Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
authorLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 20 Jun 2005 23:00:33 +0000 (16:00 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 20 Jun 2005 23:00:33 +0000 (16:00 -0700)
224 files changed:
Documentation/DocBook/kernel-api.tmpl
Documentation/driver-model/device.txt
Documentation/driver-model/driver.txt
Documentation/filesystems/sysfs.txt
arch/arm/common/amba.c
arch/arm/kernel/ecard.c
arch/arm26/kernel/ecard.c
arch/i386/kernel/cpuid.c
arch/i386/kernel/msr.c
arch/ia64/sn/kernel/tiocx.c
arch/parisc/kernel/drivers.c
arch/ppc/kernel/pci.c
arch/ppc/syslib/ocp.c
arch/ppc/syslib/of_device.c
arch/ppc64/kernel/of_device.c
arch/ppc64/kernel/pci.c
arch/ppc64/kernel/vio.c
drivers/acpi/scan.c
drivers/base/Makefile
drivers/base/base.h
drivers/base/bus.c
drivers/base/class.c
drivers/base/class_simple.c [deleted file]
drivers/base/core.c
drivers/base/dd.c [new file with mode: 0644]
drivers/base/dmapool.c
drivers/base/driver.c
drivers/base/node.c
drivers/base/power/resume.c
drivers/base/power/suspend.c
drivers/base/power/sysfs.c
drivers/base/sys.c
drivers/block/aoe/aoechr.c
drivers/block/as-iosched.c
drivers/block/cfq-iosched.c
drivers/block/deadline-iosched.c
drivers/block/genhd.c
drivers/block/ll_rw_blk.c
drivers/block/paride/pg.c
drivers/block/paride/pt.c
drivers/block/ub.c
drivers/char/dsp56k.c
drivers/char/ftape/zftape/zftape-init.c
drivers/char/hvcs.c
drivers/char/ip2main.c
drivers/char/ipmi/ipmi_devintf.c
drivers/char/istallion.c
drivers/char/lp.c
drivers/char/mbcs.c
drivers/char/mem.c
drivers/char/misc.c
drivers/char/mwave/mwavedd.c
drivers/char/ppdev.c
drivers/char/raw.c
drivers/char/snsc.c
drivers/char/stallion.c
drivers/char/tipar.c
drivers/char/tpm/tpm.c
drivers/char/tty_io.c
drivers/char/vc_screen.c
drivers/char/viotape.c
drivers/cpufreq/cpufreq.c
drivers/dio/dio-sysfs.c
drivers/eisa/eisa-bus.c
drivers/firmware/edd.c
drivers/firmware/efivars.c
drivers/i2c/chips/adm1021.c
drivers/i2c/chips/adm1025.c
drivers/i2c/chips/adm1026.c
drivers/i2c/chips/adm1031.c
drivers/i2c/chips/asb100.c
drivers/i2c/chips/ds1621.c
drivers/i2c/chips/fscher.c
drivers/i2c/chips/fscpos.c
drivers/i2c/chips/gl518sm.c
drivers/i2c/chips/gl520sm.c
drivers/i2c/chips/it87.c
drivers/i2c/chips/lm63.c
drivers/i2c/chips/lm75.c
drivers/i2c/chips/lm77.c
drivers/i2c/chips/lm78.c
drivers/i2c/chips/lm80.c
drivers/i2c/chips/lm83.c
drivers/i2c/chips/lm85.c
drivers/i2c/chips/lm87.c
drivers/i2c/chips/lm90.c
drivers/i2c/chips/lm92.c
drivers/i2c/chips/max1619.c
drivers/i2c/chips/pc87360.c
drivers/i2c/chips/pcf8574.c
drivers/i2c/chips/pcf8591.c
drivers/i2c/chips/sis5595.c
drivers/i2c/chips/smsc47b397.c
drivers/i2c/chips/smsc47m1.c
drivers/i2c/chips/via686a.c
drivers/i2c/chips/w83627hf.c
drivers/i2c/chips/w83781d.c
drivers/i2c/chips/w83l785ts.c
drivers/i2c/i2c-core.c
drivers/ieee1394/dv1394.c
drivers/ieee1394/ieee1394_core.c
drivers/ieee1394/ieee1394_core.h
drivers/ieee1394/nodemgr.c
drivers/ieee1394/raw1394.c
drivers/ieee1394/sbp2.c
drivers/ieee1394/video1394.c
drivers/infiniband/core/sysfs.c
drivers/input/evdev.c
drivers/input/gameport/gameport.c
drivers/input/input.c
drivers/input/joydev.c
drivers/input/keyboard/atkbd.c
drivers/input/mouse/psmouse.h
drivers/input/mousedev.c
drivers/input/serio/serio.c
drivers/input/tsdev.c
drivers/isdn/capi/capi.c
drivers/macintosh/adb.c
drivers/macintosh/therm_adt746x.c
drivers/macintosh/therm_pm72.c
drivers/macintosh/therm_windtunnel.c
drivers/mca/mca-bus.c
drivers/media/dvb/dvb-core/dvbdev.c
drivers/message/fusion/mptscsih.c
drivers/message/fusion/mptscsih.h
drivers/mmc/mmc_sysfs.c
drivers/net/ppp_generic.c
drivers/net/wan/cosa.c
drivers/pci/hotplug/cpqphp_sysfs.c
drivers/pci/hotplug/pci_hotplug_core.c
drivers/pci/hotplug/rpadlpar_sysfs.c
drivers/pci/hotplug/shpchp_sysfs.c
drivers/pci/pci-driver.c
drivers/pci/pci-sysfs.c
drivers/pci/pcie/portdrv_core.c
drivers/pcmcia/ds.c
drivers/pnp/card.c
drivers/pnp/driver.c
drivers/pnp/interface.c
drivers/s390/block/dasd_devmap.c
drivers/s390/block/dcssblk.c
drivers/s390/char/raw3270.c
drivers/s390/char/tape_class.c
drivers/s390/char/tape_core.c
drivers/s390/char/vmlogrdr.c
drivers/s390/cio/ccwgroup.c
drivers/s390/cio/chsc.c
drivers/s390/cio/cmf.c
drivers/s390/cio/device.c
drivers/s390/net/claw.c
drivers/s390/net/ctcmain.c
drivers/s390/net/lcs.c
drivers/s390/net/netiucv.c
drivers/s390/net/qeth_sys.c
drivers/s390/scsi/zfcp_scsi.c
drivers/s390/scsi/zfcp_sysfs_adapter.c
drivers/s390/scsi/zfcp_sysfs_port.c
drivers/s390/scsi/zfcp_sysfs_unit.c
drivers/scsi/53c700.c
drivers/scsi/arm/eesox.c
drivers/scsi/arm/powertec.c
drivers/scsi/ipr.c
drivers/scsi/megaraid/megaraid_mbox.c
drivers/scsi/osst.c
drivers/scsi/scsi_sysfs.c
drivers/scsi/scsi_transport_spi.c
drivers/scsi/sg.c
drivers/scsi/st.c
drivers/sh/superhyway/superhyway-sysfs.c
drivers/usb/core/devices.c
drivers/usb/core/file.c
drivers/usb/core/hcd.c
drivers/usb/core/sysfs.c
drivers/usb/core/usb.c
drivers/usb/gadget/dummy_hcd.c
drivers/usb/gadget/file_storage.c
drivers/usb/gadget/net2280.c
drivers/usb/gadget/pxa2xx_udc.c
drivers/usb/host/ehci-dbg.c
drivers/usb/host/ohci-dbg.c
drivers/usb/input/aiptek.c
drivers/usb/misc/cytherm.c
drivers/usb/misc/phidgetkit.c
drivers/usb/misc/phidgetservo.c
drivers/usb/misc/usbled.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/storage/scsiglue.c
drivers/video/fbmem.c
drivers/video/gbefb.c
drivers/video/w100fb.c
drivers/w1/w1.c
drivers/w1/w1_family.h
drivers/w1/w1_smem.c
drivers/w1/w1_therm.c
drivers/zorro/zorro-sysfs.c
fs/coda/psdev.c
fs/debugfs/file.c
fs/libfs.c
fs/sysfs/bin.c
fs/sysfs/dir.c
fs/sysfs/file.c
fs/sysfs/inode.c
fs/sysfs/mount.c
fs/sysfs/symlink.c
fs/sysfs/sysfs.h
include/asm-ppc/ocp.h
include/linux/device.h
include/linux/fs.h
include/linux/i2c-sysfs.h [new file with mode: 0644]
include/linux/input.h
include/linux/klist.h [new file with mode: 0644]
include/linux/kobject.h
include/linux/node.h
include/linux/sysfs.h
include/linux/usb.h
kernel/params.c
lib/Makefile
lib/klist.c [new file with mode: 0644]
lib/kobject.c
lib/kobject_uevent.c
security/seclvl.c
sound/core/sound.c
sound/oss/soundcard.c
sound/sound_core.c

index 757cef8f84918165b68a8ee67a763fb21fd342b3..bb6a0106be1100951a7b99696f9e8176bd862e7e 100644 (file)
@@ -338,7 +338,6 @@ X!Earch/i386/kernel/mca.c
 X!Iinclude/linux/device.h
 -->
 !Edrivers/base/driver.c
-!Edrivers/base/class_simple.c
 !Edrivers/base/core.c
 !Edrivers/base/firmware_class.c
 !Edrivers/base/transport_class.c
index 58cc5dc8fd3eac2f8851674db7909d0f56c32f79..a05ec50f8004dd65f29c87579612389f93660187 100644 (file)
@@ -76,6 +76,14 @@ driver_data:   Driver-specific data.
 
 platform_data: Platform data specific to the device.
 
+              Example:  for devices on custom boards, as typical of embedded
+              and SOC based hardware, Linux often uses platform_data to point
+              to board-specific structures describing devices and how they
+              are wired.  That can include what ports are available, chip
+              variants, which GPIO pins act in what additional roles, and so
+              on.  This shrinks the "Board Support Packages" (BSPs) and
+              minimizes board-specific #ifdefs in drivers.
+
 current_state: Current power state of the device.
 
 saved_state:   Pointer to saved state of the device. This is usable by
index 6031a68dd3f5c249ea5daf391948d058fda44fef..fabaca1ab1b0b0f56980a4802b81b7a11e1aa241 100644 (file)
@@ -5,21 +5,17 @@ struct device_driver {
         char                    * name;
         struct bus_type         * bus;
 
-        rwlock_t                lock;
-        atomic_t                refcount;
-
-        list_t                  bus_list;
+        struct completion      unloaded;
+        struct kobject         kobj;
         list_t                  devices;
 
-        struct driver_dir_entry dir;
+        struct module          *owner;
 
         int     (*probe)        (struct device * dev);
         int     (*remove)       (struct device * dev);
 
         int     (*suspend)      (struct device * dev, pm_message_t state, u32 level);
         int     (*resume)       (struct device * dev, u32 level);
-
-        void    (*release)      (struct device_driver * drv);
 };
 
 
@@ -51,7 +47,6 @@ being converted completely to the new model.
 static struct device_driver eepro100_driver = {
        .name           = "eepro100",
        .bus            = &pci_bus_type,
-       .devclass       = &ethernet_devclass,   /* when it's implemented */
        
        .probe          = eepro100_probe,
        .remove         = eepro100_remove,
@@ -85,7 +80,6 @@ static struct pci_driver eepro100_driver = {
        .driver        = {
                .name           = "eepro100",
                .bus            = &pci_bus_type,
-               .devclass       = &ethernet_devclass,   /* when it's implemented */
                .probe          = eepro100_probe,
                .remove         = eepro100_remove,
                .suspend        = eepro100_suspend,
@@ -166,27 +160,32 @@ Callbacks
 
        int     (*probe)        (struct device * dev);
 
-probe is called to verify the existence of a certain type of
-hardware. This is called during the driver binding process, after the
-bus has verified that the device ID of a device matches one of the
-device IDs supported by the driver. 
-
-This callback only verifies that there actually is supported hardware
-present. It may allocate a driver-specific structure, but it should
-not do any initialization of the hardware itself. The device-specific
-structure may be stored in the device's driver_data field. 
-
-       int     (*init)         (struct device * dev);
-
-init is called during the binding stage. It is called after probe has
-successfully returned and the device has been registered with its
-class. It is responsible for initializing the hardware.
+The probe() entry is called in task context, with the bus's rwsem locked
+and the driver partially bound to the device.  Drivers commonly use
+container_of() to convert "dev" to a bus-specific type, both in probe()
+and other routines.  That type often provides device resource data, such
+as pci_dev.resource[] or platform_device.resources, which is used in
+addition to dev->platform_data to initialize the driver.
+
+This callback holds the driver-specific logic to bind the driver to a
+given device.  That includes verifying that the device is present, that
+it's a version the driver can handle, that driver data structures can
+be allocated and initialized, and that any hardware can be initialized.
+Drivers often store a pointer to their state with dev_set_drvdata().
+When the driver has successfully bound itself to that device, then probe()
+returns zero and the driver model code will finish its part of binding
+the driver to that device.
+
+A driver's probe() may return a negative errno value to indicate that
+the driver did not bind to this device, in which case it should have
+released all reasources it allocated.
 
        int     (*remove)       (struct device * dev);
 
-remove is called to dissociate a driver with a device. This may be
+remove is called to unbind a driver from a device. This may be
 called if a device is physically removed from the system, if the
-driver module is being unloaded, or during a reboot sequence. 
+driver module is being unloaded, during a reboot sequence, or
+in other cases.
 
 It is up to the driver to determine if the device is present or
 not. It should free any resources allocated specifically for the
index 60f6c2c4d477968e2966eb152183fe1c71bc689b..dc276598a65a3784c4dd7d41470c41f288db9529 100644 (file)
@@ -214,7 +214,7 @@ Other notes:
 
 A very simple (and naive) implementation of a device attribute is:
 
-static ssize_t show_name(struct device * dev, char * buf)
+static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
 {
         return sprintf(buf,"%s\n",dev->name);
 }
index a0507f8c33fe815838a825a6abf069e035eeaef1..c6beb751f2a93b4057a49df188d8522e1809dcdc 100644 (file)
@@ -169,7 +169,7 @@ static void amba_device_release(struct device *dev)
 }
 
 #define amba_attr(name,fmt,arg...)                             \
-static ssize_t show_##name(struct device *_dev, char *buf)     \
+static ssize_t show_##name(struct device *_dev, struct device_attribute *attr, char *buf)      \
 {                                                              \
        struct amba_device *dev = to_amba_device(_dev);         \
        return sprintf(buf, fmt, arg);                          \
index 3dc15b131f532e4494e0dffa5ba4ed99fa703688..6540db6913381f4474d12594c6a84376d53724dd 100644 (file)
@@ -866,19 +866,19 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
        return ec;
 }
 
-static ssize_t ecard_show_irq(struct device *dev, char *buf)
+static ssize_t ecard_show_irq(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->irq);
 }
 
-static ssize_t ecard_show_dma(struct device *dev, char *buf)
+static ssize_t ecard_show_dma(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->dma);
 }
 
-static ssize_t ecard_show_resources(struct device *dev, char *buf)
+static ssize_t ecard_show_resources(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        char *str = buf;
@@ -893,19 +893,19 @@ static ssize_t ecard_show_resources(struct device *dev, char *buf)
        return str - buf;
 }
 
-static ssize_t ecard_show_vendor(struct device *dev, char *buf)
+static ssize_t ecard_show_vendor(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->cid.manufacturer);
 }
 
-static ssize_t ecard_show_device(struct device *dev, char *buf)
+static ssize_t ecard_show_device(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->cid.product);
 }
 
-static ssize_t ecard_show_type(struct device *dev, char *buf)
+static ssize_t ecard_show_type(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%s\n", ec->type == ECARD_EASI ? "EASI" : "IOC");
index 824c6b571ad933614ab04a41ad4ad3bac446307a..f2278aadac8a28638312039ff3f6cd05cd4db640 100644 (file)
@@ -562,31 +562,31 @@ static void __init ecard_init_resources(struct expansion_card *ec)
        }
 }
 
-static ssize_t ecard_show_irq(struct device *dev, char *buf)
+static ssize_t ecard_show_irq(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->irq);
 }
 
-static ssize_t ecard_show_vendor(struct device *dev, char *buf)
+static ssize_t ecard_show_vendor(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->cid.manufacturer);
 }
 
-static ssize_t ecard_show_device(struct device *dev, char *buf)
+static ssize_t ecard_show_device(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->cid.product);
 }
 
-static ssize_t ecard_show_dma(struct device *dev, char *buf)
+static ssize_t ecard_show_dma(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->dma);
 }
 
-static ssize_t ecard_show_resources(struct device *dev, char *buf)
+static ssize_t ecard_show_resources(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        char *str = buf;
index 2e2756345bb23964f763ff747e284c7e89050678..4647db4ad6de9a8bd7bc9ab9bb32a4f3d594dd5c 100644 (file)
@@ -45,7 +45,7 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
-static struct class_simple *cpuid_class;
+static struct class *cpuid_class;
 
 #ifdef CONFIG_SMP
 
@@ -158,12 +158,12 @@ static struct file_operations cpuid_fops = {
        .open = cpuid_open,
 };
 
-static int cpuid_class_simple_device_add(int i) 
+static int cpuid_class_device_create(int i)
 {
        int err = 0;
        struct class_device *class_err;
 
-       class_err = class_simple_device_add(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
+       class_err = class_device_create(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
        if (IS_ERR(class_err))
                err = PTR_ERR(class_err);
        return err;
@@ -175,10 +175,10 @@ static int __devinit cpuid_class_cpu_callback(struct notifier_block *nfb, unsign
 
        switch (action) {
        case CPU_ONLINE:
-               cpuid_class_simple_device_add(cpu);
+               cpuid_class_device_create(cpu);
                break;
        case CPU_DEAD:
-               class_simple_device_remove(MKDEV(CPUID_MAJOR, cpu));
+               class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
                break;
        }
        return NOTIFY_OK;
@@ -200,13 +200,13 @@ static int __init cpuid_init(void)
                err = -EBUSY;
                goto out;
        }
-       cpuid_class = class_simple_create(THIS_MODULE, "cpuid");
+       cpuid_class = class_create(THIS_MODULE, "cpuid");
        if (IS_ERR(cpuid_class)) {
                err = PTR_ERR(cpuid_class);
                goto out_chrdev;
        }
        for_each_online_cpu(i) {
-               err = cpuid_class_simple_device_add(i);
+               err = cpuid_class_device_create(i);
                if (err != 0) 
                        goto out_class;
        }
@@ -218,9 +218,9 @@ static int __init cpuid_init(void)
 out_class:
        i = 0;
        for_each_online_cpu(i) {
-               class_simple_device_remove(MKDEV(CPUID_MAJOR, i));
+               class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, i));
        }
-       class_simple_destroy(cpuid_class);
+       class_destroy(cpuid_class);
 out_chrdev:
        unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");    
 out:
@@ -232,8 +232,8 @@ static void __exit cpuid_exit(void)
        int cpu = 0;
 
        for_each_online_cpu(cpu)
-               class_simple_device_remove(MKDEV(CPUID_MAJOR, cpu));
-       class_simple_destroy(cpuid_class);
+               class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
+       class_destroy(cpuid_class);
        unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
        unregister_cpu_notifier(&cpuid_class_cpu_notifier);
 }
index 05d9f8f363a695dc330f69d5550de0f43e774fff..b2f03c39a6fed5eebcd381776ae0948e3f280d4a 100644 (file)
@@ -44,7 +44,7 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
-static struct class_simple *msr_class;
+static struct class *msr_class;
 
 /* Note: "err" is handled in a funny way below.  Otherwise one version
    of gcc or another breaks. */
@@ -260,12 +260,12 @@ static struct file_operations msr_fops = {
        .open = msr_open,
 };
 
-static int msr_class_simple_device_add(int i)
+static int msr_class_device_create(int i)
 {
        int err = 0;
        struct class_device *class_err;
 
-       class_err = class_simple_device_add(msr_class, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i);
+       class_err = class_device_create(msr_class, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i);
        if (IS_ERR(class_err)) 
                err = PTR_ERR(class_err);
        return err;
@@ -277,10 +277,10 @@ static int __devinit msr_class_cpu_callback(struct notifier_block *nfb, unsigned
 
        switch (action) {
        case CPU_ONLINE:
-               msr_class_simple_device_add(cpu);
+               msr_class_device_create(cpu);
                break;
        case CPU_DEAD:
-               class_simple_device_remove(MKDEV(MSR_MAJOR, cpu));      
+               class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
                break;
        }
        return NOTIFY_OK;
@@ -302,13 +302,13 @@ static int __init msr_init(void)
                err = -EBUSY;
                goto out;
        }
-       msr_class = class_simple_create(THIS_MODULE, "msr");
+       msr_class = class_create(THIS_MODULE, "msr");
        if (IS_ERR(msr_class)) {
                err = PTR_ERR(msr_class);
                goto out_chrdev;
        }
        for_each_online_cpu(i) {
-               err = msr_class_simple_device_add(i);
+               err = msr_class_device_create(i);
                if (err != 0)
                        goto out_class;
        }
@@ -320,8 +320,8 @@ static int __init msr_init(void)
 out_class:
        i = 0;
        for_each_online_cpu(i)
-               class_simple_device_remove(MKDEV(MSR_MAJOR, i));
-       class_simple_destroy(msr_class);
+               class_device_destroy(msr_class, MKDEV(MSR_MAJOR, i));
+       class_destroy(msr_class);
 out_chrdev:
        unregister_chrdev(MSR_MAJOR, "cpu/msr");
 out:
@@ -332,8 +332,8 @@ static void __exit msr_exit(void)
 {
        int cpu = 0;
        for_each_online_cpu(cpu)
-               class_simple_device_remove(MKDEV(MSR_MAJOR, cpu));
-       class_simple_destroy(msr_class);
+               class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
+       class_destroy(msr_class);
        unregister_chrdev(MSR_MAJOR, "cpu/msr");
        unregister_cpu_notifier(&msr_class_cpu_notifier);
 }
index ab9b5f35c2a72ba9bf6a398029e888dbeed3d129..a087b274847e52a265f94f473d707baa6d26fc89 100644 (file)
@@ -432,7 +432,7 @@ static int tiocx_reload(struct cx_dev *cx_dev)
        return cx_device_reload(cx_dev);
 }
 
-static ssize_t show_cxdev_control(struct device *dev, char *buf)
+static ssize_t show_cxdev_control(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct cx_dev *cx_dev = to_cx_dev(dev);
 
@@ -442,7 +442,7 @@ static ssize_t show_cxdev_control(struct device *dev, char *buf)
                       tiocx_btchar_get(cx_dev->cx_id.nasid));
 }
 
-static ssize_t store_cxdev_control(struct device *dev, const char *buf,
+static ssize_t store_cxdev_control(struct device *dev, struct device_attribute *attr, const char *buf,
                                   size_t count)
 {
        int n;
@@ -518,25 +518,22 @@ static int __init tiocx_init(void)
        return 0;
 }
 
-static void __exit tiocx_exit(void)
+static int cx_remove_device(struct device * dev, void * data)
 {
-       struct device *dev;
-       struct device *tdev;
+       struct cx_dev *cx_dev = to_cx_dev(dev);
+       device_remove_file(dev, &dev_attr_cxdev_control);
+       cx_device_unregister(cx_dev);
+       return 0;
+}
 
+static void __exit tiocx_exit(void)
+{
        DBG("tiocx_exit\n");
 
        /*
         * Unregister devices.
         */
-       list_for_each_entry_safe(dev, tdev, &tiocx_bus_type.devices.list,
-                                bus_list) {
-               if (dev) {
-                       struct cx_dev *cx_dev = to_cx_dev(dev);
-                       device_remove_file(dev, &dev_attr_cxdev_control);
-                       cx_device_unregister(cx_dev);
-               }
-       }
-
+       bus_for_each_dev(&tiocx_bus_type, NULL, NULL, cx_remove_device);
        bus_unregister(&tiocx_bus_type);
 }
 
index ebf186656afbd16bc2a0040990388462228704d6..d34bbe7ae0e3e9d192e73fe774702891bae98a6a 100644 (file)
@@ -466,7 +466,7 @@ static int parisc_generic_match(struct device *dev, struct device_driver *drv)
 }
 
 #define pa_dev_attr(name, field, format_string)                                \
