Commit 47aa5793 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

device create: char: convert device_create to device_create_drvdata

device_create() is race-prone, so use the race-free
device_create_drvdata() instead as device_create() is going away.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f79f0605
...@@ -500,7 +500,8 @@ static int __init dsp56k_init_driver(void) ...@@ -500,7 +500,8 @@ static int __init dsp56k_init_driver(void)
err = PTR_ERR(dsp56k_class); err = PTR_ERR(dsp56k_class);
goto out_chrdev; 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); printk(banner);
goto out; goto out;
......
...@@ -718,12 +718,12 @@ ip2_loadmain(int *iop, int *irqp) ...@@ -718,12 +718,12 @@ ip2_loadmain(int *iop, int *irqp)
} }
if ( NULL != ( pB = i2BoardPtrTable[i] ) ) { if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
device_create(ip2_class, NULL, device_create_drvdata(ip2_class, NULL,
MKDEV(IP2_IPL_MAJOR, 4 * i), MKDEV(IP2_IPL_MAJOR, 4 * i),
"ipl%d", i); NULL, "ipl%d", i);
device_create(ip2_class, NULL, device_create_drvdata(ip2_class, NULL,
MKDEV(IP2_IPL_MAJOR, 4 * i + 1), MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
"stat%d", i); NULL, "stat%d", i);
for ( box = 0; box < ABS_MAX_BOXES; ++box ) for ( box = 0; box < ABS_MAX_BOXES; ++box )
{ {
......
...@@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device) ...@@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
entry->dev = dev; entry->dev = dev;
mutex_lock(&reg_list_mutex); 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); list_add(&entry->link, &reg_list);
mutex_unlock(&reg_list_mutex); mutex_unlock(&reg_list_mutex);
} }
......
...@@ -4599,8 +4599,9 @@ static int __init istallion_module_init(void) ...@@ -4599,8 +4599,9 @@ static int __init istallion_module_init(void)
istallion_class = class_create(THIS_MODULE, "staliomem"); istallion_class = class_create(THIS_MODULE, "staliomem");
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), device_create_drvdata(istallion_class, NULL,
"staliomem%d", i); MKDEV(STL_SIOMEMMAJOR, i),
NULL, "staliomem%d", i);
return 0; return 0;
err_deinit: err_deinit:
......
...@@ -813,7 +813,8 @@ static int lp_register(int nr, struct parport *port) ...@@ -813,7 +813,8 @@ static int lp_register(int nr, struct parport *port)
if (reset) if (reset)
lp_reset(nr); 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, printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
(port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven"); (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
......
...@@ -989,9 +989,9 @@ static int __init chr_dev_init(void) ...@@ -989,9 +989,9 @@ static int __init chr_dev_init(void)
mem_class = class_create(THIS_MODULE, "mem"); mem_class = class_create(THIS_MODULE, "mem");
for (i = 0; i < ARRAY_SIZE(devlist); i++) for (i = 0; i < ARRAY_SIZE(devlist); i++)
device_create(mem_class, NULL, device_create_drvdata(mem_class, NULL,
MKDEV(MEM_MAJOR, devlist[i].minor), MKDEV(MEM_MAJOR, devlist[i].minor),
devlist[i].name); NULL, devlist[i].name);
return 0; return 0;
} }
......
...@@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc) ...@@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc)
misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
dev = MKDEV(MISC_MAJOR, misc->minor); dev = MKDEV(MISC_MAJOR, misc->minor);
misc->this_device = device_create(misc_class, misc->parent, dev, misc->this_device = device_create_drvdata(misc_class, misc->parent,
"%s", misc->name); dev, NULL, "%s", misc->name);
if (IS_ERR(misc->this_device)) { if (IS_ERR(misc->this_device)) {
err = PTR_ERR(misc->this_device); err = PTR_ERR(misc->this_device);
goto out; goto out;
......
...@@ -1896,7 +1896,7 @@ static int cm4000_probe(struct pcmcia_device *link) ...@@ -1896,7 +1896,7 @@ static int cm4000_probe(struct pcmcia_device *link)
return ret; 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; return 0;
} }
......
...@@ -653,7 +653,8 @@ static int reader_probe(struct pcmcia_device *link) ...@@ -653,7 +653,8 @@ static int reader_probe(struct pcmcia_device *link)
return ret; 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; return 0;
} }
......
...@@ -752,8 +752,9 @@ static const struct file_operations pp_fops = { ...@@ -752,8 +752,9 @@ static const struct file_operations pp_fops = {
static void pp_attach(struct parport *port) static void pp_attach(struct parport *port)
{ {
device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number), device_create_drvdata(ppdev_class, port->dev,
"parport%d", port->number); MKDEV(PP_MAJOR, port->number),
NULL, "parport%d", port->number);
} }
static void pp_detach(struct parport *port) static void pp_detach(struct parport *port)
......
...@@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp, ...@@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp,
static void bind_device(struct raw_config_request *rq) static void bind_device(struct raw_config_request *rq)
{ {
device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
"raw%d", rq->raw_minor); NULL, "raw%d", rq->raw_minor);
} }
/* /*
...@@ -283,7 +283,8 @@ static int __init raw_init(void) ...@@ -283,7 +283,8 @@ static int __init raw_init(void)
ret = PTR_ERR(raw_class); ret = PTR_ERR(raw_class);
goto error_region; 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; return 0;
......
...@@ -444,7 +444,8 @@ scdrv_init(void) ...@@ -444,7 +444,8 @@ scdrv_init(void)
continue; 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, ia64_sn_irtr_intr_enable(scd->scd_nasid,
0 /*ignored */ , 0 /*ignored */ ,
......
...@@ -4753,8 +4753,8 @@ static int __init stallion_module_init(void) ...@@ -4753,8 +4753,8 @@ static int __init stallion_module_init(void)
if (IS_ERR(stallion_class)) if (IS_ERR(stallion_class))
printk("STALLION: failed to create class\n"); printk("STALLION: failed to create class\n");
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
"staliomem%d", i); NULL, "staliomem%d", i);
return 0; return 0;
err_unrtty: err_unrtty:
......
...@@ -4045,7 +4045,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index, ...@@ -4045,7 +4045,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index,
else else
tty_line_name(driver, index, name); 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) ...@@ -4323,20 +4323,22 @@ static int __init tty_init(void)
if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
panic("Couldn't register /dev/tty driver\n"); 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); cdev_init(&console_cdev, &console_fops);
if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
panic("Couldn't register /dev/console driver\n"); 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 #ifdef CONFIG_UNIX98_PTYS
cdev_init(&ptmx_cdev, &ptmx_fops); cdev_init(&ptmx_cdev, &ptmx_fops);
if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
panic("Couldn't register /dev/ptmx driver\n"); 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 #endif
#ifdef CONFIG_VT #ifdef CONFIG_VT
...@@ -4344,7 +4346,7 @@ static int __init tty_init(void) ...@@ -4344,7 +4346,7 @@ static int __init tty_init(void)
if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) || if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
panic("Couldn't register /dev/tty0 driver\n"); 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(); vty_init();
#endif #endif
......
...@@ -481,10 +481,10 @@ static struct class *vc_class; ...@@ -481,10 +481,10 @@ static struct class *vc_class;
void vcs_make_sysfs(struct tty_struct *tty) void vcs_make_sysfs(struct tty_struct *tty)
{ {
device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
"vcs%u", tty->index + 1); NULL, "vcs%u", tty->index + 1);
device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
"vcsa%u", tty->index + 1); NULL, "vcsa%u", tty->index + 1);
} }
void vcs_remove_sysfs(struct tty_struct *tty) void vcs_remove_sysfs(struct tty_struct *tty)
...@@ -499,7 +499,7 @@ int __init vcs_init(void) ...@@ -499,7 +499,7 @@ int __init vcs_init(void)
panic("unable to get major %d for vcs device", VCS_MAJOR); panic("unable to get major %d for vcs device", VCS_MAJOR);
vc_class = class_create(THIS_MODULE, "vc"); vc_class = class_create(THIS_MODULE, "vc");
device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), "vcs"); device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), "vcsa"); device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
return 0; return 0;
} }
...@@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id) ...@@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
state[i].cur_part = 0; state[i].cur_part = 0;
for (j = 0; j < MAX_PARTITIONS; ++j) for (j = 0; j < MAX_PARTITIONS; ++j)
state[i].part_stat_rwi[j] = VIOT_IDLE; state[i].part_stat_rwi[j] = VIOT_IDLE;
device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
"iseries!vt%d", i); NULL, "iseries!vt%d", i);
device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
"iseries!nvt%d", i); NULL, "iseries!nvt%d", i);
printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries " printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries "
"resource %10.10s type %4.4s, model %3.3s\n", "resource %10.10s type %4.4s, model %3.3s\n",
i, viotape_unitinfo[i].rsrcname, i, viotape_unitinfo[i].rsrcname,
......
...@@ -3425,9 +3425,10 @@ int register_con_driver(const struct consw *csw, int first, int last) ...@@ -3425,9 +3425,10 @@ int register_con_driver(const struct consw *csw, int first, int last)
if (retval) if (retval)
goto err; goto err;
con_driver->dev = device_create(vtconsole_class, NULL, con_driver->dev = device_create_drvdata(vtconsole_class, NULL,
MKDEV(0, con_driver->node), MKDEV(0, con_driver->node),
"vtcon%i", con_driver->node); NULL, "vtcon%i",
con_driver->node);
if (IS_ERR(con_driver->dev)) { if (IS_ERR(con_driver->dev)) {
printk(KERN_WARNING "Unable to create device for %s; " printk(KERN_WARNING "Unable to create device for %s; "
...@@ -3535,9 +3536,10 @@ static int __init vtconsole_class_init(void) ...@@ -3535,9 +3536,10 @@ static int __init vtconsole_class_init(void)
struct con_driver *con = &registered_con_driver[i]; struct con_driver *con = &registered_con_driver[i];
if (con->con && !con->dev) { if (con->con && !con->dev) {
con->dev = device_create(vtconsole_class, NULL, con->dev = device_create_drvdata(vtconsole_class, NULL,
MKDEV(0, con->node), MKDEV(0, con->node),
"vtcon%i", con->node); NULL, "vtcon%i",
con->node);
if (IS_ERR(con->dev)) { if (IS_ERR(con->dev)) {
printk(KERN_WARNING "Unable to create " printk(KERN_WARNING "Unable to create "
......
...@@ -658,8 +658,9 @@ static int __devinit hwicap_setup(struct device *dev, int id, ...@@ -658,8 +658,9 @@ static int __devinit hwicap_setup(struct device *dev, int id,
dev_err(dev, "cdev_add() failed\n"); dev_err(dev, "cdev_add() failed\n");
goto failed3; 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 */ return 0; /* success */
failed3: failed3:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment