mirror of
https://github.com/torvalds/linux.git
synced 2024-11-01 01:31:44 +00:00
5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
325 lines
7.5 KiB
C
325 lines
7.5 KiB
C
/*
|
|
* linux/drivers/video/hecubafb.c -- FB driver for Hecuba/Apollo controller
|
|
*
|
|
* Copyright (C) 2006, Jaya Kumar
|
|
* This work was sponsored by CIS(M) Sdn Bhd
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file COPYING in the main directory of this archive for
|
|
* more details.
|
|
*
|
|
* Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven.
|
|
* This work was possible because of apollo display code from E-Ink's website
|
|
* http://support.eink.com/community
|
|
* All information used to write this code is from public material made
|
|
* available by E-Ink on its support site. Some commands such as 0xA4
|
|
* were found by looping through cmd=0x00 thru 0xFF and supplying random
|
|
* values. There are other commands that the display is capable of,
|
|
* beyond the 5 used here but they are more complex.
|
|
*
|
|
* This driver is written to be used with the Hecuba display architecture.
|
|
* The actual display chip is called Apollo and the interface electronics
|
|
* it needs is called Hecuba.
|
|
*
|
|
* It is intended to be architecture independent. A board specific driver
|
|
* must be used to perform all the physical IO interactions. An example
|
|
* is provided as n411.c
|
|
*
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/string.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/fb.h>
|
|
#include <linux/init.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/list.h>
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <video/hecubafb.h>
|
|
|
|
/* Display specific information */
|
|
#define DPY_W 600
|
|
#define DPY_H 800
|
|
|
|
static struct fb_fix_screeninfo hecubafb_fix __devinitdata = {
|
|
.id = "hecubafb",
|
|
.type = FB_TYPE_PACKED_PIXELS,
|
|
.visual = FB_VISUAL_MONO01,
|
|
.xpanstep = 0,
|
|
.ypanstep = 0,
|
|
.ywrapstep = 0,
|
|
.line_length = DPY_W,
|
|
.accel = FB_ACCEL_NONE,
|
|
};
|
|
|
|
static struct fb_var_screeninfo hecubafb_var __devinitdata = {
|
|
.xres = DPY_W,
|
|
.yres = DPY_H,
|
|
.xres_virtual = DPY_W,
|
|
.yres_virtual = DPY_H,
|
|
.bits_per_pixel = 1,
|
|
.nonstd = 1,
|
|
};
|
|
|
|
/* main hecubafb functions */
|
|
|
|
static void apollo_send_data(struct hecubafb_par *par, unsigned char data)
|
|
{
|
|
/* set data */
|
|
par->board->set_data(par, data);
|
|
|
|
/* set DS low */
|
|
par->board->set_ctl(par, HCB_DS_BIT, 0);
|
|
|
|
/* wait for ack */
|
|
par->board->wait_for_ack(par, 0);
|
|
|
|
/* set DS hi */
|
|
par->board->set_ctl(par, HCB_DS_BIT, 1);
|
|
|
|
/* wait for ack to clear */
|
|
par->board->wait_for_ack(par, 1);
|
|
}
|
|
|
|
static void apollo_send_command(struct hecubafb_par *par, unsigned char data)
|
|
{
|
|
/* command so set CD to high */
|
|
par->board->set_ctl(par, HCB_CD_BIT, 1);
|
|
|
|
/* actually strobe with command */
|
|
apollo_send_data(par, data);
|
|
|
|
/* clear CD back to low */
|
|
par->board->set_ctl(par, HCB_CD_BIT, 0);
|
|
}
|
|
|
|
static void hecubafb_dpy_update(struct hecubafb_par *par)
|
|
{
|
|
int i;
|
|
unsigned char *buf = (unsigned char __force *)par->info->screen_base;
|
|
|
|
apollo_send_command(par, APOLLO_START_NEW_IMG);
|
|
|
|
for (i=0; i < (DPY_W*DPY_H/8); i++) {
|
|
apollo_send_data(par, *(buf++));
|
|
}
|
|
|
|
apollo_send_command(par, APOLLO_STOP_IMG_DATA);
|
|
apollo_send_command(par, APOLLO_DISPLAY_IMG);
|
|
}
|
|
|
|
/* this is called back from the deferred io workqueue */
|
|
static void hecubafb_dpy_deferred_io(struct fb_info *info,
|
|
struct list_head *pagelist)
|
|
{
|
|
hecubafb_dpy_update(info->par);
|
|
}
|
|
|
|
static void hecubafb_fillrect(struct fb_info *info,
|
|
const struct fb_fillrect *rect)
|
|
{
|
|
struct hecubafb_par *par = info->par;
|
|
|
|
sys_fillrect(info, rect);
|
|
|
|
hecubafb_dpy_update(par);
|
|
}
|
|
|
|
static void hecubafb_copyarea(struct fb_info *info,
|
|
const struct fb_copyarea *area)
|
|
{
|
|
struct hecubafb_par *par = info->par;
|
|
|
|
sys_copyarea(info, area);
|
|
|
|
hecubafb_dpy_update(par);
|
|
}
|
|
|
|
static void hecubafb_imageblit(struct fb_info *info,
|
|
const struct fb_image *image)
|
|
{
|
|
struct hecubafb_par *par = info->par;
|
|
|
|
sys_imageblit(info, image);
|
|
|
|
hecubafb_dpy_update(par);
|
|
}
|
|
|
|
/*
|
|
* this is the slow path from userspace. they can seek and write to
|
|
* the fb. it's inefficient to do anything less than a full screen draw
|
|
*/
|
|
static ssize_t hecubafb_write(struct fb_info *info, const char __user *buf,
|
|
size_t count, loff_t *ppos)
|
|
{
|
|
struct hecubafb_par *par = info->par;
|
|
unsigned long p = *ppos;
|
|
void *dst;
|
|
int err = 0;
|
|
unsigned long total_size;
|
|
|
|
if (info->state != FBINFO_STATE_RUNNING)
|
|
return -EPERM;
|
|
|
|
total_size = info->fix.smem_len;
|
|
|
|
if (p > total_size)
|
|
return -EFBIG;
|
|
|
|
if (count > total_size) {
|
|
err = -EFBIG;
|
|
count = total_size;
|
|
}
|
|
|
|
if (count + p > total_size) {
|
|
if (!err)
|
|
err = -ENOSPC;
|
|
|
|
count = total_size - p;
|
|
}
|
|
|
|
dst = (void __force *) (info->screen_base + p);
|
|
|
|
if (copy_from_user(dst, buf, count))
|
|
err = -EFAULT;
|
|
|
|
if (!err)
|
|
*ppos += count;
|
|
|
|
hecubafb_dpy_update(par);
|
|
|
|
return (err) ? err : count;
|
|
}
|
|
|
|
static struct fb_ops hecubafb_ops = {
|
|
.owner = THIS_MODULE,
|
|
.fb_read = fb_sys_read,
|
|
.fb_write = hecubafb_write,
|
|
.fb_fillrect = hecubafb_fillrect,
|
|
.fb_copyarea = hecubafb_copyarea,
|
|
.fb_imageblit = hecubafb_imageblit,
|
|
};
|
|
|
|
static struct fb_deferred_io hecubafb_defio = {
|
|
.delay = HZ,
|
|
.deferred_io = hecubafb_dpy_deferred_io,
|
|
};
|
|
|
|
static int __devinit hecubafb_probe(struct platform_device *dev)
|
|
{
|
|
struct fb_info *info;
|
|
struct hecuba_board *board;
|
|
int retval = -ENOMEM;
|
|
int videomemorysize;
|
|
unsigned char *videomemory;
|
|
struct hecubafb_par *par;
|
|
|
|
/* pick up board specific routines */
|
|
board = dev->dev.platform_data;
|
|
if (!board)
|
|
return -EINVAL;
|
|
|
|
/* try to count device specific driver, if can't, platform recalls */
|
|
if (!try_module_get(board->owner))
|
|
return -ENODEV;
|
|
|
|
videomemorysize = (DPY_W*DPY_H)/8;
|
|
|
|
if (!(videomemory = vmalloc(videomemorysize)))
|
|
return retval;
|
|
|
|
memset(videomemory, 0, videomemorysize);
|
|
|
|
info = framebuffer_alloc(sizeof(struct hecubafb_par), &dev->dev);
|
|
if (!info)
|
|
goto err_fballoc;
|
|
|
|
info->screen_base = (char __force __iomem *)videomemory;
|
|
info->fbops = &hecubafb_ops;
|
|
|
|
info->var = hecubafb_var;
|
|
info->fix = hecubafb_fix;
|
|
info->fix.smem_len = videomemorysize;
|
|
par = info->par;
|
|
par->info = info;
|
|
par->board = board;
|
|
par->send_command = apollo_send_command;
|
|
par->send_data = apollo_send_data;
|
|
|
|
info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB;
|
|
|
|
info->fbdefio = &hecubafb_defio;
|
|
fb_deferred_io_init(info);
|
|
|
|
retval = register_framebuffer(info);
|
|
if (retval < 0)
|
|
goto err_fbreg;
|
|
platform_set_drvdata(dev, info);
|
|
|
|
printk(KERN_INFO
|
|
"fb%d: Hecuba frame buffer device, using %dK of video memory\n",
|
|
info->node, videomemorysize >> 10);
|
|
|
|
/* this inits the dpy */
|
|
retval = par->board->init(par);
|
|
if (retval < 0)
|
|
goto err_fbreg;
|
|
|
|
return 0;
|
|
err_fbreg:
|
|
framebuffer_release(info);
|
|
err_fballoc:
|
|
vfree(videomemory);
|
|
module_put(board->owner);
|
|
return retval;
|
|
}
|
|
|
|
static int __devexit hecubafb_remove(struct platform_device *dev)
|
|
{
|
|
struct fb_info *info = platform_get_drvdata(dev);
|
|
|
|
if (info) {
|
|
struct hecubafb_par *par = info->par;
|
|
fb_deferred_io_cleanup(info);
|
|
unregister_framebuffer(info);
|
|
vfree((void __force *)info->screen_base);
|
|
if (par->board->remove)
|
|
par->board->remove(par);
|
|
module_put(par->board->owner);
|
|
framebuffer_release(info);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver hecubafb_driver = {
|
|
.probe = hecubafb_probe,
|
|
.remove = hecubafb_remove,
|
|
.driver = {
|
|
.owner = THIS_MODULE,
|
|
.name = "hecubafb",
|
|
},
|
|
};
|
|
|
|
static int __init hecubafb_init(void)
|
|
{
|
|
return platform_driver_register(&hecubafb_driver);
|
|
}
|
|
|
|
static void __exit hecubafb_exit(void)
|
|
{
|
|
platform_driver_unregister(&hecubafb_driver);
|
|
}
|
|
|
|
module_init(hecubafb_init);
|
|
module_exit(hecubafb_exit);
|
|
|
|
MODULE_DESCRIPTION("fbdev driver for Hecuba/Apollo controller");
|
|
MODULE_AUTHOR("Jaya Kumar");
|
|
MODULE_LICENSE("GPL");
|