-static ssize_t name##_show(struct device *dev, char *buf)              \
+static ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf)               \
 {                                                                      \
        struct parisc_device *padev = to_parisc_device(dev);            \
        return sprintf(buf, format_string, padev->field);               \
index 47a15306823ae4d603a262e6dfa1dffbd9b55740..6d7b92d724582c87b9bd23b7e54752191c269666 100644 (file)
@@ -1003,7 +1003,7 @@ pci_create_OF_bus_map(void)
        }
 }
 
-static ssize_t pci_show_devspec(struct device *dev, char *buf)
+static ssize_t pci_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct pci_dev *pdev;
        struct device_node *np;
index a5156c5179a617ac0ef4baeb109c30170d1d401c..e5fd2ae503ea7c2240c373f022ffa0c989ad52e3 100644 (file)
@@ -68,7 +68,7 @@ static int ocp_inited;
 /* Sysfs support */
 #define OCP_DEF_ATTR(field, format_string)                             \
 static ssize_t                                                         \
-show_##field(struct device *dev, char *buf)                            \
+show_##field(struct device *dev, struct device_attribute *attr, char *buf)                             \
 {                                                                      \
        struct ocp_device *odev = to_ocp_dev(dev);                      \
                                                                        \
index 46269ed21aee77eaab1d784ec4e57910c3b6adc1..49c0e34e2d6bf2abf8c37522337e122e007c71ce 100644 (file)
@@ -161,7 +161,7 @@ void of_unregister_driver(struct of_platform_driver *drv)
 }
 
 
-static ssize_t dev_show_devspec(struct device *dev, char *buf)
+static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct of_device *ofdev;
 
index f4c825a69fa0ce700065f51ed48a71cfa5d5985b..66bd5ab7c25a4f17a3d95430fcc790c68e2c6360 100644 (file)
@@ -161,7 +161,7 @@ void of_unregister_driver(struct of_platform_driver *drv)
 }
 
 
-static ssize_t dev_show_devspec(struct device *dev, char *buf)
+static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct of_device *ofdev;
 
index d786d4b6af0b2a78403d4bb1325b9f2c2be414fe..2bf0513f3eca0a0fa2c53f50640ef312def4cc71 100644 (file)
@@ -507,7 +507,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
 }
 
 #ifdef CONFIG_PPC_MULTIPLATFORM
-static ssize_t pci_show_devspec(struct device *dev, char *buf)
+static ssize_t pci_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct pci_dev *pdev;
        struct device_node *np;
index cdd830cb2768b6de5e2642022b383a78941935eb..79f2dc7a9833c481e91c8e3981d9db7b38335f23 100644 (file)
@@ -300,7 +300,7 @@ static void __devinit vio_dev_release(struct device *dev)
 }
 
 #ifdef CONFIG_PPC_PSERIES
-static ssize_t viodev_show_devspec(struct device *dev, char *buf)
+static ssize_t viodev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct device_node *of_node = dev->platform_data;
 
@@ -309,7 +309,7 @@ static ssize_t viodev_show_devspec(struct device *dev, char *buf)
 DEVICE_ATTR(devspec, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_devspec, NULL);
 #endif
 
-static ssize_t viodev_show_name(struct device *dev, char *buf)
+static ssize_t viodev_show_name(struct device *dev, struct device_attribute *attr, char *buf)
 {
        return sprintf(buf, "%s\n", to_vio_dev(dev)->name);
 }
