]> err.no Git - linux-2.6/commitdiff
device create: char: convert device_create to device_create_drvdata
authorGreg Kroah-Hartman <gregkh@suse.de>
Wed, 21 May 2008 19:52:33 +0000 (12:52 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 22 Jul 2008 04:54:41 +0000 (21:54 -0700)
device_create() is race-prone, so use the race-free
device_create_drvdata() instead as device_create() is going away.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
18 files changed:
drivers/char/dsp56k.c
drivers/char/ip2/ip2main.c
drivers/char/ipmi/ipmi_devintf.c
drivers/char/istallion.c
drivers/char/lp.c
drivers/char/mem.c
drivers/char/misc.c
drivers/char/pcmcia/cm4000_cs.c
drivers/char/pcmcia/cm4040_cs.c
drivers/char/ppdev.c
drivers/char/raw.c
drivers/char/snsc.c
drivers/char/stallion.c
drivers/char/tty_io.c
drivers/char/vc_screen.c
drivers/char/viotape.c
drivers/char/vt.c
drivers/char/xilinx_hwicap/xilinx_hwicap.c

index b9a30c30e2b8682a85822c764b8b05f3bd3bdb79..33c466a4888f092c15475601b503a473808a20fc 100644 (file)
@@ -500,7 +500,8 @@ static int __init dsp56k_init_driver(void)
                err = PTR_ERR(dsp56k_class);
                goto out_chrdev;
        }
-       device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), "dsp56k");
+       device_create_drvdata(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0),
+                             NULL, "dsp56k");
 
        printk(banner);
        goto out;
index 5dc74404058f6eb46941a4af8bad71dfe3a5229e..9cb48fcd316c775007e596dc66a6adb0494ddfd9 100644 (file)
@@ -718,12 +718,12 @@ ip2_loadmain(int *iop, int *irqp)
                        }
 
                        if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
-                               device_create(ip2_class, NULL,
-                                               MKDEV(IP2_IPL_MAJOR, 4 * i),
-                                               "ipl%d", i);
-                               device_create(ip2_class, NULL,
-                                               MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
-                                               "stat%d", i);
+                               device_create_drvdata(ip2_class, NULL,
+                                                     MKDEV(IP2_IPL_MAJOR, 4 * i),
+                                                     NULL, "ipl%d", i);
+                               device_create_drvdata(ip2_class, NULL,
+                                                     MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
+                                                     NULL, "stat%d", i);
 
                            for ( box = 0; box < ABS_MAX_BOXES; ++box )
                            {
index c11a40483459f3bd581dd5429f65606b1d882f67..64e1c169e826814c922c6937f738424ba819891b 100644 (file)
@@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
        entry->dev = dev;
 
        mutex_lock(&reg_list_mutex);
-       device_create(ipmi_class, device, dev, "ipmi%d", if_num);
+       device_create_drvdata(ipmi_class, device, dev, NULL, "ipmi%d", if_num);
        list_add(&entry->link, &reg_list);
        mutex_unlock(&reg_list_mutex);
 }
index 7930fba4bafcc930a8333da54c8bfe0c4aa6b272..24637bbf02f7e3b6dd37ad18d2cdf63b96a74dd8 100644 (file)
@@ -4599,8 +4599,9 @@ static int __init istallion_module_init(void)
 
        istallion_class = class_create(THIS_MODULE, "staliomem");
        for (i = 0; i < 4; i++)
-               device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
-                             "staliomem%d", i);
+               device_create_drvdata(istallion_class, NULL,
+                                     MKDEV(STL_SIOMEMMAJOR, i),
+                                     NULL, "staliomem%d", i);
 
        return 0;
 err_deinit:
index 71abb4c33aa249d748826a317be08a3b8a4f7cd9..3f2719b9f77b5fca364477dfa7d096c66be759cb 100644 (file)
@@ -813,7 +813,8 @@ static int lp_register(int nr, struct parport *port)
        if (reset)
                lp_reset(nr);
 
-       device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), "lp%d", nr);
+       device_create_drvdata(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL,
+                             "lp%d", nr);
 
        printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, 
               (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
index b6772d657547a4e25f275f2a1bd4bc29ac3188e4..c2dba82eb5f7fa82bdb874b17f605ab01f80fb1f 100644 (file)
@@ -989,9 +989,9 @@ static int __init chr_dev_init(void)
 
        mem_class = class_create(THIS_MODULE, "mem");
        for (i = 0; i < ARRAY_SIZE(devlist); i++)
-               device_create(mem_class, NULL,
-                             MKDEV(MEM_MAJOR, devlist[i].minor),
-                             devlist[i].name);
+               device_create_drvdata(mem_class, NULL,
+                                     MKDEV(MEM_MAJOR, devlist[i].minor),
+                                     NULL, devlist[i].name);
 
        return 0;
 }
index 6e1563c3d30aea0da63650ea8a3a64daaf6727be..999aa779c08a710601fabc93cacb6f52229c53ba 100644 (file)
@@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc)
                misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
        dev = MKDEV(MISC_MAJOR, misc->minor);
 
-       misc->this_device = device_create(misc_class, misc->parent, dev,
-                                         "%s", misc->name);
+       misc->this_device = device_create_drvdata(misc_class, misc->parent,
+                                                 dev, NULL, "%s", misc->name);
        if (IS_ERR(misc->this_device)) {
                err = PTR_ERR(misc->this_device);
                goto out;
index e4a4fbd37d7a3062cd8d91faf397cbdf28443186..f070ae7bd91a1d905eab711a6ee8d013ae8f3eeb 100644 (file)
@@ -1896,7 +1896,7 @@ static int cm4000_probe(struct pcmcia_device *link)
                return ret;
        }
 
-       device_create(cmm_class, NULL, MKDEV(major, i), "cmm%d", i);
+       device_create_drvdata(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
 
        return 0;
 }
index 6181f8a9b0bd0309cb4670dd0d572af91fc8689f..0b5934bef7a4301049f19c8d82393544742f4a84 100644 (file)
@@ -653,7 +653,8 @@ static int reader_probe(struct pcmcia_device *link)
                return ret;
        }
 
-       device_create(cmx_class, NULL, MKDEV(major, i), "cmx%d", i);
+       device_create_drvdata(cmx_class, NULL, MKDEV(major, i), NULL,
+                             "cmx%d", i);
 
        return 0;
 }
index f6e6acadd9a017d98b562a9c2f2da7178a412161..7af7a7e6b9c2e570ff53eff4152e5f61d6cf7738 100644 (file)
@@ -752,8 +752,9 @@ static const struct file_operations pp_fops = {
 
 static void pp_attach(struct parport *port)
 {
-       device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number),
-                       "parport%d", port->number);
+       device_create_drvdata(ppdev_class, port->dev,
+                             MKDEV(PP_MAJOR, port->number),
+                             NULL, "parport%d", port->number);
 }
 
 static void pp_detach(struct parport *port)
index 505fcbe884a4aad394ae212396677d258b3d25fb..47b8cf281d4a79766c0717dec1ea4380d2bf9717 100644 (file)
@@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp,
 static void bind_device(struct raw_config_request *rq)
 {
        device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
-       device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
-                     "raw%d", rq->raw_minor);
+       device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
+                             NULL, "raw%d", rq->raw_minor);
 }
 
 /*
@@ -283,7 +283,8 @@ static int __init raw_init(void)
                ret = PTR_ERR(raw_class);
                goto error_region;
        }
-       device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), "rawctl");
+       device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL,
+                             "rawctl");
 
        return 0;
 
index 0b799ac1b04957f501d4c50539f58e7ee28199cd..3ce60df14c0a623f5aff950148f034938988a5f9 100644 (file)
@@ -444,7 +444,8 @@ scdrv_init(void)
                                continue;
                        }
 
-                       device_create(snsc_class, NULL, dev, "%s", devname);
+                       device_create_drvdata(snsc_class, NULL, dev, NULL,
+                                             "%s", devname);
 
                        ia64_sn_irtr_intr_enable(scd->scd_nasid,
                                                 0 /*ignored */ ,
index 0243efb0be957df493937e1fbfb5ad44b215d486..45aeeeab9f4a925b383e80b53bd8c69b4ccc729e 100644 (file)
@@ -4753,8 +4753,8 @@ static int __init stallion_module_init(void)
        if (IS_ERR(stallion_class))
                printk("STALLION: failed to create class\n");
        for (i = 0; i < 4; i++)
-               device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
-                             "staliomem%d", i);
+               device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
+                                     NULL, "staliomem%d", i);
 
        return 0;
 err_unrtty:
index 82f6a8c863320101f3f8a677f34192d03bded8d2..dc9202d2dd63ccbd1895657e4b506549384eb713 100644 (file)
@@ -4045,7 +4045,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index,
        else
                tty_line_name(driver, index, name);
 
