From a935346fdc09d5ab442f9375e0674e92ad7d2965 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sun, 2 Jan 2011 15:11:43 +0100 Subject: usb-skeleton: Use usb_[alloc|free]_coherent instead of usb_buffer_[alloc|free] --- usb/usb-skeleton.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usb/usb-skeleton.c b/usb/usb-skeleton.c index 723deef..85861ab 100644 --- a/usb/usb-skeleton.c +++ b/usb/usb-skeleton.c @@ -145,7 +145,7 @@ static void skel_write_bulk_callback(struct urb *urb) } /* free up our allocated buffer */ - usb_buffer_free(urb->dev, urb->transfer_buffer_length, + usb_free_coherent(urb->dev, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_dma); } @@ -169,7 +169,7 @@ static ssize_t skel_write(struct file *file, const char __user *user_buffer, siz goto error; } - buf = usb_buffer_alloc(dev->udev, count, GFP_KERNEL, &urb->transfer_dma); + buf = usb_alloc_coherent(dev->udev, count, GFP_KERNEL, &urb->transfer_dma); if (!buf) { retval = -ENOMEM; goto error; @@ -199,7 +199,7 @@ exit: return count; error: - usb_buffer_free(dev->udev, count, buf, urb->transfer_dma); + usb_free_coherent(dev->udev, count, buf, urb->transfer_dma); usb_free_urb(urb); kfree(buf); return retval; -- cgit v1.2.1-18-gbd029 From ccd3e1cc6a94d540759e9a1e6973abbd0f20da2a Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 14:02:56 +0100 Subject: scull: BKL ioctl pushdown API change and use sema_init() instead init_MUTEX() --- scull/main.c | 8 ++++---- scull/scull.h | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scull/main.c b/scull/main.c index ab3feb3..1bf14a7 100644 --- a/scull/main.c +++ b/scull/main.c @@ -389,8 +389,8 @@ ssize_t scull_write(struct file *filp, const char __user *buf, size_t count, * The ioctl() implementation */ -int scull_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +int scull_ioctl(struct file *filp, unsigned int cmd, + unsigned long arg) { int err = 0, tmp; @@ -552,7 +552,7 @@ struct file_operations scull_fops = { .llseek = scull_llseek, .read = scull_read, .write = scull_write, - .ioctl = scull_ioctl, + .unlocked_ioctl = scull_ioctl, .open = scull_open, .release = scull_release, }; @@ -648,7 +648,7 @@ int scull_init_module(void) for (i = 0; i < scull_nr_devs; i++) { scull_devices[i].quantum = scull_quantum; scull_devices[i].qset = scull_qset; - init_MUTEX(&scull_devices[i].sem); + sema_init(&scull_devices[i].sem, 1); scull_setup_cdev(&scull_devices[i], i); } diff --git a/scull/scull.h b/scull/scull.h index ac7362a..5b513e4 100644 --- a/scull/scull.h +++ b/scull/scull.h @@ -128,8 +128,7 @@ ssize_t scull_read(struct file *filp, char __user *buf, size_t count, ssize_t scull_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos); loff_t scull_llseek(struct file *filp, loff_t off, int whence); -int scull_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); +int scull_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); /* -- cgit v1.2.1-18-gbd029 From 4081834fc1ee725c25ce30c2b3c4135f920a48e0 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 14:05:01 +0100 Subject: scull: pipe: BKL ioctl pushdown API change --- scull/pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scull/pipe.c b/scull/pipe.c index 58603d4..e6aa7ff 100644 --- a/scull/pipe.c +++ b/scull/pipe.c @@ -317,7 +317,7 @@ struct file_operations scull_pipe_fops = { .read = scull_p_read, .write = scull_p_write, .poll = scull_p_poll, - .ioctl = scull_ioctl, + .unlocked_ioctl = scull_ioctl, .open = scull_p_open, .release = scull_p_release, .fasync = scull_p_fasync, -- cgit v1.2.1-18-gbd029 From 0c3d783548c04c43a046ac3b75940faccf556e2c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 14:05:47 +0100 Subject: scull: pipe: Use sema_init() instead init_MUTEX() --- scull/pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scull/pipe.c b/scull/pipe.c index e6aa7ff..cba06a3 100644 --- a/scull/pipe.c +++ b/scull/pipe.c @@ -363,7 +363,7 @@ int scull_p_init(dev_t firstdev) for (i = 0; i < scull_p_nr_devs; i++) { init_waitqueue_head(&(scull_p_devices[i].inq)); init_waitqueue_head(&(scull_p_devices[i].outq)); - init_MUTEX(&scull_p_devices[i].sem); + sema_init(&scull_p_devices[i].sem, 1); scull_p_setup_cdev(scull_p_devices + i, i); } #ifdef SCULL_DEBUG -- cgit v1.2.1-18-gbd029 From 1ccbbfdcf9d8e0ae6c15fc7c2ab5fffa63c190ca Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 14:43:52 +0100 Subject: scull: access: Use sema_ini() instead init_MUTEX() --- scull/access.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scull/access.c b/scull/access.c index b534721..141ff80 100644 --- a/scull/access.c +++ b/scull/access.c @@ -82,7 +82,7 @@ struct file_operations scull_sngl_fops = { .llseek = scull_llseek, .read = scull_read, .write = scull_write, - .ioctl = scull_ioctl, + .unlocked_ioctl = scull_ioctl, .open = scull_s_open, .release = scull_s_release, }; @@ -144,7 +144,7 @@ struct file_operations scull_user_fops = { .llseek = scull_llseek, .read = scull_read, .write = scull_write, - .ioctl = scull_ioctl, + .unlocked_ioctl = scull_ioctl, .open = scull_u_open, .release = scull_u_release, }; @@ -217,7 +217,7 @@ struct file_operations scull_wusr_fops = { .llseek = scull_llseek, .read = scull_read, .write = scull_write, - .ioctl = scull_ioctl, + .unlocked_ioctl = scull_ioctl, .open = scull_w_open, .release = scull_w_release, }; @@ -263,7 +263,7 @@ static struct scull_dev *scull_c_lookfor_device(dev_t key) memset(lptr, 0, sizeof(struct scull_listitem)); lptr->key = key; scull_trim(&(lptr->device)); /* initialize it */ - init_MUTEX(&(lptr->device.sem)); + sema_init(&(lptr->device.sem), 1); /* place it in the list */ list_add(&lptr->list, &scull_c_list); @@ -316,7 +316,7 @@ struct file_operations scull_priv_fops = { .llseek = scull_llseek, .read = scull_read, .write = scull_write, - .ioctl = scull_ioctl, + .unlocked_ioctl = scull_ioctl, .open = scull_c_open, .release = scull_c_release, }; @@ -349,7 +349,7 @@ static void scull_access_setup (dev_t devno, struct scull_adev_info *devinfo) /* Initialize the device structure */ dev->quantum = scull_quantum; dev->qset = scull_qset; - init_MUTEX(&dev->sem); + sema_init(&dev->sem, 1); /* Do the cdev stuff. */ cdev_init(&dev->cdev, devinfo->fops); -- cgit v1.2.1-18-gbd029 From f233851ed1cf861259e3ef3ae58e4bf9afe6040d Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 14:47:54 +0100 Subject: scullc: BKL ioctl pushdown API change --- scullc/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scullc/main.c b/scullc/main.c index 5769f1a..814db02 100644 --- a/scullc/main.c +++ b/scullc/main.c @@ -271,8 +271,7 @@ ssize_t scullc_write (struct file *filp, const char __user *buf, size_t count, * The ioctl() implementation */ -int scullc_ioctl (struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +long scullc_ioctl (struct file *filp, unsigned int cmd, unsigned long arg) { int err = 0, ret = 0, tmp; @@ -475,7 +474,7 @@ struct file_operations scullc_fops = { .llseek = scullc_llseek, .read = scullc_read, .write = scullc_write, - .ioctl = scullc_ioctl, + .unlocked_ioctl = scullc_ioctl, .open = scullc_open, .release = scullc_release, .aio_read = scullc_aio_read, -- cgit v1.2.1-18-gbd029 From f440c4949ebc5ed0fea88cef5805419659daa8b5 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 14:48:58 +0100 Subject: scull: Change scull_ioctl signature --- scull/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scull/main.c b/scull/main.c index 1bf14a7..3c78fba 100644 --- a/scull/main.c +++ b/scull/main.c @@ -389,8 +389,7 @@ ssize_t scull_write(struct file *filp, const char __user *buf, size_t count, * The ioctl() implementation */ -int scull_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) +long scull_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int err = 0, tmp; -- cgit v1.2.1-18-gbd029 From 5f027b40d7402b782e4f26bc98ae635d0de8d316 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 14:50:37 +0100 Subject: sculld: BLK ioctl pushdown API change --- scull/scull.h | 2 +- sculld/main.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scull/scull.h b/scull/scull.h index 5b513e4..532e431 100644 --- a/scull/scull.h +++ b/scull/scull.h @@ -128,7 +128,7 @@ ssize_t scull_read(struct file *filp, char __user *buf, size_t count, ssize_t scull_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos); loff_t scull_llseek(struct file *filp, loff_t off, int whence); -int scull_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); +long scull_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); /* diff --git a/sculld/main.c b/sculld/main.c index 1039d84..8a6ecb1 100644 --- a/sculld/main.c +++ b/sculld/main.c @@ -279,8 +279,7 @@ ssize_t sculld_write (struct file *filp, const char __user *buf, size_t count, * The ioctl() implementation */ -int sculld_ioctl (struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +long sculld_ioctl (struct file *filp, unsigned int cmd, unsigned long arg) { int err = 0, ret = 0, tmp; @@ -488,7 +487,7 @@ struct file_operations sculld_fops = { .llseek = sculld_llseek, .read = sculld_read, .write = sculld_write, - .ioctl = sculld_ioctl, + .unlocked_ioctl = sculld_ioctl, .mmap = sculld_mmap, .open = sculld_open, .release = sculld_release, -- cgit v1.2.1-18-gbd029 From 29f5aec11c2c41ae6c8873a70aa5fe00ba5c36b3 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 14:51:48 +0100 Subject: scullp: BLK ioctl pushdown API change --- scullp/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scullp/main.c b/scullp/main.c index 0aba67d..20f7c3d 100644 --- a/scullp/main.c +++ b/scullp/main.c @@ -270,8 +270,7 @@ ssize_t scullp_write (struct file *filp, const char __user *buf, size_t count, * The ioctl() implementation */ -int scullp_ioctl (struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +long scullp_ioctl (struct file *filp, unsigned int cmd, unsigned long arg) { int err = 0, ret = 0, tmp; @@ -479,7 +478,7 @@ struct file_operations scullp_fops = { .llseek = scullp_llseek, .read = scullp_read, .write = scullp_write, - .ioctl = scullp_ioctl, + .unlocked_ioctl = scullp_ioctl, .mmap = scullp_mmap, .open = scullp_open, .release = scullp_release, -- cgit v1.2.1-18-gbd029 From a1d85c9227812c0715020d52bbaf042311675b0a Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 14:52:53 +0100 Subject: scullv: BKL ioctl pushdown API change --- scullv/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scullv/main.c b/scullv/main.c index 6666857..df1a6fa 100644 --- a/scullv/main.c +++ b/scullv/main.c @@ -270,8 +270,7 @@ ssize_t scullv_write (struct file *filp, const char __user *buf, size_t count, * The ioctl() implementation */ -int scullv_ioctl (struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +long scullv_ioctl (struct file *filp, unsigned int cmd, unsigned long arg) { int err = 0, ret = 0, tmp; @@ -479,7 +478,7 @@ struct file_operations scullv_fops = { .llseek = scullv_llseek, .read = scullv_read, .write = scullv_write, - .ioctl = scullv_ioctl, + .unlocked_ioctl = scullv_ioctl, .mmap = scullv_mmap, .open = scullv_open, .release = scullv_release, -- cgit v1.2.1-18-gbd029 From a0f85b756dda3ca1c4051cb011e4dda2326bc397 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 16:23:37 +0100 Subject: sbull: Remove non existing blk_fs_request wrapper --- sbull/sbull.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbull/sbull.c b/sbull/sbull.c index b826769..2f688d2 100644 --- a/sbull/sbull.c +++ b/sbull/sbull.c @@ -106,7 +106,7 @@ static void sbull_request(struct request_queue *q) while ((req = blk_peek_request(q)) != NULL) { struct sbull_dev *dev = req->rq_disk->private_data; - if (! blk_fs_request(req)) { + if (req->cmd_type != REQ_TYPE_FS) { printk (KERN_NOTICE "Skip non-fs request\n"); blk_end_request(req, 0, blk_rq_cur_bytes(req)); continue; @@ -169,7 +169,7 @@ static void sbull_full_request(struct request_queue *q) struct sbull_dev *dev = q->queuedata; while ((req = blk_peek_request(q)) != NULL) { - if (! blk_fs_request(req)) { + if (req->cmd_type != REQ_TYPE_FS) { printk (KERN_NOTICE "Skip non-fs request\n"); blk_end_request(req, 0, blk_rq_cur_bytes(req)); continue; -- cgit v1.2.1-18-gbd029 From 2d84d1fe58febc186e4738900edf8d3a652bc643 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 16:24:03 +0100 Subject: tty: Use sema_init() instead init_MUTEX() --- tty/tiny_tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tty/tiny_tty.c b/tty/tiny_tty.c index 7b42ecd..966104d 100644 --- a/tty/tiny_tty.c +++ b/tty/tiny_tty.c @@ -105,7 +105,7 @@ static int tiny_open(struct tty_struct *tty, struct file *file) if (!tiny) return -ENOMEM; - init_MUTEX(&tiny->sem); + sema_init(&tiny->sem, 1); tiny->open_count = 0; tiny->timer = NULL; -- cgit v1.2.1-18-gbd029 From ba6b8fa93edd7f36328849e30a80aa64d1ec3f03 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 16:30:01 +0100 Subject: lddbus: Remove non existing member owner in struct attribute --- lddbus/lddbus.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lddbus/lddbus.c b/lddbus/lddbus.c index fbf7be9..f3101b1 100644 --- a/lddbus/lddbus.c +++ b/lddbus/lddbus.c @@ -133,7 +133,6 @@ int register_ldd_driver(struct ldd_driver *driver) if (ret) return ret; driver->version_attr.attr.name = "version"; - driver->version_attr.attr.owner = driver->module; driver->version_attr.attr.mode = S_IRUGO; driver->version_attr.show = show_version; driver->version_attr.store = NULL; -- cgit v1.2.1-18-gbd029 From 598cf26e389d3f5b85ede61ca7dbcdff80a8fd1e Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 20:16:48 +0100 Subject: sculld: Change to new page fault API --- sculld/mmap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sculld/mmap.c b/sculld/mmap.c index 4c7341d..45a1274 100644 --- a/sculld/mmap.c +++ b/sculld/mmap.c @@ -56,16 +56,16 @@ void sculld_vma_close(struct vm_area_struct *vma) * is individually decreased, and would drop to 0. */ -struct page *sculld_vma_nopage(struct vm_area_struct *vma, - unsigned long address, int *type) +static int sculld_vma_nopage(struct vm_area_struct *vma, struct vm_fault *vmf) { unsigned long offset; struct sculld_dev *ptr, *dev = vma->vm_private_data; - struct page *page = VM_FAULT_SIGBUS; + struct page *page = NULL; void *pageptr = NULL; /* default to "missing" */ + int retval = VM_FAULT_NOPAGE; down(&dev->sem); - offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); + offset = (unsigned long)(vmf->virtual_address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); if (offset >= dev->size) goto out; /* out of range */ /* @@ -83,11 +83,12 @@ struct page *sculld_vma_nopage(struct vm_area_struct *vma, /* got it, now increment the count */ get_page(page); - if (type) - *type = VM_FAULT_MINOR; + vmf->page = page; + retval = 0; + out: up(&dev->sem); - return page; + return retval; } -- cgit v1.2.1-18-gbd029 From f2b90ee46c2115276ea1ba7b4bfc68e3304bfbfa Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 20:21:53 +0100 Subject: scullv: Change to new page fault API --- scullv/mmap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scullv/mmap.c b/scullv/mmap.c index a6cad95..4b6f48c 100644 --- a/scullv/mmap.c +++ b/scullv/mmap.c @@ -57,16 +57,16 @@ void scullv_vma_close(struct vm_area_struct *vma) * is individually decreased, and would drop to 0. */ -struct page *scullv_vma_nopage(struct vm_area_struct *vma, - unsigned long address, int *type) +static int scullv_vma_nopage(struct vm_area_struct *vma, struct vm_fault *vmf) { unsigned long offset; struct scullv_dev *ptr, *dev = vma->vm_private_data; - struct page *page = VM_FAULT_SIGBUS; + struct page *page = NULL; void *pageptr = NULL; /* default to "missing" */ + int retval = VM_FAULT_NOPAGE; down(&dev->sem); - offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); + offset = (unsigned long)(vmf->virtual_address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); if (offset >= dev->size) goto out; /* out of range */ /* @@ -91,11 +91,12 @@ struct page *scullv_vma_nopage(struct vm_area_struct *vma, /* got it, now increment the count */ get_page(page); - if (type) - *type = VM_FAULT_MINOR; + vmf->page = page; + retval = 0; + out: up(&dev->sem); - return page; + return retval; } -- cgit v1.2.1-18-gbd029 From 00dfd85f782ad1ae948bdbc5224e307918024262 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 20:24:22 +0100 Subject: scullp: Change to new page fault API --- scullp/mmap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scullp/mmap.c b/scullp/mmap.c index c84f0e8..0616dcb 100644 --- a/scullp/mmap.c +++ b/scullp/mmap.c @@ -57,16 +57,16 @@ void scullp_vma_close(struct vm_area_struct *vma) * is individually decreased, and would drop to 0. */ -struct page *scullp_vma_nopage(struct vm_area_struct *vma, - unsigned long address, int *type) +static int scullp_vma_nopage(struct vm_area_struct *vma, struct vm_fault *vmf) { unsigned long offset; struct scullp_dev *ptr, *dev = vma->vm_private_data; - struct page *page = VM_FAULT_SIGBUS; + struct page *page = NULL; void *pageptr = NULL; /* default to "missing" */ + int retval = VM_FAULT_NOPAGE; down(&dev->sem); - offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); + offset = (unsigned long)(vmf->virtual_address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); if (offset >= dev->size) goto out; /* out of range */ /* @@ -85,11 +85,12 @@ struct page *scullp_vma_nopage(struct vm_area_struct *vma, /* got it, now increment the count */ get_page(page); - if (type) - *type = VM_FAULT_MINOR; + vmf->page = page; + retval = 0; + out: up(&dev->sem); - return page; + return retval; } -- cgit v1.2.1-18-gbd029 From 2ec2ee9be5335054c975bcee9407964ee7db7686 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 20:48:32 +0100 Subject: short: Fix cast to meet workqueue handler signature --- short/short.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/short/short.c b/short/short.c index 4dc1a4b..90d3feb 100644 --- a/short/short.c +++ b/short/short.c @@ -593,7 +593,7 @@ int short_init(void) * (unused) argument. */ /* this line is in short_init() */ - INIT_WORK(&short_wq, (void (*)(void *)) short_do_tasklet); + INIT_WORK(&short_wq, (void (*)(struct work_struct *)) short_do_tasklet); /* * Now we deal with the interrupt: either kernel-based -- cgit v1.2.1-18-gbd029 From 8e0b2221d6ba3f04483e4afadc4b99a6f39f1c59 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Jan 2011 20:51:57 +0100 Subject: simple: Change to new page fault API --- simple/simple.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/simple/simple.c b/simple/simple.c index 1c286dd..e3bf01e 100644 --- a/simple/simple.c +++ b/simple/simple.c @@ -98,12 +98,11 @@ static int simple_remap_mmap(struct file *filp, struct vm_area_struct *vma) /* * The nopage version. */ -struct page *simple_vma_nopage(struct vm_area_struct *vma, - unsigned long address, int *type) +static int simple_vma_nopage(struct vm_area_struct *vma, struct vm_fault *vmf) { struct page *pageptr; unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; - unsigned long physaddr = address - vma->vm_start + offset; + unsigned long physaddr = (unsigned long) vmf->virtual_address - vma->vm_start + offset; unsigned long pageframe = physaddr >> PAGE_SHIFT; // Eventually remove these printks @@ -116,9 +115,9 @@ struct page *simple_vma_nopage(struct vm_area_struct *vma, printk (KERN_NOTICE "page->index = %ld mapping %p\n", pageptr->index, pageptr->mapping); printk (KERN_NOTICE "Page frame %ld\n", pageframe); get_page(pageptr); - if (type) - *type = VM_FAULT_MINOR; - return pageptr; + vmf->page = pageptr; + + return 0; } static struct vm_operations_struct simple_nopage_vm_ops = { -- cgit v1.2.1-18-gbd029 From c892f66346d9da6835befc9aa37e07d6f2de248c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 4 Jan 2011 00:45:41 +0100 Subject: shortprint: Remove struct pt_regs argument from shortp_interrupt handler --- shortprint/shortprint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shortprint/shortprint.c b/shortprint/shortprint.c index 17eebeb..9168aeb 100644 --- a/shortprint/shortprint.c +++ b/shortprint/shortprint.c @@ -359,7 +359,7 @@ static void shortp_do_work(void *unused) /* * The top-half interrupt handler. */ -static irqreturn_t shortp_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t shortp_interrupt(int irq, void *dev_id) { if (! shortp_output_active) return IRQ_NONE; @@ -395,7 +395,7 @@ static void shortp_timeout(unsigned long unused) /* Otherwise we must have dropped an interrupt. */ spin_unlock_irqrestore(&shortp_out_lock, flags); - shortp_interrupt(shortp_irq, NULL, NULL); + shortp_interrupt(shortp_irq, NULL); } -- cgit v1.2.1-18-gbd029 From 55c6f9b6b819b5bd6fedef1792027c1e2dd03e4d Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 4 Jan 2011 00:50:05 +0100 Subject: shortprint: Change handler function argument according current worqueue API --- shortprint/shortprint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shortprint/shortprint.c b/shortprint/shortprint.c index 9168aeb..5c74e92 100644 --- a/shortprint/shortprint.c +++ b/shortprint/shortprint.c @@ -107,7 +107,7 @@ static DECLARE_WAIT_QUEUE_HEAD(shortp_out_queue); * Feeding the output queue to the device is handled by way of a * workqueue. */ -static void shortp_do_work(void *); +static void shortp_do_work(struct work_struct *work); static DECLARE_WORK(shortp_work, shortp_do_work); static struct workqueue_struct *shortp_workqueue; @@ -321,7 +321,7 @@ out: */ -static void shortp_do_work(void *unused) +static void shortp_do_work(struct work_struct *work) { int written; unsigned long flags; -- cgit v1.2.1-18-gbd029 From daeb43133eeb489512dcc38ea4aef651a4bd2898 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 4 Jan 2011 02:34:35 +0100 Subject: tty: tiny_tty: Use seq_file instead read_proc --- tty/tiny_tty.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/tty/tiny_tty.c b/tty/tiny_tty.c index 966104d..456423d 100644 --- a/tty/tiny_tty.c +++ b/tty/tiny_tty.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -354,34 +355,21 @@ static int tiny_tiocmset(struct tty_struct *tty, struct file *file, return 0; } -static int tiny_read_proc(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int tiny_proc_show(struct seq_file *m, void *v) { struct tiny_serial *tiny; - off_t begin = 0; - int length = 0; int i; - length += sprintf(page, "tinyserinfo:1.0 driver:%s\n", DRIVER_VERSION); - for (i = 0; i < TINY_TTY_MINORS && length < PAGE_SIZE; ++i) { + seq_printf(m, "tinyserinfo:1.0 driver:%s\n", DRIVER_VERSION); + for (i = 0; i < TINY_TTY_MINORS; ++i) { tiny = tiny_table[i]; if (tiny == NULL) continue; - length += sprintf(page+length, "%d\n", i); - if ((length + begin) > (off + count)) - goto done; - if ((length + begin) < off) { - begin += length; - length = 0; - } + seq_printf(m, "%d\n", i); } - *eof = 1; -done: - if (off >= (length + begin)) - return 0; - *start = page + (off-begin); - return (count < begin+length-off) ? count : begin + length-off; + + return 0; } #define tiny_ioctl tiny_ioctl_tiocgserial @@ -505,9 +493,18 @@ static int tiny_ioctl(struct tty_struct *tty, struct file *file, return -ENOIOCTLCMD; } +static int tiny_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, tiny_proc_show, NULL); +} + + static const struct file_operations serial_proc_fops = { .owner = THIS_MODULE, - .read = tiny_read_proc, + .open = tiny_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; static struct tty_operations serial_ops = { @@ -516,9 +513,7 @@ static struct tty_operations serial_ops = { .write = tiny_write, .write_room = tiny_write_room, .set_termios = tiny_set_termios, -#ifdef CONFIG_PROC_FS .proc_fops = &serial_proc_fops, -#endif .tiocmget = tiny_tiocmget, .tiocmset = tiny_tiocmset, .ioctl = tiny_ioctl, -- cgit v1.2.1-18-gbd029 From 25ea535145e56d63183c9a2b6f4d0ec7c6f9e7a9 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 5 Jan 2011 00:18:02 +0100 Subject: sbull: blk_put_queue() is not an exported symbol anymore. Use kobject_put(q->kobj) instead --- sbull/sbull.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbull/sbull.c b/sbull/sbull.c index 2f688d2..8201f7d 100644 --- a/sbull/sbull.c +++ b/sbull/sbull.c @@ -440,7 +440,7 @@ static void sbull_exit(void) } if (dev->queue) { if (request_mode == RM_NOQUEUE) - blk_put_queue(dev->queue); + kobject_put (&dev->queue->kobj); else blk_cleanup_queue(dev->queue); } -- cgit v1.2.1-18-gbd029 From 092ebcedddd4e13243db4caa28106aaa2168239e Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 6 Jan 2011 07:43:59 +0100 Subject: sbull: Use blk_fetch_request instead blk_peek_request to dequeue requests The block layer request API changes make a requirement for block drivers to dequeue requests before signal its completition. Commit 1dfd4ab138fc9f9cad869e6110022c7cfd5544d1 changed sbull to use the new block layer API. But the patch only renamed the functions while keeping the old driver semantics. It used blk_peek_request() that does the same that elv_next_request() did. Remove the request from the queue before is not only a recomendation but a true requirement. Attempting to complete a request that remains in the queue make the kernel oops. So the last commit introduced a Bug. This patch uses blk_fetch_request() instead of blk_peek_request(). blk_fetch_request() not only returns the request in the head of the queue but also removes the request from the queue so a latter signaling of the request completition doesn't hang the system. --- sbull/sbull.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sbull/sbull.c b/sbull/sbull.c index 8201f7d..0dc474e 100644 --- a/sbull/sbull.c +++ b/sbull/sbull.c @@ -104,11 +104,11 @@ static void sbull_request(struct request_queue *q) { struct request *req; - while ((req = blk_peek_request(q)) != NULL) { + while ((req = blk_fetch_request(q)) != NULL) { struct sbull_dev *dev = req->rq_disk->private_data; if (req->cmd_type != REQ_TYPE_FS) { printk (KERN_NOTICE "Skip non-fs request\n"); - blk_end_request(req, 0, blk_rq_cur_bytes(req)); + __blk_end_request_cur(req, -EIO); continue; } // printk (KERN_NOTICE "Req dev %d dir %ld sec %ld, nr %d f %lx\n", @@ -117,7 +117,7 @@ static void sbull_request(struct request_queue *q) // req->flags); sbull_transfer(dev, blk_rq_pos(req), blk_rq_cur_sectors(req), req->buffer, rq_data_dir(req)); - blk_end_request(req, 1, blk_rq_cur_bytes(req)); + __blk_end_request_cur(req, 0); } } @@ -168,17 +168,14 @@ static void sbull_full_request(struct request_queue *q) int sectors_xferred; struct sbull_dev *dev = q->queuedata; - while ((req = blk_peek_request(q)) != NULL) { + while ((req = blk_fetch_request(q)) != NULL) { if (req->cmd_type != REQ_TYPE_FS) { printk (KERN_NOTICE "Skip non-fs request\n"); - blk_end_request(req, 0, blk_rq_cur_bytes(req)); + __blk_end_request(req, -EIO, blk_rq_cur_bytes(req)); continue; } sectors_xferred = sbull_xfer_request(dev, req); - if (! __blk_end_request(req, 1, sectors_xferred)) { - blk_start_request(req); - __blk_end_request(req, 0, blk_rq_cur_bytes(req)); - } + __blk_end_request(req, 0, sectors_xferred); } } -- cgit v1.2.1-18-gbd029 From aa2ff876a387ac18ced8bb239a2831364383de19 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 6 Jan 2011 08:15:53 +0100 Subject: README: Update project documentation --- README | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README b/README index 5dd89d6..24bfa82 100755 --- a/README +++ b/README @@ -1,15 +1,20 @@ -ldd3: Linux Device Drivers 3 examples updated to work in recent kernels +ldd3: Linux Device Drivers 3 examples updated to work with recent kernels About ----- -This project aims to keep an up to date version of the original -Linux Device Drivers 3 (http://lwn.net/Kernel/LDD3/) source code. +Linux Device Drivers 3 (http://lwn.net/Kernel/LDD3/) book is now a few years +old and most of the example drivers do not compile in recent kernels. +Also, many new changes were introduced in the kernel since version 2.6.10. +Examples for many ABIs are not covered in the book, like netlink sockets, +threaded interrupt handlers, debugfs, etc. + +This project aims to keep LDD3 example drivers up-to-date with recent kernels. The original code can be found at: http://examples.oreilly.com/9780596005900/ -Besides these examples, there is a plan to add more example drivers to show -API/ABI not cover in LDD3, for example netlink and threaded interrupt handlers. +Besides the original drivers, there is a plan to add more examples that cover +more recent kernel features like the listed before. Bugs, comments or patches: martinez.javier@gmail.com -- cgit v1.2.1-18-gbd029