index 119c94093a136a4704f0422b25cf30e2e26fccbe..e85885593280dde6313df7ac701785c23511ecb0 100644 (file)
@@ -65,14 +65,14 @@ static ssize_t acpi_device_attr_show(struct kobject *kobj,
 {
        struct acpi_device *device = to_acpi_device(kobj);
        struct acpi_device_attribute *attribute = to_handle_attr(attr);
-       return attribute->show ? attribute->show(device, buf) : 0;
+       return attribute->show ? attribute->show(device, buf) : -EIO;
 }
 static ssize_t acpi_device_attr_store(struct kobject *kobj,
                struct attribute *attr, const char *buf, size_t len)
 {
        struct acpi_device *device = to_acpi_device(kobj);
        struct acpi_device_attribute *attribute = to_handle_attr(attr);
-       return attribute->store ? attribute->store(device, buf, len) : len;
+       return attribute->store ? attribute->store(device, buf, len) : -EIO;
 }
 
 static struct sysfs_ops acpi_device_sysfs_ops = {
index a47928a2e57508a30bb527143d3c503201592f00..66d9c4643fc1d0857cbaac240a2cc7a9f6dbfff6 100644 (file)
@@ -1,7 +1,7 @@
 # Makefile for the Linux device tree
 
-obj-y                  := core.o sys.o bus.o \
-                          driver.o class.o class_simple.o platform.o \
+obj-y                  := core.o sys.o bus.o dd.o \
+                          driver.o class.o platform.o \
                           cpu.o firmware.o init.o map.o dmapool.o \
                           attribute_container.o transport_class.o
 obj-y                  += power/
index 8d1e8bd48632e68b001755d673c3f90bfad47b03..645f626929209dd9e59cef9cd3070de9f0181a71 100644 (file)
@@ -4,6 +4,8 @@ extern void bus_remove_device(struct device * dev);
 extern int bus_add_driver(struct device_driver *);
 extern void bus_remove_driver(struct device_driver *);
 
+extern void driver_detach(struct device_driver * drv);
+
 static inline struct class_device *to_class_dev(struct kobject *obj)
 {
        return container_of(obj, struct class_device, kobj);
index 3cb04bb04c2b8e0d80ad910f8b6e94935be1c089..43722af90bddf2e01343bc24de33e25668952237 100644 (file)
@@ -17,9 +17,6 @@
 #include "base.h"
 #include "power/power.h"
 
-#define to_dev(node) container_of(node, struct device, bus_list)
-#define to_drv(node) container_of(node, struct device_driver, kobj.entry)
-
 #define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr)
 #define to_bus(obj) container_of(obj, struct bus_type, subsys.kset.kobj)
 
@@ -36,7 +33,7 @@ drv_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
 {
        struct driver_attribute * drv_attr = to_drv_attr(attr);
        struct device_driver * drv = to_driver(kobj);
-       ssize_t ret = 0;
+       ssize_t ret = -EIO;
 
        if (drv_attr->show)
                ret = drv_attr->show(drv, buf);
@@ -49,7 +46,7 @@ drv_attr_store(struct kobject * kobj, struct attribute * attr,
 {
        struct driver_attribute * drv_attr = to_drv_attr(attr);
        struct device_driver * drv = to_driver(kobj);
-       ssize_t ret = 0;
+       ssize_t ret = -EIO;
 
        if (drv_attr->store)
                ret = drv_attr->store(drv, buf, count);
@@ -135,50 +132,11 @@ static struct kobj_type ktype_bus = {
 
 decl_subsys(bus, &ktype_bus, NULL);
 
-static int __bus_for_each_dev(struct bus_type *bus, struct device *start,
-                             void *data, int (*fn)(struct device *, void *))
-{
-       struct list_head *head;
-       struct device *dev;
-       int error = 0;
-
-       if (!(bus = get_bus(bus)))
-               return -EINVAL;
-
-       head = &bus->devices.list;
-       dev = list_prepare_entry(start, head, bus_list);
-       list_for_each_entry_continue(dev, head, bus_list) {
-               get_device(dev);
-               error = fn(dev, data);
-               put_device(dev);
-               if (error)
-                       break;
-       }
-       put_bus(bus);
-       return error;
-}
 
-static int __bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
-                             void * data, int (*fn)(struct device_driver *, void *))
+static struct device * next_device(struct klist_iter * i)
 {
-       struct list_head *head;
-       struct device_driver *drv;
-       int error = 0;
-
-       if (!(bus = get_bus(bus)))
-               return -EINVAL;
-
-       head = &bus->drivers.list;
-       drv = list_prepare_entry(start, head, kobj.entry);
-       list_for_each_entry_continue(drv, head, kobj.entry) {
-               get_driver(drv);
-               error = fn(drv, data);
-               put_driver(drv);
-               if (error)
-                       break;
-       }
-       put_bus(bus);
-       return error;
+       struct klist_node * n = klist_next(i);
+       return n ? container_of(n, struct device, knode_bus) : NULL;
 }
 
 /**
@@ -204,12 +162,27 @@ static int __bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
 int bus_for_each_dev(struct bus_type * bus, struct device * start,
                     void * data, int (*fn)(struct device *, void *))
 {
-       int ret;
+       struct klist_iter i;
+       struct device * dev;
+       int error = 0;
 
-       down_read(&bus->subsys.rwsem);
-       ret = __bus_for_each_dev(bus, start, data, fn);
-       up_read(&bus->subsys.rwsem);
-       return ret;
+       if (!bus)
+               return -EINVAL;
+
+       klist_iter_init_node(&bus->klist_devices, &i,
+                            (start ? &start->knode_bus : NULL));
+       while ((dev = next_device(&i)) && !error)
+               error = fn(dev, data);
+       klist_iter_exit(&i);
+       return error;
+}
+
+
+
+static struct device_driver * next_driver(struct klist_iter * i)
+{
+       struct klist_node * n = klist_next(i);
+       return n ? container_of(n, struct device_driver, knode_bus) : NULL;
 }
 
 /**
@@ -235,179 +208,19 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start,
 int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
                     void * data, int (*fn)(struct device_driver *, void *))
 {
-       int ret;
-
-       down_read(&bus->subsys.rwsem);
-       ret = __bus_for_each_drv(bus, start, data, fn);
-       up_read(&bus->subsys.rwsem);
-       return ret;
-}
-
-/**
- *     device_bind_driver - bind a driver to one device.
- *     @dev:   device.
- *
- *     Allow manual attachment of a driver to a device.
- *     Caller must have already set @dev->driver.
- *
- *     Note that this does not modify the bus reference count
- *     nor take the bus's rwsem. Please verify those are accounted
- *     for before calling this. (It is ok to call with no other effort
- *     from a driver's probe() method.)
- */
-
-void device_bind_driver(struct device * dev)
-{
-       pr_debug("bound device '%s' to driver '%s'\n",
-                dev->bus_id, dev->driver->name);
-       list_add_tail(&dev->driver_list, &dev->driver->devices);
-       sysfs_create_link(&dev->driver->kobj, &dev->kobj,
-                         kobject_name(&dev->kobj));
-       sysfs_create_link(&dev->kobj, &dev->driver->kobj, "driver");
-}
-
-
-/**
- *     driver_probe_device - attempt to bind device & driver.
- *     @drv:   driver.
- *     @dev:   device.
- *
- *     First, we call the bus's match function, if one present, which
- *     should compare the device IDs the driver supports with the
- *     device IDs of the device. Note we don't do this ourselves
- *     because we don't know the format of the ID structures, nor what
- *     is to be considered a match and what is not.
- *
- *     If we find a match, we call @drv->probe(@dev) if it exists, and
- *     call device_bind_driver() above.
- */
-int driver_probe_device(struct device_driver * drv, struct device * dev)
-{
-       if (drv->bus->match && !drv->bus->match(dev, drv))
-               return -ENODEV;
-
-       dev->driver = drv;
-       if (drv->probe) {
-               int error = drv->probe(dev);
-               if (error) {
-                       dev->driver = NULL;
-                       return error;
-               }
-       }
-
-       device_bind_driver(dev);
-       return 0;
-}
-
-
-/**
- *     device_attach - try to attach device to a driver.
- *     @dev:   device.
- *
- *     Walk the list of drivers that the bus has and call
- *     driver_probe_device() for each pair. If a compatible
- *     pair is found, break out and return.
- */
-int device_attach(struct device * dev)
-{
-       struct bus_type * bus = dev->bus;
-       struct list_head * entry;
-       int error;
-
-       if (dev->driver) {
-               device_bind_driver(dev);
-               return 1;
-       }
-
-       if (bus->match) {
-               list_for_each(entry, &bus->drivers.list) {
-                       struct device_driver * drv = to_drv(entry);
-                       error = driver_probe_device(drv, dev);
-                       if (!error)
-                               /* success, driver matched */
-                               return 1;
-                       if (error != -ENODEV && error != -ENXIO)
-                               /* driver matched but the probe failed */
-                               printk(KERN_WARNING
-                                   "%s: probe of %s failed with error %d\n",
-                                   drv->name, dev->bus_id, error);
-               }
-       }
-
-       return 0;
-}
-
-
-/**
- *     driver_attach - try to bind driver to devices.
- *     @drv:   driver.
- *
- *     Walk the list of devices that the bus has on it and try to
- *     match the driver with each one.  If driver_probe_device()
- *     returns 0 and the @dev->driver is set, we've found a
- *     compatible pair.
- *
- *     Note that we ignore the -ENODEV error from driver_probe_device(),
- *     since it's perfectly valid for a driver not to bind to any devices.
- */
-void driver_attach(struct device_driver * drv)
-{
-       struct bus_type * bus = drv->bus;
-       struct list_head * entry;
-       int error;
-
-       if (!bus->match)
-               return;
-
-       list_for_each(entry, &bus->devices.list) {
-               struct device * dev = container_of(entry, struct device, bus_list);
-               if (!dev->driver) {
-                       error = driver_probe_device(drv, dev);
-                       if (error && (error != -ENODEV))
-                               /* driver matched but the probe failed */
-                               printk(KERN_WARNING
-                                   "%s: probe of %s failed with error %d\n",
-                                   drv->name, dev->bus_id, error);
-               }
-       }
-}
-
-
-/**
- *     device_release_driver - manually detach device from driver.
- *     @dev:   device.
- *
- *     Manually detach device from driver.
- *     Note that this is called without incrementing the bus
- *     reference count nor taking the bus's rwsem. Be sure that
- *     those are accounted for before calling this function.
- */
-
-void device_release_driver(struct device * dev)
-{
-       struct device_driver * drv = dev->driver;
-       if (drv) {
-               sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
-               sysfs_remove_link(&dev->kobj, "driver");
-               list_del_init(&dev->driver_list);
-               if (drv->remove)
-                       drv->remove(dev);
-               dev->driver = NULL;
-       }
-}
-
+       struct klist_iter i;
+       struct device_driver * drv;
+       int error = 0;
 
-/**
- *     driver_detach - detach driver from all devices it controls.
- *     @drv:   driver.
- */
+       if (!bus)
+               return -EINVAL;
 
-static void driver_detach(struct device_driver * drv)
-{
-       while (!list_empty(&drv->devices)) {
-               struct device * dev = container_of(drv->devices.next, struct device, driver_list);
-               device_release_driver(dev);
-       }
+       klist_iter_init_node(&bus->klist_drivers, &i,
+                            start ? &start->knode_bus : NULL);
+       while ((drv = next_driver(&i)) && !error)
+               error = fn(drv, data);
+       klist_iter_exit(&i);
+       return error;
 }
 
 static int device_add_attrs(struct bus_type * bus, struct device * dev)
@@ -456,14 +269,15 @@ int bus_add_device(struct device * dev)
        int error = 0;
 
        if (bus) {
-               down_write(&dev->bus->subsys.rwsem);
                pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
-               list_add_tail(&dev->bus_list, &dev->bus->devices.list);
-               device_attach(dev);
-               up_write(&dev->bus->subsys.rwsem);
-               device_add_attrs(bus, dev);
-               sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
-               sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
+               error = device_attach(dev);
+               klist_add_tail(&bus->klist_devices, &dev->knode_bus);
+               if (error >= 0)
+                       error = device_add_attrs(bus, dev);
+               if (!error) {
+                       sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
+                       sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
+               }
        }
        return error;
 }
@@ -483,11 +297,9 @@ void bus_remove_device(struct device * dev)
                sysfs_remove_link(&dev->kobj, "bus");
                sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
                device_remove_attrs(dev->bus, dev);
-               down_write(&dev->bus->subsys.rwsem);
+               klist_remove(&dev->knode_bus);
                pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
                device_release_driver(dev);
-               list_del_init(&dev->bus_list);
-               up_write(&dev->bus->subsys.rwsem);
                put_bus(dev->bus);
        }
 }
@@ -547,9 +359,8 @@ int bus_add_driver(struct device_driver * drv)
                        return error;
                }
 
-               down_write(&bus->subsys.rwsem);
                driver_attach(drv);
-               up_write(&bus->subsys.rwsem);
+               klist_add_tail(&bus->klist_drivers, &drv->knode_bus);
                module_add_driver(drv->owner, drv);
 
                driver_add_attrs(bus, drv);
@@ -571,10 +382,9 @@ void bus_remove_driver(struct device_driver * drv)
 {
        if (drv->bus) {
                driver_remove_attrs(drv->bus, drv);
-               down_write(&drv->bus->subsys.rwsem);
+               klist_remove(&drv->knode_bus);
                pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
                driver_detach(drv);
-               up_write(&drv->bus->subsys.rwsem);
                module_remove_driver(drv);
                kobject_unregister(&drv->kobj);
                put_bus(drv->bus);
@@ -587,7 +397,7 @@ static int bus_rescan_devices_helper(struct device *dev, void *data)
 {
        int *count = data;
 
-       if (!dev->driver && device_attach(dev))
+       if (!dev->driver && (device_attach(dev) > 0))
                (*count)++;
 
        return 0;
@@ -607,9 +417,7 @@ int bus_rescan_devices(struct bus_type * bus)
 {
        int count = 0;
 
-       down_write(&bus->subsys.rwsem);
-       __bus_for_each_dev(bus, NULL, &count, bus_rescan_devices_helper);
-       up_write(&bus->subsys.rwsem);
+       bus_for_each_dev(bus, NULL, &count, bus_rescan_devices_helper);
 
        return count;
 }
@@ -710,6 +518,9 @@ int bus_register(struct bus_type * bus)
        retval = kset_register(&bus->drivers);
        if (retval)
                goto bus_drivers_fail;
+
+       klist_init(&bus->klist_devices);
+       klist_init(&bus->klist_drivers);
        bus_add_attrs(bus);
 
        pr_debug("bus type '%s' registered\n", bus->name);
@@ -749,12 +560,6 @@ int __init buses_init(void)
 EXPORT_SYMBOL_GPL(bus_for_each_dev);
 EXPORT_SYMBOL_GPL(bus_for_each_drv);
 
-EXPORT_SYMBOL_GPL(driver_probe_device);
-EXPORT_SYMBOL_GPL(device_bind_driver);
-EXPORT_SYMBOL_GPL(device_release_driver);
-EXPORT_SYMBOL_GPL(device_attach);
-EXPORT_SYMBOL_GPL(driver_attach);
-
 EXPORT_SYMBOL_GPL(bus_add_device);
 EXPORT_SYMBOL_GPL(bus_remove_device);
 EXPORT_SYMBOL_GPL(bus_register);
index d2a2f8f2b4ed49d7c9e60e4c3a768f7ce53065e4..479c12570881374f9bdb6fafb172879b583b20bc 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/kdev_t.h>
+#include <linux/err.h>
 #include "base.h"
 
 #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
@@ -26,7 +27,7 @@ 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);
-       ssize_t ret = 0;
+       ssize_t ret = -EIO;
 
        if (class_attr->show)
                ret = class_attr->show(dc, buf);
@@ -39,7 +40,7 @@ class_attr_store(struct kobject * kobj, struct attribute * attr,
 {
        struct class_attribute * class_attr = to_class_attr(attr);
        struct class * dc = to_class(kobj);
-       ssize_t ret = 0;
+       ssize_t ret = -EIO;
 
        if (class_attr->store)
                ret = class_attr->store(dc, buf, count);
@@ -162,6 +163,69 @@ void class_unregister(struct class * cls)
        subsystem_unregister(&cls->subsys);
 }
 
+static void class_create_release(struct class *cls)
+{
+       kfree(cls);
+}
+
+static void class_device_create_release(struct class_device *class_dev)
+{
+       kfree(class_dev);
+}
+
+/**
+ * class_create - create a struct class structure
+ * @owner: pointer to the module that is to "own" this struct class
+ * @name: pointer to a string for the name of this class.
+ *
+ * This is used to create a struct class pointer that can then be used
+ * in calls to class_device_create().
+ *
+ * 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, char *name)
+{
+       struct class *cls;
+       int retval;
+
+       cls = kmalloc(sizeof(struct class), GFP_KERNEL);
+       if (!cls) {
+               retval = -ENOMEM;
+               goto error;
+       }
+       memset(cls, 0x00, sizeof(struct class));
+
+       cls->name = name;
+       cls->owner = owner;
+       cls->class_release = class_create_release;
+       cls->release = class_device_create_release;
+
+       retval = class_register(cls);
+       if (retval)
+               goto error;
+
+       return cls;
+
+error:
+       kfree(cls);
+       return ERR_PTR(retval);
+}
+
+/**
+ * class_destroy - destroys a struct class structure
+ * @cs: pointer to the struct class that is to be destroyed
+ *
+ * Note, the pointer to be destroyed must have been created with a call
+ * to class_create().
+ */
+void class_destroy(struct class *cls)
+{
+       if ((cls == NULL) || (IS_ERR(cls)))
+               return;
+
+       class_unregister(cls);
+}
 
 /* Class Device Stuff */
 
@@ -262,7 +326,7 @@ static int class_hotplug_filter(struct kset *kset, struct kobject *kobj)
        return 0;
 }
 
-static char *class_hotplug_name(struct kset *kset, struct kobject *kobj)
+static const char *class_hotplug_name(struct kset *kset, struct kobject *kobj)
 {
        struct class_device *class_dev = to_class_dev(kobj);
 
@@ -375,7 +439,6 @@ static ssize_t show_dev(struct class_device *class_dev, char *buf)
 {
        return print_dev_t(buf, class_dev->devt);
 }
-static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
 
 void class_device_initialize(struct class_device *class_dev)
 {
@@ -412,7 +475,31 @@ int class_device_add(struct class_device *class_dev)
        if ((error = kobject_add(&class_dev->kobj)))
                goto register_done;
 
-       /* now take care of our own registration */
+       /* add the needed attributes to this device */
+       if (MAJOR(class_dev->devt)) {
+               struct class_device_attribute *attr;
+               attr = kmalloc(sizeof(*attr), GFP_KERNEL);
+               if (!attr) {
+                       error = -ENOMEM;
+                       kobject_del(&class_dev->kobj);
+                       goto register_done;
+               }
+               memset(attr, sizeof(*attr), 0x00);
+               attr->attr.name = "dev";
+               attr->attr.mode = S_IRUGO;
+               attr->attr.owner = parent->owner;
+               attr->show = show_dev;
+               attr->store = NULL;
+               class_device_create_file(class_dev, attr);
+               class_dev->devt_attr = attr;
+       }
+
+       class_device_add_attrs(class_dev);
+       if (class_dev->dev)
+               sysfs_create_link(&class_dev->kobj,
+                                 &class_dev->dev->kobj, "device");
+
+       /* notify any interfaces this device is now here */
        if (parent) {
                down(&parent->sem);
                list_add_tail(&class_dev->node, &parent->children);
@@ -421,16 +508,8 @@ int class_device_add(struct class_device *class_dev)
                                class_intf->add(class_dev);
                up(&parent->sem);
        }
-
-       if (MAJOR(class_dev->devt))
-               class_device_create_file(class_dev, &class_device_attr_dev);
-
-       class_device_add_attrs(class_dev);
-       if (class_dev->dev)
-               sysfs_create_link(&class_dev->kobj,
-                                 &class_dev->dev->kobj, "device");
-
        kobject_hotplug(&class_dev->kobj, KOBJ_ADD);
+
  register_done:
        if (error && parent)
                class_put(parent);
@@ -444,6 +523,58 @@ int class_device_register(struct class_device *class_dev)
        return class_device_add(class_dev);
 }
 
+/**
+ * class_device_create - creates a class device and registers it with sysfs
+ * @cs: pointer to the struct class that this device should be registered to.
+ * @dev: the dev_t for the char device to be added.
+ * @device: a pointer to a struct device that is assiociated with this class device.
+ * @fmt: string for the class device's name
+ *
+ * This function can be used by char device classes.  A struct
+ * class_device will be created in sysfs, registered to the specified
+ * class.  A "dev" file will be created, showing the dev_t for the
+ * device.  The pointer to the struct class_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 class_device *class_device_create(struct class *cls, dev_t devt,
+                                        struct device *device, char *fmt, ...)
+{
+       va_list args;
+       struct class_device *class_dev = NULL;
+       int retval = -ENODEV;
+
+       if (cls == NULL || IS_ERR(cls))
+               goto error;
+
+       class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL);
+       if (!class_dev) {
+               retval = -ENOMEM;
+               goto error;
+       }
+       memset(class_dev, 0x00, sizeof(struct class_device));
+
+       class_dev->devt = devt;
+       class_dev->dev = device;
+       class_dev->class = cls;
+
+       va_start(args, fmt);
+       vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args);
+       va_end(args);
+       retval = class_device_register(class_dev);
+       if (retval)
+               goto error;
+
+       return class_dev;
+
+error:
+       kfree(class_dev);
+       return ERR_PTR(retval);
+}
+
 void class_device_del(struct class_device *class_dev)
 {
        struct class * parent = class_dev->class;
@@ -460,6 +591,11 @@ void class_device_del(struct class_device *class_dev)
 
        if (class_dev->dev)
                sysfs_remove_link(&class_dev->kobj, "device");
+       if (class_dev->devt_attr) {
+               class_device_remove_file(class_dev, class_dev->devt_attr);
+               kfree(class_dev->devt_attr);
+               class_dev->devt_attr = NULL;
+       }
        class_device_remove_attrs(class_dev);
 
        kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE);
@@ -477,6 +613,32 @@ void class_device_unregister(struct class_device *class_dev)
        class_device_put(class_dev);
 }
 
+/**
+ * class_device_destroy - removes a class device that was created with class_device_create()
+ * @cls: the pointer to the struct class that this device was registered * with.
+ * @dev: the dev_t of the device that was previously registered.
+ *
+ * This call unregisters and cleans up a class device that was created with a
+ * call to class_device_create()
+ */
+void class_device_destroy(struct class *cls, dev_t devt)
+{
+       struct class_device *class_dev = NULL;
+       struct class_device *class_dev_tmp;
+
+       down(&cls->sem);
+       list_for_each_entry(class_dev_tmp, &cls->children, node) {
+               if (class_dev_tmp->devt == devt) {
+                       class_dev = class_dev_tmp;
+                       break;
+               }
+       }
+       up(&cls->sem);
+
+       if (class_dev)
+               class_device_unregister(class_dev);
+}
+
 int class_device_rename(struct class_device *class_dev, char *new_name)
 {
        int error = 0;
@@ -576,6 +738,8 @@ EXPORT_SYMBOL_GPL(class_register);
 EXPORT_SYMBOL_GPL(class_unregister);
 EXPORT_SYMBOL_GPL(class_get);
 EXPORT_SYMBOL_GPL(class_put);
+EXPORT_SYMBOL_GPL(class_create);
+EXPORT_SYMBOL_GPL(class_destroy);
 
 EXPORT_SYMBOL_GPL(class_device_register);
 EXPORT_SYMBOL_GPL(class_device_unregister);
@@ -584,6 +748,8 @@ EXPORT_SYMBOL_GPL(class_device_add);
 EXPORT_SYMBOL_GPL(class_device_del);
 EXPORT_SYMBOL_GPL(class_device_get);
 EXPORT_SYMBOL_GPL(class_device_put);
+EXPORT_SYMBOL_GPL(class_device_create);
+EXPORT_SYMBOL_GPL(class_device_destroy);
 EXPORT_SYMBOL_GPL(class_device_create_file);
 EXPORT_SYMBOL_GPL(class_device_remove_file);
 EXPORT_SYMBOL_GPL(class_device_create_bin_file);
diff --git a/drivers/base/class_simple.c b/drivers/base/class_simple.c
deleted file mode 100644 (file)
index 27699eb..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * class_simple.c - a "simple" interface for classes for simple char devices.
- *
- * Copyright (c) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
- * Copyright (c) 2003-2004 IBM Corp.
- *
- * This file is released under the GPLv2
- *
- */
-
-#include <linux/config.h>
-#include <linux/device.h>
-#include <linux/err.h>
-
-struct class_simple {
-       struct class class;
-};
-#define to_class_simple(d) container_of(d, struct class_simple, class)
-
-struct simple_dev {
-       struct list_head node;
-       struct class_device class_dev;
-};
-#define to_simple_dev(d) container_of(d, struct simple_dev, class_dev)
-
-static LIST_HEAD(simple_dev_list);
-static DEFINE_SPINLOCK(simple_dev_list_lock);
-
-static void release_simple_dev(struct class_device *class_dev)
-{
-       struct simple_dev *s_dev = to_simple_dev(class_dev);
-       kfree(s_dev);
-}
-
-static void class_simple_release(struct class *class)
-{
-       struct class_simple *cs = to_class_simple(class);
-       kfree(cs);
-}
-
-/**
- * class_simple_create - create a struct class_simple structure
- * @owner: pointer to the module that is to "own" this struct class_simple
- * @name: pointer to a string for the name of this class.
- *
- * This is used to create a struct class_simple pointer that can then be used
- * in calls to class_simple_device_add().  This is used when you do not wish to
- * create a full blown class support for a type of char devices.
- *
- * Note, the pointer created here is to be destroyed when finished by making a
- * call to class_simple_destroy().
- */
-struct class_simple *class_simple_create(struct module *owner, char *name)
-{
-       struct class_simple *cs;
-       int retval;
-
-       cs = kmalloc(sizeof(*cs), GFP_KERNEL);
-       if (!cs) {
-               retval = -ENOMEM;
-               goto error;
-       }
-       memset(cs, 0x00, sizeof(*cs));
-
-       cs->class.name = name;
-       cs->class.class_release = class_simple_release;
-       cs->class.release = release_simple_dev;
-
-       retval = class_register(&cs->class);
-       if (retval)
-               goto error;
-
-       return cs;
-
-error:
-       kfree(cs);
-       return ERR_PTR(retval);
-}
-EXPORT_SYMBOL(class_simple_create);
-
-/**
- * class_simple_destroy - destroys a struct class_simple structure
- * @cs: pointer to the struct class_simple that is to be destroyed
- *
- * Note, the pointer to be destroyed must have been created with a call to
- * class_simple_create().
- */
-void class_simple_destroy(struct class_simple *cs)
-{
-       if ((cs == NULL) || (IS_ERR(cs)))
-               return;
-
-       class_unregister(&cs->class);
-}
-EXPORT_SYMBOL(class_simple_destroy);
-
-/**
- * class_simple_device_add - adds a class device to sysfs for a character driver
- * @cs: pointer to the struct class_simple that this device should be registered to.
- * @dev: the dev_t for the device to be added.
- * @device: a pointer to a struct device that is assiociated with this class device.
- * @fmt: string for the class device's name
- *
- * This function can be used by simple char device classes that do not
- * implement their own class device registration.  A struct class_device will
- * be created in sysfs, registered to the specified class.  A "dev" file will
- * be created, showing the dev_t for the device.  The pointer to the struct
- * class_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_simple passed to this function must have previously been
- * created with a call to class_simple_create().
- */
-struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...)
-{
-       va_list args;
-       struct simple_dev *s_dev = NULL;
-       int retval;
-
-       if ((cs == NULL) || (IS_ERR(cs))) {
-               retval = -ENODEV;
-               goto error;
-       }
-
-       s_dev = kmalloc(sizeof(*s_dev), GFP_KERNEL);
-       if (!s_dev) {
-               retval = -ENOMEM;
-               goto error;
-       }
-       memset(s_dev, 0x00, sizeof(*s_dev));
-
-       s_dev->class_dev.devt = dev;
-       s_dev->class_dev.dev = device;
-       s_dev->class_dev.class = &cs->class;
-
-       va_start(args, fmt);
-       vsnprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, fmt, args);
-       va_end(args);
-       retval = class_device_register(&s_dev->class_dev);
-       if (retval)
-               goto error;
-
-       spin_lock(&simple_dev_list_lock);
-       list_add(&s_dev->node, &simple_dev_list);
-       spin_unlock(&simple_dev_list_lock);
-
-       return &s_dev->class_dev;
-
-error:
-       kfree(s_dev);
-       return ERR_PTR(retval);
-}
-EXPORT_SYMBOL(class_simple_device_add);
-
-/**
- * class_simple_set_hotplug - set the hotplug callback in the embedded struct class
- * @cs: pointer to the struct class_simple to hold the pointer
- * @hotplug: function pointer to the hotplug function
- *
- * Implement and set a hotplug function to add environment variables specific to this
- * class on the hotplug event.
- */
-int class_simple_set_hotplug(struct class_simple *cs,
-       int (*hotplug)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size))
-{
-       if ((cs == NULL) || (IS_ERR(cs)))
-               return -ENODEV;
-       cs->class.hotplug = hotplug;
-       return 0;
-}
-EXPORT_SYMBOL(class_simple_set_hotplug);
-
-/**
- * class_simple_device_remove - removes a class device that was created with class_simple_device_add()
- * @dev: the dev_t of the device that was previously registered.
- *
- * This call unregisters and cleans up a class device that was created with a
- * call to class_device_simple_add()
- */
-void class_simple_device_remove(dev_t dev)
-{
-       struct simple_dev *s_dev = NULL;
-       int found = 0;
-
-       spin_lock(&simple_dev_list_lock);
-       list_for_each_entry(s_dev, &simple_dev_list, node) {
-               if (s_dev->class_dev.devt == dev) {
-                       found = 1;
-                       break;
-               }
-       }
-       if (found) {
-               list_del(&s_dev->node);
-               spin_unlock(&simple_dev_list_lock);
-               class_device_unregister(&s_dev->class_dev);
-       } else {
-               spin_unlock(&simple_dev_list_lock);
-       }
-}
-EXPORT_SYMBOL(class_simple_device_remove);
index fbc223486f81b2b8380b0e157a81e429986ff73c..86d79755fbfb9d4c62c572df8d0585200d1064bf 100644 (file)
@@ -36,10 +36,10 @@ dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
 {
        struct device_attribute * dev_attr = to_dev_attr(attr);
        struct device * dev = to_dev(kobj);
-       ssize_t ret = 0;
+       ssize_t ret = -EIO;
 
        if (dev_attr->show)
-               ret = dev_attr->show(dev, buf);
+               ret = dev_attr->show(dev, dev_attr, buf);
        return ret;
 }
 
@@ -49,10 +49,10 @@ dev_attr_store(struct kobject * kobj, struct attribute * attr,
 {
        struct device_attribute * dev_attr = to_dev_attr(attr);
        struct device * dev = to_dev(kobj);
-       ssize_t ret = 0;
+       ssize_t ret = -EIO;
 
        if (dev_attr->store)
-               ret = dev_attr->store(dev, buf, count);
+               ret = dev_attr->store(dev, dev_attr, buf, count);
        return ret;
 }
 
@@ -102,7 +102,7 @@ static int dev_hotplug_filter(struct kset *kset, struct kobject *kobj)
        return 0;
 }
 
-static char *dev_hotplug_name(struct kset *kset, struct kobject *kobj)
+static const char *dev_hotplug_name(struct kset *kset, struct kobject *kobj)
 {
        struct device *dev = to_dev(kobj);
 
@@ -207,11 +207,9 @@ void device_initialize(struct device *dev)
 {
        kobj_set_kset_s(dev, devices_subsys);
        kobject_init(&dev->kobj);
-       INIT_LIST_HEAD(&dev->node);
-       INIT_LIST_HEAD(&dev->children);
-       INIT_LIST_HEAD(&dev->driver_list);
-       INIT_LIST_HEAD(&dev->bus_list);
+       klist_init(&dev->klist_children);
        INIT_LIST_HEAD(&dev->dma_pools);
+       init_MUTEX(&dev->sem);
 }
 
 /**
@@ -250,10 +248,8 @@ int device_add(struct device *dev)
                goto PMError;
        if ((error = bus_add_device(dev)))
                goto BusError;
-       down_write(&devices_subsys.rwsem);
        if (parent)
-               list_add_tail(&dev->node, &parent->children);
-       up_write(&devices_subsys.rwsem);
+               klist_add_tail(&parent->klist_children, &dev->knode_parent);
 
        /* notify platform of device entry */
        if (platform_notify)
@@ -336,10 +332,8 @@ void device_del(struct device * dev)
 {
        struct device * parent = dev->parent;
 
-       down_write(&devices_subsys.rwsem);
        if (parent)
-               list_del_init(&dev->node);
-       up_write(&devices_subsys.rwsem);
+               klist_remove(&dev->knode_parent);
 
        /* Notify the platform of the removal, in case they
         * need to do anything...
@@ -373,6 +367,12 @@ void device_unregister(struct device * dev)
 }
 
 
+static struct device * next_device(struct klist_iter * i)
+{
+       struct klist_node * n = klist_next(i);
+       return n ? container_of(n, struct device, knode_parent) : NULL;
+}
+
 /**
  *     device_for_each_child - device child iterator.
  *     @dev:   parent struct device.
@@ -385,39 +385,20 @@ void device_unregister(struct device * dev)
  *     We check the return of @fn each time. If it returns anything
  *     other than 0, we break out and return that value.
  */
-int device_for_each_child(struct device * dev, void * data,
+int device_for_each_child(struct device * parent, void * data,
                     int (*fn)(struct device *, void *))
 {
+       struct klist_iter i;
        struct device * child;
        int error = 0;
 
-       down_read(&devices_subsys.rwsem);
-       list_for_each_entry(child, &dev->children, node) {
-               if((error = fn(child, data)))
-                       break;
-       }
-       up_read(&devices_subsys.rwsem);
+       klist_iter_init(&parent->klist_children, &i);
+       while ((child = next_device(&i)) && !error)
+               error = fn(child, data);
+       klist_iter_exit(&i);
        return error;
 }
 
-/**
- *     device_find - locate device on a bus by name.
- *     @name:  name of the device.
- *     @bus:   bus to scan for the device.
- *
- *     Call kset_find_obj() to iterate over list of devices on
- *     a bus to find device by name. Return device if found.
- *
- *     Note that kset_find_obj increments device's reference count.
- */
-struct device *device_find(const char *name, struct bus_type *bus)
-{
-       struct kobject *k = kset_find_obj(&bus->devices, name);
-       if (k)
-               return to_dev(k);
-       return NULL;
-}
-
 int __init devices_init(void)
 {
        return subsystem_register(&devices_subsys);
@@ -433,7 +414,6 @@ EXPORT_SYMBOL_GPL(device_del);
 EXPORT_SYMBOL_GPL(device_unregister);
 EXPORT_SYMBOL_GPL(get_device);
 EXPORT_SYMBOL_GPL(put_device);
-EXPORT_SYMBOL_GPL(device_find);
 
 EXPORT_SYMBOL_GPL(device_create_file);
 EXPORT_SYMBOL_GPL(device_remove_file);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
new file mode 100644 (file)
index 0000000..6db3a78
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ *     drivers/base/dd.c - The core device/driver interactions.
+ *
+ *     This file contains the (sometimes tricky) code that controls the
+ *     interactions between devices and drivers, which primarily includes
+ *     driver binding and unbinding.
+ *
+ *     All of this code used to exist in drivers/base/bus.c, but was
+ *     relocated to here in the name of compartmentalization (since it wasn't
+ *     strictly code just for the 'struct bus_type'.
+ *
+ *     Copyright (c) 2002-5 Patrick Mochel
+ *     Copyright (c) 2002-3 Open Source Development Labs
+ *
+ *     This file is released under the GPLv2
+ */
+
+#include <linux/device.h>
+#include <linux/module.h>
+
+#include "base.h"
+#include "power/power.h"
+
+#define to_drv(node) container_of(node, struct device_driver, kobj.entry)
+
+
+/**
+ *     device_bind_driver - bind a driver to one device.
+ *     @dev:   device.
+ *
+ *     Allow manual attachment of a driver to a device.
+ *     Caller must have already set @dev->driver.
+ *
+ *     Note that this does not modify the bus reference count
+ *     nor take the bus's rwsem. Please verify those are accounted
+ *     for before calling this. (It is ok to call with no other effort
+ *     from a driver's probe() method.)
+ *
+ *     This function must be called with @dev->sem held.
+ */
+void device_bind_driver(struct device * dev)
+{
+       pr_debug("bound device '%s' to driver '%s'\n",
+                dev->bus_id, dev->driver->name);
+       klist_add_tail(&dev->driver->klist_devices, &dev->knode_driver);
+       sysfs_create_link(&dev->driver->kobj, &dev->kobj,
+                         kobject_name(&dev->kobj));
+       sysfs_create_link(&dev->kobj, &dev->driver->kobj, "driver");
+}
+
+/**
+ *     driver_probe_device - attempt to bind device & driver.
+ *     @drv:   driver.
+ *     @dev:   device.
+ *
+ *     First, we call the bus's match function, if one present, which
+ *     should compare the device IDs the driver supports with the
+ *     device IDs of the device. Note we don't do this ourselves
+ *     because we don't know the format of the ID structures, nor what
+ *     is to be considered a match and what is not.
+ *
+ *
+ *     This function returns 1 if a match is found, an error if one
+ *     occurs (that is not -ENODEV or -ENXIO), and 0 otherwise.
+ *
+ *     This function must be called with @dev->sem held.
+ */
+static int driver_probe_device(struct device_driver * drv, struct device * dev)
+{
+       int ret = 0;
+
+       if (drv->bus->match && !drv->bus->match(dev, drv))
+               goto Done;
+
+       pr_debug("%s: Matched Device %s with Driver %s\n",
+                drv->bus->name, dev->bus_id, drv->name);
+       dev->driver = drv;
+       if (drv->probe) {
+               ret = drv->probe(dev);
+               if (ret) {
+                       dev->driver = NULL;
+                       goto ProbeFailed;
+               }
+       }
+       device_bind_driver(dev);
+       ret = 1;
+       pr_debug("%s: Bound Device %s to Driver %s\n",
+                drv->bus->name, dev->bus_id, drv->name);
+       goto Done;
+
+ ProbeFailed:
+       if (ret == -ENODEV || ret == -ENXIO) {
+               /* Driver matched, but didn't support device
+                * or device not found.
+                * Not an error; keep going.
+                */
+               ret = 0;
+       } else {
+               /* driver matched but the probe failed */
+               printk(KERN_WARNING
+                      "%s: probe of %s failed with error %d\n",
+                      drv->name, dev->bus_id, ret);
+       }
+ Done:
+       return ret;
+}
+
+static int __device_attach(struct device_driver * drv, void * data)
+{
+       struct device * dev = data;
+       return driver_probe_device(drv, dev);
+}
+
+/**
+ *     device_attach - try to attach device to a driver.
+ *     @dev:   device.
+ *
+ *     Walk the list of drivers that the bus has and call
+ *     driver_probe_device() for each pair. If a compatible
+ *     pair is found, break out and return.
+ *
+ *     Returns 1 if the device was bound to a driver;
+ *     0 if no matching device was found; error code otherwise.
+ */
+int device_attach(struct device * dev)
+{
+       int ret = 0;
+
+       down(&dev->sem);
+       if (dev->driver) {
+               device_bind_driver(dev);
+               ret = 1;
+       } else
+               ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
+       up(&dev->sem);
+       return ret;
+}
+
+static int __driver_attach(struct device * dev, void * data)
+{
+       struct device_driver * drv = data;
+
+       /*
+        * Lock device and try to bind to it. We drop the error
+        * here and always return 0, because we need to keep trying
+        * to bind to devices and some drivers will return an error
+        * simply if it didn't support the device.
+        *
+        * driver_probe_device() will spit a warning if there
+        * is an error.
+        */
+
+       down(&dev->sem);
+       if (!dev->driver)
+               driver_probe_device(drv, dev);
+       up(&dev->sem);
+
+
+       return 0;
+}
+
+/**
+ *     driver_attach - try to bind driver to devices.
+ *     @drv:   driver.
+ *
+ *     Walk the list of devices that the bus has on it and try to
+ *     match the driver with each one.  If driver_probe_device()
+ *     returns 0 and the @dev->driver is set, we've found a
+ *     compatible pair.
+ */
+void driver_attach(struct device_driver * drv)
+{
+       bus_for_each_dev(drv->bus, NULL, drv, __driver_attach);
+}
+
+/**
+ *     device_release_driver - manually detach device from driver.
+ *     @dev:   device.
+ *
+ *     Manually detach device from driver.
+ *
+ *     __device_release_driver() must be called with @dev->sem held.
+ */
+
+static void __device_release_driver(struct device * dev)
+{
+       struct device_driver * drv;
+
+       drv = dev->driver;
+       if (drv) {
+               get_driver(drv);
+               sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
+               sysfs_remove_link(&dev->kobj, "driver");
+               klist_remove(&dev->knode_driver);
+
+               if (drv->remove)
+                       drv->remove(dev);
+               dev->driver = NULL;
+               put_driver(drv);
+       }
+}
+
+void device_release_driver(struct device * dev)
+{
+       /*
+        * If anyone calls device_release_driver() recursively from
+        * within their ->remove callback for the same device, they
+        * will deadlock right here.
+        */
+       down(&dev->sem);
+       __device_release_driver(dev);
+       up(&dev->sem);
+}
+
+
+/**
+ * driver_detach - detach driver from all devices it controls.
+ * @drv: driver.
+ */
+void driver_detach(struct device_driver * drv)
+{
+       struct device * dev;
+
+       for (;;) {
+               spin_lock_irq(&drv->klist_devices.k_lock);
+               if (list_empty(&drv->klist_devices.k_list)) {
+                       spin_unlock_irq(&drv->klist_devices.k_lock);
+                       break;
+               }
+               dev = list_entry(drv->klist_devices.k_list.prev,
+                               struct device, knode_driver.n_node);
+               get_device(dev);
+               spin_unlock_irq(&drv->klist_devices.k_lock);
+
+               down(&dev->sem);
+               if (dev->driver == drv)
+                       __device_release_driver(dev);
+               up(&dev->sem);
+               put_device(dev);
+       }
+}
+
+
+EXPORT_SYMBOL_GPL(device_bind_driver);
+EXPORT_SYMBOL_GPL(device_release_driver);
+EXPORT_SYMBOL_GPL(device_attach);
+EXPORT_SYMBOL_GPL(driver_attach);
+
index f48833df61a29dfba2c469abba7bc4ed6516aa77..c4aebf2f522d724abfbb8e1c5538ac8441322bbd 100644 (file)
@@ -41,7 +41,7 @@ struct dma_page {     /* cacheable header for 'allocation' bytes */
 static DECLARE_MUTEX (pools_lock);
 
 static ssize_t
-show_pools (struct device *dev, char *buf)
+show_pools (struct device *dev, struct device_attribute *attr, char *buf)
 {
        unsigned temp;
        unsigned size;
index 3b269f7e52135472c70b6102e17ca31a5b24c050..1b645886e9eba14046fbb0d62fd7051477ff43a5 100644 (file)
 #define to_dev(node) container_of(node, struct device, driver_list)
 #define to_drv(obj) container_of(obj, struct device_driver, kobj)
 
+
+static struct device * next_device(struct klist_iter * i)
+{
+       struct klist_node * n = klist_next(i);
+       return n ? container_of(n, struct device, knode_driver) : NULL;
+}
+
+/**
+ *     driver_for_each_device - Iterator for devices bound to a driver.
+ *     @drv:   Driver we're iterating.
+ *     @data:  Data to pass to the callback.
+ *     @fn:    Function to call for each device.
+ *
+ *     Iterate over the @drv's list of devices calling @fn for each one.
+ */
+
+int driver_for_each_device(struct device_driver * drv, struct device * start, 
+                          void * data, int (*fn)(struct device *, void *))
+{
+       struct klist_iter i;
+       struct device * dev;
+       int error = 0;
+
+       if (!drv)
+               return -EINVAL;
+
+       klist_iter_init_node(&drv->klist_devices, &i,
+                            start ? &start->knode_driver : NULL);
+       while ((dev = next_device(&i)) && !error)
+               error = fn(dev, data);
+       klist_iter_exit(&i);
+       return error;
+}
+
+EXPORT_SYMBOL_GPL(driver_for_each_device);
+
+
 /**
  *     driver_create_file - create sysfs file for driver.
  *     @drv:   driver.
@@ -85,7 +122,7 @@ void put_driver(struct device_driver * drv)
  */
 int driver_register(struct device_driver * drv)
 {
-       INIT_LIST_HEAD(&drv->devices);
+       klist_init(&drv->klist_devices);
        init_completion(&drv->unloaded);
        return bus_add_driver(drv);
 }
index 583d57ec49a822f0f30305526d456141662bec38..5d4517ccc422c392e308b83376b2d537fce67485 100644 (file)
@@ -136,7 +136,7 @@ static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL);
  *
  * Initialize and register the node device.
  */
-int __init register_node(struct node *node, int num, struct node *parent)
+int register_node(struct node *node, int num, struct node *parent)
 {
        int error;
 
@@ -153,8 +153,24 @@ int __init register_node(struct node *node, int num, struct node *parent)
        return error;
 }
 
+/**
+ * unregister_node - unregister a node device
+ * @node: node going away
+ *
+ * Unregisters a node device @node.  All the devices on the node must be
+ * unregistered before calling this function.
+ */
+void unregister_node(struct node *node)
+{
+       sysdev_remove_file(&node->sysdev, &attr_cpumap);
+       sysdev_remove_file(&node->sysdev, &attr_meminfo);
+       sysdev_remove_file(&node->sysdev, &attr_numastat);
+       sysdev_remove_file(&node->sysdev, &attr_distance);
+
+       sysdev_unregister(&node->sysdev);
+}
 
-int __init register_node_type(void)
+static int __init register_node_type(void)
 {
        return sysdev_class_register(&node_class);
 }
index 26468971ef5a7711179e87f0d500cdc680888157..bdd96b03b8857a14367535bf408224b1eb939503 100644 (file)
@@ -22,6 +22,9 @@ extern int sysdev_resume(void);
 
 int resume_device(struct device * dev)
 {
+       int error = 0;
+
+       down(&dev->sem);
        if (dev->power.pm_parent
                        && dev->power.pm_parent->power.power_state) {
                dev_err(dev, "PM: resume from %d, parent %s still %d\n",
@@ -31,9 +34,10 @@ int resume_device(struct device * dev)
        }
        if (dev->bus && dev->bus->resume) {
                dev_dbg(dev,"resuming\n");
-               return dev->bus->resume(dev);
+               error = dev->bus->resume(dev);
        }
-       return 0;
+       up(&dev->sem);
+       return error;
 }
 
 
index 0ec44ef840beaf42c89d2fdb897be5f60685a369..2ccee3763acfae23a3d1de899179dd5ac0ca9419 100644 (file)
@@ -39,6 +39,7 @@ int suspend_device(struct device * dev, pm_message_t state)
 {
        int error = 0;
 
+       down(&dev->sem);
        if (dev->power.power_state) {
                dev_dbg(dev, "PM: suspend %d-->%d\n",
                        dev->power.power_state, state);
@@ -58,7 +59,7 @@ int suspend_device(struct device * dev, pm_message_t state)
                dev_dbg(dev, "suspending\n");
                error = dev->bus->suspend(dev, state);
        }
-
+       up(&dev->sem);
        return error;
 }
 
@@ -113,8 +114,19 @@ int device_suspend(pm_message_t state)
                put_device(dev);
        }
        up(&dpm_list_sem);
-       if (error)
+       if (error) {
+               /* we failed... before resuming, bring back devices from
+                * dpm_off_irq list back to main dpm_off list, we do want
+                * to call resume() on them, in case they partially suspended
+                * despite returning -EAGAIN
+                */
+               while (!list_empty(&dpm_off_irq)) {
+                       struct list_head * entry = dpm_off_irq.next;
+                       list_del(entry);
+                       list_add(entry, &dpm_off);
+               }
                dpm_resume();
+       }
        up(&dpm_sem);
        return error;
 }
index 6ac96349a8e8688b3e557608742b9d866ddb99f7..f82b3df9545f68b66cd1866862bc665a1f7e00c5 100644 (file)
  *     low-power state.
  */
 
-static ssize_t state_show(struct device * dev, char * buf)
+static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf)
 {
        return sprintf(buf, "%u\n", dev->power.power_state);
 }
 
-static ssize_t state_store(struct device * dev, const char * buf, size_t n)
+static ssize_t state_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t n)
 {
        u32 state;
        char * rest;
index 9102e3756f953cfc8bd0303f1add2948ee07a8bc..f37a13de804a9905c131f59d75c07ada35f9dd9d 100644 (file)
@@ -37,7 +37,7 @@ sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer)
 
        if (sysdev_attr->show)
                return sysdev_attr->show(sysdev, buffer);
-       return 0;
+       return -EIO;
 }
 
 
@@ -50,7 +50,7 @@ sysdev_store(struct kobject * kobj, struct attribute * attr,
 
        if (sysdev_attr->store)
                return sysdev_attr->store(sysdev, buffer, count);
-       return 0;
+       return -EIO;
 }
 
 static struct sysfs_ops sysfs_ops = {
index 14aeca3e2e8c58ab178ba489b6e32f230ebec29d..45a243096187afed4746ca58b84584841b2373eb 100644 (file)
@@ -36,7 +36,7 @@ static int emsgs_head_idx, emsgs_tail_idx;
 static struct semaphore emsgs_sema;
 static spinlock_t emsgs_lock;
 static int nblocked_emsgs_readers;
-static struct class_simple *aoe_class;
+static struct class *aoe_class;
 static struct aoe_chardev chardevs[] = {
        { MINOR_ERR, "err" },
        { MINOR_DISCOVER, "discover" },
@@ -218,13 +218,13 @@ aoechr_init(void)
        }
        sema_init(&emsgs_sema, 0);
        spin_lock_init(&emsgs_lock);
-       aoe_class = class_simple_create(THIS_MODULE, "aoe");
+       aoe_class = class_create(THIS_MODULE, "aoe");
        if (IS_ERR(aoe_class)) {
                unregister_chrdev(AOE_MAJOR, "aoechr");
                return PTR_ERR(aoe_class);
        }
        for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
-               class_simple_device_add(aoe_class,
+               class_device_create(aoe_class,
                                        MKDEV(AOE_MAJOR, chardevs[i].minor),
                                        NULL, chardevs[i].name);
 
@@ -237,8 +237,8 @@ aoechr_exit(void)
        int i;
 
        for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
-               class_simple_device_remove(MKDEV(AOE_MAJOR, chardevs[i].minor));
-       class_simple_destroy(aoe_class);
+               class_device_destroy(aoe_class, MKDEV(AOE_MAJOR, chardevs[i].minor));
+       class_destroy(aoe_class);
        unregister_chrdev(AOE_MAJOR, "aoechr");
 }
 
index a9575bb58a5e14630c507734bb35288c32da8338..638db06de2bea5414a55b0dfa8522a5db238c8bf 100644 (file)
@@ -2044,7 +2044,7 @@ as_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
        struct as_fs_entry *entry = to_as(attr);
 
        if (!entry->show)
-               return 0;
+               return -EIO;
 
        return entry->show(e->elevator_data, page);
 }
@@ -2057,7 +2057,7 @@ as_attr_store(struct kobject *kobj, struct attribute *attr,
        struct as_fs_entry *entry = to_as(attr);
 
        if (!entry->store)
-               return -EINVAL;
+               return -EIO;
 
        return entry->store(e->elevator_data, page, length);
 }
index 2210bacad56a34c4023a85036681c51657d19f8b..3ac47dde64da3be93b5e4bed65cee827f16db952 100644 (file)
@@ -1775,7 +1775,7 @@ cfq_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
        struct cfq_fs_entry *entry = to_cfq(attr);
 
        if (!entry->show)
-               return 0;
+               return -EIO;
 
        return entry->show(e->elevator_data, page);
 }
@@ -1788,7 +1788,7 @@ cfq_attr_store(struct kobject *kobj, struct attribute *attr,
        struct cfq_fs_entry *entry = to_cfq(attr);
 
        if (!entry->store)
-               return -EINVAL;
+               return -EIO;
 
        return entry->store(e->elevator_data, page, length);
 }
index d63d34c671f7a7fcbc9007ca009a04f125303cd1..7f79f3dd01655f111d88701bb48df642c72046a5 100644 (file)
@@ -886,7 +886,7 @@ deadline_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
        struct deadline_fs_entry *entry = to_deadline(attr);
 
        if (!entry->show)
-               return 0;
+               return -EIO;
 
        return entry->show(e->elevator_data, page);
 }
@@ -899,7 +899,7 @@ deadline_attr_store(struct kobject *kobj, struct attribute *attr,
        struct deadline_fs_entry *entry = to_deadline(attr);
 
        if (!entry->store)
-               return -EINVAL;
+               return -EIO;
 
        return entry->store(e->elevator_data, page, length);
 }
index 8bbe01d4b487cf5c9a03b474e8ffd2e57bbf1e8f..53f7d846b747f35692f782e0bc84f1fa8639a42e 100644 (file)
@@ -322,7 +322,7 @@ static ssize_t disk_attr_show(struct kobject *kobj, struct attribute *attr,
        struct gendisk *disk = to_disk(kobj);
        struct disk_attribute *disk_attr =
                container_of(attr,struct disk_attribute,attr);
-       ssize_t ret = 0;
+       ssize_t ret = -EIO;
 
        if (disk_attr->show)
                ret = disk_attr->show(disk,page);
index f20eba22b14b254553933848e94f3f4192552603..81fe3a0c1fe730f0cfea7661b65c44602aca5844 100644 (file)
@@ -3574,7 +3574,7 @@ queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
 
        q = container_of(kobj, struct request_queue, kobj);
        if (!entry->show)
-               return 0;
+               return -EIO;
 
        return entry->show(q, page);
 }
@@ -3588,7 +3588,7 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,
 
        q = container_of(kobj, struct request_queue, kobj);
        if (!entry->store)
-               return -EINVAL;
+               return -EIO;
 
        return entry->store(q, page, length);
 }
index dbeb107bb97107c42af8abffa049d56bb888f9e4..84d8e291ed964aaafb537790dc2fd00f1b781263 100644 (file)
@@ -222,7 +222,7 @@ static int pg_identify(struct pg *dev, int log);
 
 static char pg_scratch[512];   /* scratch block buffer */
 
-static struct class_simple *pg_class;
+static struct class *pg_class;
 
 /* kernel glue structures */
 
@@ -666,7 +666,7 @@ static int __init pg_init(void)
                err = -1;
                goto out;
        }
-       pg_class = class_simple_create(THIS_MODULE, "pg");
+       pg_class = class_create(THIS_MODULE, "pg");
        if (IS_ERR(pg_class)) {
                err = PTR_ERR(pg_class);
                goto out_chrdev;
@@ -675,7 +675,7 @@ static int __init pg_init(void)
        for (unit = 0; unit < PG_UNITS; unit++) {
                struct pg *dev = &devices[unit];
                if (dev->present) {
-                       class_simple_device_add(pg_class, MKDEV(major, unit), 
+                       class_device_create(pg_class, MKDEV(major, unit),
                                        NULL, "pg%u", unit);
                        err = devfs_mk_cdev(MKDEV(major, unit),
                                      S_IFCHR | S_IRUSR | S_IWUSR, "pg/%u",
@@ -688,8 +688,8 @@ static int __init pg_init(void)
        goto out;
 
 out_class:
-       class_simple_device_remove(MKDEV(major, unit));
-       class_simple_destroy(pg_class);
+       class_device_destroy(pg_class, MKDEV(major, unit));
+       class_destroy(pg_class);
 out_chrdev:
        unregister_chrdev(major, "pg");
 out:
@@ -703,11 +703,11 @@ static void __exit pg_exit(void)
        for (unit = 0; unit < PG_UNITS; unit++) {
                struct pg *dev = &devices[unit];
                if (dev->present) {
-                       class_simple_device_remove(MKDEV(major, unit));
+                       class_device_destroy(pg_class, MKDEV(major, unit));
                        devfs_remove("pg/%u", unit);
                }
        }
-       class_simple_destroy(pg_class);
+       class_destroy(pg_class);
        devfs_remove("pg");
        unregister_chrdev(major, name);
 
index 8fbd6922fe0d461a0b3cd5b885756fc882d0535d..5fe8ee86f095bb82a9691fd5792f8411a4797555 100644 (file)
@@ -242,7 +242,7 @@ static struct file_operations pt_fops = {
 };
 
 /* sysfs class support */
-static struct class_simple *pt_class;
+static struct class *pt_class;
 
 static inline int status_reg(struct pi_adapter *pi)
 {
@@ -963,7 +963,7 @@ static int __init pt_init(void)
                err = -1;
                goto out;
        }
-       pt_class = class_simple_create(THIS_MODULE, "pt");
+       pt_class = class_create(THIS_MODULE, "pt");
        if (IS_ERR(pt_class)) {
                err = PTR_ERR(pt_class);
                goto out_chrdev;
@@ -972,29 +972,29 @@ static int __init pt_init(void)
        devfs_mk_dir("pt");
        for (unit = 0; unit < PT_UNITS; unit++)
                if (pt[unit].present) {
-                       class_simple_device_add(pt_class, MKDEV(major, unit), 
+                       class_device_create(pt_class, MKDEV(major, unit),
                                        NULL, "pt%d", unit);
                        err = devfs_mk_cdev(MKDEV(major, unit),
                                      S_IFCHR | S_IRUSR | S_IWUSR,
                                      "pt/%d", unit);
                        if (err) {
-                               class_simple_device_remove(MKDEV(major, unit));
+                               class_device_destroy(pt_class, MKDEV(major, unit));
                                goto out_class;
                        }
-                       class_simple_device_add(pt_class, MKDEV(major, unit + 128),
+                       class_device_create(pt_class, MKDEV(major, unit + 128),
                                        NULL, "pt%dn", unit);
                        err = devfs_mk_cdev(MKDEV(major, unit + 128),
                                      S_IFCHR | S_IRUSR | S_IWUSR,
                                      "pt/%dn", unit);
                        if (err) {
-                               class_simple_device_remove(MKDEV(major, unit + 128));
+                               class_device_destroy(pt_class, MKDEV(major, unit + 128));
                                goto out_class;
                        }
                }
        goto out;
 
 out_class:
-       class_simple_destroy(pt_class);
+       class_destroy(pt_class);
 out_chrdev:
        unregister_chrdev(major, "pt");
 out:
@@ -1006,12 +1006,12 @@ static void __exit pt_exit(void)
        int unit;
        for (unit = 0; unit < PT_UNITS; unit++)
                if (pt[unit].present) {
-                       class_simple_device_remove(MKDEV(major, unit));
+                       class_device_destroy(pt_class, MKDEV(major, unit));
                        devfs_remove("pt/%d", unit);
-                       class_simple_device_remove(MKDEV(major, unit + 128));
+                       class_device_destroy(pt_class, MKDEV(major, unit + 128));
                        devfs_remove("pt/%dn", unit);
                }
-       class_simple_destroy(pt_class);
+       class_destroy(pt_class);
        devfs_remove("pt");
        unregister_chrdev(major, name);
        for (unit = 0; unit < PT_UNITS; unit++)
index 19c5e59bcfa826966d433c2edd6f921592a7f40f..685f061e69b2971484a9546de5f3e32cc7b32801 100644 (file)
@@ -430,7 +430,7 @@ static void ub_cmdtr_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd,
        }
 }
 
-static ssize_t ub_diag_show(struct device *dev, char *page)
+static ssize_t ub_diag_show(struct device *dev, struct device_attribute *attr, char *page)
 {
        struct usb_interface *intf;
        struct ub_dev *sc;
index 37d6649011ad29900d11d6a2483db08d6bae768d..26271e3ca82371542b9395fea1815e0b71f43290 100644 (file)
@@ -144,7 +144,7 @@ static struct dsp56k_device {
        int tx_wsize, rx_wsize;
 } dsp56k;
 
-static struct class_simple *dsp56k_class;
+static struct class *dsp56k_class;
 
 static int dsp56k_reset(void)
 {
@@ -510,12 +510,12 @@ static int __init dsp56k_init_driver(void)
                printk("DSP56k driver: Unable to register driver\n");
                return -ENODEV;
        }
-       dsp56k_class = class_simple_create(THIS_MODULE, "dsp56k");
+       dsp56k_class = class_create(THIS_MODULE, "dsp56k");
        if (IS_ERR(dsp56k_class)) {
                err = PTR_ERR(dsp56k_class);
                goto out_chrdev;
        }
-       class_simple_device_add(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
+       class_device_create(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
 
        err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
                      S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k");
@@ -526,8 +526,8 @@ static int __init dsp56k_init_driver(void)
        goto out;
 
 out_class:
-       class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
-       class_simple_destroy(dsp56k_class);
+       class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
+       class_destroy(dsp56k_class);
 out_chrdev:
        unregister_chrdev(DSP56K_MAJOR, "dsp56k");
 out:
@@ -537,8 +537,8 @@ module_init(dsp56k_init_driver);
 
 static void __exit dsp56k_cleanup_driver(void)
 {
-       class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
-       class_simple_destroy(dsp56k_class);
+       class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
+       class_destroy(dsp56k_class);
        unregister_chrdev(DSP56K_MAJOR, "dsp56k");
        devfs_remove("dsp56k");
 }
index dbac7e54e8e069911517c99f153b9c8650475b06..5745b74044ec1b1a583a606b2ef7346b7df5bfad 100644 (file)
@@ -99,7 +99,7 @@ static struct file_operations zft_cdev =
        .release        = zft_close,
 };
 
-static struct class_simple *zft_class;
+static struct class *zft_class;
 
 /*      Open floppy tape device
  */
@@ -329,29 +329,29 @@ KERN_INFO
              "installing zftape VFS interface for ftape driver ...");
        TRACE_CATCH(register_chrdev(QIC117_TAPE_MAJOR, "zft", &zft_cdev),);
 
-       zft_class = class_simple_create(THIS_MODULE, "zft");
+       zft_class = class_create(THIS_MODULE, "zft");
        for (i = 0; i < 4; i++) {
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
+               class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
                devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i),
                                S_IFCHR | S_IRUSR | S_IWUSR,
                                "qft%i", i);
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
+               class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
                devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4),
                                S_IFCHR | S_IRUSR | S_IWUSR,
                                "nqft%i", i);
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
+               class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
                devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16),
                                S_IFCHR | S_IRUSR | S_IWUSR,
                                "zqft%i", i);
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
+               class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
                devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20),
                                S_IFCHR | S_IRUSR | S_IWUSR,
                                "nzqft%i", i);
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
+               class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
                devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32),
                                S_IFCHR | S_IRUSR | S_IWUSR,
                                "rawqft%i", i);
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
+               class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
                devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36),
                                S_IFCHR | S_IRUSR | S_IWUSR,
                                "nrawqft%i", i);
@@ -381,19 +381,19 @@ static void zft_exit(void)
        }
         for (i = 0; i < 4; i++) {
                devfs_remove("qft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i));
                devfs_remove("nqft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 4));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4));
                devfs_remove("zqft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 16));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16));
                devfs_remove("nzqft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 20));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20));
                devfs_remove("rawqft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 32));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32));
                devfs_remove("nrawqft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 36));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36));
        }
-       class_simple_destroy(zft_class);
+       class_destroy(zft_class);
        zft_uninit_mem(); /* release remaining memory, if any */
         printk(KERN_INFO "zftape successfully unloaded.\n");
        TRACE_EXIT;
index abfbdcfd4e725a397f23121144d5a308c1a429e7..3236d2404905003ad92ce5b2ef82cc96f28a3906 100644 (file)
@@ -1466,7 +1466,7 @@ static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
 }
 /* The sysfs interface for the driver and devices */
 
-static ssize_t hvcs_partner_vtys_show(struct device *dev, char *buf)
+static ssize_t hvcs_partner_vtys_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct vio_dev *viod = to_vio_dev(dev);
        struct hvcs_struct *hvcsd = from_vio_dev(viod);
@@ -1480,7 +1480,7 @@ static ssize_t hvcs_partner_vtys_show(struct device *dev, char *buf)
 }
 static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
 
-static ssize_t hvcs_partner_clcs_show(struct device *dev, char *buf)
+static ssize_t hvcs_partner_clcs_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct vio_dev *viod = to_vio_dev(dev);
        struct hvcs_struct *hvcsd = from_vio_dev(viod);
@@ -1494,7 +1494,7 @@ static ssize_t hvcs_partner_clcs_show(struct device *dev, char *buf)
 }
 static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
 
-static ssize_t hvcs_current_vty_store(struct device *dev, const char * buf,
+static ssize_t hvcs_current_vty_store(struct device *dev, struct device_attribute *attr, const char * buf,
                size_t count)
 {
        /*
@@ -1505,7 +1505,7 @@ static ssize_t hvcs_current_vty_store(struct device *dev, const char * buf,
        return -EPERM;
 }
 
-static ssize_t hvcs_current_vty_show(struct device *dev, char *buf)
+static ssize_t hvcs_current_vty_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct vio_dev *viod = to_vio_dev(dev);
        struct hvcs_struct *hvcsd = from_vio_dev(viod);
@@ -1521,7 +1521,7 @@ static ssize_t hvcs_current_vty_show(struct device *dev, char *buf)
 static DEVICE_ATTR(current_vty,
        S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
 
-static ssize_t hvcs_vterm_state_store(struct device *dev, const char *buf,
+static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribute *attr, const char *buf,
                size_t count)
 {
        struct vio_dev *viod = to_vio_dev(dev);
@@ -1559,7 +1559,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, const char *buf,
        return count;
 }
 
-static ssize_t hvcs_vterm_state_show(struct device *dev, char *buf)
+static ssize_t hvcs_vterm_state_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct vio_dev *viod = to_vio_dev(dev);
        struct hvcs_struct *hvcsd = from_vio_dev(viod);
@@ -1574,7 +1574,7 @@ static ssize_t hvcs_vterm_state_show(struct device *dev, char *buf)
 static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
                hvcs_vterm_state_show, hvcs_vterm_state_store);
 
-static ssize_t hvcs_index_show(struct device *dev, char *buf)
+static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct vio_dev *viod = to_vio_dev(dev);
        struct hvcs_struct *hvcsd = from_vio_dev(viod);
index fca9a978fb73fc2662daea26caa6f0744e0a5764..3b8314b4249ac902b5da172c20a781191956afa2 100644 (file)
@@ -302,7 +302,7 @@ static char rirqs[IP2_MAX_BOARDS];
 static int Valid_Irqs[] = { 3, 4, 5, 7, 10, 11, 12, 15, 0};
 
 /* for sysfs class support */
-static struct class_simple *ip2_class;
+static struct class *ip2_class;
 
 // Some functions to keep track of what irq's we have
 
@@ -414,9 +414,9 @@ cleanup_module(void)
                        iiResetDelay( i2BoardPtrTable[i] );
                        /* free io addresses and Tibet */
                        release_region( ip2config.addr[i], 8 );
-                       class_simple_device_remove(MKDEV(IP2_IPL_MAJOR, 4 * i)); 
+                       class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i));
                        devfs_remove("ip2/ipl%d", i);
-                       class_simple_device_remove(MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
+                       class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
                        devfs_remove("ip2/stat%d", i);
                }
                /* Disable and remove interrupt handler. */
@@ -425,7 +425,7 @@ cleanup_module(void)
                        clear_requested_irq( ip2config.irq[i]);
                }
        }
-       class_simple_destroy(ip2_class);
+       class_destroy(ip2_class);
        devfs_remove("ip2");
        if ( ( err = tty_unregister_driver ( ip2_tty_driver ) ) ) {
                printk(KERN_ERR "IP2: failed to unregister tty driver (%d)\n", err);
@@ -700,7 +700,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                printk(KERN_ERR "IP2: failed to register IPL device (%d)\n", err );
        } else {
                /* create the sysfs class */
-               ip2_class = class_simple_create(THIS_MODULE, "ip2");
+               ip2_class = class_create(THIS_MODULE, "ip2");
                if (IS_ERR(ip2_class)) {
                        err = PTR_ERR(ip2_class);
                        goto out_chrdev;        
@@ -722,25 +722,25 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                        }
 
                        if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
-                               class_simple_device_add(ip2_class, MKDEV(IP2_IPL_MAJOR, 
+                               class_device_create(ip2_class, MKDEV(IP2_IPL_MAJOR,
                                                4 * i), NULL, "ipl%d", i);
                                err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i),
                                                S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
                                                "ip2/ipl%d", i);
                                if (err) {
-                                       class_simple_device_remove(MKDEV(IP2_IPL_MAJOR, 
-                                               4 * i));
+                                       class_device_destroy(ip2_class,
+                                               MKDEV(IP2_IPL_MAJOR, 4 * i));
                                        goto out_class;
                                }
 
-                               class_simple_device_add(ip2_class, MKDEV(IP2_IPL_MAJOR, 
+                               class_device_create(ip2_class, MKDEV(IP2_IPL_MAJOR,
                                                4 * i + 1), NULL, "stat%d", i);
                                err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
                                                S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
                                                "ip2/stat%d", i);
                                if (err) {
-                                       class_simple_device_remove(MKDEV(IP2_IPL_MAJOR, 
-                                               4 * i + 1));
+                                       class_device_destroy(ip2_class,
+                                               MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
                                        goto out_class;
                                }
 
@@ -798,7 +798,7 @@ retry:
        goto out;
 
 out_class:
-       class_simple_destroy(ip2_class);
+       class_destroy(ip2_class);
 out_chrdev:
        unregister_chrdev(IP2_IPL_MAJOR, "ip2");
 out:
index 6dc765dc5413dfe1f0ba58ead7d921899be22194..88d1ad656e99a2df138122225992d7cb91f3d728 100644 (file)
@@ -520,7 +520,7 @@ MODULE_PARM_DESC(ipmi_major, "Sets the major number of the IPMI device.  By"
                 " interface.  Other values will set the major device number"
                 " to that value.");
 
-static struct class_simple *ipmi_class;
+static struct class *ipmi_class;
 
 static void ipmi_new_smi(int if_num)
 {
@@ -529,12 +529,12 @@ static void ipmi_new_smi(int if_num)
        devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
                      "ipmidev/%d", if_num);
 
-       class_simple_device_add(ipmi_class, dev, NULL, "ipmi%d", if_num);
+       class_device_create(ipmi_class, dev, NULL, "ipmi%d", if_num);
 }
 
 static void ipmi_smi_gone(int if_num)
 {
-       class_simple_device_remove(MKDEV(ipmi_major, if_num));
+       class_device_destroy(ipmi_class, MKDEV(ipmi_major, if_num));
        devfs_remove("ipmidev/%d", if_num);
 }
 
@@ -555,7 +555,7 @@ static __init int init_ipmi_devintf(void)
        printk(KERN_INFO "ipmi device interface version "
               IPMI_DEVINTF_VERSION "\n");
 
-       ipmi_class = class_simple_create(THIS_MODULE, "ipmi");
+       ipmi_class = class_create(THIS_MODULE, "ipmi");
        if (IS_ERR(ipmi_class)) {
                printk(KERN_ERR "ipmi: can't register device class\n");
                return PTR_ERR(ipmi_class);
@@ -563,7 +563,7 @@ static __init int init_ipmi_devintf(void)
 
        rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops);
        if (rv < 0) {
-               class_simple_destroy(ipmi_class);
+               class_destroy(ipmi_class);
                printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major);
                return rv;
        }
@@ -577,7 +577,7 @@ static __init int init_ipmi_devintf(void)
        rv = ipmi_smi_watcher_register(&smi_watcher);
        if (rv) {
                unregister_chrdev(ipmi_major, DEVICE_NAME);
-               class_simple_destroy(ipmi_class);
+               class_destroy(ipmi_class);
                printk(KERN_WARNING "ipmi: can't register smi watcher\n");
                return rv;
        }
@@ -588,7 +588,7 @@ module_init(init_ipmi_devintf);
 
 static __exit void cleanup_ipmi(void)
 {
-       class_simple_destroy(ipmi_class);
+       class_destroy(ipmi_class);
        ipmi_smi_watcher_unregister(&smi_watcher);
        devfs_remove(DEVICE_NAME);
        unregister_chrdev(ipmi_major, DEVICE_NAME);
index 21aed0e8779de8e934b0bedebd8c4306ea9abe34..c02a21dbad5d516b400f28fa0f2c601aaa8b7136 100644 (file)
@@ -792,7 +792,7 @@ static int  stli_timeron;
 
 /*****************************************************************************/
 
-static struct class_simple *istallion_class;
+static struct class *istallion_class;
 
 #ifdef MODULE
 
@@ -854,10 +854,10 @@ static void __exit istallion_module_exit(void)
        put_tty_driver(stli_serial);
        for (i = 0; i < 4; i++) {
                devfs_remove("staliomem/%d", i);
-               class_simple_device_remove(MKDEV(STL_SIOMEMMAJOR, i));
+               class_device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR, i));
        }
        devfs_remove("staliomem");
-       class_simple_destroy(istallion_class);
+       class_destroy(istallion_class);
        if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
                printk("STALLION: failed to un-register serial memory device, "
                        "errno=%d\n", -i);
@@ -5242,12 +5242,12 @@ int __init stli_init(void)
                                "device\n");
 
        devfs_mk_dir("staliomem");
-       istallion_class = class_simple_create(THIS_MODULE, "staliomem");
+       istallion_class = class_create(THIS_MODULE, "staliomem");
        for (i = 0; i < 4; i++) {
                devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
                               S_IFCHR | S_IRUSR | S_IWUSR,
                               "staliomem/%d", i);
-               class_simple_device_add(istallion_class, MKDEV(STL_SIOMEMMAJOR, i), 
+               class_device_create(istallion_class, MKDEV(STL_SIOMEMMAJOR, i),
                                NULL, "staliomem%d", i);
        }
 
index 4dee945031d45cf46d61b604bcbfffe58f1ac895..59eebe5a035f1c7691656f389c75af261769c0eb 100644 (file)
 static struct lp_struct lp_table[LP_NO];
 
 static unsigned int lp_count = 0;
-static struct class_simple *lp_class;
+static struct class *lp_class;
 
 #ifdef CONFIG_LP_CONSOLE
 static struct parport *console_registered; // initially NULL
@@ -804,7 +804,7 @@ static int lp_register(int nr, struct parport *port)
        if (reset)
                lp_reset(nr);
 
-       class_simple_device_add(lp_class, MKDEV(LP_MAJOR, nr), NULL,
+       class_device_create(lp_class, MKDEV(LP_MAJOR, nr), NULL,
                                "lp%d", nr);
        devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO,
                        "printers/%d", nr);
@@ -907,7 +907,7 @@ static int __init lp_init (void)
        }
 
        devfs_mk_dir("printers");
-       lp_class = class_simple_create(THIS_MODULE, "printer");
+       lp_class = class_create(THIS_MODULE, "printer");
        if (IS_ERR(lp_class)) {
                err = PTR_ERR(lp_class);
                goto out_devfs;
@@ -930,7 +930,7 @@ static int __init lp_init (void)
        return 0;
 
 out_class:
-       class_simple_destroy(lp_class);
+       class_destroy(lp_class);
 out_devfs:
        devfs_remove("printers");
        unregister_chrdev(LP_MAJOR, "lp");
@@ -981,10 +981,10 @@ static void lp_cleanup_module (void)
                        continue;
                parport_unregister_device(lp_table[offset].dev);
                devfs_remove("printers/%d", offset);
-               class_simple_device_remove(MKDEV(LP_MAJOR, offset));
+               class_device_destroy(lp_class, MKDEV(LP_MAJOR, offset));
        }
        devfs_remove("printers");
-       class_simple_destroy(lp_class);
+       class_destroy(lp_class);
 }
 
 __setup("lp=", lp_setup);
index ac9cfa9701ea9003d0f440ec572e0eecaec7a1a3..115dbb35334b031e71acaedff084402499a449a2 100644 (file)
@@ -699,7 +699,7 @@ static inline int mbcs_hw_init(struct mbcs_soft *soft)
        return 0;
 }
 
-static ssize_t show_algo(struct device *dev, char *buf)
+static ssize_t show_algo(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct cx_dev *cx_dev = to_cx_dev(dev);
        struct mbcs_soft *soft = cx_dev->soft;
@@ -715,7 +715,7 @@ static ssize_t show_algo(struct device *dev, char *buf)
                       (debug0 >> 32), (debug0 & 0xffffffff));
 }
 
-static ssize_t store_algo(struct device *dev, const char *buf, size_t count)
+static ssize_t store_algo(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        int n;
        struct cx_dev *cx_dev = to_cx_dev(dev);
index 947cb3cef816715dafe2c6a48e092d9dbf30d0a7..257b8ee605e555d14dc5da5495d14e609b891bbe 100644 (file)
@@ -856,7 +856,7 @@ static const struct {
        {11,"kmsg",    S_IRUGO | S_IWUSR,           &kmsg_fops},
 };
 
-static struct class_simple *mem_class;
+static struct class *mem_class;
 
 static int __init chr_dev_init(void)
 {
@@ -865,10 +865,9 @@ static int __init chr_dev_init(void)
        if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))
                printk("unable to get major %d for memory devs\n", MEM_MAJOR);
 
-       mem_class = class_simple_create(THIS_MODULE, "mem");
+       mem_class = class_create(THIS_MODULE, "mem");
        for (i = 0; i < ARRAY_SIZE(devlist); i++) {
-               class_simple_device_add(mem_class,
-                                       MKDEV(MEM_MAJOR, devlist[i].minor),
+               class_device_create(mem_class, MKDEV(MEM_MAJOR, devlist[i].minor),
                                        NULL, devlist[i].name);
                devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
                                S_IFCHR | devlist[i].mode, devlist[i].name);
index 0937544762da76d0a8627a9fe96b35c394a5d768..3115d318b9978618784a4ee4f8173070cfcbe023 100644 (file)
@@ -177,10 +177,10 @@ fail:
 
 /* 
  * TODO for 2.7:
- *  - add a struct class_device to struct miscdevice and make all usages of
+ *  - add a struct kref to struct miscdevice and make all usages of
  *    them dynamic.
  */
-static struct class_simple *misc_class;
+static struct class *misc_class;
 
 static struct file_operations misc_fops = {
        .owner          = THIS_MODULE,
@@ -238,8 +238,8 @@ int misc_register(struct miscdevice * misc)
        }
        dev = MKDEV(MISC_MAJOR, misc->minor);
 
-       misc->class = class_simple_device_add(misc_class, dev,
-                                             misc->dev, misc->name);
+       misc->class = class_device_create(misc_class, dev, misc->dev,
+                                         "%s", misc->name);
        if (IS_ERR(misc->class)) {
                err = PTR_ERR(misc->class);
                goto out;
@@ -248,7 +248,7 @@ int misc_register(struct miscdevice * misc)
        err = devfs_mk_cdev(dev, S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP, 
                            misc->devfs_name);
        if (err) {
-               class_simple_device_remove(dev);
+               class_device_destroy(misc_class, dev);
                goto out;
        }
 
@@ -281,7 +281,7 @@ int misc_deregister(struct miscdevice * misc)
 
        down(&misc_sem);
        list_del(&misc->list);
-       class_simple_device_remove(MKDEV(MISC_MAJOR, misc->minor));
+       class_device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
        devfs_remove(misc->devfs_name);
        if (i < DYNAMIC_MINORS && i>0) {
                misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
@@ -302,7 +302,7 @@ static int __init misc_init(void)
        if (ent)
                ent->proc_fops = &misc_proc_fops;
 #endif
-       misc_class = class_simple_create(THIS_MODULE, "misc");
+       misc_class = class_create(THIS_MODULE, "misc");
        if (IS_ERR(misc_class))
                return PTR_ERR(misc_class);
 #ifdef CONFIG_MVME16x
@@ -323,7 +323,7 @@ static int __init misc_init(void)
        if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) {
                printk("unable to get major %d for misc devices\n",
                       MISC_MAJOR);
-               class_simple_destroy(misc_class);
+               class_destroy(misc_class);
                return -EIO;
        }
        return 0;
index d37625d477465c732a19273beecf1c706c40e0b7..d568991ac6b3eafcc2dd85b48a881756c9353d2c 100644 (file)
@@ -472,7 +472,7 @@ struct device mwave_device;
 
 /* Prevent code redundancy, create a macro for mwave_show_* functions. */
 #define mwave_show_function(attr_name, format_string, field)           \
-static ssize_t mwave_show_##attr_name(struct device *dev, char *buf)   \
+static ssize_t mwave_show_##attr_name(struct device *dev, struct device_attribute *attr, char *buf)    \
 {                                                                      \
        DSP_3780I_CONFIG_SETTINGS *pSettings =                          \
                &mwave_s_mdd.rBDData.rDspSettings;                      \
index 5eda075c62bd173eafa3c0868bdb12b00e6b0b9b..0e22880432bca3d8c89be8c7b0a6ffabbd05fc03 100644 (file)
@@ -737,7 +737,7 @@ static unsigned int pp_poll (struct file * file, poll_table * wait)
        return mask;
 }
 
-static struct class_simple *ppdev_class;
+static struct class *ppdev_class;
 
 static struct file_operations pp_fops = {
        .owner          = THIS_MODULE,
@@ -752,13 +752,13 @@ static struct file_operations pp_fops = {
 
 static void pp_attach(struct parport *port)
 {
-       class_simple_device_add(ppdev_class, MKDEV(PP_MAJOR, port->number),
+       class_device_create(ppdev_class, MKDEV(PP_MAJOR, port->number),
                        NULL, "parport%d", port->number);
 }
 
 static void pp_detach(struct parport *port)
 {
-       class_simple_device_remove(MKDEV(PP_MAJOR, port->number));
+       class_device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number));
 }
 
 static struct parport_driver pp_driver = {
@@ -776,7 +776,7 @@ static int __init ppdev_init (void)
                        PP_MAJOR);
                return -EIO;
        }
-       ppdev_class = class_simple_create(THIS_MODULE, CHRDEV);
+       ppdev_class = class_create(THIS_MODULE, CHRDEV);
        if (IS_ERR(ppdev_class)) {
                err = PTR_ERR(ppdev_class);
                goto out_chrdev;
@@ -798,7 +798,7 @@ out_class:
        for (i = 0; i < PARPORT_MAX; i++)
                devfs_remove("parports/%d", i);
        devfs_remove("parports");
-       class_simple_destroy(ppdev_class);
+       class_destroy(ppdev_class);
 out_chrdev:
        unregister_chrdev(PP_MAJOR, CHRDEV);
 out:
@@ -813,7 +813,7 @@ static void __exit ppdev_cleanup (void)
                devfs_remove("parports/%d", i);
        parport_unregister_driver(&pp_driver);
        devfs_remove("parports");
-       class_simple_destroy(ppdev_class);
+       class_destroy(ppdev_class);
        unregister_chrdev (PP_MAJOR, CHRDEV);
 }
 
index ca5f42bcaad91eeca08a3984cf530ab2f7b5818c..f13e5de02207b8dff569c58f80d6ab85988671ee 100644 (file)
@@ -27,7 +27,7 @@ struct raw_device_data {
        int inuse;
 };
 
-static struct class_simple *raw_class;
+static struct class *raw_class;
 static struct raw_device_data raw_devices[MAX_RAW_MINORS];
 static DECLARE_MUTEX(raw_mutex);
 static struct file_operations raw_ctl_fops;         /* forward declaration */
@@ -127,8 +127,8 @@ raw_ioctl(struct inode *inode, struct file *filp,
 
 static void bind_device(struct raw_config_request *rq)
 {
-       class_simple_device_remove(MKDEV(RAW_MAJOR, rq->raw_minor));
-       class_simple_device_add(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor),
+       class_device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
+       class_device_create(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor),
                                      NULL, "raw%d", rq->raw_minor);
 }
 
@@ -200,8 +200,8 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
                        if (rq.block_major == 0 && rq.block_minor == 0) {
                                /* unbind */
                                rawdev->binding = NULL;
-                               class_simple_device_remove(MKDEV(RAW_MAJOR,
-                                                               rq.raw_minor));
+                               class_device_destroy(raw_class,
+                                               MKDEV(RAW_MAJOR, rq.raw_minor));
                        } else {
                                rawdev->binding = bdget(dev);
                                if (rawdev->binding == NULL)
@@ -300,14 +300,14 @@ static int __init raw_init(void)
                goto error;
        }
 
-       raw_class = class_simple_create(THIS_MODULE, "raw");
+       raw_class = class_create(THIS_MODULE, "raw");
        if (IS_ERR(raw_class)) {
                printk(KERN_ERR "Error creating raw class.\n");
                cdev_del(&raw_cdev);
                unregister_chrdev_region(dev, MAX_RAW_MINORS);
                goto error;
        }
-       class_simple_device_add(raw_class, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
+       class_device_create(raw_class, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
 
        devfs_mk_cdev(MKDEV(RAW_MAJOR, 0),
                      S_IFCHR | S_IRUGO | S_IWUGO,
@@ -331,8 +331,8 @@ static void __exit raw_exit(void)
                devfs_remove("raw/raw%d", i);
        devfs_remove("raw/rawctl");
        devfs_remove("raw");
-       class_simple_device_remove(MKDEV(RAW_MAJOR, 0));
-       class_simple_destroy(raw_class);
+       class_device_destroy(raw_class, MKDEV(RAW_MAJOR, 0));
+       class_destroy(raw_class);
        cdev_del(&raw_cdev);
        unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS);
 }
index e3c0b52d943fda57b321896c48d43c6a86c64f71..261a41bf6d02edc4fece911485dd5680d9ddcede 100644 (file)
@@ -357,6 +357,8 @@ static struct file_operations scdrv_fops = {
        .release =      scdrv_release,
 };
 
+static struct class *snsc_class;
+
 /*
  * scdrv_init
  *
@@ -372,7 +374,6 @@ scdrv_init(void)
        char *devnamep;
        struct sysctl_data_s *scd;
        void *salbuf;
-       struct class_simple *snsc_class;
        dev_t first_dev, dev;
        nasid_t event_nasid = ia64_sn_get_console_nasid();
 
@@ -382,7 +383,7 @@ scdrv_init(void)
                       __FUNCTION__);
                return -ENODEV;
        }
-       snsc_class = class_simple_create(THIS_MODULE, SYSCTL_BASENAME);
+       snsc_class = class_create(THIS_MODULE, SYSCTL_BASENAME);
 
        for (cnode = 0; cnode < numionodes; cnode++) {
                        geoid = cnodeid_get_geoid(cnode);
@@ -436,7 +437,7 @@ scdrv_init(void)
                                continue;
                        }
 
-                       class_simple_device_add(snsc_class, dev, NULL,
+                       class_device_create(snsc_class, dev, NULL,
                                                "%s", devname);
 
                        ia64_sn_irtr_intr_enable(scd->scd_nasid,
index b8899f560b5ecd85dd17f86affdf1f0638c0fa4d..951545a6ef2d3f4c63a6f8c372fcbe88bbbdb277 100644 (file)
@@ -719,7 +719,7 @@ static struct file_operations       stl_fsiomem = {
 
 /*****************************************************************************/
 
-static struct class_simple *stallion_class;
+static struct class *stallion_class;
 
 /*
  *     Loadable module initialization stuff.
@@ -777,13 +777,13 @@ static void __exit stallion_module_exit(void)
        }
        for (i = 0; i < 4; i++) {
                devfs_remove("staliomem/%d", i);
-               class_simple_device_remove(MKDEV(STL_SIOMEMMAJOR, i));
+               class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
        }
        devfs_remove("staliomem");
        if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
                printk("STALLION: failed to un-register serial memory device, "
                        "errno=%d\n", -i);
-       class_simple_destroy(stallion_class);
+       class_destroy(stallion_class);
 
        if (stl_tmpwritebuf != (char *) NULL)
                kfree(stl_tmpwritebuf);
@@ -3090,12 +3090,12 @@ static int __init stl_init(void)
                printk("STALLION: failed to register serial board device\n");
        devfs_mk_dir("staliomem");
 
-       stallion_class = class_simple_create(THIS_MODULE, "staliomem");
+       stallion_class = class_create(THIS_MODULE, "staliomem");
        for (i = 0; i < 4; i++) {
                devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
                                S_IFCHR|S_IRUSR|S_IWUSR,
                                "staliomem/%d", i);
-               class_simple_device_add(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem%d", i);
+               class_device_create(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem%d", i);
        }
 
        stl_serial->owner = THIS_MODULE;
index 0c5ba9dc906358c15cb29663d923c5fb505c8adb..659335d80ee73703b6c56b7653e454a34332402a 100644 (file)
@@ -90,7 +90,7 @@ static int timeout = TIMAXTIME;       /* timeout in tenth of seconds     */
 static unsigned int tp_count;  /* tipar count */
 static unsigned long opened;   /* opened devices */
 
-static struct class_simple *tipar_class;
+static struct class *tipar_class;
 
 /* --- macros for parport access -------------------------------------- */
 
@@ -436,7 +436,7 @@ tipar_register(int nr, struct parport *port)
                goto out;
        }
 
-       class_simple_device_add(tipar_class, MKDEV(TIPAR_MAJOR,
+       class_device_create(tipar_class, MKDEV(TIPAR_MAJOR,
                        TIPAR_MINOR + nr), NULL, "par%d", nr);
        /* Use devfs, tree: /dev/ticables/par/[0..2] */
        err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr),
@@ -458,8 +458,8 @@ tipar_register(int nr, struct parport *port)
        goto out;
 
 out_class:
-       class_simple_device_remove(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr));
-       class_simple_destroy(tipar_class);
+       class_device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr));
+       class_destroy(tipar_class);
 out:
        return err;
 }
@@ -505,7 +505,7 @@ tipar_init_module(void)
        /* Use devfs with tree: /dev/ticables/par/[0..2] */
        devfs_mk_dir("ticables/par");
 
-       tipar_class = class_simple_create(THIS_MODULE, "ticables");
+       tipar_class = class_create(THIS_MODULE, "ticables");
        if (IS_ERR(tipar_class)) {
                err = PTR_ERR(tipar_class);
                goto out_chrdev;
@@ -539,10 +539,10 @@ tipar_cleanup_module(void)
                if (table[i].dev == NULL)
                        continue;
                parport_unregister_device(table[i].dev);
-               class_simple_device_remove(MKDEV(TIPAR_MAJOR, i));
+               class_device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, i));
                devfs_remove("ticables/par/%d", i);
        }