-       return device_create(tty_class, device, dev, name);
+       return device_create_drvdata(tty_class, device, dev, NULL, name);
 }
 
 /**
@@ -4323,20 +4323,22 @@ static int __init tty_init(void)
        if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
                panic("Couldn't register /dev/tty driver\n");
-       device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), "tty");
+       device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL,
+                             "tty");
 
        cdev_init(&console_cdev, &console_fops);
        if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
                panic("Couldn't register /dev/console driver\n");
-       device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), "console");
+       device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL,
+                             "console");
 
 #ifdef CONFIG_UNIX98_PTYS
        cdev_init(&ptmx_cdev, &ptmx_fops);
        if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
                panic("Couldn't register /dev/ptmx driver\n");
-       device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), "ptmx");
+       device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
 #endif
 
 #ifdef CONFIG_VT
@@ -4344,7 +4346,7 @@ static int __init tty_init(void)
        if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
            register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
                panic("Couldn't register /dev/tty0 driver\n");
-       device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0");
+       device_create_drvdata(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
 
        vty_init();
 #endif
index eebfad2777d29ac9bfd7134eab259c11c7bd5a79..c2ae52dd53d1a6447affa697afaa53c9f9f9f7f7 100644 (file)
@@ -481,10 +481,10 @@ static struct class *vc_class;
 
 void vcs_make_sysfs(struct tty_struct *tty)
 {
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
-                       "vcs%u", tty->index + 1);
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
-                       "vcsa%u", tty->index + 1);
+       device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
+                             NULL, "vcs%u", tty->index + 1);
+       device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
+                             NULL, "vcsa%u", tty->index + 1);
 }
 
 void vcs_remove_sysfs(struct tty_struct *tty)
@@ -499,7 +499,7 @@ int __init vcs_init(void)
                panic("unable to get major %d for vcs device", VCS_MAJOR);
        vc_class = class_create(THIS_MODULE, "vc");
 
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), "vcs");
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), "vcsa");
+       device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
+       device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
        return 0;
 }
index e5da98d8f9cd70f493ecb8c9d7521639f937e779..7a70a40ad639855b4f3880386ef7b34f47d71f46 100644 (file)
@@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
        state[i].cur_part = 0;
        for (j = 0; j < MAX_PARTITIONS; ++j)
                state[i].part_stat_rwi[j] = VIOT_IDLE;
-       device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
-                       "iseries!vt%d", i);
-       device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
-                       "iseries!nvt%d", i);
+       device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
+                             NULL, "iseries!vt%d", i);
+       device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
+                             NULL, "iseries!nvt%d", i);
        printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries "
                        "resource %10.10s type %4.4s, model %3.3s\n",
                        i, viotape_unitinfo[i].rsrcname,
index 935f1c207a1f0edfe7056fee448e4ff337164229..e32a076d5f1f8f182025341d98d3a89f25a9f4f8 100644 (file)
@@ -3425,9 +3425,10 @@ int register_con_driver(const struct consw *csw, int first, int last)
        if (retval)
                goto err;
 
-       con_driver->dev = device_create(vtconsole_class, NULL,
-                                       MKDEV(0, con_driver->node),
-                                       "vtcon%i", con_driver->node);
+       con_driver->dev = device_create_drvdata(vtconsole_class, NULL,
+                                               MKDEV(0, con_driver->node),
+                                               NULL, "vtcon%i",
+                                               con_driver->node);
 
        if (IS_ERR(con_driver->dev)) {
                printk(KERN_WARNING "Unable to create device for %s; "
@@ -3535,9 +3536,10 @@ static int __init vtconsole_class_init(void)
                struct con_driver *con = &registered_con_driver[i];
 
                if (con->con && !con->dev) {
-                       con->dev = device_create(vtconsole_class, NULL,
-                                                MKDEV(0, con->node),
-                                                "vtcon%i", con->node);
+                       con->dev = device_create_drvdata(vtconsole_class, NULL,
+                                                        MKDEV(0, con->node),
+                                                        NULL, "vtcon%i",
+                                                        con->node);
 
                        if (IS_ERR(con->dev)) {
                                printk(KERN_WARNING "Unable to create "
index 1e1b81e57cdcf7060739a42bd6862d2d5a2caab7..51966ccf4ea3f56c4449f88c93906ab81e136111 100644 (file)
@@ -658,8 +658,9 @@ static int __devinit hwicap_setup(struct device *dev, int id,
                dev_err(dev, "cdev_add() failed\n");
                goto failed3;
        }
-       /*  devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */
-       device_create(icap_class, dev, devt, "%s%d", DRIVER_NAME, id);
+
+       device_create_drvdata(icap_class, dev, devt, NULL,
+                             "%s%d", DRIVER_NAME, id);
        return 0;               /* success */
 
  failed3: