* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (79 commits) arm: bus_id -> dev_name() and dev_set_name() conversions sparc64: fix up bus_id changes in sparc core code 3c59x: handle pci_name() being const MTD: handle pci_name() being const HP iLO driver sysdev: Convert the x86 mce tolerant sysdev attribute to generic attribute sysdev: Add utility functions for simple int/ulong variable sysdev attributes sysdev: Pass the attribute to the low level sysdev show/store function driver core: Suppress sysfs warnings for device_rename(). kobject: Transmit return value of call_usermodehelper() to caller sysfs-rules.txt: reword API stability statement debugfs: Implement debugfs_remove_recursive() HOWTO: change email addresses of James in HOWTO always enable FW_LOADER unless EMBEDDED=y uio-howto.tmpl: use unique output names uio-howto.tmpl: use standard copyright/legal markings sysfs: don't call notify_change sysdev: fix debugging statements in registration code. kobject: should use kobject_put() in kset-example kobject: reorder kobject to save space on 64 bit builds ...
Unified · Split
| @@ -0,0 +1,20 @@ | ||
| 1 | +What: /sys/dev | |
| 2 | +Date: April 2008 | |
| 3 | +KernelVersion: 2.6.26 | |
| 4 | +Contact: Dan Williams <dan.j.williams@intel.com> | |
| 5 | +Description: The /sys/dev tree provides a method to look up the sysfs | |
| 6 | + path for a device using the information returned from | |
| 7 | + stat(2). There are two directories, 'block' and 'char', | |
| 8 | + beneath /sys/dev containing symbolic links with names of | |
| 9 | + the form "<major>:<minor>". These links point to the | |
| 10 | + corresponding sysfs path for the given device. | |
| 11 | + | |
| 12 | + Example: | |
| 13 | + $ readlink /sys/dev/block/8:32 | |
| 14 | + ../../block/sdc | |
| 15 | + | |
| 16 | + Entries in /sys/dev/char and /sys/dev/block will be | |
| 17 | + dynamically created and destroyed as devices enter and | |
| 18 | + leave the system. | |
| 19 | + | |
| 20 | +Users: mdadm <linux-raid@vger.kernel.org> | |
| @@ -21,6 +21,18 @@ · 20 unmodified lines | ||
| 21 | 21 | </affiliation> |
| 22 | 22 | </author> |
| 23 | 23 | |
| 24 | +<copyright> | |
| 25 | + <year>2006-2008</year> | |
| 26 | + <holder>Hans-Jürgen Koch.</holder> | |
| 27 | +</copyright> | |
| 28 | + | |
| 29 | +<legalnotice> | |
| 30 | +<para> | |
| 31 | +This documentation is Free Software licensed under the terms of the | |
| 32 | +GPL version 2. | |
| 33 | +</para> | |
| 34 | +</legalnotice> | |
| 35 | + | |
| 24 | 36 | <pubdate>2006-12-11</pubdate> |
| 25 | 37 | |
| 26 | 38 | <abstract> |
| @@ -29,6 +41,12 @@ · 2 unmodified lines | ||
| 29 | 41 | </abstract> |
| 30 | 42 | |
| 31 | 43 | <revhistory> |
| 44 | + <revision> | |
| 45 | + <revnumber>0.5</revnumber> | |
| 46 | + <date>2008-05-22</date> | |
| 47 | + <authorinitials>hjk</authorinitials> | |
| 48 | + <revremark>Added description of write() function.</revremark> | |
| 49 | + </revision> | |
| 32 | 50 | <revision> |
| 33 | 51 | <revnumber>0.4</revnumber> |
| 34 | 52 | <date>2007-11-26</date> |
| @@ -57,20 +75,9 @@ · 22 unmodified lines | ||
| 57 | 75 | </bookinfo> |
| 58 | 76 | |
| 59 | 77 | <chapter id="aboutthisdoc"> |
| 60 | −<?dbhtml filename="about.html"?> | |
| 78 | +<?dbhtml filename="aboutthis.html"?> | |
| 61 | 79 | <title>About this document</title> |
| 62 | 80 | |
| 63 | −<sect1 id="copyright"> | |
| 64 | −<?dbhtml filename="copyright.html"?> | |
| 65 | −<title>Copyright and License</title> | |
| 66 | −<para> | |
| 67 | − Copyright (c) 2006 by Hans-Jürgen Koch.</para> | |
| 68 | −<para> | |
| 69 | −This documentation is Free Software licensed under the terms of the | |
| 70 | −GPL version 2. | |
| 71 | −</para> | |
| 72 | −</sect1> | |
| 73 | − | |
| 74 | 81 | <sect1 id="translations"> |
| 75 | 82 | <?dbhtml filename="translations.html"?> |
| 76 | 83 | <title>Translations</title> |
| @@ -189,6 +196,30 @@ interested in translating it, please email me · 112 unmodified lines | ||
| 189 | 196 | represents the total interrupt count. You can use this number |
| 190 | 197 | to figure out if you missed some interrupts. |
| 191 | 198 | </para> |
| 199 | + <para> | |
| 200 | + For some hardware that has more than one interrupt source internally, | |
| 201 | + but not separate IRQ mask and status registers, there might be | |
| 202 | + situations where userspace cannot determine what the interrupt source | |
| 203 | + was if the kernel handler disables them by writing to the chip's IRQ | |
| 204 | + register. In such a case, the kernel has to disable the IRQ completely | |
| 205 | + to leave the chip's register untouched. Now the userspace part can | |
| 206 | + determine the cause of the interrupt, but it cannot re-enable | |
| 207 | + interrupts. Another cornercase is chips where re-enabling interrupts | |
| 208 | + is a read-modify-write operation to a combined IRQ status/acknowledge | |
| 209 | + register. This would be racy if a new interrupt occurred | |
| 210 | + simultaneously. | |
| 211 | + </para> | |
| 212 | + <para> | |
| 213 | + To address these problems, UIO also implements a write() function. It | |
| 214 | + is normally not used and can be ignored for hardware that has only a | |
| 215 | + single interrupt source or has separate IRQ mask and status registers. | |
| 216 | + If you need it, however, a write to <filename>/dev/uioX</filename> | |
| 217 | + will call the <function>irqcontrol()</function> function implemented | |
| 218 | + by the driver. You have to write a 32-bit value that is usually either | |
| 219 | + 0 or 1 to disable or enable interrupts. If a driver does not implement | |
| 220 | + <function>irqcontrol()</function>, <function>write()</function> will | |
| 221 | + return with <varname>-ENOSYS</varname>. | |
| 222 | + </para> | |
| 192 | 223 | |
| 193 | 224 | <para> |
| 194 | 225 | To handle interrupts properly, your custom kernel module can |
| @@ -362,6 +393,14 @@ device is actually used. · 167 unmodified lines | ||
| 362 | 393 | <function>open()</function>, you will probably also want a custom |
| 363 | 394 | <function>release()</function> function. |
| 364 | 395 | </para></listitem> |
| 396 | + | |
| 397 | +<listitem><para> | |
| 398 | +<varname>int (*irqcontrol)(struct uio_info *info, s32 irq_on) | |
| 399 | +</varname>: Optional. If you need to be able to enable or disable | |
| 400 | +interrupts from userspace by writing to <filename>/dev/uioX</filename>, | |
| 401 | +you can implement this function. The parameter <varname>irq_on</varname> | |
| 402 | +will be 0 to disable interrupts and 1 to enable them. | |
| 403 | +</para></listitem> | |
| 365 | 404 | </itemizedlist> |
| 366 | 405 | |
| 367 | 406 | <para> |
| @@ -358,7 +358,7 @@ Here is a list of some of the different kernel trees available: · 357 unmodified lines | ||
| 358 | 358 | - pcmcia, Dominik Brodowski <linux@dominikbrodowski.net> |
| 359 | 359 | git.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git |
| 360 | 360 | |
| 361 | − - SCSI, James Bottomley <James.Bottomley@SteelEye.com> | |
| 361 | + - SCSI, James Bottomley <James.Bottomley@hansenpartnership.com> | |
| 362 | 362 | git.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git |
| 363 | 363 | |
| 364 | 364 | - x86, Ingo Molnar <mingo@elte.hu> |
| @@ -248,6 +248,7 @@ The top level sysfs directory looks like: · 247 unmodified lines | ||
| 248 | 248 | block/ |
| 249 | 249 | bus/ |
| 250 | 250 | class/ |
| 251 | +dev/ | |
| 251 | 252 | devices/ |
| 252 | 253 | firmware/ |
| 253 | 254 | net/ |
| @@ -274,6 +275,11 @@ fs/ contains a directory for some filesystems. Currently each · 20 unmodified lines | ||
| 274 | 275 | filesystem wanting to export attributes must create its own hierarchy |
| 275 | 276 | below fs/ (see ./fuse.txt for an example). |
| 276 | 277 | |
| 278 | +dev/ contains two directories char/ and block/. Inside these two | |
| 279 | +directories there are symlinks named <major>:<minor>. These symlinks | |
| 280 | +point to the sysfs directory for the given device. /sys/dev provides a | |
| 281 | +quick way to lookup the sysfs interface for a device from the result of | |
| 282 | +a stat(2) operation. | |
| 277 | 283 | |
| 278 | 284 | More information can driver-model specific features can be found in |
| 279 | 285 | Documentation/driver-model/. |
| @@ -3,9 +3,8 @@ Rules on how to access information in the Linux kernel sysfs · 2 unmodified lines | ||
| 3 | 3 | The kernel-exported sysfs exports internal kernel implementation details |
| 4 | 4 | and depends on internal kernel structures and layout. It is agreed upon |
| 5 | 5 | by the kernel developers that the Linux kernel does not provide a stable |
| 6 | −internal API. As sysfs is a direct export of kernel internal | |
| 7 | −structures, the sysfs interface cannot provide a stable interface either; | |
| 8 | −it may always change along with internal kernel changes. | |
| 6 | +internal API. Therefore, there are aspects of the sysfs interface that | |
| 7 | +may not be stable across kernel releases. | |
| 9 | 8 | |
| 10 | 9 | To minimize the risk of breaking users of sysfs, which are in most cases |
| 11 | 10 | low-level userspace applications, with a new kernel release, the users |
| @@ -554,9 +554,8 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size, · 553 unmodified lines | ||
| 554 | 554 | |
| 555 | 555 | device_info = kmalloc(sizeof(struct dmabounce_device_info), GFP_ATOMIC); |
| 556 | 556 | if (!device_info) { |
| 557 | − printk(KERN_ERR | |
| 558 | − "Could not allocated dmabounce_device_info for %s", | |
| 559 | − dev->bus_id); | |
| 557 | + dev_err(dev, | |
| 558 | + "Could not allocated dmabounce_device_info\n"); | |
| 560 | 559 | return -ENOMEM; |
| 561 | 560 | } |
| 562 | 561 | |
| @@ -594,8 +593,7 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size, · 31 unmodified lines | ||
| 594 | 593 | |
| 595 | 594 | dev->archdata.dmabounce = device_info; |
| 596 | 595 | |
| 597 | − printk(KERN_INFO "dmabounce: registered device %s on %s bus\n", | |
| 598 | − dev->bus_id, dev->bus->name); | |
| 596 | + dev_info(dev, "dmabounce: registered device\n"); | |
| 599 | 597 | |
| 600 | 598 | return 0; |
| 601 | 599 | |
| @@ -614,16 +612,15 @@ dmabounce_unregister_dev(struct device *dev) · 12 unmodified lines | ||
| 614 | 612 | dev->archdata.dmabounce = NULL; |
| 615 | 613 | |
| 616 | 614 | if (!device_info) { |
| 617 | − printk(KERN_WARNING | |
| 618 | − "%s: Never registered with dmabounce but attempting" \ | |
| 619 | − "to unregister!\n", dev->bus_id); | |
| 615 | + dev_warn(dev, | |
| 616 | + "Never registered with dmabounce but attempting" | |
| 617 | + "to unregister!\n"); | |
| 620 | 618 | return; |
| 621 | 619 | } |
| 622 | 620 | |
| 623 | 621 | if (!list_empty(&device_info->safe_buffers)) { |
| 624 | − printk(KERN_ERR | |
| 625 | − "%s: Removing from dmabounce with pending buffers!\n", | |
| 626 | − dev->bus_id); | |
| 622 | + dev_err(dev, | |
| 623 | + "Removing from dmabounce with pending buffers!\n"); | |
| 627 | 624 | BUG(); |
| 628 | 625 | } |
| 629 | 626 | |
| @@ -639,8 +636,7 @@ dmabounce_unregister_dev(struct device *dev) · 9 unmodified lines | ||
| 639 | 636 | |
| 640 | 637 | kfree(device_info); |
| 641 | 638 | |
| 642 | − printk(KERN_INFO "dmabounce: device %s on %s bus unregistered\n", | |
| 643 | − dev->bus_id, dev->bus->name); | |
| 639 | + dev_info(dev, "dmabounce: device unregistered\n"); | |
| 644 | 640 | } |
| 645 | 641 | |
| 646 | 642 | |
| @@ -543,7 +543,6 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info) · 542 unmodified lines | ||
| 543 | 543 | goto out; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | − strncpy(dev->dev.bus_id, info->name, sizeof(dev->dev.bus_id)); | |
| 547 | 546 | /* |
| 548 | 547 | * If the parent device has a DMA mask associated with it, |
| 549 | 548 | * propagate it down to the children. |
| @@ -553,6 +552,7 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info) · 3 unmodified lines | ||
| 553 | 552 | dev->dev.dma_mask = &dev->dma_mask; |
| 554 | 553 | } |
| 555 | 554 | |
| 555 | + dev_set_name(&dev->dev, "%s", info->name); | |
| 556 | 556 | dev->devid = info->devid; |
| 557 | 557 | dev->dev.parent = lchip->dev; |
| 558 | 558 | dev->dev.bus = &locomo_bus_type; |
| @@ -550,9 +550,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, · 549 unmodified lines | ||
| 550 | 550 | goto out; |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | − snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), | |
| 554 | − "%4.4lx", info->offset); | |
| 555 | − | |
| 553 | + dev_set_name(&dev->dev, "%4.4lx", info->offset); | |
| 556 | 554 | dev->devid = info->devid; |
| 557 | 555 | dev->dev.parent = sachip->dev; |
| 558 | 556 | dev->dev.bus = &sa1111_bus_type; |
| @@ -560,7 +558,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, · 1 unmodified line | ||
| 560 | 558 | dev->dev.coherent_dma_mask = sachip->dev->coherent_dma_mask; |
| 561 | 559 | dev->res.start = sachip->phys + info->offset; |
| 562 | 560 | dev->res.end = dev->res.start + 511; |
| 563 | − dev->res.name = dev->dev.bus_id; | |
| 561 | + dev->res.name = dev_name(&dev->dev); | |
| 564 | 562 | dev->res.flags = IORESOURCE_MEM; |
| 565 | 563 | dev->mapbase = sachip->base + info->offset; |
| 566 | 564 | dev->skpcr_mask = info->skpcr_mask; |
| @@ -570,6 +568,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, · 3 unmodified lines | ||
| 570 | 568 | if (ret) { |
| 571 | 569 | printk("SA1111: failed to allocate resource for %s\n", |
| 572 | 570 | dev->res.name); |
| 571 | + dev_set_name(&dev->dev, NULL); | |
| 573 | 572 | kfree(dev); |
| 574 | 573 | goto out; |
| 575 | 574 | } |
| @@ -593,7 +592,8 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, · 17 unmodified lines | ||
| 593 | 592 | if (dev->dma_mask != 0xffffffffUL) { |
| 594 | 593 | ret = dmabounce_register_dev(&dev->dev, 1024, 4096); |
| 595 | 594 | if (ret) { |
| 596 | − printk("SA1111: Failed to register %s with dmabounce", dev->dev.bus_id); | |
| 595 | + dev_err(&dev->dev, "SA1111: Failed to register" | |
| 596 | + " with dmabounce\n"); | |
| 597 | 597 | device_unregister(&dev->dev); |
| 598 | 598 | } |
| 599 | 599 | } |
| @@ -247,7 +247,7 @@ static int __devinit scoop_probe(struct platform_device *pdev) · 246 unmodified lines | ||
| 247 | 247 | devptr->gpio.base = -1; |
| 248 | 248 | |
| 249 | 249 | if (inf->gpio_base != 0) { |
| 250 | − devptr->gpio.label = pdev->dev.bus_id; | |
| 250 | + devptr->gpio.label = dev_name(&pdev->dev); | |
| 251 | 251 | devptr->gpio.base = inf->gpio_base; |
| 252 | 252 | devptr->gpio.ngpio = 12; /* PA11 = 0, PA12 = 1, etc. up to PA22 = 11 */ |
| 253 | 253 | devptr->gpio.set = scoop_gpio_set; |
| @@ -783,7 +783,7 @@ static void ecard_proc_init(void) · 782 unmodified lines | ||
| 783 | 783 | |
| 784 | 784 | #define ec_set_resource(ec,nr,st,sz) \ |
| 785 | 785 | do { \ |
| 786 | − (ec)->resource[nr].name = ec->dev.bus_id; \ | |
| 786 | + (ec)->resource[nr].name = dev_name(&ec->dev); \ | |
| 787 | 787 | (ec)->resource[nr].start = st; \ |
| 788 | 788 | (ec)->resource[nr].end = (st) + (sz) - 1; \ |
| 789 | 789 | (ec)->resource[nr].flags = IORESOURCE_MEM; \ |
| @@ -853,8 +853,7 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot) · 63 unmodified lines | ||
| 853 | 853 | for (i = 0; i < ECARD_NUM_RESOURCES; i++) { |
| 854 | 854 | if (ec->resource[i].flags && |
| 855 | 855 | request_resource(&iomem_resource, &ec->resource[i])) { |
| 856 | − printk(KERN_ERR "%s: resource(s) not available\n", | |
| 857 | − ec->dev.bus_id); | |
| 856 | + dev_err(&ec->dev, "resource(s) not available\n"); | |
| 858 | 857 | ec->resource[i].end -= ec->resource[i].start; |
| 859 | 858 | ec->resource[i].start = 0; |
| 860 | 859 | ec->resource[i].flags = 0; |
| @@ -130,7 +130,9 @@ static const struct leds_evt_name evt_names[] = { · 129 unmodified lines | ||
| 130 | 130 | { "red", led_red_on, led_red_off }, |
| 131 | 131 | }; |
| 132 | 132 | |
| 133 | −static ssize_t leds_store(struct sys_device *dev, const char *buf, size_t size) | |
| 133 | +static ssize_t leds_store(struct sys_device *dev, | |
| 134 | + struct sysdev_attribute *attr, | |
| 135 | + const char *buf, size_t size) | |
| 134 | 136 | { |
| 135 | 137 | int ret = -EINVAL, len = strcspn(buf, " "); |
| 136 | 138 | |
| @@ -393,9 +393,7 @@ static int impd1_probe(struct lm_device *dev) · 392 unmodified lines | ||
| 393 | 393 | if (!d) |
| 394 | 394 | continue; |
| 395 | 395 | |
| 396 | − snprintf(d->dev.bus_id, sizeof(d->dev.bus_id), | |
| 397 | − "lm%x:%5.5lx", dev->id, idev->offset >> 12); | |
| 398 | − | |
| 396 | + dev_set_name(&d->dev, "lm%x:%5.5lx", dev->id, idev->offset >> 12); | |
| 399 | 397 | d->dev.parent = &dev->dev; |
| 400 | 398 | d->res.start = dev->resource.start + idev->offset; |
| 401 | 399 | d->res.end = d->res.start + SZ_4K - 1; |
| @@ -407,8 +405,7 @@ static int impd1_probe(struct lm_device *dev) · 5 unmodified lines | ||
| 407 | 405 | |
| 408 | 406 | ret = amba_device_register(d, &dev->resource); |
| 409 | 407 | if (ret) { |
| 410 | − printk("unable to register device %s: %d\n", | |
| 411 | − d->dev.bus_id, ret); | |
| 408 | + dev_err(&d->dev, "unable to register device: %d\n"); | |
| 412 | 409 | kfree(d); |
| 413 | 410 | } |
| 414 | 411 | } |
| @@ -81,8 +81,10 @@ int lm_device_register(struct lm_device *dev) · 80 unmodified lines | ||
| 81 | 81 | dev->dev.release = lm_device_release; |
| 82 | 82 | dev->dev.bus = &lm_bustype; |
| 83 | 83 | |
| 84 | − snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), "lm%d", dev->id); | |
| 85 | − dev->resource.name = dev->dev.bus_id; | |
| 84 | + ret = dev_set_name(&dev->dev, "lm%d", dev->id); | |
| 85 | + if (ret) | |
| 86 | + return ret; | |
| 87 | + dev->resource.name = dev_name(&dev->dev); | |
| 86 | 88 | |
| 87 | 89 | ret = request_resource(&iomem_resource, &dev->resource); |
| 88 | 90 | if (ret == 0) { |
| @@ -334,7 +334,7 @@ static int omap_mbox_init(struct omap_mbox *mbox) · 333 unmodified lines | ||
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | mbox->dev.class = &omap_mbox_class; |
| 337 | − strlcpy(mbox->dev.bus_id, mbox->name, KOBJ_NAME_LEN); | |
| 337 | + dev_set_name(&mbox->dev, "%s", mbox->name); | |
| 338 | 338 | dev_set_drvdata(&mbox->dev, mbox); |
| 339 | 339 | |
| 340 | 340 | ret = device_register(&mbox->dev); |
| @@ -26,14 +26,16 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices); · 25 unmodified lines | ||
| 26 | 26 | * XXX: If/when a SMP-capable implementation of AVR32 will ever be |
| 27 | 27 | * made, we must make sure that the code executes on the correct CPU. |
| 28 | 28 | */ |
| 29 | −static ssize_t show_pc0event(struct sys_device *dev, char *buf) | |
| 29 | +static ssize_t show_pc0event(struct sys_device *dev, | |
| 30 | + struct sysdev_attribute *attr, char *buf) | |
| 30 | 31 | { |
| 31 | 32 | unsigned long pccr; |
| 32 | 33 | |
| 33 | 34 | pccr = sysreg_read(PCCR); |
| 34 | 35 | return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f); |
| 35 | 36 | } |
| 36 | −static ssize_t store_pc0event(struct sys_device *dev, const char *buf, | |
| 37 | +static ssize_t store_pc0event(struct sys_device *dev, | |
| 38 | + struct sysdev_attribute *attr, const char *buf, | |
| 37 | 39 | size_t count) |
| 38 | 40 | { |
| 39 | 41 | unsigned long val; |
| @@ -46,15 +48,17 @@ static ssize_t store_pc0event(struct sys_device *dev, const char *buf, · 6 unmodified lines | ||
| 46 | 48 | sysreg_write(PCCR, val); |
| 47 | 49 | return count; |
| 48 | 50 | } |
| 49 | −static ssize_t show_pc0count(struct sys_device *dev, char *buf) | |
| 51 | +static ssize_t show_pc0count(struct sys_device *dev, | |
| 52 | + struct sysdev_attribute *attr, char *buf) | |
| 50 | 53 | { |
| 51 | 54 | unsigned long pcnt0; |
| 52 | 55 | |
| 53 | 56 | pcnt0 = sysreg_read(PCNT0); |
| 54 | 57 | return sprintf(buf, "%lu\n", pcnt0); |
| 55 | 58 | } |
| 56 | −static ssize_t store_pc0count(struct sys_device *dev, const char *buf, | |
| 57 | − size_t count) | |
| 59 | +static ssize_t store_pc0count(struct sys_device *dev, | |
| 60 | + struct sysdev_attribute *attr, | |
| 61 | + const char *buf, size_t count) | |
| 58 | 62 | { |
| 59 | 63 | unsigned long val; |
| 60 | 64 | char *endp; |
| @@ -67,14 +71,16 @@ static ssize_t store_pc0count(struct sys_device *dev, const char *buf, · 6 unmodified lines | ||
| 67 | 71 | return count; |
| 68 | 72 | } |
| 69 | 73 | |
| 70 | −static ssize_t show_pc1event(struct sys_device *dev, char *buf) | |
| 74 | +static ssize_t show_pc1event(struct sys_device *dev, | |
| 75 | + struct sysdev_attribute *attr, char *buf) | |
| 71 | 76 | { |
| 72 | 77 | unsigned long pccr; |
| 73 | 78 | |
| 74 | 79 | pccr = sysreg_read(PCCR); |
| 75 | 80 | return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f); |
| 76 | 81 | } |
| 77 | −static ssize_t store_pc1event(struct sys_device *dev, const char *buf, | |
| 82 | +static ssize_t store_pc1event(struct sys_device *dev, | |
| 83 | + struct sysdev_attribute *attr, const char *buf, | |
| 78 | 84 | size_t count) |
| 79 | 85 | { |
| 80 | 86 | unsigned long val; |
| @@ -87,14 +93,16 @@ static ssize_t store_pc1event(struct sys_device *dev, const char *buf, · 6 unmodified lines | ||
| 87 | 93 | sysreg_write(PCCR, val); |
| 88 | 94 | return count; |
| 89 | 95 | } |
| 90 | −static ssize_t show_pc1count(struct sys_device *dev, char *buf) | |
| 96 | +static ssize_t show_pc1count(struct sys_device *dev, | |
| 97 | + struct sysdev_attribute *attr, char *buf) | |
| 91 | 98 | { |
| 92 | 99 | unsigned long pcnt1; |
| 93 | 100 | |
| 94 | 101 | pcnt1 = sysreg_read(PCNT1); |
| 95 | 102 | return sprintf(buf, "%lu\n", pcnt1); |
| 96 | 103 | } |
| 97 | −static ssize_t store_pc1count(struct sys_device *dev, const char *buf, | |
| 104 | +static ssize_t store_pc1count(struct sys_device *dev, | |
| 105 | + struct sysdev_attribute *attr, const char *buf, | |
| 98 | 106 | size_t count) |
| 99 | 107 | { |
| 100 | 108 | unsigned long val; |
| @@ -108,14 +116,16 @@ static ssize_t store_pc1count(struct sys_device *dev, const char *buf, · 7 unmodified lines | ||
| 108 | 116 | return count; |
| 109 | 117 | } |
| 110 | 118 | |
| 111 | −static ssize_t show_pccycles(struct sys_device *dev, char *buf) | |
| 119 | +static ssize_t show_pccycles(struct sys_device *dev, | |
| 120 | + struct sysdev_attribute *attr, char *buf) | |
| 112 | 121 | { |
| 113 | 122 | unsigned long pccnt; |
| 114 | 123 | |
| 115 | 124 | pccnt = sysreg_read(PCCNT); |
| 116 | 125 | return sprintf(buf, "%lu\n", pccnt); |
| 117 | 126 | } |
| 118 | −static ssize_t store_pccycles(struct sys_device *dev, const char *buf, | |
| 127 | +static ssize_t store_pccycles(struct sys_device *dev, | |
| 128 | + struct sysdev_attribute *attr, const char *buf, | |
| 119 | 129 | size_t count) |
| 120 | 130 | { |
| 121 | 131 | unsigned long val; |
| @@ -129,14 +139,16 @@ static ssize_t store_pccycles(struct sys_device *dev, const char *buf, · 7 unmodified lines | ||
| 129 | 139 | return count; |
| 130 | 140 | } |
| 131 | 141 | |
| 132 | −static ssize_t show_pcenable(struct sys_device *dev, char *buf) | |
| 142 | +static ssize_t show_pcenable(struct sys_device *dev, | |
| 143 | + struct sysdev_attribute *attr, char *buf) | |
| 133 | 144 | { |
| 134 | 145 | unsigned long pccr; |
| 135 | 146 | |
| 136 | 147 | pccr = sysreg_read(PCCR); |
| 137 | 148 | return sprintf(buf, "%c\n", (pccr & 1)?'1':'0'); |
| 138 | 149 | } |
| 139 | −static ssize_t store_pcenable(struct sys_device *dev, const char *buf, | |
| 150 | +static ssize_t store_pcenable(struct sys_device *dev, | |
| 151 | + struct sysdev_attribute *attr, const char *buf, | |
| 140 | 152 | size_t count) |
| 141 | 153 | { |
| 142 | 154 | unsigned long pccr, val; |
| @@ -55,7 +55,8 @@ static u64 resources[NR_CPUS]; · 54 unmodified lines | ||
| 55 | 55 | |
| 56 | 56 | #define show(name) \ |
| 57 | 57 | static ssize_t \ |
| 58 | −show_##name(struct sys_device *dev, char *buf) \ | |
| 58 | +show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \ | |
| 59 | + char *buf) \ | |
| 59 | 60 | { \ |
| 60 | 61 | u32 cpu=dev->id; \ |
| 61 | 62 | return sprintf(buf, "%lx\n", name[cpu]); \ |
| @@ -63,7 +64,8 @@ show_##name(struct sys_device *dev, char *buf) \ · 1 unmodified line | ||
| 63 | 64 | |
| 64 | 65 | #define store(name) \ |
| 65 | 66 | static ssize_t \ |
| 66 | −store_##name(struct sys_device *dev, const char *buf, size_t size) \ | |
| 67 | +store_##name(struct sys_device *dev, struct sysdev_attribute *attr, \ | |
| 68 | + const char *buf, size_t size) \ | |
| 67 | 69 | { \ |
| 68 | 70 | unsigned int cpu=dev->id; \ |
| 69 | 71 | name[cpu] = simple_strtoull(buf, NULL, 16); \ |
| @@ -76,7 +78,8 @@ show(call_start) · 6 unmodified lines | ||
| 76 | 78 | * processor. The cpu number in driver is only used for storing data. |
| 77 | 79 | */ |
| 78 | 80 | static ssize_t |
| 79 | −store_call_start(struct sys_device *dev, const char *buf, size_t size) | |
| 81 | +store_call_start(struct sys_device *dev, struct sysdev_attribute *attr, | |
| 82 | + const char *buf, size_t size) | |
| 80 | 83 | { |
| 81 | 84 | unsigned int cpu=dev->id; |
| 82 | 85 | unsigned long call_start = simple_strtoull(buf, NULL, 16); |
| @@ -124,14 +127,16 @@ show(err_type_info) · 41 unmodified lines | ||
| 124 | 127 | store(err_type_info) |
| 125 | 128 | |
| 126 | 129 | static ssize_t |
| 127 | −show_virtual_to_phys(struct sys_device *dev, char *buf) | |
| 130 | +show_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr, | |
| 131 | + char *buf) | |
| 128 | 132 | { |
| 129 | 133 | unsigned int cpu=dev->id; |
| 130 | 134 | return sprintf(buf, "%lx\n", phys_addr[cpu]); |
| 131 | 135 | } |
| 132 | 136 | |
| 133 | 137 | static ssize_t |
| 134 | −store_virtual_to_phys(struct sys_device *dev, const char *buf, size_t size) | |
| 138 | +store_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr, | |
| 139 | + const char *buf, size_t size) | |
| 135 | 140 | { |
| 136 | 141 | unsigned int cpu=dev->id; |
| 137 | 142 | u64 virt_addr=simple_strtoull(buf, NULL, 16); |
| @@ -154,7 +159,8 @@ show(err_struct_info) · 16 unmodified lines | ||
| 154 | 159 | store(err_struct_info) |
| 155 | 160 | |
| 156 | 161 | static ssize_t |
| 157 | −show_err_data_buffer(struct sys_device *dev, char *buf) | |
| 162 | +show_err_data_buffer(struct sys_device *dev, | |
| 163 | + struct sysdev_attribute *attr, char *buf) | |
| 158 | 164 | { |
| 159 | 165 | unsigned int cpu=dev->id; |
| 160 | 166 | |
| @@ -165,7 +171,9 @@ show_err_data_buffer(struct sys_device *dev, char *buf) · 4 unmodified lines | ||
| 165 | 171 | } |
| 166 | 172 | |
| 167 | 173 | static ssize_t |
| 168 | −store_err_data_buffer(struct sys_device *dev, const char *buf, size_t size) | |
| 174 | +store_err_data_buffer(struct sys_device *dev, | |
| 175 | + struct sysdev_attribute *attr, | |
| 176 | + const char *buf, size_t size) | |
| 169 | 177 | { |
| 170 | 178 | unsigned int cpu=dev->id; |
| 171 | 179 | int ret; |
| @@ -522,8 +522,8 @@ static int __init rtlx_module_init(void) · 521 unmodified lines | ||
| 522 | 522 | atomic_set(&channel_wqs[i].in_open, 0); |
| 523 | 523 | mutex_init(&channel_wqs[i].mutex); |
| 524 | 524 | |
| 525 | − dev = device_create(mt_class, NULL, MKDEV(major, i), | |
| 526 | − "%s%d", module_name, i); | |
| 525 | + dev = device_create_drvdata(mt_class, NULL, MKDEV(major, i), | |
| 526 | + NULL, "%s%d", module_name, i); | |
| 527 | 527 | if (IS_ERR(dev)) { |
| 528 | 528 | err = PTR_ERR(dev); |
| 529 | 529 | goto out_chrdev; |
| @@ -576,7 +576,8 @@ static int __init sbprof_tb_init(void) · 575 unmodified lines | ||
| 576 | 576 | |
| 577 | 577 | tb_class = tbc; |
| 578 | 578 | |
| 579 | − dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), "tb"); | |
| 579 | + dev = device_create_drvdata(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), | |
| 580 | + NULL, "tb"); | |
| 580 | 581 | if (IS_ERR(dev)) { |
| 581 | 582 | err = PTR_ERR(dev); |
| 582 | 583 | goto out_class; |
| @@ -28,7 +28,9 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices); · 27 unmodified lines | ||
| 28 | 28 | /* Time in microseconds we delay before sleeping in the idle loop */ |
| 29 | 29 | DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 }; |
| 30 | 30 | |
| 31 | −static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf, | |
| 31 | +static ssize_t store_smt_snooze_delay(struct sys_device *dev, | |
| 32 | + struct sysdev_attribute *attr, | |
| 33 | + const char *buf, | |
| 32 | 34 | size_t count) |
| 33 | 35 | { |
| 34 | 36 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); |
| @@ -44,7 +46,9 @@ static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf, · 9 unmodified lines | ||
| 44 | 46 | return count; |
| 45 | 47 | } |
| 46 | 48 | |
| 47 | −static ssize_t show_smt_snooze_delay(struct sys_device *dev, char *buf) | |
| 49 | +static ssize_t show_smt_snooze_delay(struct sys_device *dev, | |
| 50 | + struct sysdev_attribute *attr, | |
| 51 | + char *buf) | |
| 48 | 52 | { |
| 49 | 53 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); |
| 50 | 54 | |
| @@ -152,14 +156,17 @@ static unsigned long write_##NAME(unsigned long val) \ · 101 unmodified lines | ||
| 152 | 156 | mtspr(ADDRESS, val); \ |
| 153 | 157 | return 0; \ |
| 154 | 158 | } \ |
| 155 | −static ssize_t show_##NAME(struct sys_device *dev, char *buf) \ | |
| 159 | +static ssize_t show_##NAME(struct sys_device *dev, \ | |
| 160 | + struct sysdev_attribute *attr, \ | |
| 161 | + char *buf) \ | |
| 156 | 162 | { \ |
| 157 | 163 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ |
| 158 | 164 | unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \ |
| 159 | 165 | return sprintf(buf, "%lx\n", val); \ |
| 160 | 166 | } \ |
| 161 | 167 | static ssize_t __used \ |
| 162 | − store_##NAME(struct sys_device *dev, const char *buf, size_t count) \ | |
| 168 | + store_##NAME(struct sys_device *dev, struct sysdev_attribute *attr, \ | |
| 169 | + const char *buf, size_t count) \ | |
| 163 | 170 | { \ |
| 164 | 171 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ |
| 165 | 172 | unsigned long val; \ |
| @@ -97,7 +97,8 @@ static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iom · 96 unmodified lines | ||
| 97 | 97 | return value.spe[spu->spe_id]; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | −static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf) | |
| 100 | +static ssize_t spu_show_temp(struct sys_device *sysdev, struct sysdev_attribute *attr, | |
| 101 | + char *buf) | |
| 101 | 102 | { |
| 102 | 103 | u8 value; |
| 103 | 104 | struct cbe_pmd_regs __iomem *pmd_regs; |
| @@ -146,32 +147,38 @@ static ssize_t store_throttle(struct cbe_pmd_regs __iomem *pmd_regs, const char · 42 unmodified lines | ||
| 146 | 147 | return size; |
| 147 | 148 | } |
| 148 | 149 | |
| 149 | −static ssize_t spu_show_throttle_end(struct sys_device *sysdev, char *buf) | |
| 150 | +static ssize_t spu_show_throttle_end(struct sys_device *sysdev, | |
| 151 | + struct sysdev_attribute *attr, char *buf) | |
| 150 | 152 | { |
| 151 | 153 | return show_throttle(get_pmd_regs(sysdev), buf, 0); |
| 152 | 154 | } |
| 153 | 155 | |
| 154 | −static ssize_t spu_show_throttle_begin(struct sys_device *sysdev, char *buf) | |
| 156 | +static ssize_t spu_show_throttle_begin(struct sys_device *sysdev, | |
| 157 | + struct sysdev_attribute *attr, char *buf) | |
| 155 | 158 | { |
| 156 | 159 | return show_throttle(get_pmd_regs(sysdev), buf, 8); |
| 157 | 160 | } |
| 158 | 161 | |
| 159 | −static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev, char *buf) | |
| 162 | +static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev, | |
| 163 | + struct sysdev_attribute *attr, char *buf) | |
| 160 | 164 | { |
| 161 | 165 | return show_throttle(get_pmd_regs(sysdev), buf, 16); |
| 162 | 166 | } |
| 163 | 167 | |
| 164 | −static ssize_t spu_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size) | |
| 168 | +static ssize_t spu_store_throttle_end(struct sys_device *sysdev, | |
| 169 | + struct sysdev_attribute *attr, const char *buf, size_t size) | |
| 165 | 170 | { |
| 166 | 171 | return store_throttle(get_pmd_regs(sysdev), buf, size, 0); |
| 167 | 172 | } |
| 168 | 173 | |
| 169 | −static ssize_t spu_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size) | |
| 174 | +static ssize_t spu_store_throttle_begin(struct sys_device *sysdev, | |
| 175 | + struct sysdev_attribute *attr, const char *buf, size_t size) | |
| 170 | 176 | { |
| 171 | 177 | return store_throttle(get_pmd_regs(sysdev), buf, size, 8); |
| 172 | 178 | } |
| 173 | 179 | |
| 174 | −static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size) | |
| 180 | +static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev, | |
| 181 | + struct sysdev_attribute *attr, const char *buf, size_t size) | |
| 175 | 182 | { |
| 176 | 183 | return store_throttle(get_pmd_regs(sysdev), buf, size, 16); |
| 177 | 184 | } |
| @@ -192,43 +199,51 @@ static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos) · 14 unmodified lines | ||
| 192 | 199 | |
| 193 | 200 | /* shows the temperature of the DTS on the PPE, |
| 194 | 201 | * located near the linear thermal sensor */ |
| 195 | −static ssize_t ppe_show_temp0(struct sys_device *sysdev, char *buf) | |
| 202 | +static ssize_t ppe_show_temp0(struct sys_device *sysdev, | |
| 203 | + struct sysdev_attribute *attr, char *buf) | |
| 196 | 204 | { |
| 197 | 205 | return ppe_show_temp(sysdev, buf, 32); |
| 198 | 206 | } |
| 199 | 207 | |
| 200 | 208 | /* shows the temperature of the second DTS on the PPE */ |
| 201 | −static ssize_t ppe_show_temp1(struct sys_device *sysdev, char *buf) | |
| 209 | +static ssize_t ppe_show_temp1(struct sys_device *sysdev, | |
| 210 | + struct sysdev_attribute *attr, char *buf) | |
| 202 | 211 | { |
| 203 | 212 | return ppe_show_temp(sysdev, buf, 0); |
| 204 | 213 | } |
| 205 | 214 | |
| 206 | −static ssize_t ppe_show_throttle_end(struct sys_device *sysdev, char *buf) | |
| 215 | +static ssize_t ppe_show_throttle_end(struct sys_device *sysdev, | |
| 216 | + struct sysdev_attribute *attr, char *buf) | |
| 207 | 217 | { |
| 208 | 218 | return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 32); |
| 209 | 219 | } |
| 210 | 220 | |
| 211 | −static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev, char *buf) | |
| 221 | +static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev, | |
| 222 | + struct sysdev_attribute *attr, char *buf) | |
| 212 | 223 | { |
| 213 | 224 | return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 40); |
| 214 | 225 | } |
| 215 | 226 | |
| 216 | −static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev, char *buf) | |
| 227 | +static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev, | |
| 228 | + struct sysdev_attribute *attr, char *buf) | |
| 217 | 229 | { |
| 218 | 230 | return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 48); |
| 219 | 231 | } |
| 220 | 232 | |
| 221 | −static ssize_t ppe_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size) | |
| 233 | +static ssize_t ppe_store_throttle_end(struct sys_device *sysdev, | |
| 234 | + struct sysdev_attribute *attr, const char *buf, size_t size) | |
| 222 | 235 | { |
| 223 | 236 | return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 32); |
| 224 | 237 | } |
| 225 | 238 | |
| 226 | −static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size) | |
| 239 | +static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev, | |
| 240 | + struct sysdev_attribute *attr, const char *buf, size_t size) | |
| 227 | 241 | { |
| 228 | 242 | return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 40); |
| 229 | 243 | } |
| 230 | 244 | |
| 231 | −static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size) | |
| 245 | +static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev, | |
| 246 | + struct sysdev_attribute *attr, const char *buf, size_t size) | |
| 232 | 247 | { |
| 233 | 248 | return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 48); |
| 234 | 249 | } |
| @@ -703,7 +703,8 @@ static unsigned long long spu_acct_time(struct spu *spu, · 702 unmodified lines | ||
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | |
| 706 | −static ssize_t spu_stat_show(struct sys_device *sysdev, char *buf) | |
| 706 | +static ssize_t spu_stat_show(struct sys_device *sysdev, | |
| 707 | + struct sysdev_attribute *attr, char *buf) | |
| 707 | 708 | { |
| 708 | 709 | struct spu *spu = container_of(sysdev, struct spu, sysdev); |
| 709 | 710 | |
| @@ -367,7 +367,7 @@ static void chrp_pci_fixup_vt8231_ata(struct pci_dev *viaide) · 366 unmodified lines | ||
| 367 | 367 | viaisa = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL); |
| 368 | 368 | if (!viaisa) |
| 369 | 369 | return; |
| 370 | − printk("Fixing VIA IDE, force legacy mode on '%s'\n", viaide->dev.bus_id); | |
| 370 | + dev_info(&viaide->dev, "Fixing VIA IDE, force legacy mode on\n"); | |
| 371 | 371 | |
| 372 | 372 | pci_read_config_byte(viaide, PCI_CLASS_PROG, &progif); |
| 373 | 373 | pci_write_config_byte(viaide, PCI_CLASS_PROG, progif & ~0x5); |
| @@ -864,7 +864,8 @@ int setup_profiling_timer(unsigned int multiplier) · 863 unmodified lines | ||
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | #ifdef CONFIG_HOTPLUG_CPU |
| 867 | −static ssize_t cpu_configure_show(struct sys_device *dev, char *buf) | |
| 867 | +static ssize_t cpu_configure_show(struct sys_device *dev, | |
| 868 | + struct sysdev_attribute *attr, char *buf) | |
| 868 | 869 | { |
| 869 | 870 | ssize_t count; |
| 870 | 871 | |
| @@ -874,8 +875,9 @@ static ssize_t cpu_configure_show(struct sys_device *dev, char *buf) · 3 unmodified lines | ||
| 874 | 875 | return count; |
| 875 | 876 | } |
| 876 | 877 | |
| 877 | −static ssize_t cpu_configure_store(struct sys_device *dev, const char *buf, | |
| 878 | − size_t count) | |
| 878 | +static ssize_t cpu_configure_store(struct sys_device *dev, | |
| 879 | + struct sysdev_attribute *attr, | |
| 880 | + const char *buf, size_t count) | |
| 879 | 881 | { |
| 880 | 882 | int cpu = dev->id; |
| 881 | 883 | int val, rc; |
| @@ -922,7 +924,8 @@ out: · 40 unmodified lines | ||
| 922 | 924 | static SYSDEV_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store); |
| 923 | 925 | #endif /* CONFIG_HOTPLUG_CPU */ |
| 924 | 926 | |
| 925 | −static ssize_t cpu_polarization_show(struct sys_device *dev, char *buf) | |
| 927 | +static ssize_t cpu_polarization_show(struct sys_device *dev, | |
| 928 | + struct sysdev_attribute *attr, char *buf) | |
| 926 | 929 | { |
| 927 | 930 | int cpu = dev->id; |
| 928 | 931 | ssize_t count; |
| @@ -950,7 +953,8 @@ static ssize_t cpu_polarization_show(struct sys_device *dev, char *buf) · 21 unmodified lines | ||
| 950 | 953 | } |
| 951 | 954 | static SYSDEV_ATTR(polarization, 0444, cpu_polarization_show, NULL); |
| 952 | 955 | |
| 953 | −static ssize_t show_cpu_address(struct sys_device *dev, char *buf) | |
| 956 | +static ssize_t show_cpu_address(struct sys_device *dev, | |
| 957 | + struct sysdev_attribute *attr, char *buf) | |
| 954 | 958 | { |
| 955 | 959 | return sprintf(buf, "%d\n", __cpu_logical_map[dev->id]); |
| 956 | 960 | } |
| @@ -970,7 +974,8 @@ static struct attribute_group cpu_common_attr_group = { · 13 unmodified lines | ||
| 970 | 974 | .attrs = cpu_common_attrs, |
| 971 | 975 | }; |
| 972 | 976 | |
| 973 | −static ssize_t show_capability(struct sys_device *dev, char *buf) | |
| 977 | +static ssize_t show_capability(struct sys_device *dev, | |
| 978 | + struct sysdev_attribute *attr, char *buf) | |
| 974 | 979 | { |
| 975 | 980 | unsigned int capability; |
| 976 | 981 | int rc; |
| @@ -982,7 +987,8 @@ static ssize_t show_capability(struct sys_device *dev, char *buf) · 5 unmodified lines | ||
| 982 | 987 | } |
| 983 | 988 | static SYSDEV_ATTR(capability, 0444, show_capability, NULL); |
| 984 | 989 | |
| 985 | −static ssize_t show_idle_count(struct sys_device *dev, char *buf) | |
| 990 | +static ssize_t show_idle_count(struct sys_device *dev, | |
| 991 | + struct sysdev_attribute *attr, char *buf) | |
| 986 | 992 | { |
| 987 | 993 | struct s390_idle_data *idle; |
| 988 | 994 | unsigned long long idle_count; |
| @@ -995,7 +1001,8 @@ static ssize_t show_idle_count(struct sys_device *dev, char *buf) · 6 unmodified lines | ||
| 995 | 1001 | } |
| 996 | 1002 | static SYSDEV_ATTR(idle_count, 0444, show_idle_count, NULL); |
| 997 | 1003 | |
| 998 | −static ssize_t show_idle_time(struct sys_device *dev, char *buf) | |
| 1004 | +static ssize_t show_idle_time(struct sys_device *dev, | |
| 1005 | + struct sysdev_attribute *attr, char *buf) | |
| 999 | 1006 | { |
| 1000 | 1007 | struct s390_idle_data *idle; |
| 1001 | 1008 | unsigned long long new_time; |
| @@ -1112,7 +1119,9 @@ out: · 110 unmodified lines | ||
| 1112 | 1119 | return rc; |
| 1113 | 1120 | } |
| 1114 | 1121 | |
| 1115 | −static ssize_t __ref rescan_store(struct sys_device *dev, const char *buf, | |
| 1122 | +static ssize_t __ref rescan_store(struct sys_device *dev, | |
| 1123 | + struct sysdev_attribute *attr, | |
| 1124 | + const char *buf, | |
| 1116 | 1125 | size_t count) |
| 1117 | 1126 | { |
| 1118 | 1127 | int rc; |
| @@ -1123,7 +1132,9 @@ static ssize_t __ref rescan_store(struct sys_device *dev, const char *buf, · 4 unmodified lines | ||
| 1123 | 1132 | static SYSDEV_ATTR(rescan, 0200, NULL, rescan_store); |
| 1124 | 1133 | #endif /* CONFIG_HOTPLUG_CPU */ |
| 1125 | 1134 | |
| 1126 | −static ssize_t dispatching_show(struct sys_device *dev, char *buf) | |
| 1135 | +static ssize_t dispatching_show(struct sys_device *dev, | |
| 1136 | + struct sysdev_attribute *attr, | |
| 1137 | + char *buf) | |
| 1127 | 1138 | { |
| 1128 | 1139 | ssize_t count; |
| 1129 | 1140 | |
| @@ -1133,8 +1144,9 @@ static ssize_t dispatching_show(struct sys_device *dev, char *buf) · 3 unmodified lines | ||
| 1133 | 1144 | return count; |
| 1134 | 1145 | } |
| 1135 | 1146 | |
| 1136 | −static ssize_t dispatching_store(struct sys_device *dev, const char *buf, | |
| 1137 | − size_t count) | |
| 1147 | +static ssize_t dispatching_store(struct sys_device *dev, | |
| 1148 | + struct sysdev_attribute *attr, | |
| 1149 | + const char *buf, size_t count) | |
| 1138 | 1150 | { |
| 1139 | 1151 | int val, rc; |
| 1140 | 1152 | char delim; |
| @@ -1100,7 +1100,9 @@ static inline struct etr_aib *etr_aib_from_dev(struct sys_device *dev) · 1099 unmodified lines | ||
| 1100 | 1100 | return etr_port1_online ? &etr_port1 : NULL; |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | −static ssize_t etr_online_show(struct sys_device *dev, char *buf) | |
| 1103 | +static ssize_t etr_online_show(struct sys_device *dev, | |
| 1104 | + struct sysdev_attribute *attr, | |
| 1105 | + char *buf) | |
| 1104 | 1106 | { |
| 1105 | 1107 | unsigned int online; |
| 1106 | 1108 | |
| @@ -1109,7 +1111,8 @@ static ssize_t etr_online_show(struct sys_device *dev, char *buf) · 2 unmodified lines | ||
| 1109 | 1111 | } |
| 1110 | 1112 | |
| 1111 | 1113 | static ssize_t etr_online_store(struct sys_device *dev, |
| 1112 | − const char *buf, size_t count) | |
| 1114 | + struct sysdev_attribute *attr, | |
| 1115 | + const char *buf, size_t count) | |
| 1113 | 1116 | { |
| 1114 | 1117 | unsigned int value; |
| 1115 | 1118 | |
| @@ -1136,7 +1139,9 @@ static ssize_t etr_online_store(struct sys_device *dev, · 20 unmodified lines | ||
| 1136 | 1139 | |
| 1137 | 1140 | static SYSDEV_ATTR(online, 0600, etr_online_show, etr_online_store); |
| 1138 | 1141 | |
| 1139 | −static ssize_t etr_stepping_control_show(struct sys_device *dev, char *buf) | |
| 1142 | +static ssize_t etr_stepping_control_show(struct sys_device *dev, | |
| 1143 | + struct sysdev_attribute *attr, | |
| 1144 | + char *buf) | |
| 1140 | 1145 | { |
| 1141 | 1146 | return sprintf(buf, "%i\n", (dev == &etr_port0_dev) ? |
| 1142 | 1147 | etr_eacr.e0 : etr_eacr.e1); |
| @@ -1144,7 +1149,8 @@ static ssize_t etr_stepping_control_show(struct sys_device *dev, char *buf) · 1 unmodified line | ||
| 1144 | 1149 | |
| 1145 | 1150 | static SYSDEV_ATTR(stepping_control, 0400, etr_stepping_control_show, NULL); |
| 1146 | 1151 | |
| 1147 | −static ssize_t etr_mode_code_show(struct sys_device *dev, char *buf) | |
| 1152 | +static ssize_t etr_mode_code_show(struct sys_device *dev, | |
| 1153 | + struct sysdev_attribute *attr, char *buf) | |
| 1148 | 1154 | { |
| 1149 | 1155 | if (!etr_port0_online && !etr_port1_online) |
| 1150 | 1156 | /* Status word is not uptodate if both ports are offline. */ |
| @@ -1155,7 +1161,8 @@ static ssize_t etr_mode_code_show(struct sys_device *dev, char *buf) · 4 unmodified lines | ||
| 1155 | 1161 | |
| 1156 | 1162 | static SYSDEV_ATTR(state_code, 0400, etr_mode_code_show, NULL); |
| 1157 | 1163 | |
| 1158 | −static ssize_t etr_untuned_show(struct sys_device *dev, char *buf) | |
| 1164 | +static ssize_t etr_untuned_show(struct sys_device *dev, | |
| 1165 | + struct sysdev_attribute *attr, char *buf) | |
| 1159 | 1166 | { |
| 1160 | 1167 | struct etr_aib *aib = etr_aib_from_dev(dev); |
| 1161 | 1168 | |
| @@ -1166,7 +1173,8 @@ static ssize_t etr_untuned_show(struct sys_device *dev, char *buf) · 4 unmodified lines | ||
| 1166 | 1173 | |
| 1167 | 1174 | static SYSDEV_ATTR(untuned, 0400, etr_untuned_show, NULL); |
| 1168 | 1175 | |
| 1169 | −static ssize_t etr_network_id_show(struct sys_device *dev, char *buf) | |
| 1176 | +static ssize_t etr_network_id_show(struct sys_device *dev, | |
| 1177 | + struct sysdev_attribute *attr, char *buf) | |
| 1170 | 1178 | { |
| 1171 | 1179 | struct etr_aib *aib = etr_aib_from_dev(dev); |
| 1172 | 1180 | |
| @@ -1177,7 +1185,8 @@ static ssize_t etr_network_id_show(struct sys_device *dev, char *buf) · 4 unmodified lines | ||
| 1177 | 1185 | |
| 1178 | 1186 | static SYSDEV_ATTR(network, 0400, etr_network_id_show, NULL); |
| 1179 | 1187 | |
| 1180 | −static ssize_t etr_id_show(struct sys_device *dev, char *buf) | |
| 1188 | +static ssize_t etr_id_show(struct sys_device *dev, | |
| 1189 | + struct sysdev_attribute *attr, char *buf) | |
| 1181 | 1190 | { |
| 1182 | 1191 | struct etr_aib *aib = etr_aib_from_dev(dev); |
| 1183 | 1192 | |
| @@ -1188,7 +1197,8 @@ static ssize_t etr_id_show(struct sys_device *dev, char *buf) · 4 unmodified lines | ||
| 1188 | 1197 | |
| 1189 | 1198 | static SYSDEV_ATTR(id, 0400, etr_id_show, NULL); |
| 1190 | 1199 | |
| 1191 | −static ssize_t etr_port_number_show(struct sys_device *dev, char *buf) | |
| 1200 | +static ssize_t etr_port_number_show(struct sys_device *dev, | |
| 1201 | + struct sysdev_attribute *attr, char *buf) | |
| 1192 | 1202 | { |
| 1193 | 1203 | struct etr_aib *aib = etr_aib_from_dev(dev); |
| 1194 | 1204 | |
| @@ -1199,7 +1209,8 @@ static ssize_t etr_port_number_show(struct sys_device *dev, char *buf) · 4 unmodified lines | ||
| 1199 | 1209 | |
| 1200 | 1210 | static SYSDEV_ATTR(port, 0400, etr_port_number_show, NULL); |
| 1201 | 1211 | |
| 1202 | −static ssize_t etr_coupled_show(struct sys_device *dev, char *buf) | |
| 1212 | +static ssize_t etr_coupled_show(struct sys_device *dev, | |
| 1213 | + struct sysdev_attribute *attr, char *buf) | |
| 1203 | 1214 | { |
| 1204 | 1215 | struct etr_aib *aib = etr_aib_from_dev(dev); |
| 1205 | 1216 | |
| @@ -1210,7 +1221,8 @@ static ssize_t etr_coupled_show(struct sys_device *dev, char *buf) · 4 unmodified lines | ||
| 1210 | 1221 | |
| 1211 | 1222 | static SYSDEV_ATTR(coupled, 0400, etr_coupled_show, NULL); |
| 1212 | 1223 | |
| 1213 | −static ssize_t etr_local_time_show(struct sys_device *dev, char *buf) | |
| 1224 | +static ssize_t etr_local_time_show(struct sys_device *dev, | |
| 1225 | + struct sysdev_attribute *attr, char *buf) | |
| 1214 | 1226 | { |
| 1215 | 1227 | struct etr_aib *aib = etr_aib_from_dev(dev); |
| 1216 | 1228 | |
| @@ -1221,7 +1233,8 @@ static ssize_t etr_local_time_show(struct sys_device *dev, char *buf) · 4 unmodified lines | ||
| 1221 | 1233 | |
| 1222 | 1234 | static SYSDEV_ATTR(local_time, 0400, etr_local_time_show, NULL); |
| 1223 | 1235 | |
| 1224 | −static ssize_t etr_utc_offset_show(struct sys_device *dev, char *buf) | |
| 1236 | +static ssize_t etr_utc_offset_show(struct sys_device *dev, | |
| 1237 | + struct sysdev_attribute *attr, char *buf) | |
| 1225 | 1238 | { |
| 1226 | 1239 | struct etr_aib *aib = etr_aib_from_dev(dev); |
| 1227 | 1240 | |
| @@ -23,7 +23,8 @@ static struct sysdev_class dma_sysclass = { · 22 unmodified lines | ||
| 23 | 23 | }; |
| 24 | 24 | EXPORT_SYMBOL(dma_sysclass); |
| 25 | 25 | |
| 26 | −static ssize_t dma_show_devices(struct sys_device *dev, char *buf) | |
| 26 | +static ssize_t dma_show_devices(struct sys_device *dev, | |
| 27 | + struct sysdev_attribute *attr, char *buf) | |
| 27 | 28 | { |
| 28 | 29 | ssize_t len = 0; |
| 29 | 30 | int i; |
| @@ -57,13 +58,15 @@ static int __init dma_sysclass_init(void) · 27 unmodified lines | ||
| 57 | 58 | } |
| 58 | 59 | postcore_initcall(dma_sysclass_init); |
| 59 | 60 | |
| 60 | −static ssize_t dma_show_dev_id(struct sys_device *dev, char *buf) | |
| 61 | +static ssize_t dma_show_dev_id(struct sys_device *dev, | |
| 62 | + struct sysdev_attribute *attr, char *buf) | |
| 61 | 63 | { |
| 62 | 64 | struct dma_channel *channel = to_dma_channel(dev); |
| 63 | 65 | return sprintf(buf, "%s\n", channel->dev_id); |
| 64 | 66 | } |
| 65 | 67 | |
| 66 | 68 | static ssize_t dma_store_dev_id(struct sys_device *dev, |
| 69 | + struct sysdev_attribute *attr, | |
| 67 | 70 | const char *buf, size_t count) |
| 68 | 71 | { |
| 69 | 72 | struct dma_channel *channel = to_dma_channel(dev); |
| @@ -74,6 +77,7 @@ static ssize_t dma_store_dev_id(struct sys_device *dev, · 4 unmodified lines | ||
| 74 | 77 | static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id); |
| 75 | 78 | |
| 76 | 79 | static ssize_t dma_store_config(struct sys_device *dev, |
| 80 | + struct sysdev_attribute *attr, | |
| 77 | 81 | const char *buf, size_t count) |
| 78 | 82 | { |
| 79 | 83 | struct dma_channel *channel = to_dma_channel(dev); |
| @@ -87,13 +91,15 @@ static ssize_t dma_store_config(struct sys_device *dev, · 7 unmodified lines | ||
| 87 | 91 | |
| 88 | 92 | static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config); |
| 89 | 93 | |
| 90 | −static ssize_t dma_show_mode(struct sys_device *dev, char *buf) | |
| 94 | +static ssize_t dma_show_mode(struct sys_device *dev, | |
| 95 | + struct sysdev_attribute *attr, char *buf) | |
| 91 | 96 | { |
| 92 | 97 | struct dma_channel *channel = to_dma_channel(dev); |
| 93 | 98 | return sprintf(buf, "0x%08x\n", channel->mode); |
| 94 | 99 | } |
| 95 | 100 | |
| 96 | 101 | static ssize_t dma_store_mode(struct sys_device *dev, |
| 102 | + struct sysdev_attribute *attr, | |
| 97 | 103 | const char *buf, size_t count) |
| 98 | 104 | { |
| 99 | 105 | struct dma_channel *channel = to_dma_channel(dev); |
| @@ -104,7 +110,8 @@ static ssize_t dma_store_mode(struct sys_device *dev, · 4 unmodified lines | ||
| 104 | 110 | static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode); |
| 105 | 111 | |
| 106 | 112 | #define dma_ro_attr(field, fmt) \ |
| 107 | −static ssize_t dma_show_##field(struct sys_device *dev, char *buf) \ | |
| 113 | +static ssize_t dma_show_##field(struct sys_device *dev, \ | |
| 114 | + struct sysdev_attribute *attr, char *buf)\ | |
| 108 | 115 | { \ |
| 109 | 116 | struct dma_channel *channel = to_dma_channel(dev); \ |
| 110 | 117 | return sprintf(buf, fmt, channel->field); \ |
| @@ -401,7 +401,7 @@ static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_de · 400 unmodified lines | ||
| 401 | 401 | dev->ofdev.node = dp; |
| 402 | 402 | dev->ofdev.dev.parent = &dev->bus->ofdev.dev; |
| 403 | 403 | dev->ofdev.dev.bus = &ebus_bus_type; |
| 404 | − sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node); | |
| 404 | + dev_set_name(&dev->ofdev.dev, "ebus[%08x]", dp->node); | |
| 405 | 405 | |
| 406 | 406 | /* Register with core */ |
| 407 | 407 | if (of_device_register(&dev->ofdev) != 0) |
| @@ -501,7 +501,7 @@ void __init ebus_init(void) · 93 unmodified lines | ||
| 501 | 501 | ebus->ofdev.node = dp; |
| 502 | 502 | ebus->ofdev.dev.parent = &pdev->dev; |
| 503 | 503 | ebus->ofdev.dev.bus = &ebus_bus_type; |
| 504 | − sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus); | |
| 504 | + dev_set_name(&ebus->ofdev.dev, "ebus%d", num_ebus); | |
| 505 | 505 | |
| 506 | 506 | /* Register with core */ |
| 507 | 507 | if (of_device_register(&ebus->ofdev) != 0) |
| @@ -797,9 +797,9 @@ static struct of_device * __init scan_one_device(struct device_node *dp, · 796 unmodified lines | ||
| 797 | 797 | op->dev.parent = parent; |
| 798 | 798 | op->dev.bus = &of_platform_bus_type; |
| 799 | 799 | if (!parent) |
| 800 | − strcpy(op->dev.bus_id, "root"); | |
| 800 | + dev_set_name(&op->dev, "root"); | |
| 801 | 801 | else |
| 802 | − sprintf(op->dev.bus_id, "%08x", dp->node); | |
| 802 | + dev_set_name(&op->dev, "%08x", dp->node); | |
| 803 | 803 | |
| 804 | 804 | if (of_device_register(op)) { |
| 805 | 805 | printk("%s: Could not register of device.\n", |
| @@ -408,7 +408,7 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, · 407 unmodified lines | ||
| 408 | 408 | dev->class = class >> 8; |
| 409 | 409 | dev->revision = class & 0xff; |
| 410 | 410 | |
| 411 | − sprintf(dev->dev.bus_id, "%04x:%02x:%02x.%d", pci_domain_nr(bus), | |
| 411 | + dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus), | |
| 412 | 412 | dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); |
| 413 | 413 | |
| 414 | 414 | if (ofpci_verbose) |
| @@ -14,7 +14,8 @@ · 13 unmodified lines | ||
| 14 | 14 | static DEFINE_PER_CPU(struct hv_mmu_statistics, mmu_stats) __attribute__((aligned(64))); |
| 15 | 15 | |
| 16 | 16 | #define SHOW_MMUSTAT_ULONG(NAME) \ |
| 17 | −static ssize_t show_##NAME(struct sys_device *dev, char *buf) \ | |
| 17 | +static ssize_t show_##NAME(struct sys_device *dev, \ | |
| 18 | + struct sysdev_attribute *attr, char *buf) \ | |
| 18 | 19 | { \ |
| 19 | 20 | struct hv_mmu_statistics *p = &per_cpu(mmu_stats, dev->id); \ |
| 20 | 21 | return sprintf(buf, "%lu\n", p->NAME); \ |
| @@ -135,13 +136,16 @@ static unsigned long write_mmustat_enable(unsigned long val) · 114 unmodified lines | ||
| 135 | 136 | return sun4v_mmustat_conf(ra, &orig_ra); |
| 136 | 137 | } |
| 137 | 138 | |
| 138 | −static ssize_t show_mmustat_enable(struct sys_device *s, char *buf) | |
| 139 | +static ssize_t show_mmustat_enable(struct sys_device *s, | |
| 140 | + struct sysdev_attribute *attr, char *buf) | |
| 139 | 141 | { |
| 140 | 142 | unsigned long val = run_on_cpu(s->id, read_mmustat_enable, 0); |
| 141 | 143 | return sprintf(buf, "%lx\n", val); |
| 142 | 144 | } |
| 143 | 145 | |
| 144 | −static ssize_t store_mmustat_enable(struct sys_device *s, const char *buf, size_t count) | |
| 146 | +static ssize_t store_mmustat_enable(struct sys_device *s, | |
| 147 | + struct sysdev_attribute *attr, const char *buf, | |
| 148 | + size_t count) | |
| 145 | 149 | { |
| 146 | 150 | unsigned long val, err; |
| 147 | 151 | int ret = sscanf(buf, "%ld", &val); |
| @@ -179,14 +183,16 @@ static void unregister_mmu_stats(struct sys_device *s) · 31 unmodified lines | ||
| 179 | 183 | #endif |
| 180 | 184 | |
| 181 | 185 | #define SHOW_CPUDATA_ULONG_NAME(NAME, MEMBER) \ |
| 182 | −static ssize_t show_##NAME(struct sys_device *dev, char *buf) \ | |
| 186 | +static ssize_t show_##NAME(struct sys_device *dev, \ | |
| 187 | + struct sysdev_attribute *attr, char *buf) \ | |
| 183 | 188 | { \ |
| 184 | 189 | cpuinfo_sparc *c = &cpu_data(dev->id); \ |
| 185 | 190 | return sprintf(buf, "%lu\n", c->MEMBER); \ |
| 186 | 191 | } |
| 187 | 192 | |
| 188 | 193 | #define SHOW_CPUDATA_UINT_NAME(NAME, MEMBER) \ |
| 189 | −static ssize_t show_##NAME(struct sys_device *dev, char *buf) \ | |
| 194 | +static ssize_t show_##NAME(struct sys_device *dev, \ | |
| 195 | + struct sysdev_attribute *attr, char *buf) \ | |
| 190 | 196 | { \ |
| 191 | 197 | cpuinfo_sparc *c = &cpu_data(dev->id); \ |
| 192 | 198 | return sprintf(buf, "%u\n", c->MEMBER); \ |
| @@ -224,7 +224,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, · 223 unmodified lines | ||
| 224 | 224 | if (!strcmp(type, "domain-services-port")) |
| 225 | 225 | bus_id_name = "ds"; |
| 226 | 226 | |
| 227 | − if (strlen(bus_id_name) >= KOBJ_NAME_LEN - 4) { | |
| 227 | + if (strlen(bus_id_name) >= BUS_ID_SIZE - 4) { | |
| 228 | 228 | printk(KERN_ERR "VIO: bus_id_name [%s] is too long.\n", |
| 229 | 229 | bus_id_name); |
| 230 | 230 | return NULL; |
| @@ -260,16 +260,14 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, · 29 unmodified lines | ||
| 260 | 260 | vio_fill_channel_info(hp, mp, vdev); |
| 261 | 261 | |
| 262 | 262 | if (!id) { |
| 263 | − snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s", | |
| 264 | − bus_id_name); | |
| 263 | + dev_set_name(&vdev->dev, "%s", bus_id_name); | |
| 265 | 264 | vdev->dev_no = ~(u64)0; |
| 266 | 265 | } else if (!cfg_handle) { |
| 267 | − snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s-%lu", | |
| 268 | − bus_id_name, *id); | |
| 266 | + dev_set_name(&vdev->dev, "%s-%lu", bus_id_name, *id); | |
| 269 | 267 | vdev->dev_no = *id; |
| 270 | 268 | } else { |
| 271 | − snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s-%lu-%lu", | |
| 272 | − bus_id_name, *cfg_handle, *id); | |
| 269 | + dev_set_name(&vdev->dev, "%s-%lu-%lu", bus_id_name, | |
| 270 | + *cfg_handle, *id); | |
| 273 | 271 | vdev->dev_no = *cfg_handle; |
| 274 | 272 | } |
| 275 | 273 | |
| @@ -292,12 +290,12 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, · 16 unmodified lines | ||
| 292 | 290 | } |
| 293 | 291 | vdev->dp = dp; |
| 294 | 292 | |
| 295 | − printk(KERN_INFO "VIO: Adding device %s\n", vdev->dev.bus_id); | |
| 293 | + printk(KERN_INFO "VIO: Adding device %s\n", dev_name(&vdev->dev)); | |
| 296 | 294 | |
| 297 | 295 | err = device_register(&vdev->dev); |
| 298 | 296 | if (err) { |
| 299 | 297 | printk(KERN_ERR "VIO: Could not register device %s, err=%d\n", |
| 300 | − vdev->dev.bus_id, err); | |
| 298 | + dev_name(&vdev->dev), err); | |
| 301 | 299 | kfree(vdev); |
| 302 | 300 | return NULL; |
| 303 | 301 | } |
| @@ -330,7 +328,7 @@ static void vio_remove(struct mdesc_handle *hp, u64 node) · 26 unmodified lines | ||
| 330 | 328 | dev = device_find_child(&root_vdev->dev, (void *) node, |
| 331 | 329 | vio_md_node_match); |
| 332 | 330 | if (dev) { |
| 333 | − printk(KERN_INFO "VIO: Removing device %s\n", dev->bus_id); | |
| 331 | + printk(KERN_INFO "VIO: Removing device %s\n", dev_name(dev)); | |
| 334 | 332 | |
| 335 | 333 | device_unregister(dev); |
| 336 | 334 | } |
| @@ -762,10 +762,14 @@ DEFINE_PER_CPU(struct sys_device, device_mce); · 761 unmodified lines | ||
| 762 | 762 | |
| 763 | 763 | /* Why are there no generic functions for this? */ |
| 764 | 764 | #define ACCESSOR(name, var, start) \ |
| 765 | − static ssize_t show_ ## name(struct sys_device *s, char *buf) { \ | |
| 765 | + static ssize_t show_ ## name(struct sys_device *s, \ | |
| 766 | + struct sysdev_attribute *attr, \ | |
| 767 | + char *buf) { \ | |
| 766 | 768 | return sprintf(buf, "%lx\n", (unsigned long)var); \ |
| 767 | 769 | } \ |
| 768 | − static ssize_t set_ ## name(struct sys_device *s,const char *buf,size_t siz) { \ | |
| 770 | + static ssize_t set_ ## name(struct sys_device *s, \ | |
| 771 | + struct sysdev_attribute *attr, \ | |
| 772 | + const char *buf, size_t siz) { \ | |
| 769 | 773 | char *end; \ |
| 770 | 774 | unsigned long new = simple_strtoul(buf, &end, 0); \ |
| 771 | 775 | if (end == buf) return -EINVAL; \ |
| @@ -786,14 +790,16 @@ ACCESSOR(bank3ctl,bank[3],mce_restart()) · 14 unmodified lines | ||
| 786 | 790 | ACCESSOR(bank4ctl,bank[4],mce_restart()) |
| 787 | 791 | ACCESSOR(bank5ctl,bank[5],mce_restart()) |
| 788 | 792 | |
| 789 | −static ssize_t show_trigger(struct sys_device *s, char *buf) | |
| 793 | +static ssize_t show_trigger(struct sys_device *s, struct sysdev_attribute *attr, | |
| 794 | + char *buf) | |
| 790 | 795 | { |
| 791 | 796 | strcpy(buf, trigger); |
| 792 | 797 | strcat(buf, "\n"); |
| 793 | 798 | return strlen(trigger) + 1; |
| 794 | 799 | } |
| 795 | 800 | |
| 796 | −static ssize_t set_trigger(struct sys_device *s,const char *buf,size_t siz) | |
| 801 | +static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr, | |
| 802 | + const char *buf,size_t siz) | |
| 797 | 803 | { |
| 798 | 804 | char *p; |
| 799 | 805 | int len; |
| @@ -806,12 +812,12 @@ static ssize_t set_trigger(struct sys_device *s,const char *buf,size_t siz) · 6 unmodified lines | ||
| 806 | 812 | } |
| 807 | 813 | |
| 808 | 814 | static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger); |
| 809 | −ACCESSOR(tolerant,tolerant,) | |
| 815 | +static SYSDEV_INT_ATTR(tolerant, 0644, tolerant); | |
| 810 | 816 | ACCESSOR(check_interval,check_interval,mce_restart()) |
| 811 | 817 | static struct sysdev_attribute *mce_attributes[] = { |
| 812 | 818 | &attr_bank0ctl, &attr_bank1ctl, &attr_bank2ctl, |
| 813 | 819 | &attr_bank3ctl, &attr_bank4ctl, &attr_bank5ctl, |
| 814 | − &attr_tolerant, &attr_check_interval, &attr_trigger, | |
| 820 | + &attr_tolerant.attr, &attr_check_interval, &attr_trigger, | |
| 815 | 821 | NULL |
| 816 | 822 | }; |
| 817 | 823 | |
| @@ -35,6 +35,7 @@ atomic_t therm_throt_en = ATOMIC_INIT(0); · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | #define define_therm_throt_sysdev_show_func(name) \ |
| 37 | 37 | static ssize_t therm_throt_sysdev_show_##name(struct sys_device *dev, \ |
| 38 | + struct sysdev_attribute *attr, \ | |
| 38 | 39 | char *buf) \ |
| 39 | 40 | { \ |
| 40 | 41 | unsigned int cpu = dev->id; \ |
| @@ -141,8 +141,8 @@ static __cpuinit int cpuid_device_create(int cpu) · 140 unmodified lines | ||
| 141 | 141 | { |
| 142 | 142 | struct device *dev; |
| 143 | 143 | |
| 144 | − dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), | |
| 145 | − "cpu%d", cpu); | |
| 144 | + dev = device_create_drvdata(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), | |
| 145 | + NULL, "cpu%d", cpu); | |
| 146 | 146 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
| 147 | 147 | } |
| 148 | 148 | |
| @@ -644,7 +644,9 @@ static void microcode_fini_cpu(int cpu) · 643 unmodified lines | ||
| 644 | 644 | mutex_unlock(µcode_mutex); |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | −static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz) | |
| 647 | +static ssize_t reload_store(struct sys_device *dev, | |
| 648 | + struct sysdev_attribute *attr, | |
| 649 | + const char *buf, size_t sz) | |
| 648 | 650 | { |
| 649 | 651 | struct ucode_cpu_info *uci = ucode_cpu_info + dev->id; |
| 650 | 652 | char *end; |
| @@ -674,14 +676,16 @@ static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz) · 23 unmodified lines | ||
| 674 | 676 | return sz; |
| 675 | 677 | } |
| 676 | 678 | |
| 677 | −static ssize_t version_show(struct sys_device *dev, char *buf) | |
| 679 | +static ssize_t version_show(struct sys_device *dev, | |
| 680 | + struct sysdev_attribute *attr, char *buf) | |
| 678 | 681 | { |
| 679 | 682 | struct ucode_cpu_info *uci = ucode_cpu_info + dev->id; |
| 680 | 683 | |
| 681 | 684 | return sprintf(buf, "0x%x\n", uci->rev); |
| 682 | 685 | } |
| 683 | 686 | |
| 684 | −static ssize_t pf_show(struct sys_device *dev, char *buf) | |
| 687 | +static ssize_t pf_show(struct sys_device *dev, | |
| 688 | + struct sysdev_attribute *attr, char *buf) | |
| 685 | 689 | { |
| 686 | 690 | struct ucode_cpu_info *uci = ucode_cpu_info + dev->id; |
| 687 | 691 | |
| @@ -149,8 +149,8 @@ static int __cpuinit msr_device_create(int cpu) · 148 unmodified lines | ||
| 149 | 149 | { |
| 150 | 150 | struct device *dev; |
| 151 | 151 | |
| 152 | − dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), | |
| 153 | − "msr%d", cpu); | |
| 152 | + dev = device_create_drvdata(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), | |
| 153 | + NULL, "msr%d", cpu); | |
| 154 | 154 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
| 155 | 155 | } |
| 156 | 156 | |
| @@ -314,8 +314,7 @@ int dma_supported(struct device *dev, u64 mask) · 313 unmodified lines | ||
| 314 | 314 | { |
| 315 | 315 | #ifdef CONFIG_PCI |
| 316 | 316 | if (mask > 0xffffffff && forbid_dac > 0) { |
| 317 | − printk(KERN_INFO "PCI: Disallowing DAC for device %s\n", | |
| 318 | − dev->bus_id); | |
| 317 | + dev_info(dev, "PCI: Disallowing DAC for device\n"); | |
| 319 | 318 | return 0; |
| 320 | 319 | } |
| 321 | 320 | #endif |
| @@ -342,8 +341,7 @@ int dma_supported(struct device *dev, u64 mask) · 20 unmodified lines | ||
| 342 | 341 | type. Normally this doesn't make any difference, but gives |
| 343 | 342 | more gentle handling of IOMMU overflow. */ |
| 344 | 343 | if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) { |
| 345 | − printk(KERN_INFO "%s: Force SAC with mask %Lx\n", | |
| 346 | − dev->bus_id, mask); | |
| 344 | + dev_info(dev, "Force SAC with mask %Lx\n", mask); | |
| 347 | 345 | return 0; |
| 348 | 346 | } |
| 349 | 347 | |
| @@ -198,9 +198,7 @@ static void iommu_full(struct device *dev, size_t size, int dir) · 197 unmodified lines | ||
| 198 | 198 | * out. Hopefully no network devices use single mappings that big. |
| 199 | 199 | */ |
| 200 | 200 | |
| 201 | − printk(KERN_ERR | |
| 202 | − "PCI-DMA: Out of IOMMU space for %lu bytes at device %s\n", | |
| 203 | − size, dev->bus_id); | |
| 201 | + dev_err(dev, "PCI-DMA: Out of IOMMU space for %lu bytes\n", size); | |
| 204 | 202 | |
| 205 | 203 | if (size > PAGE_SIZE*EMERGENCY_PAGES) { |
| 206 | 204 | if (dir == PCI_DMA_FROMDEVICE || dir == PCI_DMA_BIDIRECTIONAL) |
| @@ -1044,7 +1044,8 @@ int bsg_register_queue(struct request_queue *q, struct device *parent, · 1043 unmodified lines | ||
| 1044 | 1044 | bcd->release = release; |
| 1045 | 1045 | kref_init(&bcd->ref); |
| 1046 | 1046 | dev = MKDEV(bsg_major, bcd->minor); |
| 1047 | − class_dev = device_create(bsg_class, parent, dev, "%s", devname); | |
| 1047 | + class_dev = device_create_drvdata(bsg_class, parent, dev, NULL, | |
| 1048 | + "%s", devname); | |
| 1048 | 1049 | if (IS_ERR(class_dev)) { |
| 1049 | 1050 | ret = PTR_ERR(class_dev); |
| 1050 | 1051 | goto put_dev; |
| @@ -183,6 +183,7 @@ static int exact_lock(dev_t devt, void *data) · 182 unmodified lines | ||
| 183 | 183 | void add_disk(struct gendisk *disk) |
| 184 | 184 | { |
| 185 | 185 | struct backing_dev_info *bdi; |
| 186 | + int retval; | |
| 186 | 187 | |
| 187 | 188 | disk->flags |= GENHD_FL_UP; |
| 188 | 189 | blk_register_region(MKDEV(disk->major, disk->first_minor), |
| @@ -193,7 +194,8 @@ void add_disk(struct gendisk *disk) · 4 unmodified lines | ||
| 193 | 194 | |
| 194 | 195 | bdi = &disk->queue->backing_dev_info; |
| 195 | 196 | bdi_register_dev(bdi, MKDEV(disk->major, disk->first_minor)); |
| 196 | − sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi"); | |
| 197 | + retval = sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi"); | |
| 198 | + WARN_ON(retval); | |
| 197 | 199 | } |
| 198 | 200 | |
| 199 | 201 | EXPORT_SYMBOL(add_disk); |
| @@ -225,89 +227,111 @@ struct gendisk *get_gendisk(dev_t devt, int *part) · 25 unmodified lines | ||
| 225 | 227 | } |
| 226 | 228 | |
| 227 | 229 | /* |
| 228 | − * print a full list of all partitions - intended for places where the root | |
| 229 | − * filesystem can't be mounted and thus to give the victim some idea of what | |
| 230 | − * went wrong | |
| 230 | + * print a partitions - intended for places where the root filesystem can't be | |
| 231 | + * mounted and thus to give the victim some idea of what went wrong | |
| 231 | 232 | */ |
| 232 | −void __init printk_all_partitions(void) | |
| 233 | +static int printk_partition(struct device *dev, void *data) | |
| 233 | 234 | { |
| 234 | − struct device *dev; | |
| 235 | 235 | struct gendisk *sgp; |
| 236 | 236 | char buf[BDEVNAME_SIZE]; |
| 237 | 237 | int n; |
| 238 | 238 | |
| 239 | − mutex_lock(&block_class_lock); | |
| 240 | − /* For each block device... */ | |
| 241 | − list_for_each_entry(dev, &block_class.devices, node) { | |
| 242 | − if (dev->type != &disk_type) | |
| 243 | − continue; | |
| 244 | − sgp = dev_to_disk(dev); | |
| 245 | − /* | |
| 246 | − * Don't show empty devices or things that have been surpressed | |
| 247 | − */ | |
| 248 | − if (get_capacity(sgp) == 0 || | |
| 249 | − (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)) | |
| 250 | − continue; | |
| 239 | + if (dev->type != &disk_type) | |
| 240 | + goto exit; | |
| 251 | 241 | |
| 252 | − /* | |
| 253 | − * Note, unlike /proc/partitions, I am showing the numbers in | |
| 254 | − * hex - the same format as the root= option takes. | |
| 255 | − */ | |
| 256 | − printk("%02x%02x %10llu %s", | |
| 257 | − sgp->major, sgp->first_minor, | |
| 258 | − (unsigned long long)get_capacity(sgp) >> 1, | |
| 259 | − disk_name(sgp, 0, buf)); | |
| 260 | − if (sgp->driverfs_dev != NULL && | |
| 261 | − sgp->driverfs_dev->driver != NULL) | |
| 262 | − printk(" driver: %s\n", | |
| 263 | − sgp->driverfs_dev->driver->name); | |
| 264 | − else | |
| 265 | − printk(" (driver?)\n"); | |
| 266 | − | |
| 267 | − /* now show the partitions */ | |
| 268 | − for (n = 0; n < sgp->minors - 1; ++n) { | |
| 269 | − if (sgp->part[n] == NULL) | |
| 270 | − continue; | |
| 271 | − if (sgp->part[n]->nr_sects == 0) | |
| 272 | − continue; | |
| 273 | − printk(" %02x%02x %10llu %s\n", | |
| 274 | − sgp->major, n + 1 + sgp->first_minor, | |
| 275 | − (unsigned long long)sgp->part[n]->nr_sects >> 1, | |
| 276 | − disk_name(sgp, n + 1, buf)); | |
| 277 | − } | |
| 242 | + sgp = dev_to_disk(dev); | |
| 243 | + /* | |
| 244 | + * Don't show empty devices or things that have been surpressed | |
| 245 | + */ | |
| 246 | + if (get_capacity(sgp) == 0 || | |
| 247 | + (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)) | |
| 248 | + goto exit; | |
| 249 | + | |
| 250 | + /* | |
| 251 | + * Note, unlike /proc/partitions, I am showing the numbers in | |
| 252 | + * hex - the same format as the root= option takes. | |
| 253 | + */ | |
| 254 | + printk("%02x%02x %10llu %s", | |
| 255 | + sgp->major, sgp->first_minor, | |
| 256 | + (unsigned long long)get_capacity(sgp) >> 1, | |
| 257 | + disk_name(sgp, 0, buf)); | |
| 258 | + if (sgp->driverfs_dev != NULL && | |
| 259 | + sgp->driverfs_dev->driver != NULL) | |
| 260 | + printk(" driver: %s\n", | |
| 261 | + sgp->driverfs_dev->driver->name); | |
| 262 | + else | |
| 263 | + printk(" (driver?)\n"); | |
| 264 | + | |
| 265 | + /* now show the partitions */ | |
| 266 | + for (n = 0; n < sgp->minors - 1; ++n) { | |
| 267 | + if (sgp->part[n] == NULL) | |
| 268 | + goto exit; | |
| 269 | + if (sgp->part[n]->nr_sects == 0) | |
| 270 | + goto exit; | |
| 271 | + printk(" %02x%02x %10llu %s\n", | |
| 272 | + sgp->major, n + 1 + sgp->first_minor, | |
| 273 | + (unsigned long long)sgp->part[n]->nr_sects >> 1, | |
| 274 | + disk_name(sgp, n + 1, buf)); | |
| 278 | 275 | } |
| 276 | +exit: | |
| 277 | + return 0; | |
| 278 | +} | |
| 279 | 279 | |
| 280 | +/* | |
| 281 | + * print a full list of all partitions - intended for places where the root | |
| 282 | + * filesystem can't be mounted and thus to give the victim some idea of what | |
| 283 | + * went wrong | |
| 284 | + */ | |
| 285 | +void __init printk_all_partitions(void) | |
| 286 | +{ | |
| 287 | + mutex_lock(&block_class_lock); | |
| 288 | + class_for_each_device(&block_class, NULL, NULL, printk_partition); | |
| 280 | 289 | mutex_unlock(&block_class_lock); |
| 281 | 290 | } |
| 282 | 291 | |
| 283 | 292 | #ifdef CONFIG_PROC_FS |
| 284 | 293 | /* iterator */ |
| 294 | +static int find_start(struct device *dev, void *data) | |
| 295 | +{ | |
| 296 | + loff_t k = *(loff_t *)data; | |
| 297 | + | |
| 298 | + if (dev->type != &disk_type) | |
| 299 | + return 0; | |
| 300 | + if (!k--) | |
| 301 | + return 1; | |
| 302 | + return 0; | |
| 303 | +} | |
| 304 | + | |
| 285 | 305 | static void *part_start(struct seq_file *part, loff_t *pos) |
| 286 | 306 | { |
| 287 | − loff_t k = *pos; | |
| 288 | 307 | struct device *dev; |
| 308 | + loff_t n = *pos; | |
| 309 | + | |
| 310 | + if (!n) | |
| 311 | + seq_puts(part, "major minor #blocks name\n\n"); | |
| 289 | 312 | |
| 290 | 313 | mutex_lock(&block_class_lock); |
| 291 | − list_for_each_entry(dev, &block_class.devices, node) { | |
| 292 | − if (dev->type != &disk_type) | |
| 293 | − continue; | |
| 294 | − if (!k--) | |
| 295 | − return dev_to_disk(dev); | |
| 296 | − } | |
| 314 | + dev = class_find_device(&block_class, NULL, (void *)pos, find_start); | |
| 315 | + if (dev) | |
| 316 | + return dev_to_disk(dev); | |
| 297 | 317 | return NULL; |
| 298 | 318 | } |
| 299 | 319 | |
| 320 | +static int find_next(struct device *dev, void *data) | |
| 321 | +{ | |
| 322 | + if (dev->type == &disk_type) | |
| 323 | + return 1; | |
| 324 | + return 0; | |
| 325 | +} | |
| 326 | + | |
| 300 | 327 | static void *part_next(struct seq_file *part, void *v, loff_t *pos) |
| 301 | 328 | { |
| 302 | 329 | struct gendisk *gp = v; |
| 303 | 330 | struct device *dev; |
| 304 | 331 | ++*pos; |
| 305 | − list_for_each_entry(dev, &gp->dev.node, node) { | |
| 306 | − if (&dev->node == &block_class.devices) | |
| 307 | − return NULL; | |
| 308 | − if (dev->type == &disk_type) | |
| 309 | − return dev_to_disk(dev); | |
| 310 | − } | |
| 332 | + dev = class_find_device(&block_class, &gp->dev, NULL, find_next); | |
| 333 | + if (dev) | |
| 334 | + return dev_to_disk(dev); | |
| 311 | 335 | return NULL; |
| 312 | 336 | } |
| 313 | 337 | |
| @@ -322,9 +346,6 @@ static int show_partition(struct seq_file *part, void *v) · 8 unmodified lines | ||
| 322 | 346 | int n; |
| 323 | 347 | char buf[BDEVNAME_SIZE]; |
| 324 | 348 | |
| 325 | − if (&sgp->dev.node == block_class.devices.next) | |
| 326 | − seq_puts(part, "major minor #blocks name\n\n"); | |
| 327 | − | |
| 328 | 349 | /* Don't show non-partitionable removeable devices or empty devices */ |
| 329 | 350 | if (!get_capacity(sgp) || |
| 330 | 351 | (sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE))) |
| @@ -370,7 +391,10 @@ static struct kobject *base_probe(dev_t devt, int *part, void *data) · 39 unmodified lines | ||
| 370 | 391 | |
| 371 | 392 | static int __init genhd_device_init(void) |
| 372 | 393 | { |
| 373 | − int error = class_register(&block_class); | |
| 394 | + int error; | |
| 395 | + | |
| 396 | + block_class.dev_kobj = sysfs_dev_block_kobj; | |
| 397 | + error = class_register(&block_class); | |
| 374 | 398 | if (unlikely(error)) |
| 375 | 399 | return error; |
| 376 | 400 | bdev_map = kobj_map_init(base_probe, &block_class_lock); |
| @@ -532,6 +556,7 @@ static struct device_type disk_type = { · 155 unmodified lines | ||
| 532 | 556 | .release = disk_release, |
| 533 | 557 | }; |
| 534 | 558 | |
| 559 | +#ifdef CONFIG_PROC_FS | |
| 535 | 560 | /* |
| 536 | 561 | * aggregate disk stat collector. Uses the same stats that the sysfs |
| 537 | 562 | * entries do, above, but makes them available through one seq_file. |
| @@ -542,16 +567,12 @@ static struct device_type disk_type = { · 4 unmodified lines | ||
| 542 | 567 | |
| 543 | 568 | static void *diskstats_start(struct seq_file *part, loff_t *pos) |
| 544 | 569 | { |
| 545 | − loff_t k = *pos; | |
| 546 | 570 | struct device *dev; |
| 547 | 571 | |
| 548 | 572 | mutex_lock(&block_class_lock); |
| 549 | − list_for_each_entry(dev, &block_class.devices, node) { | |
| 550 | − if (dev->type != &disk_type) | |
| 551 | − continue; | |
| 552 | − if (!k--) | |
| 553 | − return dev_to_disk(dev); | |
| 554 | − } | |
| 573 | + dev = class_find_device(&block_class, NULL, (void *)pos, find_start); | |
| 574 | + if (dev) | |
| 575 | + return dev_to_disk(dev); | |
| 555 | 576 | return NULL; |
| 556 | 577 | } |
| 557 | 578 | |
| @@ -561,12 +582,9 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos) · 3 unmodified lines | ||
| 561 | 582 | struct device *dev; |
| 562 | 583 | |
| 563 | 584 | ++*pos; |
| 564 | − list_for_each_entry(dev, &gp->dev.node, node) { | |
| 565 | − if (&dev->node == &block_class.devices) | |
| 566 | − return NULL; | |
| 567 | − if (dev->type == &disk_type) | |
| 568 | − return dev_to_disk(dev); | |
| 569 | − } | |
| 585 | + dev = class_find_device(&block_class, &gp->dev, NULL, find_next); | |
| 586 | + if (dev) | |
| 587 | + return dev_to_disk(dev); | |
| 570 | 588 | return NULL; |
| 571 | 589 | } |
| 572 | 590 | |
| @@ -641,6 +659,7 @@ const struct seq_operations diskstats_op = { · 68 unmodified lines | ||
| 641 | 659 | .stop = diskstats_stop, |
| 642 | 660 | .show = diskstats_show |
| 643 | 661 | }; |
| 662 | +#endif /* CONFIG_PROC_FS */ | |
| 644 | 663 | |
| 645 | 664 | static void media_change_notify_thread(struct work_struct *work) |
| 646 | 665 | { |
| @@ -665,24 +684,38 @@ void genhd_media_change_notify(struct gendisk *disk) · 18 unmodified lines | ||
| 665 | 684 | EXPORT_SYMBOL_GPL(genhd_media_change_notify); |
| 666 | 685 | #endif /* 0 */ |
| 667 | 686 | |
| 687 | +struct find_block { | |
| 688 | + const char *name; | |
| 689 | + int part; | |
| 690 | +}; | |
| 691 | + | |
| 692 | +static int match_id(struct device *dev, void *data) | |
| 693 | +{ | |
| 694 | + struct find_block *find = data; | |
| 695 | + | |
| 696 | + if (dev->type != &disk_type) | |
| 697 | + return 0; | |
| 698 | + if (strcmp(dev->bus_id, find->name) == 0) { | |
| 699 | + struct gendisk *disk = dev_to_disk(dev); | |
| 700 | + if (find->part < disk->minors) | |
| 701 | + return 1; | |
| 702 | + } | |
| 703 | + return 0; | |
| 704 | +} | |
| 705 | + | |
| 668 | 706 | dev_t blk_lookup_devt(const char *name, int part) |
| 669 | 707 | { |
| 670 | 708 | struct device *dev; |
| 671 | 709 | dev_t devt = MKDEV(0, 0); |
| 710 | + struct find_block find; | |
| 672 | 711 | |
| 673 | 712 | mutex_lock(&block_class_lock); |
| 674 | − list_for_each_entry(dev, &block_class.devices, node) { | |
| 675 | − if (dev->type != &disk_type) | |
| 676 | − continue; | |
| 677 | − if (strcmp(dev->bus_id, name) == 0) { | |
| 678 | − struct gendisk *disk = dev_to_disk(dev); | |
| 679 | − | |
| 680 | − if (part < disk->minors) | |
| 681 | − devt = MKDEV(MAJOR(dev->devt), | |
| 682 | − MINOR(dev->devt) + part); | |
| 683 | − break; | |
| 684 | − } | |
| 685 | − } | |
| 713 | + find.name = name; | |
| 714 | + find.part = part; | |
| 715 | + dev = class_find_device(&block_class, NULL, (void *)&find, match_id); | |
| 716 | + if (dev) | |
| 717 | + devt = MKDEV(MAJOR(dev->devt), | |
| 718 | + MINOR(dev->devt) + part); | |
| 686 | 719 | mutex_unlock(&block_class_lock); |
| 687 | 720 | |
| 688 | 721 | return devt; |
| @@ -263,22 +263,22 @@ static int acpi_fan_add(struct acpi_device *device) · 262 unmodified lines | ||
| 263 | 263 | goto end; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | − printk(KERN_INFO PREFIX | |
| 267 | − "%s is registered as cooling_device%d\n", | |
| 268 | − device->dev.bus_id, cdev->id); | |
| 266 | + dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id); | |
| 269 | 267 | |
| 270 | 268 | acpi_driver_data(device) = cdev; |
| 271 | 269 | result = sysfs_create_link(&device->dev.kobj, |
| 272 | 270 | &cdev->device.kobj, |
| 273 | 271 | "thermal_cooling"); |
| 274 | 272 | if (result) |
| 275 | − printk(KERN_ERR PREFIX "Create sysfs link\n"); | |
| 273 | + dev_err(&device->dev, "Failed to create sysfs link " | |
| 274 | + "'thermal_cooling'\n"); | |
| 276 | 275 | |
| 277 | 276 | result = sysfs_create_link(&cdev->device.kobj, |
| 278 | 277 | &device->dev.kobj, |
| 279 | 278 | "device"); |
| 280 | 279 | if (result) |
| 281 | − printk(KERN_ERR PREFIX "Create sysfs link\n"); | |
| 280 | + dev_err(&device->dev, "Failed to create sysfs link " | |
| 281 | + "'device'\n"); | |
| 282 | 282 | |
| 283 | 283 | result = acpi_fan_add_fs(device); |
| 284 | 284 | if (result) |
| @@ -146,8 +146,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) · 145 unmodified lines | ||
| 146 | 146 | acpi_status status; |
| 147 | 147 | |
| 148 | 148 | if (dev->archdata.acpi_handle) { |
| 149 | − printk(KERN_WARNING PREFIX | |
| 150 | − "Drivers changed 'acpi_handle' for %s\n", dev->bus_id); | |
| 149 | + dev_warn(dev, "Drivers changed 'acpi_handle'\n"); | |
| 151 | 150 | return -EINVAL; |
| 152 | 151 | } |
| 153 | 152 | get_device(dev); |
| @@ -195,8 +194,7 @@ static int acpi_unbind_one(struct device *dev) · 41 unmodified lines | ||
| 195 | 194 | /* acpi_bind_one increase refcnt by one */ |
| 196 | 195 | put_device(dev); |
| 197 | 196 | } else { |
| 198 | − printk(KERN_ERR PREFIX | |
| 199 | − "Oops, 'acpi_handle' corrupt for %s\n", dev->bus_id); | |
| 197 | + dev_err(dev, "Oops, 'acpi_handle' corrupt\n"); | |
| 200 | 198 | } |
| 201 | 199 | return 0; |
| 202 | 200 | } |
| @@ -714,9 +714,8 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) · 713 unmodified lines | ||
| 714 | 714 | goto end; |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | − printk(KERN_INFO PREFIX | |
| 718 | − "%s is registered as cooling_device%d\n", | |
| 719 | − device->dev.bus_id, pr->cdev->id); | |
| 717 | + dev_info(&device->dev, "registered as cooling_device%d\n", | |
| 718 | + pr->cdev->id); | |
| 720 | 719 | |
| 721 | 720 | result = sysfs_create_link(&device->dev.kobj, |
| 722 | 721 | &pr->cdev->device.kobj, |
| @@ -471,7 +471,7 @@ static int acpi_device_register(struct acpi_device *device, · 470 unmodified lines | ||
| 471 | 471 | device->dev.release = &acpi_device_release; |
| 472 | 472 | result = device_add(&device->dev); |
| 473 | 473 | if(result) { |
| 474 | − printk(KERN_ERR PREFIX "Error adding device %s", device->dev.bus_id); | |
| 474 | + dev_err(&device->dev, "Error adding device\n"); | |
| 475 | 475 | goto end; |
| 476 | 476 | } |
| 477 | 477 | |
| @@ -1179,8 +1179,8 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) · 1178 unmodified lines | ||
| 1179 | 1179 | |
| 1180 | 1180 | tz->tz_enabled = 1; |
| 1181 | 1181 | |
| 1182 | − printk(KERN_INFO PREFIX "%s is registered as thermal_zone%d\n", | |
| 1183 | − tz->device->dev.bus_id, tz->thermal_zone->id); | |
| 1182 | + dev_info(&tz->device->dev, "registered as thermal_zone%d\n", | |
| 1183 | + tz->thermal_zone->id); | |
| 1184 | 1184 | return 0; |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| @@ -762,9 +762,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) · 761 unmodified lines | ||
| 762 | 762 | if (IS_ERR(device->cdev)) |
| 763 | 763 | return; |
| 764 | 764 | |
| 765 | − printk(KERN_INFO PREFIX | |
| 766 | − "%s is registered as cooling_device%d\n", | |
| 767 | − device->dev->dev.bus_id, device->cdev->id); | |
| 765 | + dev_info(&device->dev->dev, "registered as cooling_device%d\n", | |
| 766 | + device->cdev->id); | |
| 768 | 767 | result = sysfs_create_link(&device->dev->dev.kobj, |
| 769 | 768 | &device->cdev->device.kobj, |
| 770 | 769 | "thermal_cooling"); |
| @@ -27,8 +27,9 @@ config PREVENT_FIRMWARE_BUILD · 26 unmodified lines | ||
| 27 | 27 | If unsure say Y here. |
| 28 | 28 | |
| 29 | 29 | config FW_LOADER |
| 30 | − tristate "Userspace firmware loading support" | |
| 30 | + tristate "Userspace firmware loading support" if EMBEDDED | |
| 31 | 31 | depends on HOTPLUG |
| 32 | + default y | |
| 32 | 33 | ---help--- |
| 33 | 34 | This option is provided for the case where no in-kernel-tree modules |
| 34 | 35 | require userspace firmware loading support, but a module built outside |
| @@ -36,6 +36,33 @@ struct driver_private { · 35 unmodified lines | ||
| 36 | 36 | }; |
| 37 | 37 | #define to_driver(obj) container_of(obj, struct driver_private, kobj) |
| 38 | 38 | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * struct class_private - structure to hold the private to the driver core portions of the class structure. | |
| 42 | + * | |
| 43 | + * @class_subsys - the struct kset that defines this class. This is the main kobject | |
| 44 | + * @class_devices - list of devices associated with this class | |
| 45 | + * @class_interfaces - list of class_interfaces associated with this class | |
| 46 | + * @class_dirs - "glue" directory for virtual devices associated with this class | |
| 47 | + * @class_mutex - mutex to protect the children, devices, and interfaces lists. | |
| 48 | + * @class - pointer back to the struct class that this structure is associated | |
| 49 | + * with. | |
| 50 | + * | |
| 51 | + * This structure is the one that is the actual kobject allowing struct | |
| 52 | + * class to be statically allocated safely. Nothing outside of the driver | |
| 53 | + * core should ever touch these fields. | |
| 54 | + */ | |
| 55 | +struct class_private { | |
| 56 | + struct kset class_subsys; | |
| 57 | + struct list_head class_devices; | |
| 58 | + struct list_head class_interfaces; | |
| 59 | + struct kset class_dirs; | |
| 60 | + struct mutex class_mutex; | |
| 61 | + struct class *class; | |
| 62 | +}; | |
| 63 | +#define to_class(obj) \ | |
| 64 | + container_of(obj, struct class_private, class_subsys.kobj) | |
| 65 | + | |
| 39 | 66 | /* initialisation functions */ |
| 40 | 67 | extern int devices_init(void); |
| 41 | 68 | extern int buses_init(void); |
| @@ -18,20 +18,20 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <linux/err.h> |
| 19 | 19 | #include <linux/slab.h> |
| 20 | 20 | #include <linux/genhd.h> |
| 21 | +#include <linux/mutex.h> | |
| 21 | 22 | #include "base.h" |
| 22 | 23 | |
| 23 | 24 | #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) |
| 24 | −#define to_class(obj) container_of(obj, struct class, subsys.kobj) | |
| 25 | 25 | |
| 26 | 26 | static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr, |
| 27 | 27 | char *buf) |
| 28 | 28 | { |
| 29 | 29 | struct class_attribute *class_attr = to_class_attr(attr); |
| 30 | − struct class *dc = to_class(kobj); | |
| 30 | + struct class_private *cp = to_class(kobj); | |
| 31 | 31 | ssize_t ret = -EIO; |
| 32 | 32 | |
| 33 | 33 | if (class_attr->show) |
| 34 | − ret = class_attr->show(dc, buf); | |
| 34 | + ret = class_attr->show(cp->class, buf); | |
| 35 | 35 | return ret; |
| 36 | 36 | } |
| 37 | 37 | |
| @@ -39,17 +39,18 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr, · 1 unmodified line | ||
| 39 | 39 | const char *buf, size_t count) |
| 40 | 40 | { |
| 41 | 41 | struct class_attribute *class_attr = to_class_attr(attr); |
| 42 | − struct class *dc = to_class(kobj); | |
| 42 | + struct class_private *cp = to_class(kobj); | |
| 43 | 43 | ssize_t ret = -EIO; |
| 44 | 44 | |
| 45 | 45 | if (class_attr->store) |
| 46 | − ret = class_attr->store(dc, buf, count); | |
| 46 | + ret = class_attr->store(cp->class, buf, count); | |
| 47 | 47 | return ret; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | static void class_release(struct kobject *kobj) |
| 51 | 51 | { |
| 52 | − struct class *class = to_class(kobj); | |
| 52 | + struct class_private *cp = to_class(kobj); | |
| 53 | + struct class *class = cp->class; | |
| 53 | 54 | |
| 54 | 55 | pr_debug("class '%s': release.\n", class->name); |
| 55 | 56 | |
| @@ -70,7 +71,7 @@ static struct kobj_type class_ktype = { · 14 unmodified lines | ||
| 70 | 71 | .release = class_release, |
| 71 | 72 | }; |
| 72 | 73 | |
| 73 | −/* Hotplug events for classes go to the class_obj subsys */ | |
| 74 | +/* Hotplug events for classes go to the class class_subsys */ | |
| 74 | 75 | static struct kset *class_kset; |
| 75 | 76 | |
| 76 | 77 | |
| @@ -78,7 +79,8 @@ int class_create_file(struct class *cls, const struct class_attribute *attr) · 1 unmodified line | ||
| 78 | 79 | { |
| 79 | 80 | int error; |
| 80 | 81 | if (cls) |
| 81 | − error = sysfs_create_file(&cls->subsys.kobj, &attr->attr); | |
| 82 | + error = sysfs_create_file(&cls->p->class_subsys.kobj, | |
| 83 | + &attr->attr); | |
| 82 | 84 | else |
| 83 | 85 | error = -EINVAL; |
| 84 | 86 | return error; |
| @@ -87,21 +89,20 @@ int class_create_file(struct class *cls, const struct class_attribute *attr) · 2 unmodified lines | ||
| 87 | 89 | void class_remove_file(struct class *cls, const struct class_attribute *attr) |
| 88 | 90 | { |
| 89 | 91 | if (cls) |
| 90 | − sysfs_remove_file(&cls->subsys.kobj, &attr->attr); | |
| 92 | + sysfs_remove_file(&cls->p->class_subsys.kobj, &attr->attr); | |
| 91 | 93 | } |
| 92 | 94 | |
| 93 | 95 | static struct class *class_get(struct class *cls) |
| 94 | 96 | { |
| 95 | 97 | if (cls) |
| 96 | − return container_of(kset_get(&cls->subsys), | |
| 97 | − struct class, subsys); | |
| 98 | − return NULL; | |
| 98 | + kset_get(&cls->p->class_subsys); | |
| 99 | + return cls; | |
| 99 | 100 | } |
| 100 | 101 | |
| 101 | 102 | static void class_put(struct class *cls) |
| 102 | 103 | { |
| 103 | 104 | if (cls) |
| 104 | − kset_put(&cls->subsys); | |
| 105 | + kset_put(&cls->p->class_subsys); | |
| 105 | 106 | } |
| 106 | 107 | |
| 107 | 108 | static int add_class_attrs(struct class *cls) |
| @@ -134,42 +135,57 @@ static void remove_class_attrs(struct class *cls) · 26 unmodified lines | ||
| 134 | 135 | } |
| 135 | 136 | } |
| 136 | 137 | |
| 137 | −int class_register(struct class *cls) | |
| 138 | +int __class_register(struct class *cls, struct lock_class_key *key) | |
| 138 | 139 | { |
| 140 | + struct class_private *cp; | |
| 139 | 141 | int error; |
| 140 | 142 | |
| 141 | 143 | pr_debug("device class '%s': registering\n", cls->name); |
| 142 | 144 | |
| 143 | − INIT_LIST_HEAD(&cls->devices); | |
| 144 | − INIT_LIST_HEAD(&cls->interfaces); | |
| 145 | − kset_init(&cls->class_dirs); | |
| 146 | − init_MUTEX(&cls->sem); | |
| 147 | − error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name); | |
| 148 | − if (error) | |
| 145 | + cp = kzalloc(sizeof(*cp), GFP_KERNEL); | |
| 146 | + if (!cp) | |
| 147 | + return -ENOMEM; | |
| 148 | + INIT_LIST_HEAD(&cp->class_devices); | |
| 149 | + INIT_LIST_HEAD(&cp->class_interfaces); | |
| 150 | + kset_init(&cp->class_dirs); | |
| 151 | + __mutex_init(&cp->class_mutex, "struct class mutex", key); | |
| 152 | + error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name); | |
| 153 | + if (error) { | |
| 154 | + kfree(cp); | |
| 149 | 155 | return error; |
| 156 | + } | |
| 157 | + | |
| 158 | + /* set the default /sys/dev directory for devices of this class */ | |
| 159 | + if (!cls->dev_kobj) | |
| 160 | + cls->dev_kobj = sysfs_dev_char_kobj; | |
| 150 | 161 | |
| 151 | 162 | #if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK) |
| 152 | 163 | /* let the block class directory show up in the root of sysfs */ |
| 153 | 164 | if (cls != &block_class) |
| 154 | − cls->subsys.kobj.kset = class_kset; | |
| 165 | + cp->class_subsys.kobj.kset = class_kset; | |
| 155 | 166 | #else |
| 156 | − cls->subsys.kobj.kset = class_kset; | |
| 167 | + cp->class_subsys.kobj.kset = class_kset; | |
| 157 | 168 | #endif |
| 158 | − cls->subsys.kobj.ktype = &class_ktype; | |
| 169 | + cp->class_subsys.kobj.ktype = &class_ktype; | |
| 170 | + cp->class = cls; | |
| 171 | + cls->p = cp; | |
| 159 | 172 | |
| 160 | − error = kset_register(&cls->subsys); | |
| 161 | − if (!error) { | |
| 162 | − error = add_class_attrs(class_get(cls)); | |
| 163 | − class_put(cls); | |
| 173 | + error = kset_register(&cp->class_subsys); | |
| 174 | + if (error) { | |
| 175 | + kfree(cp); | |
| 176 | + return error; | |
| 164 | 177 | } |
| 178 | + error = add_class_attrs(class_get(cls)); | |
| 179 | + class_put(cls); | |
| 165 | 180 | return error; |
| 166 | 181 | } |
| 182 | +EXPORT_SYMBOL_GPL(__class_register); | |
| 167 | 183 | |
| 168 | 184 | void class_unregister(struct class *cls) |
| 169 | 185 | { |
| 170 | 186 | pr_debug("device class '%s': unregistering\n", cls->name); |
| 171 | 187 | remove_class_attrs(cls); |
| 172 | − kset_unregister(&cls->subsys); | |
| 188 | + kset_unregister(&cls->p->class_subsys); | |
| 173 | 189 | } |
| 174 | 190 | |
| 175 | 191 | static void class_create_release(struct class *cls) |
| @@ -189,7 +205,8 @@ static void class_create_release(struct class *cls) · 13 unmodified lines | ||
| 189 | 205 | * Note, the pointer created here is to be destroyed when finished by |
| 190 | 206 | * making a call to class_destroy(). |
| 191 | 207 | */ |
| 192 | −struct class *class_create(struct module *owner, const char *name) | |
| 208 | +struct class *__class_create(struct module *owner, const char *name, | |
| 209 | + struct lock_class_key *key) | |
| 193 | 210 | { |
| 194 | 211 | struct class *cls; |
| 195 | 212 | int retval; |
| @@ -204,7 +221,7 @@ struct class *class_create(struct module *owner, const char *name) · 8 unmodified lines | ||
| 204 | 221 | cls->owner = owner; |
| 205 | 222 | cls->class_release = class_create_release; |
| 206 | 223 | |
| 207 | − retval = class_register(cls); | |
| 224 | + retval = __class_register(cls, key); | |
| 208 | 225 | if (retval) |
| 209 | 226 | goto error; |
| 210 | 227 | |
| @@ -214,6 +231,7 @@ error: · 3 unmodified lines | ||
| 214 | 231 | kfree(cls); |
| 215 | 232 | return ERR_PTR(retval); |
| 216 | 233 | } |
| 234 | +EXPORT_SYMBOL_GPL(__class_create); | |
| 217 | 235 | |
| 218 | 236 | /** |
| 219 | 237 | * class_destroy - destroys a struct class structure |
| @@ -252,39 +270,44 @@ char *make_class_name(const char *name, struct kobject *kobj) · 32 unmodified lines | ||
| 252 | 270 | /** |
| 253 | 271 | * class_for_each_device - device iterator |
| 254 | 272 | * @class: the class we're iterating |
| 273 | + * @start: the device to start with in the list, if any. | |
| 255 | 274 | * @data: data for the callback |
| 256 | 275 | * @fn: function to be called for each device |
| 257 | 276 | * |
| 258 | 277 | * Iterate over @class's list of devices, and call @fn for each, |
| 259 | − * passing it @data. | |
| 278 | + * passing it @data. If @start is set, the list iteration will start | |
| 279 | + * there, otherwise if it is NULL, the iteration starts at the | |
| 280 | + * beginning of the list. | |
| 260 | 281 | * |
| 261 | 282 | * We check the return of @fn each time. If it returns anything |
| 262 | 283 | * other than 0, we break out and return that value. |
| 263 | 284 | * |
| 264 | − * Note, we hold class->sem in this function, so it can not be | |
| 285 | + * Note, we hold class->class_mutex in this function, so it can not be | |
| 265 | 286 | * re-acquired in @fn, otherwise it will self-deadlocking. For |
| 266 | 287 | * example, calls to add or remove class members would be verboten. |
| 267 | 288 | */ |
| 268 | −int class_for_each_device(struct class *class, void *data, | |
| 269 | − int (*fn)(struct device *, void *)) | |
| 289 | +int class_for_each_device(struct class *class, struct device *start, | |
| 290 | + void *data, int (*fn)(struct device *, void *)) | |
| 270 | 291 | { |
| 271 | 292 | struct device *dev; |
| 272 | 293 | int error = 0; |
| 273 | 294 | |
| 274 | 295 | if (!class) |
| 275 | 296 | return -EINVAL; |
| 276 | − down(&class->sem); | |
| 277 | − list_for_each_entry(dev, &class->devices, node) { | |
| 297 | + mutex_lock(&class->p->class_mutex); | |
| 298 | + list_for_each_entry(dev, &class->p->class_devices, node) { | |
| 299 | + if (start) { | |
| 300 | + if (start == dev) | |
| 301 | + start = NULL; | |
| 302 | + continue; | |
| 303 | + } | |
| 278 | 304 | dev = get_device(dev); |
| 279 | − if (dev) { | |
| 280 | − error = fn(dev, data); | |
| 281 | − put_device(dev); | |
| 282 | − } else | |
| 283 | − error = -ENODEV; | |
| 305 | + error = fn(dev, data); | |
| 306 | + put_device(dev); | |
| 284 | 307 | if (error) |
| 285 | 308 | break; |
| 286 | 309 | } |
| 287 | − up(&class->sem); | |
| 310 | + mutex_unlock(&class->p->class_mutex); | |
| 288 | 311 | |
| 289 | 312 | return error; |
| 290 | 313 | } |
| @@ -293,6 +316,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device); · 2 unmodified lines | ||
| 293 | 316 | /** |
| 294 | 317 | * class_find_device - device iterator for locating a particular device |
| 295 | 318 | * @class: the class we're iterating |
| 319 | + * @start: Device to begin with | |
| 296 | 320 | * @data: data for the match function |
| 297 | 321 | * @match: function to check device |
| 298 | 322 | * |
| @@ -306,12 +330,13 @@ EXPORT_SYMBOL_GPL(class_for_each_device); · 7 unmodified lines | ||
| 306 | 330 | * |
| 307 | 331 | * Note, you will need to drop the reference with put_device() after use. |
| 308 | 332 | * |
| 309 | − * We hold class->sem in this function, so it can not be | |
| 333 | + * We hold class->class_mutex in this function, so it can not be | |
| 310 | 334 | * re-acquired in @match, otherwise it will self-deadlocking. For |
| 311 | 335 | * example, calls to add or remove class members would be verboten. |
| 312 | 336 | */ |
| 313 | −struct device *class_find_device(struct class *class, void *data, | |
| 314 | − int (*match)(struct device *, void *)) | |
| 337 | +struct device *class_find_device(struct class *class, struct device *start, | |
| 338 | + void *data, | |
| 339 | + int (*match)(struct device *, void *)) | |
| 315 | 340 | { |
| 316 | 341 | struct device *dev; |
| 317 | 342 | int found = 0; |
| @@ -319,19 +344,21 @@ struct device *class_find_device(struct class *class, void *data, · 1 unmodified line | ||
| 319 | 344 | if (!class) |
| 320 | 345 | return NULL; |
| 321 | 346 | |
| 322 | − down(&class->sem); | |
| 323 | − list_for_each_entry(dev, &class->devices, node) { | |
| 347 | + mutex_lock(&class->p->class_mutex); | |
| 348 | + list_for_each_entry(dev, &class->p->class_devices, node) { | |
| 349 | + if (start) { | |
| 350 | + if (start == dev) | |
| 351 | + start = NULL; | |
| 352 | + continue; | |
| 353 | + } | |
| 324 | 354 | dev = get_device(dev); |
| 325 | − if (dev) { | |
| 326 | − if (match(dev, data)) { | |
| 327 | − found = 1; | |
| 328 | − break; | |
| 329 | − } else | |
| 330 | − put_device(dev); | |
| 331 | − } else | |
| 355 | + if (match(dev, data)) { | |
| 356 | + found = 1; | |
| 332 | 357 | break; |
| 358 | + } else | |
| 359 | + put_device(dev); | |
| 333 | 360 | } |
| 334 | − up(&class->sem); | |
| 361 | + mutex_unlock(&class->p->class_mutex); | |
| 335 | 362 | |
| 336 | 363 | return found ? dev : NULL; |
| 337 | 364 | } |
| @@ -349,13 +376,13 @@ int class_interface_register(struct class_interface *class_intf) · 11 unmodified lines | ||
| 349 | 376 | if (!parent) |
| 350 | 377 | return -EINVAL; |
| 351 | 378 | |
| 352 | − down(&parent->sem); | |
| 353 | − list_add_tail(&class_intf->node, &parent->interfaces); | |
| 379 | + mutex_lock(&parent->p->class_mutex); | |
| 380 | + list_add_tail(&class_intf->node, &parent->p->class_interfaces); | |
| 354 | 381 | if (class_intf->add_dev) { |
| 355 | − list_for_each_entry(dev, &parent->devices, node) | |
| 382 | + list_for_each_entry(dev, &parent->p->class_devices, node) | |
| 356 | 383 | class_intf->add_dev(dev, class_intf); |
| 357 | 384 | } |
| 358 | − up(&parent->sem); | |
| 385 | + mutex_unlock(&parent->p->class_mutex); | |
| 359 | 386 | |
| 360 | 387 | return 0; |
| 361 | 388 | } |
| @@ -368,13 +395,13 @@ void class_interface_unregister(struct class_interface *class_intf) · 6 unmodified lines | ||
| 368 | 395 | if (!parent) |
| 369 | 396 | return; |
| 370 | 397 | |
| 371 | − down(&parent->sem); | |
| 398 | + mutex_lock(&parent->p->class_mutex); | |
| 372 | 399 | list_del_init(&class_intf->node); |
| 373 | 400 | if (class_intf->remove_dev) { |
| 374 | − list_for_each_entry(dev, &parent->devices, node) | |
| 401 | + list_for_each_entry(dev, &parent->p->class_devices, node) | |
| 375 | 402 | class_intf->remove_dev(dev, class_intf); |
| 376 | 403 | } |
| 377 | − up(&parent->sem); | |
| 404 | + mutex_unlock(&parent->p->class_mutex); | |
| 378 | 405 | |
| 379 | 406 | class_put(parent); |
| 380 | 407 | } |
| @@ -389,9 +416,7 @@ int __init classes_init(void) · 8 unmodified lines | ||
| 389 | 416 | |
| 390 | 417 | EXPORT_SYMBOL_GPL(class_create_file); |
| 391 | 418 | EXPORT_SYMBOL_GPL(class_remove_file); |
| 392 | −EXPORT_SYMBOL_GPL(class_register); | |
| 393 | 419 | EXPORT_SYMBOL_GPL(class_unregister); |
| 394 | −EXPORT_SYMBOL_GPL(class_create); | |
| 395 | 420 | EXPORT_SYMBOL_GPL(class_destroy); |
| 396 | 421 | |
| 397 | 422 | EXPORT_SYMBOL_GPL(class_interface_register); |
| @@ -21,12 +21,16 @@ · 20 unmodified lines | ||
| 21 | 21 | #include <linux/genhd.h> |
| 22 | 22 | #include <linux/kallsyms.h> |
| 23 | 23 | #include <linux/semaphore.h> |
| 24 | +#include <linux/mutex.h> | |
| 24 | 25 | |
| 25 | 26 | #include "base.h" |
| 26 | 27 | #include "power/power.h" |
| 27 | 28 | |
| 28 | 29 | int (*platform_notify)(struct device *dev) = NULL; |
| 29 | 30 | int (*platform_notify_remove)(struct device *dev) = NULL; |
| 31 | +static struct kobject *dev_kobj; | |
| 32 | +struct kobject *sysfs_dev_char_kobj; | |
| 33 | +struct kobject *sysfs_dev_block_kobj; | |
| 30 | 34 | |
| 31 | 35 | #ifdef CONFIG_BLOCK |
| 32 | 36 | static inline int device_is_not_partition(struct device *dev) |
| @@ -548,7 +552,7 @@ static struct kobject *get_device_parent(struct device *dev, · 515 unmodified lines | ||
| 548 | 552 | { |
| 549 | 553 | /* class devices without a parent live in /sys/class/<classname>/ */ |
| 550 | 554 | if (dev->class && (!parent || parent->class != dev->class)) |
| 551 | − return &dev->class->subsys.kobj; | |
| 555 | + return &dev->class->p->class_subsys.kobj; | |
| 552 | 556 | /* all other devices keep their parent */ |
| 553 | 557 | else if (parent) |
| 554 | 558 | return &parent->kobj; |
| @@ -594,13 +598,13 @@ static struct kobject *get_device_parent(struct device *dev, · 39 unmodified lines | ||
| 594 | 598 | parent_kobj = &parent->kobj; |
| 595 | 599 | |
| 596 | 600 | /* find our class-directory at the parent and reference it */ |
| 597 | − spin_lock(&dev->class->class_dirs.list_lock); | |
| 598 | − list_for_each_entry(k, &dev->class->class_dirs.list, entry) | |
| 601 | + spin_lock(&dev->class->p->class_dirs.list_lock); | |
| 602 | + list_for_each_entry(k, &dev->class->p->class_dirs.list, entry) | |
| 599 | 603 | if (k->parent == parent_kobj) { |
| 600 | 604 | kobj = kobject_get(k); |
| 601 | 605 | break; |
| 602 | 606 | } |
| 603 | − spin_unlock(&dev->class->class_dirs.list_lock); | |
| 607 | + spin_unlock(&dev->class->p->class_dirs.list_lock); | |
| 604 | 608 | if (kobj) |
| 605 | 609 | return kobj; |
| 606 | 610 | |
| @@ -608,7 +612,7 @@ static struct kobject *get_device_parent(struct device *dev, · 1 unmodified line | ||
| 608 | 612 | k = kobject_create(); |
| 609 | 613 | if (!k) |
| 610 | 614 | return NULL; |
| 611 | − k->kset = &dev->class->class_dirs; | |
| 615 | + k->kset = &dev->class->p->class_dirs; | |
| 612 | 616 | retval = kobject_add(k, parent_kobj, "%s", dev->class->name); |
| 613 | 617 | if (retval < 0) { |
| 614 | 618 | kobject_put(k); |
| @@ -627,7 +631,7 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir) · 12 unmodified lines | ||
| 627 | 631 | { |
| 628 | 632 | /* see if we live in a "glue" directory */ |
| 629 | 633 | if (!glue_dir || !dev->class || |
| 630 | − glue_dir->kset != &dev->class->class_dirs) | |
| 634 | + glue_dir->kset != &dev->class->p->class_dirs) | |
| 631 | 635 | return; |
| 632 | 636 | |
| 633 | 637 | kobject_put(glue_dir); |
| @@ -654,17 +658,18 @@ static int device_add_class_symlinks(struct device *dev) · 20 unmodified lines | ||
| 654 | 658 | if (!dev->class) |
| 655 | 659 | return 0; |
| 656 | 660 | |
| 657 | − error = sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj, | |
| 661 | + error = sysfs_create_link(&dev->kobj, | |
| 662 | + &dev->class->p->class_subsys.kobj, | |
| 658 | 663 | "subsystem"); |
| 659 | 664 | if (error) |
| 660 | 665 | goto out; |
| 661 | 666 | |
| 662 | 667 | #ifdef CONFIG_SYSFS_DEPRECATED |
| 663 | 668 | /* stacked class devices need a symlink in the class directory */ |
| 664 | − if (dev->kobj.parent != &dev->class->subsys.kobj && | |
| 669 | + if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && | |
| 665 | 670 | device_is_not_partition(dev)) { |
| 666 | − error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | |
| 667 | − dev->bus_id); | |
| 671 | + error = sysfs_create_link(&dev->class->p->class_subsys.kobj, | |
| 672 | + &dev->kobj, dev->bus_id); | |
| 668 | 673 | if (error) |
| 669 | 674 | goto out_subsys; |
| 670 | 675 | } |
| @@ -701,13 +706,14 @@ out_device: · 30 unmodified lines | ||
| 701 | 706 | if (dev->parent && device_is_not_partition(dev)) |
| 702 | 707 | sysfs_remove_link(&dev->kobj, "device"); |
| 703 | 708 | out_busid: |
| 704 | − if (dev->kobj.parent != &dev->class->subsys.kobj && | |
| 709 | + if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && | |
| 705 | 710 | device_is_not_partition(dev)) |
| 706 | − sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | |
| 711 | + sysfs_remove_link(&dev->class->p->class_subsys.kobj, | |
| 712 | + dev->bus_id); | |
| 707 | 713 | #else |
| 708 | 714 | /* link in the class directory pointing to the device */ |
| 709 | − error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | |
| 710 | − dev->bus_id); | |
| 715 | + error = sysfs_create_link(&dev->class->p->class_subsys.kobj, | |
| 716 | + &dev->kobj, dev->bus_id); | |
| 711 | 717 | if (error) |
| 712 | 718 | goto out_subsys; |
| 713 | 719 | |
| @@ -720,7 +726,7 @@ out_busid: · 6 unmodified lines | ||
| 720 | 726 | return 0; |
| 721 | 727 | |
| 722 | 728 | out_busid: |
| 723 | − sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | |
| 729 | + sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id); | |
| 724 | 730 | #endif |
| 725 | 731 | |
| 726 | 732 | out_subsys: |
| @@ -746,14 +752,15 @@ static void device_remove_class_symlinks(struct device *dev) · 19 unmodified lines | ||
| 746 | 752 | sysfs_remove_link(&dev->kobj, "device"); |
| 747 | 753 | } |
| 748 | 754 | |
| 749 | − if (dev->kobj.parent != &dev->class->subsys.kobj && | |
| 755 | + if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && | |
| 750 | 756 | device_is_not_partition(dev)) |
| 751 | − sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | |
| 757 | + sysfs_remove_link(&dev->class->p->class_subsys.kobj, | |
| 758 | + dev->bus_id); | |
| 752 | 759 | #else |
| 753 | 760 | if (dev->parent && device_is_not_partition(dev)) |
| 754 | 761 | sysfs_remove_link(&dev->kobj, "device"); |
| 755 | 762 | |
| 756 | − sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | |
| 763 | + sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id); | |
| 757 | 764 | #endif |
| 758 | 765 | |
| 759 | 766 | sysfs_remove_link(&dev->kobj, "subsystem"); |
| @@ -775,6 +782,54 @@ int dev_set_name(struct device *dev, const char *fmt, ...) · 15 unmodified lines | ||
| 775 | 782 | } |
| 776 | 783 | EXPORT_SYMBOL_GPL(dev_set_name); |
| 777 | 784 | |
| 785 | +/** | |
| 786 | + * device_to_dev_kobj - select a /sys/dev/ directory for the device | |
| 787 | + * @dev: device | |
| 788 | + * | |
| 789 | + * By default we select char/ for new entries. Setting class->dev_obj | |
| 790 | + * to NULL prevents an entry from being created. class->dev_kobj must | |
| 791 | + * be set (or cleared) before any devices are registered to the class | |
| 792 | + * otherwise device_create_sys_dev_entry() and | |
| 793 | + * device_remove_sys_dev_entry() will disagree about the the presence | |
| 794 | + * of the link. | |
| 795 | + */ | |
| 796 | +static struct kobject *device_to_dev_kobj(struct device *dev) | |
| 797 | +{ | |
| 798 | + struct kobject *kobj; | |
| 799 | + | |
| 800 | + if (dev->class) | |
| 801 | + kobj = dev->class->dev_kobj; | |
| 802 | + else | |
| 803 | + kobj = sysfs_dev_char_kobj; | |
| 804 | + | |
| 805 | + return kobj; | |
| 806 | +} | |
| 807 | + | |
| 808 | +static int device_create_sys_dev_entry(struct device *dev) | |
| 809 | +{ | |
| 810 | + struct kobject *kobj = device_to_dev_kobj(dev); | |
| 811 | + int error = 0; | |
| 812 | + char devt_str[15]; | |
| 813 | + | |
| 814 | + if (kobj) { | |
| 815 | + format_dev_t(devt_str, dev->devt); | |
| 816 | + error = sysfs_create_link(kobj, &dev->kobj, devt_str); | |
| 817 | + } | |
| 818 | + | |
| 819 | + return error; | |
| 820 | +} | |
| 821 | + | |
| 822 | +static void device_remove_sys_dev_entry(struct device *dev) | |
| 823 | +{ | |
| 824 | + struct kobject *kobj = device_to_dev_kobj(dev); | |
| 825 | + char devt_str[15]; | |
| 826 | + | |
| 827 | + if (kobj) { | |
| 828 | + format_dev_t(devt_str, dev->devt); | |
| 829 | + sysfs_remove_link(kobj, devt_str); | |
| 830 | + } | |
| 831 | +} | |
| 832 | + | |
| 778 | 833 | /** |
| 779 | 834 | * device_add - add device to device hierarchy. |
| 780 | 835 | * @dev: device. |
| @@ -829,6 +884,10 @@ int device_add(struct device *dev) · 48 unmodified lines | ||
| 829 | 884 | error = device_create_file(dev, &devt_attr); |
| 830 | 885 | if (error) |
| 831 | 886 | goto ueventattrError; |
| 887 | + | |
| 888 | + error = device_create_sys_dev_entry(dev); | |
| 889 | + if (error) | |
| 890 | + goto devtattrError; | |
| 832 | 891 | } |
| 833 | 892 | |
| 834 | 893 | error = device_add_class_symlinks(dev); |
| @@ -849,15 +908,16 @@ int device_add(struct device *dev) · 14 unmodified lines | ||
| 849 | 908 | klist_add_tail(&dev->knode_parent, &parent->klist_children); |
| 850 | 909 | |
| 851 | 910 | if (dev->class) { |
| 852 | − down(&dev->class->sem); | |
| 911 | + mutex_lock(&dev->class->p->class_mutex); | |
| 853 | 912 | /* tie the class to the device */ |
| 854 | − list_add_tail(&dev->node, &dev->class->devices); | |
| 913 | + list_add_tail(&dev->node, &dev->class->p->class_devices); | |
| 855 | 914 | |
| 856 | 915 | /* notify any interfaces that the device is here */ |
| 857 | − list_for_each_entry(class_intf, &dev->class->interfaces, node) | |
| 916 | + list_for_each_entry(class_intf, | |
| 917 | + &dev->class->p->class_interfaces, node) | |
| 858 | 918 | if (class_intf->add_dev) |
| 859 | 919 | class_intf->add_dev(dev, class_intf); |
| 860 | − up(&dev->class->sem); | |
| 920 | + mutex_unlock(&dev->class->p->class_mutex); | |
| 861 | 921 | } |
| 862 | 922 | Done: |
| 863 | 923 | put_device(dev); |
| @@ -872,6 +932,9 @@ int device_add(struct device *dev) · 8 unmodified lines | ||
| 872 | 932 | AttrsError: |
| 873 | 933 | device_remove_class_symlinks(dev); |
| 874 | 934 | SymlinkError: |
| 935 | + if (MAJOR(dev->devt)) | |
| 936 | + device_remove_sys_dev_entry(dev); | |
| 937 | + devtattrError: | |
| 875 | 938 | if (MAJOR(dev->devt)) |
| 876 | 939 | device_remove_file(dev, &devt_attr); |
| 877 | 940 | ueventattrError: |
| @@ -948,19 +1011,22 @@ void device_del(struct device *dev) · 70 unmodified lines | ||
| 948 | 1011 | device_pm_remove(dev); |
| 949 | 1012 | if (parent) |
| 950 | 1013 | klist_del(&dev->knode_parent); |
| 951 | − if (MAJOR(dev->devt)) | |
| 1014 | + if (MAJOR(dev->devt)) { | |
| 1015 | + device_remove_sys_dev_entry(dev); | |
| 952 | 1016 | device_remove_file(dev, &devt_attr); |
| 1017 | + } | |
| 953 | 1018 | if (dev->class) { |
| 954 | 1019 | device_remove_class_symlinks(dev); |
| 955 | 1020 | |
| 956 | − down(&dev->class->sem); | |
| 1021 | + mutex_lock(&dev->class->p->class_mutex); | |
| 957 | 1022 | /* notify any interfaces that the device is now gone */ |
| 958 | − list_for_each_entry(class_intf, &dev->class->interfaces, node) | |
| 1023 | + list_for_each_entry(class_intf, | |
| 1024 | + &dev->class->p->class_interfaces, node) | |
| 959 | 1025 | if (class_intf->remove_dev) |
| 960 | 1026 | class_intf->remove_dev(dev, class_intf); |
| 961 | 1027 | /* remove the device from the class list */ |
| 962 | 1028 | list_del_init(&dev->node); |
| 963 | − up(&dev->class->sem); | |
| 1029 | + mutex_unlock(&dev->class->p->class_mutex); | |
| 964 | 1030 | } |
| 965 | 1031 | device_remove_file(dev, &uevent_attr); |
| 966 | 1032 | device_remove_attrs(dev); |
| @@ -1074,7 +1140,25 @@ int __init devices_init(void) · 107 unmodified lines | ||
| 1074 | 1140 | devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL); |
| 1075 | 1141 | if (!devices_kset) |
| 1076 | 1142 | return -ENOMEM; |
| 1143 | + dev_kobj = kobject_create_and_add("dev", NULL); | |
| 1144 | + if (!dev_kobj) | |
| 1145 | + goto dev_kobj_err; | |
| 1146 | + sysfs_dev_block_kobj = kobject_create_and_add("block", dev_kobj); | |
| 1147 | + if (!sysfs_dev_block_kobj) | |
| 1148 | + goto block_kobj_err; | |
| 1149 | + sysfs_dev_char_kobj = kobject_create_and_add("char", dev_kobj); | |
| 1150 | + if (!sysfs_dev_char_kobj) | |
| 1151 | + goto char_kobj_err; | |
| 1152 | + | |
| 1077 | 1153 | return 0; |
| 1154 | + | |
| 1155 | + char_kobj_err: | |
| 1156 | + kobject_put(sysfs_dev_block_kobj); | |
| 1157 | + block_kobj_err: | |
| 1158 | + kobject_put(dev_kobj); | |
| 1159 | + dev_kobj_err: | |
| 1160 | + kset_unregister(devices_kset); | |
| 1161 | + return -ENOMEM; | |
| 1078 | 1162 | } |
| 1079 | 1163 | |
| 1080 | 1164 | EXPORT_SYMBOL_GPL(device_for_each_child); |
| @@ -1157,49 +1241,12 @@ error: · 76 unmodified lines | ||
| 1157 | 1241 | } |
| 1158 | 1242 | EXPORT_SYMBOL_GPL(device_create_vargs); |
| 1159 | 1243 | |
| 1160 | −/** | |
| 1161 | − * device_create_drvdata - creates a device and registers it with sysfs | |
| 1162 | − * @class: pointer to the struct class that this device should be registered to | |
| 1163 | − * @parent: pointer to the parent struct device of this new device, if any | |
| 1164 | − * @devt: the dev_t for the char device to be added | |
| 1165 | − * @drvdata: the data to be added to the device for callbacks | |
| 1166 | − * @fmt: string for the device's name | |
| 1167 | − * | |
| 1168 | − * This function can be used by char device classes. A struct device | |
| 1169 | − * will be created in sysfs, registered to the specified class. | |
| 1170 | − * | |
| 1171 | − * A "dev" file will be created, showing the dev_t for the device, if | |
| 1172 | − * the dev_t is not 0,0. | |
| 1173 | − * If a pointer to a parent struct device is passed in, the newly created | |
| 1174 | − * struct device will be a child of that device in sysfs. | |
| 1175 | − * The pointer to the struct device will be returned from the call. | |
| 1176 | − * Any further sysfs files that might be required can be created using this | |
| 1177 | − * pointer. | |
| 1178 | − * | |
| 1179 | − * Note: the struct class passed to this function must have previously | |
| 1180 | − * been created with a call to class_create(). | |
| 1181 | − */ | |
| 1182 | −struct device *device_create_drvdata(struct class *class, | |
| 1183 | − struct device *parent, | |
| 1184 | − dev_t devt, | |
| 1185 | − void *drvdata, | |
| 1186 | − const char *fmt, ...) | |
| 1187 | −{ | |
| 1188 | − va_list vargs; | |
| 1189 | − struct device *dev; | |
| 1190 | − | |
| 1191 | − va_start(vargs, fmt); | |
| 1192 | − dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs); | |
| 1193 | − va_end(vargs); | |
| 1194 | − return dev; | |
| 1195 | −} | |
| 1196 | −EXPORT_SYMBOL_GPL(device_create_drvdata); | |
| 1197 | − | |
| 1198 | 1244 | /** |
| 1199 | 1245 | * device_create - creates a device and registers it with sysfs |
| 1200 | 1246 | * @class: pointer to the struct class that this device should be registered to |
| 1201 | 1247 | * @parent: pointer to the parent struct device of this new device, if any |
| 1202 | 1248 | * @devt: the dev_t for the char device to be added |
| 1249 | + * @drvdata: the data to be added to the device for callbacks | |
| 1203 | 1250 | * @fmt: string for the device's name |
| 1204 | 1251 | * |
| 1205 | 1252 | * This function can be used by char device classes. A struct device |
| @@ -1217,13 +1264,13 @@ EXPORT_SYMBOL_GPL(device_create_drvdata); · 11 unmodified lines | ||
| 1217 | 1264 | * been created with a call to class_create(). |
| 1218 | 1265 | */ |
| 1219 | 1266 | struct device *device_create(struct class *class, struct device *parent, |
| 1220 | − dev_t devt, const char *fmt, ...) | |
| 1267 | + dev_t devt, void *drvdata, const char *fmt, ...) | |
| 1221 | 1268 | { |
| 1222 | 1269 | va_list vargs; |
| 1223 | 1270 | struct device *dev; |
| 1224 | 1271 | |
| 1225 | 1272 | va_start(vargs, fmt); |
| 1226 | − dev = device_create_vargs(class, parent, devt, NULL, fmt, vargs); | |
| 1273 | + dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs); | |
| 1227 | 1274 | va_end(vargs); |
| 1228 | 1275 | return dev; |
| 1229 | 1276 | } |
| @@ -1248,7 +1295,7 @@ void device_destroy(struct class *class, dev_t devt) · 18 unmodified lines | ||
| 1248 | 1295 | { |
| 1249 | 1296 | struct device *dev; |
| 1250 | 1297 | |
| 1251 | − dev = class_find_device(class, &devt, __match_devt); | |
| 1298 | + dev = class_find_device(class, NULL, &devt, __match_devt); | |
| 1252 | 1299 | if (dev) { |
| 1253 | 1300 | put_device(dev); |
| 1254 | 1301 | device_unregister(dev); |
| @@ -1298,8 +1345,9 @@ int device_rename(struct device *dev, char *new_name) · 43 unmodified lines | ||
| 1298 | 1345 | if (old_class_name) { |
| 1299 | 1346 | new_class_name = make_class_name(dev->class->name, &dev->kobj); |
| 1300 | 1347 | if (new_class_name) { |
| 1301 | − error = sysfs_create_link(&dev->parent->kobj, | |
| 1302 | − &dev->kobj, new_class_name); | |
| 1348 | + error = sysfs_create_link_nowarn(&dev->parent->kobj, | |
| 1349 | + &dev->kobj, | |
| 1350 | + new_class_name); | |
| 1303 | 1351 | if (error) |
| 1304 | 1352 | goto out; |
| 1305 | 1353 | sysfs_remove_link(&dev->parent->kobj, old_class_name); |
| @@ -1307,11 +1355,12 @@ int device_rename(struct device *dev, char *new_name) · 1 unmodified line | ||
| 1307 | 1355 | } |
| 1308 | 1356 | #else |
| 1309 | 1357 | if (dev->class) { |
| 1310 | − error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | |
| 1311 | − dev->bus_id); | |
| 1358 | + error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj, | |
| 1359 | + &dev->kobj, dev->bus_id); | |
| 1312 | 1360 | if (error) |
| 1313 | 1361 | goto out; |
| 1314 | − sysfs_remove_link(&dev->class->subsys.kobj, old_device_name); | |
| 1362 | + sysfs_remove_link(&dev->class->p->class_subsys.kobj, | |
| 1363 | + old_device_name); | |
| 1315 | 1364 | } |
| 1316 | 1365 | #endif |
| 1317 | 1366 | |
| @@ -1447,4 +1496,7 @@ void device_shutdown(void) · 129 unmodified lines | ||
| 1447 | 1496 | dev->driver->shutdown(dev); |
| 1448 | 1497 | } |
| 1449 | 1498 | } |
| 1499 | + kobject_put(sysfs_dev_char_kobj); | |
| 1500 | + kobject_put(sysfs_dev_block_kobj); | |
| 1501 | + kobject_put(dev_kobj); | |
| 1450 | 1502 | } |
| @@ -21,15 +21,16 @@ EXPORT_SYMBOL(cpu_sysdev_class); · 20 unmodified lines | ||
| 21 | 21 | static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices); |
| 22 | 22 | |
| 23 | 23 | #ifdef CONFIG_HOTPLUG_CPU |
| 24 | −static ssize_t show_online(struct sys_device *dev, char *buf) | |
| 24 | +static ssize_t show_online(struct sys_device *dev, struct sysdev_attribute *attr, | |
| 25 | + char *buf) | |
| 25 | 26 | { |
| 26 | 27 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); |
| 27 | 28 | |
| 28 | 29 | return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | −static ssize_t __ref store_online(struct sys_device *dev, const char *buf, | |
| 32 | − size_t count) | |
| 32 | +static ssize_t __ref store_online(struct sys_device *dev, struct sysdev_attribute *attr, | |
| 33 | + const char *buf, size_t count) | |
| 33 | 34 | { |
| 34 | 35 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); |
| 35 | 36 | ssize_t ret; |
| @@ -80,7 +81,8 @@ static inline void register_cpu_control(struct cpu *cpu) · 44 unmodified lines | ||
| 80 | 81 | #ifdef CONFIG_KEXEC |
| 81 | 82 | #include <linux/kexec.h> |
| 82 | 83 | |
| 83 | −static ssize_t show_crash_notes(struct sys_device *dev, char *buf) | |
| 84 | +static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute *attr, | |
| 85 | + char *buf) | |
| 84 | 86 | { |
| 85 | 87 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); |
| 86 | 88 | ssize_t rc; |
| @@ -92,7 +92,8 @@ unregister_memory(struct memory_block *memory, struct mem_section *section) · 91 unmodified lines | ||
| 92 | 92 | * uses. |
| 93 | 93 | */ |
| 94 | 94 | |
| 95 | −static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf) | |
| 95 | +static ssize_t show_mem_phys_index(struct sys_device *dev, | |
| 96 | + struct sysdev_attribute *attr, char *buf) | |
| 96 | 97 | { |
| 97 | 98 | struct memory_block *mem = |
| 98 | 99 | container_of(dev, struct memory_block, sysdev); |
| @@ -102,7 +103,8 @@ static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf) · 3 unmodified lines | ||
| 102 | 103 | /* |
| 103 | 104 | * online, offline, going offline, etc. |
| 104 | 105 | */ |
| 105 | −static ssize_t show_mem_state(struct sys_device *dev, char *buf) | |
| 106 | +static ssize_t show_mem_state(struct sys_device *dev, | |
| 107 | + struct sysdev_attribute *attr, char *buf) | |
| 106 | 108 | { |
| 107 | 109 | struct memory_block *mem = |
| 108 | 110 | container_of(dev, struct memory_block, sysdev); |
| @@ -217,7 +219,8 @@ out: · 108 unmodified lines | ||
| 217 | 219 | } |
| 218 | 220 | |
| 219 | 221 | static ssize_t |
| 220 | −store_mem_state(struct sys_device *dev, const char *buf, size_t count) | |
| 222 | +store_mem_state(struct sys_device *dev, | |
| 223 | + struct sysdev_attribute *attr, const char *buf, size_t count) | |
| 221 | 224 | { |
| 222 | 225 | struct memory_block *mem; |
| 223 | 226 | unsigned int phys_section_nr; |
| @@ -248,7 +251,8 @@ out: · 24 unmodified lines | ||
| 248 | 251 | * s.t. if I offline all of these sections I can then |
| 249 | 252 | * remove the physical device? |
| 250 | 253 | */ |
| 251 | −static ssize_t show_phys_device(struct sys_device *dev, char *buf) | |
| 254 | +static ssize_t show_phys_device(struct sys_device *dev, | |
| 255 | + struct sysdev_attribute *attr, char *buf) | |
| 252 | 256 | { |
| 253 | 257 | struct memory_block *mem = |
| 254 | 258 | container_of(dev, struct memory_block, sysdev); |
| @@ -36,11 +36,13 @@ static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf) · 35 unmodified lines | ||
| 36 | 36 | return len; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | −static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf) | |
| 39 | +static inline ssize_t node_read_cpumask(struct sys_device *dev, | |
| 40 | + struct sysdev_attribute *attr, char *buf) | |
| 40 | 41 | { |
| 41 | 42 | return node_read_cpumap(dev, 0, buf); |
| 42 | 43 | } |
| 43 | −static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf) | |
| 44 | +static inline ssize_t node_read_cpulist(struct sys_device *dev, | |
| 45 | + struct sysdev_attribute *attr, char *buf) | |
| 44 | 46 | { |
| 45 | 47 | return node_read_cpumap(dev, 1, buf); |
| 46 | 48 | } |
| @@ -49,7 +51,8 @@ static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL); · 2 unmodified lines | ||
| 49 | 51 | static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL); |
| 50 | 52 | |
| 51 | 53 | #define K(x) ((x) << (PAGE_SHIFT - 10)) |
| 52 | −static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) | |
| 54 | +static ssize_t node_read_meminfo(struct sys_device * dev, | |
| 55 | + struct sysdev_attribute *attr, char * buf) | |
| 53 | 56 | { |
| 54 | 57 | int n; |
| 55 | 58 | int nid = dev->id; |
| @@ -112,7 +115,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) · 56 unmodified lines | ||
| 112 | 115 | #undef K |
| 113 | 116 | static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL); |
| 114 | 117 | |
| 115 | −static ssize_t node_read_numastat(struct sys_device * dev, char * buf) | |
| 118 | +static ssize_t node_read_numastat(struct sys_device * dev, | |
| 119 | + struct sysdev_attribute *attr, char * buf) | |
| 116 | 120 | { |
| 117 | 121 | return sprintf(buf, |
| 118 | 122 | "numa_hit %lu\n" |
| @@ -130,7 +134,8 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf) · 11 unmodified lines | ||
| 130 | 134 | } |
| 131 | 135 | static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL); |
| 132 | 136 | |
| 133 | −static ssize_t node_read_distance(struct sys_device * dev, char * buf) | |
| 137 | +static ssize_t node_read_distance(struct sys_device * dev, | |
| 138 | + struct sysdev_attribute *attr, char * buf) | |
| 134 | 139 | { |
| 135 | 140 | int nid = dev->id; |
| 136 | 141 | int len = 0; |
| @@ -194,7 +194,7 @@ static int show_dev_hash(unsigned int value) · 193 unmodified lines | ||
| 194 | 194 | struct device * dev = to_device(entry); |
| 195 | 195 | unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH); |
| 196 | 196 | if (hash == value) { |
| 197 | − printk(" hash matches device %s\n", dev->bus_id); | |
| 197 | + dev_info(dev, "hash matches\n"); | |
| 198 | 198 | match++; |
| 199 | 199 | } |
| 200 | 200 | entry = entry->prev; |
| @@ -36,7 +36,7 @@ sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer) · 35 unmodified lines | ||
| 36 | 36 | struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); |
| 37 | 37 | |
| 38 | 38 | if (sysdev_attr->show) |
| 39 | − return sysdev_attr->show(sysdev, buffer); | |
| 39 | + return sysdev_attr->show(sysdev, sysdev_attr, buffer); | |
| 40 | 40 | return -EIO; |
| 41 | 41 | } |
| 42 | 42 | |
| @@ -49,7 +49,7 @@ sysdev_store(struct kobject * kobj, struct attribute * attr, · 6 unmodified lines | ||
| 49 | 49 | struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); |
| 50 | 50 | |
| 51 | 51 | if (sysdev_attr->store) |
| 52 | − return sysdev_attr->store(sysdev, buffer, count); | |
| 52 | + return sysdev_attr->store(sysdev, sysdev_attr, buffer, count); | |
| 53 | 53 | return -EIO; |
| 54 | 54 | } |
| 55 | 55 | |
| @@ -130,8 +130,8 @@ static struct kset *system_kset; · 74 unmodified lines | ||
| 130 | 130 | |
| 131 | 131 | int sysdev_class_register(struct sysdev_class * cls) |
| 132 | 132 | { |
| 133 | − pr_debug("Registering sysdev class '%s'\n", | |
| 134 | − kobject_name(&cls->kset.kobj)); | |
| 133 | + pr_debug("Registering sysdev class '%s'\n", cls->name); | |
| 134 | + | |
| 135 | 135 | INIT_LIST_HEAD(&cls->drivers); |
| 136 | 136 | memset(&cls->kset.kobj, 0x00, sizeof(struct kobject)); |
| 137 | 137 | cls->kset.kobj.parent = &system_kset->kobj; |
| @@ -241,7 +241,8 @@ int sysdev_register(struct sys_device * sysdev) · 103 unmodified lines | ||
| 241 | 241 | if (!cls) |
| 242 | 242 | return -EINVAL; |
| 243 | 243 | |
| 244 | − pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj)); | |
| 244 | + pr_debug("Registering sys device of class '%s'\n", | |
| 245 | + kobject_name(&cls->kset.kobj)); | |
| 245 | 246 | |
| 246 | 247 | /* initialize the kobject to 0, in case it had previously been used */ |
| 247 | 248 | memset(&sysdev->kobj, 0x00, sizeof(struct kobject)); |
| @@ -257,6 +258,9 @@ int sysdev_register(struct sys_device * sysdev) · 9 unmodified lines | ||
| 257 | 258 | if (!error) { |
| 258 | 259 | struct sysdev_driver * drv; |
| 259 | 260 | |
| 261 | + pr_debug("Registering sys device '%s'\n", | |
| 262 | + kobject_name(&sysdev->kobj)); | |
| 263 | + | |
| 260 | 264 | mutex_lock(&sysdev_drivers_lock); |
| 261 | 265 | /* Generic notification is implicit, because it's that |
| 262 | 266 | * code that should have called us. |
| @@ -269,6 +273,7 @@ int sysdev_register(struct sys_device * sysdev) · 6 unmodified lines | ||
| 269 | 273 | } |
| 270 | 274 | mutex_unlock(&sysdev_drivers_lock); |
| 271 | 275 | } |
| 276 | + | |
| 272 | 277 | kobject_uevent(&sysdev->kobj, KOBJ_ADD); |
| 273 | 278 | return error; |
| 274 | 279 | } |
| @@ -474,3 +479,52 @@ int __init system_bus_init(void) · 199 unmodified lines | ||
| 474 | 479 | |
| 475 | 480 | EXPORT_SYMBOL_GPL(sysdev_register); |
| 476 | 481 | EXPORT_SYMBOL_GPL(sysdev_unregister); |
| 482 | + | |
| 483 | +#define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr) | |
| 484 | + | |
| 485 | +ssize_t sysdev_store_ulong(struct sys_device *sysdev, | |
| 486 | + struct sysdev_attribute *attr, | |
| 487 | + const char *buf, size_t size) | |
| 488 | +{ | |
| 489 | + struct sysdev_ext_attribute *ea = to_ext_attr(attr); | |
| 490 | + char *end; | |
| 491 | + unsigned long new = simple_strtoul(buf, &end, 0); | |
| 492 | + if (end == buf) | |
| 493 | + return -EINVAL; | |
| 494 | + *(unsigned long *)(ea->var) = new; | |
| 495 | + return end - buf; | |
| 496 | +} | |
| 497 | +EXPORT_SYMBOL_GPL(sysdev_store_ulong); | |
| 498 | + | |
| 499 | +ssize_t sysdev_show_ulong(struct sys_device *sysdev, | |
| 500 | + struct sysdev_attribute *attr, | |
| 501 | + char *buf) | |
| 502 | +{ | |
| 503 | + struct sysdev_ext_attribute *ea = to_ext_attr(attr); | |
| 504 | + return snprintf(buf, PAGE_SIZE, "%lx\n", *(unsigned long *)(ea->var)); | |
| 505 | +} | |
| 506 | +EXPORT_SYMBOL_GPL(sysdev_show_ulong); | |
| 507 | + | |
| 508 | +ssize_t sysdev_store_int(struct sys_device *sysdev, | |
| 509 | + struct sysdev_attribute *attr, | |
| 510 | + const char *buf, size_t size) | |
| 511 | +{ | |
| 512 | + struct sysdev_ext_attribute *ea = to_ext_attr(attr); | |
| 513 | + char *end; | |
| 514 | + long new = simple_strtol(buf, &end, 0); | |
| 515 | + if (end == buf || new > INT_MAX || new < INT_MIN) | |
| 516 | + return -EINVAL; | |
| 517 | + *(int *)(ea->var) = new; | |
| 518 | + return end - buf; | |
| 519 | +} | |
| 520 | +EXPORT_SYMBOL_GPL(sysdev_store_int); | |
| 521 | + | |
| 522 | +ssize_t sysdev_show_int(struct sys_device *sysdev, | |
| 523 | + struct sysdev_attribute *attr, | |
| 524 | + char *buf) | |
| 525 | +{ | |
| 526 | + struct sysdev_ext_attribute *ea = to_ext_attr(attr); | |
| 527 | + return snprintf(buf, PAGE_SIZE, "%d\n", *(int *)(ea->var)); | |
| 528 | +} | |
| 529 | +EXPORT_SYMBOL_GPL(sysdev_show_int); | |
| 530 | + | |
| @@ -34,7 +34,8 @@ · 33 unmodified lines | ||
| 34 | 34 | static SYSDEV_ATTR(_name, 0444, show_##_name, NULL) |
| 35 | 35 | |
| 36 | 36 | #define define_id_show_func(name) \ |
| 37 | −static ssize_t show_##name(struct sys_device *dev, char *buf) \ | |
| 37 | +static ssize_t show_##name(struct sys_device *dev, \ | |
| 38 | + struct sysdev_attribute *attr, char *buf) \ | |
| 38 | 39 | { \ |
| 39 | 40 | unsigned int cpu = dev->id; \ |
| 40 | 41 | return sprintf(buf, "%d\n", topology_##name(cpu)); \ |
| @@ -59,14 +60,17 @@ static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf) · 18 unmodified lines | ||
| 59 | 60 | |
| 60 | 61 | #ifdef arch_provides_topology_pointers |
| 61 | 62 | #define define_siblings_show_map(name) \ |
| 62 | −static ssize_t show_##name(struct sys_device *dev, char *buf) \ | |
| 63 | +static ssize_t show_##name(struct sys_device *dev, \ | |
| 64 | + struct sysdev_attribute *attr, char *buf) \ | |
| 63 | 65 | { \ |
| 64 | 66 | unsigned int cpu = dev->id; \ |
| 65 | 67 | return show_cpumap(0, &(topology_##name(cpu)), buf); \ |
| 66 | 68 | } |
| 67 | 69 | |
| 68 | 70 | #define define_siblings_show_list(name) \ |
| 69 | −static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ | |
| 71 | +static ssize_t show_##name##_list(struct sys_device *dev, \ | |
| 72 | + struct sysdev_attribute *attr, \ | |
| 73 | + char *buf) \ | |
| 70 | 74 | { \ |
| 71 | 75 | unsigned int cpu = dev->id; \ |
| 72 | 76 | return show_cpumap(1, &(topology_##name(cpu)), buf); \ |
| @@ -74,7 +78,8 @@ static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ · 1 unmodified line | ||
| 74 | 78 | |
| 75 | 79 | #else |
| 76 | 80 | #define define_siblings_show_map(name) \ |
| 77 | −static ssize_t show_##name(struct sys_device *dev, char *buf) \ | |
| 81 | +static ssize_t show_##name(struct sys_device *dev, \ | |
| 82 | + struct sysdev_attribute *attr, char *buf) \ | |
| 78 | 83 | { \ |
| 79 | 84 | unsigned int cpu = dev->id; \ |
| 80 | 85 | cpumask_t mask = topology_##name(cpu); \ |
| @@ -82,7 +87,9 @@ static ssize_t show_##name(struct sys_device *dev, char *buf) \ · 1 unmodified line | ||
| 82 | 87 | } |
| 83 | 88 | |
| 84 | 89 | #define define_siblings_show_list(name) \ |
| 85 | −static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ | |
| 90 | +static ssize_t show_##name##_list(struct sys_device *dev, \ | |
| 91 | + struct sysdev_attribute *attr, \ | |
| 92 | + char *buf) \ | |
| 86 | 93 | { \ |
| 87 | 94 | unsigned int cpu = dev->id; \ |
| 88 | 95 | cpumask_t mask = topology_##name(cpu); \ |
| @@ -277,8 +277,9 @@ aoechr_init(void) · 276 unmodified lines | ||
| 277 | 277 | return PTR_ERR(aoe_class); |
| 278 | 278 | } |
| 279 | 279 | for (i = 0; i < ARRAY_SIZE(chardevs); ++i) |
| 280 | − device_create(aoe_class, NULL, | |
| 281 | − MKDEV(AOE_MAJOR, chardevs[i].minor), chardevs[i].name); | |
| 280 | + device_create_drvdata(aoe_class, NULL, | |
| 281 | + MKDEV(AOE_MAJOR, chardevs[i].minor), | |
| 282 | + NULL, chardevs[i].name); | |
| 282 | 283 | |
| 283 | 284 | return 0; |
| 284 | 285 | } |
| @@ -686,8 +686,9 @@ static int __init pg_init(void) · 685 unmodified lines | ||
| 686 | 686 | for (unit = 0; unit < PG_UNITS; unit++) { |
| 687 | 687 | struct pg *dev = &devices[unit]; |
| 688 | 688 | if (dev->present) |
| 689 | − device_create(pg_class, NULL, MKDEV(major, unit), | |
| 690 | − "pg%u", unit); | |
| 689 | + device_create_drvdata(pg_class, NULL, | |
| 690 | + MKDEV(major, unit), NULL, | |
| 691 | + "pg%u", unit); | |
| 691 | 692 | } |
| 692 | 693 | err = 0; |
| 693 | 694 | goto out; |
| @@ -979,10 +979,12 @@ static int __init pt_init(void) · 978 unmodified lines | ||
| 979 | 979 | |
| 980 | 980 | for (unit = 0; unit < PT_UNITS; unit++) |
| 981 | 981 | if (pt[unit].present) { |
| 982 | − device_create(pt_class, NULL, MKDEV(major, unit), | |
| 983 | − "pt%d", unit); | |
| 984 | − device_create(pt_class, NULL, MKDEV(major, unit + 128), | |
| 985 | − "pt%dn", unit); | |
| 982 | + device_create_drvdata(pt_class, NULL, | |
| 983 | + MKDEV(major, unit), NULL, | |
| 984 | + "pt%d", unit); | |
| 985 | + device_create_drvdata(pt_class, NULL, | |
| 986 | + MKDEV(major, unit + 128), NULL, | |
| 987 | + "pt%dn", unit); | |
| 986 | 988 | } |
| 987 | 989 | goto out; |
| 988 | 990 | |
| @@ -303,7 +303,9 @@ static struct kobj_type kobj_pkt_type_wqueue = { · 302 unmodified lines | ||
| 303 | 303 | static void pkt_sysfs_dev_new(struct pktcdvd_device *pd) |
| 304 | 304 | { |
| 305 | 305 | if (class_pktcdvd) { |
| 306 | − pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, "%s", pd->name); | |
| 306 | + pd->dev = device_create_drvdata(class_pktcdvd, NULL, | |
| 307 | + pd->pkt_dev, NULL, | |
| 308 | + "%s", pd->name); | |
| 307 | 309 | if (IS_ERR(pd->dev)) |
| 308 | 310 | pd->dev = NULL; |
| 309 | 311 | } |
| @@ -500,7 +500,8 @@ static int __init dsp56k_init_driver(void) · 499 unmodified lines | ||
| 500 | 500 | err = PTR_ERR(dsp56k_class); |
| 501 | 501 | goto out_chrdev; |
| 502 | 502 | } |
| 503 | − device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), "dsp56k"); | |
| 503 | + device_create_drvdata(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), | |
| 504 | + NULL, "dsp56k"); | |
| 504 | 505 | |
| 505 | 506 | printk(banner); |
| 506 | 507 | goto out; |
| @@ -718,12 +718,12 @@ ip2_loadmain(int *iop, int *irqp) · 717 unmodified lines | ||
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | if ( NULL != ( pB = i2BoardPtrTable[i] ) ) { |
| 721 | − device_create(ip2_class, NULL, | |
| 722 | − MKDEV(IP2_IPL_MAJOR, 4 * i), | |
| 723 | − "ipl%d", i); | |
| 724 | − device_create(ip2_class, NULL, | |
| 725 | − MKDEV(IP2_IPL_MAJOR, 4 * i + 1), | |
| 726 | − "stat%d", i); | |
| 721 | + device_create_drvdata(ip2_class, NULL, | |
| 722 | + MKDEV(IP2_IPL_MAJOR, 4 * i), | |
| 723 | + NULL, "ipl%d", i); | |
| 724 | + device_create_drvdata(ip2_class, NULL, | |
| 725 | + MKDEV(IP2_IPL_MAJOR, 4 * i + 1), | |
| 726 | + NULL, "stat%d", i); | |
| 727 | 727 | |
| 728 | 728 | for ( box = 0; box < ABS_MAX_BOXES; ++box ) |
| 729 | 729 | { |
| @@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device) · 870 unmodified lines | ||
| 871 | 871 | entry->dev = dev; |
| 872 | 872 | |
| 873 | 873 | mutex_lock(®_list_mutex); |
| 874 | − device_create(ipmi_class, device, dev, "ipmi%d", if_num); | |
| 874 | + device_create_drvdata(ipmi_class, device, dev, NULL, "ipmi%d", if_num); | |
| 875 | 875 | list_add(&entry->link, ®_list); |
| 876 | 876 | mutex_unlock(®_list_mutex); |
| 877 | 877 | } |
| @@ -4599,8 +4599,9 @@ static int __init istallion_module_init(void) · 4598 unmodified lines | ||
| 4599 | 4599 | |
| 4600 | 4600 | istallion_class = class_create(THIS_MODULE, "staliomem"); |
| 4601 | 4601 | for (i = 0; i < 4; i++) |
| 4602 | − device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), | |
| 4603 | − "staliomem%d", i); | |
| 4602 | + device_create_drvdata(istallion_class, NULL, | |
| 4603 | + MKDEV(STL_SIOMEMMAJOR, i), | |
| 4604 | + NULL, "staliomem%d", i); | |
| 4604 | 4605 | |
| 4605 | 4606 | return 0; |
| 4606 | 4607 | err_deinit: |
| @@ -813,7 +813,8 @@ static int lp_register(int nr, struct parport *port) · 812 unmodified lines | ||
| 813 | 813 | if (reset) |
| 814 | 814 | lp_reset(nr); |
| 815 | 815 | |
| 816 | − device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), "lp%d", nr); | |
| 816 | + device_create_drvdata(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL, | |
| 817 | + "lp%d", nr); | |
| 817 | 818 | |
| 818 | 819 | printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, |
| 819 | 820 | (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven"); |
| @@ -989,9 +989,9 @@ static int __init chr_dev_init(void) · 988 unmodified lines | ||
| 989 | 989 | |
| 990 | 990 | mem_class = class_create(THIS_MODULE, "mem"); |
| 991 | 991 | for (i = 0; i < ARRAY_SIZE(devlist); i++) |
| 992 | − device_create(mem_class, NULL, | |
| 993 | − MKDEV(MEM_MAJOR, devlist[i].minor), | |
| 994 | − devlist[i].name); | |
| 992 | + device_create_drvdata(mem_class, NULL, | |
| 993 | + MKDEV(MEM_MAJOR, devlist[i].minor), | |
| 994 | + NULL, devlist[i].name); | |
| 995 | 995 | |
| 996 | 996 | return 0; |
| 997 | 997 | } |
| @@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc) · 216 unmodified lines | ||
| 217 | 217 | misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); |
| 218 | 218 | dev = MKDEV(MISC_MAJOR, misc->minor); |
| 219 | 219 | |
| 220 | − misc->this_device = device_create(misc_class, misc->parent, dev, | |
| 221 | − "%s", misc->name); | |
| 220 | + misc->this_device = device_create_drvdata(misc_class, misc->parent, | |
| 221 | + dev, NULL, "%s", misc->name); | |
| 222 | 222 | if (IS_ERR(misc->this_device)) { |
| 223 | 223 | err = PTR_ERR(misc->this_device); |
| 224 | 224 | goto out; |
| @@ -1896,7 +1896,7 @@ static int cm4000_probe(struct pcmcia_device *link) · 1895 unmodified lines | ||
| 1896 | 1896 | return ret; |
| 1897 | 1897 | } |
| 1898 | 1898 | |
| 1899 | − device_create(cmm_class, NULL, MKDEV(major, i), "cmm%d", i); | |
| 1899 | + device_create_drvdata(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i); | |
| 1900 | 1900 | |
| 1901 | 1901 | return 0; |
| 1902 | 1902 | } |
| @@ -653,7 +653,8 @@ static int reader_probe(struct pcmcia_device *link) · 652 unmodified lines | ||
| 653 | 653 | return ret; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | − device_create(cmx_class, NULL, MKDEV(major, i), "cmx%d", i); | |
| 656 | + device_create_drvdata(cmx_class, NULL, MKDEV(major, i), NULL, | |
| 657 | + "cmx%d", i); | |
| 657 | 658 | |
| 658 | 659 | return 0; |
| 659 | 660 | } |
| @@ -752,8 +752,9 @@ static const struct file_operations pp_fops = { · 751 unmodified lines | ||
| 752 | 752 | |
| 753 | 753 | static void pp_attach(struct parport *port) |
| 754 | 754 | { |
| 755 | − device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number), | |
| 756 | − "parport%d", port->number); | |
| 755 | + device_create_drvdata(ppdev_class, port->dev, | |
| 756 | + MKDEV(PP_MAJOR, port->number), | |
| 757 | + NULL, "parport%d", port->number); | |
| 757 | 758 | } |
| 758 | 759 | |
| 759 | 760 | static void pp_detach(struct parport *port) |
| @@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp, · 130 unmodified lines | ||
| 131 | 131 | static void bind_device(struct raw_config_request *rq) |
| 132 | 132 | { |
| 133 | 133 | device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); |
| 134 | − device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), | |
| 135 | − "raw%d", rq->raw_minor); | |
| 134 | + device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), | |
| 135 | + NULL, "raw%d", rq->raw_minor); | |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /* |
| @@ -283,7 +283,8 @@ static int __init raw_init(void) · 144 unmodified lines | ||
| 283 | 283 | ret = PTR_ERR(raw_class); |
| 284 | 284 | goto error_region; |
| 285 | 285 | } |
| 286 | − device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), "rawctl"); | |
| 286 | + device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, | |
| 287 | + "rawctl"); | |
| 287 | 288 | |
| 288 | 289 | return 0; |
| 289 | 290 | |
| @@ -444,7 +444,8 @@ scdrv_init(void) · 443 unmodified lines | ||
| 444 | 444 | continue; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | − device_create(snsc_class, NULL, dev, "%s", devname); | |
| 447 | + device_create_drvdata(snsc_class, NULL, dev, NULL, | |
| 448 | + "%s", devname); | |
| 448 | 449 | |
| 449 | 450 | ia64_sn_irtr_intr_enable(scd->scd_nasid, |
| 450 | 451 | 0 /*ignored */ , |
| @@ -4755,8 +4755,8 @@ static int __init stallion_module_init(void) · 4754 unmodified lines | ||
| 4755 | 4755 | if (IS_ERR(stallion_class)) |
| 4756 | 4756 | printk("STALLION: failed to create class\n"); |
| 4757 | 4757 | for (i = 0; i < 4; i++) |
| 4758 | − device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), | |
| 4759 | − "staliomem%d", i); | |
| 4758 | + device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), | |
| 4759 | + NULL, "staliomem%d", i); | |
| 4760 | 4760 | |
| 4761 | 4761 | return 0; |
| 4762 | 4762 | err_unrtty: |
| @@ -3412,7 +3412,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index, · 3411 unmodified lines | ||
| 3412 | 3412 | else |
| 3413 | 3413 | tty_line_name(driver, index, name); |
| 3414 | 3414 | |
| 3415 | − return device_create(tty_class, device, dev, name); | |
| 3415 | + return device_create_drvdata(tty_class, device, dev, NULL, name); | |
| 3416 | 3416 | } |
| 3417 | 3417 | |
| 3418 | 3418 | /** |
| @@ -3690,20 +3690,22 @@ static int __init tty_init(void) · 271 unmodified lines | ||
| 3690 | 3690 | if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || |
| 3691 | 3691 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) |
| 3692 | 3692 | panic("Couldn't register /dev/tty driver\n"); |
| 3693 | − device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), "tty"); | |
| 3693 | + device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, | |
| 3694 | + "tty"); | |
| 3694 | 3695 | |
| 3695 | 3696 | cdev_init(&console_cdev, &console_fops); |
| 3696 | 3697 | if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || |
| 3697 | 3698 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) |
| 3698 | 3699 | panic("Couldn't register /dev/console driver\n"); |
| 3699 | − device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), "console"); | |
| 3700 | + device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, | |
| 3701 | + "console"); | |
| 3700 | 3702 | |
| 3701 | 3703 | #ifdef CONFIG_UNIX98_PTYS |
| 3702 | 3704 | cdev_init(&ptmx_cdev, &ptmx_fops); |
| 3703 | 3705 | if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || |
| 3704 | 3706 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) |
| 3705 | 3707 | panic("Couldn't register /dev/ptmx driver\n"); |
| 3706 | − device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), "ptmx"); | |
| 3708 | + device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx"); | |
| 3707 | 3709 | #endif |
| 3708 | 3710 | |
| 3709 | 3711 | #ifdef CONFIG_VT |
| @@ -3711,7 +3713,7 @@ static int __init tty_init(void) · 1 unmodified line | ||
| 3711 | 3713 | if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) || |
| 3712 | 3714 | register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) |
| 3713 | 3715 | panic("Couldn't register /dev/tty0 driver\n"); |
| 3714 | − device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0"); | |
| 3716 | + device_create_drvdata(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0"); | |
| 3715 | 3717 | |
| 3716 | 3718 | vty_init(); |
| 3717 | 3719 | #endif |
| @@ -481,10 +481,10 @@ static struct class *vc_class; · 480 unmodified lines | ||
| 481 | 481 | |
| 482 | 482 | void vcs_make_sysfs(struct tty_struct *tty) |
| 483 | 483 | { |
| 484 | − device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), | |
| 485 | − "vcs%u", tty->index + 1); | |
| 486 | − device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), | |
| 487 | − "vcsa%u", tty->index + 1); | |
| 484 | + device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), | |
| 485 | + NULL, "vcs%u", tty->index + 1); | |
| 486 | + device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), | |
| 487 | + NULL, "vcsa%u", tty->index + 1); | |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | void vcs_remove_sysfs(struct tty_struct *tty) |
| @@ -499,7 +499,7 @@ int __init vcs_init(void) · 8 unmodified lines | ||
| 499 | 499 | panic("unable to get major %d for vcs device", VCS_MAJOR); |
| 500 | 500 | vc_class = class_create(THIS_MODULE, "vc"); |
| 501 | 501 | |
| 502 | − device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), "vcs"); | |
| 503 | − device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), "vcsa"); | |
| 502 | + device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); | |
| 503 | + device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); | |
| 504 | 504 | return 0; |
| 505 | 505 | } |
| @@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id) · 885 unmodified lines | ||
| 886 | 886 | state[i].cur_part = 0; |
| 887 | 887 | for (j = 0; j < MAX_PARTITIONS; ++j) |
| 888 | 888 | state[i].part_stat_rwi[j] = VIOT_IDLE; |
| 889 | − device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), | |
| 890 | − "iseries!vt%d", i); | |
| 891 | − device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), | |
| 892 | − "iseries!nvt%d", i); | |
| 889 | + device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), | |
| 890 | + NULL, "iseries!vt%d", i); | |
| 891 | + device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), | |
| 892 | + NULL, "iseries!nvt%d", i); | |
| 893 | 893 | printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries " |
| 894 | 894 | "resource %10.10s type %4.4s, model %3.3s\n", |
| 895 | 895 | i, viotape_unitinfo[i].rsrcname, |
| @@ -3425,9 +3425,10 @@ int register_con_driver(const struct consw *csw, int first, int last) · 3424 unmodified lines | ||
| 3425 | 3425 | if (retval) |
| 3426 | 3426 | goto err; |
| 3427 | 3427 | |
| 3428 | − con_driver->dev = device_create(vtconsole_class, NULL, | |
| 3429 | − MKDEV(0, con_driver->node), | |
| 3430 | − "vtcon%i", con_driver->node); | |
| 3428 | + con_driver->dev = device_create_drvdata(vtconsole_class, NULL, | |
| 3429 | + MKDEV(0, con_driver->node), | |
| 3430 | + NULL, "vtcon%i", | |
| 3431 | + con_driver->node); | |
| 3431 | 3432 | |
| 3432 | 3433 | if (IS_ERR(con_driver->dev)) { |
| 3433 | 3434 | printk(KERN_WARNING "Unable to create device for %s; " |
| @@ -3535,9 +3536,10 @@ static int __init vtconsole_class_init(void) · 101 unmodified lines | ||
| 3535 | 3536 | struct con_driver *con = ®istered_con_driver[i]; |
| 3536 | 3537 | |
| 3537 | 3538 | if (con->con && !con->dev) { |
| 3538 | − con->dev = device_create(vtconsole_class, NULL, | |
| 3539 | − MKDEV(0, con->node), | |
| 3540 | − "vtcon%i", con->node); | |
| 3539 | + con->dev = device_create_drvdata(vtconsole_class, NULL, | |
| 3540 | + MKDEV(0, con->node), | |
| 3541 | + NULL, "vtcon%i", | |
| 3542 | + con->node); | |
| 3541 | 3543 | |
| 3542 | 3544 | if (IS_ERR(con->dev)) { |
| 3543 | 3545 | printk(KERN_WARNING "Unable to create " |
| @@ -658,8 +658,9 @@ static int __devinit hwicap_setup(struct device *dev, int id, · 657 unmodified lines | ||
| 658 | 658 | dev_err(dev, "cdev_add() failed\n"); |
| 659 | 659 | goto failed3; |
| 660 | 660 | } |
| 661 | − /* devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */ | |
| 662 | − device_create(icap_class, dev, devt, "%s%d", DRIVER_NAME, id); | |
| 661 | + | |
| 662 | + device_create_drvdata(icap_class, dev, devt, NULL, | |
| 663 | + "%s%d", DRIVER_NAME, id); | |
| 663 | 664 | return 0; /* success */ |
| 664 | 665 | |
| 665 | 666 | failed3: |
| @@ -21,7 +21,8 @@ static int __init cpuidle_sysfs_setup(char *unused) · 20 unmodified lines | ||
| 21 | 21 | } |
| 22 | 22 | __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); |
| 23 | 23 | |
| 24 | −static ssize_t show_available_governors(struct sys_device *dev, char *buf) | |
| 24 | +static ssize_t show_available_governors(struct sys_device *dev, | |
| 25 | + struct sysdev_attribute *attr, char *buf) | |
| 25 | 26 | { |
| 26 | 27 | ssize_t i = 0; |
| 27 | 28 | struct cpuidle_governor *tmp; |
| @@ -39,7 +40,8 @@ out: · 11 unmodified lines | ||
| 39 | 40 | return i; |
| 40 | 41 | } |
| 41 | 42 | |
| 42 | −static ssize_t show_current_driver(struct sys_device *dev, char *buf) | |
| 43 | +static ssize_t show_current_driver(struct sys_device *dev, | |
| 44 | + struct sysdev_attribute *attr, char *buf) | |
| 43 | 45 | { |
| 44 | 46 | ssize_t ret; |
| 45 | 47 | |
| @@ -53,7 +55,8 @@ static ssize_t show_current_driver(struct sys_device *dev, char *buf) · 7 unmodified lines | ||
| 53 | 55 | return ret; |
| 54 | 56 | } |
| 55 | 57 | |
| 56 | −static ssize_t show_current_governor(struct sys_device *dev, char *buf) | |
| 58 | +static ssize_t show_current_governor(struct sys_device *dev, | |
| 59 | + struct sysdev_attribute *attr, char *buf) | |
| 57 | 60 | { |
| 58 | 61 | ssize_t ret; |
| 59 | 62 | |
| @@ -68,6 +71,7 @@ static ssize_t show_current_governor(struct sys_device *dev, char *buf) · 8 unmodified lines | ||
| 68 | 71 | } |
| 69 | 72 | |
| 70 | 73 | static ssize_t store_current_governor(struct sys_device *dev, |
| 74 | + struct sysdev_attribute *attr, | |
| 71 | 75 | const char *buf, size_t count) |
| 72 | 76 | { |
| 73 | 77 | char gov_name[CPUIDLE_NAME_LEN]; |
| @@ -14,8 +14,9 @@ int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot) · 13 unmodified lines | ||
| 14 | 14 | { |
| 15 | 15 | struct device *cd; |
| 16 | 16 | |
| 17 | − cd = device_create(dca_class, dca->cd, MKDEV(0, slot + 1), | |
| 18 | − "requester%d", slot); | |
| 17 | + cd = device_create_drvdata(dca_class, dca->cd, | |
| 18 | + MKDEV(0, slot + 1), NULL, | |
| 19 | + "requester%d", slot); | |
| 19 | 20 | if (IS_ERR(cd)) |
| 20 | 21 | return PTR_ERR(cd); |
| 21 | 22 | return 0; |
| @@ -46,7 +47,8 @@ idr_try_again: · 24 unmodified lines | ||
| 46 | 47 | return err; |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | − cd = device_create(dca_class, dev, MKDEV(0, 0), "dca%d", dca->id); | |
| 50 | + cd = device_create_drvdata(dca_class, dev, MKDEV(0, 0), NULL, | |
| 51 | + "dca%d", dca->id); | |
| 50 | 52 | if (IS_ERR(cd)) { |
| 51 | 53 | spin_lock(&dca_idr_lock); |
| 52 | 54 | idr_remove(&dca_idr, dca->id); |
| @@ -9,7 +9,7 @@ obj-${CONFIG_EISA_VIRTUAL_ROOT} += virtual_root.o · 8 unmodified lines | ||
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | # Ugly hack to get DEVICE_NAME_SIZE value... |
| 12 | −DEVICE_NAME_SIZE =$(shell awk '$$1=="\#define" && $$2=="DEVICE_NAME_SIZE" {print $$3-1}' $(srctree)/include/linux/device.h) | |
| 12 | +DEVICE_NAME_SIZE = 50 | |
| 13 | 13 | |
| 14 | 14 | $(obj)/eisa-bus.o: $(obj)/devlist.h |
| 15 | 15 | |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | struct eisa_device_info { |
| 24 | 24 | struct eisa_device_id id; |
| 25 | − char name[DEVICE_NAME_SIZE]; | |
| 25 | + char name[50]; | |
| 26 | 26 | }; |
| 27 | 27 | |
| 28 | 28 | #ifdef CONFIG_EISA_NAMES |
| @@ -63,7 +63,7 @@ static void __init eisa_name_device (struct eisa_device *edev) · 34 unmodified lines | ||
| 63 | 63 | if (!strcmp (edev->id.sig, eisa_table[i].id.sig)) { |
| 64 | 64 | strlcpy (edev->pretty_name, |
| 65 | 65 | eisa_table[i].name, |
| 66 | − DEVICE_NAME_SIZE); | |
| 66 | + sizeof(edev->pretty_name)); | |
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | } |
| @@ -322,8 +322,9 @@ int hidraw_connect(struct hid_device *hid) · 321 unmodified lines | ||
| 322 | 322 | goto out; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | − dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor), | |
| 326 | − "%s%d", "hidraw", minor); | |
| 325 | + dev->dev = device_create_drvdata(hidraw_class, NULL, | |
| 326 | + MKDEV(hidraw_major, minor), NULL, | |
| 327 | + "%s%d", "hidraw", minor); | |
| 327 | 328 | |
| 328 | 329 | if (IS_ERR(dev->dev)) { |
| 329 | 330 | spin_lock(&minors_lock); |
| @@ -55,7 +55,8 @@ again: · 54 unmodified lines | ||
| 55 | 55 | return ERR_PTR(err); |
| 56 | 56 | |
| 57 | 57 | id = id & MAX_ID_MASK; |
| 58 | − hwdev = device_create(hwmon_class, dev, MKDEV(0,0), HWMON_ID_FORMAT, id); | |
| 58 | + hwdev = device_create_drvdata(hwmon_class, dev, MKDEV(0, 0), NULL, | |
| 59 | + HWMON_ID_FORMAT, id); | |
| 59 | 60 | |
| 60 | 61 | if (IS_ERR(hwdev)) { |
| 61 | 62 | spin_lock(&idr_lock); |
| @@ -722,7 +722,8 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) · 721 unmodified lines | ||
| 722 | 722 | |
| 723 | 723 | INIT_LIST_HEAD(&driver->clients); |
| 724 | 724 | /* Walk the adapters that are already present */ |
| 725 | − class_for_each_device(&i2c_adapter_class, driver, __attach_adapter); | |
| 725 | + class_for_each_device(&i2c_adapter_class, NULL, driver, | |
| 726 | + __attach_adapter); | |
| 726 | 727 | |
| 727 | 728 | mutex_unlock(&core_lock); |
| 728 | 729 | return 0; |
| @@ -782,7 +783,8 @@ void i2c_del_driver(struct i2c_driver *driver) · 53 unmodified lines | ||
| 782 | 783 | { |
| 783 | 784 | mutex_lock(&core_lock); |
| 784 | 785 | |
| 785 | − class_for_each_device(&i2c_adapter_class, driver, __detach_adapter); | |
| 786 | + class_for_each_device(&i2c_adapter_class, NULL, driver, | |
| 787 | + __detach_adapter); | |
| 786 | 788 | |
| 787 | 789 | driver_unregister(&driver->driver); |
| 788 | 790 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); |
| @@ -521,9 +521,9 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) · 520 unmodified lines | ||
| 521 | 521 | return PTR_ERR(i2c_dev); |
| 522 | 522 | |
| 523 | 523 | /* register this i2c device with the driver core */ |
| 524 | − i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, | |
| 525 | − MKDEV(I2C_MAJOR, adap->nr), | |
| 526 | − "i2c-%d", adap->nr); | |
| 524 | + i2c_dev->dev = device_create_drvdata(i2c_dev_class, &adap->dev, | |
| 525 | + MKDEV(I2C_MAJOR, adap->nr), | |
| 526 | + NULL, "i2c-%d", adap->nr); | |
| 527 | 527 | if (IS_ERR(i2c_dev->dev)) { |
| 528 | 528 | res = PTR_ERR(i2c_dev->dev); |
| 529 | 529 | goto error; |
| @@ -2697,10 +2697,12 @@ static int ide_tape_probe(ide_drive_t *drive) · 2696 unmodified lines | ||
| 2697 | 2697 | |
| 2698 | 2698 | idetape_setup(drive, tape, minor); |
| 2699 | 2699 | |
| 2700 | − device_create(idetape_sysfs_class, &drive->gendev, | |
| 2701 | − MKDEV(IDETAPE_MAJOR, minor), "%s", tape->name); | |
| 2702 | − device_create(idetape_sysfs_class, &drive->gendev, | |
| 2703 | − MKDEV(IDETAPE_MAJOR, minor + 128), "n%s", tape->name); | |
| 2700 | + device_create_drvdata(idetape_sysfs_class, &drive->gendev, | |
| 2701 | + MKDEV(IDETAPE_MAJOR, minor), NULL, | |
| 2702 | + "%s", tape->name); | |
| 2703 | + device_create_drvdata(idetape_sysfs_class, &drive->gendev, | |
| 2704 | + MKDEV(IDETAPE_MAJOR, minor + 128), NULL, | |
| 2705 | + "n%s", tape->name); | |
| 2704 | 2706 | |
| 2705 | 2707 | g->fops = &idetape_block_ops; |
| 2706 | 2708 | ide_register_region(g); |
| @@ -2296,9 +2296,10 @@ static void dv1394_add_host(struct hpsb_host *host) · 2295 unmodified lines | ||
| 2296 | 2296 | |
| 2297 | 2297 | ohci = (struct ti_ohci *)host->hostdata; |
| 2298 | 2298 | |
| 2299 | − device_create(hpsb_protocol_class, NULL, MKDEV( | |
| 2300 | − IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), | |
| 2301 | − "dv1394-%d", id); | |
| 2299 | + device_create_drvdata(hpsb_protocol_class, NULL, | |
| 2300 | + MKDEV(IEEE1394_MAJOR, | |
| 2301 | + IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), NULL, | |
| 2302 | + "dv1394-%d", id); | |
| 2302 | 2303 | |
| 2303 | 2304 | dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE); |
| 2304 | 2305 | dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT); |
| @@ -754,7 +754,8 @@ static void nodemgr_remove_uds(struct node_entry *ne) · 753 unmodified lines | ||
| 754 | 754 | */ |
| 755 | 755 | mutex_lock(&nodemgr_serialize_remove_uds); |
| 756 | 756 | for (;;) { |
| 757 | − dev = class_find_device(&nodemgr_ud_class, ne, __match_ne); | |
| 757 | + dev = class_find_device(&nodemgr_ud_class, NULL, ne, | |
| 758 | + __match_ne); | |
| 758 | 759 | if (!dev) |
| 759 | 760 | break; |
| 760 | 761 | ud = container_of(dev, struct unit_directory, unit_dev); |
| @@ -901,7 +902,8 @@ static struct node_entry *find_entry_by_guid(u64 guid) · 140 unmodified lines | ||
| 901 | 902 | struct device *dev; |
| 902 | 903 | struct node_entry *ne; |
| 903 | 904 | |
| 904 | − dev = class_find_device(&nodemgr_ne_class, &guid, __match_ne_guid); | |
| 905 | + dev = class_find_device(&nodemgr_ne_class, NULL, &guid, | |
| 906 | + __match_ne_guid); | |
| 905 | 907 | if (!dev) |
| 906 | 908 | return NULL; |
| 907 | 909 | ne = container_of(dev, struct node_entry, node_dev); |
| @@ -940,7 +942,8 @@ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, · 32 unmodified lines | ||
| 940 | 942 | param.host = host; |
| 941 | 943 | param.nodeid = nodeid; |
| 942 | 944 | |
| 943 | − dev = class_find_device(&nodemgr_ne_class, ¶m, __match_ne_nodeid); | |
| 945 | + dev = class_find_device(&nodemgr_ne_class, NULL, ¶m, | |
| 946 | + __match_ne_nodeid); | |
| 944 | 947 | if (!dev) |
| 945 | 948 | return NULL; |
| 946 | 949 | ne = container_of(dev, struct node_entry, node_dev); |
| @@ -1453,7 +1456,8 @@ static void nodemgr_suspend_ne(struct node_entry *ne) · 506 unmodified lines | ||
| 1453 | 1456 | ne->in_limbo = 1; |
| 1454 | 1457 | WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo)); |
| 1455 | 1458 | |
| 1456 | − class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_driver_suspend); | |
| 1459 | + class_for_each_device(&nodemgr_ud_class, NULL, ne, | |
| 1460 | + __nodemgr_driver_suspend); | |
| 1457 | 1461 | } |
| 1458 | 1462 | |
| 1459 | 1463 | |
| @@ -1462,7 +1466,8 @@ static void nodemgr_resume_ne(struct node_entry *ne) · 2 unmodified lines | ||
| 1462 | 1466 | ne->in_limbo = 0; |
| 1463 | 1467 | device_remove_file(&ne->device, &dev_attr_ne_in_limbo); |
| 1464 | 1468 | |
| 1465 | − class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_driver_resume); | |
| 1469 | + class_for_each_device(&nodemgr_ud_class, NULL, ne, | |
| 1470 | + __nodemgr_driver_resume); | |
| 1466 | 1471 | HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", |
| 1467 | 1472 | NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid); |
| 1468 | 1473 | } |
| @@ -1498,7 +1503,8 @@ static int __nodemgr_update_pdrv(struct device *dev, void *data) · 29 unmodified lines | ||
| 1498 | 1503 | |
| 1499 | 1504 | static void nodemgr_update_pdrv(struct node_entry *ne) |
| 1500 | 1505 | { |
| 1501 | − class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_update_pdrv); | |
| 1506 | + class_for_each_device(&nodemgr_ud_class, NULL, ne, | |
| 1507 | + __nodemgr_update_pdrv); | |
| 1502 | 1508 | } |
| 1503 | 1509 | |
| 1504 | 1510 | |
| @@ -1591,7 +1597,8 @@ static void nodemgr_node_probe(struct host_info *hi, int generation) · 86 unmodified lines | ||
| 1591 | 1597 | * while probes are time-consuming. (Well, those probes need some |
| 1592 | 1598 | * improvement...) */ |
| 1593 | 1599 | |
| 1594 | − class_for_each_device(&nodemgr_ne_class, ¶m, __nodemgr_node_probe); | |
| 1600 | + class_for_each_device(&nodemgr_ne_class, NULL, ¶m, | |
| 1601 | + __nodemgr_node_probe); | |
| 1595 | 1602 | |
| 1596 | 1603 | /* If we had a bus reset while we were scanning the bus, it is |
| 1597 | 1604 | * possible that we did not probe all nodes. In that case, we |
| @@ -1826,7 +1833,7 @@ int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *)) · 228 unmodified lines | ||
| 1826 | 1833 | |
| 1827 | 1834 | hip.cb = cb; |
| 1828 | 1835 | hip.data = data; |
| 1829 | − error = class_for_each_device(&hpsb_host_class, &hip, | |
| 1836 | + error = class_for_each_device(&hpsb_host_class, NULL, &hip, | |
| 1830 | 1837 | __nodemgr_for_each_host); |
| 1831 | 1838 | |
| 1832 | 1839 | return error; |
| @@ -3010,10 +3010,10 @@ static int __init init_raw1394(void) · 3009 unmodified lines | ||
| 3010 | 3010 | hpsb_register_highlevel(&raw1394_highlevel); |
| 3011 | 3011 | |
| 3012 | 3012 | if (IS_ERR |
| 3013 | − (device_create( | |
| 3013 | + (device_create_drvdata( | |
| 3014 | 3014 | hpsb_protocol_class, NULL, |
| 3015 | 3015 | MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), |
| 3016 | − RAW1394_DEVICE_NAME))) { | |
| 3016 | + NULL, RAW1394_DEVICE_NAME))) { | |
| 3017 | 3017 | ret = -EFAULT; |
| 3018 | 3018 | goto out_unreg; |
| 3019 | 3019 | } |
| @@ -1341,9 +1341,9 @@ static void video1394_add_host (struct hpsb_host *host) · 1340 unmodified lines | ||
| 1341 | 1341 | hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); |
| 1342 | 1342 | |
| 1343 | 1343 | minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; |
| 1344 | − device_create(hpsb_protocol_class, NULL, | |
| 1345 | − MKDEV(IEEE1394_MAJOR, minor), | |
| 1346 | − "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); | |
| 1344 | + device_create_drvdata(hpsb_protocol_class, NULL, | |
| 1345 | + MKDEV(IEEE1394_MAJOR, minor), NULL, | |
| 1346 | + "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); | |
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | 1349 | |
| @@ -44,6 +44,7 @@ · 43 unmodified lines | ||
| 44 | 44 | #include <linux/spinlock.h> |
| 45 | 45 | #include <linux/sysfs.h> |
| 46 | 46 | #include <linux/workqueue.h> |
| 47 | +#include <linux/kdev_t.h> | |
| 47 | 48 | |
| 48 | 49 | #include <rdma/ib_cache.h> |
| 49 | 50 | #include <rdma/ib_cm.h> |
| @@ -162,8 +163,8 @@ struct cm_port { · 112 unmodified lines | ||
| 162 | 163 | |
| 163 | 164 | struct cm_device { |
| 164 | 165 | struct list_head list; |
| 165 | − struct ib_device *device; | |
| 166 | − struct kobject dev_obj; | |
| 166 | + struct ib_device *ib_device; | |
| 167 | + struct device *device; | |
| 167 | 168 | u8 ack_delay; |
| 168 | 169 | struct cm_port *port[0]; |
| 169 | 170 | }; |
| @@ -339,7 +340,7 @@ static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc, · 169 unmodified lines | ||
| 339 | 340 | { |
| 340 | 341 | av->port = port; |
| 341 | 342 | av->pkey_index = wc->pkey_index; |
| 342 | − ib_init_ah_from_wc(port->cm_dev->device, port->port_num, wc, | |
| 343 | + ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc, | |
| 343 | 344 | grh, &av->ah_attr); |
| 344 | 345 | } |
| 345 | 346 | |
| @@ -353,7 +354,7 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av) · 7 unmodified lines | ||
| 353 | 354 | |
| 354 | 355 | read_lock_irqsave(&cm.device_lock, flags); |
| 355 | 356 | list_for_each_entry(cm_dev, &cm.device_list, list) { |
| 356 | − if (!ib_find_cached_gid(cm_dev->device, &path->sgid, | |
| 357 | + if (!ib_find_cached_gid(cm_dev->ib_device, &path->sgid, | |
| 357 | 358 | &p, NULL)) { |
| 358 | 359 | port = cm_dev->port[p-1]; |
| 359 | 360 | break; |
| @@ -364,13 +365,13 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av) · 4 unmodified lines | ||
| 364 | 365 | if (!port) |
| 365 | 366 | return -EINVAL; |
| 366 | 367 | |
| 367 | − ret = ib_find_cached_pkey(cm_dev->device, port->port_num, | |
| 368 | + ret = ib_find_cached_pkey(cm_dev->ib_device, port->port_num, | |
| 368 | 369 | be16_to_cpu(path->pkey), &av->pkey_index); |
| 369 | 370 | if (ret) |
| 370 | 371 | return ret; |
| 371 | 372 | |
| 372 | 373 | av->port = port; |
| 373 | − ib_init_ah_from_path(cm_dev->device, port->port_num, path, | |
| 374 | + ib_init_ah_from_path(cm_dev->ib_device, port->port_num, path, | |
| 374 | 375 | &av->ah_attr); |
| 375 | 376 | av->timeout = path->packet_life_time + 1; |
| 376 | 377 | return 0; |
| @@ -1515,7 +1516,7 @@ static int cm_req_handler(struct cm_work *work) · 1138 unmodified lines | ||
| 1515 | 1516 | |
| 1516 | 1517 | req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad; |
| 1517 | 1518 | |
| 1518 | − cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL); | |
| 1519 | + cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL); | |
| 1519 | 1520 | if (IS_ERR(cm_id)) |
| 1520 | 1521 | return PTR_ERR(cm_id); |
| 1521 | 1522 | |
| @@ -1550,7 +1551,7 @@ static int cm_req_handler(struct cm_work *work) · 28 unmodified lines | ||
| 1550 | 1551 | cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]); |
| 1551 | 1552 | ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av); |
| 1552 | 1553 | if (ret) { |
| 1553 | − ib_get_cached_gid(work->port->cm_dev->device, | |
| 1554 | + ib_get_cached_gid(work->port->cm_dev->ib_device, | |
| 1554 | 1555 | work->port->port_num, 0, &work->path[0].sgid); |
| 1555 | 1556 | ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID, |
| 1556 | 1557 | &work->path[0].sgid, sizeof work->path[0].sgid, |
| @@ -2950,7 +2951,7 @@ static int cm_sidr_req_handler(struct cm_work *work) · 1393 unmodified lines | ||
| 2950 | 2951 | struct cm_sidr_req_msg *sidr_req_msg; |
| 2951 | 2952 | struct ib_wc *wc; |
| 2952 | 2953 | |
| 2953 | − cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL); | |
| 2954 | + cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL); | |
| 2954 | 2955 | if (IS_ERR(cm_id)) |
| 2955 | 2956 | return PTR_ERR(cm_id); |
| 2956 | 2957 | cm_id_priv = container_of(cm_id, struct cm_id_private, id); |
| @@ -3578,7 +3579,7 @@ static void cm_get_ack_delay(struct cm_device *cm_dev) · 621 unmodified lines | ||
| 3578 | 3579 | { |
| 3579 | 3580 | struct ib_device_attr attr; |
| 3580 | 3581 | |
| 3581 | − if (ib_query_device(cm_dev->device, &attr)) | |
| 3582 | + if (ib_query_device(cm_dev->ib_device, &attr)) | |
| 3582 | 3583 | cm_dev->ack_delay = 0; /* acks will rely on packet life time */ |
| 3583 | 3584 | else |
| 3584 | 3585 | cm_dev->ack_delay = attr.local_ca_ack_delay; |
| @@ -3618,18 +3619,6 @@ static struct kobj_type cm_port_obj_type = { · 33 unmodified lines | ||
| 3618 | 3619 | .release = cm_release_port_obj |
| 3619 | 3620 | }; |
| 3620 | 3621 | |
| 3621 | −static void cm_release_dev_obj(struct kobject *obj) | |
| 3622 | −{ | |
| 3623 | − struct cm_device *cm_dev; | |
| 3624 | − | |
| 3625 | − cm_dev = container_of(obj, struct cm_device, dev_obj); | |
| 3626 | − kfree(cm_dev); | |
| 3627 | −} | |
| 3628 | − | |
| 3629 | −static struct kobj_type cm_dev_obj_type = { | |
| 3630 | − .release = cm_release_dev_obj | |
| 3631 | −}; | |
| 3632 | − | |
| 3633 | 3622 | struct class cm_class = { |
| 3634 | 3623 | .name = "infiniband_cm", |
| 3635 | 3624 | }; |
| @@ -3640,7 +3629,7 @@ static int cm_create_port_fs(struct cm_port *port) · 4 unmodified lines | ||
| 3640 | 3629 | int i, ret; |
| 3641 | 3630 | |
| 3642 | 3631 | ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type, |
| 3643 | − &port->cm_dev->dev_obj, | |
| 3632 | + &port->cm_dev->device->kobj, | |
| 3644 | 3633 | "%d", port->port_num); |
| 3645 | 3634 | if (ret) { |
| 3646 | 3635 | kfree(port); |
| @@ -3676,7 +3665,7 @@ static void cm_remove_port_fs(struct cm_port *port) · 29 unmodified lines | ||
| 3676 | 3665 | kobject_put(&port->port_obj); |
| 3677 | 3666 | } |
| 3678 | 3667 | |
| 3679 | −static void cm_add_one(struct ib_device *device) | |
| 3668 | +static void cm_add_one(struct ib_device *ib_device) | |
| 3680 | 3669 | { |
| 3681 | 3670 | struct cm_device *cm_dev; |
| 3682 | 3671 | struct cm_port *port; |
| @@ -3691,26 +3680,27 @@ static void cm_add_one(struct ib_device *device) · 8 unmodified lines | ||
| 3691 | 3680 | int ret; |
| 3692 | 3681 | u8 i; |
| 3693 | 3682 | |
| 3694 | − if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) | |
| 3683 | + if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB) | |
| 3695 | 3684 | return; |
| 3696 | 3685 | |
| 3697 | 3686 | cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) * |
| 3698 | − device->phys_port_cnt, GFP_KERNEL); | |
| 3687 | + ib_device->phys_port_cnt, GFP_KERNEL); | |
| 3699 | 3688 | if (!cm_dev) |
| 3700 | 3689 | return; |
| 3701 | 3690 | |
| 3702 | − cm_dev->device = device; | |
| 3691 | + cm_dev->ib_device = ib_device; | |
| 3703 | 3692 | cm_get_ack_delay(cm_dev); |
| 3704 | 3693 | |
| 3705 | − ret = kobject_init_and_add(&cm_dev->dev_obj, &cm_dev_obj_type, | |
| 3706 | − &cm_class.subsys.kobj, "%s", device->name); | |
| 3707 | − if (ret) { | |
| 3694 | + cm_dev->device = device_create_drvdata(&cm_class, &ib_device->dev, | |
| 3695 | + MKDEV(0, 0), NULL, | |
| 3696 | + "%s", ib_device->name); | |
| 3697 | + if (!cm_dev->device) { | |
| 3708 | 3698 | kfree(cm_dev); |
| 3709 | 3699 | return; |
| 3710 | 3700 | } |
| 3711 | 3701 | |
| 3712 | 3702 | set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask); |
| 3713 | − for (i = 1; i <= device->phys_port_cnt; i++) { | |
| 3703 | + for (i = 1; i <= ib_device->phys_port_cnt; i++) { | |
| 3714 | 3704 | port = kzalloc(sizeof *port, GFP_KERNEL); |
| 3715 | 3705 | if (!port) |
| 3716 | 3706 | goto error1; |
| @@ -3723,7 +3713,7 @@ static void cm_add_one(struct ib_device *device) · 6 unmodified lines | ||
| 3723 | 3713 | if (ret) |
| 3724 | 3714 | goto error1; |
| 3725 | 3715 | |
| 3726 | − port->mad_agent = ib_register_mad_agent(device, i, | |
| 3716 | + port->mad_agent = ib_register_mad_agent(ib_device, i, | |
| 3727 | 3717 | IB_QPT_GSI, |
| 3728 | 3718 | ®_req, |
| 3729 | 3719 | 0, |
| @@ -3733,11 +3723,11 @@ static void cm_add_one(struct ib_device *device) · 3 unmodified lines | ||
| 3733 | 3723 | if (IS_ERR(port->mad_agent)) |
| 3734 | 3724 | goto error2; |
| 3735 | 3725 | |
| 3736 | − ret = ib_modify_port(device, i, 0, &port_modify); | |
| 3726 | + ret = ib_modify_port(ib_device, i, 0, &port_modify); | |
| 3737 | 3727 | if (ret) |
| 3738 | 3728 | goto error3; |
| 3739 | 3729 | } |
| 3740 | − ib_set_client_data(device, &cm_client, cm_dev); | |
| 3730 | + ib_set_client_data(ib_device, &cm_client, cm_dev); | |
| 3741 | 3731 | |
| 3742 | 3732 | write_lock_irqsave(&cm.device_lock, flags); |
| 3743 | 3733 | list_add_tail(&cm_dev->list, &cm.device_list); |
| @@ -3753,14 +3743,14 @@ error1: · 9 unmodified lines | ||
| 3753 | 3743 | port_modify.clr_port_cap_mask = IB_PORT_CM_SUP; |
| 3754 | 3744 | while (--i) { |
| 3755 | 3745 | port = cm_dev->port[i-1]; |
| 3756 | − ib_modify_port(device, port->port_num, 0, &port_modify); | |
| 3746 | + ib_modify_port(ib_device, port->port_num, 0, &port_modify); | |
| 3757 | 3747 | ib_unregister_mad_agent(port->mad_agent); |
| 3758 | 3748 | cm_remove_port_fs(port); |
| 3759 | 3749 | } |
| 3760 | − kobject_put(&cm_dev->dev_obj); | |
| 3750 | + device_unregister(cm_dev->device); | |
| 3761 | 3751 | } |
| 3762 | 3752 | |
| 3763 | −static void cm_remove_one(struct ib_device *device) | |
| 3753 | +static void cm_remove_one(struct ib_device *ib_device) | |
| 3764 | 3754 | { |
| 3765 | 3755 | struct cm_device *cm_dev; |
| 3766 | 3756 | struct cm_port *port; |
| @@ -3770,7 +3760,7 @@ static void cm_remove_one(struct ib_device *device) · 3 unmodified lines | ||
| 3770 | 3760 | unsigned long flags; |
| 3771 | 3761 | int i; |
| 3772 | 3762 | |
| 3773 | − cm_dev = ib_get_client_data(device, &cm_client); | |
| 3763 | + cm_dev = ib_get_client_data(ib_device, &cm_client); | |
| 3774 | 3764 | if (!cm_dev) |
| 3775 | 3765 | return; |
| 3776 | 3766 | |
| @@ -3778,14 +3768,14 @@ static void cm_remove_one(struct ib_device *device) · 1 unmodified line | ||
| 3778 | 3768 | list_del(&cm_dev->list); |
| 3779 | 3769 | write_unlock_irqrestore(&cm.device_lock, flags); |
| 3780 | 3770 | |
| 3781 | − for (i = 1; i <= device->phys_port_cnt; i++) { | |
| 3771 | + for (i = 1; i <= ib_device->phys_port_cnt; i++) { | |
| 3782 | 3772 | port = cm_dev->port[i-1]; |
| 3783 | − ib_modify_port(device, port->port_num, 0, &port_modify); | |
| 3773 | + ib_modify_port(ib_device, port->port_num, 0, &port_modify); | |
| 3784 | 3774 | ib_unregister_mad_agent(port->mad_agent); |
| 3785 | 3775 | flush_workqueue(cm.wq); |
| 3786 | 3776 | cm_remove_port_fs(port); |
| 3787 | 3777 | } |
| 3788 | − kobject_put(&cm_dev->dev_obj); | |
| 3778 | + device_unregister(cm_dev->device); | |
| 3789 | 3779 | } |
| 3790 | 3780 | |
| 3791 | 3781 | static int __init ib_cm_init(void) |
| @@ -2455,7 +2455,7 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops, · 2454 unmodified lines | ||
| 2455 | 2455 | goto err_cdev; |
| 2456 | 2456 | } |
| 2457 | 2457 | |
| 2458 | − device = device_create(ipath_class, NULL, dev, name); | |
| 2458 | + device = device_create_drvdata(ipath_class, NULL, dev, NULL, name); | |
| 2459 | 2459 | |
| 2460 | 2460 | if (IS_ERR(device)) { |
| 2461 | 2461 | ret = PTR_ERR(device); |
| @@ -1553,7 +1553,8 @@ static int __init capi_init(void) · 1552 unmodified lines | ||
| 1553 | 1553 | return PTR_ERR(capi_class); |
| 1554 | 1554 | } |
| 1555 | 1555 | |
| 1556 | − device_create(capi_class, NULL, MKDEV(capi_major, 0), "capi"); | |
| 1556 | + device_create_drvdata(capi_class, NULL, MKDEV(capi_major, 0), NULL, | |
| 1557 | + "capi"); | |
| 1557 | 1558 | |
| 1558 | 1559 | #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE |
| 1559 | 1560 | if (capinc_tty_init() < 0) { |
| @@ -862,7 +862,8 @@ adbdev_init(void) · 861 unmodified lines | ||
| 862 | 862 | adb_dev_class = class_create(THIS_MODULE, "adb"); |
| 863 | 863 | if (IS_ERR(adb_dev_class)) |
| 864 | 864 | return; |
| 865 | − device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), "adb"); | |
| 865 | + device_create_drvdata(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, | |
| 866 | + "adb"); | |
| 866 | 867 | |
| 867 | 868 | platform_device_register(&adb_pfdev); |
| 868 | 869 | platform_driver_probe(&adb_pfdrv, adb_dummy_probe); |
| @@ -40,7 +40,7 @@ static struct mca_bus *mca_root_busses[MAX_MCA_BUSSES]; · 39 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | struct mca_device_info { |
| 42 | 42 | short pos_id; /* the 2 byte pos id for this card */ |
| 43 | − char name[DEVICE_NAME_SIZE]; | |
| 43 | + char name[50]; | |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | static int mca_bus_match (struct device *dev, struct device_driver *drv) |
| @@ -233,9 +233,9 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, · 232 unmodified lines | ||
| 233 | 233 | |
| 234 | 234 | mutex_unlock(&dvbdev_register_lock); |
| 235 | 235 | |
| 236 | − clsdev = device_create(dvb_class, adap->device, | |
| 236 | + clsdev = device_create_drvdata(dvb_class, adap->device, | |
| 237 | 237 | MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), |
| 238 | − "dvb%d.%s%d", adap->num, dnames[type], id); | |
| 238 | + NULL, "dvb%d.%s%d", adap->num, dnames[type], id); | |
| 239 | 239 | if (IS_ERR(clsdev)) { |
| 240 | 240 | printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n", |
| 241 | 241 | __func__, adap->num, dnames[type], id, PTR_ERR(clsdev)); |
| @@ -51,7 +51,7 @@ struct jmb38x_ms_host { · 50 unmodified lines | ||
| 51 | 51 | void __iomem *addr; |
| 52 | 52 | spinlock_t lock; |
| 53 | 53 | int id; |
| 54 | − char host_id[DEVICE_ID_SIZE]; | |
| 54 | + char host_id[32]; | |
| 55 | 55 | int irq; |
| 56 | 56 | unsigned int block_pos; |
| 57 | 57 | unsigned long timeout_jiffies; |
| @@ -781,7 +781,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt) · 723 unmodified lines | ||
| 781 | 781 | |
| 782 | 782 | spin_lock_init(&host->lock); |
| 783 | 783 | host->id = cnt; |
| 784 | − snprintf(host->host_id, DEVICE_ID_SIZE, DRIVER_NAME ":slot%d", | |
| 784 | + snprintf(host->host_id, sizeof(host->host_id), DRIVER_NAME ":slot%d", | |
| 785 | 785 | host->id); |
| 786 | 786 | host->irq = jm->pdev->irq; |
| 787 | 787 | host->timeout_jiffies = msecs_to_jiffies(1000); |
| @@ -1670,7 +1670,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) · 1669 unmodified lines | ||
| 1670 | 1670 | INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work); |
| 1671 | 1671 | spin_lock_init(&ioc->fault_reset_work_lock); |
| 1672 | 1672 | |
| 1673 | − snprintf(ioc->reset_work_q_name, KOBJ_NAME_LEN, "mpt_poll_%d", ioc->id); | |
| 1673 | + snprintf(ioc->reset_work_q_name, sizeof(ioc->reset_work_q_name), | |
| 1674 | + "mpt_poll_%d", ioc->id); | |
| 1674 | 1675 | ioc->reset_work_q = |
| 1675 | 1676 | create_singlethread_workqueue(ioc->reset_work_q_name); |
| 1676 | 1677 | if (!ioc->reset_work_q) { |
| @@ -707,12 +707,12 @@ typedef struct _MPT_ADAPTER · 706 unmodified lines | ||
| 707 | 707 | u8 fc_link_speed[2]; |
| 708 | 708 | spinlock_t fc_rescan_work_lock; |
| 709 | 709 | struct work_struct fc_rescan_work; |
| 710 | − char fc_rescan_work_q_name[KOBJ_NAME_LEN]; | |
| 710 | + char fc_rescan_work_q_name[20]; | |
| 711 | 711 | struct workqueue_struct *fc_rescan_work_q; |
| 712 | 712 | struct scsi_cmnd **ScsiLookup; |
| 713 | 713 | spinlock_t scsi_lookup_lock; |
| 714 | 714 | |
| 715 | − char reset_work_q_name[KOBJ_NAME_LEN]; | |
| 715 | + char reset_work_q_name[20]; | |
| 716 | 716 | struct workqueue_struct *reset_work_q; |
| 717 | 717 | struct delayed_work fault_reset_work; |
| 718 | 718 | spinlock_t fault_reset_work_lock; |
| @@ -1326,8 +1326,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 1325 unmodified lines | ||
| 1326 | 1326 | |
| 1327 | 1327 | /* initialize workqueue */ |
| 1328 | 1328 | |
| 1329 | − snprintf(ioc->fc_rescan_work_q_name, KOBJ_NAME_LEN, "mptfc_wq_%d", | |
| 1330 | − sh->host_no); | |
| 1329 | + snprintf(ioc->fc_rescan_work_q_name, sizeof(ioc->fc_rescan_work_q_name), | |
| 1330 | + "mptfc_wq_%d", sh->host_no); | |
| 1331 | 1331 | ioc->fc_rescan_work_q = |
| 1332 | 1332 | create_singlethread_workqueue(ioc->fc_rescan_work_q_name); |
| 1333 | 1333 | if (!ioc->fc_rescan_work_q) |
| @@ -420,4 +420,17 @@ config SGI_XP · 419 unmodified lines | ||
| 420 | 420 | this feature will allow for direct communication between SSIs |
| 421 | 421 | based on a network adapter and DMA messaging. |
| 422 | 422 | |
| 423 | +config HP_ILO | |
| 424 | + tristate "Channel interface driver for HP iLO/iLO2 processor" | |
| 425 | + default n | |
| 426 | + help | |
| 427 | + The channel interface driver allows applications to communicate | |
| 428 | + with iLO/iLO2 management processors present on HP ProLiant | |
| 429 | + servers. Upon loading, the driver creates /dev/hpilo/dXccbN files, | |
| 430 | + which can be used to gather data from the management processor, | |
| 431 | + via read and write system calls. | |
| 432 | + | |
| 433 | + To compile this driver as a module, choose M here: the | |
| 434 | + module will be called hpilo. | |
| 435 | + | |
| 423 | 436 | endif # MISC_DEVICES |
| @@ -27,3 +27,4 @@ obj-$(CONFIG_INTEL_MENLOW) += intel_menlow.o · 26 unmodified lines | ||
| 27 | 27 | obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o |
| 28 | 28 | obj-$(CONFIG_KGDB_TESTS) += kgdbts.o |
| 29 | 29 | obj-$(CONFIG_SGI_XP) += sgi-xp/ |
| 30 | +obj-$(CONFIG_HP_ILO) += hpilo.o | |
| @@ -0,0 +1,768 @@ | ||
| 1 | +/* | |
| 2 | + * Driver for HP iLO/iLO2 management processor. | |
| 3 | + * | |
| 4 | + * Copyright (C) 2008 Hewlett-Packard Development Company, L.P. | |
| 5 | + * David Altobelli <david.altobelli@hp.com> | |
| 6 | + * | |
| 7 | + * This program is free software; you can redistribute it and/or modify | |
| 8 | + * it under the terms of the GNU General Public License version 2 as | |
| 9 | + * published by the Free Software Foundation. | |
| 10 | + */ | |
| 11 | +#include <linux/kernel.h> | |
| 12 | +#include <linux/types.h> | |
| 13 | +#include <linux/module.h> | |
| 14 | +#include <linux/fs.h> | |
| 15 | +#include <linux/pci.h> | |
| 16 | +#include <linux/ioport.h> | |
| 17 | +#include <linux/device.h> | |
| 18 | +#include <linux/file.h> | |
| 19 | +#include <linux/cdev.h> | |
| 20 | +#include <linux/spinlock.h> | |
| 21 | +#include <linux/delay.h> | |
| 22 | +#include <linux/uaccess.h> | |
| 23 | +#include <linux/io.h> | |
| 24 | +#include "hpilo.h" | |
| 25 | + | |
| 26 | +static struct class *ilo_class; | |
| 27 | +static unsigned int ilo_major; | |
| 28 | +static char ilo_hwdev[MAX_ILO_DEV]; | |
| 29 | + | |
| 30 | +static inline int get_entry_id(int entry) | |
| 31 | +{ | |
| 32 | + return (entry & ENTRY_MASK_DESCRIPTOR) >> ENTRY_BITPOS_DESCRIPTOR; | |
| 33 | +} | |
| 34 | + | |
| 35 | +static inline int get_entry_len(int entry) | |
| 36 | +{ | |
| 37 | + return ((entry & ENTRY_MASK_QWORDS) >> ENTRY_BITPOS_QWORDS) << 3; | |
| 38 | +} | |
| 39 | + | |
| 40 | +static inline int mk_entry(int id, int len) | |
| 41 | +{ | |
| 42 | + int qlen = len & 7 ? (len >> 3) + 1 : len >> 3; | |
| 43 | + return id << ENTRY_BITPOS_DESCRIPTOR | qlen << ENTRY_BITPOS_QWORDS; | |
| 44 | +} | |
| 45 | + | |
| 46 | +static inline int desc_mem_sz(int nr_entry) | |
| 47 | +{ | |
| 48 | + return nr_entry << L2_QENTRY_SZ; | |
| 49 | +} | |
| 50 | + | |
| 51 | +/* | |
| 52 | + * FIFO queues, shared with hardware. | |
| 53 | + * | |
| 54 | + * If a queue has empty slots, an entry is added to the queue tail, | |
| 55 | + * and that entry is marked as occupied. | |
| 56 | + * Entries can be dequeued from the head of the list, when the device | |
| 57 | + * has marked the entry as consumed. | |
| 58 | + * | |
| 59 | + * Returns true on successful queue/dequeue, false on failure. | |
| 60 | + */ | |
| 61 | +static int fifo_enqueue(struct ilo_hwinfo *hw, char *fifobar, int entry) | |
| 62 | +{ | |
| 63 | + struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar); | |
| 64 | + int ret = 0; | |
| 65 | + | |
| 66 | + spin_lock(&hw->fifo_lock); | |
| 67 | + if (!(fifo_q->fifobar[(fifo_q->tail + 1) & fifo_q->imask] | |
| 68 | + & ENTRY_MASK_O)) { | |
| 69 | + fifo_q->fifobar[fifo_q->tail & fifo_q->imask] |= | |
| 70 | + (entry & ENTRY_MASK_NOSTATE) | fifo_q->merge; | |
| 71 | + fifo_q->tail += 1; | |
| 72 | + ret = 1; | |
| 73 | + } | |
| 74 | + spin_unlock(&hw->fifo_lock); | |
| 75 | + | |
| 76 | + return ret; | |
| 77 | +} | |
| 78 | + | |
| 79 | +static int fifo_dequeue(struct ilo_hwinfo *hw, char *fifobar, int *entry) | |
| 80 | +{ | |
| 81 | + struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar); | |
| 82 | + int ret = 0; | |
| 83 | + u64 c; | |
| 84 | + | |
| 85 | + spin_lock(&hw->fifo_lock); | |
| 86 | + c = fifo_q->fifobar[fifo_q->head & fifo_q->imask]; | |
| 87 | + if (c & ENTRY_MASK_C) { | |
| 88 | + if (entry) | |
| 89 | + *entry = c & ENTRY_MASK_NOSTATE; | |
| 90 | + | |
| 91 | + fifo_q->fifobar[fifo_q->head & fifo_q->imask] = | |
| 92 | + (c | ENTRY_MASK) + 1; | |
| 93 | + fifo_q->head += 1; | |
| 94 | + ret = 1; | |
| 95 | + } | |
| 96 | + spin_unlock(&hw->fifo_lock); | |
| 97 | + | |
| 98 | + return ret; | |
| 99 | +} | |
| 100 | + | |
| 101 | +static int ilo_pkt_enqueue(struct ilo_hwinfo *hw, struct ccb *ccb, | |
| 102 | + int dir, int id, int len) | |
| 103 | +{ | |
| 104 | + char *fifobar; | |
| 105 | + int entry; | |
| 106 | + | |
| 107 | + if (dir == SENDQ) | |
| 108 | + fifobar = ccb->ccb_u1.send_fifobar; | |
| 109 | + else | |
| 110 | + fifobar = ccb->ccb_u3.recv_fifobar; | |
| 111 | + | |
| 112 | + entry = mk_entry(id, len); | |
| 113 | + return fifo_enqueue(hw, fifobar, entry); | |
| 114 | +} | |
| 115 | + | |
| 116 | +static int ilo_pkt_dequeue(struct ilo_hwinfo *hw, struct ccb *ccb, | |
| 117 | + int dir, int *id, int *len, void **pkt) | |
| 118 | +{ | |
| 119 | + char *fifobar, *desc; | |
| 120 | + int entry = 0, pkt_id = 0; | |
| 121 | + int ret; | |
| 122 | + | |
| 123 | + if (dir == SENDQ) { | |
| 124 | + fifobar = ccb->ccb_u1.send_fifobar; | |
| 125 | + desc = ccb->ccb_u2.send_desc; | |
| 126 | + } else { | |
| 127 | + fifobar = ccb->ccb_u3.recv_fifobar; | |
| 128 | + desc = ccb->ccb_u4.recv_desc; | |
| 129 | + } | |
| 130 | + | |
| 131 | + ret = fifo_dequeue(hw, fifobar, &entry); | |
| 132 | + if (ret) { | |
| 133 | + pkt_id = get_entry_id(entry); | |
| 134 | + if (id) | |
| 135 | + *id = pkt_id; | |
| 136 | + if (len) | |
| 137 | + *len = get_entry_len(entry); | |
| 138 | + if (pkt) | |
| 139 | + *pkt = (void *)(desc + desc_mem_sz(pkt_id)); | |
| 140 | + } | |
| 141 | + | |
| 142 | + return ret; | |
| 143 | +} | |
| 144 | + | |
| 145 | +static inline void doorbell_set(struct ccb *ccb) | |
| 146 | +{ | |
| 147 | + iowrite8(1, ccb->ccb_u5.db_base); | |
| 148 | +} | |
| 149 | + | |
| 150 | +static inline void doorbell_clr(struct ccb *ccb) | |
| 151 | +{ | |
| 152 | + iowrite8(2, ccb->ccb_u5.db_base); | |
| 153 | +} | |
| 154 | +static inline int ctrl_set(int l2sz, int idxmask, int desclim) | |
| 155 | +{ | |
| 156 | + int active = 0, go = 1; | |
| 157 | + return l2sz << CTRL_BITPOS_L2SZ | | |
| 158 | + idxmask << CTRL_BITPOS_FIFOINDEXMASK | | |
| 159 | + desclim << CTRL_BITPOS_DESCLIMIT | | |
| 160 | + active << CTRL_BITPOS_A | | |
| 161 | + go << CTRL_BITPOS_G; | |
| 162 | +} | |
| 163 | +static void ctrl_setup(struct ccb *ccb, int nr_desc, int l2desc_sz) | |
| 164 | +{ | |
| 165 | + /* for simplicity, use the same parameters for send and recv ctrls */ | |
| 166 | + ccb->send_ctrl = ctrl_set(l2desc_sz, nr_desc-1, nr_desc-1); | |
| 167 | + ccb->recv_ctrl = ctrl_set(l2desc_sz, nr_desc-1, nr_desc-1); | |
| 168 | +} | |
| 169 | + | |
| 170 | +static inline int fifo_sz(int nr_entry) | |
| 171 | +{ | |
| 172 | + /* size of a fifo is determined by the number of entries it contains */ | |
| 173 | + return (nr_entry * sizeof(u64)) + FIFOHANDLESIZE; | |
| 174 | +} | |
| 175 | + | |
| 176 | +static void fifo_setup(void *base_addr, int nr_entry) | |
| 177 | +{ | |
| 178 | + struct fifo *fifo_q = base_addr; | |
| 179 | + int i; | |
| 180 | + | |
| 181 | + /* set up an empty fifo */ | |
| 182 | + fifo_q->head = 0; | |
| 183 | + fifo_q->tail = 0; | |
| 184 | + fifo_q->reset = 0; | |
| 185 | + fifo_q->nrents = nr_entry; | |
| 186 | + fifo_q->imask = nr_entry - 1; | |
| 187 | + fifo_q->merge = ENTRY_MASK_O; | |
| 188 | + | |
| 189 | + for (i = 0; i < nr_entry; i++) | |
| 190 | + fifo_q->fifobar[i] = 0; | |
| 191 | +} | |
| 192 | + | |
| 193 | +static void ilo_ccb_close(struct pci_dev *pdev, struct ccb_data *data) | |
| 194 | +{ | |
| 195 | + struct ccb *driver_ccb; | |
| 196 | + struct ccb __iomem *device_ccb; | |
| 197 | + int retries; | |
| 198 | + | |
| 199 | + driver_ccb = &data->driver_ccb; | |
| 200 | + device_ccb = data->mapped_ccb; | |
| 201 | + | |
| 202 | + /* complicated dance to tell the hw we are stopping */ | |
| 203 | + doorbell_clr(driver_ccb); | |
| 204 | + iowrite32(ioread32(&device_ccb->send_ctrl) & ~(1 << CTRL_BITPOS_G), | |
| 205 | + &device_ccb->send_ctrl); | |
| 206 | + iowrite32(ioread32(&device_ccb->recv_ctrl) & ~(1 << CTRL_BITPOS_G), | |
| 207 | + &device_ccb->recv_ctrl); | |
| 208 | + | |
| 209 | + /* give iLO some time to process stop request */ | |
| 210 | + for (retries = 1000; retries > 0; retries--) { | |
| 211 | + doorbell_set(driver_ccb); | |
| 212 | + udelay(1); | |
| 213 | + if (!(ioread32(&device_ccb->send_ctrl) & (1 << CTRL_BITPOS_A)) | |
| 214 | + && | |
| 215 | + !(ioread32(&device_ccb->recv_ctrl) & (1 << CTRL_BITPOS_A))) | |
| 216 | + break; | |
| 217 | + } | |
| 218 | + if (retries == 0) | |
| 219 | + dev_err(&pdev->dev, "Closing, but controller still active\n"); | |
| 220 | + | |
| 221 | + /* clear the hw ccb */ | |
| 222 | + memset_io(device_ccb, 0, sizeof(struct ccb)); | |
| 223 | + | |
| 224 | + /* free resources used to back send/recv queues */ | |
| 225 | + pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa); | |
| 226 | +} | |
| 227 | + | |
| 228 | +static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot) | |
| 229 | +{ | |
| 230 | + char *dma_va, *dma_pa; | |
| 231 | + int pkt_id, pkt_sz, i, error; | |
| 232 | + struct ccb *driver_ccb, *ilo_ccb; | |
| 233 | + struct pci_dev *pdev; | |
| 234 | + | |
| 235 | + driver_ccb = &data->driver_ccb; | |
| 236 | + ilo_ccb = &data->ilo_ccb; | |
| 237 | + pdev = hw->ilo_dev; | |
| 238 | + | |
| 239 | + data->dma_size = 2 * fifo_sz(NR_QENTRY) + | |
| 240 | + 2 * desc_mem_sz(NR_QENTRY) + | |
| 241 | + ILO_START_ALIGN + ILO_CACHE_SZ; | |
| 242 | + | |
| 243 | + error = -ENOMEM; | |
| 244 | + data->dma_va = pci_alloc_consistent(pdev, data->dma_size, | |
| 245 | + &data->dma_pa); | |
| 246 | + if (!data->dma_va) | |
| 247 | + goto out; | |
| 248 | + | |
| 249 | + dma_va = (char *)data->dma_va; | |
| 250 | + dma_pa = (char *)data->dma_pa; | |
| 251 | + | |
| 252 | + memset(dma_va, 0, data->dma_size); | |
| 253 | + | |
| 254 | + dma_va = (char *)roundup((unsigned long)dma_va, ILO_START_ALIGN); | |
| 255 | + dma_pa = (char *)roundup((unsigned long)dma_pa, ILO_START_ALIGN); | |
| 256 | + | |
| 257 | + /* | |
| 258 | + * Create two ccb's, one with virt addrs, one with phys addrs. | |
| 259 | + * Copy the phys addr ccb to device shared mem. | |
| 260 | + */ | |
| 261 | + ctrl_setup(driver_ccb, NR_QENTRY, L2_QENTRY_SZ); | |
| 262 | + ctrl_setup(ilo_ccb, NR_QENTRY, L2_QENTRY_SZ); | |
| 263 | + | |
| 264 | + fifo_setup(dma_va, NR_QENTRY); | |
| 265 | + driver_ccb->ccb_u1.send_fifobar = dma_va + FIFOHANDLESIZE; | |
| 266 | + ilo_ccb->ccb_u1.send_fifobar = dma_pa + FIFOHANDLESIZE; | |
| 267 | + dma_va += fifo_sz(NR_QENTRY); | |
| 268 | + dma_pa += fifo_sz(NR_QENTRY); | |
| 269 | + | |
| 270 | + dma_va = (char *)roundup((unsigned long)dma_va, ILO_CACHE_SZ); | |
| 271 | + dma_pa = (char *)roundup((unsigned long)dma_pa, ILO_CACHE_SZ); | |
| 272 | + | |
| 273 | + fifo_setup(dma_va, NR_QENTRY); | |
| 274 | + driver_ccb->ccb_u3.recv_fifobar = dma_va + FIFOHANDLESIZE; | |
| 275 | + ilo_ccb->ccb_u3.recv_fifobar = dma_pa + FIFOHANDLESIZE; | |
| 276 | + dma_va += fifo_sz(NR_QENTRY); | |
| 277 | + dma_pa += fifo_sz(NR_QENTRY); | |
| 278 | + | |
| 279 | + driver_ccb->ccb_u2.send_desc = dma_va; | |
| 280 | + ilo_ccb->ccb_u2.send_desc = dma_pa; | |
| 281 | + dma_pa += desc_mem_sz(NR_QENTRY); | |
| 282 | + dma_va += desc_mem_sz(NR_QENTRY); | |
| 283 | + | |
| 284 | + driver_ccb->ccb_u4.recv_desc = dma_va; | |
| 285 | + ilo_ccb->ccb_u4.recv_desc = dma_pa; | |
| 286 | + | |
| 287 | + driver_ccb->channel = slot; | |
| 288 | + ilo_ccb->channel = slot; | |
| 289 | + | |
| 290 | + driver_ccb->ccb_u5.db_base = hw->db_vaddr + (slot << L2_DB_SIZE); | |
| 291 | + ilo_ccb->ccb_u5.db_base = NULL; /* hw ccb's doorbell is not used */ | |
| 292 | + | |
| 293 | + /* copy the ccb with physical addrs to device memory */ | |
| 294 | + data->mapped_ccb = (struct ccb __iomem *) | |
| 295 | + (hw->ram_vaddr + (slot * ILOHW_CCB_SZ)); | |
| 296 | + memcpy_toio(data->mapped_ccb, ilo_ccb, sizeof(struct ccb)); | |
| 297 | + | |
| 298 | + /* put packets on the send and receive queues */ | |
| 299 | + pkt_sz = 0; | |
| 300 | + for (pkt_id = 0; pkt_id < NR_QENTRY; pkt_id++) { | |
| 301 | + ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, pkt_sz); | |
| 302 | + doorbell_set(driver_ccb); | |
| 303 | + } | |
| 304 | + | |
| 305 | + pkt_sz = desc_mem_sz(1); | |
| 306 | + for (pkt_id = 0; pkt_id < NR_QENTRY; pkt_id++) | |
| 307 | + ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, pkt_sz); | |
| 308 | + | |
| 309 | + doorbell_clr(driver_ccb); | |
| 310 | + | |
| 311 | + /* make sure iLO is really handling requests */ | |
| 312 | + for (i = 1000; i > 0; i--) { | |
| 313 | + if (ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, NULL, NULL)) | |
| 314 | + break; | |
| 315 | + udelay(1); | |
| 316 | + } | |
| 317 | + | |
| 318 | + if (i) { | |
| 319 | + ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, 0); | |
| 320 | + doorbell_set(driver_ccb); | |
| 321 | + } else { | |
| 322 | + dev_err(&pdev->dev, "Open could not dequeue a packet\n"); | |
| 323 | + error = -EBUSY; | |
| 324 | + goto free; | |
| 325 | + } | |
| 326 | + | |
| 327 | + return 0; | |
| 328 | +free: | |
| 329 | + pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa); | |
| 330 | +out: | |
| 331 | + return error; | |
| 332 | +} | |
| 333 | + | |
| 334 | +static inline int is_channel_reset(struct ccb *ccb) | |
| 335 | +{ | |
| 336 | + /* check for this particular channel needing a reset */ | |
| 337 | + return FIFOBARTOHANDLE(ccb->ccb_u1.send_fifobar)->reset; | |
| 338 | +} | |
| 339 | + | |
| 340 | +static inline void set_channel_reset(struct ccb *ccb) | |
| 341 | +{ | |
| 342 | + /* set a flag indicating this channel needs a reset */ | |
| 343 | + FIFOBARTOHANDLE(ccb->ccb_u1.send_fifobar)->reset = 1; | |
| 344 | +} | |
| 345 | + | |
| 346 | +static inline int is_device_reset(struct ilo_hwinfo *hw) | |
| 347 | +{ | |
| 348 | + /* check for global reset condition */ | |
| 349 | + return ioread32(&hw->mmio_vaddr[DB_OUT]) & (1 << DB_RESET); | |
| 350 | +} | |
| 351 | + | |
| 352 | +static inline void clear_device(struct ilo_hwinfo *hw) | |
| 353 | +{ | |
| 354 | + /* clear the device (reset bits, pending channel entries) */ | |
| 355 | + iowrite32(-1, &hw->mmio_vaddr[DB_OUT]); | |
| 356 | +} | |
| 357 | + | |
| 358 | +static void ilo_locked_reset(struct ilo_hwinfo *hw) | |
| 359 | +{ | |
| 360 | + int slot; | |
| 361 | + | |
| 362 | + /* | |
| 363 | + * Mapped memory is zeroed on ilo reset, so set a per ccb flag | |
| 364 | + * to indicate that this ccb needs to be closed and reopened. | |
| 365 | + */ | |
| 366 | + for (slot = 0; slot < MAX_CCB; slot++) { | |
| 367 | + if (!hw->ccb_alloc[slot]) | |
| 368 | + continue; | |
| 369 | + set_channel_reset(&hw->ccb_alloc[slot]->driver_ccb); | |
| 370 | + } | |
| 371 | + | |
| 372 | + clear_device(hw); | |
| 373 | +} | |
| 374 | + | |
| 375 | +static void ilo_reset(struct ilo_hwinfo *hw) | |
| 376 | +{ | |
| 377 | + spin_lock(&hw->alloc_lock); | |
| 378 | + | |
| 379 | + /* reset might have been handled after lock was taken */ | |
| 380 | + if (is_device_reset(hw)) | |
| 381 | + ilo_locked_reset(hw); | |
| 382 | + | |
| 383 | + spin_unlock(&hw->alloc_lock); | |
| 384 | +} | |
| 385 | + | |
| 386 | +static ssize_t ilo_read(struct file *fp, char __user *buf, | |
| 387 | + size_t len, loff_t *off) | |
| 388 | +{ | |
| 389 | + int err, found, cnt, pkt_id, pkt_len; | |
| 390 | + struct ccb_data *data; | |
| 391 | + struct ccb *driver_ccb; | |
| 392 | + struct ilo_hwinfo *hw; | |
| 393 | + void *pkt; | |
| 394 | + | |
| 395 | + data = fp->private_data; | |
| 396 | + driver_ccb = &data->driver_ccb; | |
| 397 | + hw = data->ilo_hw; | |
| 398 | + | |
| 399 | + if (is_device_reset(hw) || is_channel_reset(driver_ccb)) { | |
| 400 | + /* | |
| 401 | + * If the device has been reset, applications | |
| 402 | + * need to close and reopen all ccbs. | |
| 403 | + */ | |
| 404 | + ilo_reset(hw); | |
| 405 | + return -ENODEV; | |
| 406 | + } | |
| 407 | + | |
| 408 | + /* | |
| 409 | + * This function is to be called when data is expected | |
| 410 | + * in the channel, and will return an error if no packet is found | |
| 411 | + * during the loop below. The sleep/retry logic is to allow | |
| 412 | + * applications to call read() immediately post write(), | |
| 413 | + * and give iLO some time to process the sent packet. | |
| 414 | + */ | |
| 415 | + cnt = 20; | |
| 416 | + do { | |
| 417 | + /* look for a received packet */ | |
| 418 | + found = ilo_pkt_dequeue(hw, driver_ccb, RECVQ, &pkt_id, | |
| 419 | + &pkt_len, &pkt); | |
| 420 | + if (found) | |
| 421 | + break; | |
| 422 | + cnt--; | |
| 423 | + msleep(100); | |
| 424 | + } while (!found && cnt); | |
| 425 | + | |
| 426 | + if (!found) | |
| 427 | + return -EAGAIN; | |
| 428 | + | |
| 429 | + /* only copy the length of the received packet */ | |
| 430 | + if (pkt_len < len) | |
| 431 | + len = pkt_len; | |
| 432 | + | |
| 433 | + err = copy_to_user(buf, pkt, len); | |
| 434 | + | |
| 435 | + /* return the received packet to the queue */ | |
| 436 | + ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, desc_mem_sz(1)); | |
| 437 | + | |
| 438 | + return err ? -EFAULT : len; | |
| 439 | +} | |
| 440 | + | |
| 441 | +static ssize_t ilo_write(struct file *fp, const char __user *buf, | |
| 442 | + size_t len, loff_t *off) | |
| 443 | +{ | |
| 444 | + int err, pkt_id, pkt_len; | |
| 445 | + struct ccb_data *data; | |
| 446 | + struct ccb *driver_ccb; | |
| 447 | + struct ilo_hwinfo *hw; | |
| 448 | + void *pkt; | |
| 449 | + | |
| 450 | + data = fp->private_data; | |
| 451 | + driver_ccb = &data->driver_ccb; | |
| 452 | + hw = data->ilo_hw; | |
| 453 | + | |
| 454 | + if (is_device_reset(hw) || is_channel_reset(driver_ccb)) { | |
| 455 | + /* | |
| 456 | + * If the device has been reset, applications | |
| 457 | + * need to close and reopen all ccbs. | |
| 458 | + */ | |
| 459 | + ilo_reset(hw); | |
| 460 | + return -ENODEV; | |
| 461 | + } | |
| 462 | + | |
| 463 | + /* get a packet to send the user command */ | |
| 464 | + if (!ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, &pkt_len, &pkt)) | |
| 465 | + return -EBUSY; | |
| 466 | + | |
| 467 | + /* limit the length to the length of the packet */ | |
| 468 | + if (pkt_len < len) | |
| 469 | + len = pkt_len; | |
| 470 | + | |
| 471 | + /* on failure, set the len to 0 to return empty packet to the device */ | |
| 472 | + err = copy_from_user(pkt, buf, len); | |
| 473 | + if (err) | |
| 474 | + len = 0; | |
| 475 | + | |
| 476 | + /* send the packet */ | |
| 477 | + ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, len); | |
| 478 | + doorbell_set(driver_ccb); | |
| 479 | + | |
| 480 | + return err ? -EFAULT : len; | |
| 481 | +} | |
| 482 | + | |
| 483 | +static int ilo_close(struct inode *ip, struct file *fp) | |
| 484 | +{ | |
| 485 | + int slot; | |
| 486 | + struct ccb_data *data; | |
| 487 | + struct ilo_hwinfo *hw; | |
| 488 | + | |
| 489 | + slot = iminor(ip) % MAX_CCB; | |
| 490 | + hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev); | |
| 491 | + | |
| 492 | + spin_lock(&hw->alloc_lock); | |
| 493 | + | |
| 494 | + if (is_device_reset(hw)) | |
| 495 | + ilo_locked_reset(hw); | |
| 496 | + | |
| 497 | + if (hw->ccb_alloc[slot]->ccb_cnt == 1) { | |
| 498 | + | |
| 499 | + data = fp->private_data; | |
| 500 | + | |
| 501 | + ilo_ccb_close(hw->ilo_dev, data); | |
| 502 | + | |
| 503 | + kfree(data); | |
| 504 | + hw->ccb_alloc[slot] = NULL; | |
| 505 | + } else | |
| 506 | + hw->ccb_alloc[slot]->ccb_cnt--; | |
| 507 | + | |
| 508 | + spin_unlock(&hw->alloc_lock); | |
| 509 | + | |
| 510 | + return 0; | |
| 511 | +} | |
| 512 | + | |
| 513 | +static int ilo_open(struct inode *ip, struct file *fp) | |
| 514 | +{ | |
| 515 | + int slot, error; | |
| 516 | + struct ccb_data *data; | |
| 517 | + struct ilo_hwinfo *hw; | |
| 518 | + | |
| 519 | + slot = iminor(ip) % MAX_CCB; | |
| 520 | + hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev); | |
| 521 | + | |
| 522 | + /* new ccb allocation */ | |
| 523 | + data = kzalloc(sizeof(*data), GFP_KERNEL); | |
| 524 | + if (!data) | |
| 525 | + return -ENOMEM; | |
| 526 | + | |
| 527 | + spin_lock(&hw->alloc_lock); | |
| 528 | + | |
| 529 | + if (is_device_reset(hw)) | |
| 530 | + ilo_locked_reset(hw); | |
| 531 | + | |
| 532 | + /* each fd private_data holds sw/hw view of ccb */ | |
| 533 | + if (hw->ccb_alloc[slot] == NULL) { | |
| 534 | + /* create a channel control block for this minor */ | |
| 535 | + error = ilo_ccb_open(hw, data, slot); | |
| 536 | + if (!error) { | |
| 537 | + hw->ccb_alloc[slot] = data; | |
| 538 | + hw->ccb_alloc[slot]->ccb_cnt = 1; | |
| 539 | + hw->ccb_alloc[slot]->ccb_excl = fp->f_flags & O_EXCL; | |
| 540 | + hw->ccb_alloc[slot]->ilo_hw = hw; | |
| 541 | + } else | |
| 542 | + kfree(data); | |
| 543 | + } else { | |
| 544 | + kfree(data); | |
| 545 | + if (fp->f_flags & O_EXCL || hw->ccb_alloc[slot]->ccb_excl) { | |
| 546 | + /* | |
| 547 | + * The channel exists, and either this open | |
| 548 | + * or a previous open of this channel wants | |
| 549 | + * exclusive access. | |
| 550 | + */ | |
| 551 | + error = -EBUSY; | |
| 552 | + } else { | |
| 553 | + hw->ccb_alloc[slot]->ccb_cnt++; | |
| 554 | + error = 0; | |
| 555 | + } | |
| 556 | + } | |
| 557 | + spin_unlock(&hw->alloc_lock); | |
| 558 | + | |
| 559 | + if (!error) | |
| 560 | + fp->private_data = hw->ccb_alloc[slot]; | |
| 561 | + | |
| 562 | + return error; | |
| 563 | +} | |
| 564 | + | |
| 565 | +static const struct file_operations ilo_fops = { | |
| 566 | + .owner = THIS_MODULE, | |
| 567 | + .read = ilo_read, | |
| 568 | + .write = ilo_write, | |
| 569 | + .open = ilo_open, | |
| 570 | + .release = ilo_close, | |
| 571 | +}; | |
| 572 | + | |
| 573 | +static void ilo_unmap_device(struct pci_dev *pdev, struct ilo_hwinfo *hw) | |
| 574 | +{ | |
| 575 | + pci_iounmap(pdev, hw->db_vaddr); | |
| 576 | + pci_iounmap(pdev, hw->ram_vaddr); | |
| 577 | + pci_iounmap(pdev, hw->mmio_vaddr); | |
| 578 | +} | |
| 579 | + | |
| 580 | +static int __devinit ilo_map_device(struct pci_dev *pdev, struct ilo_hwinfo *hw) | |
| 581 | +{ | |
| 582 | + int error = -ENOMEM; | |
| 583 | + | |
| 584 | + /* map the memory mapped i/o registers */ | |
| 585 | + hw->mmio_vaddr = pci_iomap(pdev, 1, 0); | |
| 586 | + if (hw->mmio_vaddr == NULL) { | |
| 587 | + dev_err(&pdev->dev, "Error mapping mmio\n"); | |
| 588 | + goto out; | |
| 589 | + } | |
| 590 | + | |
| 591 | + /* map the adapter shared memory region */ | |
| 592 | + hw->ram_vaddr = pci_iomap(pdev, 2, MAX_CCB * ILOHW_CCB_SZ); | |
| 593 | + if (hw->ram_vaddr == NULL) { | |
| 594 | + dev_err(&pdev->dev, "Error mapping shared mem\n"); | |
| 595 | + goto mmio_free; | |
| 596 | + } | |
| 597 | + | |
| 598 | + /* map the doorbell aperture */ | |
| 599 | + hw->db_vaddr = pci_iomap(pdev, 3, MAX_CCB * ONE_DB_SIZE); | |
| 600 | + if (hw->db_vaddr == NULL) { | |
| 601 | + dev_err(&pdev->dev, "Error mapping doorbell\n"); | |
| 602 | + goto ram_free; | |
| 603 | + } | |
| 604 | + | |
| 605 | + return 0; | |
| 606 | +ram_free: | |
| 607 | + pci_iounmap(pdev, hw->ram_vaddr); | |
| 608 | +mmio_free: | |
| 609 | + pci_iounmap(pdev, hw->mmio_vaddr); | |
| 610 | +out: | |
| 611 | + return error; | |
| 612 | +} | |
| 613 | + | |
| 614 | +static void ilo_remove(struct pci_dev *pdev) | |
| 615 | +{ | |
| 616 | + int i, minor; | |
| 617 | + struct ilo_hwinfo *ilo_hw = pci_get_drvdata(pdev); | |
| 618 | + | |
| 619 | + clear_device(ilo_hw); | |
| 620 | + | |
| 621 | + minor = MINOR(ilo_hw->cdev.dev); | |
| 622 | + for (i = minor; i < minor + MAX_CCB; i++) | |
| 623 | + device_destroy(ilo_class, MKDEV(ilo_major, i)); | |
| 624 | + | |
| 625 | + cdev_del(&ilo_hw->cdev); | |
| 626 | + ilo_unmap_device(pdev, ilo_hw); | |
| 627 | + pci_release_regions(pdev); | |
| 628 | + pci_disable_device(pdev); | |
| 629 | + kfree(ilo_hw); | |
| 630 | + ilo_hwdev[(minor / MAX_CCB)] = 0; | |
| 631 | +} | |
| 632 | + | |
| 633 | +static int __devinit ilo_probe(struct pci_dev *pdev, | |
| 634 | + const struct pci_device_id *ent) | |
| 635 | +{ | |
| 636 | + int devnum, minor, start, error; | |
| 637 | + struct ilo_hwinfo *ilo_hw; | |
| 638 | + | |
| 639 | + /* find a free range for device files */ | |
| 640 | + for (devnum = 0; devnum < MAX_ILO_DEV; devnum++) { | |
| 641 | + if (ilo_hwdev[devnum] == 0) { | |
| 642 | + ilo_hwdev[devnum] = 1; | |
| 643 | + break; | |
| 644 | + } | |
| 645 | + } | |
| 646 | + | |
| 647 | + if (devnum == MAX_ILO_DEV) { | |
| 648 | + dev_err(&pdev->dev, "Error finding free device\n"); | |
| 649 | + return -ENODEV; | |
| 650 | + } | |
| 651 | + | |
| 652 | + /* track global allocations for this device */ | |
| 653 | + error = -ENOMEM; | |
| 654 | + ilo_hw = kzalloc(sizeof(*ilo_hw), GFP_KERNEL); | |
| 655 | + if (!ilo_hw) | |
| 656 | + goto out; | |
| 657 | + | |
| 658 | + ilo_hw->ilo_dev = pdev; | |
| 659 | + spin_lock_init(&ilo_hw->alloc_lock); | |
| 660 | + spin_lock_init(&ilo_hw->fifo_lock); | |
| 661 | + | |
| 662 | + error = pci_enable_device(pdev); | |
| 663 | + if (error) | |
| 664 | + goto free; | |
| 665 | + | |
| 666 | + pci_set_master(pdev); | |
| 667 | + | |
| 668 | + error = pci_request_regions(pdev, ILO_NAME); | |
| 669 | + if (error) | |
| 670 | + goto disable; | |
| 671 | + | |
| 672 | + error = ilo_map_device(pdev, ilo_hw); | |
| 673 | + if (error) | |
| 674 | + goto free_regions; | |
| 675 | + | |
| 676 | + pci_set_drvdata(pdev, ilo_hw); | |
| 677 | + clear_device(ilo_hw); | |
| 678 | + | |
| 679 | + cdev_init(&ilo_hw->cdev, &ilo_fops); | |
| 680 | + ilo_hw->cdev.owner = THIS_MODULE; | |
| 681 | + start = devnum * MAX_CCB; | |
| 682 | + error = cdev_add(&ilo_hw->cdev, MKDEV(ilo_major, start), MAX_CCB); | |
| 683 | + if (error) { | |
| 684 | + dev_err(&pdev->dev, "Could not add cdev\n"); | |
| 685 | + goto unmap; | |
| 686 | + } | |
| 687 | + | |
| 688 | + for (minor = 0 ; minor < MAX_CCB; minor++) { | |
| 689 | + struct device *dev; | |
| 690 | + dev = device_create(ilo_class, &pdev->dev, | |
| 691 | + MKDEV(ilo_major, minor), NULL, | |
| 692 | + "hpilo!d%dccb%d", devnum, minor); | |
| 693 | + if (IS_ERR(dev)) | |
| 694 | + dev_err(&pdev->dev, "Could not create files\n"); | |
| 695 | + } | |
| 696 | + | |
| 697 | + return 0; | |
| 698 | +unmap: | |
| 699 | + ilo_unmap_device(pdev, ilo_hw); | |
| 700 | +free_regions: | |
| 701 | + pci_release_regions(pdev); | |
| 702 | +disable: | |
| 703 | + pci_disable_device(pdev); | |
| 704 | +free: | |
| 705 | + kfree(ilo_hw); | |
| 706 | +out: | |
| 707 | + ilo_hwdev[devnum] = 0; | |
| 708 | + return error; | |
| 709 | +} | |
| 710 | + | |
| 711 | +static struct pci_device_id ilo_devices[] = { | |
| 712 | + { PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB204) }, | |
| 713 | + { } | |
| 714 | +}; | |
| 715 | +MODULE_DEVICE_TABLE(pci, ilo_devices); | |
| 716 | + | |
| 717 | +static struct pci_driver ilo_driver = { | |
| 718 | + .name = ILO_NAME, | |
| 719 | + .id_table = ilo_devices, | |
| 720 | + .probe = ilo_probe, | |
| 721 | + .remove = __devexit_p(ilo_remove), | |
| 722 | +}; | |
| 723 | + | |
| 724 | +static int __init ilo_init(void) | |
| 725 | +{ | |
| 726 | + int error; | |
| 727 | + dev_t dev; | |
| 728 | + | |
| 729 | + ilo_class = class_create(THIS_MODULE, "iLO"); | |
| 730 | + if (IS_ERR(ilo_class)) { | |
| 731 | + error = PTR_ERR(ilo_class); | |
| 732 | + goto out; | |
| 733 | + } | |
| 734 | + | |
| 735 | + error = alloc_chrdev_region(&dev, 0, MAX_OPEN, ILO_NAME); | |
| 736 | + if (error) | |
| 737 | + goto class_destroy; | |
| 738 | + | |
| 739 | + ilo_major = MAJOR(dev); | |
| 740 | + | |
| 741 | + error = pci_register_driver(&ilo_driver); | |
| 742 | + if (error) | |
| 743 | + goto chr_remove; | |
| 744 | + | |
| 745 | + return 0; | |
| 746 | +chr_remove: | |
| 747 | + unregister_chrdev_region(dev, MAX_OPEN); | |
| 748 | +class_destroy: | |
| 749 | + class_destroy(ilo_class); | |
| 750 | +out: | |
| 751 | + return error; | |
| 752 | +} | |
| 753 | + | |
| 754 | +static void __exit ilo_exit(void) | |
| 755 | +{ | |
| 756 | + pci_unregister_driver(&ilo_driver); | |
| 757 | + unregister_chrdev_region(MKDEV(ilo_major, 0), MAX_OPEN); | |
| 758 | + class_destroy(ilo_class); | |
| 759 | +} | |
| 760 | + | |
| 761 | +MODULE_VERSION("0.05"); | |
| 762 | +MODULE_ALIAS(ILO_NAME); | |
| 763 | +MODULE_DESCRIPTION(ILO_NAME); | |
| 764 | +MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>"); | |
| 765 | +MODULE_LICENSE("GPL v2"); | |
| 766 | + | |
| 767 | +module_init(ilo_init); | |
| 768 | +module_exit(ilo_exit); | |
| @@ -0,0 +1,189 @@ | ||
| 1 | +/* | |
| 2 | + * linux/drivers/char/hpilo.h | |
| 3 | + * | |
| 4 | + * Copyright (C) 2008 Hewlett-Packard Development Company, L.P. | |
| 5 | + * David Altobelli <david.altobelli@hp.com> | |
| 6 | + * | |
| 7 | + * This program is free software; you can redistribute it and/or modify | |
| 8 | + * it under the terms of the GNU General Public License version 2 as | |
| 9 | + * published by the Free Software Foundation. | |
| 10 | + */ | |
| 11 | +#ifndef __HPILO_H | |
| 12 | +#define __HPILO_H | |
| 13 | + | |
| 14 | +#define ILO_NAME "hpilo" | |
| 15 | + | |
| 16 | +/* max number of open channel control blocks per device, hw limited to 32 */ | |
| 17 | +#define MAX_CCB 8 | |
| 18 | +/* max number of supported devices */ | |
| 19 | +#define MAX_ILO_DEV 1 | |
| 20 | +/* max number of files */ | |
| 21 | +#define MAX_OPEN (MAX_CCB * MAX_ILO_DEV) | |
| 22 | + | |
| 23 | +/* | |
| 24 | + * Per device, used to track global memory allocations. | |
| 25 | + */ | |
| 26 | +struct ilo_hwinfo { | |
| 27 | + /* mmio registers on device */ | |
| 28 | + char __iomem *mmio_vaddr; | |
| 29 | + | |
| 30 | + /* doorbell registers on device */ | |
| 31 | + char __iomem *db_vaddr; | |
| 32 | + | |
| 33 | + /* shared memory on device used for channel control blocks */ | |
| 34 | + char __iomem *ram_vaddr; | |
| 35 | + | |
| 36 | + /* files corresponding to this device */ | |
| 37 | + struct ccb_data *ccb_alloc[MAX_CCB]; | |
| 38 | + | |
| 39 | + struct pci_dev *ilo_dev; | |
| 40 | + | |
| 41 | + spinlock_t alloc_lock; | |
| 42 | + spinlock_t fifo_lock; | |
| 43 | + | |
| 44 | + struct cdev cdev; | |
| 45 | +}; | |
| 46 | + | |
| 47 | +/* offset from mmio_vaddr */ | |
| 48 | +#define DB_OUT 0xD4 | |
| 49 | +/* DB_OUT reset bit */ | |
| 50 | +#define DB_RESET 26 | |
| 51 | + | |
| 52 | +/* | |
| 53 | + * Channel control block. Used to manage hardware queues. | |
| 54 | + * The format must match hw's version. The hw ccb is 128 bytes, | |
| 55 | + * but the context area shouldn't be touched by the driver. | |
| 56 | + */ | |
| 57 | +#define ILOSW_CCB_SZ 64 | |
| 58 | +#define ILOHW_CCB_SZ 128 | |
| 59 | +struct ccb { | |
| 60 | + union { | |
| 61 | + char *send_fifobar; | |
| 62 | + u64 padding1; | |
| 63 | + } ccb_u1; | |
| 64 | + union { | |
| 65 | + char *send_desc; | |
| 66 | + u64 padding2; | |
| 67 | + } ccb_u2; | |
| 68 | + u64 send_ctrl; | |
| 69 | + | |
| 70 | + union { | |
| 71 | + char *recv_fifobar; | |
| 72 | + u64 padding3; | |
| 73 | + } ccb_u3; | |
| 74 | + union { | |
| 75 | + char *recv_desc; | |
| 76 | + u64 padding4; | |
| 77 | + } ccb_u4; | |
| 78 | + u64 recv_ctrl; | |
| 79 | + | |
| 80 | + union { | |
| 81 | + char __iomem *db_base; | |
| 82 | + u64 padding5; | |
| 83 | + } ccb_u5; | |
| 84 | + | |
| 85 | + u64 channel; | |
| 86 | + | |
| 87 | + /* unused context area (64 bytes) */ | |
| 88 | +}; | |
| 89 | + | |
| 90 | +/* ccb queue parameters */ | |
| 91 | +#define SENDQ 1 | |
| 92 | +#define RECVQ 2 | |
| 93 | +#define NR_QENTRY 4 | |
| 94 | +#define L2_QENTRY_SZ 12 | |
| 95 | + | |
| 96 | +/* ccb ctrl bitfields */ | |
| 97 | +#define CTRL_BITPOS_L2SZ 0 | |
| 98 | +#define CTRL_BITPOS_FIFOINDEXMASK 4 | |
| 99 | +#define CTRL_BITPOS_DESCLIMIT 18 | |
| 100 | +#define CTRL_BITPOS_A 30 | |
| 101 | +#define CTRL_BITPOS_G 31 | |
| 102 | + | |
| 103 | +/* ccb doorbell macros */ | |
| 104 | +#define L2_DB_SIZE 14 | |
| 105 | +#define ONE_DB_SIZE (1 << L2_DB_SIZE) | |
| 106 | + | |
| 107 | +/* | |
| 108 | + * Per fd structure used to track the ccb allocated to that dev file. | |
| 109 | + */ | |
| 110 | +struct ccb_data { | |
| 111 | + /* software version of ccb, using virtual addrs */ | |
| 112 | + struct ccb driver_ccb; | |
| 113 | + | |
| 114 | + /* hardware version of ccb, using physical addrs */ | |
| 115 | + struct ccb ilo_ccb; | |
| 116 | + | |
| 117 | + /* hardware ccb is written to this shared mapped device memory */ | |
| 118 | + struct ccb __iomem *mapped_ccb; | |
| 119 | + | |
| 120 | + /* dma'able memory used for send/recv queues */ | |
| 121 | + void *dma_va; | |
| 122 | + dma_addr_t dma_pa; | |
| 123 | + size_t dma_size; | |
| 124 | + | |
| 125 | + /* pointer to hardware device info */ | |
| 126 | + struct ilo_hwinfo *ilo_hw; | |
| 127 | + | |
| 128 | + /* usage count, to allow for shared ccb's */ | |
| 129 | + int ccb_cnt; | |
| 130 | + | |
| 131 | + /* open wanted exclusive access to this ccb */ | |
| 132 | + int ccb_excl; | |
| 133 | +}; | |
| 134 | + | |
| 135 | +/* | |
| 136 | + * FIFO queue structure, shared with hw. | |
| 137 | + */ | |
| 138 | +#define ILO_START_ALIGN 4096 | |
| 139 | +#define ILO_CACHE_SZ 128 | |
| 140 | +struct fifo { | |
| 141 | + u64 nrents; /* user requested number of fifo entries */ | |
| 142 | + u64 imask; /* mask to extract valid fifo index */ | |
| 143 | + u64 merge; /* O/C bits to merge in during enqueue operation */ | |
| 144 | + u64 reset; /* set to non-zero when the target device resets */ | |
| 145 | + u8 pad_0[ILO_CACHE_SZ - (sizeof(u64) * 4)]; | |
| 146 | + | |
| 147 | + u64 head; | |
| 148 | + u8 pad_1[ILO_CACHE_SZ - (sizeof(u64))]; | |
| 149 | + | |
| 150 | + u64 tail; | |
| 151 | + u8 pad_2[ILO_CACHE_SZ - (sizeof(u64))]; | |
| 152 | + | |
| 153 | + u64 fifobar[1]; | |
| 154 | +}; | |
| 155 | + | |
| 156 | +/* convert between struct fifo, and the fifobar, which is saved in the ccb */ | |
| 157 | +#define FIFOHANDLESIZE (sizeof(struct fifo) - sizeof(u64)) | |
| 158 | +#define FIFOBARTOHANDLE(_fifo) \ | |
| 159 | + ((struct fifo *)(((char *)(_fifo)) - FIFOHANDLESIZE)) | |
| 160 | + | |
| 161 | +/* the number of qwords to consume from the entry descriptor */ | |
| 162 | +#define ENTRY_BITPOS_QWORDS 0 | |
| 163 | +/* descriptor index number (within a specified queue) */ | |
| 164 | +#define ENTRY_BITPOS_DESCRIPTOR 10 | |
| 165 | +/* state bit, fifo entry consumed by consumer */ | |
| 166 | +#define ENTRY_BITPOS_C 22 | |
| 167 | +/* state bit, fifo entry is occupied */ | |
| 168 | +#define ENTRY_BITPOS_O 23 | |
| 169 | + | |
| 170 | +#define ENTRY_BITS_QWORDS 10 | |
| 171 | +#define ENTRY_BITS_DESCRIPTOR 12 | |
| 172 | +#define ENTRY_BITS_C 1 | |
| 173 | +#define ENTRY_BITS_O 1 | |
| 174 | +#define ENTRY_BITS_TOTAL \ | |
| 175 | + (ENTRY_BITS_C + ENTRY_BITS_O + \ | |
| 176 | + ENTRY_BITS_QWORDS + ENTRY_BITS_DESCRIPTOR) | |
| 177 | + | |
| 178 | +/* extract various entry fields */ | |
| 179 | +#define ENTRY_MASK ((1 << ENTRY_BITS_TOTAL) - 1) | |
| 180 | +#define ENTRY_MASK_C (((1 << ENTRY_BITS_C) - 1) << ENTRY_BITPOS_C) | |
| 181 | +#define ENTRY_MASK_O (((1 << ENTRY_BITS_O) - 1) << ENTRY_BITPOS_O) | |
| 182 | +#define ENTRY_MASK_QWORDS \ | |
| 183 | + (((1 << ENTRY_BITS_QWORDS) - 1) << ENTRY_BITPOS_QWORDS) | |
| 184 | +#define ENTRY_MASK_DESCRIPTOR \ | |
| 185 | + (((1 << ENTRY_BITS_DESCRIPTOR) - 1) << ENTRY_BITPOS_DESCRIPTOR) | |
| 186 | + | |
| 187 | +#define ENTRY_MASK_NOSTATE (ENTRY_MASK >> (ENTRY_BITS_C + ENTRY_BITS_O)) | |
| 188 | + | |
| 189 | +#endif /* __HPILO_H */ | |
| @@ -399,8 +399,9 @@ static int __devinit phantom_probe(struct pci_dev *pdev, · 398 unmodified lines | ||
| 399 | 399 | goto err_irq; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | − if (IS_ERR(device_create(phantom_class, &pdev->dev, MKDEV(phantom_major, | |
| 403 | − minor), "phantom%u", minor))) | |
| 402 | + if (IS_ERR(device_create_drvdata(phantom_class, &pdev->dev, | |
| 403 | + MKDEV(phantom_major, minor), | |
| 404 | + NULL, "phantom%u", minor))) | |
| 404 | 405 | dev_err(&pdev->dev, "can't create device\n"); |
| 405 | 406 | |
| 406 | 407 | pci_set_drvdata(pdev, pht); |
| @@ -241,6 +241,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) · 240 unmodified lines | ||
| 241 | 241 | { |
| 242 | 242 | struct block_device *bdev; |
| 243 | 243 | struct block2mtd_dev *dev; |
| 244 | + char *name; | |
| 244 | 245 | |
| 245 | 246 | if (!devname) |
| 246 | 247 | return NULL; |
| @@ -279,12 +280,13 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) · 32 unmodified lines | ||
| 279 | 280 | |
| 280 | 281 | /* Setup the MTD structure */ |
| 281 | 282 | /* make the name contain the block device in */ |
| 282 | − dev->mtd.name = kmalloc(sizeof("block2mtd: ") + strlen(devname), | |
| 283 | + name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1, | |
| 283 | 284 | GFP_KERNEL); |
| 284 | − if (!dev->mtd.name) | |
| 285 | + if (!name) | |
| 285 | 286 | goto devinit_err; |
| 286 | 287 | |
| 287 | − sprintf(dev->mtd.name, "block2mtd: %s", devname); | |
| 288 | + sprintf(name, "block2mtd: %s", devname); | |
| 289 | + dev->mtd.name = name; | |
| 288 | 290 | |
| 289 | 291 | dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; |
| 290 | 292 | dev->mtd.erasesize = erase_size; |
| @@ -28,10 +28,13 @@ static void mtd_notify_add(struct mtd_info* mtd) · 27 unmodified lines | ||
| 28 | 28 | if (!mtd) |
| 29 | 29 | return; |
| 30 | 30 | |
| 31 | − device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), "mtd%d", mtd->index); | |
| 31 | + device_create_drvdata(mtd_class, NULL, | |
| 32 | + MKDEV(MTD_CHAR_MAJOR, mtd->index*2), | |
| 33 | + NULL, "mtd%d", mtd->index); | |
| 32 | 34 | |
| 33 | − device_create(mtd_class, NULL, | |
| 34 | − MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), "mtd%dro", mtd->index); | |
| 35 | + device_create_drvdata(mtd_class, NULL, | |
| 36 | + MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), | |
| 37 | + NULL, "mtd%dro", mtd->index); | |
| 35 | 38 | } |
| 36 | 39 | |
| 37 | 40 | static void mtd_notify_remove(struct mtd_info* mtd) |
| @@ -1010,7 +1010,7 @@ static int __devinit vortex_probe1(struct device *gendev, · 1009 unmodified lines | ||
| 1010 | 1010 | static int printed_version; |
| 1011 | 1011 | int retval, print_info; |
| 1012 | 1012 | struct vortex_chip_info * const vci = &vortex_info_tbl[chip_idx]; |
| 1013 | − char *print_name = "3c59x"; | |
| 1013 | + const char *print_name = "3c59x"; | |
| 1014 | 1014 | struct pci_dev *pdev = NULL; |
| 1015 | 1015 | struct eisa_device *edev = NULL; |
| 1016 | 1016 | DECLARE_MAC_BUF(mac); |
| @@ -677,7 +677,7 @@ static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo · 676 unmodified lines | ||
| 677 | 677 | { |
| 678 | 678 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
| 679 | 679 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
| 680 | − strlcpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info)); | |
| 680 | + strlcpy(info->bus_info, dev_name(dev->dev.parent), sizeof(info->bus_info)); | |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | static const struct ethtool_ops at91ether_ethtool_ops = { |
| @@ -848,7 +848,7 @@ static int ep93xx_eth_probe(struct platform_device *pdev) · 847 unmodified lines | ||
| 848 | 848 | |
| 849 | 849 | ep->res = request_mem_region(pdev->resource[0].start, |
| 850 | 850 | pdev->resource[0].end - pdev->resource[0].start + 1, |
| 851 | − pdev->dev.bus_id); | |
| 851 | + dev_name(&pdev->dev)); | |
| 852 | 852 | if (ep->res == NULL) { |
| 853 | 853 | dev_err(&pdev->dev, "Could not reserve memory region\n"); |
| 854 | 854 | err = -ENOMEM; |
| @@ -535,7 +535,7 @@ static int __init etherh_addr(char *addr, struct expansion_card *ec) · 534 unmodified lines | ||
| 535 | 535 | |
| 536 | 536 | if (!ecard_readchunk(&cd, ec, 0xf5, 0)) { |
| 537 | 537 | printk(KERN_ERR "%s: unable to read podule description string\n", |
| 538 | − ec->dev.bus_id); | |
| 538 | + dev_name(&ec->dev)); | |
| 539 | 539 | goto no_addr; |
| 540 | 540 | } |
| 541 | 541 | |
| @@ -554,7 +554,7 @@ static int __init etherh_addr(char *addr, struct expansion_card *ec) · 12 unmodified lines | ||
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | printk(KERN_ERR "%s: unable to parse MAC address: %s\n", |
| 557 | − ec->dev.bus_id, cd.d.string); | |
| 557 | + dev_name(&ec->dev), cd.d.string); | |
| 558 | 558 | |
| 559 | 559 | no_addr: |
| 560 | 560 | return -ENODEV; |
| @@ -585,7 +585,7 @@ static void etherh_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i · 24 unmodified lines | ||
| 585 | 585 | { |
| 586 | 586 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
| 587 | 587 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
| 588 | − strlcpy(info->bus_info, dev->dev.parent->bus_id, | |
| 588 | + strlcpy(info->bus_info, dev_name(dev->dev.parent), | |
| 589 | 589 | sizeof(info->bus_info)); |
| 590 | 590 | } |
| 591 | 591 | |
| @@ -866,7 +866,8 @@ static int __init ppp_init(void) · 865 unmodified lines | ||
| 866 | 866 | err = PTR_ERR(ppp_class); |
| 867 | 867 | goto out_chrdev; |
| 868 | 868 | } |
| 869 | − device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), "ppp"); | |
| 869 | + device_create_drvdata(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), | |
| 870 | + NULL, "ppp"); | |
| 870 | 871 | } |
| 871 | 872 | |
| 872 | 873 | out: |
| @@ -397,9 +397,9 @@ static int __init cosa_init(void) · 396 unmodified lines | ||
| 397 | 397 | err = PTR_ERR(cosa_class); |
| 398 | 398 | goto out_chrdev; |
| 399 | 399 | } |
| 400 | − for (i=0; i<nr_cards; i++) { | |
| 401 | − device_create(cosa_class, NULL, MKDEV(cosa_major, i), "cosa%d", i); | |
| 402 | − } | |
| 400 | + for (i = 0; i < nr_cards; i++) | |
| 401 | + device_create_drvdata(cosa_class, NULL, MKDEV(cosa_major, i), | |
| 402 | + NULL, "cosa%d", i); | |
| 403 | 403 | err = 0; |
| 404 | 404 | goto out; |
| 405 | 405 | |
| @@ -36,7 +36,7 @@ · 35 unmodified lines | ||
| 36 | 36 | #define _ACPIPHP_H |
| 37 | 37 | |
| 38 | 38 | #include <linux/acpi.h> |
| 39 | −#include <linux/kobject.h> /* for KOBJ_NAME_LEN */ | |
| 39 | +#include <linux/kobject.h> | |
| 40 | 40 | #include <linux/mutex.h> |
| 41 | 41 | #include <linux/pci_hotplug.h> |
| 42 | 42 | |
| @@ -51,7 +51,7 @@ · 8 unmodified lines | ||
| 51 | 51 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) |
| 52 | 52 | |
| 53 | 53 | /* name size which is used for entries in pcihpfs */ |
| 54 | −#define SLOT_NAME_SIZE KOBJ_NAME_LEN /* {_SUN} */ | |
| 54 | +#define SLOT_NAME_SIZE 20 /* {_SUN} */ | |
| 55 | 55 | |
| 56 | 56 | struct acpiphp_bridge; |
| 57 | 57 | struct acpiphp_slot; |
| @@ -78,7 +78,7 @@ static void find_main_battery(void) · 77 unmodified lines | ||
| 78 | 78 | main_battery = NULL; |
| 79 | 79 | bp.main = main_battery; |
| 80 | 80 | |
| 81 | − error = class_for_each_device(power_supply_class, &bp, | |
| 81 | + error = class_for_each_device(power_supply_class, NULL, &bp, | |
| 82 | 82 | __find_main_battery); |
| 83 | 83 | if (error) { |
| 84 | 84 | main_battery = bp.main; |
| @@ -41,7 +41,7 @@ static void power_supply_changed_work(struct work_struct *work) · 40 unmodified lines | ||
| 41 | 41 | |
| 42 | 42 | dev_dbg(psy->dev, "%s\n", __func__); |
| 43 | 43 | |
| 44 | − class_for_each_device(power_supply_class, psy, | |
| 44 | + class_for_each_device(power_supply_class, NULL, psy, | |
| 45 | 45 | __power_supply_changed_work); |
| 46 | 46 | |
| 47 | 47 | power_supply_update_leds(psy); |
| @@ -79,7 +79,7 @@ int power_supply_am_i_supplied(struct power_supply *psy) · 31 unmodified lines | ||
| 79 | 79 | { |
| 80 | 80 | int error; |
| 81 | 81 | |
| 82 | − error = class_for_each_device(power_supply_class, psy, | |
| 82 | + error = class_for_each_device(power_supply_class, NULL, psy, | |
| 83 | 83 | __power_supply_am_i_supplied); |
| 84 | 84 | |
| 85 | 85 | dev_dbg(psy->dev, "%s %d\n", __func__, error); |
| @@ -345,7 +345,7 @@ struct rtc_device *rtc_class_open(char *name) · 344 unmodified lines | ||
| 345 | 345 | struct device *dev; |
| 346 | 346 | struct rtc_device *rtc = NULL; |
| 347 | 347 | |
| 348 | − dev = class_find_device(rtc_class, name, __rtc_match); | |
| 348 | + dev = class_find_device(rtc_class, NULL, name, __rtc_match); | |
| 349 | 349 | if (dev) |
| 350 | 350 | rtc = to_rtc_device(dev); |
| 351 | 351 | |
| @@ -1168,17 +1168,19 @@ static int raw3270_create_attributes(struct raw3270 *rp) · 1167 unmodified lines | ||
| 1168 | 1168 | if (rc) |
| 1169 | 1169 | goto out; |
| 1170 | 1170 | |
| 1171 | − rp->clttydev = device_create(class3270, &rp->cdev->dev, | |
| 1172 | − MKDEV(IBM_TTY3270_MAJOR, rp->minor), | |
| 1173 | − "tty%s", rp->cdev->dev.bus_id); | |
| 1171 | + rp->clttydev = device_create_drvdata(class3270, &rp->cdev->dev, | |
| 1172 | + MKDEV(IBM_TTY3270_MAJOR, rp->minor), | |
| 1173 | + NULL, | |
| 1174 | + "tty%s", rp->cdev->dev.bus_id); | |
| 1174 | 1175 | if (IS_ERR(rp->clttydev)) { |
| 1175 | 1176 | rc = PTR_ERR(rp->clttydev); |
| 1176 | 1177 | goto out_ttydev; |
| 1177 | 1178 | } |
| 1178 | 1179 | |
| 1179 | − rp->cltubdev = device_create(class3270, &rp->cdev->dev, | |
| 1180 | − MKDEV(IBM_FS3270_MAJOR, rp->minor), | |
| 1181 | − "tub%s", rp->cdev->dev.bus_id); | |
| 1180 | + rp->cltubdev = device_create_drvdata(class3270, &rp->cdev->dev, | |
| 1181 | + MKDEV(IBM_FS3270_MAJOR, rp->minor), | |
| 1182 | + NULL, | |
| 1183 | + "tub%s", rp->cdev->dev.bus_id); | |
| 1182 | 1184 | if (!IS_ERR(rp->cltubdev)) |
| 1183 | 1185 | goto out; |
| 1184 | 1186 | |
| @@ -69,10 +69,9 @@ struct tape_class_device *register_tape_dev( · 68 unmodified lines | ||
| 69 | 69 | if (rc) |
| 70 | 70 | goto fail_with_cdev; |
| 71 | 71 | |
| 72 | − tcd->class_device = device_create(tape_class, device, | |
| 73 | − tcd->char_device->dev, | |
| 74 | − "%s", tcd->device_name | |
| 75 | − ); | |
| 72 | + tcd->class_device = device_create_drvdata(tape_class, device, | |
| 73 | + tcd->char_device->dev, | |
| 74 | + NULL, "%s", tcd->device_name); | |
| 76 | 75 | rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0; |
| 77 | 76 | if (rc) |
| 78 | 77 | goto fail_with_cdev; |
| @@ -896,8 +896,9 @@ static int ur_set_online(struct ccw_device *cdev) · 895 unmodified lines | ||
| 896 | 896 | goto fail_free_cdev; |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | − urd->device = device_create(vmur_class, NULL, urd->char_device->dev, | |
| 900 | − "%s", node_id); | |
| 899 | + urd->device = device_create_drvdata(vmur_class, NULL, | |
| 900 | + urd->char_device->dev, NULL, | |
| 901 | + "%s", node_id); | |
| 901 | 902 | if (IS_ERR(urd->device)) { |
| 902 | 903 | rc = PTR_ERR(urd->device); |
| 903 | 904 | TRACE("ur_set_online: device_create rc=%d\n", rc); |
| @@ -78,7 +78,7 @@ static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sde · 77 unmodified lines | ||
| 78 | 78 | else |
| 79 | 79 | sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev; |
| 80 | 80 | sdev->ofdev.dev.bus = &sbus_bus_type; |
| 81 | − sprintf(sdev->ofdev.dev.bus_id, "sbus[%08x]", dp->node); | |
| 81 | + dev_set_name(&sdev->ofdev.dev, "sbus[%08x]", dp->node); | |
| 82 | 82 | |
| 83 | 83 | if (of_device_register(&sdev->ofdev) != 0) |
| 84 | 84 | printk(KERN_DEBUG "sbus: device registration error for %s!\n", |
| @@ -257,11 +257,11 @@ static void __init build_one_sbus(struct device_node *dp, int num_sbus) · 172 unmodified lines | ||
| 257 | 257 | sbus->ofdev.node = dp; |
| 258 | 258 | sbus->ofdev.dev.parent = NULL; |
| 259 | 259 | sbus->ofdev.dev.bus = &sbus_bus_type; |
| 260 | − sprintf(sbus->ofdev.dev.bus_id, "sbus%d", num_sbus); | |
| 260 | + dev_set_name(&sbus->ofdev.dev, "sbus%d", num_sbus); | |
| 261 | 261 | |
| 262 | 262 | if (of_device_register(&sbus->ofdev) != 0) |
| 263 | 263 | printk(KERN_DEBUG "sbus: device registration error for %s!\n", |
| 264 | − sbus->ofdev.dev.bus_id); | |
| 264 | + dev_name(&sbus->ofdev.dev)); | |
| 265 | 265 | |
| 266 | 266 | dev_dp = dp->child; |
| 267 | 267 | while (dev_dp) { |
| @@ -271,8 +271,8 @@ rebuild_sys_tab: · 270 unmodified lines | ||
| 271 | 271 | pHba->initialized = TRUE; |
| 272 | 272 | pHba->state &= ~DPTI_STATE_RESET; |
| 273 | 273 | if (adpt_sysfs_class) { |
| 274 | − struct device *dev = device_create(adpt_sysfs_class, | |
| 275 | − NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), | |
| 274 | + struct device *dev = device_create_drvdata(adpt_sysfs_class, | |
| 275 | + NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL, | |
| 276 | 276 | "dpti%d", pHba->unit); |
| 277 | 277 | if (IS_ERR(dev)) { |
| 278 | 278 | printk(KERN_WARNING"dpti%d: unable to " |
| @@ -232,8 +232,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev) · 231 unmodified lines | ||
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | if (shost->transportt->create_work_queue) { |
| 235 | − snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d", | |
| 236 | − shost->host_no); | |
| 235 | + snprintf(shost->work_q_name, sizeof(shost->work_q_name), | |
| 236 | + "scsi_wq_%d", shost->host_no); | |
| 237 | 237 | shost->work_q = create_singlethread_workqueue( |
| 238 | 238 | shost->work_q_name); |
| 239 | 239 | if (!shost->work_q) { |
| @@ -466,7 +466,8 @@ struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) · 226 unmodified lines | ||
| 466 | 466 | struct device *cdev; |
| 467 | 467 | struct Scsi_Host *shost = ERR_PTR(-ENXIO); |
| 468 | 468 | |
| 469 | − cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match); | |
| 469 | + cdev = class_find_device(&shost_class, NULL, &hostnum, | |
| 470 | + __scsi_host_match); | |
| 470 | 471 | if (cdev) { |
| 471 | 472 | shost = scsi_host_get(class_to_shost(cdev)); |
| 472 | 473 | put_device(cdev); |
| @@ -417,15 +417,16 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev, · 416 unmodified lines | ||
| 417 | 417 | fc_host->next_vport_number = 0; |
| 418 | 418 | fc_host->npiv_vports_inuse = 0; |
| 419 | 419 | |
| 420 | − snprintf(fc_host->work_q_name, KOBJ_NAME_LEN, "fc_wq_%d", | |
| 421 | − shost->host_no); | |
| 420 | + snprintf(fc_host->work_q_name, sizeof(fc_host->work_q_name), | |
| 421 | + "fc_wq_%d", shost->host_no); | |
| 422 | 422 | fc_host->work_q = create_singlethread_workqueue( |
| 423 | 423 | fc_host->work_q_name); |
| 424 | 424 | if (!fc_host->work_q) |
| 425 | 425 | return -ENOMEM; |
| 426 | 426 | |
| 427 | − snprintf(fc_host->devloss_work_q_name, KOBJ_NAME_LEN, "fc_dl_%d", | |
| 428 | − shost->host_no); | |
| 427 | + snprintf(fc_host->devloss_work_q_name, | |
| 428 | + sizeof(fc_host->devloss_work_q_name), | |
| 429 | + "fc_dl_%d", shost->host_no); | |
| 429 | 430 | fc_host->devloss_work_q = create_singlethread_workqueue( |
| 430 | 431 | fc_host->devloss_work_q_name); |
| 431 | 432 | if (!fc_host->devloss_work_q) { |
| @@ -170,7 +170,7 @@ iscsi_create_endpoint(int dd_size) · 169 unmodified lines | ||
| 170 | 170 | int err; |
| 171 | 171 | |
| 172 | 172 | for (id = 1; id < ISCSI_MAX_EPID; id++) { |
| 173 | − dev = class_find_device(&iscsi_endpoint_class, &id, | |
| 173 | + dev = class_find_device(&iscsi_endpoint_class, NULL, &id, | |
| 174 | 174 | iscsi_match_epid); |
| 175 | 175 | if (!dev) |
| 176 | 176 | break; |
| @@ -222,7 +222,7 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) · 45 unmodified lines | ||
| 222 | 222 | struct iscsi_endpoint *ep; |
| 223 | 223 | struct device *dev; |
| 224 | 224 | |
| 225 | − dev = class_find_device(&iscsi_endpoint_class, &handle, | |
| 225 | + dev = class_find_device(&iscsi_endpoint_class, NULL, &handle, | |
| 226 | 226 | iscsi_match_epid); |
| 227 | 227 | if (!dev) |
| 228 | 228 | return NULL; |
| @@ -247,8 +247,8 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, · 18 unmodified lines | ||
| 247 | 247 | atomic_set(&ihost->nr_scans, 0); |
| 248 | 248 | mutex_init(&ihost->mutex); |
| 249 | 249 | |
| 250 | − snprintf(ihost->scan_workq_name, KOBJ_NAME_LEN, "iscsi_scan_%d", | |
| 251 | − shost->host_no); | |
| 250 | + snprintf(ihost->scan_workq_name, sizeof(ihost->scan_workq_name), | |
| 251 | + "iscsi_scan_%d", shost->host_no); | |
| 252 | 252 | ihost->scan_workq = create_singlethread_workqueue( |
| 253 | 253 | ihost->scan_workq_name); |
| 254 | 254 | if (!ihost->scan_workq) |
| @@ -502,7 +502,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num) · 501 unmodified lines | ||
| 502 | 502 | struct device *dev; |
| 503 | 503 | struct spi_master *master = NULL; |
| 504 | 504 | |
| 505 | − dev = class_find_device(&spi_master_class, &bus_num, | |
| 505 | + dev = class_find_device(&spi_master_class, NULL, &bus_num, | |
| 506 | 506 | __spi_master_match); |
| 507 | 507 | if (dev) |
| 508 | 508 | master = container_of(dev, struct spi_master, dev); |
| @@ -576,7 +576,8 @@ static int spidev_probe(struct spi_device *spi) · 575 unmodified lines | ||
| 576 | 576 | struct device *dev; |
| 577 | 577 | |
| 578 | 578 | spidev->devt = MKDEV(SPIDEV_MAJOR, minor); |
| 579 | − dev = device_create(spidev_class, &spi->dev, spidev->devt, | |
| 579 | + dev = device_create_drvdata(spidev_class, &spi->dev, | |
| 580 | + spidev->devt, spidev, | |
| 580 | 581 | "spidev%d.%d", |
| 581 | 582 | spi->master->bus_num, spi->chip_select); |
| 582 | 583 | status = IS_ERR(dev) ? PTR_ERR(dev) : 0; |
| @@ -586,7 +587,6 @@ static int spidev_probe(struct spi_device *spi) · 3 unmodified lines | ||
| 586 | 587 | } |
| 587 | 588 | if (status == 0) { |
| 588 | 589 | set_bit(minor, minors); |
| 589 | − spi_set_drvdata(spi, spidev); | |
| 590 | 590 | list_add(&spidev->device_entry, &device_list); |
| 591 | 591 | } |
| 592 | 592 | mutex_unlock(&device_list_lock); |
| @@ -15,7 +15,7 @@ if UIO · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | config UIO_CIF |
| 17 | 17 | tristate "generic Hilscher CIF Card driver" |
| 18 | − depends on UIO && PCI | |
| 18 | + depends on PCI | |
| 19 | 19 | default n |
| 20 | 20 | help |
| 21 | 21 | Driver for Hilscher CIF DeviceNet and Profibus cards. This |
| @@ -26,9 +26,15 @@ config UIO_CIF · 4 unmodified lines | ||
| 26 | 26 | To compile this driver as a module, choose M here: the module |
| 27 | 27 | will be called uio_cif. |
| 28 | 28 | |
| 29 | +config UIO_PDRV | |
| 30 | + tristate "Userspace I/O platform driver" | |
| 31 | + help | |
| 32 | + Generic platform driver for Userspace I/O devices. | |
| 33 | + | |
| 34 | + If you don't know what to do here, say N. | |
| 35 | + | |
| 29 | 36 | config UIO_SMX |
| 30 | 37 | tristate "SMX cryptengine UIO interface" |
| 31 | − depends on UIO | |
| 32 | 38 | default n |
| 33 | 39 | help |
| 34 | 40 | Userspace IO interface to the Cryptography engine found on the |
| @@ -1,3 +1,4 @@ | ||
| 1 | 1 | obj-$(CONFIG_UIO) += uio.o |
| 2 | 2 | obj-$(CONFIG_UIO_CIF) += uio_cif.o |
| 3 | +obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o | |
| 3 | 4 | obj-$(CONFIG_UIO_SMX) += uio_smx.o |
| @@ -427,6 +427,31 @@ static ssize_t uio_read(struct file *filep, char __user *buf, · 426 unmodified lines | ||
| 427 | 427 | return retval; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | +static ssize_t uio_write(struct file *filep, const char __user *buf, | |
| 431 | + size_t count, loff_t *ppos) | |
| 432 | +{ | |
| 433 | + struct uio_listener *listener = filep->private_data; | |
| 434 | + struct uio_device *idev = listener->dev; | |
| 435 | + ssize_t retval; | |
| 436 | + s32 irq_on; | |
| 437 | + | |
| 438 | + if (idev->info->irq == UIO_IRQ_NONE) | |
| 439 | + return -EIO; | |
| 440 | + | |
| 441 | + if (count != sizeof(s32)) | |
| 442 | + return -EINVAL; | |
| 443 | + | |
| 444 | + if (!idev->info->irqcontrol) | |
| 445 | + return -ENOSYS; | |
| 446 | + | |
| 447 | + if (copy_from_user(&irq_on, buf, count)) | |
| 448 | + return -EFAULT; | |
| 449 | + | |
| 450 | + retval = idev->info->irqcontrol(idev->info, irq_on); | |
| 451 | + | |
| 452 | + return retval ? retval : sizeof(s32); | |
| 453 | +} | |
| 454 | + | |
| 430 | 455 | static int uio_find_mem_index(struct vm_area_struct *vma) |
| 431 | 456 | { |
| 432 | 457 | int mi; |
| @@ -546,6 +571,7 @@ static const struct file_operations uio_fops = { · 113 unmodified lines | ||
| 546 | 571 | .open = uio_open, |
| 547 | 572 | .release = uio_release, |
| 548 | 573 | .read = uio_read, |
| 574 | + .write = uio_write, | |
| 549 | 575 | .mmap = uio_mmap, |
| 550 | 576 | .poll = uio_poll, |
| 551 | 577 | .fasync = uio_fasync, |
| @@ -0,0 +1,118 @@ | ||
| 1 | +/* | |
| 2 | + * drivers/uio/uio_pdrv.c | |
| 3 | + * | |
| 4 | + * Copyright (C) 2008 by Digi International Inc. | |
| 5 | + * All rights reserved. | |
| 6 | + * | |
| 7 | + * This program is free software; you can redistribute it and/or modify it | |
| 8 | + * under the terms of the GNU General Public License version 2 as published by | |
| 9 | + * the Free Software Foundation. | |
| 10 | + */ | |
| 11 | +#include <linux/platform_device.h> | |
| 12 | +#include <linux/uio_driver.h> | |
| 13 | +#include <linux/stringify.h> | |
| 14 | + | |
| 15 | +#define DRIVER_NAME "uio" | |
| 16 | + | |
| 17 | +struct uio_platdata { | |
| 18 | + struct uio_info *uioinfo; | |
| 19 | +}; | |
| 20 | + | |
| 21 | +static int uio_pdrv_probe(struct platform_device *pdev) | |
| 22 | +{ | |
| 23 | + struct uio_info *uioinfo = pdev->dev.platform_data; | |
| 24 | + struct uio_platdata *pdata; | |
| 25 | + struct uio_mem *uiomem; | |
| 26 | + int ret = -ENODEV; | |
| 27 | + int i; | |
| 28 | + | |
| 29 | + if (!uioinfo || !uioinfo->name || !uioinfo->version) { | |
| 30 | + dev_dbg(&pdev->dev, "%s: err_uioinfo\n", __func__); | |
| 31 | + goto err_uioinfo; | |
| 32 | + } | |
| 33 | + | |
| 34 | + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | |
| 35 | + if (!pdata) { | |
| 36 | + ret = -ENOMEM; | |
| 37 | + dev_dbg(&pdev->dev, "%s: err_alloc_pdata\n", __func__); | |
| 38 | + goto err_alloc_pdata; | |
| 39 | + } | |
| 40 | + | |
| 41 | + pdata->uioinfo = uioinfo; | |
| 42 | + | |
| 43 | + uiomem = &uioinfo->mem[0]; | |
| 44 | + | |
| 45 | + for (i = 0; i < pdev->num_resources; ++i) { | |
| 46 | + struct resource *r = &pdev->resource[i]; | |
| 47 | + | |
| 48 | + if (r->flags != IORESOURCE_MEM) | |
| 49 | + continue; | |
| 50 | + | |
| 51 | + if (uiomem >= &uioinfo->mem[MAX_UIO_MAPS]) { | |
| 52 | + dev_warn(&pdev->dev, "device has more than " | |
| 53 | + __stringify(MAX_UIO_MAPS) | |
| 54 | + " I/O memory resources.\n"); | |
| 55 | + break; | |
| 56 | + } | |
| 57 | + | |
| 58 | + uiomem->memtype = UIO_MEM_PHYS; | |
| 59 | + uiomem->addr = r->start; | |
| 60 | + uiomem->size = r->end - r->start + 1; | |
| 61 | + ++uiomem; | |
| 62 | + } | |
| 63 | + | |
| 64 | + while (uiomem < &uioinfo->mem[MAX_UIO_MAPS]) { | |
| 65 | + uiomem->size = 0; | |
| 66 | + ++uiomem; | |
| 67 | + } | |
| 68 | + | |
| 69 | + pdata->uioinfo->priv = pdata; | |
| 70 | + | |
| 71 | + ret = uio_register_device(&pdev->dev, pdata->uioinfo); | |
| 72 | + | |
| 73 | + if (ret) { | |
| 74 | + kfree(pdata); | |
| 75 | +err_alloc_pdata: | |
| 76 | +err_uioinfo: | |
| 77 | + return ret; | |
| 78 | + } | |
| 79 | + | |
| 80 | + platform_set_drvdata(pdev, pdata); | |
| 81 | + | |
| 82 | + return 0; | |
| 83 | +} | |
| 84 | + | |
| 85 | +static int uio_pdrv_remove(struct platform_device *pdev) | |
| 86 | +{ | |
| 87 | + struct uio_platdata *pdata = platform_get_drvdata(pdev); | |
| 88 | + | |
| 89 | + uio_unregister_device(pdata->uioinfo); | |
| 90 | + | |
| 91 | + return 0; | |
| 92 | +} | |
| 93 | + | |
| 94 | +static struct platform_driver uio_pdrv = { | |
| 95 | + .probe = uio_pdrv_probe, | |
| 96 | + .remove = uio_pdrv_remove, | |
| 97 | + .driver = { | |
| 98 | + .name = DRIVER_NAME, | |
| 99 | + .owner = THIS_MODULE, | |
| 100 | + }, | |
| 101 | +}; | |
| 102 | + | |
| 103 | +static int __init uio_pdrv_init(void) | |
| 104 | +{ | |
| 105 | + return platform_driver_register(&uio_pdrv); | |
| 106 | +} | |
| 107 | + | |
| 108 | +static void __exit uio_pdrv_exit(void) | |
| 109 | +{ | |
| 110 | + platform_driver_unregister(&uio_pdrv); | |
| 111 | +} | |
| 112 | +module_init(uio_pdrv_init); | |
| 113 | +module_exit(uio_pdrv_exit); | |
| 114 | + | |
| 115 | +MODULE_AUTHOR("Uwe Kleine-Koenig"); | |
| 116 | +MODULE_DESCRIPTION("Userspace I/O platform driver"); | |
| 117 | +MODULE_LICENSE("GPL"); | |
| 118 | +MODULE_ALIAS("platform:" DRIVER_NAME); | |
| @@ -1729,9 +1729,9 @@ static int usb_classdev_add(struct usb_device *dev) · 1728 unmodified lines | ||
| 1729 | 1729 | { |
| 1730 | 1730 | struct device *cldev; |
| 1731 | 1731 | |
| 1732 | − cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt, | |
| 1733 | − "usbdev%d.%d", dev->bus->busnum, | |
| 1734 | − dev->devnum); | |
| 1732 | + cldev = device_create_drvdata(usb_classdev_class, &dev->dev, | |
| 1733 | + dev->dev.devt, NULL, "usbdev%d.%d", | |
| 1734 | + dev->bus->busnum, dev->devnum); | |
| 1735 | 1735 | if (IS_ERR(cldev)) |
| 1736 | 1736 | return PTR_ERR(cldev); |
| 1737 | 1737 | dev->usb_classdev = cldev; |
| @@ -1792,6 +1792,11 @@ int __init usb_devio_init(void) · 54 unmodified lines | ||
| 1792 | 1792 | usb_classdev_class = NULL; |
| 1793 | 1793 | goto out; |
| 1794 | 1794 | } |
| 1795 | + /* devices of this class shadow the major:minor of their parent | |
| 1796 | + * device, so clear ->dev_kobj to prevent adding duplicate entries | |
| 1797 | + * to /sys/dev | |
| 1798 | + */ | |
| 1799 | + usb_classdev_class->dev_kobj = NULL; | |
| 1795 | 1800 | |
| 1796 | 1801 | usb_register_notify(&usbdev_nb); |
| 1797 | 1802 | #endif |
| @@ -196,8 +196,9 @@ int usb_register_dev(struct usb_interface *intf, · 195 unmodified lines | ||
| 196 | 196 | ++temp; |
| 197 | 197 | else |
| 198 | 198 | temp = name; |
| 199 | − intf->usb_dev = device_create(usb_class->class, &intf->dev, | |
| 200 | − MKDEV(USB_MAJOR, minor), "%s", temp); | |
| 199 | + intf->usb_dev = device_create_drvdata(usb_class->class, &intf->dev, | |
| 200 | + MKDEV(USB_MAJOR, minor), NULL, | |
| 201 | + "%s", temp); | |
| 201 | 202 | if (IS_ERR(intf->usb_dev)) { |
| 202 | 203 | down_write(&minor_rwsem); |
| 203 | 204 | usb_minors[intf->minor] = NULL; |
| @@ -1360,8 +1360,8 @@ printer_bind(struct usb_gadget *gadget) · 1359 unmodified lines | ||
| 1360 | 1360 | |
| 1361 | 1361 | |
| 1362 | 1362 | /* Setup the sysfs files for the printer gadget. */ |
| 1363 | − dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno, | |
| 1364 | − "g_printer"); | |
| 1363 | + dev->pdev = device_create_drvdata(usb_gadget_class, NULL, | |
| 1364 | + g_printer_devno, NULL, "g_printer"); | |
| 1365 | 1365 | if (IS_ERR(dev->pdev)) { |
| 1366 | 1366 | ERROR(dev, "Failed to create device: g_printer\n"); |
| 1367 | 1367 | goto fail; |
| @@ -1162,8 +1162,9 @@ int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus) · 1161 unmodified lines | ||
| 1162 | 1162 | if (minor >= MON_BIN_MAX_MINOR) |
| 1163 | 1163 | return 0; |
| 1164 | 1164 | |
| 1165 | − dev = device_create(mon_bin_class, ubus? ubus->controller: NULL, | |
| 1166 | − MKDEV(MAJOR(mon_bin_dev0), minor), "usbmon%d", minor); | |
| 1165 | + dev = device_create_drvdata(mon_bin_class, ubus? ubus->controller: NULL, | |
| 1166 | + MKDEV(MAJOR(mon_bin_dev0), minor), NULL, | |
| 1167 | + "usbmon%d", minor); | |
| 1167 | 1168 | if (IS_ERR(dev)) |
| 1168 | 1169 | return 0; |
| 1169 | 1170 | |
| @@ -1872,7 +1872,7 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i · 1871 unmodified lines | ||
| 1872 | 1872 | struct fb_info *info = pci_get_drvdata(pdev); |
| 1873 | 1873 | struct aty128fb_par *par = info->par; |
| 1874 | 1874 | struct fb_var_screeninfo var; |
| 1875 | − char video_card[DEVICE_NAME_SIZE]; | |
| 1875 | + char video_card[50]; | |
| 1876 | 1876 | u8 chip_rev; |
| 1877 | 1877 | u32 dac; |
| 1878 | 1878 | |
| @@ -289,7 +289,7 @@ struct radeonfb_info { · 288 unmodified lines | ||
| 289 | 289 | struct radeon_regs state; |
| 290 | 290 | struct radeon_regs init_state; |
| 291 | 291 | |
| 292 | − char name[DEVICE_NAME_SIZE]; | |
| 292 | + char name[50]; | |
| 293 | 293 | |
| 294 | 294 | unsigned long mmio_base_phys; |
| 295 | 295 | unsigned long fb_base_phys; |
| @@ -3586,7 +3586,8 @@ static int __init fb_console_init(void) · 3585 unmodified lines | ||
| 3586 | 3586 | |
| 3587 | 3587 | acquire_console_sem(); |
| 3588 | 3588 | fb_register_client(&fbcon_event_notifier); |
| 3589 | − fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), "fbcon"); | |
| 3589 | + fbcon_device = device_create_drvdata(fb_class, NULL, MKDEV(0, 0), | |
| 3590 | + NULL, "fbcon"); | |
| 3590 | 3591 | |
| 3591 | 3592 | if (IS_ERR(fbcon_device)) { |
| 3592 | 3593 | printk(KERN_WARNING "Unable to create device " |
| @@ -1439,8 +1439,9 @@ register_framebuffer(struct fb_info *fb_info) · 1438 unmodified lines | ||
| 1439 | 1439 | break; |
| 1440 | 1440 | fb_info->node = i; |
| 1441 | 1441 | |
| 1442 | − fb_info->dev = device_create(fb_class, fb_info->device, | |
| 1443 | − MKDEV(FB_MAJOR, i), "fb%d", i); | |
| 1442 | + fb_info->dev = device_create_drvdata(fb_class, fb_info->device, | |
| 1443 | + MKDEV(FB_MAJOR, i), NULL, | |
| 1444 | + "fb%d", i); | |
| 1444 | 1445 | if (IS_ERR(fb_info->dev)) { |
| 1445 | 1446 | /* Not fatal */ |
| 1446 | 1447 | printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev)); |
| @@ -610,6 +610,7 @@ static ssize_t show_target_kb(struct sys_device *dev, char *buf) · 609 unmodified lines | ||
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | static ssize_t store_target_kb(struct sys_device *dev, |
| 613 | + struct sysdev_attribute *attr, | |
| 613 | 614 | const char *buf, |
| 614 | 615 | size_t count) |
| 615 | 616 | { |
| @@ -362,8 +362,9 @@ static int init_coda_psdev(void) · 361 unmodified lines | ||
| 362 | 362 | goto out_chrdev; |
| 363 | 363 | } |
| 364 | 364 | for (i = 0; i < MAX_CODADEVS; i++) |
| 365 | − device_create(coda_psdev_class, NULL, | |
| 366 | − MKDEV(CODA_PSDEV_MAJOR,i), "cfs%d", i); | |
| 365 | + device_create_drvdata(coda_psdev_class, NULL, | |
| 366 | + MKDEV(CODA_PSDEV_MAJOR, i), | |
| 367 | + NULL, "cfs%d", i); | |
| 367 | 368 | coda_sysctl_init(); |
| 368 | 369 | goto out; |
| 369 | 370 | |
| @@ -309,6 +309,31 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, · 308 unmodified lines | ||
| 309 | 309 | } |
| 310 | 310 | EXPORT_SYMBOL_GPL(debugfs_create_symlink); |
| 311 | 311 | |
| 312 | +static void __debugfs_remove(struct dentry *dentry, struct dentry *parent) | |
| 313 | +{ | |
| 314 | + int ret = 0; | |
| 315 | + | |
| 316 | + if (debugfs_positive(dentry)) { | |
| 317 | + if (dentry->d_inode) { | |
| 318 | + dget(dentry); | |
| 319 | + switch (dentry->d_inode->i_mode & S_IFMT) { | |
| 320 | + case S_IFDIR: | |
| 321 | + ret = simple_rmdir(parent->d_inode, dentry); | |
| 322 | + break; | |
| 323 | + case S_IFLNK: | |
| 324 | + kfree(dentry->d_inode->i_private); | |
| 325 | + /* fall through */ | |
| 326 | + default: | |
| 327 | + simple_unlink(parent->d_inode, dentry); | |
| 328 | + break; | |
| 329 | + } | |
| 330 | + if (!ret) | |
| 331 | + d_delete(dentry); | |
| 332 | + dput(dentry); | |
| 333 | + } | |
| 334 | + } | |
| 335 | +} | |
| 336 | + | |
| 312 | 337 | /** |
| 313 | 338 | * debugfs_remove - removes a file or directory from the debugfs filesystem |
| 314 | 339 | * @dentry: a pointer to a the dentry of the file or directory to be |
| @@ -325,7 +350,6 @@ EXPORT_SYMBOL_GPL(debugfs_create_symlink); · 10 unmodified lines | ||
| 325 | 350 | void debugfs_remove(struct dentry *dentry) |
| 326 | 351 | { |
| 327 | 352 | struct dentry *parent; |
| 328 | − int ret = 0; | |
| 329 | 353 | |
| 330 | 354 | if (!dentry) |
| 331 | 355 | return; |
| @@ -335,29 +359,83 @@ void debugfs_remove(struct dentry *dentry) · 3 unmodified lines | ||
| 335 | 359 | return; |
| 336 | 360 | |
| 337 | 361 | mutex_lock(&parent->d_inode->i_mutex); |
| 338 | − if (debugfs_positive(dentry)) { | |
| 339 | − if (dentry->d_inode) { | |
| 340 | − dget(dentry); | |
| 341 | − switch (dentry->d_inode->i_mode & S_IFMT) { | |
| 342 | − case S_IFDIR: | |
| 343 | − ret = simple_rmdir(parent->d_inode, dentry); | |
| 344 | − break; | |
| 345 | − case S_IFLNK: | |
| 346 | − kfree(dentry->d_inode->i_private); | |
| 347 | − /* fall through */ | |
| 348 | − default: | |
| 349 | − simple_unlink(parent->d_inode, dentry); | |
| 362 | + __debugfs_remove(dentry, parent); | |
| 363 | + mutex_unlock(&parent->d_inode->i_mutex); | |
| 364 | + simple_release_fs(&debugfs_mount, &debugfs_mount_count); | |
| 365 | +} | |
| 366 | +EXPORT_SYMBOL_GPL(debugfs_remove); | |
| 367 | + | |
| 368 | +/** | |
| 369 | + * debugfs_remove_recursive - recursively removes a directory | |
| 370 | + * @dentry: a pointer to a the dentry of the directory to be removed. | |
| 371 | + * | |
| 372 | + * This function recursively removes a directory tree in debugfs that | |
| 373 | + * was previously created with a call to another debugfs function | |
| 374 | + * (like debugfs_create_file() or variants thereof.) | |
| 375 | + * | |
| 376 | + * This function is required to be called in order for the file to be | |
| 377 | + * removed, no automatic cleanup of files will happen when a module is | |
| 378 | + * removed, you are responsible here. | |
| 379 | + */ | |
| 380 | +void debugfs_remove_recursive(struct dentry *dentry) | |
| 381 | +{ | |
| 382 | + struct dentry *child; | |
| 383 | + struct dentry *parent; | |
| 384 | + | |
| 385 | + if (!dentry) | |
| 386 | + return; | |
| 387 | + | |
| 388 | + parent = dentry->d_parent; | |
| 389 | + if (!parent || !parent->d_inode) | |
| 390 | + return; | |
| 391 | + | |
| 392 | + parent = dentry; | |
| 393 | + mutex_lock(&parent->d_inode->i_mutex); | |
| 394 | + | |
| 395 | + while (1) { | |
| 396 | + /* | |
| 397 | + * When all dentries under "parent" has been removed, | |
| 398 | + * walk up the tree until we reach our starting point. | |
| 399 | + */ | |
| 400 | + if (list_empty(&parent->d_subdirs)) { | |
| 401 | + mutex_unlock(&parent->d_inode->i_mutex); | |
| 402 | + if (parent == dentry) | |
| 350 | 403 | break; |
| 351 | − } | |
| 352 | − if (!ret) | |
| 353 | − d_delete(dentry); | |
| 354 | − dput(dentry); | |
| 404 | + parent = parent->d_parent; | |
| 405 | + mutex_lock(&parent->d_inode->i_mutex); | |
| 406 | + } | |
| 407 | + child = list_entry(parent->d_subdirs.next, struct dentry, | |
| 408 | + d_u.d_child); | |
| 409 | + | |
| 410 | + /* | |
| 411 | + * If "child" isn't empty, walk down the tree and | |
| 412 | + * remove all its descendants first. | |
| 413 | + */ | |
| 414 | + if (!list_empty(&child->d_subdirs)) { | |
| 415 | + mutex_unlock(&parent->d_inode->i_mutex); | |
| 416 | + parent = child; | |
| 417 | + mutex_lock(&parent->d_inode->i_mutex); | |
| 418 | + continue; | |
| 355 | 419 | } |
| 420 | + __debugfs_remove(child, parent); | |
| 421 | + if (parent->d_subdirs.next == &child->d_u.d_child) { | |
| 422 | + /* | |
| 423 | + * Avoid infinite loop if we fail to remove | |
| 424 | + * one dentry. | |
| 425 | + */ | |
| 426 | + mutex_unlock(&parent->d_inode->i_mutex); | |
| 427 | + break; | |
| 428 | + } | |
| 429 | + simple_release_fs(&debugfs_mount, &debugfs_mount_count); | |
| 356 | 430 | } |
| 431 | + | |
| 432 | + parent = dentry->d_parent; | |
| 433 | + mutex_lock(&parent->d_inode->i_mutex); | |
| 434 | + __debugfs_remove(dentry, parent); | |
| 357 | 435 | mutex_unlock(&parent->d_inode->i_mutex); |
| 358 | 436 | simple_release_fs(&debugfs_mount, &debugfs_mount_count); |
| 359 | 437 | } |
| 360 | −EXPORT_SYMBOL_GPL(debugfs_remove); | |
| 438 | +EXPORT_SYMBOL_GPL(debugfs_remove_recursive); | |
| 361 | 439 | |
| 362 | 440 | /** |
| 363 | 441 | * debugfs_rename - rename a file/directory in the debugfs filesystem |
| @@ -401,7 +401,7 @@ void register_disk(struct gendisk *disk) · 400 unmodified lines | ||
| 401 | 401 | disk->dev.parent = disk->driverfs_dev; |
| 402 | 402 | disk->dev.devt = MKDEV(disk->major, disk->first_minor); |
| 403 | 403 | |
| 404 | − strlcpy(disk->dev.bus_id, disk->disk_name, KOBJ_NAME_LEN); | |
| 404 | + strlcpy(disk->dev.bus_id, disk->disk_name, BUS_ID_SIZE); | |
| 405 | 405 | /* ewww... some of these buggers have / in the name... */ |
| 406 | 406 | s = strchr(disk->dev.bus_id, '/'); |
| 407 | 407 | if (s) |
| @@ -398,7 +398,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, · 397 unmodified lines | ||
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | − * sysfs_add_one - add sysfs_dirent to parent | |
| 401 | + * __sysfs_add_one - add sysfs_dirent to parent without warning | |
| 402 | 402 | * @acxt: addrm context to use |
| 403 | 403 | * @sd: sysfs_dirent to be added |
| 404 | 404 | * |
| @@ -417,7 +417,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, · 12 unmodified lines | ||
| 417 | 417 | * 0 on success, -EEXIST if entry with the given name already |
| 418 | 418 | * exists. |
| 419 | 419 | */ |
| 420 | −int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |
| 420 | +int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |
| 421 | 421 | { |
| 422 | 422 | if (sysfs_find_dirent(acxt->parent_sd, sd->s_name)) |
| 423 | 423 | return -EEXIST; |
| @@ -434,6 +434,39 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) · 10 unmodified lines | ||
| 434 | 434 | return 0; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | +/** | |
| 438 | + * sysfs_add_one - add sysfs_dirent to parent | |
| 439 | + * @acxt: addrm context to use | |
| 440 | + * @sd: sysfs_dirent to be added | |
| 441 | + * | |
| 442 | + * Get @acxt->parent_sd and set sd->s_parent to it and increment | |
| 443 | + * nlink of parent inode if @sd is a directory and link into the | |
| 444 | + * children list of the parent. | |
| 445 | + * | |
| 446 | + * This function should be called between calls to | |
| 447 | + * sysfs_addrm_start() and sysfs_addrm_finish() and should be | |
| 448 | + * passed the same @acxt as passed to sysfs_addrm_start(). | |
| 449 | + * | |
| 450 | + * LOCKING: | |
| 451 | + * Determined by sysfs_addrm_start(). | |
| 452 | + * | |
| 453 | + * RETURNS: | |
| 454 | + * 0 on success, -EEXIST if entry with the given name already | |
| 455 | + * exists. | |
| 456 | + */ | |
| 457 | +int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |
| 458 | +{ | |
| 459 | + int ret; | |
| 460 | + | |
| 461 | + ret = __sysfs_add_one(acxt, sd); | |
| 462 | + if (ret == -EEXIST) { | |
| 463 | + printk(KERN_WARNING "sysfs: duplicate filename '%s' " | |
| 464 | + "can not be created\n", sd->s_name); | |
| 465 | + WARN_ON(1); | |
| 466 | + } | |
| 467 | + return ret; | |
| 468 | +} | |
| 469 | + | |
| 437 | 470 | /** |
| 438 | 471 | * sysfs_remove_one - remove sysfs_dirent from parent |
| 439 | 472 | * @acxt: addrm context to use |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <linux/kobject.h> |
| 15 | 15 | #include <linux/kallsyms.h> |
| 16 | 16 | #include <linux/slab.h> |
| 17 | +#include <linux/fsnotify.h> | |
| 17 | 18 | #include <linux/namei.h> |
| 18 | 19 | #include <linux/poll.h> |
| 19 | 20 | #include <linux/list.h> |
| @@ -585,9 +586,11 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) · 565 unmodified lines | ||
| 585 | 586 | |
| 586 | 587 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); |
| 587 | 588 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; |
| 588 | − rc = notify_change(victim, &newattrs); | |
| 589 | + newattrs.ia_ctime = current_fs_time(inode->i_sb); | |
| 590 | + rc = sysfs_setattr(victim, &newattrs); | |
| 589 | 591 | |
| 590 | 592 | if (rc == 0) { |
| 593 | + fsnotify_change(victim, newattrs.ia_valid); | |
| 591 | 594 | mutex_lock(&sysfs_mutex); |
| 592 | 595 | victim_sd->s_mode = newattrs.ia_mode; |
| 593 | 596 | mutex_unlock(&sysfs_mutex); |
| @@ -19,13 +19,8 @@ · 18 unmodified lines | ||
| 19 | 19 | |
| 20 | 20 | #include "sysfs.h" |
| 21 | 21 | |
| 22 | −/** | |
| 23 | − * sysfs_create_link - create symlink between two objects. | |
| 24 | − * @kobj: object whose directory we're creating the link in. | |
| 25 | − * @target: object we're pointing to. | |
| 26 | − * @name: name of the symlink. | |
| 27 | − */ | |
| 28 | −int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) | |
| 22 | +static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target, | |
| 23 | + const char *name, int warn) | |
| 29 | 24 | { |
| 30 | 25 | struct sysfs_dirent *parent_sd = NULL; |
| 31 | 26 | struct sysfs_dirent *target_sd = NULL; |
| @@ -65,7 +60,10 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char · 33 unmodified lines | ||
| 65 | 60 | target_sd = NULL; /* reference is now owned by the symlink */ |
| 66 | 61 | |
| 67 | 62 | sysfs_addrm_start(&acxt, parent_sd); |
| 68 | − error = sysfs_add_one(&acxt, sd); | |
| 63 | + if (warn) | |
| 64 | + error = sysfs_add_one(&acxt, sd); | |
| 65 | + else | |
| 66 | + error = __sysfs_add_one(&acxt, sd); | |
| 69 | 67 | sysfs_addrm_finish(&acxt); |
| 70 | 68 | |
| 71 | 69 | if (error) |
| @@ -79,6 +77,33 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char · 7 unmodified lines | ||
| 79 | 77 | return error; |
| 80 | 78 | } |
| 81 | 79 | |
| 80 | +/** | |
| 81 | + * sysfs_create_link - create symlink between two objects. | |
| 82 | + * @kobj: object whose directory we're creating the link in. | |
| 83 | + * @target: object we're pointing to. | |
| 84 | + * @name: name of the symlink. | |
| 85 | + */ | |
| 86 | +int sysfs_create_link(struct kobject *kobj, struct kobject *target, | |
| 87 | + const char *name) | |
| 88 | +{ | |
| 89 | + return sysfs_do_create_link(kobj, target, name, 1); | |
| 90 | +} | |
| 91 | + | |
| 92 | +/** | |
| 93 | + * sysfs_create_link_nowarn - create symlink between two objects. | |
| 94 | + * @kobj: object whose directory we're creating the link in. | |
| 95 | + * @target: object we're pointing to. | |
| 96 | + * @name: name of the symlink. | |
| 97 | + * | |
| 98 | + * This function does the same as sysf_create_link(), but it | |
| 99 | + * doesn't warn if the link already exists. | |
| 100 | + */ | |
| 101 | +int sysfs_create_link_nowarn(struct kobject *kobj, struct kobject *target, | |
| 102 | + const char *name) | |
| 103 | +{ | |
| 104 | + return sysfs_do_create_link(kobj, target, name, 0); | |
| 105 | +} | |
| 106 | + | |
| 82 | 107 | /** |
| 83 | 108 | * sysfs_remove_link - remove symlink in object's directory. |
| 84 | 109 | * @kobj: object we're acting for. |
| @@ -107,6 +107,7 @@ struct sysfs_dirent *sysfs_get_active_two(struct sysfs_dirent *sd); · 106 unmodified lines | ||
| 107 | 107 | void sysfs_put_active_two(struct sysfs_dirent *sd); |
| 108 | 108 | void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, |
| 109 | 109 | struct sysfs_dirent *parent_sd); |
| 110 | +int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd); | |
| 110 | 111 | int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd); |
| 111 | 112 | void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd); |
| 112 | 113 | void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); |
| @@ -44,6 +44,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, · 43 unmodified lines | ||
| 44 | 44 | const char *dest); |
| 45 | 45 | |
| 46 | 46 | void debugfs_remove(struct dentry *dentry); |
| 47 | +void debugfs_remove_recursive(struct dentry *dentry); | |
| 47 | 48 | |
| 48 | 49 | struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, |
| 49 | 50 | struct dentry *new_dir, const char *new_name); |
| @@ -101,6 +102,9 @@ static inline struct dentry *debugfs_create_symlink(const char *name, · 51 unmodified lines | ||
| 101 | 102 | static inline void debugfs_remove(struct dentry *dentry) |
| 102 | 103 | { } |
| 103 | 104 | |
| 105 | +static inline void debugfs_remove_recursive(struct dentry *dentry) | |
| 106 | +{ } | |
| 107 | + | |
| 104 | 108 | static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, |
| 105 | 109 | struct dentry *new_dir, char *new_name) |
| 106 | 110 | { |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | #include <linux/kobject.h> |
| 17 | 17 | #include <linux/klist.h> |
| 18 | 18 | #include <linux/list.h> |
| 19 | +#include <linux/lockdep.h> | |
| 19 | 20 | #include <linux/compiler.h> |
| 20 | 21 | #include <linux/types.h> |
| 21 | 22 | #include <linux/module.h> |
| @@ -24,17 +25,13 @@ · 2 unmodified lines | ||
| 24 | 25 | #include <asm/atomic.h> |
| 25 | 26 | #include <asm/device.h> |
| 26 | 27 | |
| 27 | −#define DEVICE_NAME_SIZE 50 | |
| 28 | −/* DEVICE_NAME_HALF is really less than half to accommodate slop */ | |
| 29 | −#define DEVICE_NAME_HALF __stringify(20) | |
| 30 | −#define DEVICE_ID_SIZE 32 | |
| 31 | −#define BUS_ID_SIZE KOBJ_NAME_LEN | |
| 32 | − | |
| 28 | +#define BUS_ID_SIZE 20 | |
| 33 | 29 | |
| 34 | 30 | struct device; |
| 35 | 31 | struct device_driver; |
| 36 | 32 | struct driver_private; |
| 37 | 33 | struct class; |
| 34 | +struct class_private; | |
| 38 | 35 | struct bus_type; |
| 39 | 36 | struct bus_type_private; |
| 40 | 37 | |
| @@ -186,13 +183,9 @@ struct class { · 145 unmodified lines | ||
| 186 | 183 | const char *name; |
| 187 | 184 | struct module *owner; |
| 188 | 185 | |
| 189 | − struct kset subsys; | |
| 190 | − struct list_head devices; | |
| 191 | − struct list_head interfaces; | |
| 192 | − struct kset class_dirs; | |
| 193 | − struct semaphore sem; /* locks children, devices, interfaces */ | |
| 194 | 186 | struct class_attribute *class_attrs; |
| 195 | 187 | struct device_attribute *dev_attrs; |
| 188 | + struct kobject *dev_kobj; | |
| 196 | 189 | |
| 197 | 190 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); |
| 198 | 191 | |
| @@ -203,13 +196,28 @@ struct class { · 4 unmodified lines | ||
| 203 | 196 | int (*resume)(struct device *dev); |
| 204 | 197 | |
| 205 | 198 | struct pm_ops *pm; |
| 199 | + struct class_private *p; | |
| 206 | 200 | }; |
| 207 | 201 | |
| 208 | −extern int __must_check class_register(struct class *class); | |
| 202 | +extern struct kobject *sysfs_dev_block_kobj; | |
| 203 | +extern struct kobject *sysfs_dev_char_kobj; | |
| 204 | +extern int __must_check __class_register(struct class *class, | |
| 205 | + struct lock_class_key *key); | |
| 209 | 206 | extern void class_unregister(struct class *class); |
| 210 | −extern int class_for_each_device(struct class *class, void *data, | |
| 207 | + | |
| 208 | +/* This is a #define to keep the compiler from merging different | |
| 209 | + * instances of the __key variable */ | |
| 210 | +#define class_register(class) \ | |
| 211 | +({ \ | |
| 212 | + static struct lock_class_key __key; \ | |
| 213 | + __class_register(class, &__key); \ | |
| 214 | +}) | |
| 215 | + | |
| 216 | +extern int class_for_each_device(struct class *class, struct device *start, | |
| 217 | + void *data, | |
| 211 | 218 | int (*fn)(struct device *dev, void *data)); |
| 212 | −extern struct device *class_find_device(struct class *class, void *data, | |
| 219 | +extern struct device *class_find_device(struct class *class, | |
| 220 | + struct device *start, void *data, | |
| 213 | 221 | int (*match)(struct device *, void *)); |
| 214 | 222 | |
| 215 | 223 | struct class_attribute { |
| @@ -237,9 +245,19 @@ struct class_interface { · 21 unmodified lines | ||
| 237 | 245 | extern int __must_check class_interface_register(struct class_interface *); |
| 238 | 246 | extern void class_interface_unregister(struct class_interface *); |
| 239 | 247 | |
| 240 | −extern struct class *class_create(struct module *owner, const char *name); | |
| 248 | +extern struct class * __must_check __class_create(struct module *owner, | |
| 249 | + const char *name, | |
| 250 | + struct lock_class_key *key); | |
| 241 | 251 | extern void class_destroy(struct class *cls); |
| 242 | 252 | |
| 253 | +/* This is a #define to keep the compiler from merging different | |
| 254 | + * instances of the __key variable */ | |
| 255 | +#define class_create(owner, name) \ | |
| 256 | +({ \ | |
| 257 | + static struct lock_class_key __key; \ | |
| 258 | + __class_create(owner, name, &__key); \ | |
| 259 | +}) | |
| 260 | + | |
| 243 | 261 | /* |
| 244 | 262 | * The type of device, "struct device" is embedded in. A class |
| 245 | 263 | * or bus can contain devices of different types |
| @@ -468,14 +486,10 @@ extern struct device *device_create_vargs(struct class *cls, · 222 unmodified lines | ||
| 468 | 486 | const char *fmt, |
| 469 | 487 | va_list vargs); |
| 470 | 488 | extern struct device *device_create(struct class *cls, struct device *parent, |
| 471 | − dev_t devt, const char *fmt, ...) | |
| 472 | − __attribute__((format(printf, 4, 5))); | |
| 473 | −extern struct device *device_create_drvdata(struct class *cls, | |
| 474 | − struct device *parent, | |
| 475 | − dev_t devt, | |
| 476 | − void *drvdata, | |
| 477 | − const char *fmt, ...) | |
| 489 | + dev_t devt, void *drvdata, | |
| 490 | + const char *fmt, ...) | |
| 478 | 491 | __attribute__((format(printf, 5, 6))); |
| 492 | +#define device_create_drvdata device_create | |
| 479 | 493 | extern void device_destroy(struct class *cls, dev_t devt); |
| 480 | 494 | |
| 481 | 495 | /* |
| @@ -40,7 +40,7 @@ struct eisa_device { · 39 unmodified lines | ||
| 40 | 40 | u64 dma_mask; |
| 41 | 41 | struct device dev; /* generic device */ |
| 42 | 42 | #ifdef CONFIG_EISA_NAMES |
| 43 | − char pretty_name[DEVICE_NAME_SIZE]; | |
| 43 | + char pretty_name[50]; | |
| 44 | 44 | #endif |
| 45 | 45 | }; |
| 46 | 46 | |
| @@ -26,7 +26,6 @@ · 25 unmodified lines | ||
| 26 | 26 | #include <linux/wait.h> |
| 27 | 27 | #include <asm/atomic.h> |
| 28 | 28 | |
| 29 | −#define KOBJ_NAME_LEN 20 | |
| 30 | 29 | #define UEVENT_HELPER_PATH_LEN 256 |
| 31 | 30 | #define UEVENT_NUM_ENVP 32 /* number of env pointers */ |
| 32 | 31 | #define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */ |
| @@ -59,12 +58,12 @@ enum kobject_action { · 26 unmodified lines | ||
| 59 | 58 | |
| 60 | 59 | struct kobject { |
| 61 | 60 | const char *name; |
| 62 | − struct kref kref; | |
| 63 | 61 | struct list_head entry; |
| 64 | 62 | struct kobject *parent; |
| 65 | 63 | struct kset *kset; |
| 66 | 64 | struct kobj_type *ktype; |
| 67 | 65 | struct sysfs_dirent *sd; |
| 66 | + struct kref kref; | |
| 68 | 67 | unsigned int state_initialized:1; |
| 69 | 68 | unsigned int state_in_sysfs:1; |
| 70 | 69 | unsigned int state_add_uevent_sent:1; |
| @@ -189,7 +189,7 @@ typedef union { · 188 unmodified lines | ||
| 189 | 189 | */ |
| 190 | 190 | |
| 191 | 191 | struct map_info { |
| 192 | − char *name; | |
| 192 | + const char *name; | |
| 193 | 193 | unsigned long size; |
| 194 | 194 | resource_size_t phys; |
| 195 | 195 | #define NO_XIP (-1UL) |
| @@ -121,7 +121,7 @@ struct mtd_info { · 120 unmodified lines | ||
| 121 | 121 | u_int32_t oobavail; // Available OOB bytes per block |
| 122 | 122 | |
| 123 | 123 | // Kernel-only stuff starts here. |
| 124 | − char *name; | |
| 124 | + const char *name; | |
| 125 | 125 | int index; |
| 126 | 126 | |
| 127 | 127 | /* ecc layout structure pointer - read only ! */ |
| @@ -733,7 +733,7 @@ struct spi_board_info { · 732 unmodified lines | ||
| 733 | 733 | * controller_data goes to spi_device.controller_data, |
| 734 | 734 | * irq is copied too |
| 735 | 735 | */ |
| 736 | − char modalias[KOBJ_NAME_LEN]; | |
| 736 | + char modalias[32]; | |
| 737 | 737 | const void *platform_data; |
| 738 | 738 | void *controller_data; |
| 739 | 739 | int irq; |
| @@ -99,8 +99,9 @@ extern void sysdev_unregister(struct sys_device *); · 98 unmodified lines | ||
| 99 | 99 | |
| 100 | 100 | struct sysdev_attribute { |
| 101 | 101 | struct attribute attr; |
| 102 | − ssize_t (*show)(struct sys_device *, char *); | |
| 103 | − ssize_t (*store)(struct sys_device *, const char *, size_t); | |
| 102 | + ssize_t (*show)(struct sys_device *, struct sysdev_attribute *, char *); | |
| 103 | + ssize_t (*store)(struct sys_device *, struct sysdev_attribute *, | |
| 104 | + const char *, size_t); | |
| 104 | 105 | }; |
| 105 | 106 | |
| 106 | 107 | |
| @@ -118,4 +119,38 @@ struct sysdev_attribute { · 11 unmodified lines | ||
| 118 | 119 | extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *); |
| 119 | 120 | extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *); |
| 120 | 121 | |
| 122 | +struct sysdev_ext_attribute { | |
| 123 | + struct sysdev_attribute attr; | |
| 124 | + void *var; | |
| 125 | +}; | |
| 126 | + | |
| 127 | +/* | |
| 128 | + * Support for simple variable sysdev attributes. | |
| 129 | + * The pointer to the variable is stored in a sysdev_ext_attribute | |
| 130 | + */ | |
| 131 | + | |
| 132 | +/* Add more types as needed */ | |
| 133 | + | |
| 134 | +extern ssize_t sysdev_show_ulong(struct sys_device *, struct sysdev_attribute *, | |
| 135 | + char *); | |
| 136 | +extern ssize_t sysdev_store_ulong(struct sys_device *, | |
| 137 | + struct sysdev_attribute *, const char *, size_t); | |
| 138 | +extern ssize_t sysdev_show_int(struct sys_device *, struct sysdev_attribute *, | |
| 139 | + char *); | |
| 140 | +extern ssize_t sysdev_store_int(struct sys_device *, | |
| 141 | + struct sysdev_attribute *, const char *, size_t); | |
| 142 | + | |
| 143 | +#define _SYSDEV_ULONG_ATTR(_name, _mode, _var) \ | |
| 144 | + { _SYSDEV_ATTR(_name, _mode, sysdev_show_ulong, sysdev_store_ulong), \ | |
| 145 | + &(_var) } | |
| 146 | +#define SYSDEV_ULONG_ATTR(_name, _mode, _var) \ | |
| 147 | + struct sysdev_ext_attribute attr_##_name = \ | |
| 148 | + _SYSDEV_ULONG_ATTR(_name, _mode, _var); | |
| 149 | +#define _SYSDEV_INT_ATTR(_name, _mode, _var) \ | |
| 150 | + { _SYSDEV_ATTR(_name, _mode, sysdev_show_int, sysdev_store_int), \ | |
| 151 | + &(_var) } | |
| 152 | +#define SYSDEV_INT_ATTR(_name, _mode, _var) \ | |
| 153 | + struct sysdev_ext_attribute attr_##_name = \ | |
| 154 | + _SYSDEV_INT_ATTR(_name, _mode, _var); | |
| 155 | + | |
| 121 | 156 | #endif /* _SYSDEV_H_ */ |
| @@ -101,6 +101,9 @@ void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr); · 100 unmodified lines | ||
| 101 | 101 | |
| 102 | 102 | int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target, |
| 103 | 103 | const char *name); |
| 104 | +int __must_check sysfs_create_link_nowarn(struct kobject *kobj, | |
| 105 | + struct kobject *target, | |
| 106 | + const char *name); | |
| 104 | 107 | void sysfs_remove_link(struct kobject *kobj, const char *name); |
| 105 | 108 | |
| 106 | 109 | int __must_check sysfs_create_group(struct kobject *kobj, |
| @@ -180,6 +183,13 @@ static inline int sysfs_create_link(struct kobject *kobj, · 73 unmodified lines | ||
| 180 | 183 | return 0; |
| 181 | 184 | } |
| 182 | 185 | |
| 186 | +static inline int sysfs_create_link_nowarn(struct kobject *kobj, | |
| 187 | + struct kobject *target, | |
| 188 | + const char *name) | |
| 189 | +{ | |
| 190 | + return 0; | |
| 191 | +} | |
| 192 | + | |
| 183 | 193 | static inline void sysfs_remove_link(struct kobject *kobj, const char *name) |
| 184 | 194 | { |
| 185 | 195 | } |
| @@ -36,7 +36,7 @@ struct uio_mem { · 35 unmodified lines | ||
| 36 | 36 | struct uio_map *map; |
| 37 | 37 | }; |
| 38 | 38 | |
| 39 | −#define MAX_UIO_MAPS 5 | |
| 39 | +#define MAX_UIO_MAPS 5 | |
| 40 | 40 | |
| 41 | 41 | struct uio_device; |
| 42 | 42 | |
| @@ -53,6 +53,7 @@ struct uio_device; · 10 unmodified lines | ||
| 53 | 53 | * @mmap: mmap operation for this uio device |
| 54 | 54 | * @open: open operation for this uio device |
| 55 | 55 | * @release: release operation for this uio device |
| 56 | + * @irqcontrol: disable/enable irqs when 0/1 is written to /dev/uioX | |
| 56 | 57 | */ |
| 57 | 58 | struct uio_info { |
| 58 | 59 | struct uio_device *uio_dev; |
| @@ -66,6 +67,7 @@ struct uio_info { · 7 unmodified lines | ||
| 66 | 67 | int (*mmap)(struct uio_info *info, struct vm_area_struct *vma); |
| 67 | 68 | int (*open)(struct uio_info *info, struct inode *inode); |
| 68 | 69 | int (*release)(struct uio_info *info, struct inode *inode); |
| 70 | + int (*irqcontrol)(struct uio_info *info, s32 irq_on); | |
| 69 | 71 | }; |
| 70 | 72 | |
| 71 | 73 | extern int __must_check |
| @@ -80,11 +82,11 @@ static inline int __must_check · 8 unmodified lines | ||
| 80 | 82 | extern void uio_unregister_device(struct uio_info *info); |
| 81 | 83 | extern void uio_event_notify(struct uio_info *info); |
| 82 | 84 | |
| 83 | −/* defines for uio_device->irq */ | |
| 85 | +/* defines for uio_info->irq */ | |
| 84 | 86 | #define UIO_IRQ_CUSTOM -1 |
| 85 | 87 | #define UIO_IRQ_NONE -2 |
| 86 | 88 | |
| 87 | −/* defines for uio_device->memtype */ | |
| 89 | +/* defines for uio_mem->memtype */ | |
| 88 | 90 | #define UIO_MEM_NONE 0 |
| 89 | 91 | #define UIO_MEM_PHYS 1 |
| 90 | 92 | #define UIO_MEM_LOGICAL 2 |
| @@ -623,7 +623,7 @@ struct Scsi_Host { · 622 unmodified lines | ||
| 623 | 623 | /* |
| 624 | 624 | * Optional work queue to be utilized by the transport |
| 625 | 625 | */ |
| 626 | − char work_q_name[KOBJ_NAME_LEN]; | |
| 626 | + char work_q_name[20]; | |
| 627 | 627 | struct workqueue_struct *work_q; |
| 628 | 628 | |
| 629 | 629 | /* |
| @@ -489,9 +489,9 @@ struct fc_host_attrs { · 488 unmodified lines | ||
| 489 | 489 | u16 npiv_vports_inuse; |
| 490 | 490 | |
| 491 | 491 | /* work queues for rport state manipulation */ |
| 492 | − char work_q_name[KOBJ_NAME_LEN]; | |
| 492 | + char work_q_name[20]; | |
| 493 | 493 | struct workqueue_struct *work_q; |
| 494 | − char devloss_work_q_name[KOBJ_NAME_LEN]; | |
| 494 | + char devloss_work_q_name[20]; | |
| 495 | 495 | struct workqueue_struct *devloss_work_q; |
| 496 | 496 | }; |
| 497 | 497 | |
| @@ -198,7 +198,7 @@ struct iscsi_cls_host { · 197 unmodified lines | ||
| 198 | 198 | atomic_t nr_scans; |
| 199 | 199 | struct mutex mutex; |
| 200 | 200 | struct workqueue_struct *scan_workq; |
| 201 | − char scan_workq_name[KOBJ_NAME_LEN]; | |
| 201 | + char scan_workq_name[20]; | |
| 202 | 202 | }; |
| 203 | 203 | |
| 204 | 204 | extern void iscsi_host_for_each_session(struct Scsi_Host *shost, |
| @@ -297,8 +297,8 @@ static int test_func(void *data) · 296 unmodified lines | ||
| 297 | 297 | * |
| 298 | 298 | * opcode:data |
| 299 | 299 | */ |
| 300 | −static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf, | |
| 301 | − size_t count) | |
| 300 | +static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribute *attr, | |
| 301 | + const char *buf, size_t count) | |
| 302 | 302 | { |
| 303 | 303 | struct sched_param schedpar; |
| 304 | 304 | struct test_thread_data *td; |
| @@ -360,7 +360,8 @@ static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf, · 55 unmodified lines | ||
| 360 | 360 | * @dev: thread to query |
| 361 | 361 | * @buf: char buffer to be filled with thread status info |
| 362 | 362 | */ |
| 363 | −static ssize_t sysfs_test_status(struct sys_device *dev, char *buf) | |
| 363 | +static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute *attr, | |
| 364 | + char *buf) | |
| 364 | 365 | { |
| 365 | 366 | struct test_thread_data *td; |
| 366 | 367 | struct task_struct *tsk; |
| @@ -7737,11 +7737,13 @@ static ssize_t sched_power_savings_store(const char *buf, size_t count, int smt) · 7736 unmodified lines | ||
| 7737 | 7737 | } |
| 7738 | 7738 | |
| 7739 | 7739 | #ifdef CONFIG_SCHED_MC |
| 7740 | −static ssize_t sched_mc_power_savings_show(struct sys_device *dev, char *page) | |
| 7740 | +static ssize_t sched_mc_power_savings_show(struct sys_device *dev, | |
| 7741 | + struct sysdev_attribute *attr, char *page) | |
| 7741 | 7742 | { |
| 7742 | 7743 | return sprintf(page, "%u\n", sched_mc_power_savings); |
| 7743 | 7744 | } |
| 7744 | 7745 | static ssize_t sched_mc_power_savings_store(struct sys_device *dev, |
| 7746 | + struct sysdev_attribute *attr, | |
| 7745 | 7747 | const char *buf, size_t count) |
| 7746 | 7748 | { |
| 7747 | 7749 | return sched_power_savings_store(buf, count, 0); |
| @@ -7751,11 +7753,13 @@ static SYSDEV_ATTR(sched_mc_power_savings, 0644, sched_mc_power_savings_show, · 3 unmodified lines | ||
| 7751 | 7753 | #endif |
| 7752 | 7754 | |
| 7753 | 7755 | #ifdef CONFIG_SCHED_SMT |
| 7754 | −static ssize_t sched_smt_power_savings_show(struct sys_device *dev, char *page) | |
| 7756 | +static ssize_t sched_smt_power_savings_show(struct sys_device *dev, | |
| 7757 | + struct sysdev_attribute *attr, char *page) | |
| 7755 | 7758 | { |
| 7756 | 7759 | return sprintf(page, "%u\n", sched_smt_power_savings); |
| 7757 | 7760 | } |
| 7758 | 7761 | static ssize_t sched_smt_power_savings_store(struct sys_device *dev, |
| 7762 | + struct sysdev_attribute *attr, | |
| 7759 | 7763 | const char *buf, size_t count) |
| 7760 | 7764 | { |
| 7761 | 7765 | return sched_power_savings_store(buf, count, 1); |
| @@ -376,7 +376,8 @@ void clocksource_unregister(struct clocksource *cs) · 375 unmodified lines | ||
| 376 | 376 | * Provides sysfs interface for listing current clocksource. |
| 377 | 377 | */ |
| 378 | 378 | static ssize_t |
| 379 | −sysfs_show_current_clocksources(struct sys_device *dev, char *buf) | |
| 379 | +sysfs_show_current_clocksources(struct sys_device *dev, | |
| 380 | + struct sysdev_attribute *attr, char *buf) | |
| 380 | 381 | { |
| 381 | 382 | ssize_t count = 0; |
| 382 | 383 | |
| @@ -397,6 +398,7 @@ sysfs_show_current_clocksources(struct sys_device *dev, char *buf) · 14 unmodified lines | ||
| 397 | 398 | * clocksource selction. |
| 398 | 399 | */ |
| 399 | 400 | static ssize_t sysfs_override_clocksource(struct sys_device *dev, |
| 401 | + struct sysdev_attribute *attr, | |
| 400 | 402 | const char *buf, size_t count) |
| 401 | 403 | { |
| 402 | 404 | struct clocksource *ovr = NULL; |
| @@ -449,7 +451,9 @@ static ssize_t sysfs_override_clocksource(struct sys_device *dev, · 46 unmodified lines | ||
| 449 | 451 | * Provides sysfs interface for listing registered clocksources |
| 450 | 452 | */ |
| 451 | 453 | static ssize_t |
| 452 | −sysfs_show_available_clocksources(struct sys_device *dev, char *buf) | |
| 454 | +sysfs_show_available_clocksources(struct sys_device *dev, | |
| 455 | + struct sysdev_attribute *attr, | |
| 456 | + char *buf) | |
| 453 | 457 | { |
| 454 | 458 | struct clocksource *src; |
| 455 | 459 | ssize_t count = 0; |
| @@ -74,6 +74,9 @@ config DEBUG_FS · 73 unmodified lines | ||
| 74 | 74 | debugging files into. Enable this option to be able to read and |
| 75 | 75 | write to these files. |
| 76 | 76 | |
| 77 | + For detailed documentation on the debugfs API, see | |
| 78 | + Documentation/DocBook/filesystems. | |
| 79 | + | |
| 77 | 80 | If unsure, say N. |
| 78 | 81 | |
| 79 | 82 | config HEADERS_CHECK |
| @@ -216,13 +216,19 @@ static int kobject_add_internal(struct kobject *kobj) · 215 unmodified lines | ||
| 216 | 216 | static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, |
| 217 | 217 | va_list vargs) |
| 218 | 218 | { |
| 219 | − /* Free the old name, if necessary. */ | |
| 220 | − kfree(kobj->name); | |
| 219 | + const char *old_name = kobj->name; | |
| 220 | + char *s; | |
| 221 | 221 | |
| 222 | 222 | kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs); |
| 223 | 223 | if (!kobj->name) |
| 224 | 224 | return -ENOMEM; |
| 225 | 225 | |
| 226 | + /* ewww... some of these buggers have '/' in the name ... */ | |
| 227 | + s = strchr(kobj->name, '/'); | |
| 228 | + if (s) | |
| 229 | + s[0] = '!'; | |
| 230 | + | |
| 231 | + kfree(old_name); | |
| 226 | 232 | return 0; |
| 227 | 233 | } |
| 228 | 234 | |
| @@ -245,7 +245,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, · 244 unmodified lines | ||
| 245 | 245 | if (retval) |
| 246 | 246 | goto exit; |
| 247 | 247 | |
| 248 | − call_usermodehelper(argv[0], argv, env->envp, UMH_WAIT_EXEC); | |
| 248 | + retval = call_usermodehelper(argv[0], argv, | |
| 249 | + env->envp, UMH_WAIT_EXEC); | |
| 249 | 250 | } |
| 250 | 251 | |
| 251 | 252 | exit: |
| @@ -398,10 +398,6 @@ int hci_register_sysfs(struct hci_dev *hdev) · 397 unmodified lines | ||
| 398 | 398 | if (device_create_file(dev, bt_attrs[i]) < 0) |
| 399 | 399 | BT_ERR("Failed to create device attribute"); |
| 400 | 400 | |
| 401 | − if (sysfs_create_link(&bt_class->subsys.kobj, | |
| 402 | − &dev->kobj, kobject_name(&dev->kobj)) < 0) | |
| 403 | − BT_ERR("Failed to create class symlink"); | |
| 404 | − | |
| 405 | 401 | return 0; |
| 406 | 402 | } |
| 407 | 403 | |
| @@ -409,9 +405,6 @@ void hci_unregister_sysfs(struct hci_dev *hdev) · 1 unmodified line | ||
| 409 | 405 | { |
| 410 | 406 | BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); |
| 411 | 407 | |
| 412 | − sysfs_remove_link(&bt_class->subsys.kobj, | |
| 413 | − kobject_name(&hdev->dev.kobj)); | |
| 414 | − | |
| 415 | 408 | device_del(&hdev->dev); |
| 416 | 409 | } |
| 417 | 410 | |
| @@ -124,7 +124,7 @@ static int fw_setup_class_device(struct class_device *class_dev, · 123 unmodified lines | ||
| 124 | 124 | class_dev->class_id[BUS_ID_SIZE-1] = '\0'; |
| 125 | 125 | class_dev->dev = device; |
| 126 | 126 | |
| 127 | − class_dev->class = &firmware_class, | |
| 127 | + class_dev->class = &firmware_class; | |
| 128 | 128 | class_set_devdata(class_dev, fw_priv); |
| 129 | 129 | retval = class_device_register(class_dev); |
| 130 | 130 | if (retval) { |
| @@ -211,7 +211,7 @@ static struct foo_obj *create_foo_obj(const char *name) · 210 unmodified lines | ||
| 211 | 211 | */ |
| 212 | 212 | retval = kobject_init_and_add(&foo->kobj, &foo_ktype, NULL, "%s", name); |
| 213 | 213 | if (retval) { |
| 214 | − kfree(foo); | |
| 214 | + kobject_put(&foo->kobj); | |
| 215 | 215 | return NULL; |
| 216 | 216 | } |
| 217 | 217 | |
| @@ -340,11 +340,18 @@ static int do_acpi_entry(const char *filename, · 339 unmodified lines | ||
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /* looks like: "pnp:dD" */ |
| 343 | −static int do_pnp_entry(const char *filename, | |
| 344 | − struct pnp_device_id *id, char *alias) | |
| 343 | +static void do_pnp_device_entry(void *symval, unsigned long size, | |
| 344 | + struct module *mod) | |
| 345 | 345 | { |
| 346 | − sprintf(alias, "pnp:d%s*", id->id); | |
| 347 | − return 1; | |
| 346 | + const unsigned long id_size = sizeof(struct pnp_device_id); | |
| 347 | + const struct pnp_device_id *id = symval; | |
| 348 | + | |
| 349 | + device_id_check(mod->name, "pnp", size, id_size, symval); | |
| 350 | + | |
| 351 | + buf_printf(&mod->dev_table_buf, | |
| 352 | + "MODULE_ALIAS(\"pnp:d%s*\");\n", id->id); | |
| 353 | + buf_printf(&mod->dev_table_buf, | |
| 354 | + "MODULE_ALIAS(\"acpi*:%s:*\");\n", id->id); | |
| 348 | 355 | } |
| 349 | 356 | |
| 350 | 357 | /* looks like: "pnp:dD" for every device of the card */ |
| @@ -388,9 +395,12 @@ static void do_pnp_card_entries(void *symval, unsigned long size, · 37 unmodified lines | ||
| 388 | 395 | } |
| 389 | 396 | |
| 390 | 397 | /* add an individual alias for every device entry */ |
| 391 | − if (!dup) | |
| 398 | + if (!dup) { | |
| 392 | 399 | buf_printf(&mod->dev_table_buf, |
| 393 | 400 | "MODULE_ALIAS(\"pnp:d%s*\");\n", id); |
| 401 | + buf_printf(&mod->dev_table_buf, | |
| 402 | + "MODULE_ALIAS(\"acpi*:%s:*\");\n", id); | |
| 403 | + } | |
| 394 | 404 | } |
| 395 | 405 | } |
| 396 | 406 | } |
| @@ -701,9 +711,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, · 304 unmodified lines | ||
| 701 | 711 | sizeof(struct acpi_device_id), "acpi", |
| 702 | 712 | do_acpi_entry, mod); |
| 703 | 713 | else if (sym_is(symname, "__mod_pnp_device_table")) |
| 704 | − do_table(symval, sym->st_size, | |
| 705 | − sizeof(struct pnp_device_id), "pnp", | |
| 706 | − do_pnp_entry, mod); | |
| 714 | + do_pnp_device_entry(symval, sym->st_size, mod); | |
| 707 | 715 | else if (sym_is(symname, "__mod_pnp_card_device_table")) |
| 708 | 716 | do_pnp_card_entries(symval, sym->st_size, mod); |
| 709 | 717 | else if (sym_is(symname, "__mod_pcmcia_device_table")) |
| @@ -548,8 +548,9 @@ int snd_card_register(struct snd_card *card) · 547 unmodified lines | ||
| 548 | 548 | snd_assert(card != NULL, return -EINVAL); |
| 549 | 549 | #ifndef CONFIG_SYSFS_DEPRECATED |
| 550 | 550 | if (!card->card_dev) { |
| 551 | − card->card_dev = device_create(sound_class, card->dev, 0, | |
| 552 | − "card%i", card->number); | |
| 551 | + card->card_dev = device_create_drvdata(sound_class, card->dev, | |
| 552 | + MKDEV(0, 0), NULL, | |
| 553 | + "card%i", card->number); | |
| 553 | 554 | if (IS_ERR(card->card_dev)) |
| 554 | 555 | card->card_dev = NULL; |
| 555 | 556 | } |
| @@ -560,17 +560,19 @@ static int __init oss_init(void) · 559 unmodified lines | ||
| 560 | 560 | sound_dmap_flag = (dmabuf > 0 ? 1 : 0); |
| 561 | 561 | |
| 562 | 562 | for (i = 0; i < ARRAY_SIZE(dev_list); i++) { |
| 563 | − device_create(sound_class, NULL, | |
| 564 | − MKDEV(SOUND_MAJOR, dev_list[i].minor), | |
| 565 | − "%s", dev_list[i].name); | |
| 563 | + device_create_drvdata(sound_class, NULL, | |
| 564 | + MKDEV(SOUND_MAJOR, dev_list[i].minor), | |
| 565 | + NULL, "%s", dev_list[i].name); | |
| 566 | 566 | |
| 567 | 567 | if (!dev_list[i].num) |
| 568 | 568 | continue; |
| 569 | 569 | |
| 570 | 570 | for (j = 1; j < *dev_list[i].num; j++) |
| 571 | − device_create(sound_class, NULL, | |
| 572 | − MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)), | |
| 573 | − "%s%d", dev_list[i].name, j); | |
| 571 | + device_create_drvdata(sound_class, NULL, | |
| 572 | + MKDEV(SOUND_MAJOR, | |
| 573 | + dev_list[i].minor + (j*0x10)), | |
| 574 | + NULL, | |
| 575 | + "%s%d", dev_list[i].name, j); | |
| 574 | 576 | } |
| 575 | 577 | |
| 576 | 578 | if (sound_nblocks >= 1024) |
| @@ -171,8 +171,9 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati · 170 unmodified lines | ||
| 171 | 171 | else |
| 172 | 172 | sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP); |
| 173 | 173 | |
| 174 | − device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor), | |
| 175 | − s->name+6); | |
| 174 | + device_create_drvdata(sound_class, dev, | |
| 175 | + MKDEV(SOUND_MAJOR, s->unit_minor), | |
| 176 | + NULL, s->name+6); | |
| 176 | 177 | return r; |
| 177 | 178 | |
| 178 | 179 | fail: |