-       class_simple_destroy(tipar_class);
+       class_destroy(tipar_class);
        devfs_remove("ticables/par");
 
        pr_info("tipar: module unloaded\n");
index 87235330fdbe9ced1e186e8e670f919709fd2c9c..8ce508b29865eb866cb21f4575c1cc324b66cda5 100644 (file)
@@ -212,7 +212,7 @@ static u8 pcrread[] = {
        0, 0, 0, 0              /* PCR index */
 };
 
-static ssize_t show_pcrs(struct device *dev, char *buf)
+static ssize_t show_pcrs(struct device *dev, struct device_attribute *attr, char *buf)
 {
        u8 data[READ_PCR_RESULT_SIZE];
        ssize_t len;
@@ -255,7 +255,7 @@ static u8 readpubek[] = {
        0, 0, 0, 124,           /* TPM_ORD_ReadPubek */
 };
 
-static ssize_t show_pubek(struct device *dev, char *buf)
+static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, char *buf)
 {
        u8 data[READ_PUBEK_RESULT_SIZE];
        ssize_t len;
@@ -330,7 +330,7 @@ static u8 cap_manufacturer[] = {
        0, 0, 1, 3
 };
 
-static ssize_t show_caps(struct device *dev, char *buf)
+static ssize_t show_caps(struct device *dev, struct device_attribute *attr, char *buf)
 {
        u8 data[READ_PUBEK_RESULT_SIZE];
        ssize_t len;
index 26e5e19ed8545b880833623e960f654378e595f0..31831030f73fcd3a0e59e159020edc42c89a3e3e 100644 (file)
@@ -2654,7 +2654,7 @@ static void tty_default_put_char(struct tty_struct *tty, unsigned char ch)
        tty->driver->write(tty, &ch, 1);
 }
 
-static struct class_simple *tty_class;
+static struct class *tty_class;
 
 /**
  * tty_register_device - register a tty device
@@ -2687,7 +2687,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
                pty_line_name(driver, index, name);
        else
                tty_line_name(driver, index, name);
-       class_simple_device_add(tty_class, dev, device, name);
+       class_device_create(tty_class, dev, device, name);
 }
 
 /**
@@ -2701,7 +2701,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
 void tty_unregister_device(struct tty_driver *driver, unsigned index)
 {
        devfs_remove("%s%d", driver->devfs_name, index + driver->name_base);
-       class_simple_device_remove(MKDEV(driver->major, driver->minor_start) + index);
+       class_device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index);
 }
 
 EXPORT_SYMBOL(tty_register_device);
@@ -2918,7 +2918,7 @@ extern int vty_init(void);
 
 static int __init tty_class_init(void)
 {
-       tty_class = class_simple_create(THIS_MODULE, "tty");
+       tty_class = class_create(THIS_MODULE, "tty");
        if (IS_ERR(tty_class))
                return PTR_ERR(tty_class);
        return 0;
@@ -2947,14 +2947,14 @@ static int __init tty_init(void)
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
                panic("Couldn't register /dev/tty driver\n");
        devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty");
-       class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
+       class_device_create(tty_class, 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");
        devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console");
-       class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
+       class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
 
 #ifdef CONFIG_UNIX98_PTYS
        cdev_init(&ptmx_cdev, &ptmx_fops);
@@ -2962,7 +2962,7 @@ static int __init tty_init(void)
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
                panic("Couldn't register /dev/ptmx driver\n");
        devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx");
-       class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
+       class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
 #endif
 
 #ifdef CONFIG_VT
@@ -2971,7 +2971,7 @@ static int __init tty_init(void)
            register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
                panic("Couldn't register /dev/tty0 driver\n");
        devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0");
-       class_simple_device_add(tty_class, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
+       class_device_create(tty_class, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
 
        vty_init();
 #endif
index 7abe405b8657cd835a30d54f9628d656c2ed4510..79c2928a8817d1132389a129c4da1a36dda8afb3 100644 (file)
@@ -474,7 +474,7 @@ static struct file_operations vcs_fops = {
        .open           = vcs_open,
 };
 
-static struct class_simple *vc_class;
+static struct class *vc_class;
 
 void vcs_make_devfs(struct tty_struct *tty)
 {
@@ -484,26 +484,26 @@ void vcs_make_devfs(struct tty_struct *tty)
        devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129),
                        S_IFCHR|S_IRUSR|S_IWUSR,
                        "vcc/a%u", tty->index + 1);
-       class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, tty->index + 1), NULL, "vcs%u", tty->index + 1);
-       class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, tty->index + 129), NULL, "vcsa%u", tty->index + 1);
+       class_device_create(vc_class, MKDEV(VCS_MAJOR, tty->index + 1), NULL, "vcs%u", tty->index + 1);
+       class_device_create(vc_class, MKDEV(VCS_MAJOR, tty->index + 129), NULL, "vcsa%u", tty->index + 1);
 }
 void vcs_remove_devfs(struct tty_struct *tty)
 {
        devfs_remove("vcc/%u", tty->index + 1);
        devfs_remove("vcc/a%u", tty->index + 1);
-       class_simple_device_remove(MKDEV(VCS_MAJOR, tty->index + 1));
-       class_simple_device_remove(MKDEV(VCS_MAJOR, tty->index + 129));
+       class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1));
+       class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129));
 }
 
 int __init vcs_init(void)
 {
        if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops))
                panic("unable to get major %d for vcs device", VCS_MAJOR);
-       vc_class = class_simple_create(THIS_MODULE, "vc");
+       vc_class = class_create(THIS_MODULE, "vc");
 
        devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0");
        devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0");
-       class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
-       class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
+       class_device_create(vc_class, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
+       class_device_create(vc_class, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
        return 0;
 }
index aea3cbf5219d4a0ab89827f6179bf4118264279a..4764b4f9555de93de3ec0e945a7089a4e5dbf537 100644 (file)
@@ -237,7 +237,7 @@ static dma_addr_t viotape_unitinfo_token;
 
 static struct mtget viomtget[VIOTAPE_MAX_TAPE];
 
-static struct class_simple *tape_class;
+static struct class *tape_class;
 
 static struct device *tape_device[VIOTAPE_MAX_TAPE];
 
@@ -956,9 +956,9 @@ 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;
-       class_simple_device_add(tape_class, MKDEV(VIOTAPE_MAJOR, i), NULL,
+       class_device_create(tape_class, MKDEV(VIOTAPE_MAJOR, i), NULL,
                        "iseries!vt%d", i);
-       class_simple_device_add(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80),
+       class_device_create(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80),
                        NULL, "iseries!nvt%d", i);
        devfs_mk_cdev(MKDEV(VIOTAPE_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR,
                        "iseries/vt%d", i);
@@ -980,8 +980,8 @@ static int viotape_remove(struct vio_dev *vdev)
        devfs_remove("iseries/nvt%d", i);
        devfs_remove("iseries/vt%d", i);
        devfs_unregister_tape(state[i].dev_handle);
-       class_simple_device_remove(MKDEV(VIOTAPE_MAJOR, i | 0x80));
-       class_simple_device_remove(MKDEV(VIOTAPE_MAJOR, i));
+       class_device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80));
+       class_device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i));
        return 0;
 }
 
@@ -1045,7 +1045,7 @@ int __init viotap_init(void)
                goto clear_handler;
        }
 
-       tape_class = class_simple_create(THIS_MODULE, "tape");
+       tape_class = class_create(THIS_MODULE, "tape");
        if (IS_ERR(tape_class)) {
                printk(VIOTAPE_KERN_WARN "Unable to allocat class\n");
                ret = PTR_ERR(tape_class);
@@ -1070,7 +1070,7 @@ int __init viotap_init(void)
        return 0;
 
 unreg_class:
-       class_simple_destroy(tape_class);
+       class_destroy(tape_class);
 unreg_chrdev:
        unregister_chrdev(VIOTAPE_MAJOR, "viotape");
 clear_handler:
@@ -1110,7 +1110,7 @@ static void __exit viotap_exit(void)
 
        remove_proc_entry("iSeries/viotape", NULL);
        vio_unregister_driver(&viotape_driver);
-       class_simple_destroy(tape_class);
+       class_destroy(tape_class);
        ret = unregister_chrdev(VIOTAPE_MAJOR, "viotape");
        if (ret < 0)
                printk(VIOTAPE_KERN_WARN "Error unregistering device: %d\n",
index 03b5fb2ddcf44902aba3d2e79d7f1c5f3b036140..bf62dfe4976acc4f986886aa3e922c2c453d011a 100644 (file)
@@ -521,7 +521,7 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf)
        policy = cpufreq_cpu_get(policy->cpu);
        if (!policy)
                return -EINVAL;
-       ret = fattr->show ? fattr->show(policy,buf) : 0;
+       ret = fattr->show ? fattr->show(policy,buf) : -EIO;
        cpufreq_cpu_put(policy);
        return ret;
 }
@@ -535,7 +535,7 @@ static ssize_t store(struct kobject * kobj, struct attribute * attr,
        policy = cpufreq_cpu_get(policy->cpu);
        if (!policy)
                return -EINVAL;
-       ret = fattr->store ? fattr->store(policy,buf,count) : 0;
+       ret = fattr->store ? fattr->store(policy,buf,count) : -EIO;
        cpufreq_cpu_put(policy);
        return ret;
 }
index d30591f69dd9ce5304c258189ddfd9428c16a37f..f464630388471a69fb048d41f60c4d186821df3e 100644 (file)
@@ -17,7 +17,7 @@
 
 /* show configuration fields */
 
-static ssize_t dio_show_id(struct device *dev, char *buf)
+static ssize_t dio_show_id(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct dio_dev *d;
 
@@ -26,7 +26,7 @@ static ssize_t dio_show_id(struct device *dev, char *buf)
 }
 static DEVICE_ATTR(id, S_IRUGO, dio_show_id, NULL);
 
-static ssize_t dio_show_ipl(struct device *dev, char *buf)
+static ssize_t dio_show_ipl(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct dio_dev *d;
 
@@ -35,7 +35,7 @@ static ssize_t dio_show_ipl(struct device *dev, char *buf)
 }
 static DEVICE_ATTR(ipl, S_IRUGO, dio_show_ipl, NULL);
 
-static ssize_t dio_show_secid(struct device *dev, char *buf)
+static ssize_t dio_show_secid(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct dio_dev *d;
 
@@ -44,7 +44,7 @@ static ssize_t dio_show_secid(struct device *dev, char *buf)
 }
 static DEVICE_ATTR(secid, S_IRUGO, dio_show_secid, NULL);
 
-static ssize_t dio_show_name(struct device *dev, char *buf)
+static ssize_t dio_show_name(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct dio_dev *d;
 
@@ -53,7 +53,7 @@ static ssize_t dio_show_name(struct device *dev, char *buf)
 }
 static DEVICE_ATTR(name, S_IRUGO, dio_show_name, NULL);
 
-static ssize_t dio_show_resource(struct device *dev, char *buf)
+static ssize_t dio_show_resource(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct dio_dev *d = to_dio_dev(dev);
 
index 6381ba53853c25c32567be5c37934ad8582a6604..1937743c8e2971bb15b9f1d703aca168be4240e2 100644 (file)
@@ -149,7 +149,7 @@ void eisa_driver_unregister (struct eisa_driver *edrv)
        driver_unregister (&edrv->driver);
 }
 
-static ssize_t eisa_show_sig (struct device *dev, char *buf)
+static ssize_t eisa_show_sig (struct device *dev, struct device_attribute *attr, char *buf)
 {
         struct eisa_device *edev = to_eisa_device (dev);
         return sprintf (buf,"%s\n", edev->id.sig);
@@ -157,7 +157,7 @@ static ssize_t eisa_show_sig (struct device *dev, char *buf)
 
 static DEVICE_ATTR(signature, S_IRUGO, eisa_show_sig, NULL);
 
-static ssize_t eisa_show_state (struct device *dev, char *buf)
+static ssize_t eisa_show_state (struct device *dev, struct device_attribute *attr, char *buf)
 {
         struct eisa_device *edev = to_eisa_device (dev);
         return sprintf (buf,"%d\n", edev->state & EISA_CONFIG_ENABLED);
index 33b669e6f977ec392c662b973601c0b794dcf21b..6996476669f17397d1f9b1cab8e8b2f2a094cb6d 100644 (file)
@@ -115,7 +115,7 @@ edd_attr_show(struct kobject * kobj, struct attribute *attr, char *buf)
 {
        struct edd_device *dev = to_edd_device(kobj);
        struct edd_attribute *edd_attr = to_edd_attr(attr);
-       ssize_t ret = 0;
+       ssize_t ret = -EIO;
 
        if (edd_attr->show)
                ret = edd_attr->show(dev, buf);
index 0287ff65963be783c03397729532114c35be6393..a3451cb94004dc3a876f5032e6a440b8c6800df5 100644 (file)
@@ -352,7 +352,7 @@ static ssize_t efivar_attr_show(struct kobject *kobj, struct attribute *attr,
 {
        struct efivar_entry *var = to_efivar_entry(kobj);
        struct efivar_attribute *efivar_attr = to_efivar_attr(attr);
-       ssize_t ret = 0;
+       ssize_t ret = -EIO;
 
        if (!capable(CAP_SYS_ADMIN))
                return -EACCES;
@@ -368,7 +368,7 @@ static ssize_t efivar_attr_store(struct kobject *kobj, struct attribute *attr,
 {
        struct efivar_entry *var = to_efivar_entry(kobj);
        struct efivar_attribute *efivar_attr = to_efivar_attr(attr);
-       ssize_t ret = 0;
+       ssize_t ret = -EIO;
 
        if (!capable(CAP_SYS_ADMIN))
                return -EACCES;
index 9c59a370b6d9563179d9bba00846ef1e2be8e198..9058c3956710d38c5444e50876fbd31c6f4800b1 100644 (file)
@@ -137,7 +137,7 @@ static struct i2c_driver adm1021_driver = {
 };
 
 #define show(value)    \
-static ssize_t show_##value(struct device *dev, char *buf)             \
+static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf)              \
 {                                                                      \
        struct adm1021_data *data = adm1021_update_device(dev);         \
        return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value));        \
@@ -150,7 +150,7 @@ show(remote_temp_hyst);
 show(remote_temp_input);
 
 #define show2(value)   \
-static ssize_t show_##value(struct device *dev, char *buf)             \
+static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf)              \
 {                                                                      \
        struct adm1021_data *data = adm1021_update_device(dev);         \
        return sprintf(buf, "%d\n", data->value);                       \
@@ -159,7 +159,7 @@ show2(alarms);
 show2(die_code);
 
 #define set(value, reg)        \
-static ssize_t set_##value(struct device *dev, const char *buf, size_t count)  \
+static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)   \
 {                                                              \
        struct i2c_client *client = to_i2c_client(dev);         \
        struct adm1021_data *data = i2c_get_clientdata(client); \
index e0771a3d05c955ccf0278496ac104658a7701764..111f0c86c9337d9f7733d127c5c399850066d13d 100644 (file)
@@ -153,19 +153,19 @@ struct adm1025_data {
  */
 
 #define show_in(offset) \
-static ssize_t show_in##offset(struct device *dev, char *buf) \
+static ssize_t show_in##offset(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        struct adm1025_data *data = adm1025_update_device(dev); \
        return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \
                       in_scale[offset])); \
 } \
-static ssize_t show_in##offset##_min(struct device *dev, char *buf) \
+static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        struct adm1025_data *data = adm1025_update_device(dev); \
        return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \
                       in_scale[offset])); \
 } \
-static ssize_t show_in##offset##_max(struct device *dev, char *buf) \
+static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        struct adm1025_data *data = adm1025_update_device(dev); \
        return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \
@@ -180,17 +180,17 @@ show_in(4);
 show_in(5);
 
 #define show_temp(offset) \
-static ssize_t show_temp##offset(struct device *dev, char *buf) \
+static ssize_t show_temp##offset(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        struct adm1025_data *data = adm1025_update_device(dev); \
        return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \
 } \
-static ssize_t show_temp##offset##_min(struct device *dev, char *buf) \
+static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        struct adm1025_data *data = adm1025_update_device(dev); \
        return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \
 } \
-static ssize_t show_temp##offset##_max(struct device *dev, char *buf) \
+static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        struct adm1025_data *data = adm1025_update_device(dev); \
        return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \
@@ -200,7 +200,7 @@ show_temp(1);
 show_temp(2);
 
 #define set_in(offset) \
-static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \
+static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
        size_t count) \
 { \
        struct i2c_client *client = to_i2c_client(dev); \
@@ -214,7 +214,7 @@ static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \
        up(&data->update_lock); \
        return count; \
 } \
-static ssize_t set_in##offset##_max(struct device *dev, const char *buf, \
+static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
        size_t count) \
 { \
        struct i2c_client *client = to_i2c_client(dev); \
@@ -240,7 +240,7 @@ set_in(4);
 set_in(5);
 
 #define set_temp(offset) \
-static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \
+static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
        size_t count) \
 { \
        struct i2c_client *client = to_i2c_client(dev); \
@@ -254,7 +254,7 @@ static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \
        up(&data->update_lock); \
        return count; \
 } \
-static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \
+static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
        size_t count) \
 { \
        struct i2c_client *client = to_i2c_client(dev); \
@@ -275,26 +275,26 @@ static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
 set_temp(1);
 set_temp(2);
 
-static ssize_t show_alarms(struct device *dev, char *buf)
+static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1025_data *data = adm1025_update_device(dev);
        return sprintf(buf, "%u\n", data->alarms);
 }
 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
 
-static ssize_t show_vid(struct device *dev, char *buf)
+static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1025_data *data = adm1025_update_device(dev);
        return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));
 }
 static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL);
 
-static ssize_t show_vrm(struct device *dev, char *buf)
+static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1025_data *data = adm1025_update_device(dev);
        return sprintf(buf, "%u\n", data->vrm);
 }
-static ssize_t set_vrm(struct device *dev, const char *buf, size_t count)
+static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1025_data *data = i2c_get_clientdata(client);
index 39e2f4a900bf321be243ecac9656f7de29871327..b15fafe8f1116340604f20d3dbde248d041d48bf 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
 #include <linux/i2c-sensor.h>
+#include <linux/i2c-sysfs.h>
 #include <linux/i2c-vid.h>
 
 /* Addresses to scan */
@@ -711,19 +712,27 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)
        return data;
 }
 
-static ssize_t show_in(struct device *dev, char *buf, int nr)
+static ssize_t show_in(struct device *dev, struct device_attribute *attr,
+               char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in[nr]));
 }
-static ssize_t show_in_min(struct device *dev, char *buf, int nr) 
+static ssize_t show_in_min(struct device *dev, struct device_attribute *attr,
+               char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev); 
        return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr]));
 }
-static ssize_t set_in_min(struct device *dev, const char *buf, 
-               size_t count, int nr)
+static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
@@ -734,14 +743,19 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
        up(&data->update_lock);
        return count; 
 }
-static ssize_t show_in_max(struct device *dev, char *buf, int nr)
+static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
+               char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr]));
 }
-static ssize_t set_in_max(struct device *dev, const char *buf,
-               size_t count, int nr)
+static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
@@ -753,34 +767,13 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
        return count;
 }
 
-#define in_reg(offset)                                                    \
-static ssize_t show_in##offset (struct device *dev, char *buf)            \
-{                                                                         \
-       return show_in(dev, buf, offset);                                 \
-}                                                                         \
-static ssize_t show_in##offset##_min (struct device *dev, char *buf)      \
-{                                                                         \
-       return show_in_min(dev, buf, offset);                             \
-}                                                                         \
-static ssize_t set_in##offset##_min (struct device *dev,                  \
-       const char *buf, size_t count)                                    \
-{                                                                         \
-       return set_in_min(dev, buf, count, offset);                       \
-}                                                                         \
-static ssize_t show_in##offset##_max (struct device *dev, char *buf)      \
-{                                                                         \
-       return show_in_max(dev, buf, offset);                             \
-}                                                                         \
-static ssize_t set_in##offset##_max (struct device *dev,                  \
-       const char *buf, size_t count)                                    \
-{                                                                         \
-       return set_in_max(dev, buf, count, offset);                       \
-}                                                                         \
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);   \
-static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR,                   \
-               show_in##offset##_min, set_in##offset##_min);             \
-static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR,                   \
-               show_in##offset##_max, set_in##offset##_max);
+#define in_reg(offset)                                         \
+static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in,        \
+               NULL, offset);                                  \
+static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
+               show_in_min, set_in_min, offset);               \
+static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
+               show_in_max, set_in_max, offset);
 
 
 in_reg(0);
@@ -800,19 +793,19 @@ in_reg(13);
 in_reg(14);
 in_reg(15);
 
-static ssize_t show_in16(struct device *dev, char *buf)
+static ssize_t show_in16(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in[16]) -
                NEG12_OFFSET);
 }
-static ssize_t show_in16_min(struct device *dev, char *buf) 
+static ssize_t show_in16_min(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev); 
        return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_min[16])
                - NEG12_OFFSET);
 }
-static ssize_t set_in16_min(struct device *dev, const char *buf, size_t count)
+static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
@@ -824,13 +817,13 @@ static ssize_t set_in16_min(struct device *dev, const char *buf, size_t count)
        up(&data->update_lock);
        return count; 
 }
-static ssize_t show_in16_max(struct device *dev, char *buf)
+static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_max[16])
                        - NEG12_OFFSET);
 }
-static ssize_t set_in16_max(struct device *dev, const char *buf, size_t count)
+static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
@@ -843,30 +836,38 @@ static ssize_t set_in16_max(struct device *dev, const char *buf, size_t count)
        return count;
 }
 
-static DEVICE_ATTR(in16_input, S_IRUGO, show_in16, NULL);
-static DEVICE_ATTR(in16_min, S_IRUGO | S_IWUSR, show_in16_min, set_in16_min);
-static DEVICE_ATTR(in16_max, S_IRUGO | S_IWUSR, show_in16_max, set_in16_max);
+static SENSOR_DEVICE_ATTR(in16_input, S_IRUGO, show_in16, NULL, 16);
+static SENSOR_DEVICE_ATTR(in16_min, S_IRUGO | S_IWUSR, show_in16_min, set_in16_min, 16);
+static SENSOR_DEVICE_ATTR(in16_max, S_IRUGO | S_IWUSR, show_in16_max, set_in16_max, 16);
 
 
 
 
 /* Now add fan read/write functions */
 
-static ssize_t show_fan(struct device *dev, char *buf, int nr)
+static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
+               char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr],
                data->fan_div[nr]));
 }
-static ssize_t show_fan_min(struct device *dev, char *buf, int nr)
+static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
+               char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr],
                data->fan_div[nr]));
 }
-static ssize_t set_fan_min(struct device *dev, const char *buf,
-               size_t count, int nr)
+static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
@@ -879,23 +880,11 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
        return count;
 }
 
-#define fan_offset(offset)                                                  \
-static ssize_t show_fan_##offset (struct device *dev, char *buf)            \
-{                                                                           \
-       return show_fan(dev, buf, offset - 1);                              \
-}                                                                           \
-static ssize_t show_fan_##offset##_min (struct device *dev, char *buf)      \
-{                                                                           \
-       return show_fan_min(dev, buf, offset - 1);                          \
-}                                                                           \
-static ssize_t set_fan_##offset##_min (struct device *dev,                  \
-       const char *buf, size_t count)                                      \
-{                                                                           \
-       return set_fan_min(dev, buf, count, offset - 1);                    \
-}                                                                           \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);  \
-static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR,                    \
-               show_fan_##offset##_min, set_fan_##offset##_min);
+#define fan_offset(offset)                                                     \
+static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL,        \
+               offset - 1);                                                    \
+static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR,                \
+               show_fan_min, set_fan_min, offset - 1);
 
 fan_offset(1);
 fan_offset(2);
