mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 11:16:11 +00:00
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* 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 ...
This commit is contained in:
commit
53baaaa968
173 changed files with 2525 additions and 768 deletions
20
Documentation/ABI/testing/sysfs-dev
Normal file
20
Documentation/ABI/testing/sysfs-dev
Normal file
|
@ -0,0 +1,20 @@
|
|||
What: /sys/dev
|
||||
Date: April 2008
|
||||
KernelVersion: 2.6.26
|
||||
Contact: Dan Williams <dan.j.williams@intel.com>
|
||||
Description: The /sys/dev tree provides a method to look up the sysfs
|
||||
path for a device using the information returned from
|
||||
stat(2). There are two directories, 'block' and 'char',
|
||||
beneath /sys/dev containing symbolic links with names of
|
||||
the form "<major>:<minor>". These links point to the
|
||||
corresponding sysfs path for the given device.
|
||||
|
||||
Example:
|
||||
$ readlink /sys/dev/block/8:32
|
||||
../../block/sdc
|
||||
|
||||
Entries in /sys/dev/char and /sys/dev/block will be
|
||||
dynamically created and destroyed as devices enter and
|
||||
leave the system.
|
||||
|
||||
Users: mdadm <linux-raid@vger.kernel.org>
|
|
@ -21,6 +21,18 @@
|
|||
</affiliation>
|
||||
</author>
|
||||
|
||||
<copyright>
|
||||
<year>2006-2008</year>
|
||||
<holder>Hans-Jürgen Koch.</holder>
|
||||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
<para>
|
||||
This documentation is Free Software licensed under the terms of the
|
||||
GPL version 2.
|
||||
</para>
|
||||
</legalnotice>
|
||||
|
||||
<pubdate>2006-12-11</pubdate>
|
||||
|
||||
<abstract>
|
||||
|
@ -29,6 +41,12 @@
|
|||
</abstract>
|
||||
|
||||
<revhistory>
|
||||
<revision>
|
||||
<revnumber>0.5</revnumber>
|
||||
<date>2008-05-22</date>
|
||||
<authorinitials>hjk</authorinitials>
|
||||
<revremark>Added description of write() function.</revremark>
|
||||
</revision>
|
||||
<revision>
|
||||
<revnumber>0.4</revnumber>
|
||||
<date>2007-11-26</date>
|
||||
|
@ -57,20 +75,9 @@
|
|||
</bookinfo>
|
||||
|
||||
<chapter id="aboutthisdoc">
|
||||
<?dbhtml filename="about.html"?>
|
||||
<?dbhtml filename="aboutthis.html"?>
|
||||
<title>About this document</title>
|
||||
|
||||
<sect1 id="copyright">
|
||||
<?dbhtml filename="copyright.html"?>
|
||||
<title>Copyright and License</title>
|
||||
<para>
|
||||
Copyright (c) 2006 by Hans-Jürgen Koch.</para>
|
||||
<para>
|
||||
This documentation is Free Software licensed under the terms of the
|
||||
GPL version 2.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="translations">
|
||||
<?dbhtml filename="translations.html"?>
|
||||
<title>Translations</title>
|
||||
|
@ -189,6 +196,30 @@ interested in translating it, please email me
|
|||
represents the total interrupt count. You can use this number
|
||||
to figure out if you missed some interrupts.
|
||||
</para>
|
||||
<para>
|
||||
For some hardware that has more than one interrupt source internally,
|
||||
but not separate IRQ mask and status registers, there might be
|
||||
situations where userspace cannot determine what the interrupt source
|
||||
was if the kernel handler disables them by writing to the chip's IRQ
|
||||
register. In such a case, the kernel has to disable the IRQ completely
|
||||
to leave the chip's register untouched. Now the userspace part can
|
||||
determine the cause of the interrupt, but it cannot re-enable
|
||||
interrupts. Another cornercase is chips where re-enabling interrupts
|
||||
is a read-modify-write operation to a combined IRQ status/acknowledge
|
||||
register. This would be racy if a new interrupt occurred
|
||||
simultaneously.
|
||||
</para>
|
||||
<para>
|
||||
To address these problems, UIO also implements a write() function. It
|
||||
is normally not used and can be ignored for hardware that has only a
|
||||
single interrupt source or has separate IRQ mask and status registers.
|
||||
If you need it, however, a write to <filename>/dev/uioX</filename>
|
||||
will call the <function>irqcontrol()</function> function implemented
|
||||
by the driver. You have to write a 32-bit value that is usually either
|
||||
0 or 1 to disable or enable interrupts. If a driver does not implement
|
||||
<function>irqcontrol()</function>, <function>write()</function> will
|
||||
return with <varname>-ENOSYS</varname>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To handle interrupts properly, your custom kernel module can
|
||||
|
@ -362,6 +393,14 @@ device is actually used.
|
|||
<function>open()</function>, you will probably also want a custom
|
||||
<function>release()</function> function.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
<varname>int (*irqcontrol)(struct uio_info *info, s32 irq_on)
|
||||
</varname>: Optional. If you need to be able to enable or disable
|
||||
interrupts from userspace by writing to <filename>/dev/uioX</filename>,
|
||||
you can implement this function. The parameter <varname>irq_on</varname>
|
||||
will be 0 to disable interrupts and 1 to enable them.
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
|
|
|
@ -358,7 +358,7 @@ Here is a list of some of the different kernel trees available:
|
|||
- pcmcia, Dominik Brodowski <linux@dominikbrodowski.net>
|
||||
git.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git
|
||||
|
||||
- SCSI, James Bottomley <James.Bottomley@SteelEye.com>
|
||||
- SCSI, James Bottomley <James.Bottomley@hansenpartnership.com>
|
||||
git.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git
|
||||
|
||||
- x86, Ingo Molnar <mingo@elte.hu>
|
||||
|
|
|
@ -248,6 +248,7 @@ The top level sysfs directory looks like:
|
|||
block/
|
||||
bus/
|
||||
class/
|
||||
dev/
|
||||
devices/
|
||||
firmware/
|
||||
net/
|
||||
|
@ -274,6 +275,11 @@ fs/ contains a directory for some filesystems. Currently each
|
|||
filesystem wanting to export attributes must create its own hierarchy
|
||||
below fs/ (see ./fuse.txt for an example).
|
||||
|
||||
dev/ contains two directories char/ and block/. Inside these two
|
||||
directories there are symlinks named <major>:<minor>. These symlinks
|
||||
point to the sysfs directory for the given device. /sys/dev provides a
|
||||
quick way to lookup the sysfs interface for a device from the result of
|
||||
a stat(2) operation.
|
||||
|
||||
More information can driver-model specific features can be found in
|
||||
Documentation/driver-model/.
|
||||
|
|
|
@ -3,9 +3,8 @@ Rules on how to access information in the Linux kernel sysfs
|
|||
The kernel-exported sysfs exports internal kernel implementation details
|
||||
and depends on internal kernel structures and layout. It is agreed upon
|
||||
by the kernel developers that the Linux kernel does not provide a stable
|
||||
internal API. As sysfs is a direct export of kernel internal
|
||||
structures, the sysfs interface cannot provide a stable interface either;
|
||||
it may always change along with internal kernel changes.
|
||||
internal API. Therefore, there are aspects of the sysfs interface that
|
||||
may not be stable across kernel releases.
|
||||
|
||||
To minimize the risk of breaking users of sysfs, which are in most cases
|
||||
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,
|
|||
|
||||
device_info = kmalloc(sizeof(struct dmabounce_device_info), GFP_ATOMIC);
|
||||
if (!device_info) {
|
||||
printk(KERN_ERR
|
||||
"Could not allocated dmabounce_device_info for %s",
|
||||
dev->bus_id);
|
||||
dev_err(dev,
|
||||
"Could not allocated dmabounce_device_info\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -594,8 +593,7 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
|
|||
|
||||
dev->archdata.dmabounce = device_info;
|
||||
|
||||
printk(KERN_INFO "dmabounce: registered device %s on %s bus\n",
|
||||
dev->bus_id, dev->bus->name);
|
||||
dev_info(dev, "dmabounce: registered device\n");
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -614,16 +612,15 @@ dmabounce_unregister_dev(struct device *dev)
|
|||
dev->archdata.dmabounce = NULL;
|
||||
|
||||
if (!device_info) {
|
||||
printk(KERN_WARNING
|
||||
"%s: Never registered with dmabounce but attempting" \
|
||||
"to unregister!\n", dev->bus_id);
|
||||
dev_warn(dev,
|
||||
"Never registered with dmabounce but attempting"
|
||||
"to unregister!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!list_empty(&device_info->safe_buffers)) {
|
||||
printk(KERN_ERR
|
||||
"%s: Removing from dmabounce with pending buffers!\n",
|
||||
dev->bus_id);
|
||||
dev_err(dev,
|
||||
"Removing from dmabounce with pending buffers!\n");
|
||||
BUG();
|
||||
}
|
||||
|
||||
|
@ -639,8 +636,7 @@ dmabounce_unregister_dev(struct device *dev)
|
|||
|
||||
kfree(device_info);
|
||||
|
||||
printk(KERN_INFO "dmabounce: device %s on %s bus unregistered\n",
|
||||
dev->bus_id, dev->bus->name);
|
||||
dev_info(dev, "dmabounce: device unregistered\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -543,7 +543,6 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)
|
|||
goto out;
|
||||
}
|
||||
|
||||
strncpy(dev->dev.bus_id, info->name, sizeof(dev->dev.bus_id));
|
||||
/*
|
||||
* If the parent device has a DMA mask associated with it,
|
||||
* propagate it down to the children.
|
||||
|
@ -553,6 +552,7 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)
|
|||
dev->dev.dma_mask = &dev->dma_mask;
|
||||
}
|
||||
|
||||
dev_set_name(&dev->dev, "%s", info->name);
|
||||
dev->devid = info->devid;
|
||||
dev->dev.parent = lchip->dev;
|
||||
dev->dev.bus = &locomo_bus_type;
|
||||
|
|
|
@ -550,9 +550,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
|
|||
goto out;
|
||||
}
|
||||
|
||||
snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id),
|
||||
"%4.4lx", info->offset);
|
||||
|
||||
dev_set_name(&dev->dev, "%4.4lx", info->offset);
|
||||
dev->devid = info->devid;
|
||||
dev->dev.parent = sachip->dev;
|
||||
dev->dev.bus = &sa1111_bus_type;
|
||||
|
@ -560,7 +558,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
|
|||
dev->dev.coherent_dma_mask = sachip->dev->coherent_dma_mask;
|
||||
dev->res.start = sachip->phys + info->offset;
|
||||
dev->res.end = dev->res.start + 511;
|
||||
dev->res.name = dev->dev.bus_id;
|
||||
dev->res.name = dev_name(&dev->dev);
|
||||
dev->res.flags = IORESOURCE_MEM;
|
||||
dev->mapbase = sachip->base + info->offset;
|
||||
dev->skpcr_mask = info->skpcr_mask;
|
||||
|
@ -570,6 +568,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
|
|||
if (ret) {
|
||||
printk("SA1111: failed to allocate resource for %s\n",
|
||||
dev->res.name);
|
||||
dev_set_name(&dev->dev, NULL);
|
||||
kfree(dev);
|
||||
goto out;
|
||||
}
|
||||
|
@ -593,7 +592,8 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
|
|||
if (dev->dma_mask != 0xffffffffUL) {
|
||||
ret = dmabounce_register_dev(&dev->dev, 1024, 4096);
|
||||
if (ret) {
|
||||
printk("SA1111: Failed to register %s with dmabounce", dev->dev.bus_id);
|
||||
dev_err(&dev->dev, "SA1111: Failed to register"
|
||||
" with dmabounce\n");
|
||||
device_unregister(&dev->dev);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ static int __devinit scoop_probe(struct platform_device *pdev)
|
|||
devptr->gpio.base = -1;
|
||||
|
||||
if (inf->gpio_base != 0) {
|
||||
devptr->gpio.label = pdev->dev.bus_id;
|
||||
devptr->gpio.label = dev_name(&pdev->dev);
|
||||
devptr->gpio.base = inf->gpio_base;
|
||||
devptr->gpio.ngpio = 12; /* PA11 = 0, PA12 = 1, etc. up to PA22 = 11 */
|
||||
devptr->gpio.set = scoop_gpio_set;
|
||||
|
|
|
@ -783,7 +783,7 @@ static void ecard_proc_init(void)
|
|||
|
||||
#define ec_set_resource(ec,nr,st,sz) \
|
||||
do { \
|
||||
(ec)->resource[nr].name = ec->dev.bus_id; \
|
||||
(ec)->resource[nr].name = dev_name(&ec->dev); \
|
||||
(ec)->resource[nr].start = st; \
|
||||
(ec)->resource[nr].end = (st) + (sz) - 1; \
|
||||
(ec)->resource[nr].flags = IORESOURCE_MEM; \
|
||||
|
@ -853,8 +853,7 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
|
|||
for (i = 0; i < ECARD_NUM_RESOURCES; i++) {
|
||||
if (ec->resource[i].flags &&
|
||||
request_resource(&iomem_resource, &ec->resource[i])) {
|
||||
printk(KERN_ERR "%s: resource(s) not available\n",
|
||||
ec->dev.bus_id);
|
||||
dev_err(&ec->dev, "resource(s) not available\n");
|
||||
ec->resource[i].end -= ec->resource[i].start;
|
||||
ec->resource[i].start = 0;
|
||||
ec->resource[i].flags = 0;
|
||||
|
|
|
@ -130,7 +130,9 @@ static const struct leds_evt_name evt_names[] = {
|
|||
{ "red", led_red_on, led_red_off },
|
||||
};
|
||||
|
||||
static ssize_t leds_store(struct sys_device *dev, const char *buf, size_t size)
|
||||
static ssize_t leds_store(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
int ret = -EINVAL, len = strcspn(buf, " ");
|
||||
|
||||
|
|
|
@ -393,9 +393,7 @@ static int impd1_probe(struct lm_device *dev)
|
|||
if (!d)
|
||||
continue;
|
||||
|
||||
snprintf(d->dev.bus_id, sizeof(d->dev.bus_id),
|
||||
"lm%x:%5.5lx", dev->id, idev->offset >> 12);
|
||||
|
||||
dev_set_name(&d->dev, "lm%x:%5.5lx", dev->id, idev->offset >> 12);
|
||||
d->dev.parent = &dev->dev;
|
||||
d->res.start = dev->resource.start + idev->offset;
|
||||
d->res.end = d->res.start + SZ_4K - 1;
|
||||
|
@ -407,8 +405,7 @@ static int impd1_probe(struct lm_device *dev)
|
|||
|
||||
ret = amba_device_register(d, &dev->resource);
|
||||
if (ret) {
|
||||
printk("unable to register device %s: %d\n",
|
||||
d->dev.bus_id, ret);
|
||||
dev_err(&d->dev, "unable to register device: %d\n");
|
||||
kfree(d);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,8 +81,10 @@ int lm_device_register(struct lm_device *dev)
|
|||
dev->dev.release = lm_device_release;
|
||||
dev->dev.bus = &lm_bustype;
|
||||
|
||||
snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), "lm%d", dev->id);
|
||||
dev->resource.name = dev->dev.bus_id;
|
||||
ret = dev_set_name(&dev->dev, "lm%d", dev->id);
|
||||
if (ret)
|
||||
return ret;
|
||||
dev->resource.name = dev_name(&dev->dev);
|
||||
|
||||
ret = request_resource(&iomem_resource, &dev->resource);
|
||||
if (ret == 0) {
|
||||
|
|
|
@ -334,7 +334,7 @@ static int omap_mbox_init(struct omap_mbox *mbox)
|
|||
}
|
||||
|
||||
mbox->dev.class = &omap_mbox_class;
|
||||
strlcpy(mbox->dev.bus_id, mbox->name, KOBJ_NAME_LEN);
|
||||
dev_set_name(&mbox->dev, "%s", mbox->name);
|
||||
dev_set_drvdata(&mbox->dev, mbox);
|
||||
|
||||
ret = device_register(&mbox->dev);
|
||||
|
|
|
@ -26,14 +26,16 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
|
|||
* XXX: If/when a SMP-capable implementation of AVR32 will ever be
|
||||
* made, we must make sure that the code executes on the correct CPU.
|
||||
*/
|
||||
static ssize_t show_pc0event(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_pc0event(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
unsigned long pccr;
|
||||
|
||||
pccr = sysreg_read(PCCR);
|
||||
return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f);
|
||||
}
|
||||
static ssize_t store_pc0event(struct sys_device *dev, const char *buf,
|
||||
static ssize_t store_pc0event(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
unsigned long val;
|
||||
|
@ -46,15 +48,17 @@ static ssize_t store_pc0event(struct sys_device *dev, const char *buf,
|
|||
sysreg_write(PCCR, val);
|
||||
return count;
|
||||
}
|
||||
static ssize_t show_pc0count(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_pc0count(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
unsigned long pcnt0;
|
||||
|
||||
pcnt0 = sysreg_read(PCNT0);
|
||||
return sprintf(buf, "%lu\n", pcnt0);
|
||||
}
|
||||
static ssize_t store_pc0count(struct sys_device *dev, const char *buf,
|
||||
size_t count)
|
||||
static ssize_t store_pc0count(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
unsigned long val;
|
||||
char *endp;
|
||||
|
@ -67,14 +71,16 @@ static ssize_t store_pc0count(struct sys_device *dev, const char *buf,
|
|||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_pc1event(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_pc1event(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
unsigned long pccr;
|
||||
|
||||
pccr = sysreg_read(PCCR);
|
||||
return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f);
|
||||
}
|
||||
static ssize_t store_pc1event(struct sys_device *dev, const char *buf,
|
||||
static ssize_t store_pc1event(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
unsigned long val;
|
||||
|
@ -87,14 +93,16 @@ static ssize_t store_pc1event(struct sys_device *dev, const char *buf,
|
|||
sysreg_write(PCCR, val);
|
||||
return count;
|
||||
}
|
||||
static ssize_t show_pc1count(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_pc1count(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
unsigned long pcnt1;
|
||||
|
||||
pcnt1 = sysreg_read(PCNT1);
|
||||
return sprintf(buf, "%lu\n", pcnt1);
|
||||
}
|
||||
static ssize_t store_pc1count(struct sys_device *dev, const char *buf,
|
||||
static ssize_t store_pc1count(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
unsigned long val;
|
||||
|
@ -108,14 +116,16 @@ static ssize_t store_pc1count(struct sys_device *dev, const char *buf,
|
|||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_pccycles(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_pccycles(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
unsigned long pccnt;
|
||||
|
||||
pccnt = sysreg_read(PCCNT);
|
||||
return sprintf(buf, "%lu\n", pccnt);
|
||||
}
|
||||
static ssize_t store_pccycles(struct sys_device *dev, const char *buf,
|
||||
static ssize_t store_pccycles(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
unsigned long val;
|
||||
|
@ -129,14 +139,16 @@ static ssize_t store_pccycles(struct sys_device *dev, const char *buf,
|
|||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_pcenable(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_pcenable(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
unsigned long pccr;
|
||||
|
||||
pccr = sysreg_read(PCCR);
|
||||
return sprintf(buf, "%c\n", (pccr & 1)?'1':'0');
|
||||
}
|
||||
static ssize_t store_pcenable(struct sys_device *dev, const char *buf,
|
||||
static ssize_t store_pcenable(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
unsigned long pccr, val;
|
||||
|
|
|
@ -55,7 +55,8 @@ static u64 resources[NR_CPUS];
|
|||
|
||||
#define show(name) \
|
||||
static ssize_t \
|
||||
show_##name(struct sys_device *dev, char *buf) \
|
||||
show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \
|
||||
char *buf) \
|
||||
{ \
|
||||
u32 cpu=dev->id; \
|
||||
return sprintf(buf, "%lx\n", name[cpu]); \
|
||||
|
@ -63,7 +64,8 @@ show_##name(struct sys_device *dev, char *buf) \
|
|||
|
||||
#define store(name) \
|
||||
static ssize_t \
|
||||
store_##name(struct sys_device *dev, const char *buf, size_t size) \
|
||||
store_##name(struct sys_device *dev, struct sysdev_attribute *attr, \
|
||||
const char *buf, size_t size) \
|
||||
{ \
|
||||
unsigned int cpu=dev->id; \
|
||||
name[cpu] = simple_strtoull(buf, NULL, 16); \
|
||||
|
@ -76,7 +78,8 @@ show(call_start)
|
|||
* processor. The cpu number in driver is only used for storing data.
|
||||
*/
|
||||
static ssize_t
|
||||
store_call_start(struct sys_device *dev, const char *buf, size_t size)
|
||||
store_call_start(struct sys_device *dev, struct sysdev_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
unsigned int cpu=dev->id;
|
||||
unsigned long call_start = simple_strtoull(buf, NULL, 16);
|
||||
|
@ -124,14 +127,16 @@ show(err_type_info)
|
|||
store(err_type_info)
|
||||
|
||||
static ssize_t
|
||||
show_virtual_to_phys(struct sys_device *dev, char *buf)
|
||||
show_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
unsigned int cpu=dev->id;
|
||||
return sprintf(buf, "%lx\n", phys_addr[cpu]);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
store_virtual_to_phys(struct sys_device *dev, const char *buf, size_t size)
|
||||
store_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
unsigned int cpu=dev->id;
|
||||
u64 virt_addr=simple_strtoull(buf, NULL, 16);
|
||||
|
@ -154,7 +159,8 @@ show(err_struct_info)
|
|||
store(err_struct_info)
|
||||
|
||||
static ssize_t
|
||||
show_err_data_buffer(struct sys_device *dev, char *buf)
|
||||
show_err_data_buffer(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
unsigned int cpu=dev->id;
|
||||
|
||||
|
@ -165,7 +171,9 @@ show_err_data_buffer(struct sys_device *dev, char *buf)
|
|||
}
|
||||
|
||||
static ssize_t
|
||||
store_err_data_buffer(struct sys_device *dev, const char *buf, size_t size)
|
||||
store_err_data_buffer(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
unsigned int cpu=dev->id;
|
||||
int ret;
|
||||
|
|
|
@ -522,8 +522,8 @@ static int __init rtlx_module_init(void)
|
|||
atomic_set(&channel_wqs[i].in_open, 0);
|
||||
mutex_init(&channel_wqs[i].mutex);
|
||||
|
||||
dev = device_create(mt_class, NULL, MKDEV(major, i),
|
||||
"%s%d", module_name, i);
|
||||
dev = device_create_drvdata(mt_class, NULL, MKDEV(major, i),
|
||||
NULL, "%s%d", module_name, i);
|
||||
if (IS_ERR(dev)) {
|
||||
err = PTR_ERR(dev);
|
||||
goto out_chrdev;
|
||||
|
|
|
@ -576,7 +576,8 @@ static int __init sbprof_tb_init(void)
|
|||
|
||||
tb_class = tbc;
|
||||
|
||||
dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), "tb");
|
||||
dev = device_create_drvdata(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0),
|
||||
NULL, "tb");
|
||||
if (IS_ERR(dev)) {
|
||||
err = PTR_ERR(dev);
|
||||
goto out_class;
|
||||
|
|
|
@ -28,7 +28,9 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
|
|||
/* Time in microseconds we delay before sleeping in the idle loop */
|
||||
DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 };
|
||||
|
||||
static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf,
|
||||
static ssize_t store_smt_snooze_delay(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
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,
|
|||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_smt_snooze_delay(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_smt_snooze_delay(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct cpu *cpu = container_of(dev, struct cpu, sysdev);
|
||||
|
||||
|
@ -152,14 +156,17 @@ static unsigned long write_##NAME(unsigned long val) \
|
|||
mtspr(ADDRESS, val); \
|
||||
return 0; \
|
||||
} \
|
||||
static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
|
||||
static ssize_t show_##NAME(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, \
|
||||
char *buf) \
|
||||
{ \
|
||||
struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
|
||||
unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \
|
||||
return sprintf(buf, "%lx\n", val); \
|
||||
} \
|
||||
static ssize_t __used \
|
||||
store_##NAME(struct sys_device *dev, const char *buf, size_t count) \
|
||||
store_##NAME(struct sys_device *dev, struct sysdev_attribute *attr, \
|
||||
const char *buf, size_t count) \
|
||||
{ \
|
||||
struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
|
||||
unsigned long val; \
|
||||
|
|
|
@ -97,7 +97,8 @@ static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iom
|
|||
return value.spe[spu->spe_id];
|
||||
}
|
||||
|
||||
static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf)
|
||||
static ssize_t spu_show_temp(struct sys_device *sysdev, struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
u8 value;
|
||||
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
|
|||
return size;
|
||||
}
|
||||
|
||||
static ssize_t spu_show_throttle_end(struct sys_device *sysdev, char *buf)
|
||||
static ssize_t spu_show_throttle_end(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return show_throttle(get_pmd_regs(sysdev), buf, 0);
|
||||
}
|
||||
|
||||
static ssize_t spu_show_throttle_begin(struct sys_device *sysdev, char *buf)
|
||||
static ssize_t spu_show_throttle_begin(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return show_throttle(get_pmd_regs(sysdev), buf, 8);
|
||||
}
|
||||
|
||||
static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev, char *buf)
|
||||
static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return show_throttle(get_pmd_regs(sysdev), buf, 16);
|
||||
}
|
||||
|
||||
static ssize_t spu_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size)
|
||||
static ssize_t spu_store_throttle_end(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, const char *buf, size_t size)
|
||||
{
|
||||
return store_throttle(get_pmd_regs(sysdev), buf, size, 0);
|
||||
}
|
||||
|
||||
static ssize_t spu_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size)
|
||||
static ssize_t spu_store_throttle_begin(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, const char *buf, size_t size)
|
||||
{
|
||||
return store_throttle(get_pmd_regs(sysdev), buf, size, 8);
|
||||
}
|
||||
|
||||
static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size)
|
||||
static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, const char *buf, size_t size)
|
||||
{
|
||||
return store_throttle(get_pmd_regs(sysdev), buf, size, 16);
|
||||
}
|
||||
|
@ -192,43 +199,51 @@ static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos)
|
|||
|
||||
/* shows the temperature of the DTS on the PPE,
|
||||
* located near the linear thermal sensor */
|
||||
static ssize_t ppe_show_temp0(struct sys_device *sysdev, char *buf)
|
||||
static ssize_t ppe_show_temp0(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return ppe_show_temp(sysdev, buf, 32);
|
||||
}
|
||||
|
||||
/* shows the temperature of the second DTS on the PPE */
|
||||
static ssize_t ppe_show_temp1(struct sys_device *sysdev, char *buf)
|
||||
static ssize_t ppe_show_temp1(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return ppe_show_temp(sysdev, buf, 0);
|
||||
}
|
||||
|
||||
static ssize_t ppe_show_throttle_end(struct sys_device *sysdev, char *buf)
|
||||
static ssize_t ppe_show_throttle_end(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 32);
|
||||
}
|
||||
|
||||
static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev, char *buf)
|
||||
static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 40);
|
||||
}
|
||||
|
||||
static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev, char *buf)
|
||||
static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 48);
|
||||
}
|
||||
|
||||
static ssize_t ppe_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size)
|
||||
static ssize_t ppe_store_throttle_end(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, const char *buf, size_t size)
|
||||
{
|
||||
return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 32);
|
||||
}
|
||||
|
||||
static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size)
|
||||
static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, const char *buf, size_t size)
|
||||
{
|
||||
return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 40);
|
||||
}
|
||||
|
||||
static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size)
|
||||
static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, const char *buf, size_t size)
|
||||
{
|
||||
return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 48);
|
||||
}
|
||||
|
|
|
@ -703,7 +703,8 @@ static unsigned long long spu_acct_time(struct spu *spu,
|
|||
}
|
||||
|
||||
|
||||
static ssize_t spu_stat_show(struct sys_device *sysdev, char *buf)
|
||||
static ssize_t spu_stat_show(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct spu *spu = container_of(sysdev, struct spu, sysdev);
|
||||
|
||||
|
|
|
@ -367,7 +367,7 @@ static void chrp_pci_fixup_vt8231_ata(struct pci_dev *viaide)
|
|||
viaisa = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL);
|
||||
if (!viaisa)
|
||||
return;
|
||||
printk("Fixing VIA IDE, force legacy mode on '%s'\n", viaide->dev.bus_id);
|
||||
dev_info(&viaide->dev, "Fixing VIA IDE, force legacy mode on\n");
|
||||
|
||||
pci_read_config_byte(viaide, PCI_CLASS_PROG, &progif);
|
||||
pci_write_config_byte(viaide, PCI_CLASS_PROG, progif & ~0x5);
|
||||
|
|
|
@ -864,7 +864,8 @@ int setup_profiling_timer(unsigned int multiplier)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_HOTPLUG_CPU
|
||||
static ssize_t cpu_configure_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t cpu_configure_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
ssize_t count;
|
||||
|
||||
|
@ -874,8 +875,9 @@ static ssize_t cpu_configure_show(struct sys_device *dev, char *buf)
|
|||
return count;
|
||||
}
|
||||
|
||||
static ssize_t cpu_configure_store(struct sys_device *dev, const char *buf,
|
||||
size_t count)
|
||||
static ssize_t cpu_configure_store(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
int cpu = dev->id;
|
||||
int val, rc;
|
||||
|
@ -922,7 +924,8 @@ out:
|
|||
static SYSDEV_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store);
|
||||
#endif /* CONFIG_HOTPLUG_CPU */
|
||||
|
||||
static ssize_t cpu_polarization_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t cpu_polarization_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
int cpu = dev->id;
|
||||
ssize_t count;
|
||||
|
@ -950,7 +953,8 @@ static ssize_t cpu_polarization_show(struct sys_device *dev, char *buf)
|
|||
}
|
||||
static SYSDEV_ATTR(polarization, 0444, cpu_polarization_show, NULL);
|
||||
|
||||
static ssize_t show_cpu_address(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_cpu_address(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%d\n", __cpu_logical_map[dev->id]);
|
||||
}
|
||||
|
@ -970,7 +974,8 @@ static struct attribute_group cpu_common_attr_group = {
|
|||
.attrs = cpu_common_attrs,
|
||||
};
|
||||
|
||||
static ssize_t show_capability(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_capability(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
unsigned int capability;
|
||||
int rc;
|
||||
|
@ -982,7 +987,8 @@ static ssize_t show_capability(struct sys_device *dev, char *buf)
|
|||
}
|
||||
static SYSDEV_ATTR(capability, 0444, show_capability, NULL);
|
||||
|
||||
static ssize_t show_idle_count(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_idle_count(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct s390_idle_data *idle;
|
||||
unsigned long long idle_count;
|
||||
|
@ -995,7 +1001,8 @@ static ssize_t show_idle_count(struct sys_device *dev, char *buf)
|
|||
}
|
||||
static SYSDEV_ATTR(idle_count, 0444, show_idle_count, NULL);
|
||||
|
||||
static ssize_t show_idle_time(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_idle_time(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct s390_idle_data *idle;
|
||||
unsigned long long new_time;
|
||||
|
@ -1112,7 +1119,9 @@ out:
|
|||
return rc;
|
||||
}
|
||||
|
||||
static ssize_t __ref rescan_store(struct sys_device *dev, const char *buf,
|
||||
static ssize_t __ref rescan_store(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
int rc;
|
||||
|
@ -1123,7 +1132,9 @@ static ssize_t __ref rescan_store(struct sys_device *dev, const char *buf,
|
|||
static SYSDEV_ATTR(rescan, 0200, NULL, rescan_store);
|
||||
#endif /* CONFIG_HOTPLUG_CPU */
|
||||
|
||||
static ssize_t dispatching_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t dispatching_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
ssize_t count;
|
||||
|
||||
|
@ -1133,8 +1144,9 @@ static ssize_t dispatching_show(struct sys_device *dev, char *buf)
|
|||
return count;
|
||||
}
|
||||
|
||||
static ssize_t dispatching_store(struct sys_device *dev, const char *buf,
|
||||
size_t count)
|
||||
static ssize_t dispatching_store(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
int val, rc;
|
||||
char delim;
|
||||
|
|
|
@ -1100,7 +1100,9 @@ static inline struct etr_aib *etr_aib_from_dev(struct sys_device *dev)
|
|||
return etr_port1_online ? &etr_port1 : NULL;
|
||||
}
|
||||
|
||||
static ssize_t etr_online_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t etr_online_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
unsigned int online;
|
||||
|
||||
|
@ -1109,7 +1111,8 @@ static ssize_t etr_online_show(struct sys_device *dev, char *buf)
|
|||
}
|
||||
|
||||
static ssize_t etr_online_store(struct sys_device *dev,
|
||||
const char *buf, size_t count)
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
unsigned int value;
|
||||
|
||||
|
@ -1136,7 +1139,9 @@ static ssize_t etr_online_store(struct sys_device *dev,
|
|||
|
||||
static SYSDEV_ATTR(online, 0600, etr_online_show, etr_online_store);
|
||||
|
||||
static ssize_t etr_stepping_control_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t etr_stepping_control_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
return sprintf(buf, "%i\n", (dev == &etr_port0_dev) ?
|
||||
etr_eacr.e0 : etr_eacr.e1);
|
||||
|
@ -1144,7 +1149,8 @@ static ssize_t etr_stepping_control_show(struct sys_device *dev, char *buf)
|
|||
|
||||
static SYSDEV_ATTR(stepping_control, 0400, etr_stepping_control_show, NULL);
|
||||
|
||||
static ssize_t etr_mode_code_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t etr_mode_code_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
if (!etr_port0_online && !etr_port1_online)
|
||||
/* 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)
|
|||
|
||||
static SYSDEV_ATTR(state_code, 0400, etr_mode_code_show, NULL);
|
||||
|
||||
static ssize_t etr_untuned_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t etr_untuned_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct etr_aib *aib = etr_aib_from_dev(dev);
|
||||
|
||||
|
@ -1166,7 +1173,8 @@ static ssize_t etr_untuned_show(struct sys_device *dev, char *buf)
|
|||
|
||||
static SYSDEV_ATTR(untuned, 0400, etr_untuned_show, NULL);
|
||||
|
||||
static ssize_t etr_network_id_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t etr_network_id_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct etr_aib *aib = etr_aib_from_dev(dev);
|
||||
|
||||
|
@ -1177,7 +1185,8 @@ static ssize_t etr_network_id_show(struct sys_device *dev, char *buf)
|
|||
|
||||
static SYSDEV_ATTR(network, 0400, etr_network_id_show, NULL);
|
||||
|
||||
static ssize_t etr_id_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t etr_id_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct etr_aib *aib = etr_aib_from_dev(dev);
|
||||
|
||||
|
@ -1188,7 +1197,8 @@ static ssize_t etr_id_show(struct sys_device *dev, char *buf)
|
|||
|
||||
static SYSDEV_ATTR(id, 0400, etr_id_show, NULL);
|
||||
|
||||
static ssize_t etr_port_number_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t etr_port_number_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct etr_aib *aib = etr_aib_from_dev(dev);
|
||||
|
||||
|
@ -1199,7 +1209,8 @@ static ssize_t etr_port_number_show(struct sys_device *dev, char *buf)
|
|||
|
||||
static SYSDEV_ATTR(port, 0400, etr_port_number_show, NULL);
|
||||
|
||||
static ssize_t etr_coupled_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t etr_coupled_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct etr_aib *aib = etr_aib_from_dev(dev);
|
||||
|
||||
|
@ -1210,7 +1221,8 @@ static ssize_t etr_coupled_show(struct sys_device *dev, char *buf)
|
|||
|
||||
static SYSDEV_ATTR(coupled, 0400, etr_coupled_show, NULL);
|
||||
|
||||
static ssize_t etr_local_time_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t etr_local_time_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct etr_aib *aib = etr_aib_from_dev(dev);
|
||||
|
||||
|
@ -1221,7 +1233,8 @@ static ssize_t etr_local_time_show(struct sys_device *dev, char *buf)
|
|||
|
||||
static SYSDEV_ATTR(local_time, 0400, etr_local_time_show, NULL);
|
||||
|
||||
static ssize_t etr_utc_offset_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t etr_utc_offset_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct etr_aib *aib = etr_aib_from_dev(dev);
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@ static struct sysdev_class dma_sysclass = {
|
|||
};
|
||||
EXPORT_SYMBOL(dma_sysclass);
|
||||
|
||||
static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
|
||||
static ssize_t dma_show_devices(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
ssize_t len = 0;
|
||||
int i;
|
||||
|
@ -57,13 +58,15 @@ static int __init dma_sysclass_init(void)
|
|||
}
|
||||
postcore_initcall(dma_sysclass_init);
|
||||
|
||||
static ssize_t dma_show_dev_id(struct sys_device *dev, char *buf)
|
||||
static ssize_t dma_show_dev_id(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct dma_channel *channel = to_dma_channel(dev);
|
||||
return sprintf(buf, "%s\n", channel->dev_id);
|
||||
}
|
||||
|
||||
static ssize_t dma_store_dev_id(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct dma_channel *channel = to_dma_channel(dev);
|
||||
|
@ -74,6 +77,7 @@ static ssize_t dma_store_dev_id(struct sys_device *dev,
|
|||
static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id);
|
||||
|
||||
static ssize_t dma_store_config(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct dma_channel *channel = to_dma_channel(dev);
|
||||
|
@ -87,13 +91,15 @@ static ssize_t dma_store_config(struct sys_device *dev,
|
|||
|
||||
static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config);
|
||||
|
||||
static ssize_t dma_show_mode(struct sys_device *dev, char *buf)
|
||||
static ssize_t dma_show_mode(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct dma_channel *channel = to_dma_channel(dev);
|
||||
return sprintf(buf, "0x%08x\n", channel->mode);
|
||||
}
|
||||
|
||||
static ssize_t dma_store_mode(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct dma_channel *channel = to_dma_channel(dev);
|
||||
|
@ -104,7 +110,8 @@ static ssize_t dma_store_mode(struct sys_device *dev,
|
|||
static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode);
|
||||
|
||||
#define dma_ro_attr(field, fmt) \
|
||||
static ssize_t dma_show_##field(struct sys_device *dev, char *buf) \
|
||||
static ssize_t dma_show_##field(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, char *buf)\
|
||||
{ \
|
||||
struct dma_channel *channel = to_dma_channel(dev); \
|
||||
return sprintf(buf, fmt, channel->field); \
|
||||
|
|
|
@ -401,7 +401,7 @@ static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_de
|
|||
dev->ofdev.node = dp;
|
||||
dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
|
||||
dev->ofdev.dev.bus = &ebus_bus_type;
|
||||
sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node);
|
||||
dev_set_name(&dev->ofdev.dev, "ebus[%08x]", dp->node);
|
||||
|
||||
/* Register with core */
|
||||
if (of_device_register(&dev->ofdev) != 0)
|
||||
|
@ -501,7 +501,7 @@ void __init ebus_init(void)
|
|||
ebus->ofdev.node = dp;
|
||||
ebus->ofdev.dev.parent = &pdev->dev;
|
||||
ebus->ofdev.dev.bus = &ebus_bus_type;
|
||||
sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus);
|
||||
dev_set_name(&ebus->ofdev.dev, "ebus%d", num_ebus);
|
||||
|
||||
/* Register with core */
|
||||
if (of_device_register(&ebus->ofdev) != 0)
|
||||
|
|
|
@ -797,9 +797,9 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
|
|||
op->dev.parent = parent;
|
||||
op->dev.bus = &of_platform_bus_type;
|
||||
if (!parent)
|
||||
strcpy(op->dev.bus_id, "root");
|
||||
dev_set_name(&op->dev, "root");
|
||||
else
|
||||
sprintf(op->dev.bus_id, "%08x", dp->node);
|
||||
dev_set_name(&op->dev, "%08x", dp->node);
|
||||
|
||||
if (of_device_register(op)) {
|
||||
printk("%s: Could not register of device.\n",
|
||||
|
|
|
@ -408,7 +408,7 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
|
|||
dev->class = class >> 8;
|
||||
dev->revision = class & 0xff;
|
||||
|
||||
sprintf(dev->dev.bus_id, "%04x:%02x:%02x.%d", pci_domain_nr(bus),
|
||||
dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus),
|
||||
dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
|
||||
|
||||
if (ofpci_verbose)
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
static DEFINE_PER_CPU(struct hv_mmu_statistics, mmu_stats) __attribute__((aligned(64)));
|
||||
|
||||
#define SHOW_MMUSTAT_ULONG(NAME) \
|
||||
static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
|
||||
static ssize_t show_##NAME(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, char *buf) \
|
||||
{ \
|
||||
struct hv_mmu_statistics *p = &per_cpu(mmu_stats, dev->id); \
|
||||
return sprintf(buf, "%lu\n", p->NAME); \
|
||||
|
@ -135,13 +136,16 @@ static unsigned long write_mmustat_enable(unsigned long val)
|
|||
return sun4v_mmustat_conf(ra, &orig_ra);
|
||||
}
|
||||
|
||||
static ssize_t show_mmustat_enable(struct sys_device *s, char *buf)
|
||||
static ssize_t show_mmustat_enable(struct sys_device *s,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
unsigned long val = run_on_cpu(s->id, read_mmustat_enable, 0);
|
||||
return sprintf(buf, "%lx\n", val);
|
||||
}
|
||||
|
||||
static ssize_t store_mmustat_enable(struct sys_device *s, const char *buf, size_t count)
|
||||
static ssize_t store_mmustat_enable(struct sys_device *s,
|
||||
struct sysdev_attribute *attr, const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
unsigned long val, err;
|
||||
int ret = sscanf(buf, "%ld", &val);
|
||||
|
@ -179,14 +183,16 @@ static void unregister_mmu_stats(struct sys_device *s)
|
|||
#endif
|
||||
|
||||
#define SHOW_CPUDATA_ULONG_NAME(NAME, MEMBER) \
|
||||
static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
|
||||
static ssize_t show_##NAME(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, char *buf) \
|
||||
{ \
|
||||
cpuinfo_sparc *c = &cpu_data(dev->id); \
|
||||
return sprintf(buf, "%lu\n", c->MEMBER); \
|
||||
}
|
||||
|
||||
#define SHOW_CPUDATA_UINT_NAME(NAME, MEMBER) \
|
||||
static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
|
||||
static ssize_t show_##NAME(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, char *buf) \
|
||||
{ \
|
||||
cpuinfo_sparc *c = &cpu_data(dev->id); \
|
||||
return sprintf(buf, "%u\n", c->MEMBER); \
|
||||
|
|
|
@ -224,7 +224,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
|
|||
if (!strcmp(type, "domain-services-port"))
|
||||
bus_id_name = "ds";
|
||||
|
||||
if (strlen(bus_id_name) >= KOBJ_NAME_LEN - 4) {
|
||||
if (strlen(bus_id_name) >= BUS_ID_SIZE - 4) {
|
||||
printk(KERN_ERR "VIO: bus_id_name [%s] is too long.\n",
|
||||
bus_id_name);
|
||||
return NULL;
|
||||
|
@ -260,16 +260,14 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
|
|||
vio_fill_channel_info(hp, mp, vdev);
|
||||
|
||||
if (!id) {
|
||||
snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s",
|
||||
bus_id_name);
|
||||
dev_set_name(&vdev->dev, "%s", bus_id_name);
|
||||
vdev->dev_no = ~(u64)0;
|
||||
} else if (!cfg_handle) {
|
||||
snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s-%lu",
|
||||
bus_id_name, *id);
|
||||
dev_set_name(&vdev->dev, "%s-%lu", bus_id_name, *id);
|
||||
vdev->dev_no = *id;
|
||||
} else {
|
||||
snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s-%lu-%lu",
|
||||
bus_id_name, *cfg_handle, *id);
|
||||
dev_set_name(&vdev->dev, "%s-%lu-%lu", bus_id_name,
|
||||
*cfg_handle, *id);
|
||||
vdev->dev_no = *cfg_handle;
|
||||
}
|
||||
|
||||
|
@ -292,12 +290,12 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
|
|||
}
|
||||
vdev->dp = dp;
|
||||
|
||||
printk(KERN_INFO "VIO: Adding device %s\n", vdev->dev.bus_id);
|
||||
printk(KERN_INFO "VIO: Adding device %s\n", dev_name(&vdev->dev));
|
||||
|
||||
err = device_register(&vdev->dev);
|
||||
if (err) {
|
||||
printk(KERN_ERR "VIO: Could not register device %s, err=%d\n",
|
||||
vdev->dev.bus_id, err);
|
||||
dev_name(&vdev->dev), err);
|
||||
kfree(vdev);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -330,7 +328,7 @@ static void vio_remove(struct mdesc_handle *hp, u64 node)
|
|||
dev = device_find_child(&root_vdev->dev, (void *) node,
|
||||
vio_md_node_match);
|
||||
if (dev) {
|
||||
printk(KERN_INFO "VIO: Removing device %s\n", dev->bus_id);
|
||||
printk(KERN_INFO "VIO: Removing device %s\n", dev_name(dev));
|
||||
|
||||
device_unregister(dev);
|
||||
}
|
||||
|
|
|
@ -762,10 +762,14 @@ DEFINE_PER_CPU(struct sys_device, device_mce);
|
|||
|
||||
/* Why are there no generic functions for this? */
|
||||
#define ACCESSOR(name, var, start) \
|
||||
static ssize_t show_ ## name(struct sys_device *s, char *buf) { \
|
||||
static ssize_t show_ ## name(struct sys_device *s, \
|
||||
struct sysdev_attribute *attr, \
|
||||
char *buf) { \
|
||||
return sprintf(buf, "%lx\n", (unsigned long)var); \
|
||||
} \
|
||||
static ssize_t set_ ## name(struct sys_device *s,const char *buf,size_t siz) { \
|
||||
static ssize_t set_ ## name(struct sys_device *s, \
|
||||
struct sysdev_attribute *attr, \
|
||||
const char *buf, size_t siz) { \
|
||||
char *end; \
|
||||
unsigned long new = simple_strtoul(buf, &end, 0); \
|
||||
if (end == buf) return -EINVAL; \
|
||||
|
@ -786,14 +790,16 @@ ACCESSOR(bank3ctl,bank[3],mce_restart())
|
|||
ACCESSOR(bank4ctl,bank[4],mce_restart())
|
||||
ACCESSOR(bank5ctl,bank[5],mce_restart())
|
||||
|
||||
static ssize_t show_trigger(struct sys_device *s, char *buf)
|
||||
static ssize_t show_trigger(struct sys_device *s, struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
strcpy(buf, trigger);
|
||||
strcat(buf, "\n");
|
||||
return strlen(trigger) + 1;
|
||||
}
|
||||
|
||||
static ssize_t set_trigger(struct sys_device *s,const char *buf,size_t siz)
|
||||
static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr,
|
||||
const char *buf,size_t siz)
|
||||
{
|
||||
char *p;
|
||||
int len;
|
||||
|
@ -806,12 +812,12 @@ static ssize_t set_trigger(struct sys_device *s,const char *buf,size_t siz)
|
|||
}
|
||||
|
||||
static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger);
|
||||
ACCESSOR(tolerant,tolerant,)
|
||||
static SYSDEV_INT_ATTR(tolerant, 0644, tolerant);
|
||||
ACCESSOR(check_interval,check_interval,mce_restart())
|
||||
static struct sysdev_attribute *mce_attributes[] = {
|
||||
&attr_bank0ctl, &attr_bank1ctl, &attr_bank2ctl,
|
||||
&attr_bank3ctl, &attr_bank4ctl, &attr_bank5ctl,
|
||||
&attr_tolerant, &attr_check_interval, &attr_trigger,
|
||||
&attr_tolerant.attr, &attr_check_interval, &attr_trigger,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ atomic_t therm_throt_en = ATOMIC_INIT(0);
|
|||
|
||||
#define define_therm_throt_sysdev_show_func(name) \
|
||||
static ssize_t therm_throt_sysdev_show_##name(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, \
|
||||
char *buf) \
|
||||
{ \
|
||||
unsigned int cpu = dev->id; \
|
||||
|
|
|
@ -141,8 +141,8 @@ static __cpuinit int cpuid_device_create(int cpu)
|
|||
{
|
||||
struct device *dev;
|
||||
|
||||
dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu),
|
||||
"cpu%d", cpu);
|
||||
dev = device_create_drvdata(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu),
|
||||
NULL, "cpu%d", cpu);
|
||||
return IS_ERR(dev) ? PTR_ERR(dev) : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -644,7 +644,9 @@ static void microcode_fini_cpu(int cpu)
|
|||
mutex_unlock(µcode_mutex);
|
||||
}
|
||||
|
||||
static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz)
|
||||
static ssize_t reload_store(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t sz)
|
||||
{
|
||||
struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
|
||||
char *end;
|
||||
|
@ -674,14 +676,16 @@ static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz)
|
|||
return sz;
|
||||
}
|
||||
|
||||
static ssize_t version_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t version_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
|
||||
|
||||
return sprintf(buf, "0x%x\n", uci->rev);
|
||||
}
|
||||
|
||||
static ssize_t pf_show(struct sys_device *dev, char *buf)
|
||||
static ssize_t pf_show(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
|
||||
|
||||
|
|
|
@ -149,8 +149,8 @@ static int __cpuinit msr_device_create(int cpu)
|
|||
{
|
||||
struct device *dev;
|
||||
|
||||
dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu),
|
||||
"msr%d", cpu);
|
||||
dev = device_create_drvdata(msr_class, NULL, MKDEV(MSR_MAJOR, cpu),
|
||||
NULL, "msr%d", cpu);
|
||||
return IS_ERR(dev) ? PTR_ERR(dev) : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -314,8 +314,7 @@ int dma_supported(struct device *dev, u64 mask)
|
|||
{
|
||||
#ifdef CONFIG_PCI
|
||||
if (mask > 0xffffffff && forbid_dac > 0) {
|
||||
printk(KERN_INFO "PCI: Disallowing DAC for device %s\n",
|
||||
dev->bus_id);
|
||||
dev_info(dev, "PCI: Disallowing DAC for device\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -342,8 +341,7 @@ int dma_supported(struct device *dev, u64 mask)
|
|||
type. Normally this doesn't make any difference, but gives
|
||||
more gentle handling of IOMMU overflow. */
|
||||
if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
|
||||
printk(KERN_INFO "%s: Force SAC with mask %Lx\n",
|
||||
dev->bus_id, mask);
|
||||
dev_info(dev, "Force SAC with mask %Lx\n", mask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -198,9 +198,7 @@ static void iommu_full(struct device *dev, size_t size, int dir)
|
|||
* out. Hopefully no network devices use single mappings that big.
|
||||
*/
|
||||
|
||||
printk(KERN_ERR
|
||||
"PCI-DMA: Out of IOMMU space for %lu bytes at device %s\n",
|
||||
size, dev->bus_id);
|
||||
dev_err(dev, "PCI-DMA: Out of IOMMU space for %lu bytes\n", size);
|
||||
|
||||
if (size > PAGE_SIZE*EMERGENCY_PAGES) {
|
||||
if (dir == PCI_DMA_FROMDEVICE || dir == PCI_DMA_BIDIRECTIONAL)
|
||||
|
|
|
@ -1044,7 +1044,8 @@ int bsg_register_queue(struct request_queue *q, struct device *parent,
|
|||
bcd->release = release;
|
||||
kref_init(&bcd->ref);
|
||||
dev = MKDEV(bsg_major, bcd->minor);
|
||||
class_dev = device_create(bsg_class, parent, dev, "%s", devname);
|
||||
class_dev = device_create_drvdata(bsg_class, parent, dev, NULL,
|
||||
"%s", devname);
|
||||
if (IS_ERR(class_dev)) {
|
||||
ret = PTR_ERR(class_dev);
|
||||
goto put_dev;
|
||||
|
|
209
block/genhd.c
209
block/genhd.c
|
@ -183,6 +183,7 @@ static int exact_lock(dev_t devt, void *data)
|
|||
void add_disk(struct gendisk *disk)
|
||||
{
|
||||
struct backing_dev_info *bdi;
|
||||
int retval;
|
||||
|
||||
disk->flags |= GENHD_FL_UP;
|
||||
blk_register_region(MKDEV(disk->major, disk->first_minor),
|
||||
|
@ -193,7 +194,8 @@ void add_disk(struct gendisk *disk)
|
|||
|
||||
bdi = &disk->queue->backing_dev_info;
|
||||
bdi_register_dev(bdi, MKDEV(disk->major, disk->first_minor));
|
||||
sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
|
||||
retval = sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
|
||||
WARN_ON(retval);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(add_disk);
|
||||
|
@ -224,6 +226,57 @@ struct gendisk *get_gendisk(dev_t devt, int *part)
|
|||
return kobj ? dev_to_disk(dev) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* print a partitions - intended for places where the root filesystem can't be
|
||||
* mounted and thus to give the victim some idea of what went wrong
|
||||
*/
|
||||
static int printk_partition(struct device *dev, void *data)
|
||||
{
|
||||
struct gendisk *sgp;
|
||||
char buf[BDEVNAME_SIZE];
|
||||
int n;
|
||||
|
||||
if (dev->type != &disk_type)
|
||||
goto exit;
|
||||
|
||||
sgp = dev_to_disk(dev);
|
||||
/*
|
||||
* Don't show empty devices or things that have been surpressed
|
||||
*/
|
||||
if (get_capacity(sgp) == 0 ||
|
||||
(sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
|
||||
goto exit;
|
||||
|
||||
/*
|
||||
* Note, unlike /proc/partitions, I am showing the numbers in
|
||||
* hex - the same format as the root= option takes.
|
||||
*/
|
||||
printk("%02x%02x %10llu %s",
|
||||
sgp->major, sgp->first_minor,
|
||||
(unsigned long long)get_capacity(sgp) >> 1,
|
||||
disk_name(sgp, 0, buf));
|
||||
if (sgp->driverfs_dev != NULL &&
|
||||
sgp->driverfs_dev->driver != NULL)
|
||||
printk(" driver: %s\n",
|
||||
sgp->driverfs_dev->driver->name);
|
||||
else
|
||||
printk(" (driver?)\n");
|
||||
|
||||
/* now show the partitions */
|
||||
for (n = 0; n < sgp->minors - 1; ++n) {
|
||||
if (sgp->part[n] == NULL)
|
||||
goto exit;
|
||||
if (sgp->part[n]->nr_sects == 0)
|
||||
goto exit;
|
||||
printk(" %02x%02x %10llu %s\n",
|
||||
sgp->major, n + 1 + sgp->first_minor,
|
||||
(unsigned long long)sgp->part[n]->nr_sects >> 1,
|
||||
disk_name(sgp, n + 1, buf));
|
||||
}
|
||||
exit:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* print a full list of all partitions - intended for places where the root
|
||||
* filesystem can't be mounted and thus to give the victim some idea of what
|
||||
|
@ -231,83 +284,54 @@ struct gendisk *get_gendisk(dev_t devt, int *part)
|
|||
*/
|
||||
void __init printk_all_partitions(void)
|
||||
{
|
||||
struct device *dev;
|
||||
struct gendisk *sgp;
|
||||
char buf[BDEVNAME_SIZE];
|
||||
int n;
|
||||
|
||||
mutex_lock(&block_class_lock);
|
||||
/* For each block device... */
|
||||
list_for_each_entry(dev, &block_class.devices, node) {
|
||||
if (dev->type != &disk_type)
|
||||
continue;
|
||||
sgp = dev_to_disk(dev);
|
||||
/*
|
||||
* Don't show empty devices or things that have been surpressed
|
||||
*/
|
||||
if (get_capacity(sgp) == 0 ||
|
||||
(sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Note, unlike /proc/partitions, I am showing the numbers in
|
||||
* hex - the same format as the root= option takes.
|
||||
*/
|
||||
printk("%02x%02x %10llu %s",
|
||||
sgp->major, sgp->first_minor,
|
||||
(unsigned long long)get_capacity(sgp) >> 1,
|
||||
disk_name(sgp, 0, buf));
|
||||
if (sgp->driverfs_dev != NULL &&
|
||||
sgp->driverfs_dev->driver != NULL)
|
||||
printk(" driver: %s\n",
|
||||
sgp->driverfs_dev->driver->name);
|
||||
else
|
||||
printk(" (driver?)\n");
|
||||
|
||||
/* now show the partitions */
|
||||
for (n = 0; n < sgp->minors - 1; ++n) {
|
||||
if (sgp->part[n] == NULL)
|
||||
continue;
|
||||
if (sgp->part[n]->nr_sects == 0)
|
||||
continue;
|
||||
printk(" %02x%02x %10llu %s\n",
|
||||
sgp->major, n + 1 + sgp->first_minor,
|
||||
(unsigned long long)sgp->part[n]->nr_sects >> 1,
|
||||
disk_name(sgp, n + 1, buf));
|
||||
}
|
||||
}
|
||||
|
||||
class_for_each_device(&block_class, NULL, NULL, printk_partition);
|
||||
mutex_unlock(&block_class_lock);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
/* iterator */
|
||||
static int find_start(struct device *dev, void *data)
|
||||
{
|
||||
loff_t k = *(loff_t *)data;
|
||||
|
||||
if (dev->type != &disk_type)
|
||||
return 0;
|
||||
if (!k--)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *part_start(struct seq_file *part, loff_t *pos)
|
||||
{
|
||||
loff_t k = *pos;
|
||||
struct device *dev;
|
||||
loff_t n = *pos;
|
||||
|
||||
if (!n)
|
||||
seq_puts(part, "major minor #blocks name\n\n");
|
||||
|
||||
mutex_lock(&block_class_lock);
|
||||
list_for_each_entry(dev, &block_class.devices, node) {
|
||||
if (dev->type != &disk_type)
|
||||
continue;
|
||||
if (!k--)
|
||||
return dev_to_disk(dev);
|
||||
}
|
||||
dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
|
||||
if (dev)
|
||||
return dev_to_disk(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int find_next(struct device *dev, void *data)
|
||||
{
|
||||
if (dev->type == &disk_type)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *part_next(struct seq_file *part, void *v, loff_t *pos)
|
||||
{
|
||||
struct gendisk *gp = v;
|
||||
struct device *dev;
|
||||
++*pos;
|
||||
list_for_each_entry(dev, &gp->dev.node, node) {
|
||||
if (&dev->node == &block_class.devices)
|
||||
return NULL;
|
||||
if (dev->type == &disk_type)
|
||||
return dev_to_disk(dev);
|
||||
}
|
||||
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
|
||||
if (dev)
|
||||
return dev_to_disk(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -322,9 +346,6 @@ static int show_partition(struct seq_file *part, void *v)
|
|||
int n;
|
||||
char buf[BDEVNAME_SIZE];
|
||||
|
||||
if (&sgp->dev.node == block_class.devices.next)
|
||||
seq_puts(part, "major minor #blocks name\n\n");
|
||||
|
||||
/* Don't show non-partitionable removeable devices or empty devices */
|
||||
if (!get_capacity(sgp) ||
|
||||
(sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE)))
|
||||
|
@ -370,7 +391,10 @@ static struct kobject *base_probe(dev_t devt, int *part, void *data)
|
|||
|
||||
static int __init genhd_device_init(void)
|
||||
{
|
||||
int error = class_register(&block_class);
|
||||
int error;
|
||||
|
||||
block_class.dev_kobj = sysfs_dev_block_kobj;
|
||||
error = class_register(&block_class);
|
||||
if (unlikely(error))
|
||||
return error;
|
||||
bdev_map = kobj_map_init(base_probe, &block_class_lock);
|
||||
|
@ -532,6 +556,7 @@ static struct device_type disk_type = {
|
|||
.release = disk_release,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
/*
|
||||
* aggregate disk stat collector. Uses the same stats that the sysfs
|
||||
* entries do, above, but makes them available through one seq_file.
|
||||
|
@ -542,16 +567,12 @@ static struct device_type disk_type = {
|
|||
|
||||
static void *diskstats_start(struct seq_file *part, loff_t *pos)
|
||||
{
|
||||
loff_t k = *pos;
|
||||
struct device *dev;
|
||||
|
||||
mutex_lock(&block_class_lock);
|
||||
list_for_each_entry(dev, &block_class.devices, node) {
|
||||
if (dev->type != &disk_type)
|
||||
continue;
|
||||
if (!k--)
|
||||
return dev_to_disk(dev);
|
||||
}
|
||||
dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
|
||||
if (dev)
|
||||
return dev_to_disk(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -561,12 +582,9 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
|
|||
struct device *dev;
|
||||
|
||||
++*pos;
|
||||
list_for_each_entry(dev, &gp->dev.node, node) {
|
||||
if (&dev->node == &block_class.devices)
|
||||
return NULL;
|
||||
if (dev->type == &disk_type)
|
||||
return dev_to_disk(dev);
|
||||
}
|
||||
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
|
||||
if (dev)
|
||||
return dev_to_disk(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -641,6 +659,7 @@ const struct seq_operations diskstats_op = {
|
|||
.stop = diskstats_stop,
|
||||
.show = diskstats_show
|
||||
};
|
||||
#endif /* CONFIG_PROC_FS */
|
||||
|
||||
static void media_change_notify_thread(struct work_struct *work)
|
||||
{
|
||||
|
@ -665,24 +684,38 @@ void genhd_media_change_notify(struct gendisk *disk)
|
|||
EXPORT_SYMBOL_GPL(genhd_media_change_notify);
|
||||
#endif /* 0 */
|
||||
|
||||
struct find_block {
|
||||
const char *name;
|
||||
int part;
|
||||
};
|
||||
|
||||
static int match_id(struct device *dev, void *data)
|
||||
{
|
||||
struct find_block *find = data;
|
||||
|
||||
if (dev->type != &disk_type)
|
||||
return 0;
|
||||
if (strcmp(dev->bus_id, find->name) == 0) {
|
||||
struct gendisk *disk = dev_to_disk(dev);
|
||||
if (find->part < disk->minors)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev_t blk_lookup_devt(const char *name, int part)
|
||||
{
|
||||
struct device *dev;
|
||||
dev_t devt = MKDEV(0, 0);
|
||||
struct find_block find;
|
||||
|
||||
mutex_lock(&block_class_lock);
|
||||
list_for_each_entry(dev, &block_class.devices, node) {
|
||||
if (dev->type != &disk_type)
|
||||
continue;
|
||||
if (strcmp(dev->bus_id, name) == 0) {
|
||||
struct gendisk *disk = dev_to_disk(dev);
|
||||
|
||||
if (part < disk->minors)
|
||||
devt = MKDEV(MAJOR(dev->devt),
|
||||
MINOR(dev->devt) + part);
|
||||
break;
|
||||
}
|
||||
}
|
||||
find.name = name;
|
||||
find.part = part;
|
||||
dev = class_find_device(&block_class, NULL, (void *)&find, match_id);
|
||||
if (dev)
|
||||
devt = MKDEV(MAJOR(dev->devt),
|
||||
MINOR(dev->devt) + part);
|
||||
mutex_unlock(&block_class_lock);
|
||||
|
||||
return devt;
|
||||
|
|
|
@ -263,22 +263,22 @@ static int acpi_fan_add(struct acpi_device *device)
|
|||
goto end;
|
||||
}
|
||||
|
||||
printk(KERN_INFO PREFIX
|
||||
"%s is registered as cooling_device%d\n",
|
||||
device->dev.bus_id, cdev->id);
|
||||
dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id);
|
||||
|
||||
acpi_driver_data(device) = cdev;
|
||||
result = sysfs_create_link(&device->dev.kobj,
|
||||
&cdev->device.kobj,
|
||||
"thermal_cooling");
|
||||
if (result)
|
||||
printk(KERN_ERR PREFIX "Create sysfs link\n");
|
||||
dev_err(&device->dev, "Failed to create sysfs link "
|
||||
"'thermal_cooling'\n");
|
||||
|
||||
result = sysfs_create_link(&cdev->device.kobj,
|
||||
&device->dev.kobj,
|
||||
"device");
|
||||
if (result)
|
||||
printk(KERN_ERR PREFIX "Create sysfs link\n");
|
||||
dev_err(&device->dev, "Failed to create sysfs link "
|
||||
"'device'\n");
|
||||
|
||||
result = acpi_fan_add_fs(device);
|
||||
if (result)
|
||||
|
|
|
@ -146,8 +146,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
|
|||
acpi_status status;
|
||||
|
||||
if (dev->archdata.acpi_handle) {
|
||||
printk(KERN_WARNING PREFIX
|
||||
"Drivers changed 'acpi_handle' for %s\n", dev->bus_id);
|
||||
dev_warn(dev, "Drivers changed 'acpi_handle'\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
get_device(dev);
|
||||
|
@ -195,8 +194,7 @@ static int acpi_unbind_one(struct device *dev)
|
|||
/* acpi_bind_one increase refcnt by one */
|
||||
put_device(dev);
|
||||
} else {
|
||||
printk(KERN_ERR PREFIX
|
||||
"Oops, 'acpi_handle' corrupt for %s\n", dev->bus_id);
|
||||
dev_err(dev, "Oops, 'acpi_handle' corrupt\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -714,9 +714,8 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
|
|||
goto end;
|
||||
}
|
||||
|
||||
printk(KERN_INFO PREFIX
|
||||
"%s is registered as cooling_device%d\n",
|
||||
device->dev.bus_id, pr->cdev->id);
|
||||
dev_info(&device->dev, "registered as cooling_device%d\n",
|
||||
pr->cdev->id);
|
||||
|
||||
result = sysfs_create_link(&device->dev.kobj,
|
||||
&pr->cdev->device.kobj,
|
||||
|
|
|
@ -471,7 +471,7 @@ static int acpi_device_register(struct acpi_device *device,
|
|||
device->dev.release = &acpi_device_release;
|
||||
result = device_add(&device->dev);
|
||||
if(result) {
|
||||
printk(KERN_ERR PREFIX "Error adding device %s", device->dev.bus_id);
|
||||
dev_err(&device->dev, "Error adding device\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
|
@ -1179,8 +1179,8 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
|
|||
|
||||
tz->tz_enabled = 1;
|
||||
|
||||
printk(KERN_INFO PREFIX "%s is registered as thermal_zone%d\n",
|
||||
tz->device->dev.bus_id, tz->thermal_zone->id);
|
||||
dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
|
||||
tz->thermal_zone->id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -762,9 +762,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
|
|||
if (IS_ERR(device->cdev))
|
||||
return;
|
||||
|
||||
printk(KERN_INFO PREFIX
|
||||
"%s is registered as cooling_device%d\n",
|
||||
device->dev->dev.bus_id, device->cdev->id);
|
||||
dev_info(&device->dev->dev, "registered as cooling_device%d\n",
|
||||
device->cdev->id);
|
||||
result = sysfs_create_link(&device->dev->dev.kobj,
|
||||
&device->cdev->device.kobj,
|
||||
"thermal_cooling");
|
||||
|
|
|
@ -27,8 +27,9 @@ config PREVENT_FIRMWARE_BUILD
|
|||
If unsure say Y here.
|
||||
|
||||
config FW_LOADER
|
||||
tristate "Userspace firmware loading support"
|
||||
tristate "Userspace firmware loading support" if EMBEDDED
|
||||
depends on HOTPLUG
|
||||
default y
|
||||
---help---
|
||||
This option is provided for the case where no in-kernel-tree modules
|
||||
require userspace firmware loading support, but a module built outside
|
||||
|
|
|
@ -36,6 +36,33 @@ struct driver_private {
|
|||
};
|
||||
#define to_driver(obj) container_of(obj, struct driver_private, kobj)
|
||||
|
||||
|
||||
/**
|
||||
* struct class_private - structure to hold the private to the driver core portions of the class structure.
|
||||
*
|
||||
* @class_subsys - the struct kset that defines this class. This is the main kobject
|
||||
* @class_devices - list of devices associated with this class
|
||||
* @class_interfaces - list of class_interfaces associated with this class
|
||||
* @class_dirs - "glue" directory for virtual devices associated with this class
|
||||
* @class_mutex - mutex to protect the children, devices, and interfaces lists.
|
||||
* @class - pointer back to the struct class that this structure is associated
|
||||
* with.
|
||||
*
|
||||
* This structure is the one that is the actual kobject allowing struct
|
||||
* class to be statically allocated safely. Nothing outside of the driver
|
||||
* core should ever touch these fields.
|
||||
*/
|
||||
struct class_private {
|
||||
struct kset class_subsys;
|
||||
struct list_head class_devices;
|
||||
struct list_head class_interfaces;
|
||||
struct kset class_dirs;
|
||||
struct mutex class_mutex;
|
||||
struct class *class;
|
||||
};
|
||||
#define to_class(obj) \
|
||||
container_of(obj, struct class_private, class_subsys.kobj)
|
||||
|
||||
/* initialisation functions */
|
||||
extern int devices_init(void);
|
||||
extern int buses_init(void);
|
||||
|
|
|
@ -18,20 +18,20 @@
|
|||
#include <linux/err.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/genhd.h>
|
||||
#include <linux/mutex.h>
|
||||
#include "base.h"
|
||||
|
||||
#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
|
||||
#define to_class(obj) container_of(obj, struct class, subsys.kobj)
|
||||
|
||||
static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct class_attribute *class_attr = to_class_attr(attr);
|
||||
struct class *dc = to_class(kobj);
|
||||
struct class_private *cp = to_class(kobj);
|
||||
ssize_t ret = -EIO;
|
||||
|
||||
if (class_attr->show)
|
||||
ret = class_attr->show(dc, buf);
|
||||
ret = class_attr->show(cp->class, buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -39,17 +39,18 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
|
|||
const char *buf, size_t count)
|
||||
{
|
||||
struct class_attribute *class_attr = to_class_attr(attr);
|
||||
struct class *dc = to_class(kobj);
|
||||
struct class_private *cp = to_class(kobj);
|
||||
ssize_t ret = -EIO;
|
||||
|
||||
if (class_attr->store)
|
||||
ret = class_attr->store(dc, buf, count);
|
||||
ret = class_attr->store(cp->class, buf, count);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void class_release(struct kobject *kobj)
|
||||
{
|
||||
struct class *class = to_class(kobj);
|
||||
struct class_private *cp = to_class(kobj);
|
||||
struct class *class = cp->class;
|
||||
|
||||
pr_debug("class '%s': release.\n", class->name);
|
||||
|
||||
|
@ -70,7 +71,7 @@ static struct kobj_type class_ktype = {
|
|||
.release = class_release,
|
||||
};
|
||||
|
||||
/* Hotplug events for classes go to the class_obj subsys */
|
||||
/* Hotplug events for classes go to the class class_subsys */
|
||||
static struct kset *class_kset;
|
||||
|
||||
|
||||
|
@ -78,7 +79,8 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
|
|||
{
|
||||
int error;
|
||||
if (cls)
|
||||
error = sysfs_create_file(&cls->subsys.kobj, &attr->attr);
|
||||
error = sysfs_create_file(&cls->p->class_subsys.kobj,
|
||||
&attr->attr);
|
||||
else
|
||||
error = -EINVAL;
|
||||
return error;
|
||||
|
@ -87,21 +89,20 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
|
|||
void class_remove_file(struct class *cls, const struct class_attribute *attr)
|
||||
{
|
||||
if (cls)
|
||||
sysfs_remove_file(&cls->subsys.kobj, &attr->attr);
|
||||
sysfs_remove_file(&cls->p->class_subsys.kobj, &attr->attr);
|
||||
}
|
||||
|
||||
static struct class *class_get(struct class *cls)
|
||||
{
|
||||
if (cls)
|
||||
return container_of(kset_get(&cls->subsys),
|
||||
struct class, subsys);
|
||||
return NULL;
|
||||
kset_get(&cls->p->class_subsys);
|
||||
return cls;
|
||||
}
|
||||
|
||||
static void class_put(struct class *cls)
|
||||
{
|
||||
if (cls)
|
||||
kset_put(&cls->subsys);
|
||||
kset_put(&cls->p->class_subsys);
|
||||
}
|
||||
|
||||
static int add_class_attrs(struct class *cls)
|
||||
|
@ -134,42 +135,57 @@ static void remove_class_attrs(struct class *cls)
|
|||
}
|
||||
}
|
||||
|
||||
int class_register(struct class *cls)
|
||||
int __class_register(struct class *cls, struct lock_class_key *key)
|
||||
{
|
||||
struct class_private *cp;
|
||||
int error;
|
||||
|
||||
pr_debug("device class '%s': registering\n", cls->name);
|
||||
|
||||
INIT_LIST_HEAD(&cls->devices);
|
||||
INIT_LIST_HEAD(&cls->interfaces);
|
||||
kset_init(&cls->class_dirs);
|
||||
init_MUTEX(&cls->sem);
|
||||
error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name);
|
||||
if (error)
|
||||
cp = kzalloc(sizeof(*cp), GFP_KERNEL);
|
||||
if (!cp)
|
||||
return -ENOMEM;
|
||||
INIT_LIST_HEAD(&cp->class_devices);
|
||||
INIT_LIST_HEAD(&cp->class_interfaces);
|
||||
kset_init(&cp->class_dirs);
|
||||
__mutex_init(&cp->class_mutex, "struct class mutex", key);
|
||||
error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name);
|
||||
if (error) {
|
||||
kfree(cp);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* set the default /sys/dev directory for devices of this class */
|
||||
if (!cls->dev_kobj)
|
||||
cls->dev_kobj = sysfs_dev_char_kobj;
|
||||
|
||||
#if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK)
|
||||
/* let the block class directory show up in the root of sysfs */
|
||||
if (cls != &block_class)
|
||||
cls->subsys.kobj.kset = class_kset;
|
||||
cp->class_subsys.kobj.kset = class_kset;
|
||||
#else
|
||||
cls->subsys.kobj.kset = class_kset;
|
||||
cp->class_subsys.kobj.kset = class_kset;
|
||||
#endif
|
||||
cls->subsys.kobj.ktype = &class_ktype;
|
||||
cp->class_subsys.kobj.ktype = &class_ktype;
|
||||
cp->class = cls;
|
||||
cls->p = cp;
|
||||
|
||||
error = kset_register(&cls->subsys);
|
||||
if (!error) {
|
||||
error = add_class_attrs(class_get(cls));
|
||||
class_put(cls);
|
||||
error = kset_register(&cp->class_subsys);
|
||||
if (error) {
|
||||
kfree(cp);
|
||||
return error;
|
||||
}
|
||||
error = add_class_attrs(class_get(cls));
|
||||
class_put(cls);
|
||||
return error;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__class_register);
|
||||
|
||||
void class_unregister(struct class *cls)
|
||||
{
|
||||
pr_debug("device class '%s': unregistering\n", cls->name);
|
||||
remove_class_attrs(cls);
|
||||
kset_unregister(&cls->subsys);
|
||||
kset_unregister(&cls->p->class_subsys);
|
||||
}
|
||||
|
||||
static void class_create_release(struct class *cls)
|
||||
|
@ -189,7 +205,8 @@ static void class_create_release(struct class *cls)
|
|||
* Note, the pointer created here is to be destroyed when finished by
|
||||
* making a call to class_destroy().
|
||||
*/
|
||||
struct class *class_create(struct module *owner, const char *name)
|
||||
struct class *__class_create(struct module *owner, const char *name,
|
||||
struct lock_class_key *key)
|
||||
{
|
||||
struct class *cls;
|
||||
int retval;
|
||||
|
@ -204,7 +221,7 @@ struct class *class_create(struct module *owner, const char *name)
|
|||
cls->owner = owner;
|
||||
cls->class_release = class_create_release;
|
||||
|
||||
retval = class_register(cls);
|
||||
retval = __class_register(cls, key);
|
||||
if (retval)
|
||||
goto error;
|
||||
|
||||
|
@ -214,6 +231,7 @@ error:
|
|||
kfree(cls);
|
||||
return ERR_PTR(retval);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__class_create);
|
||||
|
||||
/**
|
||||
* class_destroy - destroys a struct class structure
|
||||
|
@ -252,39 +270,44 @@ char *make_class_name(const char *name, struct kobject *kobj)
|
|||
/**
|
||||
* class_for_each_device - device iterator
|
||||
* @class: the class we're iterating
|
||||
* @start: the device to start with in the list, if any.
|
||||
* @data: data for the callback
|
||||
* @fn: function to be called for each device
|
||||
*
|
||||
* Iterate over @class's list of devices, and call @fn for each,
|
||||
* passing it @data.
|
||||
* passing it @data. If @start is set, the list iteration will start
|
||||
* there, otherwise if it is NULL, the iteration starts at the
|
||||
* beginning of the list.
|
||||
*
|
||||
* We check the return of @fn each time. If it returns anything
|
||||
* other than 0, we break out and return that value.
|
||||
*
|
||||
* Note, we hold class->sem in this function, so it can not be
|
||||
* Note, we hold class->class_mutex in this function, so it can not be
|
||||
* re-acquired in @fn, otherwise it will self-deadlocking. For
|
||||
* example, calls to add or remove class members would be verboten.
|
||||
*/
|
||||
int class_for_each_device(struct class *class, void *data,
|
||||
int (*fn)(struct device *, void *))
|
||||
int class_for_each_device(struct class *class, struct device *start,
|
||||
void *data, int (*fn)(struct device *, void *))
|
||||
{
|
||||
struct device *dev;
|
||||
int error = 0;
|
||||
|
||||
if (!class)
|
||||
return -EINVAL;
|
||||
down(&class->sem);
|
||||
list_for_each_entry(dev, &class->devices, node) {
|
||||
mutex_lock(&class->p->class_mutex);
|
||||
list_for_each_entry(dev, &class->p->class_devices, node) {
|
||||
if (start) {
|
||||
if (start == dev)
|
||||
start = NULL;
|
||||
continue;
|
||||
}
|
||||
dev = get_device(dev);
|
||||
if (dev) {
|
||||
error = fn(dev, data);
|
||||
put_device(dev);
|
||||
} else
|
||||
error = -ENODEV;
|
||||
error = fn(dev, data);
|
||||
put_device(dev);
|
||||
if (error)
|
||||
break;
|
||||
}
|
||||
up(&class->sem);
|
||||
mutex_unlock(&class->p->class_mutex);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -293,6 +316,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
|
|||
/**
|
||||
* class_find_device - device iterator for locating a particular device
|
||||
* @class: the class we're iterating
|
||||
* @start: Device to begin with
|
||||
* @data: data for the match function
|
||||
* @match: function to check device
|
||||
*
|
||||
|
@ -306,12 +330,13 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
|
|||
*
|
||||
* Note, you will need to drop the reference with put_device() after use.
|
||||
*
|
||||
* We hold class->sem in this function, so it can not be
|
||||
* We hold class->class_mutex in this function, so it can not be
|
||||
* re-acquired in @match, otherwise it will self-deadlocking. For
|
||||
* example, calls to add or remove class members would be verboten.
|
||||
*/
|
||||
struct device *class_find_device(struct class *class, void *data,
|
||||
int (*match)(struct device *, void *))
|
||||
struct device *class_find_device(struct class *class, struct device *start,
|
||||
void *data,
|
||||
int (*match)(struct device *, void *))
|
||||
{
|
||||
struct device *dev;
|
||||
int found = 0;
|
||||
|
@ -319,19 +344,21 @@ struct device *class_find_device(struct class *class, void *data,
|
|||
if (!class)
|
||||
return NULL;
|
||||
|
||||
down(&class->sem);
|
||||
list_for_each_entry(dev, &class->devices, node) {
|
||||
mutex_lock(&class->p->class_mutex);
|
||||
list_for_each_entry(dev, &class->p->class_devices, node) {
|
||||
if (start) {
|
||||
if (start == dev)
|
||||
start = NULL;
|
||||
continue;
|
||||
}
|
||||
dev = get_device(dev);
|
||||
if (dev) {
|
||||
if (match(dev, data)) {
|
||||
found = 1;
|
||||
break;
|
||||
} else
|
||||
put_device(dev);
|
||||
} else
|
||||
if (match(dev, data)) {
|
||||
found = 1;
|
||||
break;
|
||||
} else
|
||||
put_device(dev);
|
||||
}
|
||||
up(&class->sem);
|
||||
mutex_unlock(&class->p->class_mutex);
|
||||
|
||||
return found ? dev : NULL;
|
||||
}
|
||||
|
@ -349,13 +376,13 @@ int class_interface_register(struct class_interface *class_intf)
|
|||
if (!parent)
|
||||
return -EINVAL;
|
||||
|
||||
down(&parent->sem);
|
||||
list_add_tail(&class_intf->node, &parent->interfaces);
|
||||
mutex_lock(&parent->p->class_mutex);
|
||||
list_add_tail(&class_intf->node, &parent->p->class_interfaces);
|
||||
if (class_intf->add_dev) {
|
||||
list_for_each_entry(dev, &parent->devices, node)
|
||||
list_for_each_entry(dev, &parent->p->class_devices, node)
|
||||
class_intf->add_dev(dev, class_intf);
|
||||
}
|
||||
up(&parent->sem);
|
||||
mutex_unlock(&parent->p->class_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -368,13 +395,13 @@ void class_interface_unregister(struct class_interface *class_intf)
|
|||
if (!parent)
|
||||
return;
|
||||
|
||||
down(&parent->sem);
|
||||
mutex_lock(&parent->p->class_mutex);
|
||||
list_del_init(&class_intf->node);
|
||||
if (class_intf->remove_dev) {
|
||||
list_for_each_entry(dev, &parent->devices, node)
|
||||
list_for_each_entry(dev, &parent->p->class_devices, node)
|
||||
class_intf->remove_dev(dev, class_intf);
|
||||
}
|
||||
up(&parent->sem);
|
||||
mutex_unlock(&parent->p->class_mutex);
|
||||
|
||||
class_put(parent);
|
||||
}
|
||||
|
@ -389,9 +416,7 @@ int __init classes_init(void)
|
|||
|
||||
EXPORT_SYMBOL_GPL(class_create_file);
|
||||
EXPORT_SYMBOL_GPL(class_remove_file);
|
||||
EXPORT_SYMBOL_GPL(class_register);
|
||||
EXPORT_SYMBOL_GPL(class_unregister);
|
||||
EXPORT_SYMBOL_GPL(class_create);
|
||||
EXPORT_SYMBOL_GPL(class_destroy);
|
||||
|
||||
EXPORT_SYMBOL_GPL(class_interface_register);
|
||||
|
|
|
@ -21,12 +21,16 @@
|
|||
#include <linux/genhd.h>
|
||||
#include <linux/kallsyms.h>
|
||||
#include <linux/semaphore.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#include "base.h"
|
||||
#include "power/power.h"
|
||||
|
||||
int (*platform_notify)(struct device *dev) = NULL;
|
||||
int (*platform_notify_remove)(struct device *dev) = NULL;
|
||||
static struct kobject *dev_kobj;
|
||||
struct kobject *sysfs_dev_char_kobj;
|
||||
struct kobject *sysfs_dev_block_kobj;
|
||||
|
||||
#ifdef CONFIG_BLOCK
|
||||
static inline int device_is_not_partition(struct device *dev)
|
||||
|
@ -548,7 +552,7 @@ static struct kobject *get_device_parent(struct device *dev,
|
|||
{
|
||||
/* class devices without a parent live in /sys/class/<classname>/ */
|
||||
if (dev->class && (!parent || parent->class != dev->class))
|
||||
return &dev->class->subsys.kobj;
|
||||
return &dev->class->p->class_subsys.kobj;
|
||||
/* all other devices keep their parent */
|
||||
else if (parent)
|
||||
return &parent->kobj;
|
||||
|
@ -594,13 +598,13 @@ static struct kobject *get_device_parent(struct device *dev,
|
|||
parent_kobj = &parent->kobj;
|
||||
|
||||
/* find our class-directory at the parent and reference it */
|
||||
spin_lock(&dev->class->class_dirs.list_lock);
|
||||
list_for_each_entry(k, &dev->class->class_dirs.list, entry)
|
||||
spin_lock(&dev->class->p->class_dirs.list_lock);
|
||||
list_for_each_entry(k, &dev->class->p->class_dirs.list, entry)
|
||||
if (k->parent == parent_kobj) {
|
||||
kobj = kobject_get(k);
|
||||
break;
|
||||
}
|
||||
spin_unlock(&dev->class->class_dirs.list_lock);
|
||||
spin_unlock(&dev->class->p->class_dirs.list_lock);
|
||||
if (kobj)
|
||||
return kobj;
|
||||
|
||||
|
@ -608,7 +612,7 @@ static struct kobject *get_device_parent(struct device *dev,
|
|||
k = kobject_create();
|
||||
if (!k)
|
||||
return NULL;
|
||||
k->kset = &dev->class->class_dirs;
|
||||
k->kset = &dev->class->p->class_dirs;
|
||||
retval = kobject_add(k, parent_kobj, "%s", dev->class->name);
|
||||
if (retval < 0) {
|
||||
kobject_put(k);
|
||||
|
@ -627,7 +631,7 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
|
|||
{
|
||||
/* see if we live in a "glue" directory */
|
||||
if (!glue_dir || !dev->class ||
|
||||
glue_dir->kset != &dev->class->class_dirs)
|
||||
glue_dir->kset != &dev->class->p->class_dirs)
|
||||
return;
|
||||
|
||||
kobject_put(glue_dir);
|
||||
|
@ -654,17 +658,18 @@ static int device_add_class_symlinks(struct device *dev)
|
|||
if (!dev->class)
|
||||
return 0;
|
||||
|
||||
error = sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj,
|
||||
error = sysfs_create_link(&dev->kobj,
|
||||
&dev->class->p->class_subsys.kobj,
|
||||
"subsystem");
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
#ifdef CONFIG_SYSFS_DEPRECATED
|
||||
/* stacked class devices need a symlink in the class directory */
|
||||
if (dev->kobj.parent != &dev->class->subsys.kobj &&
|
||||
if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
|
||||
device_is_not_partition(dev)) {
|
||||
error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
|
||||
dev->bus_id);
|
||||
error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
|
||||
&dev->kobj, dev->bus_id);
|
||||
if (error)
|
||||
goto out_subsys;
|
||||
}
|
||||
|
@ -701,13 +706,14 @@ out_device:
|
|||
if (dev->parent && device_is_not_partition(dev))
|
||||
sysfs_remove_link(&dev->kobj, "device");
|
||||
out_busid:
|
||||
if (dev->kobj.parent != &dev->class->subsys.kobj &&
|
||||
if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
|
||||
device_is_not_partition(dev))
|
||||
sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
|
||||
sysfs_remove_link(&dev->class->p->class_subsys.kobj,
|
||||
dev->bus_id);
|
||||
#else
|
||||
/* link in the class directory pointing to the device */
|
||||
error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
|
||||
dev->bus_id);
|
||||
error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
|
||||
&dev->kobj, dev->bus_id);
|
||||
if (error)
|
||||
goto out_subsys;
|
||||
|
||||
|
@ -720,7 +726,7 @@ out_busid:
|
|||
return 0;
|
||||
|
||||
out_busid:
|
||||
sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
|
||||
sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
|
||||
#endif
|
||||
|
||||
out_subsys:
|
||||
|
@ -746,14 +752,15 @@ static void device_remove_class_symlinks(struct device *dev)
|
|||
sysfs_remove_link(&dev->kobj, "device");
|
||||
}
|
||||
|
||||
if (dev->kobj.parent != &dev->class->subsys.kobj &&
|
||||
if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
|
||||
device_is_not_partition(dev))
|
||||
sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
|
||||
sysfs_remove_link(&dev->class->p->class_subsys.kobj,
|
||||
dev->bus_id);
|
||||
#else
|
||||
if (dev->parent && device_is_not_partition(dev))
|
||||
sysfs_remove_link(&dev->kobj, "device");
|
||||
|
||||
sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
|
||||
sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
|
||||
#endif
|
||||
|
||||
sysfs_remove_link(&dev->kobj, "subsystem");
|
||||
|
@ -775,6 +782,54 @@ int dev_set_name(struct device *dev, const char *fmt, ...)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(dev_set_name);
|
||||
|
||||
/**
|
||||
* device_to_dev_kobj - select a /sys/dev/ directory for the device
|
||||
* @dev: device
|
||||
*
|
||||
* By default we select char/ for new entries. Setting class->dev_obj
|
||||
* to NULL prevents an entry from being created. class->dev_kobj must
|
||||
* be set (or cleared) before any devices are registered to the class
|
||||
* otherwise device_create_sys_dev_entry() and
|
||||
* device_remove_sys_dev_entry() will disagree about the the presence
|
||||
* of the link.
|
||||
*/
|
||||
static struct kobject *device_to_dev_kobj(struct device *dev)
|
||||
{
|
||||
struct kobject *kobj;
|
||||
|
||||
if (dev->class)
|
||||
kobj = dev->class->dev_kobj;
|
||||
else
|
||||
kobj = sysfs_dev_char_kobj;
|
||||
|
||||
return kobj;
|
||||
}
|
||||
|
||||
static int device_create_sys_dev_entry(struct device *dev)
|
||||
{
|
||||
struct kobject *kobj = device_to_dev_kobj(dev);
|
||||
int error = 0;
|
||||
char devt_str[15];
|
||||
|
||||
if (kobj) {
|
||||
format_dev_t(devt_str, dev->devt);
|
||||
error = sysfs_create_link(kobj, &dev->kobj, devt_str);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static void device_remove_sys_dev_entry(struct device *dev)
|
||||
{
|
||||
struct kobject *kobj = device_to_dev_kobj(dev);
|
||||
char devt_str[15];
|
||||
|
||||
if (kobj) {
|
||||
format_dev_t(devt_str, dev->devt);
|
||||
sysfs_remove_link(kobj, devt_str);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* device_add - add device to device hierarchy.
|
||||
* @dev: device.
|
||||
|
@ -829,6 +884,10 @@ int device_add(struct device *dev)
|
|||
error = device_create_file(dev, &devt_attr);
|
||||
if (error)
|
||||
goto ueventattrError;
|
||||
|
||||
error = device_create_sys_dev_entry(dev);
|
||||
if (error)
|
||||
goto devtattrError;
|
||||
}
|
||||
|
||||
error = device_add_class_symlinks(dev);
|
||||
|
@ -849,15 +908,16 @@ int device_add(struct device *dev)
|
|||
klist_add_tail(&dev->knode_parent, &parent->klist_children);
|
||||
|
||||
if (dev->class) {
|
||||
down(&dev->class->sem);
|
||||
mutex_lock(&dev->class->p->class_mutex);
|
||||
/* tie the class to the device */
|
||||
list_add_tail(&dev->node, &dev->class->devices);
|
||||
list_add_tail(&dev->node, &dev->class->p->class_devices);
|
||||
|
||||
/* notify any interfaces that the device is here */
|
||||
list_for_each_entry(class_intf, &dev->class->interfaces, node)
|
||||
list_for_each_entry(class_intf,
|
||||
&dev->class->p->class_interfaces, node)
|
||||
if (class_intf->add_dev)
|
||||
class_intf->add_dev(dev, class_intf);
|
||||
up(&dev->class->sem);
|
||||
mutex_unlock(&dev->class->p->class_mutex);
|
||||
}
|
||||
Done:
|
||||
put_device(dev);
|
||||
|
@ -872,6 +932,9 @@ int device_add(struct device *dev)
|
|||
AttrsError:
|
||||
device_remove_class_symlinks(dev);
|
||||
SymlinkError:
|
||||
if (MAJOR(dev->devt))
|
||||
device_remove_sys_dev_entry(dev);
|
||||
devtattrError:
|
||||
if (MAJOR(dev->devt))
|
||||
device_remove_file(dev, &devt_attr);
|
||||
ueventattrError:
|
||||
|
@ -948,19 +1011,22 @@ void device_del(struct device *dev)
|
|||
device_pm_remove(dev);
|
||||
if (parent)
|
||||
klist_del(&dev->knode_parent);
|
||||
if (MAJOR(dev->devt))
|
||||
if (MAJOR(dev->devt)) {
|
||||
device_remove_sys_dev_entry(dev);
|
||||
device_remove_file(dev, &devt_attr);
|
||||
}
|
||||
if (dev->class) {
|
||||
device_remove_class_symlinks(dev);
|
||||
|
||||
down(&dev->class->sem);
|
||||
mutex_lock(&dev->class->p->class_mutex);
|
||||
/* notify any interfaces that the device is now gone */
|
||||
list_for_each_entry(class_intf, &dev->class->interfaces, node)
|
||||
list_for_each_entry(class_intf,
|
||||
&dev->class->p->class_interfaces, node)
|
||||
if (class_intf->remove_dev)
|
||||
class_intf->remove_dev(dev, class_intf);
|
||||
/* remove the device from the class list */
|
||||
list_del_init(&dev->node);
|
||||
up(&dev->class->sem);
|
||||
mutex_unlock(&dev->class->p->class_mutex);
|
||||
}
|
||||
device_remove_file(dev, &uevent_attr);
|
||||
device_remove_attrs(dev);
|
||||
|
@ -1074,7 +1140,25 @@ int __init devices_init(void)
|
|||
devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);
|
||||
if (!devices_kset)
|
||||
return -ENOMEM;
|
||||
dev_kobj = kobject_create_and_add("dev", NULL);
|
||||
if (!dev_kobj)
|
||||
goto dev_kobj_err;
|
||||
sysfs_dev_block_kobj = kobject_create_and_add("block", dev_kobj);
|
||||
if (!sysfs_dev_block_kobj)
|
||||
goto block_kobj_err;
|
||||
sysfs_dev_char_kobj = kobject_create_and_add("char", dev_kobj);
|
||||
if (!sysfs_dev_char_kobj)
|
||||
goto char_kobj_err;
|
||||
|
||||
return 0;
|
||||
|
||||
char_kobj_err:
|
||||
kobject_put(sysfs_dev_block_kobj);
|
||||
block_kobj_err:
|
||||
kobject_put(dev_kobj);
|
||||
dev_kobj_err:
|
||||
kset_unregister(devices_kset);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL_GPL(device_for_each_child);
|
||||
|
@ -1158,7 +1242,7 @@ error:
|
|||
EXPORT_SYMBOL_GPL(device_create_vargs);
|
||||
|
||||
/**
|
||||
* device_create_drvdata - creates a device and registers it with sysfs
|
||||
* device_create - creates a device and registers it with sysfs
|
||||
* @class: pointer to the struct class that this device should be registered to
|
||||
* @parent: pointer to the parent struct device of this new device, if any
|
||||
* @devt: the dev_t for the char device to be added
|
||||
|
@ -1179,11 +1263,8 @@ EXPORT_SYMBOL_GPL(device_create_vargs);
|
|||
* Note: the struct class passed to this function must have previously
|
||||
* been created with a call to class_create().
|
||||
*/
|
||||
struct device *device_create_drvdata(struct class *class,
|
||||
struct device *parent,
|
||||
dev_t devt,
|
||||
void *drvdata,
|
||||
const char *fmt, ...)
|
||||
struct device *device_create(struct class *class, struct device *parent,
|
||||
dev_t devt, void *drvdata, const char *fmt, ...)
|
||||
{
|
||||
va_list vargs;
|
||||
struct device *dev;
|
||||
|
@ -1193,40 +1274,6 @@ struct device *device_create_drvdata(struct class *class,
|
|||
va_end(vargs);
|
||||
return dev;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(device_create_drvdata);
|
||||
|
||||
/**
|
||||
* device_create - creates a device and registers it with sysfs
|
||||
* @class: pointer to the struct class that this device should be registered to
|
||||
* @parent: pointer to the parent struct device of this new device, if any
|
||||
* @devt: the dev_t for the char device to be added
|
||||
* @fmt: string for the device's name
|
||||
*
|
||||
* This function can be used by char device classes. A struct device
|
||||
* will be created in sysfs, registered to the specified class.
|
||||
*
|
||||
* A "dev" file will be created, showing the dev_t for the device, if
|
||||
* the dev_t is not 0,0.
|
||||
* If a pointer to a parent struct device is passed in, the newly created
|
||||
* struct device will be a child of that device in sysfs.
|
||||
* The pointer to the struct device will be returned from the call.
|
||||
* Any further sysfs files that might be required can be created using this
|
||||
* pointer.
|
||||
*
|
||||
* Note: the struct class passed to this function must have previously
|
||||
* been created with a call to class_create().
|
||||
*/
|
||||
struct device *device_create(struct class *class, struct device *parent,
|
||||
dev_t devt, const char *fmt, ...)
|
||||
{
|
||||
va_list vargs;
|
||||
struct device *dev;
|
||||
|
||||
va_start(vargs, fmt);
|
||||
dev = device_create_vargs(class, parent, devt, NULL, fmt, vargs);
|
||||
va_end(vargs);
|
||||
return dev;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(device_create);
|
||||
|
||||
static int __match_devt(struct device *dev, void *data)
|
||||
|
@ -1248,7 +1295,7 @@ void device_destroy(struct class *class, dev_t devt)
|
|||
{
|
||||
struct device *dev;
|
||||
|
||||
dev = class_find_device(class, &devt, __match_devt);
|
||||
dev = class_find_device(class, NULL, &devt, __match_devt);
|
||||
if (dev) {
|
||||
put_device(dev);
|
||||
device_unregister(dev);
|
||||
|
@ -1298,8 +1345,9 @@ int device_rename(struct device *dev, char *new_name)
|
|||
if (old_class_name) {
|
||||
new_class_name = make_class_name(dev->class->name, &dev->kobj);
|
||||
if (new_class_name) {
|
||||
error = sysfs_create_link(&dev->parent->kobj,
|
||||
&dev->kobj, new_class_name);
|
||||
error = sysfs_create_link_nowarn(&dev->parent->kobj,
|
||||
&dev->kobj,
|
||||
new_class_name);
|
||||
if (error)
|
||||
goto out;
|
||||
sysfs_remove_link(&dev->parent->kobj, old_class_name);
|
||||
|
@ -1307,11 +1355,12 @@ int device_rename(struct device *dev, char *new_name)
|
|||
}
|
||||
#else
|
||||
if (dev->class) {
|
||||
error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
|
||||
dev->bus_id);
|
||||
error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj,
|
||||
&dev->kobj, dev->bus_id);
|
||||
if (error)
|
||||
goto out;
|
||||
sysfs_remove_link(&dev->class->subsys.kobj, old_device_name);
|
||||
sysfs_remove_link(&dev->class->p->class_subsys.kobj,
|
||||
old_device_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1447,4 +1496,7 @@ void device_shutdown(void)
|
|||
dev->driver->shutdown(dev);
|
||||
}
|
||||
}
|
||||
kobject_put(sysfs_dev_char_kobj);
|
||||
kobject_put(sysfs_dev_block_kobj);
|
||||
kobject_put(dev_kobj);
|
||||
}
|
||||
|
|
|
@ -21,15 +21,16 @@ EXPORT_SYMBOL(cpu_sysdev_class);
|
|||
static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices);
|
||||
|
||||
#ifdef CONFIG_HOTPLUG_CPU
|
||||
static ssize_t show_online(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_online(struct sys_device *dev, struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct cpu *cpu = container_of(dev, struct cpu, sysdev);
|
||||
|
||||
return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id));
|
||||
}
|
||||
|
||||
static ssize_t __ref store_online(struct sys_device *dev, const char *buf,
|
||||
size_t count)
|
||||
static ssize_t __ref store_online(struct sys_device *dev, struct sysdev_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct cpu *cpu = container_of(dev, struct cpu, sysdev);
|
||||
ssize_t ret;
|
||||
|
@ -80,7 +81,8 @@ static inline void register_cpu_control(struct cpu *cpu)
|
|||
#ifdef CONFIG_KEXEC
|
||||
#include <linux/kexec.h>
|
||||
|
||||
static ssize_t show_crash_notes(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct cpu *cpu = container_of(dev, struct cpu, sysdev);
|
||||
ssize_t rc;
|
||||
|
|
|
@ -92,7 +92,8 @@ unregister_memory(struct memory_block *memory, struct mem_section *section)
|
|||
* uses.
|
||||
*/
|
||||
|
||||
static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_mem_phys_index(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct memory_block *mem =
|
||||
container_of(dev, struct memory_block, sysdev);
|
||||
|
@ -102,7 +103,8 @@ static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf)
|
|||
/*
|
||||
* online, offline, going offline, etc.
|
||||
*/
|
||||
static ssize_t show_mem_state(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_mem_state(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct memory_block *mem =
|
||||
container_of(dev, struct memory_block, sysdev);
|
||||
|
@ -217,7 +219,8 @@ out:
|
|||
}
|
||||
|
||||
static ssize_t
|
||||
store_mem_state(struct sys_device *dev, const char *buf, size_t count)
|
||||
store_mem_state(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct memory_block *mem;
|
||||
unsigned int phys_section_nr;
|
||||
|
@ -248,7 +251,8 @@ out:
|
|||
* s.t. if I offline all of these sections I can then
|
||||
* remove the physical device?
|
||||
*/
|
||||
static ssize_t show_phys_device(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_phys_device(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
struct memory_block *mem =
|
||||
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)
|
|||
return len;
|
||||
}
|
||||
|
||||
static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf)
|
||||
static inline ssize_t node_read_cpumask(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return node_read_cpumap(dev, 0, buf);
|
||||
}
|
||||
static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf)
|
||||
static inline ssize_t node_read_cpulist(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
return node_read_cpumap(dev, 1, buf);
|
||||
}
|
||||
|
@ -49,7 +51,8 @@ static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL);
|
|||
static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL);
|
||||
|
||||
#define K(x) ((x) << (PAGE_SHIFT - 10))
|
||||
static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
|
||||
static ssize_t node_read_meminfo(struct sys_device * dev,
|
||||
struct sysdev_attribute *attr, char * buf)
|
||||
{
|
||||
int n;
|
||||
int nid = dev->id;
|
||||
|
@ -112,7 +115,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
|
|||
#undef K
|
||||
static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL);
|
||||
|
||||
static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
|
||||
static ssize_t node_read_numastat(struct sys_device * dev,
|
||||
struct sysdev_attribute *attr, char * buf)
|
||||
{
|
||||
return sprintf(buf,
|
||||
"numa_hit %lu\n"
|
||||
|
@ -130,7 +134,8 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
|
|||
}
|
||||
static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
|
||||
|
||||
static ssize_t node_read_distance(struct sys_device * dev, char * buf)
|
||||
static ssize_t node_read_distance(struct sys_device * dev,
|
||||
struct sysdev_attribute *attr, char * buf)
|
||||
{
|
||||
int nid = dev->id;
|
||||
int len = 0;
|
||||
|
|
|
@ -194,7 +194,7 @@ static int show_dev_hash(unsigned int value)
|
|||
struct device * dev = to_device(entry);
|
||||
unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH);
|
||||
if (hash == value) {
|
||||
printk(" hash matches device %s\n", dev->bus_id);
|
||||
dev_info(dev, "hash matches\n");
|
||||
match++;
|
||||
}
|
||||
entry = entry->prev;
|
||||
|
|
|
@ -36,7 +36,7 @@ sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer)
|
|||
struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);
|
||||
|
||||
if (sysdev_attr->show)
|
||||
return sysdev_attr->show(sysdev, buffer);
|
||||
return sysdev_attr->show(sysdev, sysdev_attr, buffer);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ sysdev_store(struct kobject * kobj, struct attribute * attr,
|
|||
struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);
|
||||
|
||||
if (sysdev_attr->store)
|
||||
return sysdev_attr->store(sysdev, buffer, count);
|
||||
return sysdev_attr->store(sysdev, sysdev_attr, buffer, count);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -130,8 +130,8 @@ static struct kset *system_kset;
|
|||
|
||||
int sysdev_class_register(struct sysdev_class * cls)
|
||||
{
|
||||
pr_debug("Registering sysdev class '%s'\n",
|
||||
kobject_name(&cls->kset.kobj));
|
||||
pr_debug("Registering sysdev class '%s'\n", cls->name);
|
||||
|
||||
INIT_LIST_HEAD(&cls->drivers);
|
||||
memset(&cls->kset.kobj, 0x00, sizeof(struct kobject));
|
||||
cls->kset.kobj.parent = &system_kset->kobj;
|
||||
|
@ -241,7 +241,8 @@ int sysdev_register(struct sys_device * sysdev)
|
|||
if (!cls)
|
||||
return -EINVAL;
|
||||
|
||||
pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj));
|
||||
pr_debug("Registering sys device of class '%s'\n",
|
||||
kobject_name(&cls->kset.kobj));
|
||||
|
||||
/* initialize the kobject to 0, in case it had previously been used */
|
||||
memset(&sysdev->kobj, 0x00, sizeof(struct kobject));
|
||||
|
@ -257,6 +258,9 @@ int sysdev_register(struct sys_device * sysdev)
|
|||
if (!error) {
|
||||
struct sysdev_driver * drv;
|
||||
|
||||
pr_debug("Registering sys device '%s'\n",
|
||||
kobject_name(&sysdev->kobj));
|
||||
|
||||
mutex_lock(&sysdev_drivers_lock);
|
||||
/* Generic notification is implicit, because it's that
|
||||
* code that should have called us.
|
||||
|
@ -269,6 +273,7 @@ int sysdev_register(struct sys_device * sysdev)
|
|||
}
|
||||
mutex_unlock(&sysdev_drivers_lock);
|
||||
}
|
||||
|
||||
kobject_uevent(&sysdev->kobj, KOBJ_ADD);
|
||||
return error;
|
||||
}
|
||||
|
@ -474,3 +479,52 @@ int __init system_bus_init(void)
|
|||
|
||||
EXPORT_SYMBOL_GPL(sysdev_register);
|
||||
EXPORT_SYMBOL_GPL(sysdev_unregister);
|
||||
|
||||
#define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr)
|
||||
|
||||
ssize_t sysdev_store_ulong(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
struct sysdev_ext_attribute *ea = to_ext_attr(attr);
|
||||
char *end;
|
||||
unsigned long new = simple_strtoul(buf, &end, 0);
|
||||
if (end == buf)
|
||||
return -EINVAL;
|
||||
*(unsigned long *)(ea->var) = new;
|
||||
return end - buf;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sysdev_store_ulong);
|
||||
|
||||
ssize_t sysdev_show_ulong(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct sysdev_ext_attribute *ea = to_ext_attr(attr);
|
||||
return snprintf(buf, PAGE_SIZE, "%lx\n", *(unsigned long *)(ea->var));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sysdev_show_ulong);
|
||||
|
||||
ssize_t sysdev_store_int(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
struct sysdev_ext_attribute *ea = to_ext_attr(attr);
|
||||
char *end;
|
||||
long new = simple_strtol(buf, &end, 0);
|
||||
if (end == buf || new > INT_MAX || new < INT_MIN)
|
||||
return -EINVAL;
|
||||
*(int *)(ea->var) = new;
|
||||
return end - buf;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sysdev_store_int);
|
||||
|
||||
ssize_t sysdev_show_int(struct sys_device *sysdev,
|
||||
struct sysdev_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct sysdev_ext_attribute *ea = to_ext_attr(attr);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", *(int *)(ea->var));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sysdev_show_int);
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
|
||||
|
||||
#define define_id_show_func(name) \
|
||||
static ssize_t show_##name(struct sys_device *dev, char *buf) \
|
||||
static ssize_t show_##name(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, char *buf) \
|
||||
{ \
|
||||
unsigned int cpu = dev->id; \
|
||||
return sprintf(buf, "%d\n", topology_##name(cpu)); \
|
||||
|
@ -59,14 +60,17 @@ static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
|
|||
|
||||
#ifdef arch_provides_topology_pointers
|
||||
#define define_siblings_show_map(name) \
|
||||
static ssize_t show_##name(struct sys_device *dev, char *buf) \
|
||||
static ssize_t show_##name(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, char *buf) \
|
||||
{ \
|
||||
unsigned int cpu = dev->id; \
|
||||
return show_cpumap(0, &(topology_##name(cpu)), buf); \
|
||||
}
|
||||
|
||||
#define define_siblings_show_list(name) \
|
||||
static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
|
||||
static ssize_t show_##name##_list(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, \
|
||||
char *buf) \
|
||||
{ \
|
||||
unsigned int cpu = dev->id; \
|
||||
return show_cpumap(1, &(topology_##name(cpu)), buf); \
|
||||
|
@ -74,7 +78,8 @@ static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
|
|||
|
||||
#else
|
||||
#define define_siblings_show_map(name) \
|
||||
static ssize_t show_##name(struct sys_device *dev, char *buf) \
|
||||
static ssize_t show_##name(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, char *buf) \
|
||||
{ \
|
||||
unsigned int cpu = dev->id; \
|
||||
cpumask_t mask = topology_##name(cpu); \
|
||||
|
@ -82,7 +87,9 @@ static ssize_t show_##name(struct sys_device *dev, char *buf) \
|
|||
}
|
||||
|
||||
#define define_siblings_show_list(name) \
|
||||
static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
|
||||
static ssize_t show_##name##_list(struct sys_device *dev, \
|
||||
struct sysdev_attribute *attr, \
|
||||
char *buf) \
|
||||
{ \
|
||||
unsigned int cpu = dev->id; \
|
||||
cpumask_t mask = topology_##name(cpu); \
|
||||
|
|
|
@ -277,8 +277,9 @@ aoechr_init(void)
|
|||
return PTR_ERR(aoe_class);
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
|
||||
device_create(aoe_class, NULL,
|
||||
MKDEV(AOE_MAJOR, chardevs[i].minor), chardevs[i].name);
|
||||
device_create_drvdata(aoe_class, NULL,
|
||||
MKDEV(AOE_MAJOR, chardevs[i].minor),
|
||||
NULL, chardevs[i].name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -686,8 +686,9 @@ static int __init pg_init(void)
|
|||
for (unit = 0; unit < PG_UNITS; unit++) {
|
||||
struct pg *dev = &devices[unit];
|
||||
if (dev->present)
|
||||
device_create(pg_class, NULL, MKDEV(major, unit),
|
||||
"pg%u", unit);
|
||||
device_create_drvdata(pg_class, NULL,
|
||||
MKDEV(major, unit), NULL,
|
||||
"pg%u", unit);
|
||||
}
|
||||
err = 0;
|
||||
goto out;
|
||||
|
|
|
@ -979,10 +979,12 @@ static int __init pt_init(void)
|
|||
|
||||
for (unit = 0; unit < PT_UNITS; unit++)
|
||||
if (pt[unit].present) {
|
||||
device_create(pt_class, NULL, MKDEV(major, unit),
|
||||
"pt%d", unit);
|
||||
device_create(pt_class, NULL, MKDEV(major, unit + 128),
|
||||
"pt%dn", unit);
|
||||
device_create_drvdata(pt_class, NULL,
|
||||
MKDEV(major, unit), NULL,
|
||||
"pt%d", unit);
|
||||
device_create_drvdata(pt_class, NULL,
|
||||
MKDEV(major, unit + 128), NULL,
|
||||
"pt%dn", unit);
|
||||
}
|
||||
goto out;
|
||||
|
||||
|
|
|
@ -303,7 +303,9 @@ static struct kobj_type kobj_pkt_type_wqueue = {
|
|||
static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
|
||||
{
|
||||
if (class_pktcdvd) {
|
||||
pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, "%s", pd->name);
|
||||
pd->dev = device_create_drvdata(class_pktcdvd, NULL,
|
||||
pd->pkt_dev, NULL,
|
||||
"%s", pd->name);
|
||||
if (IS_ERR(pd->dev))
|
||||
pd->dev = NULL;
|
||||
}
|
||||
|
|
|
@ -500,7 +500,8 @@ static int __init dsp56k_init_driver(void)
|
|||
err = PTR_ERR(dsp56k_class);
|
||||
goto out_chrdev;
|
||||
}
|
||||
device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), "dsp56k");
|
||||
device_create_drvdata(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0),
|
||||
NULL, "dsp56k");
|
||||
|
||||
printk(banner);
|
||||
goto out;
|
||||
|
|
|
@ -718,12 +718,12 @@ ip2_loadmain(int *iop, int *irqp)
|
|||
}
|
||||
|
||||
if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
|
||||
device_create(ip2_class, NULL,
|
||||
MKDEV(IP2_IPL_MAJOR, 4 * i),
|
||||
"ipl%d", i);
|
||||
device_create(ip2_class, NULL,
|
||||
MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
|
||||
"stat%d", i);
|
||||
device_create_drvdata(ip2_class, NULL,
|
||||
MKDEV(IP2_IPL_MAJOR, 4 * i),
|
||||
NULL, "ipl%d", i);
|
||||
device_create_drvdata(ip2_class, NULL,
|
||||
MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
|
||||
NULL, "stat%d", i);
|
||||
|
||||
for ( box = 0; box < ABS_MAX_BOXES; ++box )
|
||||
{
|
||||
|
|
|
@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
|
|||
entry->dev = dev;
|
||||
|
||||
mutex_lock(®_list_mutex);
|
||||
device_create(ipmi_class, device, dev, "ipmi%d", if_num);
|
||||
device_create_drvdata(ipmi_class, device, dev, NULL, "ipmi%d", if_num);
|
||||
list_add(&entry->link, ®_list);
|
||||
mutex_unlock(®_list_mutex);
|
||||
}
|
||||
|
|
|
@ -4599,8 +4599,9 @@ static int __init istallion_module_init(void)
|
|||
|
||||
istallion_class = class_create(THIS_MODULE, "staliomem");
|
||||
for (i = 0; i < 4; i++)
|
||||
device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
|
||||
"staliomem%d", i);
|
||||
device_create_drvdata(istallion_class, NULL,
|
||||
MKDEV(STL_SIOMEMMAJOR, i),
|
||||
NULL, "staliomem%d", i);
|
||||
|
||||
return 0;
|
||||
err_deinit:
|
||||
|
|
|
@ -813,7 +813,8 @@ static int lp_register(int nr, struct parport *port)
|
|||
if (reset)
|
||||
lp_reset(nr);
|
||||
|
||||
device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), "lp%d", nr);
|
||||
device_create_drvdata(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL,
|
||||
"lp%d", nr);
|
||||
|
||||
printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
|
||||
(port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
|
||||
|
|
|
@ -989,9 +989,9 @@ static int __init chr_dev_init(void)
|
|||
|
||||
mem_class = class_create(THIS_MODULE, "mem");
|
||||
for (i = 0; i < ARRAY_SIZE(devlist); i++)
|
||||
device_create(mem_class, NULL,
|
||||
MKDEV(MEM_MAJOR, devlist[i].minor),
|
||||
devlist[i].name);
|
||||
device_create_drvdata(mem_class, NULL,
|
||||
MKDEV(MEM_MAJOR, devlist[i].minor),
|
||||
NULL, devlist[i].name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc)
|
|||
misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
|
||||
dev = MKDEV(MISC_MAJOR, misc->minor);
|
||||
|
||||
misc->this_device = device_create(misc_class, misc->parent, dev,
|
||||
"%s", misc->name);
|
||||
misc->this_device = device_create_drvdata(misc_class, misc->parent,
|
||||
dev, NULL, "%s", misc->name);
|
||||
if (IS_ERR(misc->this_device)) {
|
||||
err = PTR_ERR(misc->this_device);
|
||||
goto out;
|
||||
|
|
|
@ -1896,7 +1896,7 @@ static int cm4000_probe(struct pcmcia_device *link)
|
|||
return ret;
|
||||
}
|
||||
|
||||
device_create(cmm_class, NULL, MKDEV(major, i), "cmm%d", i);
|
||||
device_create_drvdata(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -653,7 +653,8 @@ static int reader_probe(struct pcmcia_device *link)
|
|||
return ret;
|
||||
}
|
||||
|
||||
device_create(cmx_class, NULL, MKDEV(major, i), "cmx%d", i);
|
||||
device_create_drvdata(cmx_class, NULL, MKDEV(major, i), NULL,
|
||||
"cmx%d", i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -752,8 +752,9 @@ static const struct file_operations pp_fops = {
|
|||
|
||||
static void pp_attach(struct parport *port)
|
||||
{
|
||||
device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number),
|
||||
"parport%d", port->number);
|
||||
device_create_drvdata(ppdev_class, port->dev,
|
||||
MKDEV(PP_MAJOR, port->number),
|
||||
NULL, "parport%d", port->number);
|
||||
}
|
||||
|
||||
static void pp_detach(struct parport *port)
|
||||
|
|
|
@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp,
|
|||
static void bind_device(struct raw_config_request *rq)
|
||||
{
|
||||
device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
|
||||
device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
|
||||
"raw%d", rq->raw_minor);
|
||||
device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
|
||||
NULL, "raw%d", rq->raw_minor);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -283,7 +283,8 @@ static int __init raw_init(void)
|
|||
ret = PTR_ERR(raw_class);
|
||||
goto error_region;
|
||||
}
|
||||
device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), "rawctl");
|
||||
device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL,
|
||||
"rawctl");
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -444,7 +444,8 @@ scdrv_init(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
device_create(snsc_class, NULL, dev, "%s", devname);
|
||||
device_create_drvdata(snsc_class, NULL, dev, NULL,
|
||||
"%s", devname);
|
||||
|
||||
ia64_sn_irtr_intr_enable(scd->scd_nasid,
|
||||
0 /*ignored */ ,
|
||||
|
|
|
@ -4755,8 +4755,8 @@ static int __init stallion_module_init(void)
|
|||
if (IS_ERR(stallion_class))
|
||||
printk("STALLION: failed to create class\n");
|
||||
for (i = 0; i < 4; i++)
|
||||
device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
|
||||
"staliomem%d", i);
|
||||
device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
|
||||
NULL, "staliomem%d", i);
|
||||
|
||||
return 0;
|
||||
err_unrtty:
|
||||
|
|
|
@ -3412,7 +3412,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index,
|
|||
else
|
||||
tty_line_name(driver, index, name);
|
||||
|
||||
return device_create(tty_class, device, dev, name);
|
||||
return device_create_drvdata(tty_class, device, dev, NULL, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3690,20 +3690,22 @@ static int __init tty_init(void)
|
|||
if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
|
||||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
|
||||
panic("Couldn't register /dev/tty driver\n");
|
||||
device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), "tty");
|
||||
device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL,
|
||||
"tty");
|
||||
|
||||
cdev_init(&console_cdev, &console_fops);
|
||||
if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
|
||||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
|
||||
panic("Couldn't register /dev/console driver\n");
|
||||
device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), "console");
|
||||
device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL,
|
||||
"console");
|
||||
|
||||
#ifdef CONFIG_UNIX98_PTYS
|
||||
cdev_init(&ptmx_cdev, &ptmx_fops);
|
||||
if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
|
||||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
|
||||
panic("Couldn't register /dev/ptmx driver\n");
|
||||
device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), "ptmx");
|
||||
device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_VT
|
||||
|
@ -3711,7 +3713,7 @@ static int __init tty_init(void)
|
|||
if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
|
||||
register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
|
||||
panic("Couldn't register /dev/tty0 driver\n");
|
||||
device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0");
|
||||
device_create_drvdata(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
|
||||
|
||||
vty_init();
|
||||
#endif
|
||||
|
|
|
@ -481,10 +481,10 @@ static struct class *vc_class;
|
|||
|
||||
void vcs_make_sysfs(struct tty_struct *tty)
|
||||
{
|
||||
device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
|
||||
"vcs%u", tty->index + 1);
|
||||
device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
|
||||
"vcsa%u", tty->index + 1);
|
||||
device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
|
||||
NULL, "vcs%u", tty->index + 1);
|
||||
device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
|
||||
NULL, "vcsa%u", tty->index + 1);
|
||||
}
|
||||
|
||||
void vcs_remove_sysfs(struct tty_struct *tty)
|
||||
|
@ -499,7 +499,7 @@ int __init vcs_init(void)
|
|||
panic("unable to get major %d for vcs device", VCS_MAJOR);
|
||||
vc_class = class_create(THIS_MODULE, "vc");
|
||||
|
||||
device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), "vcs");
|
||||
device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), "vcsa");
|
||||
device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
|
||||
device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
|
|||
state[i].cur_part = 0;
|
||||
for (j = 0; j < MAX_PARTITIONS; ++j)
|
||||
state[i].part_stat_rwi[j] = VIOT_IDLE;
|
||||
device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
|
||||
"iseries!vt%d", i);
|
||||
device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
|
||||
"iseries!nvt%d", i);
|
||||
device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
|
||||
NULL, "iseries!vt%d", i);
|
||||
device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
|
||||
NULL, "iseries!nvt%d", i);
|
||||
printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries "
|
||||
"resource %10.10s type %4.4s, model %3.3s\n",
|
||||
i, viotape_unitinfo[i].rsrcname,
|
||||
|
|
|
@ -3425,9 +3425,10 @@ int register_con_driver(const struct consw *csw, int first, int last)
|
|||
if (retval)
|
||||
goto err;
|
||||
|
||||
con_driver->dev = device_create(vtconsole_class, NULL,
|
||||
MKDEV(0, con_driver->node),
|
||||
"vtcon%i", con_driver->node);
|
||||
con_driver->dev = device_create_drvdata(vtconsole_class, NULL,
|
||||
MKDEV(0, con_driver->node),
|
||||
NULL, "vtcon%i",
|
||||
con_driver->node);
|
||||
|
||||
if (IS_ERR(con_driver->dev)) {
|
||||
printk(KERN_WARNING "Unable to create device for %s; "
|
||||
|
@ -3535,9 +3536,10 @@ static int __init vtconsole_class_init(void)
|
|||
struct con_driver *con = ®istered_con_driver[i];
|
||||
|
||||
if (con->con && !con->dev) {
|
||||
con->dev = device_create(vtconsole_class, NULL,
|
||||
MKDEV(0, con->node),
|
||||
"vtcon%i", con->node);
|
||||
con->dev = device_create_drvdata(vtconsole_class, NULL,
|
||||
MKDEV(0, con->node),
|
||||
NULL, "vtcon%i",
|
||||
con->node);
|
||||
|
||||
if (IS_ERR(con->dev)) {
|
||||
printk(KERN_WARNING "Unable to create "
|
||||
|
|
|
@ -658,8 +658,9 @@ static int __devinit hwicap_setup(struct device *dev, int id,
|
|||
dev_err(dev, "cdev_add() failed\n");
|
||||
goto failed3;
|
||||
}
|
||||
/* devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */
|
||||
device_create(icap_class, dev, devt, "%s%d", DRIVER_NAME, id);
|
||||
|
||||
device_create_drvdata(icap_class, dev, devt, NULL,
|
||||
"%s%d", DRIVER_NAME, id);
|
||||
return 0; /* success */
|
||||
|
||||
failed3:
|
||||
|
|
|
@ -21,7 +21,8 @@ static int __init cpuidle_sysfs_setup(char *unused)
|
|||
}
|
||||
__setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup);
|
||||
|
||||
static ssize_t show_available_governors(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_available_governors(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
ssize_t i = 0;
|
||||
struct cpuidle_governor *tmp;
|
||||
|
@ -39,7 +40,8 @@ out:
|
|||
return i;
|
||||
}
|
||||
|
||||
static ssize_t show_current_driver(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_current_driver(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
ssize_t ret;
|
||||
|
||||
|
@ -53,7 +55,8 @@ static ssize_t show_current_driver(struct sys_device *dev, char *buf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t show_current_governor(struct sys_device *dev, char *buf)
|
||||
static ssize_t show_current_governor(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr, char *buf)
|
||||
{
|
||||
ssize_t ret;
|
||||
|
||||
|
@ -68,6 +71,7 @@ static ssize_t show_current_governor(struct sys_device *dev, char *buf)
|
|||
}
|
||||
|
||||
static ssize_t store_current_governor(struct sys_device *dev,
|
||||
struct sysdev_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
char gov_name[CPUIDLE_NAME_LEN];
|
||||
|
|
|
@ -14,8 +14,9 @@ int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot)
|
|||
{
|
||||
struct device *cd;
|
||||
|
||||
cd = device_create(dca_class, dca->cd, MKDEV(0, slot + 1),
|
||||
"requester%d", slot);
|
||||
cd = device_create_drvdata(dca_class, dca->cd,
|
||||
MKDEV(0, slot + 1), NULL,
|
||||
"requester%d", slot);
|
||||
if (IS_ERR(cd))
|
||||
return PTR_ERR(cd);
|
||||
return 0;
|
||||
|
@ -46,7 +47,8 @@ idr_try_again:
|
|||
return err;
|
||||
}
|
||||
|
||||
cd = device_create(dca_class, dev, MKDEV(0, 0), "dca%d", dca->id);
|
||||
cd = device_create_drvdata(dca_class, dev, MKDEV(0, 0), NULL,
|
||||
"dca%d", dca->id);
|
||||
if (IS_ERR(cd)) {
|
||||
spin_lock(&dca_idr_lock);
|
||||
idr_remove(&dca_idr, dca->id);
|
||||
|
|
|
@ -9,7 +9,7 @@ obj-${CONFIG_EISA_VIRTUAL_ROOT} += virtual_root.o
|
|||
|
||||
|
||||
# Ugly hack to get DEVICE_NAME_SIZE value...
|
||||
DEVICE_NAME_SIZE =$(shell awk '$$1=="\#define" && $$2=="DEVICE_NAME_SIZE" {print $$3-1}' $(srctree)/include/linux/device.h)
|
||||
DEVICE_NAME_SIZE = 50
|
||||
|
||||
$(obj)/eisa-bus.o: $(obj)/devlist.h
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
struct eisa_device_info {
|
||||
struct eisa_device_id id;
|
||||
char name[DEVICE_NAME_SIZE];
|
||||
char name[50];
|
||||
};
|
||||
|
||||
#ifdef CONFIG_EISA_NAMES
|
||||
|
@ -63,7 +63,7 @@ static void __init eisa_name_device (struct eisa_device *edev)
|
|||
if (!strcmp (edev->id.sig, eisa_table[i].id.sig)) {
|
||||
strlcpy (edev->pretty_name,
|
||||
eisa_table[i].name,
|
||||
DEVICE_NAME_SIZE);
|
||||
sizeof(edev->pretty_name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -322,8 +322,9 @@ int hidraw_connect(struct hid_device *hid)
|
|||
goto out;
|
||||
}
|
||||
|
||||
dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor),
|
||||
"%s%d", "hidraw", minor);
|
||||
dev->dev = device_create_drvdata(hidraw_class, NULL,
|
||||
MKDEV(hidraw_major, minor), NULL,
|
||||
"%s%d", "hidraw", minor);
|
||||
|
||||
if (IS_ERR(dev->dev)) {
|
||||
spin_lock(&minors_lock);
|
||||
|
|
|
@ -55,7 +55,8 @@ again:
|
|||
return ERR_PTR(err);
|
||||
|
||||
id = id & MAX_ID_MASK;
|
||||
hwdev = device_create(hwmon_class, dev, MKDEV(0,0), HWMON_ID_FORMAT, id);
|
||||
hwdev = device_create_drvdata(hwmon_class, dev, MKDEV(0, 0), NULL,
|
||||
HWMON_ID_FORMAT, id);
|
||||
|
||||
if (IS_ERR(hwdev)) {
|
||||
spin_lock(&idr_lock);
|
||||
|
|
|
@ -722,7 +722,8 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
|
|||
|
||||
INIT_LIST_HEAD(&driver->clients);
|
||||
/* Walk the adapters that are already present */
|
||||
class_for_each_device(&i2c_adapter_class, driver, __attach_adapter);
|
||||
class_for_each_device(&i2c_adapter_class, NULL, driver,
|
||||
__attach_adapter);
|
||||
|
||||
mutex_unlock(&core_lock);
|
||||
return 0;
|
||||
|
@ -782,7 +783,8 @@ void i2c_del_driver(struct i2c_driver *driver)
|
|||
{
|
||||
mutex_lock(&core_lock);
|
||||
|
||||
class_for_each_device(&i2c_adapter_class, driver, __detach_adapter);
|
||||
class_for_each_device(&i2c_adapter_class, NULL, driver,
|
||||
__detach_adapter);
|
||||
|
||||
driver_unregister(&driver->driver);
|
||||
pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
|
||||
|
|
|
@ -521,9 +521,9 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
|
|||
return PTR_ERR(i2c_dev);
|
||||
|
||||
/* register this i2c device with the driver core */
|
||||
i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
|
||||
MKDEV(I2C_MAJOR, adap->nr),
|
||||
"i2c-%d", adap->nr);
|
||||
i2c_dev->dev = device_create_drvdata(i2c_dev_class, &adap->dev,
|
||||
MKDEV(I2C_MAJOR, adap->nr),
|
||||
NULL, "i2c-%d", adap->nr);
|
||||
if (IS_ERR(i2c_dev->dev)) {
|
||||
res = PTR_ERR(i2c_dev->dev);
|
||||
goto error;
|
||||
|
|
|
@ -2697,10 +2697,12 @@ static int ide_tape_probe(ide_drive_t *drive)
|
|||
|
||||
idetape_setup(drive, tape, minor);
|
||||
|
||||
device_create(idetape_sysfs_class, &drive->gendev,
|
||||
MKDEV(IDETAPE_MAJOR, minor), "%s", tape->name);
|
||||
device_create(idetape_sysfs_class, &drive->gendev,
|
||||
MKDEV(IDETAPE_MAJOR, minor + 128), "n%s", tape->name);
|
||||
device_create_drvdata(idetape_sysfs_class, &drive->gendev,
|
||||
MKDEV(IDETAPE_MAJOR, minor), NULL,
|
||||
"%s", tape->name);
|
||||
device_create_drvdata(idetape_sysfs_class, &drive->gendev,
|
||||
MKDEV(IDETAPE_MAJOR, minor + 128), NULL,
|
||||
"n%s", tape->name);
|
||||
|
||||
g->fops = &idetape_block_ops;
|
||||
ide_register_region(g);
|
||||
|
|
|
@ -2296,9 +2296,10 @@ static void dv1394_add_host(struct hpsb_host *host)
|
|||
|
||||
ohci = (struct ti_ohci *)host->hostdata;
|
||||
|
||||
device_create(hpsb_protocol_class, NULL, MKDEV(
|
||||
IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
|
||||
"dv1394-%d", id);
|
||||
device_create_drvdata(hpsb_protocol_class, NULL,
|
||||
MKDEV(IEEE1394_MAJOR,
|
||||
IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), NULL,
|
||||
"dv1394-%d", id);
|
||||
|
||||
dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
|
||||
dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
|
||||
|
|
|
@ -754,7 +754,8 @@ static void nodemgr_remove_uds(struct node_entry *ne)
|
|||
*/
|
||||
mutex_lock(&nodemgr_serialize_remove_uds);
|
||||
for (;;) {
|
||||
dev = class_find_device(&nodemgr_ud_class, ne, __match_ne);
|
||||
dev = class_find_device(&nodemgr_ud_class, NULL, ne,
|
||||
__match_ne);
|
||||
if (!dev)
|
||||
break;
|
||||
ud = container_of(dev, struct unit_directory, unit_dev);
|
||||
|
@ -901,7 +902,8 @@ static struct node_entry *find_entry_by_guid(u64 guid)
|
|||
struct device *dev;
|
||||
struct node_entry *ne;
|
||||
|
||||
dev = class_find_device(&nodemgr_ne_class, &guid, __match_ne_guid);
|
||||
dev = class_find_device(&nodemgr_ne_class, NULL, &guid,
|
||||
__match_ne_guid);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
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,
|
|||
param.host = host;
|
||||
param.nodeid = nodeid;
|
||||
|
||||
dev = class_find_device(&nodemgr_ne_class, ¶m, __match_ne_nodeid);
|
||||
dev = class_find_device(&nodemgr_ne_class, NULL, ¶m,
|
||||
__match_ne_nodeid);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
ne = container_of(dev, struct node_entry, node_dev);
|
||||
|
@ -1453,7 +1456,8 @@ static void nodemgr_suspend_ne(struct node_entry *ne)
|
|||
ne->in_limbo = 1;
|
||||
WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo));
|
||||
|
||||
class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_driver_suspend);
|
||||
class_for_each_device(&nodemgr_ud_class, NULL, ne,
|
||||
__nodemgr_driver_suspend);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1462,7 +1466,8 @@ static void nodemgr_resume_ne(struct node_entry *ne)
|
|||
ne->in_limbo = 0;
|
||||
device_remove_file(&ne->device, &dev_attr_ne_in_limbo);
|
||||
|
||||
class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_driver_resume);
|
||||
class_for_each_device(&nodemgr_ud_class, NULL, ne,
|
||||
__nodemgr_driver_resume);
|
||||
HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
|
||||
NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
|
||||
}
|
||||
|
@ -1498,7 +1503,8 @@ static int __nodemgr_update_pdrv(struct device *dev, void *data)
|
|||
|
||||
static void nodemgr_update_pdrv(struct node_entry *ne)
|
||||
{
|
||||
class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_update_pdrv);
|
||||
class_for_each_device(&nodemgr_ud_class, NULL, ne,
|
||||
__nodemgr_update_pdrv);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1591,7 +1597,8 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
|
|||
* while probes are time-consuming. (Well, those probes need some
|
||||
* improvement...) */
|
||||
|
||||
class_for_each_device(&nodemgr_ne_class, ¶m, __nodemgr_node_probe);
|
||||
class_for_each_device(&nodemgr_ne_class, NULL, ¶m,
|
||||
__nodemgr_node_probe);
|
||||
|
||||
/* If we had a bus reset while we were scanning the bus, it is
|
||||
* 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 *))
|
|||
|
||||
hip.cb = cb;
|
||||
hip.data = data;
|
||||
error = class_for_each_device(&hpsb_host_class, &hip,
|
||||
error = class_for_each_device(&hpsb_host_class, NULL, &hip,
|
||||
__nodemgr_for_each_host);
|
||||
|
||||
return error;
|
||||
|
|
|
@ -3010,10 +3010,10 @@ static int __init init_raw1394(void)
|
|||
hpsb_register_highlevel(&raw1394_highlevel);
|
||||
|
||||
if (IS_ERR
|
||||
(device_create(
|
||||
(device_create_drvdata(
|
||||
hpsb_protocol_class, NULL,
|
||||
MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
|
||||
RAW1394_DEVICE_NAME))) {
|
||||
NULL, RAW1394_DEVICE_NAME))) {
|
||||
ret = -EFAULT;
|
||||
goto out_unreg;
|
||||
}
|
||||
|
|
|
@ -1341,9 +1341,9 @@ static void video1394_add_host (struct hpsb_host *host)
|
|||
hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
|
||||
|
||||
minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
|
||||
device_create(hpsb_protocol_class, NULL,
|
||||
MKDEV(IEEE1394_MAJOR, minor),
|
||||
"%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
|
||||
device_create_drvdata(hpsb_protocol_class, NULL,
|
||||
MKDEV(IEEE1394_MAJOR, minor), NULL,
|
||||
"%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <linux/spinlock.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/kdev_t.h>
|
||||
|
||||
#include <rdma/ib_cache.h>
|
||||
#include <rdma/ib_cm.h>
|
||||
|
@ -162,8 +163,8 @@ struct cm_port {
|
|||
|
||||
struct cm_device {
|
||||
struct list_head list;
|
||||
struct ib_device *device;
|
||||
struct kobject dev_obj;
|
||||
struct ib_device *ib_device;
|
||||
struct device *device;
|
||||
u8 ack_delay;
|
||||
struct cm_port *port[0];
|
||||
};
|
||||
|
@ -339,7 +340,7 @@ static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc,
|
|||
{
|
||||
av->port = port;
|
||||
av->pkey_index = wc->pkey_index;
|
||||
ib_init_ah_from_wc(port->cm_dev->device, port->port_num, wc,
|
||||
ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc,
|
||||
grh, &av->ah_attr);
|
||||
}
|
||||
|
||||
|
@ -353,7 +354,7 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
|
|||
|
||||
read_lock_irqsave(&cm.device_lock, flags);
|
||||
list_for_each_entry(cm_dev, &cm.device_list, list) {
|
||||
if (!ib_find_cached_gid(cm_dev->device, &path->sgid,
|
||||
if (!ib_find_cached_gid(cm_dev->ib_device, &path->sgid,
|
||||
&p, NULL)) {
|
||||
port = cm_dev->port[p-1];
|
||||
break;
|
||||
|
@ -364,13 +365,13 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
|
|||
if (!port)
|
||||
return -EINVAL;
|
||||
|
||||
ret = ib_find_cached_pkey(cm_dev->device, port->port_num,
|
||||
ret = ib_find_cached_pkey(cm_dev->ib_device, port->port_num,
|
||||
be16_to_cpu(path->pkey), &av->pkey_index);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
av->port = port;
|
||||
ib_init_ah_from_path(cm_dev->device, port->port_num, path,
|
||||
ib_init_ah_from_path(cm_dev->ib_device, port->port_num, path,
|
||||
&av->ah_attr);
|
||||
av->timeout = path->packet_life_time + 1;
|
||||
return 0;
|
||||
|
@ -1515,7 +1516,7 @@ static int cm_req_handler(struct cm_work *work)
|
|||
|
||||
req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
|
||||
|
||||
cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
|
||||
cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
|
||||
if (IS_ERR(cm_id))
|
||||
return PTR_ERR(cm_id);
|
||||
|
||||
|
@ -1550,7 +1551,7 @@ static int cm_req_handler(struct cm_work *work)
|
|||
cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]);
|
||||
ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av);
|
||||
if (ret) {
|
||||
ib_get_cached_gid(work->port->cm_dev->device,
|
||||
ib_get_cached_gid(work->port->cm_dev->ib_device,
|
||||
work->port->port_num, 0, &work->path[0].sgid);
|
||||
ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
|
||||
&work->path[0].sgid, sizeof work->path[0].sgid,
|
||||
|
@ -2950,7 +2951,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
|
|||
struct cm_sidr_req_msg *sidr_req_msg;
|
||||
struct ib_wc *wc;
|
||||
|
||||
cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
|
||||
cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
|
||||
if (IS_ERR(cm_id))
|
||||
return PTR_ERR(cm_id);
|
||||
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)
|
|||
{
|
||||
struct ib_device_attr attr;
|
||||
|
||||
if (ib_query_device(cm_dev->device, &attr))
|
||||
if (ib_query_device(cm_dev->ib_device, &attr))
|
||||
cm_dev->ack_delay = 0; /* acks will rely on packet life time */
|
||||
else
|
||||
cm_dev->ack_delay = attr.local_ca_ack_delay;
|
||||
|
@ -3618,18 +3619,6 @@ static struct kobj_type cm_port_obj_type = {
|
|||
.release = cm_release_port_obj
|
||||
};
|
||||
|
||||
static void cm_release_dev_obj(struct kobject *obj)
|
||||
{
|
||||
struct cm_device *cm_dev;
|
||||
|
||||
cm_dev = container_of(obj, struct cm_device, dev_obj);
|
||||
kfree(cm_dev);
|
||||
}
|
||||
|
||||
static struct kobj_type cm_dev_obj_type = {
|
||||
.release = cm_release_dev_obj
|
||||
};
|
||||
|
||||
struct class cm_class = {
|
||||
.name = "infiniband_cm",
|
||||
};
|
||||
|
@ -3640,7 +3629,7 @@ static int cm_create_port_fs(struct cm_port *port)
|
|||
int i, ret;
|
||||
|
||||
ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type,
|
||||
&port->cm_dev->dev_obj,
|
||||
&port->cm_dev->device->kobj,
|
||||
"%d", port->port_num);
|
||||
if (ret) {
|
||||
kfree(port);
|
||||
|
@ -3676,7 +3665,7 @@ static void cm_remove_port_fs(struct cm_port *port)
|
|||
kobject_put(&port->port_obj);
|
||||
}
|
||||
|
||||
static void cm_add_one(struct ib_device *device)
|
||||
static void cm_add_one(struct ib_device *ib_device)
|
||||
{
|
||||
struct cm_device *cm_dev;
|
||||
struct cm_port *port;
|
||||
|
@ -3691,26 +3680,27 @@ static void cm_add_one(struct ib_device *device)
|
|||
int ret;
|
||||
u8 i;
|
||||
|
||||
if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
|
||||
if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
|
||||
return;
|
||||
|
||||
cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
|
||||
device->phys_port_cnt, GFP_KERNEL);
|
||||
ib_device->phys_port_cnt, GFP_KERNEL);
|
||||
if (!cm_dev)
|
||||
return;
|
||||
|
||||
cm_dev->device = device;
|
||||
cm_dev->ib_device = ib_device;
|
||||
cm_get_ack_delay(cm_dev);
|
||||
|
||||
ret = kobject_init_and_add(&cm_dev->dev_obj, &cm_dev_obj_type,
|
||||
&cm_class.subsys.kobj, "%s", device->name);
|
||||
if (ret) {
|
||||
cm_dev->device = device_create_drvdata(&cm_class, &ib_device->dev,
|
||||
MKDEV(0, 0), NULL,
|
||||
"%s", ib_device->name);
|
||||
if (!cm_dev->device) {
|
||||
kfree(cm_dev);
|
||||
return;
|
||||
}
|
||||
|
||||
set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
|
||||
for (i = 1; i <= device->phys_port_cnt; i++) {
|
||||
for (i = 1; i <= ib_device->phys_port_cnt; i++) {
|
||||
port = kzalloc(sizeof *port, GFP_KERNEL);
|
||||
if (!port)
|
||||
goto error1;
|
||||
|
@ -3723,7 +3713,7 @@ static void cm_add_one(struct ib_device *device)
|
|||
if (ret)
|
||||
goto error1;
|
||||
|
||||
port->mad_agent = ib_register_mad_agent(device, i,
|
||||
port->mad_agent = ib_register_mad_agent(ib_device, i,
|
||||
IB_QPT_GSI,
|
||||
®_req,
|
||||
0,
|
||||
|
@ -3733,11 +3723,11 @@ static void cm_add_one(struct ib_device *device)
|
|||
if (IS_ERR(port->mad_agent))
|
||||
goto error2;
|
||||
|
||||
ret = ib_modify_port(device, i, 0, &port_modify);
|
||||
ret = ib_modify_port(ib_device, i, 0, &port_modify);
|
||||
if (ret)
|
||||
goto error3;
|
||||
}
|
||||
ib_set_client_data(device, &cm_client, cm_dev);
|
||||
ib_set_client_data(ib_device, &cm_client, cm_dev);
|
||||
|
||||
write_lock_irqsave(&cm.device_lock, flags);
|
||||
list_add_tail(&cm_dev->list, &cm.device_list);
|
||||
|
@ -3753,14 +3743,14 @@ error1:
|
|||
port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
|
||||
while (--i) {
|
||||
port = cm_dev->port[i-1];
|
||||
ib_modify_port(device, port->port_num, 0, &port_modify);
|
||||
ib_modify_port(ib_device, port->port_num, 0, &port_modify);
|
||||
ib_unregister_mad_agent(port->mad_agent);
|
||||
cm_remove_port_fs(port);
|
||||
}
|
||||
kobject_put(&cm_dev->dev_obj);
|
||||
device_unregister(cm_dev->device);
|
||||
}
|
||||
|
||||
static void cm_remove_one(struct ib_device *device)
|
||||
static void cm_remove_one(struct ib_device *ib_device)
|
||||
{
|
||||
struct cm_device *cm_dev;
|
||||
struct cm_port *port;
|
||||
|
@ -3770,7 +3760,7 @@ static void cm_remove_one(struct ib_device *device)
|
|||
unsigned long flags;
|
||||
int i;
|
||||
|
||||
cm_dev = ib_get_client_data(device, &cm_client);
|
||||
cm_dev = ib_get_client_data(ib_device, &cm_client);
|
||||
if (!cm_dev)
|
||||
return;
|
||||
|
||||
|
@ -3778,14 +3768,14 @@ static void cm_remove_one(struct ib_device *device)
|
|||
list_del(&cm_dev->list);
|
||||
write_unlock_irqrestore(&cm.device_lock, flags);
|
||||
|
||||
for (i = 1; i <= device->phys_port_cnt; i++) {
|
||||
for (i = 1; i <= ib_device->phys_port_cnt; i++) {
|
||||
port = cm_dev->port[i-1];
|
||||
ib_modify_port(device, port->port_num, 0, &port_modify);
|
||||
ib_modify_port(ib_device, port->port_num, 0, &port_modify);
|
||||
ib_unregister_mad_agent(port->mad_agent);
|
||||
flush_workqueue(cm.wq);
|
||||
cm_remove_port_fs(port);
|
||||
}
|
||||
kobject_put(&cm_dev->dev_obj);
|
||||
device_unregister(cm_dev->device);
|
||||
}
|
||||
|
||||
static int __init ib_cm_init(void)
|
||||
|
|
|
@ -2455,7 +2455,7 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops,
|
|||
goto err_cdev;
|
||||
}
|
||||
|
||||
device = device_create(ipath_class, NULL, dev, name);
|
||||
device = device_create_drvdata(ipath_class, NULL, dev, NULL, name);
|
||||
|
||||
if (IS_ERR(device)) {
|
||||
ret = PTR_ERR(device);
|
||||
|
|
|
@ -1553,7 +1553,8 @@ static int __init capi_init(void)
|
|||
return PTR_ERR(capi_class);
|
||||
}
|
||||
|
||||
device_create(capi_class, NULL, MKDEV(capi_major, 0), "capi");
|
||||
device_create_drvdata(capi_class, NULL, MKDEV(capi_major, 0), NULL,
|
||||
"capi");
|
||||
|
||||
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
|
||||
if (capinc_tty_init() < 0) {
|
||||
|
|
|
@ -862,7 +862,8 @@ adbdev_init(void)
|
|||
adb_dev_class = class_create(THIS_MODULE, "adb");
|
||||
if (IS_ERR(adb_dev_class))
|
||||
return;
|
||||
device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), "adb");
|
||||
device_create_drvdata(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL,
|
||||
"adb");
|
||||
|
||||
platform_device_register(&adb_pfdev);
|
||||
platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
|
||||
|
|
|
@ -40,7 +40,7 @@ static struct mca_bus *mca_root_busses[MAX_MCA_BUSSES];
|
|||
|
||||
struct mca_device_info {
|
||||
short pos_id; /* the 2 byte pos id for this card */
|
||||
char name[DEVICE_NAME_SIZE];
|
||||
char name[50];
|
||||
};
|
||||
|
||||
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,
|
|||
|
||||
mutex_unlock(&dvbdev_register_lock);
|
||||
|
||||
clsdev = device_create(dvb_class, adap->device,
|
||||
clsdev = device_create_drvdata(dvb_class, adap->device,
|
||||
MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
|
||||
"dvb%d.%s%d", adap->num, dnames[type], id);
|
||||
NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
|
||||
if (IS_ERR(clsdev)) {
|
||||
printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n",
|
||||
__func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
|
||||
|
|
|
@ -51,7 +51,7 @@ struct jmb38x_ms_host {
|
|||
void __iomem *addr;
|
||||
spinlock_t lock;
|
||||
int id;
|
||||
char host_id[DEVICE_ID_SIZE];
|
||||
char host_id[32];
|
||||
int irq;
|
||||
unsigned int block_pos;
|
||||
unsigned long timeout_jiffies;
|
||||
|
@ -781,7 +781,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
|
|||
|
||||
spin_lock_init(&host->lock);
|
||||
host->id = cnt;
|
||||
snprintf(host->host_id, DEVICE_ID_SIZE, DRIVER_NAME ":slot%d",
|
||||
snprintf(host->host_id, sizeof(host->host_id), DRIVER_NAME ":slot%d",
|
||||
host->id);
|
||||
host->irq = jm->pdev->irq;
|
||||
host->timeout_jiffies = msecs_to_jiffies(1000);
|
||||
|
|
|
@ -1670,7 +1670,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||
INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work);
|
||||
spin_lock_init(&ioc->fault_reset_work_lock);
|
||||
|
||||
snprintf(ioc->reset_work_q_name, KOBJ_NAME_LEN, "mpt_poll_%d", ioc->id);
|
||||
snprintf(ioc->reset_work_q_name, sizeof(ioc->reset_work_q_name),
|
||||
"mpt_poll_%d", ioc->id);
|
||||
ioc->reset_work_q =
|
||||
create_singlethread_workqueue(ioc->reset_work_q_name);
|
||||
if (!ioc->reset_work_q) {
|
||||
|
|
|
@ -707,12 +707,12 @@ typedef struct _MPT_ADAPTER
|
|||
u8 fc_link_speed[2];
|
||||
spinlock_t fc_rescan_work_lock;
|
||||
struct work_struct fc_rescan_work;
|
||||
char fc_rescan_work_q_name[KOBJ_NAME_LEN];
|
||||
char fc_rescan_work_q_name[20];
|
||||
struct workqueue_struct *fc_rescan_work_q;
|
||||
struct scsi_cmnd **ScsiLookup;
|
||||
spinlock_t scsi_lookup_lock;
|
||||
|
||||
char reset_work_q_name[KOBJ_NAME_LEN];
|
||||
char reset_work_q_name[20];
|
||||
struct workqueue_struct *reset_work_q;
|
||||
struct delayed_work fault_reset_work;
|
||||
spinlock_t fault_reset_work_lock;
|
||||
|
|
|
@ -1326,8 +1326,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||
|
||||
/* initialize workqueue */
|
||||
|
||||
snprintf(ioc->fc_rescan_work_q_name, KOBJ_NAME_LEN, "mptfc_wq_%d",
|
||||
sh->host_no);
|
||||
snprintf(ioc->fc_rescan_work_q_name, sizeof(ioc->fc_rescan_work_q_name),
|
||||
"mptfc_wq_%d", sh->host_no);
|
||||
ioc->fc_rescan_work_q =
|
||||
create_singlethread_workqueue(ioc->fc_rescan_work_q_name);
|
||||
if (!ioc->fc_rescan_work_q)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue