Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S262518AbVA0AnP (ORCPT ); Wed, 26 Jan 2005 19:43:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262479AbVA0AT5 (ORCPT ); Wed, 26 Jan 2005 19:19:57 -0500 Received: from ztxmail03.ztx.compaq.com ([161.114.1.207]:64270 "EHLO ztxmail03.ztx.compaq.com") by vger.kernel.org with ESMTP id S262483AbVAZWlq convert rfc822-to-8bit (ORCPT ); Wed, 26 Jan 2005 17:41:46 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Subject: RE: [PATCH] Convert cciss to compat_ioctl Date: Wed, 26 Jan 2005 16:41:44 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] Convert cciss to compat_ioctl Thread-Index: AcT9M6zxxELdJ8JTTDyJxJU1u36/kgGq/W9g From: "Miller, Mike (OS Dev)" To: "Andi Kleen" , Cc: X-OriginalArrivalTime: 26 Jan 2005 22:41:45.0327 (UTC) FILETIME=[36A1BFF0:01C503F8] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7338 Lines: 236 > -----Original Message----- > Convert the cciss driver to compat_ioctl. This cleans up a lot > of code. > > I don't have such hardware thus this is only compile tested. > > This requires the block device compat_ioctl patch I sent earlier. Sorry I took so long to reply to this. I finally had a chance to test the change and it looks OK. mikem > > Signed-off-by: Andi Kleen > > diff -u linux-2.6.11-rc1-bk4/drivers/block/cciss.c-o > linux-2.6.11-rc1-bk4/drivers/block/cciss.c > --- linux-2.6.11-rc1-bk4/drivers/block/cciss.c-o > 2005-01-14 10:12:17.000000000 +0100 > +++ linux-2.6.11-rc1-bk4/drivers/block/cciss.c > 2005-01-18 06:30:43.000000000 +0100 > @@ -146,11 +146,18 @@ > static void cciss_procinit(int i) {} > #endif /* CONFIG_PROC_FS */ > > +#ifdef CONFIG_COMPAT > +static int cciss_compat_ioctl(struct file *f, unsigned cmd, > unsigned long arg); > +#endif > + > static struct block_device_operations cciss_fops = { > .owner = THIS_MODULE, > .open = cciss_open, > .release = cciss_release, > .ioctl = cciss_ioctl, > +#ifdef CONFIG_COMPAT > + .compat_ioctl = cciss_compat_ioctl, > +#endif > .revalidate_disk= cciss_revalidate, > }; > > @@ -477,80 +484,50 @@ > } > > #ifdef CONFIG_COMPAT > -/* for AMD 64 bit kernel compatibility with 32-bit userland ioctls */ > -extern long sys_ioctl(unsigned int fd, unsigned int cmd, > unsigned long arg); > -extern int > -register_ioctl32_conversion(unsigned int cmd, int > (*handler)(unsigned int, > - unsigned int, unsigned long, struct file *)); > -extern int unregister_ioctl32_conversion(unsigned int cmd); > - > -static int cciss_ioctl32_passthru(unsigned int fd, unsigned > cmd, unsigned long arg, struct file *file); > -static int cciss_ioctl32_big_passthru(unsigned int fd, > unsigned cmd, unsigned long arg, > - struct file *file); > - > -typedef int (*handler_type) (unsigned int, unsigned int, > unsigned long, struct file *); > - > -static struct ioctl32_map { > - unsigned int cmd; > - handler_type handler; > - int registered; > -} cciss_ioctl32_map[] = { > - { CCISS_GETPCIINFO, (handler_type) sys_ioctl, 0 }, > - { CCISS_GETINTINFO, (handler_type) sys_ioctl, 0 }, > - { CCISS_SETINTINFO, (handler_type) sys_ioctl, 0 }, > - { CCISS_GETNODENAME, (handler_type) sys_ioctl, 0 }, > - { CCISS_SETNODENAME, (handler_type) sys_ioctl, 0 }, > - { CCISS_GETHEARTBEAT, (handler_type) sys_ioctl, 0 }, > - { CCISS_GETBUSTYPES, (handler_type) sys_ioctl, 0 }, > - { CCISS_GETFIRMVER, (handler_type) sys_ioctl, 0 }, > - { CCISS_GETDRIVVER, (handler_type) sys_ioctl, 0 }, > - { CCISS_REVALIDVOLS, (handler_type) sys_ioctl, 0 }, > - { CCISS_PASSTHRU32, cciss_ioctl32_passthru, 0 }, > - { CCISS_DEREGDISK, (handler_type) sys_ioctl, 0 }, > - { CCISS_REGNEWDISK, (handler_type) sys_ioctl, 0 }, > - { CCISS_REGNEWD, (handler_type) sys_ioctl, 0 }, > - { CCISS_RESCANDISK, (handler_type) sys_ioctl, 0 }, > - { CCISS_GETLUNINFO, (handler_type) sys_ioctl, 0 }, > - { CCISS_BIG_PASSTHRU32, cciss_ioctl32_big_passthru, 0 }, > -}; > -#define NCCISS_IOCTL32_ENTRIES (sizeof(cciss_ioctl32_map) / > sizeof(cciss_ioctl32_map[0])) > -static void register_cciss_ioctl32(void) > -{ > - int i, rc; > > - for (i=0; i < NCCISS_IOCTL32_ENTRIES; i++) { > - rc = register_ioctl32_conversion( > - cciss_ioctl32_map[i].cmd, > - cciss_ioctl32_map[i].handler); > - if (rc != 0) { > - printk(KERN_WARNING "cciss: failed to register " > - "32 bit compatible ioctl 0x%08x\n", > - cciss_ioctl32_map[i].cmd); > - cciss_ioctl32_map[i].registered = 0; > - } else > - cciss_ioctl32_map[i].registered = 1; > - } > -} > -static void unregister_cciss_ioctl32(void) > +static int do_ioctl(struct file *f, unsigned cmd, unsigned long arg) > { > - int i, rc; > + int ret; > + lock_kernel(); > + ret = cciss_ioctl(f->f_dentry->d_inode, f, cmd, arg); > + unlock_kernel(); > + return ret; > +} > > - for (i=0; i < NCCISS_IOCTL32_ENTRIES; i++) { > - if (!cciss_ioctl32_map[i].registered) > - continue; > - rc = unregister_ioctl32_conversion( > - cciss_ioctl32_map[i].cmd); > - if (rc == 0) { > - cciss_ioctl32_map[i].registered = 0; > - continue; > - } > - printk(KERN_WARNING "cciss: failed to unregister " > - "32 bit compatible ioctl 0x%08x\n", > - cciss_ioctl32_map[i].cmd); > +static int cciss_ioctl32_passthru(struct file *f, unsigned > cmd, unsigned long arg); > +static int cciss_ioctl32_big_passthru(struct file *f, > unsigned cmd, unsigned long arg); > + > +static long cciss_compat_ioctl(struct file *f, unsigned cmd, > unsigned long arg) > +{ > + switch (cmd) { > + case CCISS_GETPCIINFO: > + case CCISS_GETINTINFO: > + case CCISS_SETINTINFO: > + case CCISS_GETNODENAME: > + case CCISS_SETNODENAME: > + case CCISS_GETHEARTBEAT: > + case CCISS_GETBUSTYPES: > + case CCISS_GETFIRMVER: > + case CCISS_GETDRIVVER: > + case CCISS_REVALIDVOLS: > + case CCISS_DEREGDISK: > + case CCISS_REGNEWDISK: > + case CCISS_REGNEWD: > + case CCISS_RESCANDISK: > + case CCISS_GETLUNINFO: > + return do_ioctl(f, cmd, arg); > + > + case CCISS_PASSTHRU32: > + return cciss_ioctl32_passthru(f, cmd, arg); > + case CCISS_BIG_PASSTHRU32: > + return cciss_ioctl32_big_passthru(f, cmd, arg); > + > + default: > + return -ENOIOCTLCMD; > } > } > -int cciss_ioctl32_passthru(unsigned int fd, unsigned cmd, > unsigned long arg, > - struct file *file) > + > +static int cciss_ioctl32_passthru(struct file *f, unsigned > cmd, unsigned long arg) > { > IOCTL32_Command_struct __user *arg32 = > (IOCTL32_Command_struct __user *) arg; > @@ -571,7 +548,7 @@ > if (err) > return -EFAULT; > > - err = sys_ioctl(fd, CCISS_PASSTHRU, (unsigned long) p); > + err = do_ioctl(f, CCISS_PASSTHRU, (unsigned long) p); > if (err) > return err; > err |= copy_in_user(&arg32->error_info, &p->error_info, > sizeof(arg32->error_info)); > @@ -580,8 +557,7 @@ > return err; > } > > -int cciss_ioctl32_big_passthru(unsigned int fd, unsigned > cmd, unsigned long arg, > - struct file *file) > +static int cciss_ioctl32_big_passthru(struct file *file, > unsigned cmd, unsigned long arg) > { > BIG_IOCTL32_Command_struct __user *arg32 = > (BIG_IOCTL32_Command_struct __user *) arg; > @@ -603,7 +579,7 @@ > if (err) > return -EFAULT; > > - err = sys_ioctl(fd, CCISS_BIG_PASSTHRU, (unsigned long) p); > + err = do_ioctl(file, CCISS_BIG_PASSTHRU, (unsigned long) p); > if (err) > return err; > err |= copy_in_user(&arg32->error_info, &p->error_info, > sizeof(arg32->error_info)); > @@ -611,9 +587,6 @@ > return -EFAULT; > return err; > } > -#else > -static inline void register_cciss_ioctl32(void) {} > -static inline void unregister_cciss_ioctl32(void) {} > #endif > /* > * ioctl > @@ -2915,7 +2888,6 @@ > > static int __init init_cciss_module(void) > { > - register_cciss_ioctl32(); > return ( cciss_init()); > } > > @@ -2923,7 +2895,6 @@ > { > int i; > > - unregister_cciss_ioctl32(); > pci_unregister_driver(&cciss_pci_driver); > /* double check that all controller entrys have been removed */ > for (i=0; i< MAX_CTLR; i++) > - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/