@@ -926,14 +915,19 @@ static void fixup_fan_min(struct device *dev, int fan, int old_div)
 }
 
 /* Now add fan_div read/write functions */
-static ssize_t show_fan_div(struct device *dev, char *buf, int nr)
+static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr,
+               char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", data->fan_div[nr]);
 }
-static ssize_t set_fan_div(struct device *dev, const char *buf,
-               size_t count, int nr)
+static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
        int    val,orig_div,new_div,shift;
@@ -967,17 +961,8 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
 }
 
 #define fan_offset_div(offset)                                          \
-static ssize_t show_fan_##offset##_div (struct device *dev, char *buf)  \
-{                                                                       \
-       return show_fan_div(dev, buf, offset - 1);                      \
-}                                                                       \
-static ssize_t set_fan_##offset##_div (struct device *dev,              \
-       const char *buf, size_t count)                                  \
-{                                                                       \
-       return set_fan_div(dev, buf, count, offset - 1);                \
-}                                                                       \
-static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR,                \
-               show_fan_##offset##_div, set_fan_##offset##_div);
+static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR,         \
+               show_fan_div, set_fan_div, offset - 1);
 
 fan_offset_div(1);
 fan_offset_div(2);
@@ -989,19 +974,27 @@ fan_offset_div(7);
 fan_offset_div(8);
 
 /* Temps */
-static ssize_t show_temp(struct device *dev, char *buf, int nr)
+static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
+               char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp[nr]));
 }
-static ssize_t show_temp_min(struct device *dev, char *buf, int nr)
+static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
+               char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr]));
 }
-static ssize_t set_temp_min(struct device *dev, const char *buf,
-               size_t count, int nr)
+static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
@@ -1013,14 +1006,19 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
        up(&data->update_lock);
        return count;
 }
-static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
+static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
+               char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr]));
 }
-static ssize_t set_temp_max(struct device *dev, const char *buf,
-               size_t count, int nr)
+static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
@@ -1032,48 +1030,34 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
        up(&data->update_lock);
        return count;
 }
-#define temp_reg(offset)                                                      \
-static ssize_t show_temp_##offset (struct device *dev, char *buf)             \
-{                                                                             \
-       return show_temp(dev, buf, offset - 1);                               \
-}                                                                             \
-static ssize_t show_temp_##offset##_min (struct device *dev, char *buf)       \
-{                                                                             \
-       return show_temp_min(dev, buf, offset - 1);                           \
-}                                                                             \
-static ssize_t show_temp_##offset##_max (struct device *dev, char *buf)       \
-{                                                                             \
-       return show_temp_max(dev, buf, offset - 1);                           \
-}                                                                             \
-static ssize_t set_temp_##offset##_min (struct device *dev,                   \
-       const char *buf, size_t count)                                        \
-{                                                                             \
-       return set_temp_min(dev, buf, count, offset - 1);                     \
-}                                                                             \
-static ssize_t set_temp_##offset##_max (struct device *dev,                   \
-       const char *buf, size_t count)                                        \
-{                                                                             \
-       return set_temp_max(dev, buf, count, offset - 1);                     \
-}                                                                             \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);  \
-static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR,                     \
-               show_temp_##offset##_min, set_temp_##offset##_min);           \
-static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR,                     \
-               show_temp_##offset##_max, set_temp_##offset##_max);
+
+#define temp_reg(offset)                                               \
+static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp,    \
+               NULL, offset - 1);                                      \
+static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR,       \
+               show_temp_min, set_temp_min, offset - 1);               \
+static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR,       \
+               show_temp_max, set_temp_max, offset - 1);
 
 
 temp_reg(1);
 temp_reg(2);
 temp_reg(3);
 
-static ssize_t show_temp_offset(struct device *dev, char *buf, int nr)
+static ssize_t show_temp_offset(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_offset[nr]));
 }
-static ssize_t set_temp_offset(struct device *dev, const char *buf,
-               size_t count, int nr)
+static ssize_t set_temp_offset(struct device *dev,
+               struct device_attribute *attr, const char *buf,
+               size_t count)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
@@ -1086,46 +1070,45 @@ static ssize_t set_temp_offset(struct device *dev, const char *buf,
        return count;
 }
 
-#define temp_offset_reg(offset)                                             \
-static ssize_t show_temp_##offset##_offset (struct device *dev, char *buf)  \
-{                                                                           \
-       return show_temp_offset(dev, buf, offset - 1);                      \
-}                                                                           \
-static ssize_t set_temp_##offset##_offset (struct device *dev,              \
-       const char *buf, size_t count)                                      \
-{                                                                           \
-       return set_temp_offset(dev, buf, count, offset - 1);                \
-}                                                                           \
-static DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR,                \
-               show_temp_##offset##_offset, set_temp_##offset##_offset);
+#define temp_offset_reg(offset)                                                        \
+static SENSOR_DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR,            \
+               show_temp_offset, set_temp_offset, offset - 1);
 
 temp_offset_reg(1);
 temp_offset_reg(2);
 temp_offset_reg(3);
 
-static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev, char *buf,
-               int nr)
+static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", TEMP_FROM_REG(
                ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr]));
 }
-static ssize_t show_temp_auto_point2_temp(struct device *dev, char *buf,
-               int nr)
+static ssize_t show_temp_auto_point2_temp(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr] +
                ADM1026_FAN_CONTROL_TEMP_RANGE));
 }
-static ssize_t show_temp_auto_point1_temp(struct device *dev, char *buf,
-               int nr)
+static ssize_t show_temp_auto_point1_temp(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr]));
 }
-static ssize_t set_temp_auto_point1_temp(struct device *dev, const char *buf,
-               size_t count, int nr)
+static ssize_t set_temp_auto_point1_temp(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
@@ -1138,46 +1121,27 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev, const char *buf,
        return count;
 }
 
-#define temp_auto_point(offset)                                             \
-static ssize_t show_temp##offset##_auto_point1_temp (struct device *dev,    \
-       char *buf)                                                          \
-{                                                                           \
-       return show_temp_auto_point1_temp(dev, buf, offset - 1);            \
-}                                                                           \
-static ssize_t set_temp##offset##_auto_point1_temp (struct device *dev,     \
-       const char *buf, size_t count)                                      \
-{                                                                           \
-       return set_temp_auto_point1_temp(dev, buf, count, offset - 1);      \
-}                                                                           \
-static ssize_t show_temp##offset##_auto_point1_temp_hyst (struct device     \
-       *dev, char *buf)                                                    \
-{                                                                           \
-       return show_temp_auto_point1_temp_hyst(dev, buf, offset - 1);       \
-}                                                                           \
-static ssize_t show_temp##offset##_auto_point2_temp (struct device *dev,    \
-        char *buf)                                                         \
-{                                                                           \
-       return show_temp_auto_point2_temp(dev, buf, offset - 1);            \
-}                                                                           \
-static DEVICE_ATTR(temp##offset##_auto_point1_temp, S_IRUGO | S_IWUSR,      \
-               show_temp##offset##_auto_point1_temp,                       \
-               set_temp##offset##_auto_point1_temp);                       \
-static DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO,           \
-               show_temp##offset##_auto_point1_temp_hyst, NULL);           \
-static DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO,                \
-               show_temp##offset##_auto_point2_temp, NULL);
+#define temp_auto_point(offset)                                                        \
+static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp, S_IRUGO | S_IWUSR,  \
+               show_temp_auto_point1_temp, set_temp_auto_point1_temp,          \
+               offset - 1);                                                    \
+static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO,       \
+               show_temp_auto_point1_temp_hyst, NULL, offset - 1);             \
+static SENSOR_DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO,            \
+               show_temp_auto_point2_temp, NULL, offset - 1);
 
 temp_auto_point(1);
 temp_auto_point(2);
 temp_auto_point(3);
 
-static ssize_t show_temp_crit_enable(struct device *dev, char *buf)
+static ssize_t show_temp_crit_enable(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", (data->config1 & CFG1_THERM_HOT) >> 4);
 }
-static ssize_t set_temp_crit_enable(struct device *dev, const char *buf,
-               size_t count)
+static ssize_t set_temp_crit_enable(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
@@ -1193,24 +1157,27 @@ static ssize_t set_temp_crit_enable(struct device *dev, const char *buf,
        return count;
 }
 
-static DEVICE_ATTR(temp1_crit_enable, S_IRUGO | S_IWUSR, 
-       show_temp_crit_enable, set_temp_crit_enable);
-
-static DEVICE_ATTR(temp2_crit_enable, S_IRUGO | S_IWUSR, 
-       show_temp_crit_enable, set_temp_crit_enable);
-
-static DEVICE_ATTR(temp3_crit_enable, S_IRUGO | S_IWUSR, 
+#define temp_crit_enable(offset)                               \
+static DEVICE_ATTR(temp##offset##_crit_enable, S_IRUGO | S_IWUSR, \
        show_temp_crit_enable, set_temp_crit_enable);
 
+temp_crit_enable(1);
+temp_crit_enable(2);
+temp_crit_enable(3);
 
-static ssize_t show_temp_crit(struct device *dev, char *buf, int nr)
+static ssize_t show_temp_crit(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_crit[nr]));
 }
-static ssize_t set_temp_crit(struct device *dev, const char *buf,
-               size_t count, int nr)
+static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
 {
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
@@ -1223,29 +1190,20 @@ static ssize_t set_temp_crit(struct device *dev, const char *buf,
        return count;
 }
 
-#define temp_crit_reg(offset)                                             \
-static ssize_t show_temp_##offset##_crit (struct device *dev, char *buf)  \
-{                                                                         \
-       return show_temp_crit(dev, buf, offset - 1);                      \
-}                                                                         \
-static ssize_t set_temp_##offset##_crit (struct device *dev,              \
-       const char *buf, size_t count)                                    \
-{                                                                         \
-       return set_temp_crit(dev, buf, count, offset - 1);                \
-}                                                                         \
-static DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR,                \
-               show_temp_##offset##_crit, set_temp_##offset##_crit);
+#define temp_crit_reg(offset)                                          \
+static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR,      \
+               show_temp_crit, set_temp_crit, offset - 1);
 
 temp_crit_reg(1);
 temp_crit_reg(2);
 temp_crit_reg(3);
 
-static ssize_t show_analog_out_reg(struct device *dev, char *buf)
+static ssize_t show_analog_out_reg(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", DAC_FROM_REG(data->analog_out));
 }
-static ssize_t set_analog_out_reg(struct device *dev, const char *buf,
+static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *attr, const char *buf,
                size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -1262,7 +1220,7 @@ static ssize_t set_analog_out_reg(struct device *dev, const char *buf,
 static DEVICE_ATTR(analog_out, S_IRUGO | S_IWUSR, show_analog_out_reg, 
        set_analog_out_reg);
 
-static ssize_t show_vid_reg(struct device *dev, char *buf)
+static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm));
@@ -1270,12 +1228,12 @@ static ssize_t show_vid_reg(struct device *dev, char *buf)
 
 static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL);
 
-static ssize_t show_vrm_reg(struct device *dev, char *buf)
+static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", data->vrm);
 }
-static ssize_t store_vrm_reg(struct device *dev, const char *buf,
+static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf,
                size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -1287,7 +1245,7 @@ static ssize_t store_vrm_reg(struct device *dev, const char *buf,
 
 static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
 
-static ssize_t show_alarms_reg(struct device *dev, char *buf)
+static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf, "%ld\n", (long) (data->alarms));
@@ -1295,12 +1253,12 @@ static ssize_t show_alarms_reg(struct device *dev, char *buf)
 
 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
 
-static ssize_t show_alarm_mask(struct device *dev, char *buf)
+static ssize_t show_alarm_mask(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%ld\n", data->alarm_mask);
 }
-static ssize_t set_alarm_mask(struct device *dev, const char *buf,
+static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, const char *buf,
                size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -1331,12 +1289,12 @@ static DEVICE_ATTR(alarm_mask, S_IRUGO | S_IWUSR, show_alarm_mask,
        set_alarm_mask);
 
 
-static ssize_t show_gpio(struct device *dev, char *buf)
+static ssize_t show_gpio(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%ld\n", data->gpio);
 }
-static ssize_t set_gpio(struct device *dev, const char *buf,
+static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const char *buf,
                size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -1359,12 +1317,12 @@ static ssize_t set_gpio(struct device *dev, const char *buf,
 static DEVICE_ATTR(gpio, S_IRUGO | S_IWUSR, show_gpio, set_gpio);
 
 
-static ssize_t show_gpio_mask(struct device *dev, char *buf)
+static ssize_t show_gpio_mask(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%ld\n", data->gpio_mask);
 }
-static ssize_t set_gpio_mask(struct device *dev, const char *buf,
+static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, const char *buf,
                size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -1386,12 +1344,12 @@ static ssize_t set_gpio_mask(struct device *dev, const char *buf,
 
 static DEVICE_ATTR(gpio_mask, S_IRUGO | S_IWUSR, show_gpio_mask, set_gpio_mask);
 
-static ssize_t show_pwm_reg(struct device *dev, char *buf)
+static ssize_t show_pwm_reg(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm1.pwm));
 }
-static ssize_t set_pwm_reg(struct device *dev, const char *buf,
+static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, const char *buf,
                size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -1407,12 +1365,12 @@ static ssize_t set_pwm_reg(struct device *dev, const char *buf,
        }
        return count;
 }
-static ssize_t show_auto_pwm_min(struct device *dev, char *buf)
+static ssize_t show_auto_pwm_min(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", data->pwm1.auto_pwm_min);
 }
-static ssize_t set_auto_pwm_min(struct device *dev, const char *buf,
+static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *attr, const char *buf,
                size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -1429,16 +1387,16 @@ static ssize_t set_auto_pwm_min(struct device *dev, const char *buf,
        up(&data->update_lock);
        return count;
 }
-static ssize_t show_auto_pwm_max(struct device *dev, char *buf)
+static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf)
 {
        return sprintf(buf,"%d\n", ADM1026_PWM_MAX);
 }
-static ssize_t show_pwm_enable(struct device *dev, char *buf)
+static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1026_data *data = adm1026_update_device(dev);
        return sprintf(buf,"%d\n", data->pwm1.enable);
 }
-static ssize_t set_pwm_enable(struct device *dev, const char *buf,
+static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, const char *buf,
                size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -1597,114 +1555,114 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
        adm1026_init_client(new_client);
 
        /* Register sysfs hooks */
-       device_create_file(&new_client->dev, &dev_attr_in0_input);
-       device_create_file(&new_client->dev, &dev_attr_in0_max);
-       device_create_file(&new_client->dev, &dev_attr_in0_min);
-       device_create_file(&new_client->dev, &dev_attr_in1_input);
-       device_create_file(&new_client->dev, &dev_attr_in1_max);
-       device_create_file(&new_client->dev, &dev_attr_in1_min);
-       device_create_file(&new_client->dev, &dev_attr_in2_input);
-       device_create_file(&new_client->dev, &dev_attr_in2_max);
-       device_create_file(&new_client->dev, &dev_attr_in2_min);
-       device_create_file(&new_client->dev, &dev_attr_in3_input);
-       device_create_file(&new_client->dev, &dev_attr_in3_max);
-       device_create_file(&new_client->dev, &dev_attr_in3_min);
-       device_create_file(&new_client->dev, &dev_attr_in4_input);
-       device_create_file(&new_client->dev, &dev_attr_in4_max);
-       device_create_file(&new_client->dev, &dev_attr_in4_min);
-       device_create_file(&new_client->dev, &dev_attr_in5_input);
-       device_create_file(&new_client->dev, &dev_attr_in5_max);
-       device_create_file(&new_client->dev, &dev_attr_in5_min);
-       device_create_file(&new_client->dev, &dev_attr_in6_input);
-       device_create_file(&new_client->dev, &dev_attr_in6_max);
-       device_create_file(&new_client->dev, &dev_attr_in6_min);
-       device_create_file(&new_client->dev, &dev_attr_in7_input);
-       device_create_file(&new_client->dev, &dev_attr_in7_max);
-       device_create_file(&new_client->dev, &dev_attr_in7_min);
-       device_create_file(&new_client->dev, &dev_attr_in8_input);
-       device_create_file(&new_client->dev, &dev_attr_in8_max);
-       device_create_file(&new_client->dev, &dev_attr_in8_min);
-       device_create_file(&new_client->dev, &dev_attr_in9_input);
-       device_create_file(&new_client->dev, &dev_attr_in9_max);
-       device_create_file(&new_client->dev, &dev_attr_in9_min);
-       device_create_file(&new_client->dev, &dev_attr_in10_input);
-       device_create_file(&new_client->dev, &dev_attr_in10_max);
-       device_create_file(&new_client->dev, &dev_attr_in10_min);
-       device_create_file(&new_client->dev, &dev_attr_in11_input);
-       device_create_file(&new_client->dev, &dev_attr_in11_max);
-       device_create_file(&new_client->dev, &dev_attr_in11_min);
-       device_create_file(&new_client->dev, &dev_attr_in12_input);
-       device_create_file(&new_client->dev, &dev_attr_in12_max);
-       device_create_file(&new_client->dev, &dev_attr_in12_min);
-       device_create_file(&new_client->dev, &dev_attr_in13_input);
-       device_create_file(&new_client->dev, &dev_attr_in13_max);
-       device_create_file(&new_client->dev, &dev_attr_in13_min);
-       device_create_file(&new_client->dev, &dev_attr_in14_input);
-       device_create_file(&new_client->dev, &dev_attr_in14_max);
-       device_create_file(&new_client->dev, &dev_attr_in14_min);
-       device_create_file(&new_client->dev, &dev_attr_in15_input);
-       device_create_file(&new_client->dev, &dev_attr_in15_max);
-       device_create_file(&new_client->dev, &dev_attr_in15_min);
-       device_create_file(&new_client->dev, &dev_attr_in16_input);
-       device_create_file(&new_client->dev, &dev_attr_in16_max);
-       device_create_file(&new_client->dev, &dev_attr_in16_min);
-       device_create_file(&new_client->dev, &dev_attr_fan1_input);
-       device_create_file(&new_client->dev, &dev_attr_fan1_div);
-       device_create_file(&new_client->dev, &dev_attr_fan1_min);
-       device_create_file(&new_client->dev, &dev_attr_fan2_input);
-       device_create_file(&new_client->dev, &dev_attr_fan2_div);
-       device_create_file(&new_client->dev, &dev_attr_fan2_min);
-       device_create_file(&new_client->dev, &dev_attr_fan3_input);
-       device_create_file(&new_client->dev, &dev_attr_fan3_div);
-       device_create_file(&new_client->dev, &dev_attr_fan3_min);
-       device_create_file(&new_client->dev, &dev_attr_fan4_input);
-       device_create_file(&new_client->dev, &dev_attr_fan4_div);
-       device_create_file(&new_client->dev, &dev_attr_fan4_min);
-       device_create_file(&new_client->dev, &dev_attr_fan5_input);
-       device_create_file(&new_client->dev, &dev_attr_fan5_div);
-       device_create_file(&new_client->dev, &dev_attr_fan5_min);
-       device_create_file(&new_client->dev, &dev_attr_fan6_input);
-       device_create_file(&new_client->dev, &dev_attr_fan6_div);
-       device_create_file(&new_client->dev, &dev_attr_fan6_min);
-       device_create_file(&new_client->dev, &dev_attr_fan7_input);
-       device_create_file(&new_client->dev, &dev_attr_fan7_div);
-       device_create_file(&new_client->dev, &dev_attr_fan7_min);
-       device_create_file(&new_client->dev, &dev_attr_fan8_input);
-       device_create_file(&new_client->dev, &dev_attr_fan8_div);
-       device_create_file(&new_client->dev, &dev_attr_fan8_min);
-       device_create_file(&new_client->dev, &dev_attr_temp1_input);
-       device_create_file(&new_client->dev, &dev_attr_temp1_max);
-       device_create_file(&new_client->dev, &dev_attr_temp1_min);
-       device_create_file(&new_client->dev, &dev_attr_temp2_input);
-       device_create_file(&new_client->dev, &dev_attr_temp2_max);
-       device_create_file(&new_client->dev, &dev_attr_temp2_min);
-       device_create_file(&new_client->dev, &dev_attr_temp3_input);
-       device_create_file(&new_client->dev, &dev_attr_temp3_max);
-       device_create_file(&new_client->dev, &dev_attr_temp3_min);
-       device_create_file(&new_client->dev, &dev_attr_temp1_offset);
-       device_create_file(&new_client->dev, &dev_attr_temp2_offset);
-       device_create_file(&new_client->dev, &dev_attr_temp3_offset);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in11_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in11_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in11_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in12_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in12_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in12_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in13_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in13_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in13_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in14_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in14_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in14_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in15_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in15_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in15_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in16_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in16_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_in16_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan1_div.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan1_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan2_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan2_div.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan2_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan3_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan3_div.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan3_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan4_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan4_div.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan4_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan5_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan5_div.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan5_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan6_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan6_div.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan6_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan7_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan7_div.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan7_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan8_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan8_div.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_fan8_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp1_offset.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp2_offset.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp3_offset.dev_attr);
        device_create_file(&new_client->dev, 
-               &dev_attr_temp1_auto_point1_temp);
+               &sensor_dev_attr_temp1_auto_point1_temp.dev_attr);
        device_create_file(&new_client->dev, 
-               &dev_attr_temp2_auto_point1_temp);
+               &sensor_dev_attr_temp2_auto_point1_temp.dev_attr);
        device_create_file(&new_client->dev, 
-               &dev_attr_temp3_auto_point1_temp);
+               &sensor_dev_attr_temp3_auto_point1_temp.dev_attr);
        device_create_file(&new_client->dev,
-               &dev_attr_temp1_auto_point1_temp_hyst);
+               &sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr);
        device_create_file(&new_client->dev,
-               &dev_attr_temp2_auto_point1_temp_hyst);
+               &sensor_dev_attr_temp2_auto_point1_temp_hyst.dev_attr);
        device_create_file(&new_client->dev,
-               &dev_attr_temp3_auto_point1_temp_hyst);
+               &sensor_dev_attr_temp3_auto_point1_temp_hyst.dev_attr);
        device_create_file(&new_client->dev, 
-               &dev_attr_temp1_auto_point2_temp);
+               &sensor_dev_attr_temp1_auto_point2_temp.dev_attr);
        device_create_file(&new_client->dev, 
-               &dev_attr_temp2_auto_point2_temp);
+               &sensor_dev_attr_temp2_auto_point2_temp.dev_attr);
        device_create_file(&new_client->dev, 
-               &dev_attr_temp3_auto_point2_temp);
-       device_create_file(&new_client->dev, &dev_attr_temp1_crit);
-       device_create_file(&new_client->dev, &dev_attr_temp2_crit);
-       device_create_file(&new_client->dev, &dev_attr_temp3_crit);
+               &sensor_dev_attr_temp3_auto_point2_temp.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr);
+       device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr);
        device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable);
        device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable);
        device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable);
index d4385a23f79a7d7abce199990ff3a8bbe315396b..2163dba467c47a3dfb5282d255dada96ffe89d7f 100644 (file)
@@ -292,11 +292,11 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
 }
 
 #define fan_auto_channel_offset(offset)                                                \
-static ssize_t show_fan_auto_channel_##offset (struct device *dev, char *buf)  \
+static ssize_t show_fan_auto_channel_##offset (struct device *dev, struct device_attribute *attr, char *buf)   \
 {                                                                              \
        return show_fan_auto_channel(dev, buf, offset - 1);                     \
 }                                                                              \
-static ssize_t set_fan_auto_channel_##offset (struct device *dev,              \
+static ssize_t set_fan_auto_channel_##offset (struct device *dev, struct device_attribute *attr,               \
        const char *buf, size_t count)                                          \
 {                                                                              \
        return set_fan_auto_channel(dev, buf, count, offset - 1);               \
@@ -357,24 +357,24 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr)
 }
 
 #define auto_temp_reg(offset)                                                  \
