diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/Kconfig | 3 | ||||
-rw-r--r-- | drivers/char/bsr.c | 21 | ||||
-rw-r--r-- | drivers/char/dsp56k.c | 18 | ||||
-rw-r--r-- | drivers/char/lp.c | 18 | ||||
-rw-r--r-- | drivers/char/mem.c | 15 | ||||
-rw-r--r-- | drivers/char/misc.c | 39 | ||||
-rw-r--r-- | drivers/char/ppdev.c | 19 | ||||
-rw-r--r-- | drivers/char/virtio_console.c | 25 | ||||
-rw-r--r-- | drivers/char/xilinx_hwicap/xilinx_hwicap.c | 52 | ||||
-rw-r--r-- | drivers/char/xillybus/xillybus_class.c | 21 |
10 files changed, 113 insertions, 118 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 801d6c83f896..625af75833fc 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -34,6 +34,7 @@ config TTY_PRINTK_LEVEL config PRINTER tristate "Parallel printer support" depends on PARPORT + depends on HAS_IOPORT || PARPORT_NOT_PC help If you intend to attach a printer to the parallel port of your Linux box (as opposed to using a serial printer; if the connector at the @@ -340,7 +341,7 @@ config NVRAM config DEVPORT bool "/dev/port character device" - depends on ISA || PCI + depends on HAS_IOPORT default y help Say Y here if you want to support the /dev/port device. The /dev/port diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c index ff429ba02fa4..12143854aeac 100644 --- a/drivers/char/bsr.c +++ b/drivers/char/bsr.c @@ -61,7 +61,6 @@ struct bsr_dev { static unsigned total_bsr_devs; static LIST_HEAD(bsr_devs); -static struct class *bsr_class; static int bsr_major; enum { @@ -108,6 +107,11 @@ static struct attribute *bsr_dev_attrs[] = { }; ATTRIBUTE_GROUPS(bsr_dev); +static const struct class bsr_class = { + .name = "bsr", + .dev_groups = bsr_dev_groups, +}; + static int bsr_mmap(struct file *filp, struct vm_area_struct *vma) { unsigned long size = vma->vm_end - vma->vm_start; @@ -244,7 +248,7 @@ static int bsr_add_node(struct device_node *bn) goto out_err; } - cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev, + cur->bsr_device = device_create(&bsr_class, NULL, cur->bsr_dev, cur, "%s", cur->bsr_name); if (IS_ERR(cur->bsr_device)) { printk(KERN_ERR "device_create failed for %s\n", @@ -293,13 +297,9 @@ static int __init bsr_init(void) if (!np) goto out_err; - bsr_class = class_create("bsr"); - if (IS_ERR(bsr_class)) { - printk(KERN_ERR "class_create() failed for bsr_class\n"); - ret = PTR_ERR(bsr_class); + ret = class_register(&bsr_class); + if (ret) goto out_err_1; - } - bsr_class->dev_groups = bsr_dev_groups; ret = alloc_chrdev_region(&bsr_dev, 0, BSR_MAX_DEVS, "bsr"); bsr_major = MAJOR(bsr_dev); @@ -320,7 +320,7 @@ static int __init bsr_init(void) unregister_chrdev_region(bsr_dev, BSR_MAX_DEVS); out_err_2: - class_destroy(bsr_class); + class_unregister(&bsr_class); out_err_1: of_node_put(np); @@ -335,8 +335,7 @@ static void __exit bsr_exit(void) bsr_cleanup_devs(); - if (bsr_class) - class_destroy(bsr_class); + class_unregister(&bsr_class); if (bsr_major) unregister_chrdev_region(MKDEV(bsr_major, 0), BSR_MAX_DEVS); diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index b3eaf3e5ef2e..bda27e595da1 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c @@ -101,7 +101,9 @@ static struct dsp56k_device { int tx_wsize, rx_wsize; } dsp56k; -static struct class *dsp56k_class; +static const struct class dsp56k_class = { + .name = "dsp56k", +}; static int dsp56k_reset(void) { @@ -493,7 +495,7 @@ static const char banner[] __initconst = KERN_INFO "DSP56k driver installed\n"; static int __init dsp56k_init_driver(void) { - int err = 0; + int err; if(!MACH_IS_ATARI || !ATARIHW_PRESENT(DSP56K)) { printk("DSP56k driver: Hardware not present\n"); @@ -504,12 +506,10 @@ static int __init dsp56k_init_driver(void) printk("DSP56k driver: Unable to register driver\n"); return -ENODEV; } - dsp56k_class = class_create("dsp56k"); - if (IS_ERR(dsp56k_class)) { - err = PTR_ERR(dsp56k_class); + err = class_register(&dsp56k_class); + if (err) goto out_chrdev; - } - device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, + device_create(&dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k"); printk(banner); @@ -524,8 +524,8 @@ module_init(dsp56k_init_driver); static void __exit dsp56k_cleanup_driver(void) { - device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0)); - class_destroy(dsp56k_class); + device_destroy(&dsp56k_class, MKDEV(DSP56K_MAJOR, 0)); + class_unregister(&dsp56k_class); unregister_chrdev(DSP56K_MAJOR, "dsp56k"); } module_exit(dsp56k_cleanup_driver); diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 70cfc5140c2c..2f171d14b9b5 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -145,7 +145,9 @@ static struct lp_struct lp_table[LP_NO]; static int port_num[LP_NO]; static unsigned int lp_count = 0; -static struct class *lp_class; +static const struct class lp_class = { + .name = "printer", +}; #ifdef CONFIG_LP_CONSOLE static struct parport *console_registered; @@ -932,7 +934,7 @@ static int lp_register(int nr, struct parport *port) if (reset) lp_reset(nr); - device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL, + device_create(&lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL, "lp%d", nr); printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, @@ -1004,7 +1006,7 @@ static void lp_detach(struct parport *port) if (port_num[n] == port->number) { port_num[n] = -1; lp_count--; - device_destroy(lp_class, MKDEV(LP_MAJOR, n)); + device_destroy(&lp_class, MKDEV(LP_MAJOR, n)); parport_unregister_device(lp_table[n].dev); } } @@ -1049,11 +1051,9 @@ static int __init lp_init(void) return -EIO; } - lp_class = class_create("printer"); - if (IS_ERR(lp_class)) { - err = PTR_ERR(lp_class); + err = class_register(&lp_class); + if (err) goto out_reg; - } if (parport_register_driver(&lp_driver)) { printk(KERN_ERR "lp: unable to register with parport\n"); @@ -1072,7 +1072,7 @@ static int __init lp_init(void) return 0; out_class: - class_destroy(lp_class); + class_unregister(&lp_class); out_reg: unregister_chrdev(LP_MAJOR, "lp"); return err; @@ -1115,7 +1115,7 @@ static void lp_cleanup_module(void) #endif unregister_chrdev(LP_MAJOR, "lp"); - class_destroy(lp_class); + class_unregister(&lp_class); } __setup("lp=", lp_setup); diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 94eff6a2a7b6..0fcc8615fb4f 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -746,20 +746,23 @@ static char *mem_devnode(const struct device *dev, umode_t *mode) return NULL; } -static struct class *mem_class; +static const struct class mem_class = { + .name = "mem", + .devnode = mem_devnode, +}; static int __init chr_dev_init(void) { + int retval; int minor; if (register_chrdev(MEM_MAJOR, "mem", &memory_fops)) printk("unable to get major %d for memory devs\n", MEM_MAJOR); - mem_class = class_create("mem"); - if (IS_ERR(mem_class)) - return PTR_ERR(mem_class); + retval = class_register(&mem_class); + if (retval) + return retval; - mem_class->devnode = mem_devnode; for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) { if (!devlist[minor].name) continue; @@ -770,7 +773,7 @@ static int __init chr_dev_init(void) if ((minor == DEVPORT_MINOR) && !arch_has_dev_port()) continue; - device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor), + device_create(&mem_class, NULL, MKDEV(MEM_MAJOR, minor), NULL, devlist[minor].name); } diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 1c44c29a666e..541edc26ec89 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c @@ -168,7 +168,21 @@ fail: return err; } -static struct class *misc_class; +static char *misc_devnode(const struct device *dev, umode_t *mode) +{ + const struct miscdevice *c = dev_get_drvdata(dev); + + if (mode && c->mode) + *mode = c->mode; + if (c->nodename) + return kstrdup(c->nodename, GFP_KERNEL); + return NULL; +} + +static const struct class misc_class = { + .name = "misc", + .devnode = misc_devnode, +}; static const struct file_operations misc_fops = { .owner = THIS_MODULE, @@ -226,7 +240,7 @@ int misc_register(struct miscdevice *misc) dev = MKDEV(MISC_MAJOR, misc->minor); misc->this_device = - device_create_with_groups(misc_class, misc->parent, dev, + device_create_with_groups(&misc_class, misc->parent, dev, misc, misc->groups, "%s", misc->name); if (IS_ERR(misc->this_device)) { if (is_dynamic) { @@ -263,43 +277,30 @@ void misc_deregister(struct miscdevice *misc) mutex_lock(&misc_mtx); list_del(&misc->list); - device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); + device_destroy(&misc_class, MKDEV(MISC_MAJOR, misc->minor)); misc_minor_free(misc->minor); mutex_unlock(&misc_mtx); } EXPORT_SYMBOL(misc_deregister); -static char *misc_devnode(const struct device *dev, umode_t *mode) -{ - const struct miscdevice *c = dev_get_drvdata(dev); - - if (mode && c->mode) - *mode = c->mode; - if (c->nodename) - return kstrdup(c->nodename, GFP_KERNEL); - return NULL; -} - static int __init misc_init(void) { int err; struct proc_dir_entry *ret; ret = proc_create_seq("misc", 0, NULL, &misc_seq_ops); - misc_class = class_create("misc"); - err = PTR_ERR(misc_class); - if (IS_ERR(misc_class)) + err = class_register(&misc_class); + if (err) goto fail_remove; err = -EIO; if (register_chrdev(MISC_MAJOR, "misc", &misc_fops)) goto fail_printk; - misc_class->devnode = misc_devnode; return 0; fail_printk: pr_err("unable to get major %d for misc devices\n", MISC_MAJOR); - class_destroy(misc_class); + class_unregister(&misc_class); fail_remove: if (ret) remove_proc_entry("misc", NULL); diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 81ed58157b15..4c188e9e477c 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -773,7 +773,9 @@ static __poll_t pp_poll(struct file *file, poll_table *wait) return mask; } -static struct class *ppdev_class; +static const struct class ppdev_class = { + .name = CHRDEV, +}; static const struct file_operations pp_fops = { .owner = THIS_MODULE, @@ -794,7 +796,7 @@ static void pp_attach(struct parport *port) if (devices[port->number]) return; - ret = device_create(ppdev_class, port->dev, + ret = device_create(&ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number), NULL, "parport%d", port->number); if (IS_ERR(ret)) { @@ -810,7 +812,7 @@ static void pp_detach(struct parport *port) if (!devices[port->number]) return; - device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number)); + device_destroy(&ppdev_class, MKDEV(PP_MAJOR, port->number)); devices[port->number] = NULL; } @@ -841,11 +843,10 @@ static int __init ppdev_init(void) pr_warn(CHRDEV ": unable to get major %d\n", PP_MAJOR); return -EIO; } - ppdev_class = class_create(CHRDEV); - if (IS_ERR(ppdev_class)) { - err = PTR_ERR(ppdev_class); + err = class_register(&ppdev_class); + if (err) goto out_chrdev; - } + err = parport_register_driver(&pp_driver); if (err < 0) { pr_warn(CHRDEV ": unable to register with parport\n"); @@ -856,7 +857,7 @@ static int __init ppdev_init(void) goto out; out_class: - class_destroy(ppdev_class); + class_unregister(&ppdev_class); out_chrdev: unregister_chrdev(PP_MAJOR, CHRDEV); out: @@ -867,7 +868,7 @@ static void __exit ppdev_cleanup(void) { /* Clean up all parport stuff */ parport_unregister_driver(&pp_driver); - class_destroy(ppdev_class); + class_unregister(&ppdev_class); unregister_chrdev(PP_MAJOR, CHRDEV); } diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index b65c809a4e97..680d1ef2a217 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -40,9 +40,6 @@ * across multiple devices and multiple ports per device. */ struct ports_driver_data { - /* Used for registering chardevs */ - struct class *class; - /* Used for exporting per-port information to debugfs */ struct dentry *debugfs_dir; @@ -55,6 +52,10 @@ struct ports_driver_data { static struct ports_driver_data pdrvdata; +static const struct class port_class = { + .name = "virtio-ports", +}; + static DEFINE_SPINLOCK(pdrvdata_lock); static DECLARE_COMPLETION(early_console_added); @@ -1399,7 +1400,7 @@ static int add_port(struct ports_device *portdev, u32 id) "Error %d adding cdev for port %u\n", err, id); goto free_cdev; } - port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev, + port->dev = device_create(&port_class, &port->portdev->vdev->dev, devt, port, "vport%up%u", port->portdev->vdev->index, id); if (IS_ERR(port->dev)) { @@ -1465,7 +1466,7 @@ static int add_port(struct ports_device *portdev, u32 id) free_inbufs: free_device: - device_destroy(pdrvdata.class, port->dev->devt); + device_destroy(&port_class, port->dev->devt); free_cdev: cdev_del(port->cdev); free_port: @@ -1540,7 +1541,7 @@ static void unplug_port(struct port *port) port->portdev = NULL; sysfs_remove_group(&port->dev->kobj, &port_attribute_group); - device_destroy(pdrvdata.class, port->dev->devt); + device_destroy(&port_class, port->dev->devt); cdev_del(port->cdev); debugfs_remove(port->debugfs_file); @@ -1935,6 +1936,7 @@ static void remove_vqs(struct ports_device *portdev) flush_bufs(vq, true); while ((buf = virtqueue_detach_unused_buf(vq))) free_buf(buf, true); + cond_resched(); } portdev->vdev->config->del_vqs(portdev->vdev); kfree(portdev->in_vqs); @@ -2244,12 +2246,9 @@ static int __init virtio_console_init(void) { int err; - pdrvdata.class = class_create("virtio-ports"); - if (IS_ERR(pdrvdata.class)) { - err = PTR_ERR(pdrvdata.class); - pr_err("Error %d creating virtio-ports class\n", err); + err = class_register(&port_class); + if (err) return err; - } pdrvdata.debugfs_dir = debugfs_create_dir("virtio-ports", NULL); INIT_LIST_HEAD(&pdrvdata.consoles); @@ -2271,7 +2270,7 @@ unregister: unregister_virtio_driver(&virtio_console); free: debugfs_remove_recursive(pdrvdata.debugfs_dir); - class_destroy(pdrvdata.class); + class_unregister(&port_class); return err; } @@ -2282,7 +2281,7 @@ static void __exit virtio_console_fini(void) unregister_virtio_driver(&virtio_console); unregister_virtio_driver(&virtio_rproc_serial); - class_destroy(pdrvdata.class); + class_unregister(&port_class); debugfs_remove_recursive(pdrvdata.debugfs_dir); } module_init(virtio_console_init); diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index a46f637da959..f60bb6151402 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c @@ -113,7 +113,9 @@ static DEFINE_MUTEX(hwicap_mutex); static bool probed_devices[HWICAP_DEVICES]; static struct mutex icap_sem; -static struct class *icap_class; +static const struct class icap_class = { + .name = "xilinx_config", +}; #define UNIMPLEMENTED 0xFFFF @@ -687,7 +689,7 @@ static int hwicap_setup(struct device *dev, int id, goto failed3; } - device_create(icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id); + device_create(&icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id); return 0; /* success */ failed3: @@ -721,27 +723,6 @@ static struct hwicap_driver_config fifo_icap_config = { .reset = fifo_icap_reset, }; -static int hwicap_remove(struct device *dev) -{ - struct hwicap_drvdata *drvdata; - - drvdata = dev_get_drvdata(dev); - - if (!drvdata) - return 0; - - device_destroy(icap_class, drvdata->devt); - cdev_del(&drvdata->cdev); - iounmap(drvdata->base_address); - release_mem_region(drvdata->mem_start, drvdata->mem_size); - kfree(drvdata); - - mutex_lock(&icap_sem); - probed_devices[MINOR(dev->devt)-XHWICAP_MINOR] = 0; - mutex_unlock(&icap_sem); - return 0; /* success */ -} - #ifdef CONFIG_OF static int hwicap_of_probe(struct platform_device *op, const struct hwicap_driver_config *config) @@ -825,9 +806,22 @@ static int hwicap_drv_probe(struct platform_device *pdev) &buffer_icap_config, regs); } -static int hwicap_drv_remove(struct platform_device *pdev) +static void hwicap_drv_remove(struct platform_device *pdev) { - return hwicap_remove(&pdev->dev); + struct device *dev = &pdev->dev; + struct hwicap_drvdata *drvdata; + + drvdata = dev_get_drvdata(dev); + + device_destroy(&icap_class, drvdata->devt); + cdev_del(&drvdata->cdev); + iounmap(drvdata->base_address); + release_mem_region(drvdata->mem_start, drvdata->mem_size); + kfree(drvdata); + + mutex_lock(&icap_sem); + probed_devices[MINOR(dev->devt)-XHWICAP_MINOR] = 0; + mutex_unlock(&icap_sem); } #ifdef CONFIG_OF @@ -844,7 +838,7 @@ MODULE_DEVICE_TABLE(of, hwicap_of_match); static struct platform_driver hwicap_platform_driver = { .probe = hwicap_drv_probe, - .remove = hwicap_drv_remove, + .remove_new = hwicap_drv_remove, .driver = { .name = DRIVER_NAME, .of_match_table = hwicap_of_match, @@ -856,7 +850,9 @@ static int __init hwicap_module_init(void) dev_t devt; int retval; - icap_class = class_create("xilinx_config"); + retval = class_register(&icap_class); + if (retval) + return retval; mutex_init(&icap_sem); devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR); @@ -882,7 +878,7 @@ static void __exit hwicap_module_cleanup(void) { dev_t devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR); - class_destroy(icap_class); + class_unregister(&icap_class); platform_driver_unregister(&hwicap_platform_driver); diff --git a/drivers/char/xillybus/xillybus_class.c b/drivers/char/xillybus/xillybus_class.c index 89926fe9d813..c92a628e389e 100644 --- a/drivers/char/xillybus/xillybus_class.c +++ b/drivers/char/xillybus/xillybus_class.c @@ -23,7 +23,9 @@ MODULE_LICENSE("GPL v2"); static DEFINE_MUTEX(unit_mutex); static LIST_HEAD(unit_list); -static struct class *xillybus_class; +static const struct class xillybus_class = { + .name = "xillybus", +}; #define UNITNAMELEN 16 @@ -121,7 +123,7 @@ int xillybus_init_chrdev(struct device *dev, len -= namelen + 1; idt += namelen + 1; - device = device_create(xillybus_class, + device = device_create(&xillybus_class, NULL, MKDEV(unit->major, i + unit->lowest_minor), @@ -152,7 +154,7 @@ int xillybus_init_chrdev(struct device *dev, unroll_device_create: for (i--; i >= 0; i--) - device_destroy(xillybus_class, MKDEV(unit->major, + device_destroy(&xillybus_class, MKDEV(unit->major, i + unit->lowest_minor)); cdev_del(unit->cdev); @@ -193,7 +195,7 @@ void xillybus_cleanup_chrdev(void *private_data, for (minor = unit->lowest_minor; minor < (unit->lowest_minor + unit->num_nodes); minor++) - device_destroy(xillybus_class, MKDEV(unit->major, minor)); + device_destroy(&xillybus_class, MKDEV(unit->major, minor)); cdev_del(unit->cdev); @@ -242,19 +244,12 @@ EXPORT_SYMBOL(xillybus_find_inode); static int __init xillybus_class_init(void) { - xillybus_class = class_create("xillybus"); - - if (IS_ERR(xillybus_class)) { - pr_warn("Failed to register xillybus class\n"); - - return PTR_ERR(xillybus_class); - } - return 0; + return class_register(&xillybus_class); } static void __exit xillybus_class_exit(void) { - class_destroy(xillybus_class); + class_unregister(&xillybus_class); } module_init(xillybus_class_init); |