-static ssize_t show_auto_temp_##offset##_off (struct device *dev, char *buf)   \
+static ssize_t show_auto_temp_##offset##_off (struct device *dev, struct device_attribute *attr, char *buf)    \
 {                                                                              \
        return show_auto_temp_off(dev, buf, offset - 1);                        \
 }                                                                              \
-static ssize_t show_auto_temp_##offset##_min (struct device *dev, char *buf)   \
+static ssize_t show_auto_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf)    \
 {                                                                              \
        return show_auto_temp_min(dev, buf, offset - 1);                        \
 }                                                                              \
-static ssize_t show_auto_temp_##offset##_max (struct device *dev, char *buf)   \
+static ssize_t show_auto_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf)    \
 {                                                                              \
        return show_auto_temp_max(dev, buf, offset - 1);                        \
 }                                                                              \
-static ssize_t set_auto_temp_##offset##_min (struct device *dev,               \
+static ssize_t set_auto_temp_##offset##_min (struct device *dev, struct device_attribute *attr,                \
                                             const char *buf, size_t count)     \
 {                                                                              \
        return set_auto_temp_min(dev, buf, count, offset - 1);          \
 }                                                                              \
-static ssize_t set_auto_temp_##offset##_max (struct device *dev,               \
+static ssize_t set_auto_temp_##offset##_max (struct device *dev, struct device_attribute *attr,                \
                                             const char *buf, size_t count)     \
 {                                                                              \
        return set_auto_temp_max(dev, buf, count, offset - 1);          \
@@ -421,11 +421,11 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
 }
 
 #define pwm_reg(offset)                                                        \
-static ssize_t show_pwm_##offset (struct device *dev, char *buf)       \
+static ssize_t show_pwm_##offset (struct device *dev, struct device_attribute *attr, char *buf)        \
 {                                                                      \
        return show_pwm(dev, buf, offset - 1);                  \
 }                                                                      \
-static ssize_t set_pwm_##offset (struct device *dev,                   \
+static ssize_t set_pwm_##offset (struct device *dev, struct device_attribute *attr,                    \
                                 const char *buf, size_t count)         \
 {                                                                      \
        return set_pwm(dev, buf, count, offset - 1);            \
@@ -557,24 +557,24 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
 }
 
 #define fan_offset(offset)                                             \
-static ssize_t show_fan_##offset (struct device *dev, char *buf)       \
+static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf)        \
 {                                                                      \
        return show_fan(dev, buf, offset - 1);                  \
 }                                                                      \
-static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
+static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf)  \
 {                                                                      \
        return show_fan_min(dev, buf, offset - 1);                      \
 }                                                                      \
-static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \
+static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf)  \
 {                                                                      \
        return show_fan_div(dev, buf, offset - 1);                      \
 }                                                                      \
-static ssize_t set_fan_##offset##_min (struct device *dev,             \
+static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr,              \
        const char *buf, size_t count)                                  \
 {                                                                      \
        return set_fan_min(dev, buf, count, offset - 1);                \
 }                                                                      \
-static ssize_t set_fan_##offset##_div (struct device *dev,             \
+static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr,              \
        const char *buf, size_t count)                                  \
 {                                                                      \
        return set_fan_div(dev, buf, count, offset - 1);                \
@@ -667,33 +667,33 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr)
 }
 
 #define temp_reg(offset)                                                       \
-static ssize_t show_temp_##offset (struct device *dev, char *buf)              \
+static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf)               \
 {                                                                              \
        return show_temp(dev, buf, offset - 1);                         \
 }                                                                              \
-static ssize_t show_temp_##offset##_min (struct device *dev, char *buf)                \
+static ssize_t show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf)         \
 {                                                                              \
        return show_temp_min(dev, buf, offset - 1);                             \
 }                                                                              \
-static ssize_t show_temp_##offset##_max (struct device *dev, char *buf)                \
+static ssize_t show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf)         \
 {                                                                              \
        return show_temp_max(dev, buf, offset - 1);                             \
 }                                                                              \
-static ssize_t show_temp_##offset##_crit (struct device *dev, char *buf)       \
+static ssize_t show_temp_##offset##_crit (struct device *dev, struct device_attribute *attr, char *buf)        \
 {                                                                              \
        return show_temp_crit(dev, buf, offset - 1);                    \
 }                                                                              \
-static ssize_t set_temp_##offset##_min (struct device *dev,                    \
+static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr,                     \
                                        const char *buf, size_t count)          \
 {                                                                              \
        return set_temp_min(dev, buf, count, offset - 1);                       \
 }                                                                              \
-static ssize_t set_temp_##offset##_max (struct device *dev,                    \
+static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr,                     \
                                        const char *buf, size_t count)          \
 {                                                                              \
        return set_temp_max(dev, buf, count, offset - 1);                       \
 }                                                                              \
-static ssize_t set_temp_##offset##_crit (struct device *dev,                   \
+static ssize_t set_temp_##offset##_crit (struct device *dev, struct device_attribute *attr,                    \
                                         const char *buf, size_t count)         \
 {                                                                              \
        return set_temp_crit(dev, buf, count, offset - 1);                      \
@@ -712,7 +712,7 @@ temp_reg(2);
 temp_reg(3);
 
 /* Alarms */
-static ssize_t show_alarms(struct device *dev, char *buf)
+static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct adm1031_data *data = adm1031_update_device(dev);
        return sprintf(buf, "%d\n", data->alarm);
index 7f899002bc5493ca2cbbf1225dca003c6c63e6b3..4a47b4493e34aa8b567efcf818f89245a53b3182 100644 (file)
@@ -260,28 +260,28 @@ set_in_reg(MAX, max)
 
 #define sysfs_in(offset) \
 static ssize_t \
-       show_in##offset (struct device *dev, char *buf) \
+       show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        return show_in(dev, buf, offset); \
 } \
 static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
                show_in##offset, NULL); \
 static ssize_t \
-       show_in##offset##_min (struct device *dev, char *buf) \
+       show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        return show_in_min(dev, buf, offset); \
 } \
 static ssize_t \
-       show_in##offset##_max (struct device *dev, char *buf) \
+       show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        return show_in_max(dev, buf, offset); \
 } \
-static ssize_t set_in##offset##_min (struct device *dev, \
+static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
                const char *buf, size_t count) \
 { \
        return set_in_min(dev, buf, count, offset); \
 } \
-static ssize_t set_in##offset##_max (struct device *dev, \
+static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
                const char *buf, size_t count) \
 { \
        return set_in_max(dev, buf, count, offset); \
@@ -389,24 +389,24 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
 }
 
 #define sysfs_fan(offset) \
-static ssize_t show_fan##offset(struct device *dev, char *buf) \
+static ssize_t show_fan##offset(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        return show_fan(dev, buf, offset - 1); \
 } \
-static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \
+static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        return show_fan_min(dev, buf, offset - 1); \
 } \
-static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \
+static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        return show_fan_div(dev, buf, offset - 1); \
 } \
-static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \
+static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
                                        size_t count) \
 { \
        return set_fan_min(dev, buf, count, offset - 1); \
 } \
-static ssize_t set_fan##offset##_div(struct device *dev, const char *buf, \
+static ssize_t set_fan##offset##_div(struct device *dev, struct device_attribute *attr, const char *buf, \
                                        size_t count) \
 { \
        return set_fan_div(dev, buf, count, offset - 1); \
@@ -482,27 +482,27 @@ set_temp_reg(MAX, temp_max);
 set_temp_reg(HYST, temp_hyst);
 
 #define sysfs_temp(num) \
-static ssize_t show_temp##num(struct device *dev, char *buf) \
+static ssize_t show_temp##num(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        return show_temp(dev, buf, num-1); \
 } \
 static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL); \
-static ssize_t show_temp_max##num(struct device *dev, char *buf) \
+static ssize_t show_temp_max##num(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        return show_temp_max(dev, buf, num-1); \
 } \
-static ssize_t set_temp_max##num(struct device *dev, const char *buf, \
+static ssize_t set_temp_max##num(struct device *dev, struct device_attribute *attr, const char *buf, \
                                        size_t count) \
 { \
        return set_temp_max(dev, buf, count, num-1); \
 } \
 static DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \
                show_temp_max##num, set_temp_max##num); \
-static ssize_t show_temp_hyst##num(struct device *dev, char *buf) \
+static ssize_t show_temp_hyst##num(struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        return show_temp_hyst(dev, buf, num-1); \
 } \
-static ssize_t set_temp_hyst##num(struct device *dev, const char *buf, \
+static ssize_t set_temp_hyst##num(struct device *dev, struct device_attribute *attr, const char *buf, \
                                        size_t count) \
 { \
        return set_temp_hyst(dev, buf, count, num-1); \
@@ -522,7 +522,7 @@ sysfs_temp(4);
        device_create_file(&client->dev, &dev_attr_temp##num##_max_hyst); \
 } while (0)
 
-static ssize_t show_vid(struct device *dev, char *buf)
+static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct asb100_data *data = asb100_update_device(dev);
        return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
@@ -533,13 +533,13 @@ static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
 device_create_file(&client->dev, &dev_attr_cpu0_vid)
 
 /* VRM */
-static ssize_t show_vrm(struct device *dev, char *buf)
+static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct asb100_data *data = asb100_update_device(dev);
        return sprintf(buf, "%d\n", data->vrm);
 }
 
-static ssize_t set_vrm(struct device *dev, const char *buf, size_t count)
+static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
        struct asb100_data *data = i2c_get_clientdata(client);
@@ -553,7 +553,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
 #define device_create_file_vrm(client) \
 device_create_file(&client->dev, &dev_attr_vrm);
 
-static ssize_t show_alarms(struct device *dev, char *buf)
+static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct asb100_data *data = asb100_update_device(dev);
        return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms));
@@ -564,13 +564,13 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
 device_create_file(&client->dev, &dev_attr_alarms)
 
 /* 1 PWM */
-static ssize_t show_pwm1(struct device *dev, char *buf)
+static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct asb100_data *data = asb100_update_device(dev);
        return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f));
 }
 
-static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count)
+static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
        struct asb100_data *data = i2c_get_clientdata(client);
@@ -584,13 +584,13 @@ static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count)
        return count;
 }
 
-static ssize_t show_pwm_enable1(struct device *dev, char *buf)
+static ssize_t show_pwm_enable1(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct asb100_data *data = asb100_update_device(dev);
        return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0);
 }
 
-static ssize_t set_pwm_enable1(struct device *dev, const char *buf,
+static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr, const char *buf,
                                size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
index bb1fefb2162ecccf67c1447852f84ccf5024c64d..4ae15bd5dcfb360214b86596db736e95aed21227 100644 (file)
@@ -137,7 +137,7 @@ static void ds1621_init_client(struct i2c_client *client)
 }
 
 #define show(value)                                                    \
-static ssize_t show_##value(struct device *dev, char *buf)             \
+static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf)              \
 {                                                                      \
        struct ds1621_data *data = ds1621_update_client(dev);           \
        return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value));   \
@@ -148,7 +148,7 @@ show(temp_min);
 show(temp_max);
 
 #define set_temp(suffix, value, reg)                                   \
-static ssize_t set_temp_##suffix(struct device *dev, const char *buf,  \
+static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf,   \
                                 size_t count)                          \
 {                                                                      \
        struct i2c_client *client = to_i2c_client(dev);                 \
@@ -165,7 +165,7 @@ static ssize_t set_temp_##suffix(struct device *dev, const char *buf,       \
 set_temp(min, temp_min, DS1621_REG_TEMP_MIN);
 set_temp(max, temp_max, DS1621_REG_TEMP_MAX);
 
-static ssize_t show_alarms(struct device *dev, char *buf)
+static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct ds1621_data *data = ds1621_update_client(dev);
        return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->conf));
index 18e33ac59d0cd5d7fa5e150d0d7eeb28d45c8138..c3f37dbec11a249068742bb10ffb55f26429297f 100644 (file)
@@ -157,8 +157,8 @@ struct fscher_data {
 
 #define sysfs_r(kind, sub, offset, reg) \
 static ssize_t show_##kind##sub (struct fscher_data *, char *, int); \
-static ssize_t show_##kind##offset##sub (struct device *, char *); \
-static ssize_t show_##kind##offset##sub (struct device *dev, char *buf) \
+static ssize_t show_##kind##offset##sub (struct device *, struct device_attribute *attr, char *); \
+static ssize_t show_##kind##offset##sub (struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        struct fscher_data *data = fscher_update_device(dev); \
        return show_##kind##sub(data, buf, (offset)); \
@@ -166,8 +166,8 @@ static ssize_t show_##kind##offset##sub (struct device *dev, char *buf) \
 
 #define sysfs_w(kind, sub, offset, reg) \
 static ssize_t set_##kind##sub (struct i2c_client *, struct fscher_data *, const char *, size_t, int, int); \
-static ssize_t set_##kind##offset##sub (struct device *, const char *, size_t); \
-static ssize_t set_##kind##offset##sub (struct device *dev, const char *buf, size_t count) \
+static ssize_t set_##kind##offset##sub (struct device *, struct device_attribute *attr, const char *, size_t); \
+static ssize_t set_##kind##offset##sub (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
 { \
        struct i2c_client *client = to_i2c_client(dev); \
        struct fscher_data *data = i2c_get_clientdata(client); \
index 2cac79145c7596b12827b02bdfb8cfb7430ed2e8..3beaa6191ef4ca5b6ba926fdc9c864d66d145ccc 100644 (file)
@@ -245,19 +245,19 @@ static void reset_fan_alarm(struct i2c_client *client, int nr)
 /* Volts */
 #define VOLT_FROM_REG(val, mult)       ((val) * (mult) / 255)
 
-static ssize_t show_volt_12(struct device *dev, char *buf)
+static ssize_t show_volt_12(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct fscpos_data *data = fscpos_update_device(dev);
        return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[0], 14200));
 }
 
-static ssize_t show_volt_5(struct device *dev, char *buf)
+static ssize_t show_volt_5(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct fscpos_data *data = fscpos_update_device(dev);
        return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[1], 6600));
 }
 
-static ssize_t show_volt_batt(struct device *dev, char *buf)
+static ssize_t show_volt_batt(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct fscpos_data *data = fscpos_update_device(dev);
        return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[2], 3300));
@@ -327,7 +327,7 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data
 }
 
 /* Event */
-static ssize_t show_event(struct device *dev, char *buf)
+static ssize_t show_event(struct device *dev, struct device_attribute *attr, char *buf)
 {
        /* bits 5..7 reserved => mask with 0x1f */
        struct fscpos_data *data = fscpos_update_device(dev);
@@ -338,14 +338,14 @@ static ssize_t show_event(struct device *dev, char *buf)
  * Sysfs stuff
  */
 #define create_getter(kind, sub) \
-       static ssize_t sysfs_show_##kind##sub(struct device *dev, char *buf) \
+       static ssize_t sysfs_show_##kind##sub(struct device *dev, struct device_attribute *attr, char *buf) \
        { \
                struct fscpos_data *data = fscpos_update_device(dev); \
                return show_##kind##sub(data, buf); \
        }
 
 #define create_getter_n(kind, offset, sub) \
-       static ssize_t sysfs_show_##kind##offset##sub(struct device *dev, char\
+       static ssize_t sysfs_show_##kind##offset##sub(struct device *dev, struct device_attribute *attr, char\
                                                                        *buf) \
        { \
                struct fscpos_data *data = fscpos_update_device(dev); \
@@ -353,7 +353,7 @@ static ssize_t show_event(struct device *dev, char *buf)
        }
 
 #define create_setter(kind, sub, reg) \
-       static ssize_t sysfs_set_##kind##sub (struct device *dev, const char \
+       static ssize_t sysfs_set_##kind##sub (struct device *dev, struct device_attribute *attr, const char \
                                                        *buf, size_t count) \
        { \
                struct i2c_client *client = to_i2c_client(dev); \
@@ -362,7 +362,7 @@ static ssize_t show_event(struct device *dev, char *buf)
        }
 
 #define create_setter_n(kind, offset, sub, reg) \
-       static ssize_t sysfs_set_##kind##offset##sub (struct device *dev, \
+       static ssize_t sysfs_set_##kind##offset##sub (struct device *dev, struct device_attribute *attr, \
                                        const char *buf, size_t count) \
        { \
                struct i2c_client *client = to_i2c_client(dev); \
index c82d6ce2120552be7e869e074747555c9db16de6..4316a15622517af2c89a1354ff3ca80dce6f749a 100644 (file)
@@ -164,14 +164,14 @@ static struct i2c_driver gl518_driver = {
  */
 
 #define show(type, suffix, value)                                      \
-static ssize_t show_##suffix(struct device *dev, char *buf)            \
+static ssize_t show_##suffix(struct device *dev, struct device_attribute *attr, char *buf)             \
 {                                                                      \
        struct gl518_data *data = gl518_update_device(dev);             \
        return sprintf(buf, "%d\n", type##_FROM_REG(data->value));      \
 }
 
 #define show_fan(suffix, value, index)                                 \
-static ssize_t show_##suffix(struct device *dev, char *buf)            \
+static ssize_t show_##suffix(struct device *dev, struct device_attribute *attr, char *buf)             \
 {                                                                      \
        struct gl518_data *data = gl518_update_device(dev);             \
        return sprintf(buf, "%d\n", FAN_FROM_REG(data->value[index],    \
@@ -205,7 +205,7 @@ show(BOOL, beep_enable, beep_enable);
 show(BEEP_MASK, beep_mask, beep_mask);
 
 #define set(type, suffix, value, reg)                                  \
-static ssize_t set_##suffix(struct device *dev, const char *buf,       \
+static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, const char *buf,        \
        size_t count)                                                   \
 {                                                                      \
        struct i2c_client *client = to_i2c_client(dev);                 \
@@ -220,7 +220,7 @@ static ssize_t set_##suffix(struct device *dev, const char *buf,    \
 }
 
 #define set_bits(type, suffix, value, reg, mask, shift)                        \
-static ssize_t set_##suffix(struct device *dev, const char *buf,       \
+static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, const char *buf,        \
        size_t count)                                                   \
 {                                                                      \
        struct i2c_client *client = to_i2c_client(dev);                 \
@@ -258,7 +258,7 @@ set_high(IN, in_max3, voltage_max[3], GL518_REG_VIN3_LIMIT);
 set_bits(BOOL, beep_enable, beep_enable, GL518_REG_CONF, 0x04, 2);
 set(BEEP_MASK, beep_mask, beep_mask, GL518_REG_ALARM);
 
-static ssize_t set_fan_min1(struct device *dev, const char *buf, size_t count)
+static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
        struct gl518_data *data = i2c_get_clientdata(client);
@@ -284,7 +284,7 @@ static ssize_t set_fan_min1(struct device *dev, const char *buf, size_t count)
        return count;
 }
 
-static ssize_t set_fan_min2(struct device *dev, const char *buf, size_t count)
+static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        struct i2c_client *client = to_i2c_client(dev);
        struct gl518_data *data = i2c_get_clientdata(client);
index 3fd17e46ffc6d4dbd0195c1441afd9e1b3061b6c..a13a504f5bfa621fe4b2977f0ea9b2e3a2d33e7f 100644 (file)
@@ -148,8 +148,8 @@ struct gl520_data {
 
 #define sysfs_r(type, n, item, reg) \
 static ssize_t get_##type##item (struct gl520_data *, char *, int); \
-static ssize_t get_##type##n##item (struct device *, char *); \
-static ssize_t get_##type##n##item (struct device *dev, char *buf) \
+static ssize_t get_##type##n##item (struct device *, struct device_attribute *attr, char *); \
+static ssize_t get_##type##n##item (struct device *dev, struct device_attribute *attr, char *buf) \
 { \
        struct gl520_data *data = gl520_update_device(dev); \
        return get_##type##item(data, buf, (n)); \
@@ -157,8 +157,8 @@ static ssize_t get_##type##n##item (struct device *dev, char *buf) \
 
 #define sysfs_w(type, n, item, reg) \
 static ssize_t set_##type##item (struct i2c_client *, struct gl520_data *, const char *, size_t, int, int); \
-static ssize_t set_##type##n##item (struct device *, const char *, size_t); \
-static ssize_t set_##type##n##item (struct device *dev, const char *buf, size_t count) \
+static ssize_t set_##type##n##item (struct device *, struct device_attribute *attr, const char *, size_t); \
+static ssize_t set_##type##n##item (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
 { \
        struct i2c_client *client = to_i2c_client(dev); \
        struct gl520_data *data = i2c_get_clientdata(client); \
index cf7e6898754f6dffe9a0bad6b77230f2922a37c9..007bdf9e7e2afdc8775e38dba804ad9ec9db9e5b 100644 (file)
@@ -290,7 +290,7 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
 
 #define show_in_offset(offset)                                 \
 static ssize_t                                                 \
-       show_in##offset (struct device *dev, char *buf)         \
+       show_in##offset (struct device *dev, struct device_attribute *attr, char *buf)          \
 {                                                              \
        return show_in(dev, buf, offset);                       \
 }                                                              \
@@ -298,21 +298,21 @@ static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);
 
 #define limit_in_offset(offset)                                        \
 static ssize_t                                                 \
-       show_in##offset##_min (struct device *dev, char *buf)   \
+       show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf)    \
 {                                                              \
        return show_in_min(dev, buf, offset);                   \
 }                                                              \
 static ssize_t                                                 \
-       show_in##offset##_max (struct device *dev, char *buf)   \
+       show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf)    \
 {                                                              \
        return show_in_max(dev, buf, offset);                   \
 }                                                              \
-static ssize_t set_in##offset##_min (struct device *dev,       \
+static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr,        \
                const char *buf, size_t count)                  \
 {                                                              \
        return set_in_min(dev, buf, count, offset);             \
 }                                                              \
-static ssize_t set_in##offset##_max (struct device *dev,       \
+static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr,        \
                        const char *buf, size_t count)          \
 {                                                              \
        return set_in_max(dev, buf, count, offset);             \
@@ -383,26 +383,26 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
        return count;
 }
 #define show_temp_offset(offset)                                       \
-static ssize_t show_temp_##offset (struct device *dev, char *buf)      \
+static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf)       \
 {                                                                      \
        return show_temp(dev, buf, offset - 1);                         \
 }                                                                      \
 static ssize_t                                                         \
-show_temp_##offset##_max (struct device *dev, char *buf)               \
+show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf)                \
 {                                                                      \
        return show_temp_max(dev, buf, offset - 1);                     \
 }                                                                      \
 static ssize_t                                                         \
-show_temp_##offset##_min (struct device *dev, char *buf)               \
+show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf)                \
 {                                                                      \
        return show_temp_min(dev, buf, offset - 1);                     \
 }                                                                      \
-static ssize_t set_temp_##offset##_max (struct device *dev,            \
+static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr,             \
                const char *buf, size_t count)                          \
 {                                                                      \
        return set_temp_max(dev, buf, count, offset - 1);               \
 }                                                                      \
-static ssize_t set_temp_##offset##_min (struct device *dev,            \
+static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr,             \
                const char *buf, size_t count)                          \
 {                                                                      \
        return set_temp_min(dev, buf, count, offset - 1);               \
@@ -453,11 +453,11 @@ static ssize_t set_sensor(struct device *dev, const char *buf,
        return count;
 }
 #define show_sensor_offset(offset)                                     \
-static ssize_t show_sensor_##offset (struct device *dev, char *buf)    \
+static ssize_t show_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf)     \
 {                                                                      \
        return show_sensor(dev, buf, offset - 1);                       \
 }                                                                      \
-static ssize_t set_sensor_##offset (struct device *dev,                \
+static ssize_t set_sensor_##offset (struct device *dev, struct device_attribute *attr,                 \
                const char *buf, size_t count)                          \
 {                                                                      \
        return set_sensor(dev, buf, count, offset - 1);                 \
@@ -600,24 +600,24 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
 }
 
 #define show_fan_offset(offset)                                     &nb