Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6: (36 commits)
SCSI: convert struct class_device to struct device
DRM: remove unused dev_class
IB: rename "dev" to "srp_dev" in srp_host structure
IB: convert struct class_device to struct device
memstick: convert struct class_device to struct device
driver core: replace remaining __FUNCTION__ occurrences
sysfs: refill attribute buffer when reading from offset 0
PM: Remove destroy_suspended_device()
Firmware: add iSCSI iBFT Support
PM: Remove legacy PM (fix)
Kobject: Replace list_for_each() with list_for_each_entry().
SYSFS: Explicitly include required header file slab.h.
Driver core: make device_is_registered() work for class devices
PM: Convert wakeup flag accessors to inline functions
PM: Make wakeup flags available whenever CONFIG_PM is set
PM: Fix misuse of wakeup flag accessors in serial core
Driver core: Call device_pm_add() after bus_add_device() in device_add()
PM: Handle device registrations during suspend/resume
block: send disk "change" event for rescan_partitions()
sysdev: detect multiple driver registrations
...

Fixed trivial conflict in include/linux/memory.h due to semaphore header
file change (made irrelevant by the change to mutex).

+3872 -2315
+23
Documentation/ABI/testing/sysfs-ibft
··· 1 + What: /sys/firmware/ibft/initiator 2 + Date: November 2007 3 + Contact: Konrad Rzeszutek <ketuzsezr@darnok.org> 4 + Description: The /sys/firmware/ibft/initiator directory will contain 5 + files that expose the iSCSI Boot Firmware Table initiator data. 6 + Usually this contains the Initiator name. 7 + 8 + What: /sys/firmware/ibft/targetX 9 + Date: November 2007 10 + Contact: Konrad Rzeszutek <ketuzsezr@darnok.org> 11 + Description: The /sys/firmware/ibft/targetX directory will contain 12 + files that expose the iSCSI Boot Firmware Table target data. 13 + Usually this contains the target's IP address, boot LUN, 14 + target name, and what NIC it is associated with. It can also 15 + contain the CHAP name (and password), the reverse CHAP 16 + name (and password) 17 + 18 + What: /sys/firmware/ibft/ethernetX 19 + Date: November 2007 20 + Contact: Konrad Rzeszutek <ketuzsezr@darnok.org> 21 + Description: The /sys/firmware/ibft/ethernetX directory will contain 22 + files that expose the iSCSI Boot Firmware Table NIC data. 23 + This can this can the IP address, MAC, and gateway of the NIC.
-5
Documentation/DocBook/kernel-api.tmpl
··· 297 297 !Ikernel/acct.c 298 298 </chapter> 299 299 300 - <chapter id="pmfuncs"> 301 - <title>Power Management</title> 302 - !Ekernel/power/pm.c 303 - </chapter> 304 - 305 300 <chapter id="devdrivers"> 306 301 <title>Device drivers infrastructure</title> 307 302 <sect1><title>Device Drivers Base</title>
+7 -2
Documentation/filesystems/sysfs.txt
··· 176 176 Recall that an attribute should only be exporting one value, or an 177 177 array of similar values, so this shouldn't be that expensive. 178 178 179 - This allows userspace to do partial reads and seeks arbitrarily over 180 - the entire file at will. 179 + This allows userspace to do partial reads and forward seeks 180 + arbitrarily over the entire file at will. If userspace seeks back to 181 + zero or does a pread(2) with an offset of '0' the show() method will 182 + be called again, rearmed, to fill the buffer. 181 183 182 184 - On write(2), sysfs expects the entire buffer to be passed during the 183 185 first write. Sysfs then passes the entire buffer to the store() ··· 193 191 buffer when reading and writing values. 194 192 195 193 Other notes: 194 + 195 + - Writing causes the show() method to be rearmed regardless of current 196 + file position. 196 197 197 198 - The buffer will always be PAGE_SIZE bytes in length. On i386, this 198 199 is 4096.
+27 -22
Documentation/firmware_class/firmware_sample_driver.c samples/firmware_class/firmware_sample_driver.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/device.h> 14 14 #include <linux/string.h> 15 - 16 - #include "linux/firmware.h" 15 + #include <linux/firmware.h> 17 16 18 17 static struct device ghost_device = { 19 18 .bus_id = "ghost0", ··· 30 31 static void sample_probe_default(void) 31 32 { 32 33 /* uses the default method to get the firmware */ 33 - const struct firmware *fw_entry; 34 - printk(KERN_INFO "firmware_sample_driver: a ghost device got inserted :)\n"); 34 + const struct firmware *fw_entry; 35 + int retval; 35 36 36 - if(request_firmware(&fw_entry, "sample_driver_fw", &ghost_device)!=0) 37 - { 37 + printk(KERN_INFO "firmware_sample_driver: " 38 + "a ghost device got inserted :)\n"); 39 + 40 + retval = request_firmware(&fw_entry, "sample_driver_fw", &ghost_device); 41 + if (retval) { 38 42 printk(KERN_ERR 39 43 "firmware_sample_driver: Firmware not available\n"); 40 44 return; 41 45 } 42 - 46 + 43 47 sample_firmware_load(fw_entry->data, fw_entry->size); 44 48 45 49 release_firmware(fw_entry); 46 50 47 51 /* finish setting up the device */ 48 52 } 53 + 49 54 static void sample_probe_specific(void) 50 55 { 56 + int retval; 51 57 /* Uses some specific hotplug support to get the firmware from 52 58 * userspace directly into the hardware, or via some sysfs file */ 53 59 54 60 /* NOTE: This currently doesn't work */ 55 61 56 - printk(KERN_INFO "firmware_sample_driver: a ghost device got inserted :)\n"); 62 + printk(KERN_INFO "firmware_sample_driver: " 63 + "a ghost device got inserted :)\n"); 57 64 58 - if(request_firmware(NULL, "sample_driver_fw", &ghost_device)!=0) 59 - { 65 + retval = request_firmware(NULL, "sample_driver_fw", &ghost_device); 66 + if (retval) { 60 67 printk(KERN_ERR 61 68 "firmware_sample_driver: Firmware load failed\n"); 62 69 return; 63 70 } 64 - 71 + 65 72 /* request_firmware blocks until userspace finished, so at 66 73 * this point the firmware should be already in the device */ 67 74 ··· 75 70 } 76 71 static void sample_probe_async_cont(const struct firmware *fw, void *context) 77 72 { 78 - if(!fw){ 73 + if (!fw) { 79 74 printk(KERN_ERR 80 75 "firmware_sample_driver: firmware load failed\n"); 81 76 return; ··· 85 80 (char *)context); 86 81 sample_firmware_load(fw->data, fw->size); 87 82 } 83 + 88 84 static void sample_probe_async(void) 89 85 { 90 86 /* Let's say that I can't sleep */ 91 87 int error; 92 - error = request_firmware_nowait (THIS_MODULE, FW_ACTION_NOHOTPLUG, 93 - "sample_driver_fw", &ghost_device, 94 - "my device pointer", 95 - sample_probe_async_cont); 96 - if(error){ 97 - printk(KERN_ERR 98 - "firmware_sample_driver:" 88 + error = request_firmware_nowait(THIS_MODULE, FW_ACTION_NOHOTPLUG, 89 + "sample_driver_fw", &ghost_device, 90 + "my device pointer", 91 + sample_probe_async_cont); 92 + if (error) 93 + printk(KERN_ERR "firmware_sample_driver:" 99 94 " request_firmware_nowait failed\n"); 100 - } 101 95 } 102 96 103 97 static int sample_init(void) ··· 109 105 sample_probe_async(); 110 106 return 0; 111 107 } 108 + 112 109 static void __exit sample_exit(void) 113 110 { 114 111 } 115 112 116 - module_init (sample_init); 117 - module_exit (sample_exit); 113 + module_init(sample_init); 114 + module_exit(sample_exit); 118 115 119 116 MODULE_LICENSE("GPL");
+18 -21
Documentation/firmware_class/firmware_sample_firmware_class.c samples/firmware_class/firmware_sample_firmware_class.c
··· 25 25 26 26 static inline struct class_device *to_class_dev(struct kobject *obj) 27 27 { 28 - return container_of(obj,struct class_device,kobj); 28 + return container_of(obj, struct class_device, kobj); 29 29 } 30 + 30 31 static inline 31 32 struct class_device_attribute *to_class_dev_attr(struct attribute *_attr) 32 33 { 33 - return container_of(_attr,struct class_device_attribute,attr); 34 + return container_of(_attr, struct class_device_attribute, attr); 34 35 } 35 - 36 - int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr); 37 - int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr); 38 36 39 37 struct firmware_priv { 40 38 char fw_id[FIRMWARE_NAME_MAX]; ··· 40 42 u32 abort:1; 41 43 }; 42 44 43 - extern struct class firmware_class; 44 - 45 45 static ssize_t firmware_loading_show(struct class_device *class_dev, char *buf) 46 46 { 47 47 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 48 48 return sprintf(buf, "%d\n", fw_priv->loading); 49 49 } 50 + 50 51 static ssize_t firmware_loading_store(struct class_device *class_dev, 51 52 const char *buf, size_t count) 52 53 { ··· 53 56 int prev_loading = fw_priv->loading; 54 57 55 58 fw_priv->loading = simple_strtol(buf, NULL, 10); 56 - 57 - switch(fw_priv->loading){ 59 + 60 + switch (fw_priv->loading) { 58 61 case -1: 59 62 /* abort load an panic */ 60 63 break; ··· 62 65 /* setup load */ 63 66 break; 64 67 case 0: 65 - if(prev_loading==1){ 68 + if (prev_loading == 1) { 66 69 /* finish load and get the device back to working 67 70 * state */ 68 71 } ··· 127 130 class_dev->class = &firmware_class, 128 131 class_set_devdata(class_dev, fw_priv); 129 132 retval = class_device_register(class_dev); 130 - if (retval){ 133 + if (retval) { 131 134 printk(KERN_ERR "%s: class_device_register failed\n", 132 - __FUNCTION__); 135 + __func__); 133 136 goto error_free_fw_priv; 134 137 } 135 138 136 139 retval = sysfs_create_bin_file(&class_dev->kobj, &firmware_attr_data); 137 - if (retval){ 140 + if (retval) { 138 141 printk(KERN_ERR "%s: sysfs_create_bin_file failed\n", 139 - __FUNCTION__); 142 + __func__); 140 143 goto error_unreg_class_dev; 141 144 } 142 145 143 146 retval = class_device_create_file(class_dev, 144 147 &class_device_attr_loading); 145 - if (retval){ 148 + if (retval) { 146 149 printk(KERN_ERR "%s: class_device_create_file failed\n", 147 - __FUNCTION__); 150 + __func__); 148 151 goto error_remove_data; 149 152 } 150 153 151 154 goto out; 152 - 155 + 153 156 error_remove_data: 154 157 sysfs_remove_bin_file(&class_dev->kobj, &firmware_attr_data); 155 158 error_unreg_class_dev: ··· 180 183 181 184 device_initialize(&my_device); 182 185 class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL); 183 - if(!class_dev) 186 + if (!class_dev) 184 187 return -ENOMEM; 185 188 186 189 error = fw_setup_class_device(class_dev, "my_firmware_image", 187 190 &my_device); 188 - if(error){ 191 + if (error) { 189 192 kfree(class_dev); 190 193 return error; 191 194 } 192 - return 0; 195 + return 0; 193 196 194 197 } 195 198 static void __exit firmware_sample_exit(void) ··· 199 202 kfree(fw_priv); 200 203 kfree(class_dev); 201 204 } 205 + 202 206 module_init(firmware_sample_init); 203 207 module_exit(firmware_sample_exit); 204 -
+5
Documentation/power/devices.txt
··· 196 196 197 197 The policy is that the device tree should match hardware bus topology. 198 198 (Or at least the control bus, for devices which use multiple busses.) 199 + In particular, this means that a device registration may fail if the parent of 200 + the device is suspending (ie. has been chosen by the PM core as the next 201 + device to suspend) or has already suspended, as well as after all of the other 202 + devices have been suspended. Device drivers must be prepared to cope with such 203 + situations. 199 204 200 205 201 206 Suspending Devices
+5
MAINTAINERS
··· 3610 3610 L: lm-sensors@lm-sensors.org 3611 3611 S: Maintained 3612 3612 3613 + SMX UIO Interface 3614 + P: Ben Nizette 3615 + M: bn@niasdigital.com 3616 + S: Maintained 3617 + 3613 3618 SOFTWARE RAID (Multiple Disks) SUPPORT 3614 3619 P: Ingo Molnar 3615 3620 M: mingo@redhat.com
+2
arch/arm/Kconfig
··· 1192 1192 1193 1193 source "drivers/dca/Kconfig" 1194 1194 1195 + source "drivers/uio/Kconfig" 1196 + 1195 1197 endmenu 1196 1198 1197 1199 source "fs/Kconfig"
+1 -3
arch/x86/kernel/cpuid.c
··· 154 154 err = cpuid_device_create(cpu); 155 155 break; 156 156 case CPU_UP_CANCELED: 157 + case CPU_UP_CANCELED_FROZEN: 157 158 case CPU_DEAD: 158 159 cpuid_device_destroy(cpu); 159 - break; 160 - case CPU_UP_CANCELED_FROZEN: 161 - destroy_suspended_device(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); 162 160 break; 163 161 } 164 162 return err ? NOTIFY_BAD : NOTIFY_OK;
+1 -3
arch/x86/kernel/msr.c
··· 162 162 err = msr_device_create(cpu); 163 163 break; 164 164 case CPU_UP_CANCELED: 165 + case CPU_UP_CANCELED_FROZEN: 165 166 case CPU_DEAD: 166 167 msr_device_destroy(cpu); 167 - break; 168 - case CPU_UP_CANCELED_FROZEN: 169 - destroy_suspended_device(msr_class, MKDEV(MSR_MAJOR, cpu)); 170 168 break; 171 169 } 172 170 return err ? NOTIFY_BAD : NOTIFY_OK;
+3
arch/x86/kernel/setup_32.c
··· 39 39 #include <linux/efi.h> 40 40 #include <linux/init.h> 41 41 #include <linux/edd.h> 42 + #include <linux/iscsi_ibft.h> 42 43 #include <linux/nodemask.h> 43 44 #include <linux/kexec.h> 44 45 #include <linux/crash_dump.h> ··· 690 689 #endif 691 690 numa_kva_reserve(); 692 691 reserve_crashkernel(); 692 + 693 + reserve_ibft_region(); 693 694 } 694 695 695 696 /*
+4
arch/x86/kernel/setup_64.c
··· 33 33 #include <linux/acpi.h> 34 34 #include <linux/kallsyms.h> 35 35 #include <linux/edd.h> 36 + #include <linux/iscsi_ibft.h> 36 37 #include <linux/mmzone.h> 37 38 #include <linux/kexec.h> 38 39 #include <linux/cpufreq.h> ··· 440 439 } 441 440 #endif 442 441 reserve_crashkernel(); 442 + 443 + reserve_ibft_region(); 444 + 443 445 paging_init(); 444 446 map_vsyscall(); 445 447
+5 -6
block/bsg.c
··· 758 758 mutex_lock(&bsg_mutex); 759 759 hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode))); 760 760 761 - strncpy(bd->name, rq->bsg_dev.class_dev->class_id, sizeof(bd->name) - 1); 761 + strncpy(bd->name, rq->bsg_dev.class_dev->bus_id, sizeof(bd->name) - 1); 762 762 dprintk("bound to <%s>, max queue %d\n", 763 763 format_dev_t(buf, inode->i_rdev), bd->max_queue); 764 764 ··· 946 946 mutex_lock(&bsg_mutex); 947 947 idr_remove(&bsg_minor_idr, bcd->minor); 948 948 sysfs_remove_link(&q->kobj, "bsg"); 949 - class_device_unregister(bcd->class_dev); 949 + device_unregister(bcd->class_dev); 950 950 put_device(bcd->dev); 951 951 bcd->class_dev = NULL; 952 952 mutex_unlock(&bsg_mutex); ··· 959 959 struct bsg_class_device *bcd; 960 960 dev_t dev; 961 961 int ret, minor; 962 - struct class_device *class_dev = NULL; 962 + struct device *class_dev = NULL; 963 963 const char *devname; 964 964 965 965 if (name) ··· 998 998 bcd->queue = q; 999 999 bcd->dev = get_device(gdev); 1000 1000 dev = MKDEV(bsg_major, bcd->minor); 1001 - class_dev = class_device_create(bsg_class, NULL, dev, gdev, "%s", 1002 - devname); 1001 + class_dev = device_create(bsg_class, gdev, dev, "%s", devname); 1003 1002 if (IS_ERR(class_dev)) { 1004 1003 ret = PTR_ERR(class_dev); 1005 1004 goto put_dev; ··· 1015 1016 return 0; 1016 1017 1017 1018 unregister_class_dev: 1018 - class_device_unregister(class_dev); 1019 + device_unregister(class_dev); 1019 1020 put_dev: 1020 1021 put_device(gdev); 1021 1022 remove_idr:
+2 -2
drivers/ata/ahci.c
··· 273 273 static int ahci_pci_device_resume(struct pci_dev *pdev); 274 274 #endif 275 275 276 - static struct class_device_attribute *ahci_shost_attrs[] = { 277 - &class_device_attr_link_power_management_policy, 276 + static struct device_attribute *ahci_shost_attrs[] = { 277 + &dev_attr_link_power_management_policy, 278 278 NULL 279 279 }; 280 280
+8 -7
drivers/ata/libata-scsi.c
··· 131 131 return NULL; 132 132 } 133 133 134 - static ssize_t ata_scsi_lpm_put(struct class_device *class_dev, 135 - const char *buf, size_t count) 134 + static ssize_t ata_scsi_lpm_put(struct device *dev, 135 + struct device_attribute *attr, 136 + const char *buf, size_t count) 136 137 { 137 - struct Scsi_Host *shost = class_to_shost(class_dev); 138 + struct Scsi_Host *shost = class_to_shost(dev); 138 139 struct ata_port *ap = ata_shost_to_port(shost); 139 140 enum link_pm policy = 0; 140 141 int i; ··· 163 162 } 164 163 165 164 static ssize_t 166 - ata_scsi_lpm_show(struct class_device *class_dev, char *buf) 165 + ata_scsi_lpm_show(struct device *dev, struct device_attribute *attr, char *buf) 167 166 { 168 - struct Scsi_Host *shost = class_to_shost(class_dev); 167 + struct Scsi_Host *shost = class_to_shost(dev); 169 168 struct ata_port *ap = ata_shost_to_port(shost); 170 169 const char *policy = 171 170 ata_scsi_lpm_get(ap->pm_policy); ··· 175 174 176 175 return snprintf(buf, 23, "%s\n", policy); 177 176 } 178 - CLASS_DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, 177 + DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, 179 178 ata_scsi_lpm_show, ata_scsi_lpm_put); 180 - EXPORT_SYMBOL_GPL(class_device_attr_link_power_management_policy); 179 + EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy); 181 180 182 181 static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, 183 182 void (*done)(struct scsi_cmnd *))
+38 -39
drivers/base/attribute_container.c
··· 27 27 struct internal_container { 28 28 struct klist_node node; 29 29 struct attribute_container *cont; 30 - struct class_device classdev; 30 + struct device classdev; 31 31 }; 32 32 33 33 static void internal_container_klist_get(struct klist_node *n) 34 34 { 35 35 struct internal_container *ic = 36 36 container_of(n, struct internal_container, node); 37 - class_device_get(&ic->classdev); 37 + get_device(&ic->classdev); 38 38 } 39 39 40 40 static void internal_container_klist_put(struct klist_node *n) 41 41 { 42 42 struct internal_container *ic = 43 43 container_of(n, struct internal_container, node); 44 - class_device_put(&ic->classdev); 44 + put_device(&ic->classdev); 45 45 } 46 46 47 47 ··· 53 53 * Returns the container associated with this classdev. 54 54 */ 55 55 struct attribute_container * 56 - attribute_container_classdev_to_container(struct class_device *classdev) 56 + attribute_container_classdev_to_container(struct device *classdev) 57 57 { 58 58 struct internal_container *ic = 59 59 container_of(classdev, struct internal_container, classdev); ··· 110 110 EXPORT_SYMBOL_GPL(attribute_container_unregister); 111 111 112 112 /* private function used as class release */ 113 - static void attribute_container_release(struct class_device *classdev) 113 + static void attribute_container_release(struct device *classdev) 114 114 { 115 115 struct internal_container *ic 116 116 = container_of(classdev, struct internal_container, classdev); 117 - struct device *dev = classdev->dev; 117 + struct device *dev = classdev->parent; 118 118 119 119 kfree(ic); 120 120 put_device(dev); ··· 129 129 * This function allocates storage for the class device(s) to be 130 130 * attached to dev (one for each matching attribute_container). If no 131 131 * fn is provided, the code will simply register the class device via 132 - * class_device_add. If a function is provided, it is expected to add 132 + * device_add. If a function is provided, it is expected to add 133 133 * the class device at the appropriate time. One of the things that 134 134 * might be necessary is to allocate and initialise the classdev and 135 135 * then add it a later time. To do this, call this routine for 136 136 * allocation and initialisation and then use 137 - * attribute_container_device_trigger() to call class_device_add() on 137 + * attribute_container_device_trigger() to call device_add() on 138 138 * it. Note: after this, the class device contains a reference to dev 139 139 * which is not relinquished until the release of the classdev. 140 140 */ ··· 142 142 attribute_container_add_device(struct device *dev, 143 143 int (*fn)(struct attribute_container *, 144 144 struct device *, 145 - struct class_device *)) 145 + struct device *)) 146 146 { 147 147 struct attribute_container *cont; 148 148 ··· 163 163 } 164 164 165 165 ic->cont = cont; 166 - class_device_initialize(&ic->classdev); 167 - ic->classdev.dev = get_device(dev); 166 + device_initialize(&ic->classdev); 167 + ic->classdev.parent = get_device(dev); 168 168 ic->classdev.class = cont->class; 169 - cont->class->release = attribute_container_release; 170 - strcpy(ic->classdev.class_id, dev->bus_id); 169 + cont->class->dev_release = attribute_container_release; 170 + strcpy(ic->classdev.bus_id, dev->bus_id); 171 171 if (fn) 172 172 fn(cont, dev, &ic->classdev); 173 173 else ··· 195 195 * @fn: A function to call to remove the device 196 196 * 197 197 * This routine triggers device removal. If fn is NULL, then it is 198 - * simply done via class_device_unregister (note that if something 198 + * simply done via device_unregister (note that if something 199 199 * still has a reference to the classdev, then the memory occupied 200 200 * will not be freed until the classdev is released). If you want a 201 201 * two phase release: remove from visibility and then delete the 202 202 * device, then you should use this routine with a fn that calls 203 - * class_device_del() and then use 204 - * attribute_container_device_trigger() to do the final put on the 205 - * classdev. 203 + * device_del() and then use attribute_container_device_trigger() 204 + * to do the final put on the classdev. 206 205 */ 207 206 void 208 207 attribute_container_remove_device(struct device *dev, 209 208 void (*fn)(struct attribute_container *, 210 209 struct device *, 211 - struct class_device *)) 210 + struct device *)) 212 211 { 213 212 struct attribute_container *cont; 214 213 ··· 223 224 continue; 224 225 225 226 klist_for_each_entry(ic, &cont->containers, node, &iter) { 226 - if (dev != ic->classdev.dev) 227 + if (dev != ic->classdev.parent) 227 228 continue; 228 229 klist_del(&ic->node); 229 230 if (fn) 230 231 fn(cont, dev, &ic->classdev); 231 232 else { 232 233 attribute_container_remove_attrs(&ic->classdev); 233 - class_device_unregister(&ic->classdev); 234 + device_unregister(&ic->classdev); 234 235 } 235 236 } 236 237 } ··· 251 252 attribute_container_device_trigger(struct device *dev, 252 253 int (*fn)(struct attribute_container *, 253 254 struct device *, 254 - struct class_device *)) 255 + struct device *)) 255 256 { 256 257 struct attribute_container *cont; 257 258 ··· 269 270 } 270 271 271 272 klist_for_each_entry(ic, &cont->containers, node, &iter) { 272 - if (dev == ic->classdev.dev) 273 + if (dev == ic->classdev.parent) 273 274 fn(cont, dev, &ic->classdev); 274 275 } 275 276 } ··· 312 313 * attributes listed in the container 313 314 */ 314 315 int 315 - attribute_container_add_attrs(struct class_device *classdev) 316 + attribute_container_add_attrs(struct device *classdev) 316 317 { 317 318 struct attribute_container *cont = 318 319 attribute_container_classdev_to_container(classdev); 319 - struct class_device_attribute **attrs = cont->attrs; 320 + struct device_attribute **attrs = cont->attrs; 320 321 int i, error; 321 322 322 323 BUG_ON(attrs && cont->grp); ··· 328 329 return sysfs_create_group(&classdev->kobj, cont->grp); 329 330 330 331 for (i = 0; attrs[i]; i++) { 331 - error = class_device_create_file(classdev, attrs[i]); 332 + error = device_create_file(classdev, attrs[i]); 332 333 if (error) 333 334 return error; 334 335 } ··· 337 338 } 338 339 339 340 /** 340 - * attribute_container_add_class_device - same function as class_device_add 341 + * attribute_container_add_class_device - same function as device_add 341 342 * 342 343 * @classdev: the class device to add 343 344 * 344 - * This performs essentially the same function as class_device_add except for 345 + * This performs essentially the same function as device_add except for 345 346 * attribute containers, namely add the classdev to the system and then 346 347 * create the attribute files 347 348 */ 348 349 int 349 - attribute_container_add_class_device(struct class_device *classdev) 350 + attribute_container_add_class_device(struct device *classdev) 350 351 { 351 - int error = class_device_add(classdev); 352 + int error = device_add(classdev); 352 353 if (error) 353 354 return error; 354 355 return attribute_container_add_attrs(classdev); ··· 363 364 int 364 365 attribute_container_add_class_device_adapter(struct attribute_container *cont, 365 366 struct device *dev, 366 - struct class_device *classdev) 367 + struct device *classdev) 367 368 { 368 369 return attribute_container_add_class_device(classdev); 369 370 } ··· 375 376 * 376 377 */ 377 378 void 378 - attribute_container_remove_attrs(struct class_device *classdev) 379 + attribute_container_remove_attrs(struct device *classdev) 379 380 { 380 381 struct attribute_container *cont = 381 382 attribute_container_classdev_to_container(classdev); 382 - struct class_device_attribute **attrs = cont->attrs; 383 + struct device_attribute **attrs = cont->attrs; 383 384 int i; 384 385 385 386 if (!attrs && !cont->grp) ··· 391 392 } 392 393 393 394 for (i = 0; attrs[i]; i++) 394 - class_device_remove_file(classdev, attrs[i]); 395 + device_remove_file(classdev, attrs[i]); 395 396 } 396 397 397 398 /** ··· 400 401 * @classdev: the class device 401 402 * 402 403 * This function simply removes all the attribute files and then calls 403 - * class_device_del. 404 + * device_del. 404 405 */ 405 406 void 406 - attribute_container_class_device_del(struct class_device *classdev) 407 + attribute_container_class_device_del(struct device *classdev) 407 408 { 408 409 attribute_container_remove_attrs(classdev); 409 - class_device_del(classdev); 410 + device_del(classdev); 410 411 } 411 412 412 413 /** ··· 418 419 * Looks up the device in the container's list of class devices and returns 419 420 * the corresponding class_device. 420 421 */ 421 - struct class_device * 422 + struct device * 422 423 attribute_container_find_class_device(struct attribute_container *cont, 423 424 struct device *dev) 424 425 { 425 - struct class_device *cdev = NULL; 426 + struct device *cdev = NULL; 426 427 struct internal_container *ic; 427 428 struct klist_iter iter; 428 429 429 430 klist_for_each_entry(ic, &cont->containers, node, &iter) { 430 - if (ic->classdev.dev == dev) { 431 + if (ic->classdev.parent == dev) { 431 432 cdev = &ic->classdev; 432 433 /* FIXME: must exit iterator then break */ 433 434 klist_iter_exit(&iter);
+6 -11
drivers/base/bus.c
··· 79 79 { 80 80 struct driver_private *drv_priv = to_driver(kobj); 81 81 82 - pr_debug("driver: '%s': %s\n", kobject_name(kobj), __FUNCTION__); 82 + pr_debug("driver: '%s': %s\n", kobject_name(kobj), __func__); 83 83 kfree(drv_priv); 84 84 } 85 85 ··· 505 505 int ret = 0; 506 506 507 507 if (bus) { 508 - dev->is_registered = 1; 509 508 if (bus->p->drivers_autoprobe) 510 509 ret = device_attach(dev); 511 510 WARN_ON(ret < 0); 512 511 if (ret >= 0) 513 512 klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); 514 - else 515 - dev->is_registered = 0; 516 513 } 517 514 } 518 515 ··· 530 533 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, 531 534 dev->bus_id); 532 535 device_remove_attrs(dev->bus, dev); 533 - if (dev->is_registered) { 534 - dev->is_registered = 0; 535 - klist_del(&dev->knode_bus); 536 - } 536 + klist_del(&dev->knode_bus); 537 + 537 538 pr_debug("bus: '%s': remove device %s\n", 538 539 dev->bus->name, dev->bus_id); 539 540 device_release_driver(dev); ··· 677 682 error = driver_create_file(drv, &driver_attr_uevent); 678 683 if (error) { 679 684 printk(KERN_ERR "%s: uevent attr (%s) failed\n", 680 - __FUNCTION__, drv->name); 685 + __func__, drv->name); 681 686 } 682 687 error = driver_add_attrs(bus, drv); 683 688 if (error) { 684 689 /* How the hell do we get out of this pickle? Give up */ 685 690 printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n", 686 - __FUNCTION__, drv->name); 691 + __func__, drv->name); 687 692 } 688 693 error = add_bind_files(drv); 689 694 if (error) { 690 695 /* Ditto */ 691 696 printk(KERN_ERR "%s: add_bind_files(%s) failed\n", 692 - __FUNCTION__, drv->name); 697 + __func__, drv->name); 693 698 } 694 699 695 700 kobject_uevent(&priv->kobj, KOBJ_ADD);
+4 -4
drivers/base/class.c
··· 175 175 176 176 static void class_create_release(struct class *cls) 177 177 { 178 - pr_debug("%s called for %s\n", __FUNCTION__, cls->name); 178 + pr_debug("%s called for %s\n", __func__, cls->name); 179 179 kfree(cls); 180 180 } 181 181 182 182 static void class_device_create_release(struct class_device *class_dev) 183 183 { 184 - pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); 184 + pr_debug("%s called for %s\n", __func__, class_dev->class_id); 185 185 kfree(class_dev); 186 186 } 187 187 ··· 189 189 static int class_device_create_uevent(struct class_device *class_dev, 190 190 struct kobj_uevent_env *env) 191 191 { 192 - pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); 192 + pr_debug("%s called for %s\n", __func__, class_dev->class_id); 193 193 return 0; 194 194 } 195 195 ··· 415 415 struct device *dev = class_dev->dev; 416 416 int retval = 0; 417 417 418 - pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id); 418 + pr_debug("%s - name = %s\n", __func__, class_dev->class_id); 419 419 420 420 if (MAJOR(class_dev->devt)) { 421 421 add_uevent_var(env, "MAJOR=%u", MAJOR(class_dev->devt));
+14 -44
drivers/base/core.c
··· 207 207 retval = dev->bus->uevent(dev, env); 208 208 if (retval) 209 209 pr_debug("device: '%s': %s: bus uevent() returned %d\n", 210 - dev->bus_id, __FUNCTION__, retval); 210 + dev->bus_id, __func__, retval); 211 211 } 212 212 213 213 /* have the class specific function add its stuff */ ··· 216 216 if (retval) 217 217 pr_debug("device: '%s': %s: class uevent() " 218 218 "returned %d\n", dev->bus_id, 219 - __FUNCTION__, retval); 219 + __func__, retval); 220 220 } 221 221 222 222 /* have the device type specific fuction add its stuff */ ··· 225 225 if (retval) 226 226 pr_debug("device: '%s': %s: dev_type uevent() " 227 227 "returned %d\n", dev->bus_id, 228 - __FUNCTION__, retval); 228 + __func__, retval); 229 229 } 230 230 231 231 return retval; ··· 782 782 goto Done; 783 783 } 784 784 785 - pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); 785 + pr_debug("device: '%s': %s\n", dev->bus_id, __func__); 786 786 787 787 parent = get_device(dev->parent); 788 788 setup_parent(dev, parent); ··· 817 817 error = device_add_attrs(dev); 818 818 if (error) 819 819 goto AttrsError; 820 - error = dpm_sysfs_add(dev); 821 - if (error) 822 - goto PMError; 823 - device_pm_add(dev); 824 820 error = bus_add_device(dev); 825 821 if (error) 826 822 goto BusError; 823 + error = device_pm_add(dev); 824 + if (error) 825 + goto PMError; 827 826 kobject_uevent(&dev->kobj, KOBJ_ADD); 828 827 bus_attach_device(dev); 829 828 if (parent) ··· 842 843 Done: 843 844 put_device(dev); 844 845 return error; 845 - BusError: 846 - device_pm_remove(dev); 847 846 PMError: 847 + bus_remove_device(dev); 848 + BusError: 848 849 if (dev->bus) 849 850 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 850 851 BUS_NOTIFY_DEL_DEVICE, dev); ··· 980 981 */ 981 982 void device_unregister(struct device *dev) 982 983 { 983 - pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); 984 + pr_debug("device: '%s': %s\n", dev->bus_id, __func__); 984 985 device_del(dev); 985 986 put_device(dev); 986 987 } ··· 1075 1076 1076 1077 static void device_create_release(struct device *dev) 1077 1078 { 1078 - pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); 1079 + pr_debug("device: '%s': %s\n", dev->bus_id, __func__); 1079 1080 kfree(dev); 1080 1081 } 1081 1082 ··· 1163 1164 } 1164 1165 EXPORT_SYMBOL_GPL(device_destroy); 1165 1166 1166 - #ifdef CONFIG_PM_SLEEP 1167 - /** 1168 - * destroy_suspended_device - asks the PM core to remove a suspended device 1169 - * @class: pointer to the struct class that this device was registered with 1170 - * @devt: the dev_t of the device that was previously registered 1171 - * 1172 - * This call notifies the PM core of the necessity to unregister a suspended 1173 - * device created with a call to device_create() (devices cannot be 1174 - * unregistered directly while suspended, since the PM core holds their 1175 - * semaphores at that time). 1176 - * 1177 - * It can only be called within the scope of a system sleep transition. In 1178 - * practice this means it has to be directly or indirectly invoked either by 1179 - * a suspend or resume method, or by the PM core (e.g. via 1180 - * disable_nonboot_cpus() or enable_nonboot_cpus()). 1181 - */ 1182 - void destroy_suspended_device(struct class *class, dev_t devt) 1183 - { 1184 - struct device *dev; 1185 - 1186 - dev = class_find_device(class, &devt, __match_devt); 1187 - if (dev) { 1188 - device_pm_schedule_removal(dev); 1189 - put_device(dev); 1190 - } 1191 - } 1192 - EXPORT_SYMBOL_GPL(destroy_suspended_device); 1193 - #endif /* CONFIG_PM_SLEEP */ 1194 - 1195 1167 /** 1196 1168 * device_rename - renames a device 1197 1169 * @dev: the pointer to the struct device to be renamed ··· 1180 1210 return -EINVAL; 1181 1211 1182 1212 pr_debug("device: '%s': %s: renaming to '%s'\n", dev->bus_id, 1183 - __FUNCTION__, new_name); 1213 + __func__, new_name); 1184 1214 1185 1215 #ifdef CONFIG_SYSFS_DEPRECATED 1186 1216 if ((dev->class) && (dev->parent)) ··· 1219 1249 dev->bus_id); 1220 1250 if (error) { 1221 1251 dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n", 1222 - __FUNCTION__, error); 1252 + __func__, error); 1223 1253 } 1224 1254 } 1225 1255 #endif ··· 1295 1325 new_parent_kobj = get_device_parent(dev, new_parent); 1296 1326 1297 1327 pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id, 1298 - __FUNCTION__, new_parent ? new_parent->bus_id : "<NULL>"); 1328 + __func__, new_parent ? new_parent->bus_id : "<NULL>"); 1299 1329 error = kobject_move(&dev->kobj, new_parent_kobj); 1300 1330 if (error) { 1301 1331 cleanup_glue_dir(dev, new_parent_kobj);
+2 -2
drivers/base/cpu.c
··· 28 28 return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); 29 29 } 30 30 31 - static ssize_t store_online(struct sys_device *dev, const char *buf, 31 + static ssize_t __ref store_online(struct sys_device *dev, const char *buf, 32 32 size_t count) 33 33 { 34 34 struct cpu *cpu = container_of(dev, struct cpu, sysdev); ··· 55 55 } 56 56 static SYSDEV_ATTR(online, 0644, show_online, store_online); 57 57 58 - static void __devinit register_cpu_control(struct cpu *cpu) 58 + static void __cpuinit register_cpu_control(struct cpu *cpu) 59 59 { 60 60 sysdev_create_file(&cpu->sysdev, &attr_online); 61 61 }
+7 -7
drivers/base/dd.c
··· 30 30 { 31 31 if (klist_node_attached(&dev->knode_driver)) { 32 32 printk(KERN_WARNING "%s: device %s already bound\n", 33 - __FUNCTION__, kobject_name(&dev->kobj)); 33 + __func__, kobject_name(&dev->kobj)); 34 34 return; 35 35 } 36 36 37 37 pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->bus_id, 38 - __FUNCTION__, dev->driver->name); 38 + __func__, dev->driver->name); 39 39 40 40 if (dev->bus) 41 41 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, ··· 104 104 105 105 atomic_inc(&probe_count); 106 106 pr_debug("bus: '%s': %s: probing driver %s with device %s\n", 107 - drv->bus->name, __FUNCTION__, drv->name, dev->bus_id); 107 + drv->bus->name, __func__, drv->name, dev->bus_id); 108 108 WARN_ON(!list_empty(&dev->devres_head)); 109 109 110 110 dev->driver = drv; 111 111 if (driver_sysfs_add(dev)) { 112 112 printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n", 113 - __FUNCTION__, dev->bus_id); 113 + __func__, dev->bus_id); 114 114 goto probe_failed; 115 115 } 116 116 ··· 127 127 driver_bound(dev); 128 128 ret = 1; 129 129 pr_debug("bus: '%s': %s: bound device %s to driver %s\n", 130 - drv->bus->name, __FUNCTION__, dev->bus_id, drv->name); 130 + drv->bus->name, __func__, dev->bus_id, drv->name); 131 131 goto done; 132 132 133 133 probe_failed: ··· 160 160 */ 161 161 int driver_probe_done(void) 162 162 { 163 - pr_debug("%s: probe_count = %d\n", __FUNCTION__, 163 + pr_debug("%s: probe_count = %d\n", __func__, 164 164 atomic_read(&probe_count)); 165 165 if (atomic_read(&probe_count)) 166 166 return -EBUSY; ··· 194 194 goto done; 195 195 196 196 pr_debug("bus: '%s': %s: matched device %s with driver %s\n", 197 - drv->bus->name, __FUNCTION__, dev->bus_id, drv->name); 197 + drv->bus->name, __func__, dev->bus_id, drv->name); 198 198 199 199 ret = really_probe(dev, drv); 200 200
+9 -9
drivers/base/firmware_class.c
··· 156 156 } 157 157 /* fallthrough */ 158 158 default: 159 - printk(KERN_ERR "%s: unexpected value (%d)\n", __FUNCTION__, 159 + printk(KERN_ERR "%s: unexpected value (%d)\n", __func__, 160 160 loading); 161 161 /* fallthrough */ 162 162 case -1: ··· 209 209 new_size = ALIGN(min_size, PAGE_SIZE); 210 210 new_data = vmalloc(new_size); 211 211 if (!new_data) { 212 - printk(KERN_ERR "%s: unable to alloc buffer\n", __FUNCTION__); 212 + printk(KERN_ERR "%s: unable to alloc buffer\n", __func__); 213 213 /* Make sure that we don't keep incomplete data */ 214 214 fw_load_abort(fw_priv); 215 215 return -ENOMEM; ··· 307 307 *dev_p = NULL; 308 308 309 309 if (!fw_priv || !f_dev) { 310 - printk(KERN_ERR "%s: kmalloc failed\n", __FUNCTION__); 310 + printk(KERN_ERR "%s: kmalloc failed\n", __func__); 311 311 retval = -ENOMEM; 312 312 goto error_kfree; 313 313 } ··· 328 328 retval = device_register(f_dev); 329 329 if (retval) { 330 330 printk(KERN_ERR "%s: device_register failed\n", 331 - __FUNCTION__); 331 + __func__); 332 332 goto error_kfree; 333 333 } 334 334 *dev_p = f_dev; ··· 362 362 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); 363 363 if (retval) { 364 364 printk(KERN_ERR "%s: sysfs_create_bin_file failed\n", 365 - __FUNCTION__); 365 + __func__); 366 366 goto error_unreg; 367 367 } 368 368 369 369 retval = device_create_file(f_dev, &dev_attr_loading); 370 370 if (retval) { 371 371 printk(KERN_ERR "%s: device_create_file failed\n", 372 - __FUNCTION__); 372 + __func__); 373 373 goto error_unreg; 374 374 } 375 375 ··· 399 399 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); 400 400 if (!firmware) { 401 401 printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", 402 - __FUNCTION__); 402 + __func__); 403 403 retval = -ENOMEM; 404 404 goto out; 405 405 } ··· 570 570 int error; 571 571 error = class_register(&firmware_class); 572 572 if (error) { 573 - printk(KERN_ERR "%s: class_register failed\n", __FUNCTION__); 573 + printk(KERN_ERR "%s: class_register failed\n", __func__); 574 574 return error; 575 575 } 576 576 error = class_create_file(&firmware_class, &class_attr_timeout); 577 577 if (error) { 578 578 printk(KERN_ERR "%s: class_create_file failed\n", 579 - __FUNCTION__); 579 + __func__); 580 580 class_unregister(&firmware_class); 581 581 } 582 582 return error;
+13 -20
drivers/base/memory.c
··· 20 20 #include <linux/kobject.h> 21 21 #include <linux/memory_hotplug.h> 22 22 #include <linux/mm.h> 23 + #include <linux/mutex.h> 23 24 #include <asm/atomic.h> 24 25 #include <asm/uaccess.h> 25 26 ··· 62 61 /* 63 62 * register_memory - Setup a sysfs device for a memory block 64 63 */ 65 - int register_memory(struct memory_block *memory, struct mem_section *section, 66 - struct node *root) 64 + static 65 + int register_memory(struct memory_block *memory, struct mem_section *section) 67 66 { 68 67 int error; 69 68 ··· 71 70 memory->sysdev.id = __section_nr(section); 72 71 73 72 error = sysdev_register(&memory->sysdev); 74 - 75 - if (root && !error) 76 - error = sysfs_create_link(&root->sysdev.kobj, 77 - &memory->sysdev.kobj, 78 - kobject_name(&memory->sysdev.kobj)); 79 - 80 73 return error; 81 74 } 82 75 83 76 static void 84 - unregister_memory(struct memory_block *memory, struct mem_section *section, 85 - struct node *root) 77 + unregister_memory(struct memory_block *memory, struct mem_section *section) 86 78 { 87 79 BUG_ON(memory->sysdev.cls != &memory_sysdev_class); 88 80 BUG_ON(memory->sysdev.id != __section_nr(section)); 89 81 82 + /* drop the ref. we got in remove_memory_block() */ 83 + kobject_put(&memory->sysdev.kobj); 90 84 sysdev_unregister(&memory->sysdev); 91 - if (root) 92 - sysfs_remove_link(&root->sysdev.kobj, 93 - kobject_name(&memory->sysdev.kobj)); 94 85 } 95 86 96 87 /* ··· 186 193 break; 187 194 default: 188 195 printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n", 189 - __FUNCTION__, mem, action, action); 196 + __func__, mem, action, action); 190 197 WARN_ON(1); 191 198 ret = -EINVAL; 192 199 } ··· 198 205 unsigned long to_state, unsigned long from_state_req) 199 206 { 200 207 int ret = 0; 201 - down(&mem->state_sem); 208 + mutex_lock(&mem->state_mutex); 202 209 203 210 if (mem->state != from_state_req) { 204 211 ret = -EINVAL; ··· 210 217 mem->state = to_state; 211 218 212 219 out: 213 - up(&mem->state_sem); 220 + mutex_unlock(&mem->state_mutex); 214 221 return ret; 215 222 } 216 223 ··· 334 341 335 342 mem->phys_index = __section_nr(section); 336 343 mem->state = state; 337 - init_MUTEX(&mem->state_sem); 344 + mutex_init(&mem->state_mutex); 338 345 mem->phys_device = phys_device; 339 346 340 - ret = register_memory(mem, section, NULL); 347 + ret = register_memory(mem, section); 341 348 if (!ret) 342 349 ret = mem_create_simple_file(mem, phys_index); 343 350 if (!ret) ··· 388 395 mem_remove_simple_file(mem, phys_index); 389 396 mem_remove_simple_file(mem, state); 390 397 mem_remove_simple_file(mem, phys_device); 391 - unregister_memory(mem, section, NULL); 398 + unregister_memory(mem, section); 392 399 393 400 return 0; 394 401 } ··· 444 451 ret = err; 445 452 out: 446 453 if (ret) 447 - printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret); 454 + printk(KERN_ERR "%s() failed: %d\n", __func__, ret); 448 455 return ret; 449 456 }
+28 -78
drivers/base/power/main.c
··· 50 50 LIST_HEAD(dpm_active); 51 51 static LIST_HEAD(dpm_off); 52 52 static LIST_HEAD(dpm_off_irq); 53 - static LIST_HEAD(dpm_destroy); 54 53 55 54 static DEFINE_MUTEX(dpm_list_mtx); 56 55 57 - static DECLARE_RWSEM(pm_sleep_rwsem); 58 - 59 - int (*platform_enable_wakeup)(struct device *dev, int is_on); 56 + /* 'true' if all devices have been suspended, protected by dpm_list_mtx */ 57 + static bool all_sleeping; 60 58 61 59 /** 62 60 * device_pm_add - add a device to the list of active devices 63 61 * @dev: Device to be added to the list 64 62 */ 65 - void device_pm_add(struct device *dev) 63 + int device_pm_add(struct device *dev) 66 64 { 65 + int error = 0; 66 + 67 67 pr_debug("PM: Adding info for %s:%s\n", 68 68 dev->bus ? dev->bus->name : "No Bus", 69 69 kobject_name(&dev->kobj)); 70 70 mutex_lock(&dpm_list_mtx); 71 - list_add_tail(&dev->power.entry, &dpm_active); 71 + if ((dev->parent && dev->parent->power.sleeping) || all_sleeping) { 72 + if (dev->parent->power.sleeping) 73 + dev_warn(dev, 74 + "parent %s is sleeping, will not add\n", 75 + dev->parent->bus_id); 76 + else 77 + dev_warn(dev, "devices are sleeping, will not add\n"); 78 + WARN_ON(true); 79 + error = -EBUSY; 80 + } else { 81 + error = dpm_sysfs_add(dev); 82 + if (!error) 83 + list_add_tail(&dev->power.entry, &dpm_active); 84 + } 72 85 mutex_unlock(&dpm_list_mtx); 86 + return error; 73 87 } 74 88 75 89 /** ··· 102 88 list_del_init(&dev->power.entry); 103 89 mutex_unlock(&dpm_list_mtx); 104 90 } 105 - 106 - /** 107 - * device_pm_schedule_removal - schedule the removal of a suspended device 108 - * @dev: Device to destroy 109 - * 110 - * Moves the device to the dpm_destroy list for further processing by 111 - * unregister_dropped_devices(). 112 - */ 113 - void device_pm_schedule_removal(struct device *dev) 114 - { 115 - pr_debug("PM: Preparing for removal: %s:%s\n", 116 - dev->bus ? dev->bus->name : "No Bus", 117 - kobject_name(&dev->kobj)); 118 - mutex_lock(&dpm_list_mtx); 119 - list_move_tail(&dev->power.entry, &dpm_destroy); 120 - mutex_unlock(&dpm_list_mtx); 121 - } 122 - EXPORT_SYMBOL_GPL(device_pm_schedule_removal); 123 - 124 - /** 125 - * pm_sleep_lock - mutual exclusion for registration and suspend 126 - * 127 - * Returns 0 if no suspend is underway and device registration 128 - * may proceed, otherwise -EBUSY. 129 - */ 130 - int pm_sleep_lock(void) 131 - { 132 - if (down_read_trylock(&pm_sleep_rwsem)) 133 - return 0; 134 - 135 - return -EBUSY; 136 - } 137 - 138 - /** 139 - * pm_sleep_unlock - mutual exclusion for registration and suspend 140 - * 141 - * This routine undoes the effect of device_pm_add_lock 142 - * when a device's registration is complete. 143 - */ 144 - void pm_sleep_unlock(void) 145 - { 146 - up_read(&pm_sleep_rwsem); 147 - } 148 - 149 91 150 92 /*------------------------- Resume routines -------------------------*/ 151 93 ··· 212 242 static void dpm_resume(void) 213 243 { 214 244 mutex_lock(&dpm_list_mtx); 245 + all_sleeping = false; 215 246 while(!list_empty(&dpm_off)) { 216 247 struct list_head *entry = dpm_off.next; 217 248 struct device *dev = to_device(entry); 218 249 219 250 list_move_tail(entry, &dpm_active); 251 + dev->power.sleeping = false; 220 252 mutex_unlock(&dpm_list_mtx); 221 253 resume_device(dev); 222 - mutex_lock(&dpm_list_mtx); 223 - } 224 - mutex_unlock(&dpm_list_mtx); 225 - } 226 - 227 - /** 228 - * unregister_dropped_devices - Unregister devices scheduled for removal 229 - * 230 - * Unregister all devices on the dpm_destroy list. 231 - */ 232 - static void unregister_dropped_devices(void) 233 - { 234 - mutex_lock(&dpm_list_mtx); 235 - while (!list_empty(&dpm_destroy)) { 236 - struct list_head *entry = dpm_destroy.next; 237 - struct device *dev = to_device(entry); 238 - 239 - mutex_unlock(&dpm_list_mtx); 240 - /* This also removes the device from the list */ 241 - device_unregister(dev); 242 254 mutex_lock(&dpm_list_mtx); 243 255 } 244 256 mutex_unlock(&dpm_list_mtx); ··· 236 284 { 237 285 might_sleep(); 238 286 dpm_resume(); 239 - unregister_dropped_devices(); 240 - up_write(&pm_sleep_rwsem); 241 287 } 242 288 EXPORT_SYMBOL_GPL(device_resume); 243 289 ··· 327 377 328 378 down(&dev->sem); 329 379 330 - if (dev->power.power_state.event) { 331 - dev_dbg(dev, "PM: suspend %d-->%d\n", 332 - dev->power.power_state.event, state.event); 333 - } 334 - 335 380 if (dev->class && dev->class->suspend) { 336 381 suspend_device_dbg(dev, state, "class "); 337 382 error = dev->class->suspend(dev, state); ··· 371 426 struct list_head *entry = dpm_active.prev; 372 427 struct device *dev = to_device(entry); 373 428 429 + WARN_ON(dev->parent && dev->parent->power.sleeping); 430 + 431 + dev->power.sleeping = true; 374 432 mutex_unlock(&dpm_list_mtx); 375 433 error = suspend_device(dev, state); 376 434 mutex_lock(&dpm_list_mtx); ··· 385 437 (error == -EAGAIN ? 386 438 " (please convert to suspend_late)" : 387 439 "")); 440 + dev->power.sleeping = false; 388 441 break; 389 442 } 390 443 if (!list_empty(&dev->power.entry)) 391 444 list_move(&dev->power.entry, &dpm_off); 392 445 } 446 + if (!error) 447 + all_sleeping = true; 393 448 mutex_unlock(&dpm_list_mtx); 394 449 395 450 return error; ··· 410 459 int error; 411 460 412 461 might_sleep(); 413 - down_write(&pm_sleep_rwsem); 414 462 error = dpm_suspend(state); 415 463 if (error) 416 464 device_resume();
+3 -20
drivers/base/power/power.h
··· 11 11 return container_of(entry, struct device, power.entry); 12 12 } 13 13 14 - extern void device_pm_add(struct device *); 14 + extern int device_pm_add(struct device *); 15 15 extern void device_pm_remove(struct device *); 16 - extern int pm_sleep_lock(void); 17 - extern void pm_sleep_unlock(void); 18 16 19 17 #else /* CONFIG_PM_SLEEP */ 20 18 21 - 22 - static inline void device_pm_add(struct device *dev) 23 - { 24 - } 25 - 26 - static inline void device_pm_remove(struct device *dev) 27 - { 28 - } 29 - 30 - static inline int pm_sleep_lock(void) 31 - { 32 - return 0; 33 - } 34 - 35 - static inline void pm_sleep_unlock(void) 36 - { 37 - } 19 + static inline int device_pm_add(struct device *dev) { return 0; } 20 + static inline void device_pm_remove(struct device *dev) {} 38 21 39 22 #endif 40 23
+2
drivers/base/power/sysfs.c
··· 6 6 #include <linux/string.h> 7 7 #include "power.h" 8 8 9 + int (*platform_enable_wakeup)(struct device *dev, int is_on); 10 + 9 11 10 12 /* 11 13 * wakeup - Report/change current wakeup option for device
+17 -1
drivers/base/sys.c
··· 167 167 { 168 168 int err = 0; 169 169 170 + if (!cls) { 171 + printk(KERN_WARNING "sysdev: invalid class passed to " 172 + "sysdev_driver_register!\n"); 173 + WARN_ON(1); 174 + return -EINVAL; 175 + } 176 + 177 + /* Check whether this driver has already been added to a class. */ 178 + if ((drv->entry.next != drv->entry.prev) || 179 + (drv->entry.next != NULL)) { 180 + printk(KERN_WARNING "sysdev: class %s: driver (%p) has already" 181 + " been registered to a class, something is wrong, but " 182 + "will forge on!\n", cls->name, drv); 183 + WARN_ON(1); 184 + } 185 + 170 186 mutex_lock(&sysdev_drivers_lock); 171 187 if (cls && kset_get(&cls->kset)) { 172 188 list_add_tail(&drv->entry, &cls->drivers); ··· 195 179 } 196 180 } else { 197 181 err = -EINVAL; 198 - printk(KERN_ERR "%s: invalid device class\n", __FUNCTION__); 182 + printk(KERN_ERR "%s: invalid device class\n", __func__); 199 183 WARN_ON(1); 200 184 } 201 185 mutex_unlock(&sysdev_drivers_lock);
+7 -7
drivers/base/transport_class.c
··· 66 66 67 67 static int anon_transport_dummy_function(struct transport_container *tc, 68 68 struct device *dev, 69 - struct class_device *cdev) 69 + struct device *cdev) 70 70 { 71 71 /* do nothing */ 72 72 return 0; ··· 115 115 116 116 static int transport_setup_classdev(struct attribute_container *cont, 117 117 struct device *dev, 118 - struct class_device *classdev) 118 + struct device *classdev) 119 119 { 120 120 struct transport_class *tclass = class_to_transport_class(cont->class); 121 121 struct transport_container *tcont = attribute_container_to_transport_container(cont); ··· 149 149 150 150 static int transport_add_class_device(struct attribute_container *cont, 151 151 struct device *dev, 152 - struct class_device *classdev) 152 + struct device *classdev) 153 153 { 154 154 int error = attribute_container_add_class_device(classdev); 155 155 struct transport_container *tcont = ··· 181 181 182 182 static int transport_configure(struct attribute_container *cont, 183 183 struct device *dev, 184 - struct class_device *cdev) 184 + struct device *cdev) 185 185 { 186 186 struct transport_class *tclass = class_to_transport_class(cont->class); 187 187 struct transport_container *tcont = attribute_container_to_transport_container(cont); ··· 212 212 213 213 static int transport_remove_classdev(struct attribute_container *cont, 214 214 struct device *dev, 215 - struct class_device *classdev) 215 + struct device *classdev) 216 216 { 217 217 struct transport_container *tcont = 218 218 attribute_container_to_transport_container(cont); ··· 251 251 252 252 static void transport_destroy_classdev(struct attribute_container *cont, 253 253 struct device *dev, 254 - struct class_device *classdev) 254 + struct device *classdev) 255 255 { 256 256 struct transport_class *tclass = class_to_transport_class(cont->class); 257 257 258 258 if (tclass->remove != anon_transport_dummy_function) 259 - class_device_put(classdev); 259 + put_device(classdev); 260 260 } 261 261 262 262
-1
drivers/char/drm/drmP.h
··· 640 640 struct drm_device *dev; 641 641 struct proc_dir_entry *dev_root; /**< proc directory entry */ 642 642 dev_t device; /**< Device number for mknod */ 643 - struct class_device *dev_class; 644 643 }; 645 644 646 645 /**
+5 -5
drivers/char/hw_random/core.c
··· 238 238 NULL); 239 239 240 240 241 - static void unregister_miscdev(bool suspended) 241 + static void unregister_miscdev(void) 242 242 { 243 243 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available); 244 244 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current); 245 - __misc_deregister(&rng_miscdev, suspended); 245 + misc_deregister(&rng_miscdev); 246 246 } 247 247 248 248 static int register_miscdev(void) ··· 317 317 } 318 318 EXPORT_SYMBOL_GPL(hwrng_register); 319 319 320 - void __hwrng_unregister(struct hwrng *rng, bool suspended) 320 + void hwrng_unregister(struct hwrng *rng) 321 321 { 322 322 int err; 323 323 ··· 336 336 } 337 337 } 338 338 if (list_empty(&rng_list)) 339 - unregister_miscdev(suspended); 339 + unregister_miscdev(); 340 340 341 341 mutex_unlock(&rng_mutex); 342 342 } 343 - EXPORT_SYMBOL_GPL(__hwrng_unregister); 343 + EXPORT_SYMBOL_GPL(hwrng_unregister); 344 344 345 345 346 346 MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver");
+4 -9
drivers/char/misc.c
··· 232 232 } 233 233 234 234 /** 235 - * __misc_deregister - unregister a miscellaneous device 235 + * misc_deregister - unregister a miscellaneous device 236 236 * @misc: device to unregister 237 - * @suspended: to be set if the function is used during suspend/resume 238 237 * 239 238 * Unregister a miscellaneous device that was previously 240 239 * successfully registered with misc_register(). Success ··· 241 242 * indicates an error. 242 243 */ 243 244 244 - int __misc_deregister(struct miscdevice *misc, bool suspended) 245 + int misc_deregister(struct miscdevice *misc) 245 246 { 246 247 int i = misc->minor; 247 248 ··· 250 251 251 252 mutex_lock(&misc_mtx); 252 253 list_del(&misc->list); 253 - if (suspended) 254 - destroy_suspended_device(misc_class, 255 - MKDEV(MISC_MAJOR, misc->minor)); 256 - else 257 - device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); 254 + device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); 258 255 if (i < DYNAMIC_MINORS && i>0) { 259 256 misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); 260 257 } ··· 259 264 } 260 265 261 266 EXPORT_SYMBOL(misc_register); 262 - EXPORT_SYMBOL(__misc_deregister); 267 + EXPORT_SYMBOL(misc_deregister); 263 268 264 269 static int __init misc_init(void) 265 270 {
+20
drivers/firmware/Kconfig
··· 93 93 information from userspace through /sys/class/dmi/id/ or if you want 94 94 DMI-based module auto-loading. 95 95 96 + config ISCSI_IBFT_FIND 97 + bool "iSCSI Boot Firmware Table Attributes" 98 + depends on X86 99 + default n 100 + help 101 + This option enables the kernel to find the region of memory 102 + in which the ISCSI Boot Firmware Table (iBFT) resides. This 103 + is necessary for iSCSI Boot Firmware Table Attributes module to work 104 + properly. 105 + 106 + config ISCSI_IBFT 107 + tristate "iSCSI Boot Firmware Table Attributes module" 108 + depends on ISCSI_IBFT_FIND 109 + default n 110 + help 111 + This option enables support for detection and exposing of iSCSI 112 + Boot Firmware Table (iBFT) via sysfs to userspace. If you wish to 113 + detect iSCSI boot parameters dynamically during system boot, say Y. 114 + Otherwise, say N. 115 + 96 116 endmenu
+2
drivers/firmware/Makefile
··· 8 8 obj-$(CONFIG_DELL_RBU) += dell_rbu.o 9 9 obj-$(CONFIG_DCDBAS) += dcdbas.o 10 10 obj-$(CONFIG_DMIID) += dmi-id.o 11 + obj-$(CONFIG_ISCSI_IBFT_FIND) += iscsi_ibft_find.o 12 + obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o
+982
drivers/firmware/iscsi_ibft.c
··· 1 + /* 2 + * Copyright 2007 Red Hat, Inc. 3 + * by Peter Jones <pjones@redhat.com> 4 + * Copyright 2008 IBM, Inc. 5 + * by Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 6 + * Copyright 2008 7 + * by Konrad Rzeszutek <ketuzsezr@darnok.org> 8 + * 9 + * This code exposes the iSCSI Boot Format Table to userland via sysfs. 10 + * 11 + * This program is free software; you can redistribute it and/or modify 12 + * it under the terms of the GNU General Public License v2.0 as published by 13 + * the Free Software Foundation 14 + * 15 + * This program is distributed in the hope that it will be useful, 16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 + * GNU General Public License for more details. 19 + * 20 + * Changelog: 21 + * 22 + * 14 Mar 2008 - Konrad Rzeszutek <ketuzsezr@darnok.org> 23 + * Updated comments and copyrights. (v0.4.9) 24 + * 25 + * 11 Feb 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 26 + * Converted to using ibft_addr. (v0.4.8) 27 + * 28 + * 8 Feb 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 29 + * Combined two functions in one: reserve_ibft_region. (v0.4.7) 30 + * 31 + * 30 Jan 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 32 + * Added logic to handle IPv6 addresses. (v0.4.6) 33 + * 34 + * 25 Jan 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 35 + * Added logic to handle badly not-to-spec iBFT. (v0.4.5) 36 + * 37 + * 4 Jan 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 38 + * Added __init to function declarations. (v0.4.4) 39 + * 40 + * 21 Dec 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 41 + * Updated kobject registration, combined unregister functions in one 42 + * and code and style cleanup. (v0.4.3) 43 + * 44 + * 5 Dec 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 45 + * Added end-markers to enums and re-organized kobject registration. (v0.4.2) 46 + * 47 + * 4 Dec 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 48 + * Created 'device' sysfs link to the NIC and style cleanup. (v0.4.1) 49 + * 50 + * 28 Nov 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 51 + * Added sysfs-ibft documentation, moved 'find_ibft' function to 52 + * in its own file and added text attributes for every struct field. (v0.4) 53 + * 54 + * 21 Nov 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 55 + * Added text attributes emulating OpenFirmware /proc/device-tree naming. 56 + * Removed binary /sysfs interface (v0.3) 57 + * 58 + * 29 Aug 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 59 + * Added functionality in setup.c to reserve iBFT region. (v0.2) 60 + * 61 + * 27 Aug 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 62 + * First version exposing iBFT data via a binary /sysfs. (v0.1) 63 + * 64 + */ 65 + 66 + 67 + #include <linux/blkdev.h> 68 + #include <linux/capability.h> 69 + #include <linux/ctype.h> 70 + #include <linux/device.h> 71 + #include <linux/err.h> 72 + #include <linux/init.h> 73 + #include <linux/iscsi_ibft.h> 74 + #include <linux/limits.h> 75 + #include <linux/module.h> 76 + #include <linux/pci.h> 77 + #include <linux/slab.h> 78 + #include <linux/stat.h> 79 + #include <linux/string.h> 80 + #include <linux/types.h> 81 + 82 + #define IBFT_ISCSI_VERSION "0.4.9" 83 + #define IBFT_ISCSI_DATE "2008-Mar-14" 84 + 85 + MODULE_AUTHOR("Peter Jones <pjones@redhat.com> and \ 86 + Konrad Rzeszutek <ketuzsezr@darnok.org>"); 87 + MODULE_DESCRIPTION("sysfs interface to BIOS iBFT information"); 88 + MODULE_LICENSE("GPL"); 89 + MODULE_VERSION(IBFT_ISCSI_VERSION); 90 + 91 + struct ibft_hdr { 92 + u8 id; 93 + u8 version; 94 + u16 length; 95 + u8 index; 96 + u8 flags; 97 + } __attribute__((__packed__)); 98 + 99 + struct ibft_control { 100 + struct ibft_hdr hdr; 101 + u16 extensions; 102 + u16 initiator_off; 103 + u16 nic0_off; 104 + u16 tgt0_off; 105 + u16 nic1_off; 106 + u16 tgt1_off; 107 + } __attribute__((__packed__)); 108 + 109 + struct ibft_initiator { 110 + struct ibft_hdr hdr; 111 + char isns_server[16]; 112 + char slp_server[16]; 113 + char pri_radius_server[16]; 114 + char sec_radius_server[16]; 115 + u16 initiator_name_len; 116 + u16 initiator_name_off; 117 + } __attribute__((__packed__)); 118 + 119 + struct ibft_nic { 120 + struct ibft_hdr hdr; 121 + char ip_addr[16]; 122 + u8 subnet_mask_prefix; 123 + u8 origin; 124 + char gateway[16]; 125 + char primary_dns[16]; 126 + char secondary_dns[16]; 127 + char dhcp[16]; 128 + u16 vlan; 129 + char mac[6]; 130 + u16 pci_bdf; 131 + u16 hostname_len; 132 + u16 hostname_off; 133 + } __attribute__((__packed__)); 134 + 135 + struct ibft_tgt { 136 + struct ibft_hdr hdr; 137 + char ip_addr[16]; 138 + u16 port; 139 + char lun[8]; 140 + u8 chap_type; 141 + u8 nic_assoc; 142 + u16 tgt_name_len; 143 + u16 tgt_name_off; 144 + u16 chap_name_len; 145 + u16 chap_name_off; 146 + u16 chap_secret_len; 147 + u16 chap_secret_off; 148 + u16 rev_chap_name_len; 149 + u16 rev_chap_name_off; 150 + u16 rev_chap_secret_len; 151 + u16 rev_chap_secret_off; 152 + } __attribute__((__packed__)); 153 + 154 + /* 155 + * The kobject different types and its names. 156 + * 157 + */ 158 + enum ibft_id { 159 + id_reserved = 0, /* We don't support. */ 160 + id_control = 1, /* Should show up only once and is not exported. */ 161 + id_initiator = 2, 162 + id_nic = 3, 163 + id_target = 4, 164 + id_extensions = 5, /* We don't support. */ 165 + id_end_marker, 166 + }; 167 + 168 + /* 169 + * We do not support the other types, hence the usage of NULL. 170 + * This maps to the enum ibft_id. 171 + */ 172 + static const char *ibft_id_names[] = 173 + {NULL, NULL, "initiator", "ethernet%d", "target%d", NULL, NULL}; 174 + 175 + /* 176 + * The text attributes names for each of the kobjects. 177 + */ 178 + enum ibft_eth_properties_enum { 179 + ibft_eth_index, 180 + ibft_eth_flags, 181 + ibft_eth_ip_addr, 182 + ibft_eth_subnet_mask, 183 + ibft_eth_origin, 184 + ibft_eth_gateway, 185 + ibft_eth_primary_dns, 186 + ibft_eth_secondary_dns, 187 + ibft_eth_dhcp, 188 + ibft_eth_vlan, 189 + ibft_eth_mac, 190 + /* ibft_eth_pci_bdf - this is replaced by link to the device itself. */ 191 + ibft_eth_hostname, 192 + ibft_eth_end_marker, 193 + }; 194 + 195 + static const char *ibft_eth_properties[] = 196 + {"index", "flags", "ip-addr", "subnet-mask", "origin", "gateway", 197 + "primary-dns", "secondary-dns", "dhcp", "vlan", "mac", "hostname", 198 + NULL}; 199 + 200 + enum ibft_tgt_properties_enum { 201 + ibft_tgt_index, 202 + ibft_tgt_flags, 203 + ibft_tgt_ip_addr, 204 + ibft_tgt_port, 205 + ibft_tgt_lun, 206 + ibft_tgt_chap_type, 207 + ibft_tgt_nic_assoc, 208 + ibft_tgt_name, 209 + ibft_tgt_chap_name, 210 + ibft_tgt_chap_secret, 211 + ibft_tgt_rev_chap_name, 212 + ibft_tgt_rev_chap_secret, 213 + ibft_tgt_end_marker, 214 + }; 215 + 216 + static const char *ibft_tgt_properties[] = 217 + {"index", "flags", "ip-addr", "port", "lun", "chap-type", "nic-assoc", 218 + "target-name", "chap-name", "chap-secret", "rev-chap-name", 219 + "rev-chap-name-secret", NULL}; 220 + 221 + enum ibft_initiator_properties_enum { 222 + ibft_init_index, 223 + ibft_init_flags, 224 + ibft_init_isns_server, 225 + ibft_init_slp_server, 226 + ibft_init_pri_radius_server, 227 + ibft_init_sec_radius_server, 228 + ibft_init_initiator_name, 229 + ibft_init_end_marker, 230 + }; 231 + 232 + static const char *ibft_initiator_properties[] = 233 + {"index", "flags", "isns-server", "slp-server", "pri-radius-server", 234 + "sec-radius-server", "initiator-name", NULL}; 235 + 236 + /* 237 + * The kobject and attribute structures. 238 + */ 239 + 240 + struct ibft_kobject { 241 + struct ibft_table_header *header; 242 + union { 243 + struct ibft_initiator *initiator; 244 + struct ibft_nic *nic; 245 + struct ibft_tgt *tgt; 246 + struct ibft_hdr *hdr; 247 + }; 248 + struct kobject kobj; 249 + struct list_head node; 250 + }; 251 + 252 + struct ibft_attribute { 253 + struct attribute attr; 254 + ssize_t (*show) (struct ibft_kobject *entry, 255 + struct ibft_attribute *attr, char *buf); 256 + union { 257 + struct ibft_initiator *initiator; 258 + struct ibft_nic *nic; 259 + struct ibft_tgt *tgt; 260 + struct ibft_hdr *hdr; 261 + }; 262 + struct kobject *kobj; 263 + int type; /* The enum of the type. This can be any value of: 264 + ibft_eth_properties_enum, ibft_tgt_properties_enum, 265 + or ibft_initiator_properties_enum. */ 266 + struct list_head node; 267 + }; 268 + 269 + static LIST_HEAD(ibft_attr_list); 270 + static LIST_HEAD(ibft_kobject_list); 271 + 272 + static const char nulls[16]; 273 + 274 + /* 275 + * Helper functions to parse data properly. 276 + */ 277 + static ssize_t sprintf_ipaddr(char *buf, u8 *ip) 278 + { 279 + char *str = buf; 280 + 281 + if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0 && 282 + ip[4] == 0 && ip[5] == 0 && ip[6] == 0 && ip[7] == 0 && 283 + ip[8] == 0 && ip[9] == 0 && ip[10] == 0xff && ip[11] == 0xff) { 284 + /* 285 + * IPV4 286 + */ 287 + str += sprintf(buf, NIPQUAD_FMT, ip[12], 288 + ip[13], ip[14], ip[15]); 289 + } else { 290 + /* 291 + * IPv6 292 + */ 293 + str += sprintf(str, NIP6_FMT, ntohs(ip[0]), ntohs(ip[1]), 294 + ntohs(ip[2]), ntohs(ip[3]), ntohs(ip[4]), 295 + ntohs(ip[5]), ntohs(ip[6]), ntohs(ip[7])); 296 + } 297 + str += sprintf(str, "\n"); 298 + return str - buf; 299 + } 300 + 301 + static ssize_t sprintf_string(char *str, int len, char *buf) 302 + { 303 + return sprintf(str, "%.*s\n", len, buf); 304 + } 305 + 306 + /* 307 + * Helper function to verify the IBFT header. 308 + */ 309 + static int ibft_verify_hdr(char *t, struct ibft_hdr *hdr, int id, int length) 310 + { 311 + if (hdr->id != id) { 312 + printk(KERN_ERR "iBFT error: We expected the " \ 313 + "field header.id to have %d but " \ 314 + "found %d instead!\n", id, hdr->id); 315 + return -ENODEV; 316 + } 317 + if (hdr->length != length) { 318 + printk(KERN_ERR "iBFT error: We expected the " \ 319 + "field header.length to have %d but " \ 320 + "found %d instead!\n", length, hdr->length); 321 + return -ENODEV; 322 + } 323 + 324 + return 0; 325 + } 326 + 327 + static void ibft_release(struct kobject *kobj) 328 + { 329 + struct ibft_kobject *ibft = 330 + container_of(kobj, struct ibft_kobject, kobj); 331 + kfree(ibft); 332 + } 333 + 334 + /* 335 + * Routines for parsing the iBFT data to be human readable. 336 + */ 337 + ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, 338 + struct ibft_attribute *attr, 339 + char *buf) 340 + { 341 + struct ibft_initiator *initiator = entry->initiator; 342 + void *ibft_loc = entry->header; 343 + char *str = buf; 344 + 345 + if (!initiator) 346 + return 0; 347 + 348 + switch (attr->type) { 349 + case ibft_init_index: 350 + str += sprintf(str, "%d\n", initiator->hdr.index); 351 + break; 352 + case ibft_init_flags: 353 + str += sprintf(str, "%d\n", initiator->hdr.flags); 354 + break; 355 + case ibft_init_isns_server: 356 + str += sprintf_ipaddr(str, initiator->isns_server); 357 + break; 358 + case ibft_init_slp_server: 359 + str += sprintf_ipaddr(str, initiator->slp_server); 360 + break; 361 + case ibft_init_pri_radius_server: 362 + str += sprintf_ipaddr(str, initiator->pri_radius_server); 363 + break; 364 + case ibft_init_sec_radius_server: 365 + str += sprintf_ipaddr(str, initiator->sec_radius_server); 366 + break; 367 + case ibft_init_initiator_name: 368 + str += sprintf_string(str, initiator->initiator_name_len, 369 + (char *)ibft_loc + 370 + initiator->initiator_name_off); 371 + break; 372 + default: 373 + break; 374 + } 375 + 376 + return str - buf; 377 + } 378 + 379 + ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, 380 + struct ibft_attribute *attr, 381 + char *buf) 382 + { 383 + struct ibft_nic *nic = entry->nic; 384 + void *ibft_loc = entry->header; 385 + char *str = buf; 386 + char *mac; 387 + int val; 388 + 389 + if (!nic) 390 + return 0; 391 + 392 + switch (attr->type) { 393 + case ibft_eth_index: 394 + str += sprintf(str, "%d\n", nic->hdr.index); 395 + break; 396 + case ibft_eth_flags: 397 + str += sprintf(str, "%d\n", nic->hdr.flags); 398 + break; 399 + case ibft_eth_ip_addr: 400 + str += sprintf_ipaddr(str, nic->ip_addr); 401 + break; 402 + case ibft_eth_subnet_mask: 403 + val = ~((1 << (32-nic->subnet_mask_prefix))-1); 404 + str += sprintf(str, NIPQUAD_FMT, 405 + (u8)(val >> 24), (u8)(val >> 16), 406 + (u8)(val >> 8), (u8)(val)); 407 + break; 408 + case ibft_eth_origin: 409 + str += sprintf(str, "%d\n", nic->origin); 410 + break; 411 + case ibft_eth_gateway: 412 + str += sprintf_ipaddr(str, nic->gateway); 413 + break; 414 + case ibft_eth_primary_dns: 415 + str += sprintf_ipaddr(str, nic->primary_dns); 416 + break; 417 + case ibft_eth_secondary_dns: 418 + str += sprintf_ipaddr(str, nic->secondary_dns); 419 + break; 420 + case ibft_eth_dhcp: 421 + str += sprintf_ipaddr(str, nic->dhcp); 422 + break; 423 + case ibft_eth_vlan: 424 + str += sprintf(str, "%d\n", nic->vlan); 425 + break; 426 + case ibft_eth_mac: 427 + mac = nic->mac; 428 + str += sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x\n", 429 + (u8)mac[0], (u8)mac[1], (u8)mac[2], 430 + (u8)mac[3], (u8)mac[4], (u8)mac[5]); 431 + break; 432 + case ibft_eth_hostname: 433 + str += sprintf_string(str, nic->hostname_len, 434 + (char *)ibft_loc + nic->hostname_off); 435 + break; 436 + default: 437 + break; 438 + } 439 + 440 + return str - buf; 441 + }; 442 + 443 + ssize_t ibft_attr_show_target(struct ibft_kobject *entry, 444 + struct ibft_attribute *attr, 445 + char *buf) 446 + { 447 + struct ibft_tgt *tgt = entry->tgt; 448 + void *ibft_loc = entry->header; 449 + char *str = buf; 450 + int i; 451 + 452 + if (!tgt) 453 + return 0; 454 + 455 + switch (attr->type) { 456 + case ibft_tgt_index: 457 + str += sprintf(str, "%d\n", tgt->hdr.index); 458 + break; 459 + case ibft_tgt_flags: 460 + str += sprintf(str, "%d\n", tgt->hdr.flags); 461 + break; 462 + case ibft_tgt_ip_addr: 463 + str += sprintf_ipaddr(str, tgt->ip_addr); 464 + break; 465 + case ibft_tgt_port: 466 + str += sprintf(str, "%d\n", tgt->port); 467 + break; 468 + case ibft_tgt_lun: 469 + for (i = 0; i < 8; i++) 470 + str += sprintf(str, "%x", (u8)tgt->lun[i]); 471 + str += sprintf(str, "\n"); 472 + break; 473 + case ibft_tgt_nic_assoc: 474 + str += sprintf(str, "%d\n", tgt->nic_assoc); 475 + break; 476 + case ibft_tgt_chap_type: 477 + str += sprintf(str, "%d\n", tgt->chap_type); 478 + break; 479 + case ibft_tgt_name: 480 + str += sprintf_string(str, tgt->tgt_name_len, 481 + (char *)ibft_loc + tgt->tgt_name_off); 482 + break; 483 + case ibft_tgt_chap_name: 484 + str += sprintf_string(str, tgt->chap_name_len, 485 + (char *)ibft_loc + tgt->chap_name_off); 486 + break; 487 + case ibft_tgt_chap_secret: 488 + str += sprintf_string(str, tgt->chap_secret_len, 489 + (char *)ibft_loc + tgt->chap_secret_off); 490 + break; 491 + case ibft_tgt_rev_chap_name: 492 + str += sprintf_string(str, tgt->rev_chap_name_len, 493 + (char *)ibft_loc + 494 + tgt->rev_chap_name_off); 495 + break; 496 + case ibft_tgt_rev_chap_secret: 497 + str += sprintf_string(str, tgt->rev_chap_secret_len, 498 + (char *)ibft_loc + 499 + tgt->rev_chap_secret_off); 500 + break; 501 + default: 502 + break; 503 + } 504 + 505 + return str - buf; 506 + } 507 + 508 + /* 509 + * The routine called for all sysfs attributes. 510 + */ 511 + static ssize_t ibft_show_attribute(struct kobject *kobj, 512 + struct attribute *attr, 513 + char *buf) 514 + { 515 + struct ibft_kobject *dev = 516 + container_of(kobj, struct ibft_kobject, kobj); 517 + struct ibft_attribute *ibft_attr = 518 + container_of(attr, struct ibft_attribute, attr); 519 + ssize_t ret = -EIO; 520 + char *str = buf; 521 + 522 + if (!capable(CAP_SYS_ADMIN)) 523 + return -EACCES; 524 + 525 + if (ibft_attr->show) 526 + ret = ibft_attr->show(dev, ibft_attr, str); 527 + 528 + return ret; 529 + } 530 + 531 + static struct sysfs_ops ibft_attr_ops = { 532 + .show = ibft_show_attribute, 533 + }; 534 + 535 + static struct kobj_type ibft_ktype = { 536 + .release = ibft_release, 537 + .sysfs_ops = &ibft_attr_ops, 538 + }; 539 + 540 + static struct kset *ibft_kset; 541 + 542 + static int __init ibft_check_device(void) 543 + { 544 + int len; 545 + u8 *pos; 546 + u8 csum = 0; 547 + 548 + len = ibft_addr->length; 549 + 550 + /* Sanity checking of iBFT. */ 551 + if (ibft_addr->revision != 1) { 552 + printk(KERN_ERR "iBFT module supports only revision 1, " \ 553 + "while this is %d.\n", ibft_addr->revision); 554 + return -ENOENT; 555 + } 556 + for (pos = (u8 *)ibft_addr; pos < (u8 *)ibft_addr + len; pos++) 557 + csum += *pos; 558 + 559 + if (csum) { 560 + printk(KERN_ERR "iBFT has incorrect checksum (0x%x)!\n", csum); 561 + return -ENOENT; 562 + } 563 + 564 + return 0; 565 + } 566 + 567 + /* 568 + * Helper function for ibft_register_kobjects. 569 + */ 570 + static int __init ibft_create_kobject(struct ibft_table_header *header, 571 + struct ibft_hdr *hdr, 572 + struct list_head *list) 573 + { 574 + struct ibft_kobject *ibft_kobj = NULL; 575 + struct ibft_nic *nic = (struct ibft_nic *)hdr; 576 + struct pci_dev *pci_dev; 577 + int rc = 0; 578 + 579 + ibft_kobj = kzalloc(sizeof(*ibft_kobj), GFP_KERNEL); 580 + if (!ibft_kobj) 581 + return -ENOMEM; 582 + 583 + ibft_kobj->header = header; 584 + ibft_kobj->hdr = hdr; 585 + 586 + switch (hdr->id) { 587 + case id_initiator: 588 + rc = ibft_verify_hdr("initiator", hdr, id_initiator, 589 + sizeof(*ibft_kobj->initiator)); 590 + break; 591 + case id_nic: 592 + rc = ibft_verify_hdr("ethernet", hdr, id_nic, 593 + sizeof(*ibft_kobj->nic)); 594 + break; 595 + case id_target: 596 + rc = ibft_verify_hdr("target", hdr, id_target, 597 + sizeof(*ibft_kobj->tgt)); 598 + break; 599 + case id_reserved: 600 + case id_control: 601 + case id_extensions: 602 + /* Fields which we don't support. Ignore them */ 603 + rc = 1; 604 + break; 605 + default: 606 + printk(KERN_ERR "iBFT has unknown structure type (%d). " \ 607 + "Report this bug to %.6s!\n", hdr->id, 608 + header->oem_id); 609 + rc = 1; 610 + break; 611 + } 612 + 613 + if (rc) { 614 + /* Skip adding this kobject, but exit with non-fatal error. */ 615 + kfree(ibft_kobj); 616 + goto out_invalid_struct; 617 + } 618 + 619 + ibft_kobj->kobj.kset = ibft_kset; 620 + 621 + rc = kobject_init_and_add(&ibft_kobj->kobj, &ibft_ktype, 622 + NULL, ibft_id_names[hdr->id], hdr->index); 623 + 624 + if (rc) { 625 + kfree(ibft_kobj); 626 + goto out; 627 + } 628 + 629 + kobject_uevent(&ibft_kobj->kobj, KOBJ_ADD); 630 + 631 + if (hdr->id == id_nic) { 632 + /* 633 + * We don't search for the device in other domains than 634 + * zero. This is because on x86 platforms the BIOS 635 + * executes only devices which are in domain 0. Furthermore, the 636 + * iBFT spec doesn't have a domain id field :-( 637 + */ 638 + pci_dev = pci_get_bus_and_slot((nic->pci_bdf & 0xff00) >> 8, 639 + (nic->pci_bdf & 0xff)); 640 + if (pci_dev) { 641 + rc = sysfs_create_link(&ibft_kobj->kobj, 642 + &pci_dev->dev.kobj, "device"); 643 + pci_dev_put(pci_dev); 644 + } 645 + } 646 + 647 + /* Nothing broke so lets add it to the list. */ 648 + list_add_tail(&ibft_kobj->node, list); 649 + out: 650 + return rc; 651 + out_invalid_struct: 652 + /* Unsupported structs are skipped. */ 653 + return 0; 654 + } 655 + 656 + /* 657 + * Scan the IBFT table structure for the NIC and Target fields. When 658 + * found add them on the passed-in list. We do not support the other 659 + * fields at this point, so they are skipped. 660 + */ 661 + static int __init ibft_register_kobjects(struct ibft_table_header *header, 662 + struct list_head *list) 663 + { 664 + struct ibft_control *control = NULL; 665 + void *ptr, *end; 666 + int rc = 0; 667 + u16 offset; 668 + u16 eot_offset; 669 + 670 + control = (void *)header + sizeof(*header); 671 + end = (void *)control + control->hdr.length; 672 + eot_offset = (void *)header + header->length - 673 + (void *)control - sizeof(*header); 674 + rc = ibft_verify_hdr("control", (struct ibft_hdr *)control, id_control, 675 + sizeof(*control)); 676 + 677 + /* iBFT table safety checking */ 678 + rc |= ((control->hdr.index) ? -ENODEV : 0); 679 + if (rc) { 680 + printk(KERN_ERR "iBFT error: Control header is invalid!\n"); 681 + return rc; 682 + } 683 + for (ptr = &control->initiator_off; ptr < end; ptr += sizeof(u16)) { 684 + offset = *(u16 *)ptr; 685 + if (offset && offset < header->length && offset < eot_offset) { 686 + rc = ibft_create_kobject(header, 687 + (void *)header + offset, 688 + list); 689 + if (rc) 690 + break; 691 + } 692 + } 693 + 694 + return rc; 695 + } 696 + 697 + static void ibft_unregister(struct list_head *attr_list, 698 + struct list_head *kobj_list) 699 + { 700 + struct ibft_kobject *data = NULL, *n; 701 + struct ibft_attribute *attr = NULL, *m; 702 + 703 + list_for_each_entry_safe(attr, m, attr_list, node) { 704 + sysfs_remove_file(attr->kobj, &attr->attr); 705 + list_del(&attr->node); 706 + kfree(attr); 707 + }; 708 + list_del_init(attr_list); 709 + 710 + list_for_each_entry_safe(data, n, kobj_list, node) { 711 + list_del(&data->node); 712 + if (data->hdr->id == id_nic) 713 + sysfs_remove_link(&data->kobj, "device"); 714 + kobject_put(&data->kobj); 715 + }; 716 + list_del_init(kobj_list); 717 + } 718 + 719 + static int __init ibft_create_attribute(struct ibft_kobject *kobj_data, 720 + int type, 721 + const char *name, 722 + ssize_t (*show)(struct ibft_kobject *, 723 + struct ibft_attribute*, 724 + char *buf), 725 + struct list_head *list) 726 + { 727 + struct ibft_attribute *attr = NULL; 728 + struct ibft_hdr *hdr = kobj_data->hdr; 729 + 730 + attr = kmalloc(sizeof(*attr), GFP_KERNEL); 731 + if (!attr) 732 + return -ENOMEM; 733 + 734 + attr->attr.name = name; 735 + attr->attr.mode = S_IRUSR; 736 + attr->attr.owner = THIS_MODULE; 737 + 738 + attr->hdr = hdr; 739 + attr->show = show; 740 + attr->kobj = &kobj_data->kobj; 741 + attr->type = type; 742 + 743 + list_add_tail(&attr->node, list); 744 + 745 + return 0; 746 + } 747 + 748 + /* 749 + * Helper routiners to check to determine if the entry is valid 750 + * in the proper iBFT structure. 751 + */ 752 + static int __init ibft_check_nic_for(struct ibft_nic *nic, int entry) 753 + { 754 + int rc = 0; 755 + 756 + switch (entry) { 757 + case ibft_eth_index: 758 + case ibft_eth_flags: 759 + rc = 1; 760 + break; 761 + case ibft_eth_ip_addr: 762 + if (!memcmp(nic->dhcp, nulls, sizeof(nic->dhcp))) 763 + rc = 1; 764 + break; 765 + case ibft_eth_subnet_mask: 766 + if (!memcmp(nic->dhcp, nulls, sizeof(nic->dhcp))) 767 + rc = 1; 768 + break; 769 + case ibft_eth_origin: 770 + rc = 1; 771 + break; 772 + case ibft_eth_gateway: 773 + if (memcmp(nic->gateway, nulls, sizeof(nic->gateway))) 774 + rc = 1; 775 + break; 776 + case ibft_eth_primary_dns: 777 + if (memcmp(nic->primary_dns, nulls, 778 + sizeof(nic->primary_dns))) 779 + rc = 1; 780 + break; 781 + case ibft_eth_secondary_dns: 782 + if (memcmp(nic->secondary_dns, nulls, 783 + sizeof(nic->secondary_dns))) 784 + rc = 1; 785 + break; 786 + case ibft_eth_dhcp: 787 + if (memcmp(nic->dhcp, nulls, sizeof(nic->dhcp))) 788 + rc = 1; 789 + break; 790 + case ibft_eth_vlan: 791 + case ibft_eth_mac: 792 + rc = 1; 793 + break; 794 + case ibft_eth_hostname: 795 + if (nic->hostname_off) 796 + rc = 1; 797 + break; 798 + default: 799 + break; 800 + } 801 + 802 + return rc; 803 + } 804 + 805 + static int __init ibft_check_tgt_for(struct ibft_tgt *tgt, int entry) 806 + { 807 + int rc = 0; 808 + 809 + switch (entry) { 810 + case ibft_tgt_index: 811 + case ibft_tgt_flags: 812 + case ibft_tgt_ip_addr: 813 + case ibft_tgt_port: 814 + case ibft_tgt_lun: 815 + case ibft_tgt_nic_assoc: 816 + case ibft_tgt_chap_type: 817 + rc = 1; 818 + case ibft_tgt_name: 819 + if (tgt->tgt_name_len) 820 + rc = 1; 821 + break; 822 + case ibft_tgt_chap_name: 823 + case ibft_tgt_chap_secret: 824 + if (tgt->chap_name_len) 825 + rc = 1; 826 + break; 827 + case ibft_tgt_rev_chap_name: 828 + case ibft_tgt_rev_chap_secret: 829 + if (tgt->rev_chap_name_len) 830 + rc = 1; 831 + break; 832 + default: 833 + break; 834 + } 835 + 836 + return rc; 837 + } 838 + 839 + static int __init ibft_check_initiator_for(struct ibft_initiator *init, 840 + int entry) 841 + { 842 + int rc = 0; 843 + 844 + switch (entry) { 845 + case ibft_init_index: 846 + case ibft_init_flags: 847 + rc = 1; 848 + break; 849 + case ibft_init_isns_server: 850 + if (memcmp(init->isns_server, nulls, 851 + sizeof(init->isns_server))) 852 + rc = 1; 853 + break; 854 + case ibft_init_slp_server: 855 + if (memcmp(init->slp_server, nulls, 856 + sizeof(init->slp_server))) 857 + rc = 1; 858 + break; 859 + case ibft_init_pri_radius_server: 860 + if (memcmp(init->pri_radius_server, nulls, 861 + sizeof(init->pri_radius_server))) 862 + rc = 1; 863 + break; 864 + case ibft_init_sec_radius_server: 865 + if (memcmp(init->sec_radius_server, nulls, 866 + sizeof(init->sec_radius_server))) 867 + rc = 1; 868 + break; 869 + case ibft_init_initiator_name: 870 + if (init->initiator_name_len) 871 + rc = 1; 872 + break; 873 + default: 874 + break; 875 + } 876 + 877 + return rc; 878 + } 879 + 880 + /* 881 + * Register the attributes for all of the kobjects. 882 + */ 883 + static int __init ibft_register_attributes(struct list_head *kobject_list, 884 + struct list_head *attr_list) 885 + { 886 + int rc = 0, i = 0; 887 + struct ibft_kobject *data = NULL; 888 + struct ibft_attribute *attr = NULL, *m; 889 + 890 + list_for_each_entry(data, kobject_list, node) { 891 + switch (data->hdr->id) { 892 + case id_nic: 893 + for (i = 0; i < ibft_eth_end_marker && !rc; i++) 894 + if (ibft_check_nic_for(data->nic, i)) 895 + rc = ibft_create_attribute(data, i, 896 + ibft_eth_properties[i], 897 + ibft_attr_show_nic, attr_list); 898 + break; 899 + case id_target: 900 + for (i = 0; i < ibft_tgt_end_marker && !rc; i++) 901 + if (ibft_check_tgt_for(data->tgt, i)) 902 + rc = ibft_create_attribute(data, i, 903 + ibft_tgt_properties[i], 904 + ibft_attr_show_target, 905 + attr_list); 906 + break; 907 + case id_initiator: 908 + for (i = 0; i < ibft_init_end_marker && !rc; i++) 909 + if (ibft_check_initiator_for( 910 + data->initiator, i)) 911 + rc = ibft_create_attribute(data, i, 912 + ibft_initiator_properties[i], 913 + ibft_attr_show_initiator, 914 + attr_list); 915 + break; 916 + default: 917 + break; 918 + } 919 + if (rc) 920 + break; 921 + } 922 + list_for_each_entry_safe(attr, m, attr_list, node) { 923 + rc = sysfs_create_file(attr->kobj, &attr->attr); 924 + if (rc) { 925 + list_del(&attr->node); 926 + kfree(attr); 927 + break; 928 + } 929 + } 930 + 931 + return rc; 932 + } 933 + 934 + /* 935 + * ibft_init() - creates sysfs tree entries for the iBFT data. 936 + */ 937 + static int __init ibft_init(void) 938 + { 939 + int rc = 0; 940 + 941 + ibft_kset = kset_create_and_add("ibft", NULL, firmware_kobj); 942 + if (!ibft_kset) 943 + return -ENOMEM; 944 + 945 + if (ibft_addr) { 946 + printk(KERN_INFO "iBFT detected at 0x%lx.\n", 947 + virt_to_phys((void *)ibft_addr)); 948 + 949 + rc = ibft_check_device(); 950 + if (rc) 951 + goto out_firmware_unregister; 952 + 953 + /* Scan the IBFT for data and register the kobjects. */ 954 + rc = ibft_register_kobjects(ibft_addr, &ibft_kobject_list); 955 + if (rc) 956 + goto out_free; 957 + 958 + /* Register the attributes */ 959 + rc = ibft_register_attributes(&ibft_kobject_list, 960 + &ibft_attr_list); 961 + if (rc) 962 + goto out_free; 963 + } else 964 + printk(KERN_INFO "No iBFT detected.\n"); 965 + 966 + return 0; 967 + 968 + out_free: 969 + ibft_unregister(&ibft_attr_list, &ibft_kobject_list); 970 + out_firmware_unregister: 971 + kset_unregister(ibft_kset); 972 + return rc; 973 + } 974 + 975 + static void __exit ibft_exit(void) 976 + { 977 + ibft_unregister(&ibft_attr_list, &ibft_kobject_list); 978 + kset_unregister(ibft_kset); 979 + } 980 + 981 + module_init(ibft_init); 982 + module_exit(ibft_exit);
+84
drivers/firmware/iscsi_ibft_find.c
··· 1 + /* 2 + * Copyright 2007 Red Hat, Inc. 3 + * by Peter Jones <pjones@redhat.com> 4 + * Copyright 2007 IBM, Inc. 5 + * by Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 6 + * Copyright 2008 7 + * by Konrad Rzeszutek <ketuzsezr@darnok.org> 8 + * 9 + * This code finds the iSCSI Boot Format Table. 10 + * 11 + * This program is free software; you can redistribute it and/or modify 12 + * it under the terms of the GNU General Public License v2.0 as published by 13 + * the Free Software Foundation 14 + * 15 + * This program is distributed in the hope that it will be useful, 16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 + * GNU General Public License for more details. 19 + */ 20 + 21 + #include <linux/bootmem.h> 22 + #include <linux/blkdev.h> 23 + #include <linux/ctype.h> 24 + #include <linux/device.h> 25 + #include <linux/err.h> 26 + #include <linux/init.h> 27 + #include <linux/limits.h> 28 + #include <linux/module.h> 29 + #include <linux/pci.h> 30 + #include <linux/slab.h> 31 + #include <linux/stat.h> 32 + #include <linux/string.h> 33 + #include <linux/types.h> 34 + 35 + #include <asm/mmzone.h> 36 + 37 + /* 38 + * Physical location of iSCSI Boot Format Table. 39 + */ 40 + struct ibft_table_header *ibft_addr; 41 + EXPORT_SYMBOL_GPL(ibft_addr); 42 + 43 + #define IBFT_SIGN "iBFT" 44 + #define IBFT_SIGN_LEN 4 45 + #define IBFT_START 0x80000 /* 512kB */ 46 + #define IBFT_END 0x100000 /* 1MB */ 47 + #define VGA_MEM 0xA0000 /* VGA buffer */ 48 + #define VGA_SIZE 0x20000 /* 128kB */ 49 + 50 + 51 + /* 52 + * Routine used to find the iSCSI Boot Format Table. The logical 53 + * kernel address is set in the ibft_addr global variable. 54 + */ 55 + void __init reserve_ibft_region(void) 56 + { 57 + unsigned long pos; 58 + unsigned int len = 0; 59 + void *virt; 60 + 61 + ibft_addr = 0; 62 + 63 + for (pos = IBFT_START; pos < IBFT_END; pos += 16) { 64 + /* The table can't be inside the VGA BIOS reserved space, 65 + * so skip that area */ 66 + if (pos == VGA_MEM) 67 + pos += VGA_SIZE; 68 + virt = phys_to_virt(pos); 69 + if (memcmp(virt, IBFT_SIGN, IBFT_SIGN_LEN) == 0) { 70 + unsigned long *addr = 71 + (unsigned long *)phys_to_virt(pos + 4); 72 + len = *addr; 73 + /* if the length of the table extends past 1M, 74 + * the table cannot be valid. */ 75 + if (pos + len <= (IBFT_END-1)) { 76 + ibft_addr = (struct ibft_table_header *)virt; 77 + break; 78 + } 79 + } 80 + } 81 + if (ibft_addr) 82 + reserve_bootmem(pos, PAGE_ALIGN(len), BOOTMEM_DEFAULT); 83 + } 84 + EXPORT_SYMBOL_GPL(reserve_ibft_region);
+39 -35
drivers/infiniband/core/sysfs.c
··· 427 427 .default_attrs = port_default_attrs 428 428 }; 429 429 430 - static void ib_device_release(struct class_device *cdev) 430 + static void ib_device_release(struct device *device) 431 431 { 432 - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 432 + struct ib_device *dev = container_of(device, struct ib_device, dev); 433 433 434 434 kfree(dev); 435 435 } 436 436 437 - static int ib_device_uevent(struct class_device *cdev, 437 + static int ib_device_uevent(struct device *device, 438 438 struct kobj_uevent_env *env) 439 439 { 440 - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 440 + struct ib_device *dev = container_of(device, struct ib_device, dev); 441 441 442 442 if (add_uevent_var(env, "NAME=%s", dev->name)) 443 443 return -ENOMEM; ··· 567 567 return ret; 568 568 } 569 569 570 - static ssize_t show_node_type(struct class_device *cdev, char *buf) 570 + static ssize_t show_node_type(struct device *device, 571 + struct device_attribute *attr, char *buf) 571 572 { 572 - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 573 + struct ib_device *dev = container_of(device, struct ib_device, dev); 573 574 574 575 if (!ibdev_is_alive(dev)) 575 576 return -ENODEV; ··· 584 583 } 585 584 } 586 585 587 - static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) 586 + static ssize_t show_sys_image_guid(struct device *device, 587 + struct device_attribute *dev_attr, char *buf) 588 588 { 589 - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 589 + struct ib_device *dev = container_of(device, struct ib_device, dev); 590 590 struct ib_device_attr attr; 591 591 ssize_t ret; 592 592 ··· 605 603 be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3])); 606 604 } 607 605 608 - static ssize_t show_node_guid(struct class_device *cdev, char *buf) 606 + static ssize_t show_node_guid(struct device *device, 607 + struct device_attribute *attr, char *buf) 609 608 { 610 - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 609 + struct ib_device *dev = container_of(device, struct ib_device, dev); 611 610 612 611 if (!ibdev_is_alive(dev)) 613 612 return -ENODEV; ··· 620 617 be16_to_cpu(((__be16 *) &dev->node_guid)[3])); 621 618 } 622 619 623 - static ssize_t show_node_desc(struct class_device *cdev, char *buf) 620 + static ssize_t show_node_desc(struct device *device, 621 + struct device_attribute *attr, char *buf) 624 622 { 625 - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 623 + struct ib_device *dev = container_of(device, struct ib_device, dev); 626 624 627 625 return sprintf(buf, "%.64s\n", dev->node_desc); 628 626 } 629 627 630 - static ssize_t set_node_desc(struct class_device *cdev, const char *buf, 631 - size_t count) 628 + static ssize_t set_node_desc(struct device *device, 629 + struct device_attribute *attr, 630 + const char *buf, size_t count) 632 631 { 633 - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 632 + struct ib_device *dev = container_of(device, struct ib_device, dev); 634 633 struct ib_device_modify desc = {}; 635 634 int ret; 636 635 ··· 647 642 return count; 648 643 } 649 644 650 - static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); 651 - static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); 652 - static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); 653 - static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, 654 - set_node_desc); 645 + static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); 646 + static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); 647 + static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); 648 + static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc); 655 649 656 - static struct class_device_attribute *ib_class_attributes[] = { 657 - &class_device_attr_node_type, 658 - &class_device_attr_sys_image_guid, 659 - &class_device_attr_node_guid, 660 - &class_device_attr_node_desc 650 + static struct device_attribute *ib_class_attributes[] = { 651 + &dev_attr_node_type, 652 + &dev_attr_sys_image_guid, 653 + &dev_attr_node_guid, 654 + &dev_attr_node_desc 661 655 }; 662 656 663 657 static struct class ib_class = { 664 658 .name = "infiniband", 665 - .release = ib_device_release, 666 - .uevent = ib_device_uevent, 659 + .dev_release = ib_device_release, 660 + .dev_uevent = ib_device_uevent, 667 661 }; 668 662 669 663 int ib_device_register_sysfs(struct ib_device *device) 670 664 { 671 - struct class_device *class_dev = &device->class_dev; 665 + struct device *class_dev = &device->dev; 672 666 int ret; 673 667 int i; 674 668 675 669 class_dev->class = &ib_class; 676 - class_dev->class_data = device; 677 - class_dev->dev = device->dma_device; 678 - strlcpy(class_dev->class_id, device->name, BUS_ID_SIZE); 670 + class_dev->driver_data = device; 671 + class_dev->parent = device->dma_device; 672 + strlcpy(class_dev->bus_id, device->name, BUS_ID_SIZE); 679 673 680 674 INIT_LIST_HEAD(&device->port_list); 681 675 682 - ret = class_device_register(class_dev); 676 + ret = device_register(class_dev); 683 677 if (ret) 684 678 goto err; 685 679 686 680 for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) { 687 - ret = class_device_create_file(class_dev, ib_class_attributes[i]); 681 + ret = device_create_file(class_dev, ib_class_attributes[i]); 688 682 if (ret) 689 683 goto err_unregister; 690 684 } ··· 727 723 kobject_put(&class_dev->kobj); 728 724 729 725 err_unregister: 730 - class_device_unregister(class_dev); 726 + device_unregister(class_dev); 731 727 732 728 err: 733 729 return ret; ··· 748 744 } 749 745 750 746 kobject_put(device->ports_parent); 751 - class_device_unregister(&device->class_dev); 747 + device_unregister(&device->dev); 752 748 } 753 749 754 750 int ib_sysfs_setup(void)
+31 -31
drivers/infiniband/core/ucm.c
··· 58 58 59 59 struct ib_ucm_device { 60 60 int devnum; 61 - struct cdev dev; 62 - struct class_device class_dev; 61 + struct cdev cdev; 62 + struct device dev; 63 63 struct ib_device *ib_dev; 64 64 }; 65 65 ··· 1171 1171 1172 1172 filp->private_data = file; 1173 1173 file->filp = filp; 1174 - file->device = container_of(inode->i_cdev, struct ib_ucm_device, dev); 1174 + file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev); 1175 1175 1176 1176 return 0; 1177 1177 } ··· 1202 1202 return 0; 1203 1203 } 1204 1204 1205 - static void ucm_release_class_dev(struct class_device *class_dev) 1205 + static void ib_ucm_release_dev(struct device *dev) 1206 1206 { 1207 - struct ib_ucm_device *dev; 1207 + struct ib_ucm_device *ucm_dev; 1208 1208 1209 - dev = container_of(class_dev, struct ib_ucm_device, class_dev); 1210 - cdev_del(&dev->dev); 1211 - clear_bit(dev->devnum, dev_map); 1212 - kfree(dev); 1209 + ucm_dev = container_of(dev, struct ib_ucm_device, dev); 1210 + cdev_del(&ucm_dev->cdev); 1211 + clear_bit(ucm_dev->devnum, dev_map); 1212 + kfree(ucm_dev); 1213 1213 } 1214 1214 1215 1215 static const struct file_operations ucm_fops = { ··· 1220 1220 .poll = ib_ucm_poll, 1221 1221 }; 1222 1222 1223 - static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 1223 + static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, 1224 + char *buf) 1224 1225 { 1225 - struct ib_ucm_device *dev; 1226 + struct ib_ucm_device *ucm_dev; 1226 1227 1227 - dev = container_of(class_dev, struct ib_ucm_device, class_dev); 1228 - return sprintf(buf, "%s\n", dev->ib_dev->name); 1228 + ucm_dev = container_of(dev, struct ib_ucm_device, dev); 1229 + return sprintf(buf, "%s\n", ucm_dev->ib_dev->name); 1229 1230 } 1230 - static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 1231 + static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 1231 1232 1232 1233 static void ib_ucm_add_one(struct ib_device *device) 1233 1234 { ··· 1250 1249 1251 1250 set_bit(ucm_dev->devnum, dev_map); 1252 1251 1253 - cdev_init(&ucm_dev->dev, &ucm_fops); 1254 - ucm_dev->dev.owner = THIS_MODULE; 1255 - kobject_set_name(&ucm_dev->dev.kobj, "ucm%d", ucm_dev->devnum); 1256 - if (cdev_add(&ucm_dev->dev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) 1252 + cdev_init(&ucm_dev->cdev, &ucm_fops); 1253 + ucm_dev->cdev.owner = THIS_MODULE; 1254 + kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum); 1255 + if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) 1257 1256 goto err; 1258 1257 1259 - ucm_dev->class_dev.class = &cm_class; 1260 - ucm_dev->class_dev.dev = device->dma_device; 1261 - ucm_dev->class_dev.devt = ucm_dev->dev.dev; 1262 - ucm_dev->class_dev.release = ucm_release_class_dev; 1263 - snprintf(ucm_dev->class_dev.class_id, BUS_ID_SIZE, "ucm%d", 1258 + ucm_dev->dev.class = &cm_class; 1259 + ucm_dev->dev.parent = device->dma_device; 1260 + ucm_dev->dev.devt = ucm_dev->cdev.dev; 1261 + ucm_dev->dev.release = ib_ucm_release_dev; 1262 + snprintf(ucm_dev->dev.bus_id, BUS_ID_SIZE, "ucm%d", 1264 1263 ucm_dev->devnum); 1265 - if (class_device_register(&ucm_dev->class_dev)) 1264 + if (device_register(&ucm_dev->dev)) 1266 1265 goto err_cdev; 1267 1266 1268 - if (class_device_create_file(&ucm_dev->class_dev, 1269 - &class_device_attr_ibdev)) 1270 - goto err_class; 1267 + if (device_create_file(&ucm_dev->dev, &dev_attr_ibdev)) 1268 + goto err_dev; 1271 1269 1272 1270 ib_set_client_data(device, &ucm_client, ucm_dev); 1273 1271 return; 1274 1272 1275 - err_class: 1276 - class_device_unregister(&ucm_dev->class_dev); 1273 + err_dev: 1274 + device_unregister(&ucm_dev->dev); 1277 1275 err_cdev: 1278 - cdev_del(&ucm_dev->dev); 1276 + cdev_del(&ucm_dev->cdev); 1279 1277 clear_bit(ucm_dev->devnum, dev_map); 1280 1278 err: 1281 1279 kfree(ucm_dev); ··· 1288 1288 if (!ucm_dev) 1289 1289 return; 1290 1290 1291 - class_device_unregister(&ucm_dev->class_dev); 1291 + device_unregister(&ucm_dev->dev); 1292 1292 } 1293 1293 1294 1294 static ssize_t show_abi_version(struct class *class, char *buf)
+54 -53
drivers/infiniband/core/user_mad.c
··· 88 88 */ 89 89 90 90 struct ib_umad_port { 91 - struct cdev *dev; 92 - struct class_device *class_dev; 91 + struct cdev *cdev; 92 + struct device *dev; 93 93 94 - struct cdev *sm_dev; 95 - struct class_device *sm_class_dev; 94 + struct cdev *sm_cdev; 95 + struct device *sm_dev; 96 96 struct semaphore sm_sem; 97 97 98 98 struct mutex file_mutex; ··· 948 948 .remove = ib_umad_remove_one 949 949 }; 950 950 951 - static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 951 + static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, 952 + char *buf) 952 953 { 953 - struct ib_umad_port *port = class_get_devdata(class_dev); 954 + struct ib_umad_port *port = dev_get_drvdata(dev); 954 955 955 956 if (!port) 956 957 return -ENODEV; 957 958 958 959 return sprintf(buf, "%s\n", port->ib_dev->name); 959 960 } 960 - static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 961 + static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 961 962 962 - static ssize_t show_port(struct class_device *class_dev, char *buf) 963 + static ssize_t show_port(struct device *dev, struct device_attribute *attr, 964 + char *buf) 963 965 { 964 - struct ib_umad_port *port = class_get_devdata(class_dev); 966 + struct ib_umad_port *port = dev_get_drvdata(dev); 965 967 966 968 if (!port) 967 969 return -ENODEV; 968 970 969 971 return sprintf(buf, "%d\n", port->port_num); 970 972 } 971 - static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 973 + static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 972 974 973 975 static ssize_t show_abi_version(struct class *class, char *buf) 974 976 { ··· 996 994 mutex_init(&port->file_mutex); 997 995 INIT_LIST_HEAD(&port->file_list); 998 996 999 - port->dev = cdev_alloc(); 1000 - if (!port->dev) 997 + port->cdev = cdev_alloc(); 998 + if (!port->cdev) 1001 999 return -1; 1002 - port->dev->owner = THIS_MODULE; 1003 - port->dev->ops = &umad_fops; 1004 - kobject_set_name(&port->dev->kobj, "umad%d", port->dev_num); 1005 - if (cdev_add(port->dev, base_dev + port->dev_num, 1)) 1000 + port->cdev->owner = THIS_MODULE; 1001 + port->cdev->ops = &umad_fops; 1002 + kobject_set_name(&port->cdev->kobj, "umad%d", port->dev_num); 1003 + if (cdev_add(port->cdev, base_dev + port->dev_num, 1)) 1006 1004 goto err_cdev; 1007 1005 1008 - port->class_dev = class_device_create(umad_class, NULL, port->dev->dev, 1009 - device->dma_device, 1010 - "umad%d", port->dev_num); 1011 - if (IS_ERR(port->class_dev)) 1006 + port->dev = device_create(umad_class, device->dma_device, 1007 + port->cdev->dev, "umad%d", port->dev_num); 1008 + if (IS_ERR(port->dev)) 1012 1009 goto err_cdev; 1013 1010 1014 - if (class_device_create_file(port->class_dev, &class_device_attr_ibdev)) 1015 - goto err_class; 1016 - if (class_device_create_file(port->class_dev, &class_device_attr_port)) 1017 - goto err_class; 1011 + if (device_create_file(port->dev, &dev_attr_ibdev)) 1012 + goto err_dev; 1013 + if (device_create_file(port->dev, &dev_attr_port)) 1014 + goto err_dev; 1018 1015 1019 - port->sm_dev = cdev_alloc(); 1020 - if (!port->sm_dev) 1021 - goto err_class; 1022 - port->sm_dev->owner = THIS_MODULE; 1023 - port->sm_dev->ops = &umad_sm_fops; 1024 - kobject_set_name(&port->sm_dev->kobj, "issm%d", port->dev_num); 1025 - if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) 1016 + port->sm_cdev = cdev_alloc(); 1017 + if (!port->sm_cdev) 1018 + goto err_dev; 1019 + port->sm_cdev->owner = THIS_MODULE; 1020 + port->sm_cdev->ops = &umad_sm_fops; 1021 + kobject_set_name(&port->sm_cdev->kobj, "issm%d", port->dev_num); 1022 + if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) 1026 1023 goto err_sm_cdev; 1027 1024 1028 - port->sm_class_dev = class_device_create(umad_class, NULL, port->sm_dev->dev, 1029 - device->dma_device, 1030 - "issm%d", port->dev_num); 1031 - if (IS_ERR(port->sm_class_dev)) 1025 + port->sm_dev = device_create(umad_class, device->dma_device, 1026 + port->sm_cdev->dev, 1027 + "issm%d", port->dev_num); 1028 + if (IS_ERR(port->sm_dev)) 1032 1029 goto err_sm_cdev; 1033 1030 1034 - class_set_devdata(port->class_dev, port); 1035 - class_set_devdata(port->sm_class_dev, port); 1031 + dev_set_drvdata(port->dev, port); 1032 + dev_set_drvdata(port->sm_dev, port); 1036 1033 1037 - if (class_device_create_file(port->sm_class_dev, &class_device_attr_ibdev)) 1038 - goto err_sm_class; 1039 - if (class_device_create_file(port->sm_class_dev, &class_device_attr_port)) 1040 - goto err_sm_class; 1034 + if (device_create_file(port->sm_dev, &dev_attr_ibdev)) 1035 + goto err_sm_dev; 1036 + if (device_create_file(port->sm_dev, &dev_attr_port)) 1037 + goto err_sm_dev; 1041 1038 1042 1039 spin_lock(&port_lock); 1043 1040 umad_port[port->dev_num] = port; ··· 1044 1043 1045 1044 return 0; 1046 1045 1047 - err_sm_class: 1048 - class_device_destroy(umad_class, port->sm_dev->dev); 1046 + err_sm_dev: 1047 + device_destroy(umad_class, port->sm_cdev->dev); 1049 1048 1050 1049 err_sm_cdev: 1051 - cdev_del(port->sm_dev); 1050 + cdev_del(port->sm_cdev); 1052 1051 1053 - err_class: 1054 - class_device_destroy(umad_class, port->dev->dev); 1052 + err_dev: 1053 + device_destroy(umad_class, port->cdev->dev); 1055 1054 1056 1055 err_cdev: 1057 - cdev_del(port->dev); 1056 + cdev_del(port->cdev); 1058 1057 clear_bit(port->dev_num, dev_map); 1059 1058 1060 1059 return -1; ··· 1066 1065 int already_dead; 1067 1066 int id; 1068 1067 1069 - class_set_devdata(port->class_dev, NULL); 1070 - class_set_devdata(port->sm_class_dev, NULL); 1068 + dev_set_drvdata(port->dev, NULL); 1069 + dev_set_drvdata(port->sm_dev, NULL); 1071 1070 1072 - class_device_destroy(umad_class, port->dev->dev); 1073 - class_device_destroy(umad_class, port->sm_dev->dev); 1071 + device_destroy(umad_class, port->cdev->dev); 1072 + device_destroy(umad_class, port->sm_cdev->dev); 1074 1073 1075 - cdev_del(port->dev); 1076 - cdev_del(port->sm_dev); 1074 + cdev_del(port->cdev); 1075 + cdev_del(port->sm_cdev); 1077 1076 1078 1077 spin_lock(&port_lock); 1079 1078 umad_port[port->dev_num] = NULL;
+2 -2
drivers/infiniband/core/uverbs.h
··· 73 73 struct kref ref; 74 74 struct completion comp; 75 75 int devnum; 76 - struct cdev *dev; 77 - struct class_device *class_dev; 76 + struct cdev *cdev; 77 + struct device *dev; 78 78 struct ib_device *ib_dev; 79 79 int num_comp_vectors; 80 80 };
+26 -25
drivers/infiniband/core/uverbs_main.c
··· 690 690 .remove = ib_uverbs_remove_one 691 691 }; 692 692 693 - static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 693 + static ssize_t show_ibdev(struct device *device, struct device_attribute *attr, 694 + char *buf) 694 695 { 695 - struct ib_uverbs_device *dev = class_get_devdata(class_dev); 696 + struct ib_uverbs_device *dev = dev_get_drvdata(device); 696 697 697 698 if (!dev) 698 699 return -ENODEV; 699 700 700 701 return sprintf(buf, "%s\n", dev->ib_dev->name); 701 702 } 702 - static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 703 + static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 703 704 704 - static ssize_t show_dev_abi_version(struct class_device *class_dev, char *buf) 705 + static ssize_t show_dev_abi_version(struct device *device, 706 + struct device_attribute *attr, char *buf) 705 707 { 706 - struct ib_uverbs_device *dev = class_get_devdata(class_dev); 708 + struct ib_uverbs_device *dev = dev_get_drvdata(device); 707 709 708 710 if (!dev) 709 711 return -ENODEV; 710 712 711 713 return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver); 712 714 } 713 - static CLASS_DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); 715 + static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); 714 716 715 717 static ssize_t show_abi_version(struct class *class, char *buf) 716 718 { ··· 746 744 uverbs_dev->ib_dev = device; 747 745 uverbs_dev->num_comp_vectors = device->num_comp_vectors; 748 746 749 - uverbs_dev->dev = cdev_alloc(); 750 - if (!uverbs_dev->dev) 747 + uverbs_dev->cdev = cdev_alloc(); 748 + if (!uverbs_dev->cdev) 751 749 goto err; 752 - uverbs_dev->dev->owner = THIS_MODULE; 753 - uverbs_dev->dev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; 754 - kobject_set_name(&uverbs_dev->dev->kobj, "uverbs%d", uverbs_dev->devnum); 755 - if (cdev_add(uverbs_dev->dev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) 750 + uverbs_dev->cdev->owner = THIS_MODULE; 751 + uverbs_dev->cdev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; 752 + kobject_set_name(&uverbs_dev->cdev->kobj, "uverbs%d", uverbs_dev->devnum); 753 + if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) 756 754 goto err_cdev; 757 755 758 - uverbs_dev->class_dev = class_device_create(uverbs_class, NULL, 759 - uverbs_dev->dev->dev, 760 - device->dma_device, 761 - "uverbs%d", uverbs_dev->devnum); 762 - if (IS_ERR(uverbs_dev->class_dev)) 756 + uverbs_dev->dev = device_create(uverbs_class, device->dma_device, 757 + uverbs_dev->cdev->dev, 758 + "uverbs%d", uverbs_dev->devnum); 759 + if (IS_ERR(uverbs_dev->dev)) 763 760 goto err_cdev; 764 761 765 - class_set_devdata(uverbs_dev->class_dev, uverbs_dev); 762 + dev_set_drvdata(uverbs_dev->dev, uverbs_dev); 766 763 767 - if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_ibdev)) 764 + if (device_create_file(uverbs_dev->dev, &dev_attr_ibdev)) 768 765 goto err_class; 769 - if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_abi_version)) 766 + if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version)) 770 767 goto err_class; 771 768 772 769 spin_lock(&map_lock); ··· 777 776 return; 778 777 779 778 err_class: 780 - class_device_destroy(uverbs_class, uverbs_dev->dev->dev); 779 + device_destroy(uverbs_class, uverbs_dev->cdev->dev); 781 780 782 781 err_cdev: 783 - cdev_del(uverbs_dev->dev); 782 + cdev_del(uverbs_dev->cdev); 784 783 clear_bit(uverbs_dev->devnum, dev_map); 785 784 786 785 err: ··· 797 796 if (!uverbs_dev) 798 797 return; 799 798 800 - class_set_devdata(uverbs_dev->class_dev, NULL); 801 - class_device_destroy(uverbs_class, uverbs_dev->dev->dev); 802 - cdev_del(uverbs_dev->dev); 799 + dev_set_drvdata(uverbs_dev->dev, NULL); 800 + device_destroy(uverbs_class, uverbs_dev->cdev->dev); 801 + cdev_del(uverbs_dev->cdev); 803 802 804 803 spin_lock(&map_lock); 805 804 dev_table[uverbs_dev->devnum] = NULL;
+26 -22
drivers/infiniband/hw/amso1100/c2_provider.c
··· 523 523 return err; 524 524 } 525 525 526 - static ssize_t show_rev(struct class_device *cdev, char *buf) 526 + static ssize_t show_rev(struct device *dev, struct device_attribute *attr, 527 + char *buf) 527 528 { 528 - struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev); 529 + struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev); 529 530 pr_debug("%s:%u\n", __func__, __LINE__); 530 - return sprintf(buf, "%x\n", dev->props.hw_ver); 531 + return sprintf(buf, "%x\n", c2dev->props.hw_ver); 531 532 } 532 533 533 - static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 534 + static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, 535 + char *buf) 534 536 { 535 - struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev); 537 + struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev); 536 538 pr_debug("%s:%u\n", __func__, __LINE__); 537 539 return sprintf(buf, "%x.%x.%x\n", 538 - (int) (dev->props.fw_ver >> 32), 539 - (int) (dev->props.fw_ver >> 16) & 0xffff, 540 - (int) (dev->props.fw_ver & 0xffff)); 540 + (int) (c2dev->props.fw_ver >> 32), 541 + (int) (c2dev->props.fw_ver >> 16) & 0xffff, 542 + (int) (c2dev->props.fw_ver & 0xffff)); 541 543 } 542 544 543 - static ssize_t show_hca(struct class_device *cdev, char *buf) 545 + static ssize_t show_hca(struct device *dev, struct device_attribute *attr, 546 + char *buf) 544 547 { 545 548 pr_debug("%s:%u\n", __func__, __LINE__); 546 549 return sprintf(buf, "AMSO1100\n"); 547 550 } 548 551 549 - static ssize_t show_board(struct class_device *cdev, char *buf) 552 + static ssize_t show_board(struct device *dev, struct device_attribute *attr, 553 + char *buf) 550 554 { 551 555 pr_debug("%s:%u\n", __func__, __LINE__); 552 556 return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID"); 553 557 } 554 558 555 - static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 556 - static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 557 - static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 558 - static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 559 + static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 560 + static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 561 + static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 562 + static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 559 563 560 - static struct class_device_attribute *c2_class_attributes[] = { 561 - &class_device_attr_hw_rev, 562 - &class_device_attr_fw_ver, 563 - &class_device_attr_hca_type, 564 - &class_device_attr_board_id 564 + static struct device_attribute *c2_dev_attributes[] = { 565 + &dev_attr_hw_rev, 566 + &dev_attr_fw_ver, 567 + &dev_attr_hca_type, 568 + &dev_attr_board_id 565 569 }; 566 570 567 571 static int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, ··· 865 861 if (ret) 866 862 goto out1; 867 863 868 - for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) { 869 - ret = class_device_create_file(&dev->ibdev.class_dev, 870 - c2_class_attributes[i]); 864 + for (i = 0; i < ARRAY_SIZE(c2_dev_attributes); ++i) { 865 + ret = device_create_file(&dev->ibdev.dev, 866 + c2_dev_attributes[i]); 871 867 if (ret) 872 868 goto out0; 873 869 }
+37 -38
drivers/infiniband/hw/cxgb3/iwch_provider.c
··· 1041 1041 return 0; 1042 1042 } 1043 1043 1044 - static ssize_t show_rev(struct class_device *cdev, char *buf) 1044 + static ssize_t show_rev(struct device *dev, struct device_attribute *attr, 1045 + char *buf) 1045 1046 { 1046 - struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1047 - ibdev.class_dev); 1048 - PDBG("%s class dev 0x%p\n", __func__, cdev); 1049 - return sprintf(buf, "%d\n", dev->rdev.t3cdev_p->type); 1047 + struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, 1048 + ibdev.dev); 1049 + PDBG("%s dev 0x%p\n", __func__, dev); 1050 + return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type); 1050 1051 } 1051 1052 1052 - static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 1053 + static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) 1053 1054 { 1054 - struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1055 - ibdev.class_dev); 1055 + struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, 1056 + ibdev.dev); 1056 1057 struct ethtool_drvinfo info; 1057 - struct net_device *lldev = dev->rdev.t3cdev_p->lldev; 1058 + struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; 1058 1059 1059 - PDBG("%s class dev 0x%p\n", __func__, cdev); 1060 - rtnl_lock(); 1060 + PDBG("%s dev 0x%p\n", __func__, dev); 1061 1061 lldev->ethtool_ops->get_drvinfo(lldev, &info); 1062 - rtnl_unlock(); 1063 1062 return sprintf(buf, "%s\n", info.fw_version); 1064 1063 } 1065 1064 1066 - static ssize_t show_hca(struct class_device *cdev, char *buf) 1065 + static ssize_t show_hca(struct device *dev, struct device_attribute *attr, 1066 + char *buf) 1067 1067 { 1068 - struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1069 - ibdev.class_dev); 1068 + struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, 1069 + ibdev.dev); 1070 1070 struct ethtool_drvinfo info; 1071 - struct net_device *lldev = dev->rdev.t3cdev_p->lldev; 1071 + struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; 1072 1072 1073 - PDBG("%s class dev 0x%p\n", __func__, cdev); 1074 - rtnl_lock(); 1073 + PDBG("%s dev 0x%p\n", __func__, dev); 1075 1074 lldev->ethtool_ops->get_drvinfo(lldev, &info); 1076 - rtnl_unlock(); 1077 1075 return sprintf(buf, "%s\n", info.driver); 1078 1076 } 1079 1077 1080 - static ssize_t show_board(struct class_device *cdev, char *buf) 1078 + static ssize_t show_board(struct device *dev, struct device_attribute *attr, 1079 + char *buf) 1081 1080 { 1082 - struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1083 - ibdev.class_dev); 1084 - PDBG("%s class dev 0x%p\n", __func__, dev); 1085 - return sprintf(buf, "%x.%x\n", dev->rdev.rnic_info.pdev->vendor, 1086 - dev->rdev.rnic_info.pdev->device); 1081 + struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, 1082 + ibdev.dev); 1083 + PDBG("%s dev 0x%p\n", __func__, dev); 1084 + return sprintf(buf, "%x.%x\n", iwch_dev->rdev.rnic_info.pdev->vendor, 1085 + iwch_dev->rdev.rnic_info.pdev->device); 1087 1086 } 1088 1087 1089 - static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 1090 - static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 1091 - static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 1092 - static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 1088 + static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 1089 + static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 1090 + static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 1091 + static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 1093 1092 1094 - static struct class_device_attribute *iwch_class_attributes[] = { 1095 - &class_device_attr_hw_rev, 1096 - &class_device_attr_fw_ver, 1097 - &class_device_attr_hca_type, 1098 - &class_device_attr_board_id 1093 + static struct device_attribute *iwch_class_attributes[] = { 1094 + &dev_attr_hw_rev, 1095 + &dev_attr_fw_ver, 1096 + &dev_attr_hca_type, 1097 + &dev_attr_board_id 1099 1098 }; 1100 1099 1101 1100 int iwch_register_device(struct iwch_dev *dev) ··· 1188 1189 goto bail1; 1189 1190 1190 1191 for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) { 1191 - ret = class_device_create_file(&dev->ibdev.class_dev, 1192 - iwch_class_attributes[i]); 1192 + ret = device_create_file(&dev->ibdev.dev, 1193 + iwch_class_attributes[i]); 1193 1194 if (ret) { 1194 1195 goto bail2; 1195 1196 } ··· 1207 1208 1208 1209 PDBG("%s iwch_dev %p\n", __func__, dev); 1209 1210 for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) 1210 - class_device_remove_file(&dev->ibdev.class_dev, 1211 - iwch_class_attributes[i]); 1211 + device_remove_file(&dev->ibdev.dev, 1212 + iwch_class_attributes[i]); 1212 1213 ib_unregister_device(&dev->ibdev); 1213 1214 return; 1214 1215 }
+5 -5
drivers/infiniband/hw/ipath/ipath_diag.c
··· 79 79 80 80 static atomic_t diagpkt_count = ATOMIC_INIT(0); 81 81 static struct cdev *diagpkt_cdev; 82 - static struct class_device *diagpkt_class_dev; 82 + static struct device *diagpkt_dev; 83 83 84 84 int ipath_diag_add(struct ipath_devdata *dd) 85 85 { ··· 89 89 if (atomic_inc_return(&diagpkt_count) == 1) { 90 90 ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR, 91 91 "ipath_diagpkt", &diagpkt_file_ops, 92 - &diagpkt_cdev, &diagpkt_class_dev); 92 + &diagpkt_cdev, &diagpkt_dev); 93 93 94 94 if (ret) { 95 95 ipath_dev_err(dd, "Couldn't create ipath_diagpkt " ··· 102 102 103 103 ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name, 104 104 &diag_file_ops, &dd->diag_cdev, 105 - &dd->diag_class_dev); 105 + &dd->diag_dev); 106 106 if (ret) 107 107 ipath_dev_err(dd, "Couldn't create %s device: %d", 108 108 name, ret); ··· 114 114 void ipath_diag_remove(struct ipath_devdata *dd) 115 115 { 116 116 if (atomic_dec_and_test(&diagpkt_count)) 117 - ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev); 117 + ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_dev); 118 118 119 - ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev); 119 + ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_dev); 120 120 } 121 121 122 122 /**
+22 -22
drivers/infiniband/hw/ipath/ipath_file_ops.c
··· 2434 2434 static struct class *ipath_class; 2435 2435 2436 2436 static int init_cdev(int minor, char *name, const struct file_operations *fops, 2437 - struct cdev **cdevp, struct class_device **class_devp) 2437 + struct cdev **cdevp, struct device **devp) 2438 2438 { 2439 2439 const dev_t dev = MKDEV(IPATH_MAJOR, minor); 2440 2440 struct cdev *cdev = NULL; 2441 - struct class_device *class_dev = NULL; 2441 + struct device *device = NULL; 2442 2442 int ret; 2443 2443 2444 2444 cdev = cdev_alloc(); ··· 2462 2462 goto err_cdev; 2463 2463 } 2464 2464 2465 - class_dev = class_device_create(ipath_class, NULL, dev, NULL, name); 2465 + device = device_create(ipath_class, NULL, dev, name); 2466 2466 2467 - if (IS_ERR(class_dev)) { 2468 - ret = PTR_ERR(class_dev); 2467 + if (IS_ERR(device)) { 2468 + ret = PTR_ERR(device); 2469 2469 printk(KERN_ERR IPATH_DRV_NAME ": Could not create " 2470 - "class_dev for minor %d, %s (err %d)\n", 2470 + "device for minor %d, %s (err %d)\n", 2471 2471 minor, name, -ret); 2472 2472 goto err_cdev; 2473 2473 } ··· 2481 2481 done: 2482 2482 if (ret >= 0) { 2483 2483 *cdevp = cdev; 2484 - *class_devp = class_dev; 2484 + *devp = device; 2485 2485 } else { 2486 2486 *cdevp = NULL; 2487 - *class_devp = NULL; 2487 + *devp = NULL; 2488 2488 } 2489 2489 2490 2490 return ret; 2491 2491 } 2492 2492 2493 2493 int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, 2494 - struct cdev **cdevp, struct class_device **class_devp) 2494 + struct cdev **cdevp, struct device **devp) 2495 2495 { 2496 - return init_cdev(minor, name, fops, cdevp, class_devp); 2496 + return init_cdev(minor, name, fops, cdevp, devp); 2497 2497 } 2498 2498 2499 2499 static void cleanup_cdev(struct cdev **cdevp, 2500 - struct class_device **class_devp) 2500 + struct device **devp) 2501 2501 { 2502 - struct class_device *class_dev = *class_devp; 2502 + struct device *dev = *devp; 2503 2503 2504 - if (class_dev) { 2505 - class_device_unregister(class_dev); 2506 - *class_devp = NULL; 2504 + if (dev) { 2505 + device_unregister(dev); 2506 + *devp = NULL; 2507 2507 } 2508 2508 2509 2509 if (*cdevp) { ··· 2513 2513 } 2514 2514 2515 2515 void ipath_cdev_cleanup(struct cdev **cdevp, 2516 - struct class_device **class_devp) 2516 + struct device **devp) 2517 2517 { 2518 - cleanup_cdev(cdevp, class_devp); 2518 + cleanup_cdev(cdevp, devp); 2519 2519 } 2520 2520 2521 2521 static struct cdev *wildcard_cdev; 2522 - static struct class_device *wildcard_class_dev; 2522 + static struct device *wildcard_dev; 2523 2523 2524 2524 static const dev_t dev = MKDEV(IPATH_MAJOR, 0); 2525 2525 ··· 2576 2576 goto bail; 2577 2577 } 2578 2578 ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev, 2579 - &wildcard_class_dev); 2579 + &wildcard_dev); 2580 2580 if (ret < 0) { 2581 2581 ipath_dev_err(dd, "Could not create wildcard " 2582 2582 "minor: error %d\n", -ret); ··· 2589 2589 snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit); 2590 2590 2591 2591 ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops, 2592 - &dd->user_cdev, &dd->user_class_dev); 2592 + &dd->user_cdev, &dd->user_dev); 2593 2593 if (ret < 0) 2594 2594 ipath_dev_err(dd, "Could not create user minor %d, %s\n", 2595 2595 dd->ipath_unit + 1, name); ··· 2604 2604 2605 2605 void ipath_user_remove(struct ipath_devdata *dd) 2606 2606 { 2607 - cleanup_cdev(&dd->user_cdev, &dd->user_class_dev); 2607 + cleanup_cdev(&dd->user_cdev, &dd->user_dev); 2608 2608 2609 2609 if (atomic_dec_return(&user_count) == 0) { 2610 2610 if (atomic_read(&user_setup) == 0) 2611 2611 goto bail; 2612 2612 2613 - cleanup_cdev(&wildcard_cdev, &wildcard_class_dev); 2613 + cleanup_cdev(&wildcard_cdev, &wildcard_dev); 2614 2614 user_cleanup(); 2615 2615 2616 2616 atomic_set(&user_setup, 0);
+4 -4
drivers/infiniband/hw/ipath/ipath_kernel.h
··· 466 466 struct pci_dev *pcidev; 467 467 struct cdev *user_cdev; 468 468 struct cdev *diag_cdev; 469 - struct class_device *user_class_dev; 470 - struct class_device *diag_class_dev; 469 + struct device *user_dev; 470 + struct device *diag_dev; 471 471 /* timer used to prevent stats overflow, error throttling, etc. */ 472 472 struct timer_list ipath_stats_timer; 473 473 /* timer to verify interrupts work, and fallback if possible */ ··· 854 854 855 855 struct file_operations; 856 856 int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, 857 - struct cdev **cdevp, struct class_device **class_devp); 857 + struct cdev **cdevp, struct device **devp); 858 858 void ipath_cdev_cleanup(struct cdev **cdevp, 859 - struct class_device **class_devp); 859 + struct device **devp); 860 860 861 861 int ipath_diag_add(struct ipath_devdata *); 862 862 void ipath_diag_remove(struct ipath_devdata *);
+20 -17
drivers/infiniband/hw/ipath/ipath_verbs.c
··· 2172 2172 ib_dealloc_device(ibdev); 2173 2173 } 2174 2174 2175 - static ssize_t show_rev(struct class_device *cdev, char *buf) 2175 + static ssize_t show_rev(struct device *device, struct device_attribute *attr, 2176 + char *buf) 2176 2177 { 2177 2178 struct ipath_ibdev *dev = 2178 - container_of(cdev, struct ipath_ibdev, ibdev.class_dev); 2179 + container_of(device, struct ipath_ibdev, ibdev.dev); 2179 2180 2180 2181 return sprintf(buf, "%x\n", dev->dd->ipath_pcirev); 2181 2182 } 2182 2183 2183 - static ssize_t show_hca(struct class_device *cdev, char *buf) 2184 + static ssize_t show_hca(struct device *device, struct device_attribute *attr, 2185 + char *buf) 2184 2186 { 2185 2187 struct ipath_ibdev *dev = 2186 - container_of(cdev, struct ipath_ibdev, ibdev.class_dev); 2188 + container_of(device, struct ipath_ibdev, ibdev.dev); 2187 2189 int ret; 2188 2190 2189 2191 ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128); ··· 2198 2196 return ret; 2199 2197 } 2200 2198 2201 - static ssize_t show_stats(struct class_device *cdev, char *buf) 2199 + static ssize_t show_stats(struct device *device, struct device_attribute *attr, 2200 + char *buf) 2202 2201 { 2203 2202 struct ipath_ibdev *dev = 2204 - container_of(cdev, struct ipath_ibdev, ibdev.class_dev); 2203 + container_of(device, struct ipath_ibdev, ibdev.dev); 2205 2204 int i; 2206 2205 int len; 2207 2206 ··· 2240 2237 return len; 2241 2238 } 2242 2239 2243 - static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 2244 - static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 2245 - static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); 2246 - static CLASS_DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); 2240 + static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 2241 + static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 2242 + static DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); 2243 + static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); 2247 2244 2248 - static struct class_device_attribute *ipath_class_attributes[] = { 2249 - &class_device_attr_hw_rev, 2250 - &class_device_attr_hca_type, 2251 - &class_device_attr_board_id, 2252 - &class_device_attr_stats 2245 + static struct device_attribute *ipath_class_attributes[] = { 2246 + &dev_attr_hw_rev, 2247 + &dev_attr_hca_type, 2248 + &dev_attr_board_id, 2249 + &dev_attr_stats 2253 2250 }; 2254 2251 2255 2252 static int ipath_verbs_register_sysfs(struct ib_device *dev) ··· 2258 2255 int ret; 2259 2256 2260 2257 for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) 2261 - if (class_device_create_file(&dev->class_dev, 2262 - ipath_class_attributes[i])) { 2258 + if (device_create_file(&dev->dev, 2259 + ipath_class_attributes[i])) { 2263 2260 ret = 1; 2264 2261 goto bail; 2265 2262 }
+29 -20
drivers/infiniband/hw/mlx4/main.c
··· 481 481 return err; 482 482 } 483 483 484 - static ssize_t show_hca(struct class_device *cdev, char *buf) 484 + static ssize_t show_hca(struct device *device, struct device_attribute *attr, 485 + char *buf) 485 486 { 486 - struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 487 + struct mlx4_ib_dev *dev = 488 + container_of(device, struct mlx4_ib_dev, ib_dev.dev); 487 489 return sprintf(buf, "MT%d\n", dev->dev->pdev->device); 488 490 } 489 491 490 - static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 492 + static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr, 493 + char *buf) 491 494 { 492 - struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 495 + struct mlx4_ib_dev *dev = 496 + container_of(device, struct mlx4_ib_dev, ib_dev.dev); 493 497 return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32), 494 498 (int) (dev->dev->caps.fw_ver >> 16) & 0xffff, 495 499 (int) dev->dev->caps.fw_ver & 0xffff); 496 500 } 497 501 498 - static ssize_t show_rev(struct class_device *cdev, char *buf) 502 + static ssize_t show_rev(struct device *device, struct device_attribute *attr, 503 + char *buf) 499 504 { 500 - struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 505 + struct mlx4_ib_dev *dev = 506 + container_of(device, struct mlx4_ib_dev, ib_dev.dev); 501 507 return sprintf(buf, "%x\n", dev->dev->rev_id); 502 508 } 503 509 504 - static ssize_t show_board(struct class_device *cdev, char *buf) 510 + static ssize_t show_board(struct device *device, struct device_attribute *attr, 511 + char *buf) 505 512 { 506 - struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 507 - return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN, dev->dev->board_id); 513 + struct mlx4_ib_dev *dev = 514 + container_of(device, struct mlx4_ib_dev, ib_dev.dev); 515 + return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN, 516 + dev->dev->board_id); 508 517 } 509 518 510 - static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 511 - static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 512 - static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 513 - static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 519 + static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 520 + static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 521 + static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 522 + static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 514 523 515 - static struct class_device_attribute *mlx4_class_attributes[] = { 516 - &class_device_attr_hw_rev, 517 - &class_device_attr_fw_ver, 518 - &class_device_attr_hca_type, 519 - &class_device_attr_board_id 524 + static struct device_attribute *mlx4_class_attributes[] = { 525 + &dev_attr_hw_rev, 526 + &dev_attr_fw_ver, 527 + &dev_attr_hca_type, 528 + &dev_attr_board_id 520 529 }; 521 530 522 531 static void *mlx4_ib_add(struct mlx4_dev *dev) ··· 649 640 goto err_reg; 650 641 651 642 for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) { 652 - if (class_device_create_file(&ibdev->ib_dev.class_dev, 653 - mlx4_class_attributes[i])) 643 + if (device_create_file(&ibdev->ib_dev.dev, 644 + mlx4_class_attributes[i])) 654 645 goto err_reg; 655 646 } 656 647
+28 -20
drivers/infiniband/hw/mthca/mthca_provider.c
··· 1170 1170 return 0; 1171 1171 } 1172 1172 1173 - static ssize_t show_rev(struct class_device *cdev, char *buf) 1173 + static ssize_t show_rev(struct device *device, struct device_attribute *attr, 1174 + char *buf) 1174 1175 { 1175 - struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1176 + struct mthca_dev *dev = 1177 + container_of(device, struct mthca_dev, ib_dev.dev); 1176 1178 return sprintf(buf, "%x\n", dev->rev_id); 1177 1179 } 1178 1180 1179 - static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 1181 + static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr, 1182 + char *buf) 1180 1183 { 1181 - struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1184 + struct mthca_dev *dev = 1185 + container_of(device, struct mthca_dev, ib_dev.dev); 1182 1186 return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32), 1183 1187 (int) (dev->fw_ver >> 16) & 0xffff, 1184 1188 (int) dev->fw_ver & 0xffff); 1185 1189 } 1186 1190 1187 - static ssize_t show_hca(struct class_device *cdev, char *buf) 1191 + static ssize_t show_hca(struct device *device, struct device_attribute *attr, 1192 + char *buf) 1188 1193 { 1189 - struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1194 + struct mthca_dev *dev = 1195 + container_of(device, struct mthca_dev, ib_dev.dev); 1190 1196 switch (dev->pdev->device) { 1191 1197 case PCI_DEVICE_ID_MELLANOX_TAVOR: 1192 1198 return sprintf(buf, "MT23108\n"); ··· 1208 1202 } 1209 1203 } 1210 1204 1211 - static ssize_t show_board(struct class_device *cdev, char *buf) 1205 + static ssize_t show_board(struct device *device, struct device_attribute *attr, 1206 + char *buf) 1212 1207 { 1213 - struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1208 + struct mthca_dev *dev = 1209 + container_of(device, struct mthca_dev, ib_dev.dev); 1214 1210 return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id); 1215 1211 } 1216 1212 1217 - static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 1218 - static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 1219 - static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 1220 - static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 1213 + static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 1214 + static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 1215 + static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 1216 + static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 1221 1217 1222 - static struct class_device_attribute *mthca_class_attributes[] = { 1223 - &class_device_attr_hw_rev, 1224 - &class_device_attr_fw_ver, 1225 - &class_device_attr_hca_type, 1226 - &class_device_attr_board_id 1218 + static struct device_attribute *mthca_dev_attributes[] = { 1219 + &dev_attr_hw_rev, 1220 + &dev_attr_fw_ver, 1221 + &dev_attr_hca_type, 1222 + &dev_attr_board_id 1227 1223 }; 1228 1224 1229 1225 static int mthca_init_node_data(struct mthca_dev *dev) ··· 1387 1379 if (ret) 1388 1380 return ret; 1389 1381 1390 - for (i = 0; i < ARRAY_SIZE(mthca_class_attributes); ++i) { 1391 - ret = class_device_create_file(&dev->ib_dev.class_dev, 1392 - mthca_class_attributes[i]); 1382 + for (i = 0; i < ARRAY_SIZE(mthca_dev_attributes); ++i) { 1383 + ret = device_create_file(&dev->ib_dev.dev, 1384 + mthca_dev_attributes[i]); 1393 1385 if (ret) { 1394 1386 ib_unregister_device(&dev->ib_dev); 1395 1387 return ret;
+26 -22
drivers/infiniband/hw/nes/nes_verbs.c
··· 2800 2800 /** 2801 2801 * show_rev 2802 2802 */ 2803 - static ssize_t show_rev(struct class_device *cdev, char *buf) 2803 + static ssize_t show_rev(struct device *dev, struct device_attribute *attr, 2804 + char *buf) 2804 2805 { 2805 2806 struct nes_ib_device *nesibdev = 2806 - container_of(cdev, struct nes_ib_device, ibdev.class_dev); 2807 + container_of(dev, struct nes_ib_device, ibdev.dev); 2807 2808 struct nes_vnic *nesvnic = nesibdev->nesvnic; 2808 2809 2809 2810 nes_debug(NES_DBG_INIT, "\n"); ··· 2815 2814 /** 2816 2815 * show_fw_ver 2817 2816 */ 2818 - static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 2817 + static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, 2818 + char *buf) 2819 2819 { 2820 2820 struct nes_ib_device *nesibdev = 2821 - container_of(cdev, struct nes_ib_device, ibdev.class_dev); 2821 + container_of(dev, struct nes_ib_device, ibdev.dev); 2822 2822 struct nes_vnic *nesvnic = nesibdev->nesvnic; 2823 2823 2824 2824 nes_debug(NES_DBG_INIT, "\n"); ··· 2833 2831 /** 2834 2832 * show_hca 2835 2833 */ 2836 - static ssize_t show_hca(struct class_device *cdev, char *buf) 2834 + static ssize_t show_hca(struct device *dev, struct device_attribute *attr, 2835 + char *buf) 2837 2836 { 2838 2837 nes_debug(NES_DBG_INIT, "\n"); 2839 2838 return sprintf(buf, "NES020\n"); ··· 2844 2841 /** 2845 2842 * show_board 2846 2843 */ 2847 - static ssize_t show_board(struct class_device *cdev, char *buf) 2844 + static ssize_t show_board(struct device *dev, struct device_attribute *attr, 2845 + char *buf) 2848 2846 { 2849 2847 nes_debug(NES_DBG_INIT, "\n"); 2850 2848 return sprintf(buf, "%.*s\n", 32, "NES020 Board ID"); 2851 2849 } 2852 2850 2853 2851 2854 - static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 2855 - static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 2856 - static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 2857 - static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 2852 + static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 2853 + static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 2854 + static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 2855 + static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 2858 2856 2859 - static struct class_device_attribute *nes_class_attributes[] = { 2860 - &class_device_attr_hw_rev, 2861 - &class_device_attr_fw_ver, 2862 - &class_device_attr_hca_type, 2863 - &class_device_attr_board_id 2857 + static struct device_attribute *nes_dev_attributes[] = { 2858 + &dev_attr_hw_rev, 2859 + &dev_attr_fw_ver, 2860 + &dev_attr_hca_type, 2861 + &dev_attr_board_id 2864 2862 }; 2865 2863 2866 2864 ··· 3786 3782 nesibdev->ibdev.phys_port_cnt = 1; 3787 3783 nesibdev->ibdev.num_comp_vectors = 1; 3788 3784 nesibdev->ibdev.dma_device = &nesdev->pcidev->dev; 3789 - nesibdev->ibdev.class_dev.dev = &nesdev->pcidev->dev; 3785 + nesibdev->ibdev.dev.parent = &nesdev->pcidev->dev; 3790 3786 nesibdev->ibdev.query_device = nes_query_device; 3791 3787 nesibdev->ibdev.query_port = nes_query_port; 3792 3788 nesibdev->ibdev.modify_port = nes_modify_port; ··· 3881 3877 nesibdev->max_qp = (nesadapter->max_qp-NES_FIRST_QPN) / nesadapter->port_count; 3882 3878 nesibdev->max_pd = nesadapter->max_pd / nesadapter->port_count; 3883 3879 3884 - for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) { 3885 - ret = class_device_create_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]); 3880 + for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) { 3881 + ret = device_create_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]); 3886 3882 if (ret) { 3887 3883 while (i > 0) { 3888 3884 i--; 3889 - class_device_remove_file(&nesibdev->ibdev.class_dev, 3890 - nes_class_attributes[i]); 3885 + device_remove_file(&nesibdev->ibdev.dev, 3886 + nes_dev_attributes[i]); 3891 3887 } 3892 3888 ib_unregister_device(&nesibdev->ibdev); 3893 3889 return ret; ··· 3908 3904 struct nes_vnic *nesvnic = nesibdev->nesvnic; 3909 3905 int i; 3910 3906 3911 - for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) { 3912 - class_device_remove_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]); 3907 + for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) { 3908 + device_remove_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]); 3913 3909 } 3914 3910 3915 3911 if (nesvnic->of_device_registered) {
+96 -83
drivers/infiniband/ulp/srp/ib_srp.c
··· 139 139 if (!iu->buf) 140 140 goto out_free_iu; 141 141 142 - iu->dma = ib_dma_map_single(host->dev->dev, iu->buf, size, direction); 143 - if (ib_dma_mapping_error(host->dev->dev, iu->dma)) 142 + iu->dma = ib_dma_map_single(host->srp_dev->dev, iu->buf, size, 143 + direction); 144 + if (ib_dma_mapping_error(host->srp_dev->dev, iu->dma)) 144 145 goto out_free_buf; 145 146 146 147 iu->size = size; ··· 162 161 if (!iu) 163 162 return; 164 163 165 - ib_dma_unmap_single(host->dev->dev, iu->dma, iu->size, iu->direction); 164 + ib_dma_unmap_single(host->srp_dev->dev, iu->dma, iu->size, 165 + iu->direction); 166 166 kfree(iu->buf); 167 167 kfree(iu); 168 168 } ··· 183 181 if (!attr) 184 182 return -ENOMEM; 185 183 186 - ret = ib_find_cached_pkey(target->srp_host->dev->dev, 184 + ret = ib_find_cached_pkey(target->srp_host->srp_dev->dev, 187 185 target->srp_host->port, 188 186 be16_to_cpu(target->path.pkey), 189 187 &attr->pkey_index); ··· 210 208 { 211 209 struct ib_cm_id *new_cm_id; 212 210 213 - new_cm_id = ib_create_cm_id(target->srp_host->dev->dev, 211 + new_cm_id = ib_create_cm_id(target->srp_host->srp_dev->dev, 214 212 srp_cm_handler, target); 215 213 if (IS_ERR(new_cm_id)) 216 214 return PTR_ERR(new_cm_id); ··· 231 229 if (!init_attr) 232 230 return -ENOMEM; 233 231 234 - target->cq = ib_create_cq(target->srp_host->dev->dev, srp_completion, 235 - NULL, target, SRP_CQ_SIZE, 0); 232 + target->cq = ib_create_cq(target->srp_host->srp_dev->dev, 233 + srp_completion, NULL, target, SRP_CQ_SIZE, 0); 236 234 if (IS_ERR(target->cq)) { 237 235 ret = PTR_ERR(target->cq); 238 236 goto out; ··· 250 248 init_attr->send_cq = target->cq; 251 249 init_attr->recv_cq = target->cq; 252 250 253 - target->qp = ib_create_qp(target->srp_host->dev->pd, init_attr); 251 + target->qp = ib_create_qp(target->srp_host->srp_dev->pd, init_attr); 254 252 if (IS_ERR(target->qp)) { 255 253 ret = PTR_ERR(target->qp); 256 254 ib_destroy_cq(target->cq); ··· 304 302 init_completion(&target->done); 305 303 306 304 target->path_query_id = ib_sa_path_rec_get(&srp_sa_client, 307 - target->srp_host->dev->dev, 305 + target->srp_host->srp_dev->dev, 308 306 target->srp_host->port, 309 307 &target->path, 310 308 IB_SA_PATH_REC_SERVICE_ID | ··· 405 403 (unsigned long long) be64_to_cpu(target->ioc_guid)); 406 404 memset(req->priv.initiator_port_id, 0, 8); 407 405 memcpy(req->priv.initiator_port_id + 8, 408 - &target->srp_host->dev->dev->node_guid, 8); 406 + &target->srp_host->srp_dev->dev->node_guid, 8); 409 407 } 410 408 411 409 status = ib_send_cm_req(target->cm_id, &req->param); ··· 522 520 req->fmr = NULL; 523 521 } 524 522 525 - ib_dma_unmap_sg(target->srp_host->dev->dev, scsi_sglist(scmnd), 523 + ib_dma_unmap_sg(target->srp_host->srp_dev->dev, scsi_sglist(scmnd), 526 524 scsi_sg_count(scmnd), scmnd->sc_data_direction); 527 525 } 528 526 ··· 630 628 int page_cnt; 631 629 int i, j; 632 630 int ret; 633 - struct srp_device *dev = target->srp_host->dev; 631 + struct srp_device *dev = target->srp_host->srp_dev; 634 632 struct ib_device *ibdev = dev->dev; 635 633 struct scatterlist *sg; 636 634 ··· 725 723 nents = scsi_sg_count(scmnd); 726 724 scat = scsi_sglist(scmnd); 727 725 728 - dev = target->srp_host->dev; 726 + dev = target->srp_host->srp_dev; 729 727 ibdev = dev->dev; 730 728 731 729 count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction); ··· 781 779 buf->table_desc.va = 782 780 cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf); 783 781 buf->table_desc.key = 784 - cpu_to_be32(target->srp_host->dev->mr->rkey); 782 + cpu_to_be32(target->srp_host->srp_dev->mr->rkey); 785 783 buf->table_desc.len = 786 784 cpu_to_be32(count * sizeof (struct srp_direct_buf)); 787 785 ··· 857 855 858 856 iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV]; 859 857 860 - dev = target->srp_host->dev->dev; 858 + dev = target->srp_host->srp_dev->dev; 861 859 ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len, 862 860 DMA_FROM_DEVICE); 863 861 ··· 939 937 940 938 list.addr = iu->dma; 941 939 list.length = iu->size; 942 - list.lkey = target->srp_host->dev->mr->lkey; 940 + list.lkey = target->srp_host->srp_dev->mr->lkey; 943 941 944 942 wr.next = NULL; 945 943 wr.sg_list = &list; ··· 998 996 999 997 list.addr = iu->dma; 1000 998 list.length = len; 1001 - list.lkey = target->srp_host->dev->mr->lkey; 999 + list.lkey = target->srp_host->srp_dev->mr->lkey; 1002 1000 1003 1001 wr.next = NULL; 1004 1002 wr.wr_id = target->tx_head & SRP_SQ_SIZE; ··· 1041 1039 if (!iu) 1042 1040 goto err; 1043 1041 1044 - dev = target->srp_host->dev->dev; 1042 + dev = target->srp_host->srp_dev->dev; 1045 1043 ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len, 1046 1044 DMA_TO_DEVICE); 1047 1045 ··· 1458 1456 return ret; 1459 1457 } 1460 1458 1461 - static ssize_t show_id_ext(struct class_device *cdev, char *buf) 1459 + static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr, 1460 + char *buf) 1462 1461 { 1463 - struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1462 + struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1464 1463 1465 1464 if (target->state == SRP_TARGET_DEAD || 1466 1465 target->state == SRP_TARGET_REMOVED) ··· 1471 1468 (unsigned long long) be64_to_cpu(target->id_ext)); 1472 1469 } 1473 1470 1474 - static ssize_t show_ioc_guid(struct class_device *cdev, char *buf) 1471 + static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr, 1472 + char *buf) 1475 1473 { 1476 - struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1474 + struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1477 1475 1478 1476 if (target->state == SRP_TARGET_DEAD || 1479 1477 target->state == SRP_TARGET_REMOVED) ··· 1484 1480 (unsigned long long) be64_to_cpu(target->ioc_guid)); 1485 1481 } 1486 1482 1487 - static ssize_t show_service_id(struct class_device *cdev, char *buf) 1483 + static ssize_t show_service_id(struct device *dev, 1484 + struct device_attribute *attr, char *buf) 1488 1485 { 1489 - struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1486 + struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1490 1487 1491 1488 if (target->state == SRP_TARGET_DEAD || 1492 1489 target->state == SRP_TARGET_REMOVED) ··· 1497 1492 (unsigned long long) be64_to_cpu(target->service_id)); 1498 1493 } 1499 1494 1500 - static ssize_t show_pkey(struct class_device *cdev, char *buf) 1495 + static ssize_t show_pkey(struct device *dev, struct device_attribute *attr, 1496 + char *buf) 1501 1497 { 1502 - struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1498 + struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1503 1499 1504 1500 if (target->state == SRP_TARGET_DEAD || 1505 1501 target->state == SRP_TARGET_REMOVED) ··· 1509 1503 return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey)); 1510 1504 } 1511 1505 1512 - static ssize_t show_dgid(struct class_device *cdev, char *buf) 1506 + static ssize_t show_dgid(struct device *dev, struct device_attribute *attr, 1507 + char *buf) 1513 1508 { 1514 - struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1509 + struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1515 1510 1516 1511 if (target->state == SRP_TARGET_DEAD || 1517 1512 target->state == SRP_TARGET_REMOVED) ··· 1529 1522 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7])); 1530 1523 } 1531 1524 1532 - static ssize_t show_orig_dgid(struct class_device *cdev, char *buf) 1525 + static ssize_t show_orig_dgid(struct device *dev, 1526 + struct device_attribute *attr, char *buf) 1533 1527 { 1534 - struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1528 + struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1535 1529 1536 1530 if (target->state == SRP_TARGET_DEAD || 1537 1531 target->state == SRP_TARGET_REMOVED) ··· 1549 1541 be16_to_cpu(target->orig_dgid[7])); 1550 1542 } 1551 1543 1552 - static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf) 1544 + static ssize_t show_zero_req_lim(struct device *dev, 1545 + struct device_attribute *attr, char *buf) 1553 1546 { 1554 - struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1547 + struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1555 1548 1556 1549 if (target->state == SRP_TARGET_DEAD || 1557 1550 target->state == SRP_TARGET_REMOVED) ··· 1561 1552 return sprintf(buf, "%d\n", target->zero_req_lim); 1562 1553 } 1563 1554 1564 - static ssize_t show_local_ib_port(struct class_device *cdev, char *buf) 1555 + static ssize_t show_local_ib_port(struct device *dev, 1556 + struct device_attribute *attr, char *buf) 1565 1557 { 1566 - struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1558 + struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1567 1559 1568 1560 return sprintf(buf, "%d\n", target->srp_host->port); 1569 1561 } 1570 1562 1571 - static ssize_t show_local_ib_device(struct class_device *cdev, char *buf) 1563 + static ssize_t show_local_ib_device(struct device *dev, 1564 + struct device_attribute *attr, char *buf) 1572 1565 { 1573 - struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1566 + struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1574 1567 1575 - return sprintf(buf, "%s\n", target->srp_host->dev->dev->name); 1568 + return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name); 1576 1569 } 1577 1570 1578 - static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); 1579 - static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL); 1580 - static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); 1581 - static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); 1582 - static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); 1583 - static CLASS_DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); 1584 - static CLASS_DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); 1585 - static CLASS_DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); 1586 - static CLASS_DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); 1571 + static DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); 1572 + static DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL); 1573 + static DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); 1574 + static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); 1575 + static DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); 1576 + static DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); 1577 + static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); 1578 + static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); 1579 + static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); 1587 1580 1588 - static struct class_device_attribute *srp_host_attrs[] = { 1589 - &class_device_attr_id_ext, 1590 - &class_device_attr_ioc_guid, 1591 - &class_device_attr_service_id, 1592 - &class_device_attr_pkey, 1593 - &class_device_attr_dgid, 1594 - &class_device_attr_orig_dgid, 1595 - &class_device_attr_zero_req_lim, 1596 - &class_device_attr_local_ib_port, 1597 - &class_device_attr_local_ib_device, 1581 + static struct device_attribute *srp_host_attrs[] = { 1582 + &dev_attr_id_ext, 1583 + &dev_attr_ioc_guid, 1584 + &dev_attr_service_id, 1585 + &dev_attr_pkey, 1586 + &dev_attr_dgid, 1587 + &dev_attr_orig_dgid, 1588 + &dev_attr_zero_req_lim, 1589 + &dev_attr_local_ib_port, 1590 + &dev_attr_local_ib_device, 1598 1591 NULL 1599 1592 }; 1600 1593 ··· 1624 1613 sprintf(target->target_name, "SRP.T10:%016llX", 1625 1614 (unsigned long long) be64_to_cpu(target->id_ext)); 1626 1615 1627 - if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device)) 1616 + if (scsi_add_host(target->scsi_host, host->srp_dev->dev->dma_device)) 1628 1617 return -ENODEV; 1629 1618 1630 1619 memcpy(ids.port_id, &target->id_ext, 8); ··· 1648 1637 return 0; 1649 1638 } 1650 1639 1651 - static void srp_release_class_dev(struct class_device *class_dev) 1640 + static void srp_release_dev(struct device *dev) 1652 1641 { 1653 1642 struct srp_host *host = 1654 - container_of(class_dev, struct srp_host, class_dev); 1643 + container_of(dev, struct srp_host, dev); 1655 1644 1656 1645 complete(&host->released); 1657 1646 } 1658 1647 1659 1648 static struct class srp_class = { 1660 1649 .name = "infiniband_srp", 1661 - .release = srp_release_class_dev 1650 + .dev_release = srp_release_dev 1662 1651 }; 1663 1652 1664 1653 /* ··· 1846 1835 return ret; 1847 1836 } 1848 1837 1849 - static ssize_t srp_create_target(struct class_device *class_dev, 1838 + static ssize_t srp_create_target(struct device *dev, 1839 + struct device_attribute *attr, 1850 1840 const char *buf, size_t count) 1851 1841 { 1852 1842 struct srp_host *host = 1853 - container_of(class_dev, struct srp_host, class_dev); 1843 + container_of(dev, struct srp_host, dev); 1854 1844 struct Scsi_Host *target_host; 1855 1845 struct srp_target_port *target; 1856 1846 int ret; ··· 1883 1871 if (ret) 1884 1872 goto err; 1885 1873 1886 - ib_get_cached_gid(host->dev->dev, host->port, 0, &target->path.sgid); 1874 + ib_get_cached_gid(host->srp_dev->dev, host->port, 0, 1875 + &target->path.sgid); 1887 1876 1888 1877 shost_printk(KERN_DEBUG, target->scsi_host, PFX 1889 1878 "new target: id_ext %016llx ioc_guid %016llx pkey %04x " ··· 1939 1926 return ret; 1940 1927 } 1941 1928 1942 - static CLASS_DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target); 1929 + static DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target); 1943 1930 1944 - static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 1931 + static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, 1932 + char *buf) 1945 1933 { 1946 - struct srp_host *host = 1947 - container_of(class_dev, struct srp_host, class_dev); 1934 + struct srp_host *host = container_of(dev, struct srp_host, dev); 1948 1935 1949 - return sprintf(buf, "%s\n", host->dev->dev->name); 1936 + return sprintf(buf, "%s\n", host->srp_dev->dev->name); 1950 1937 } 1951 1938 1952 - static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 1939 + static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 1953 1940 1954 - static ssize_t show_port(struct class_device *class_dev, char *buf) 1941 + static ssize_t show_port(struct device *dev, struct device_attribute *attr, 1942 + char *buf) 1955 1943 { 1956 - struct srp_host *host = 1957 - container_of(class_dev, struct srp_host, class_dev); 1944 + struct srp_host *host = container_of(dev, struct srp_host, dev); 1958 1945 1959 1946 return sprintf(buf, "%d\n", host->port); 1960 1947 } 1961 1948 1962 - static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 1949 + static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 1963 1950 1964 1951 static struct srp_host *srp_add_port(struct srp_device *device, u8 port) 1965 1952 { ··· 1972 1959 INIT_LIST_HEAD(&host->target_list); 1973 1960 spin_lock_init(&host->target_lock); 1974 1961 init_completion(&host->released); 1975 - host->dev = device; 1962 + host->srp_dev = device; 1976 1963 host->port = port; 1977 1964 1978 - host->class_dev.class = &srp_class; 1979 - host->class_dev.dev = device->dev->dma_device; 1980 - snprintf(host->class_dev.class_id, BUS_ID_SIZE, "srp-%s-%d", 1965 + host->dev.class = &srp_class; 1966 + host->dev.parent = device->dev->dma_device; 1967 + snprintf(host->dev.bus_id, BUS_ID_SIZE, "srp-%s-%d", 1981 1968 device->dev->name, port); 1982 1969 1983 - if (class_device_register(&host->class_dev)) 1970 + if (device_register(&host->dev)) 1984 1971 goto free_host; 1985 - if (class_device_create_file(&host->class_dev, &class_device_attr_add_target)) 1972 + if (device_create_file(&host->dev, &dev_attr_add_target)) 1986 1973 goto err_class; 1987 - if (class_device_create_file(&host->class_dev, &class_device_attr_ibdev)) 1974 + if (device_create_file(&host->dev, &dev_attr_ibdev)) 1988 1975 goto err_class; 1989 - if (class_device_create_file(&host->class_dev, &class_device_attr_port)) 1976 + if (device_create_file(&host->dev, &dev_attr_port)) 1990 1977 goto err_class; 1991 1978 1992 1979 return host; 1993 1980 1994 1981 err_class: 1995 - class_device_unregister(&host->class_dev); 1982 + device_unregister(&host->dev); 1996 1983 1997 1984 free_host: 1998 1985 kfree(host); ··· 2097 2084 srp_dev = ib_get_client_data(device, &srp_client); 2098 2085 2099 2086 list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { 2100 - class_device_unregister(&host->class_dev); 2087 + device_unregister(&host->dev); 2101 2088 /* 2102 2089 * Wait for the sysfs entry to go away, so that no new 2103 2090 * target ports can be created.
+2 -2
drivers/infiniband/ulp/srp/ib_srp.h
··· 97 97 }; 98 98 99 99 struct srp_host { 100 - struct srp_device *dev; 100 + struct srp_device *srp_dev; 101 101 u8 port; 102 - struct class_device class_dev; 102 + struct device dev; 103 103 struct list_head target_list; 104 104 spinlock_t target_lock; 105 105 struct completion released;
+3 -8
drivers/leds/led-class.c
··· 139 139 /** 140 140 * __led_classdev_unregister - unregisters a object of led_properties class. 141 141 * @led_cdev: the led device to unregister 142 - * @suspended: indicates whether system-wide suspend or resume is in progress 143 142 * 144 143 * Unregisters a previously registered via led_classdev_register object. 145 144 */ 146 - void __led_classdev_unregister(struct led_classdev *led_cdev, 147 - bool suspended) 145 + void led_classdev_unregister(struct led_classdev *led_cdev) 148 146 { 149 147 device_remove_file(led_cdev->dev, &dev_attr_brightness); 150 148 #ifdef CONFIG_LEDS_TRIGGERS ··· 153 155 up_write(&led_cdev->trigger_lock); 154 156 #endif 155 157 156 - if (suspended) 157 - device_pm_schedule_removal(led_cdev->dev); 158 - else 159 - device_unregister(led_cdev->dev); 158 + device_unregister(led_cdev->dev); 160 159 161 160 down_write(&leds_list_lock); 162 161 list_del(&led_cdev->node); 163 162 up_write(&leds_list_lock); 164 163 } 165 - EXPORT_SYMBOL_GPL(__led_classdev_unregister); 164 + EXPORT_SYMBOL_GPL(led_classdev_unregister); 166 165 167 166 static int __init leds_init(void) 168 167 {
+16 -17
drivers/memstick/core/memstick.c
··· 177 177 .resume = memstick_device_resume 178 178 }; 179 179 180 - static void memstick_free(struct class_device *cdev) 180 + static void memstick_free(struct device *dev) 181 181 { 182 - struct memstick_host *host = container_of(cdev, struct memstick_host, 183 - cdev); 182 + struct memstick_host *host = container_of(dev, struct memstick_host, 183 + dev); 184 184 kfree(host); 185 185 } 186 186 187 187 static struct class memstick_host_class = { 188 188 .name = "memstick_host", 189 - .release = memstick_free 189 + .dev_release = memstick_free 190 190 }; 191 191 192 192 static void memstick_free_card(struct device *dev) ··· 383 383 if (card) { 384 384 card->host = host; 385 385 snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), 386 - "%s", host->cdev.class_id); 387 - card->dev.parent = host->cdev.dev; 386 + "%s", host->dev.bus_id); 387 + card->dev.parent = &host->dev; 388 388 card->dev.bus = &memstick_bus_type; 389 389 card->dev.release = memstick_free_card; 390 390 card->check = memstick_dummy_check; ··· 427 427 media_checker); 428 428 struct memstick_dev *card; 429 429 430 - dev_dbg(host->cdev.dev, "memstick_check started\n"); 430 + dev_dbg(&host->dev, "memstick_check started\n"); 431 431 mutex_lock(&host->lock); 432 432 if (!host->card) 433 433 memstick_power_on(host); ··· 440 440 host->card = NULL; 441 441 } 442 442 } else { 443 - dev_dbg(host->cdev.dev, "new card %02x, %02x, %02x\n", 443 + dev_dbg(&host->dev, "new card %02x, %02x, %02x\n", 444 444 card->id.type, card->id.category, card->id.class); 445 445 if (host->card) { 446 446 if (memstick_set_rw_addr(host->card) ··· 465 465 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); 466 466 467 467 mutex_unlock(&host->lock); 468 - dev_dbg(host->cdev.dev, "memstick_check finished\n"); 468 + dev_dbg(&host->dev, "memstick_check finished\n"); 469 469 } 470 470 471 471 /** ··· 482 482 if (host) { 483 483 mutex_init(&host->lock); 484 484 INIT_WORK(&host->media_checker, memstick_check); 485 - host->cdev.class = &memstick_host_class; 486 - host->cdev.dev = dev; 487 - class_device_initialize(&host->cdev); 485 + host->dev.class = &memstick_host_class; 486 + host->dev.parent = dev; 487 + device_initialize(&host->dev); 488 488 } 489 489 return host; 490 490 } ··· 507 507 if (rc) 508 508 return rc; 509 509 510 - snprintf(host->cdev.class_id, BUS_ID_SIZE, 511 - "memstick%u", host->id); 510 + snprintf(host->dev.bus_id, BUS_ID_SIZE, "memstick%u", host->id); 512 511 513 - rc = class_device_add(&host->cdev); 512 + rc = device_add(&host->dev); 514 513 if (rc) { 515 514 spin_lock(&memstick_host_lock); 516 515 idr_remove(&memstick_host_idr, host->id); ··· 540 541 spin_lock(&memstick_host_lock); 541 542 idr_remove(&memstick_host_idr, host->id); 542 543 spin_unlock(&memstick_host_lock); 543 - class_device_del(&host->cdev); 544 + device_del(&host->dev); 544 545 } 545 546 EXPORT_SYMBOL(memstick_remove_host); 546 547 ··· 551 552 void memstick_free_host(struct memstick_host *host) 552 553 { 553 554 mutex_destroy(&host->lock); 554 - class_device_put(&host->cdev); 555 + put_device(&host->dev); 555 556 } 556 557 EXPORT_SYMBOL(memstick_free_host); 557 558
+2 -2
drivers/memstick/core/mspro_block.c
··· 1127 1127 u64 limit = BLK_BOUNCE_HIGH; 1128 1128 unsigned long capacity; 1129 1129 1130 - if (host->cdev.dev->dma_mask && *(host->cdev.dev->dma_mask)) 1131 - limit = *(host->cdev.dev->dma_mask); 1130 + if (host->dev.dma_mask && *(host->dev.dma_mask)) 1131 + limit = *(host->dev.dma_mask); 1132 1132 1133 1133 for (rc = 0; msb->attr_group.attrs[rc]; ++rc) { 1134 1134 s_attr = mspro_from_sysfs_attr(msb->attr_group.attrs[rc]);
+8 -8
drivers/memstick/host/jmb38x_ms.c
··· 361 361 unsigned int data_len, cmd, t_val; 362 362 363 363 if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) { 364 - dev_dbg(msh->cdev.dev, "no media status\n"); 364 + dev_dbg(&msh->dev, "no media status\n"); 365 365 host->req->error = -ETIME; 366 366 return host->req->error; 367 367 } 368 368 369 - dev_dbg(msh->cdev.dev, "control %08x\n", 369 + dev_dbg(&msh->dev, "control %08x\n", 370 370 readl(host->addr + HOST_CONTROL)); 371 - dev_dbg(msh->cdev.dev, "status %08x\n", readl(host->addr + INT_STATUS)); 372 - dev_dbg(msh->cdev.dev, "hstatus %08x\n", readl(host->addr + STATUS)); 371 + dev_dbg(&msh->dev, "status %08x\n", readl(host->addr + INT_STATUS)); 372 + dev_dbg(&msh->dev, "hstatus %08x\n", readl(host->addr + STATUS)); 373 373 374 374 host->cmd_flags = 0; 375 375 host->block_pos = 0; ··· 448 448 host->req->error = 0; 449 449 450 450 writel(cmd, host->addr + TPC); 451 - dev_dbg(msh->cdev.dev, "executing TPC %08x, len %x\n", cmd, data_len); 451 + dev_dbg(&msh->dev, "executing TPC %08x, len %x\n", cmd, data_len); 452 452 453 453 return 0; 454 454 } ··· 461 461 462 462 del_timer(&host->timer); 463 463 464 - dev_dbg(msh->cdev.dev, "c control %08x\n", 464 + dev_dbg(&msh->dev, "c control %08x\n", 465 465 readl(host->addr + HOST_CONTROL)); 466 - dev_dbg(msh->cdev.dev, "c status %08x\n", 466 + dev_dbg(&msh->dev, "c status %08x\n", 467 467 readl(host->addr + INT_STATUS)); 468 - dev_dbg(msh->cdev.dev, "c hstatus %08x\n", readl(host->addr + STATUS)); 468 + dev_dbg(&msh->dev, "c hstatus %08x\n", readl(host->addr + STATUS)); 469 469 470 470 host->req->int_reg = readl(host->addr + STATUS) & 0xff; 471 471
+67 -53
drivers/message/fusion/mptscsih.c
··· 3300 3300 } 3301 3301 3302 3302 static ssize_t 3303 - mptscsih_version_fw_show(struct class_device *cdev, char *buf) 3303 + mptscsih_version_fw_show(struct device *dev, struct device_attribute *attr, 3304 + char *buf) 3304 3305 { 3305 - struct Scsi_Host *host = class_to_shost(cdev); 3306 + struct Scsi_Host *host = class_to_shost(dev); 3306 3307 MPT_SCSI_HOST *hd = shost_priv(host); 3307 3308 MPT_ADAPTER *ioc = hd->ioc; 3308 3309 ··· 3313 3312 (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8, 3314 3313 ioc->facts.FWVersion.Word & 0x000000FF); 3315 3314 } 3316 - static CLASS_DEVICE_ATTR(version_fw, S_IRUGO, mptscsih_version_fw_show, NULL); 3315 + static DEVICE_ATTR(version_fw, S_IRUGO, mptscsih_version_fw_show, NULL); 3317 3316 3318 3317 static ssize_t 3319 - mptscsih_version_bios_show(struct class_device *cdev, char *buf) 3318 + mptscsih_version_bios_show(struct device *dev, struct device_attribute *attr, 3319 + char *buf) 3320 3320 { 3321 - struct Scsi_Host *host = class_to_shost(cdev); 3321 + struct Scsi_Host *host = class_to_shost(dev); 3322 3322 MPT_SCSI_HOST *hd = shost_priv(host); 3323 3323 MPT_ADAPTER *ioc = hd->ioc; 3324 3324 ··· 3329 3327 (ioc->biosVersion & 0x0000FF00) >> 8, 3330 3328 ioc->biosVersion & 0x000000FF); 3331 3329 } 3332 - static CLASS_DEVICE_ATTR(version_bios, S_IRUGO, mptscsih_version_bios_show, NULL); 3330 + static DEVICE_ATTR(version_bios, S_IRUGO, mptscsih_version_bios_show, NULL); 3333 3331 3334 3332 static ssize_t 3335 - mptscsih_version_mpi_show(struct class_device *cdev, char *buf) 3333 + mptscsih_version_mpi_show(struct device *dev, struct device_attribute *attr, 3334 + char *buf) 3336 3335 { 3337 - struct Scsi_Host *host = class_to_shost(cdev); 3336 + struct Scsi_Host *host = class_to_shost(dev); 3338 3337 MPT_SCSI_HOST *hd = shost_priv(host); 3339 3338 MPT_ADAPTER *ioc = hd->ioc; 3340 3339 3341 3340 return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion); 3342 3341 } 3343 - static CLASS_DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL); 3342 + static DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL); 3344 3343 3345 3344 static ssize_t 3346 - mptscsih_version_product_show(struct class_device *cdev, char *buf) 3345 + mptscsih_version_product_show(struct device *dev, 3346 + struct device_attribute *attr, 3347 + char *buf) 3347 3348 { 3348 - struct Scsi_Host *host = class_to_shost(cdev); 3349 + struct Scsi_Host *host = class_to_shost(dev); 3349 3350 MPT_SCSI_HOST *hd = shost_priv(host); 3350 3351 MPT_ADAPTER *ioc = hd->ioc; 3351 3352 3352 3353 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name); 3353 3354 } 3354 - static CLASS_DEVICE_ATTR(version_product, S_IRUGO, 3355 + static DEVICE_ATTR(version_product, S_IRUGO, 3355 3356 mptscsih_version_product_show, NULL); 3356 3357 3357 3358 static ssize_t 3358 - mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf) 3359 + mptscsih_version_nvdata_persistent_show(struct device *dev, 3360 + struct device_attribute *attr, 3361 + char *buf) 3359 3362 { 3360 - struct Scsi_Host *host = class_to_shost(cdev); 3363 + struct Scsi_Host *host = class_to_shost(dev); 3361 3364 MPT_SCSI_HOST *hd = shost_priv(host); 3362 3365 MPT_ADAPTER *ioc = hd->ioc; 3363 3366 3364 3367 return snprintf(buf, PAGE_SIZE, "%02xh\n", 3365 3368 ioc->nvdata_version_persistent); 3366 3369 } 3367 - static CLASS_DEVICE_ATTR(version_nvdata_persistent, S_IRUGO, 3370 + static DEVICE_ATTR(version_nvdata_persistent, S_IRUGO, 3368 3371 mptscsih_version_nvdata_persistent_show, NULL); 3369 3372 3370 3373 static ssize_t 3371 - mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf) 3374 + mptscsih_version_nvdata_default_show(struct device *dev, 3375 + struct device_attribute *attr, char *buf) 3372 3376 { 3373 - struct Scsi_Host *host = class_to_shost(cdev); 3377 + struct Scsi_Host *host = class_to_shost(dev); 3374 3378 MPT_SCSI_HOST *hd = shost_priv(host); 3375 3379 MPT_ADAPTER *ioc = hd->ioc; 3376 3380 3377 3381 return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default); 3378 3382 } 3379 - static CLASS_DEVICE_ATTR(version_nvdata_default, S_IRUGO, 3383 + static DEVICE_ATTR(version_nvdata_default, S_IRUGO, 3380 3384 mptscsih_version_nvdata_default_show, NULL); 3381 3385 3382 3386 static ssize_t 3383 - mptscsih_board_name_show(struct class_device *cdev, char *buf) 3387 + mptscsih_board_name_show(struct device *dev, struct device_attribute *attr, 3388 + char *buf) 3384 3389 { 3385 - struct Scsi_Host *host = class_to_shost(cdev); 3390 + struct Scsi_Host *host = class_to_shost(dev); 3386 3391 MPT_SCSI_HOST *hd = shost_priv(host); 3387 3392 MPT_ADAPTER *ioc = hd->ioc; 3388 3393 3389 3394 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name); 3390 3395 } 3391 - static CLASS_DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL); 3396 + static DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL); 3392 3397 3393 3398 static ssize_t 3394 - mptscsih_board_assembly_show(struct class_device *cdev, char *buf) 3399 + mptscsih_board_assembly_show(struct device *dev, 3400 + struct device_attribute *attr, char *buf) 3395 3401 { 3396 - struct Scsi_Host *host = class_to_shost(cdev); 3402 + struct Scsi_Host *host = class_to_shost(dev); 3397 3403 MPT_SCSI_HOST *hd = shost_priv(host); 3398 3404 MPT_ADAPTER *ioc = hd->ioc; 3399 3405 3400 3406 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly); 3401 3407 } 3402 - static CLASS_DEVICE_ATTR(board_assembly, S_IRUGO, 3408 + static DEVICE_ATTR(board_assembly, S_IRUGO, 3403 3409 mptscsih_board_assembly_show, NULL); 3404 3410 3405 3411 static ssize_t 3406 - mptscsih_board_tracer_show(struct class_device *cdev, char *buf) 3412 + mptscsih_board_tracer_show(struct device *dev, struct device_attribute *attr, 3413 + char *buf) 3407 3414 { 3408 - struct Scsi_Host *host = class_to_shost(cdev); 3415 + struct Scsi_Host *host = class_to_shost(dev); 3409 3416 MPT_SCSI_HOST *hd = shost_priv(host); 3410 3417 MPT_ADAPTER *ioc = hd->ioc; 3411 3418 3412 3419 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer); 3413 3420 } 3414 - static CLASS_DEVICE_ATTR(board_tracer, S_IRUGO, 3421 + static DEVICE_ATTR(board_tracer, S_IRUGO, 3415 3422 mptscsih_board_tracer_show, NULL); 3416 3423 3417 3424 static ssize_t 3418 - mptscsih_io_delay_show(struct class_device *cdev, char *buf) 3425 + mptscsih_io_delay_show(struct device *dev, struct device_attribute *attr, 3426 + char *buf) 3419 3427 { 3420 - struct Scsi_Host *host = class_to_shost(cdev); 3428 + struct Scsi_Host *host = class_to_shost(dev); 3421 3429 MPT_SCSI_HOST *hd = shost_priv(host); 3422 3430 MPT_ADAPTER *ioc = hd->ioc; 3423 3431 3424 3432 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); 3425 3433 } 3426 - static CLASS_DEVICE_ATTR(io_delay, S_IRUGO, 3434 + static DEVICE_ATTR(io_delay, S_IRUGO, 3427 3435 mptscsih_io_delay_show, NULL); 3428 3436 3429 3437 static ssize_t 3430 - mptscsih_device_delay_show(struct class_device *cdev, char *buf) 3438 + mptscsih_device_delay_show(struct device *dev, struct device_attribute *attr, 3439 + char *buf) 3431 3440 { 3432 - struct Scsi_Host *host = class_to_shost(cdev); 3441 + struct Scsi_Host *host = class_to_shost(dev); 3433 3442 MPT_SCSI_HOST *hd = shost_priv(host); 3434 3443 MPT_ADAPTER *ioc = hd->ioc; 3435 3444 3436 3445 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); 3437 3446 } 3438 - static CLASS_DEVICE_ATTR(device_delay, S_IRUGO, 3447 + static DEVICE_ATTR(device_delay, S_IRUGO, 3439 3448 mptscsih_device_delay_show, NULL); 3440 3449 3441 3450 static ssize_t 3442 - mptscsih_debug_level_show(struct class_device *cdev, char *buf) 3451 + mptscsih_debug_level_show(struct device *dev, struct device_attribute *attr, 3452 + char *buf) 3443 3453 { 3444 - struct Scsi_Host *host = class_to_shost(cdev); 3454 + struct Scsi_Host *host = class_to_shost(dev); 3445 3455 MPT_SCSI_HOST *hd = shost_priv(host); 3446 3456 MPT_ADAPTER *ioc = hd->ioc; 3447 3457 3448 3458 return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level); 3449 3459 } 3450 3460 static ssize_t 3451 - mptscsih_debug_level_store(struct class_device *cdev, const char *buf, 3452 - size_t count) 3461 + mptscsih_debug_level_store(struct device *dev, struct device_attribute *attr, 3462 + const char *buf, size_t count) 3453 3463 { 3454 - struct Scsi_Host *host = class_to_shost(cdev); 3464 + struct Scsi_Host *host = class_to_shost(dev); 3455 3465 MPT_SCSI_HOST *hd = shost_priv(host); 3456 3466 MPT_ADAPTER *ioc = hd->ioc; 3457 3467 int val = 0; ··· 3476 3462 ioc->name, ioc->debug_level); 3477 3463 return strlen(buf); 3478 3464 } 3479 - static CLASS_DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR, 3480 - mptscsih_debug_level_show, mptscsih_debug_level_store); 3465 + static DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR, 3466 + mptscsih_debug_level_show, mptscsih_debug_level_store); 3481 3467 3482 - struct class_device_attribute *mptscsih_host_attrs[] = { 3483 - &class_device_attr_version_fw, 3484 - &class_device_attr_version_bios, 3485 - &class_device_attr_version_mpi, 3486 - &class_device_attr_version_product, 3487 - &class_device_attr_version_nvdata_persistent, 3488 - &class_device_attr_version_nvdata_default, 3489 - &class_device_attr_board_name, 3490 - &class_device_attr_board_assembly, 3491 - &class_device_attr_board_tracer, 3492 - &class_device_attr_io_delay, 3493 - &class_device_attr_device_delay, 3494 - &class_device_attr_debug_level, 3468 + struct device_attribute *mptscsih_host_attrs[] = { 3469 + &dev_attr_version_fw, 3470 + &dev_attr_version_bios, 3471 + &dev_attr_version_mpi, 3472 + &dev_attr_version_product, 3473 + &dev_attr_version_nvdata_persistent, 3474 + &dev_attr_version_nvdata_default, 3475 + &dev_attr_board_name, 3476 + &dev_attr_board_assembly, 3477 + &dev_attr_board_tracer, 3478 + &dev_attr_io_delay, 3479 + &dev_attr_device_delay, 3480 + &dev_attr_debug_level, 3495 3481 NULL, 3496 3482 }; 3497 3483 EXPORT_SYMBOL(mptscsih_host_attrs);
+1 -1
drivers/message/fusion/mptscsih.h
··· 129 129 extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout); 130 130 extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id); 131 131 extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id); 132 - extern struct class_device_attribute *mptscsih_host_attrs[]; 132 + extern struct device_attribute *mptscsih_host_attrs[];
+64 -54
drivers/misc/enclosure.c
··· 40 40 * Looks through the list of registered enclosures to see 41 41 * if it can find a match for a device. Returns NULL if no 42 42 * enclosure is found. Obtains a reference to the enclosure class 43 - * device which must be released with class_device_put(). 43 + * device which must be released with device_put(). 44 44 */ 45 45 struct enclosure_device *enclosure_find(struct device *dev) 46 46 { 47 - struct enclosure_device *edev = NULL; 47 + struct enclosure_device *edev; 48 48 49 49 mutex_lock(&container_list_lock); 50 50 list_for_each_entry(edev, &container_list, node) { 51 - if (edev->cdev.dev == dev) { 52 - class_device_get(&edev->cdev); 51 + if (edev->edev.parent == dev) { 52 + get_device(&edev->edev); 53 53 mutex_unlock(&container_list_lock); 54 54 return edev; 55 55 } ··· 117 117 118 118 edev->components = components; 119 119 120 - edev->cdev.class = &enclosure_class; 121 - edev->cdev.dev = get_device(dev); 120 + edev->edev.class = &enclosure_class; 121 + edev->edev.parent = get_device(dev); 122 122 edev->cb = cb; 123 - snprintf(edev->cdev.class_id, BUS_ID_SIZE, "%s", name); 124 - err = class_device_register(&edev->cdev); 123 + snprintf(edev->edev.bus_id, BUS_ID_SIZE, "%s", name); 124 + err = device_register(&edev->edev); 125 125 if (err) 126 126 goto err; 127 127 ··· 135 135 return edev; 136 136 137 137 err: 138 - put_device(edev->cdev.dev); 138 + put_device(edev->edev.parent); 139 139 kfree(edev); 140 140 return ERR_PTR(err); 141 141 } ··· 158 158 159 159 for (i = 0; i < edev->components; i++) 160 160 if (edev->component[i].number != -1) 161 - class_device_unregister(&edev->component[i].cdev); 161 + device_unregister(&edev->component[i].cdev); 162 162 163 163 /* prevent any callbacks into service user */ 164 164 edev->cb = &enclosure_null_callbacks; 165 - class_device_unregister(&edev->cdev); 165 + device_unregister(&edev->edev); 166 166 } 167 167 EXPORT_SYMBOL_GPL(enclosure_unregister); 168 168 169 - static void enclosure_release(struct class_device *cdev) 169 + static void enclosure_release(struct device *cdev) 170 170 { 171 171 struct enclosure_device *edev = to_enclosure_device(cdev); 172 172 173 - put_device(cdev->dev); 173 + put_device(cdev->parent); 174 174 kfree(edev); 175 175 } 176 176 177 - static void enclosure_component_release(struct class_device *cdev) 177 + static void enclosure_component_release(struct device *dev) 178 178 { 179 - if (cdev->dev) 180 - put_device(cdev->dev); 181 - class_device_put(cdev->parent); 179 + struct enclosure_component *cdev = to_enclosure_component(dev); 180 + 181 + put_device(cdev->dev); 182 + put_device(dev->parent); 182 183 } 183 184 184 185 /** ··· 202 201 const char *name) 203 202 { 204 203 struct enclosure_component *ecomp; 205 - struct class_device *cdev; 204 + struct device *cdev; 206 205 int err; 207 206 208 207 if (number >= edev->components) ··· 216 215 ecomp->type = type; 217 216 ecomp->number = number; 218 217 cdev = &ecomp->cdev; 219 - cdev->parent = class_device_get(&edev->cdev); 218 + cdev->parent = get_device(&edev->edev); 220 219 cdev->class = &enclosure_component_class; 221 220 if (name) 222 - snprintf(cdev->class_id, BUS_ID_SIZE, "%s", name); 221 + snprintf(cdev->bus_id, BUS_ID_SIZE, "%s", name); 223 222 else 224 - snprintf(cdev->class_id, BUS_ID_SIZE, "%u", number); 223 + snprintf(cdev->bus_id, BUS_ID_SIZE, "%u", number); 225 224 226 - err = class_device_register(cdev); 225 + err = device_register(cdev); 227 226 if (err) 228 227 ERR_PTR(err); 229 228 ··· 248 247 int enclosure_add_device(struct enclosure_device *edev, int component, 249 248 struct device *dev) 250 249 { 251 - struct class_device *cdev; 250 + struct enclosure_component *cdev; 252 251 253 252 if (!edev || component >= edev->components) 254 253 return -EINVAL; 255 254 256 - cdev = &edev->component[component].cdev; 255 + cdev = &edev->component[component]; 257 256 258 - class_device_del(cdev); 259 - if (cdev->dev) 260 - put_device(cdev->dev); 257 + device_del(&cdev->cdev); 258 + put_device(cdev->dev); 261 259 cdev->dev = get_device(dev); 262 - return class_device_add(cdev); 260 + return device_add(&cdev->cdev); 263 261 } 264 262 EXPORT_SYMBOL_GPL(enclosure_add_device); 265 263 ··· 272 272 */ 273 273 int enclosure_remove_device(struct enclosure_device *edev, int component) 274 274 { 275 - struct class_device *cdev; 275 + struct enclosure_component *cdev; 276 276 277 277 if (!edev || component >= edev->components) 278 278 return -EINVAL; 279 279 280 - cdev = &edev->component[component].cdev; 280 + cdev = &edev->component[component]; 281 281 282 - class_device_del(cdev); 283 - if (cdev->dev) 284 - put_device(cdev->dev); 282 + device_del(&cdev->cdev); 283 + put_device(cdev->dev); 285 284 cdev->dev = NULL; 286 - return class_device_add(cdev); 285 + return device_add(&cdev->cdev); 287 286 } 288 287 EXPORT_SYMBOL_GPL(enclosure_remove_device); 289 288 ··· 290 291 * sysfs pieces below 291 292 */ 292 293 293 - static ssize_t enclosure_show_components(struct class_device *cdev, char *buf) 294 + static ssize_t enclosure_show_components(struct device *cdev, 295 + struct device_attribute *attr, 296 + char *buf) 294 297 { 295 298 struct enclosure_device *edev = to_enclosure_device(cdev); 296 299 297 300 return snprintf(buf, 40, "%d\n", edev->components); 298 301 } 299 302 300 - static struct class_device_attribute enclosure_attrs[] = { 303 + static struct device_attribute enclosure_attrs[] = { 301 304 __ATTR(components, S_IRUGO, enclosure_show_components, NULL), 302 305 __ATTR_NULL 303 306 }; ··· 307 306 static struct class enclosure_class = { 308 307 .name = "enclosure", 309 308 .owner = THIS_MODULE, 310 - .release = enclosure_release, 311 - .class_dev_attrs = enclosure_attrs, 309 + .dev_release = enclosure_release, 310 + .dev_attrs = enclosure_attrs, 312 311 }; 313 312 314 313 static const char *const enclosure_status [] = { ··· 327 326 [ENCLOSURE_COMPONENT_ARRAY_DEVICE] = "array device", 328 327 }; 329 328 330 - static ssize_t get_component_fault(struct class_device *cdev, char *buf) 329 + static ssize_t get_component_fault(struct device *cdev, 330 + struct device_attribute *attr, char *buf) 331 331 { 332 332 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 333 333 struct enclosure_component *ecomp = to_enclosure_component(cdev); ··· 338 336 return snprintf(buf, 40, "%d\n", ecomp->fault); 339 337 } 340 338 341 - static ssize_t set_component_fault(struct class_device *cdev, const char *buf, 342 - size_t count) 339 + static ssize_t set_component_fault(struct device *cdev, 340 + struct device_attribute *attr, 341 + const char *buf, size_t count) 343 342 { 344 343 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 345 344 struct enclosure_component *ecomp = to_enclosure_component(cdev); ··· 351 348 return count; 352 349 } 353 350 354 - static ssize_t get_component_status(struct class_device *cdev, char *buf) 351 + static ssize_t get_component_status(struct device *cdev, 352 + struct device_attribute *attr,char *buf) 355 353 { 356 354 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 357 355 struct enclosure_component *ecomp = to_enclosure_component(cdev); ··· 362 358 return snprintf(buf, 40, "%s\n", enclosure_status[ecomp->status]); 363 359 } 364 360 365 - static ssize_t set_component_status(struct class_device *cdev, const char *buf, 366 - size_t count) 361 + static ssize_t set_component_status(struct device *cdev, 362 + struct device_attribute *attr, 363 + const char *buf, size_t count) 367 364 { 368 365 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 369 366 struct enclosure_component *ecomp = to_enclosure_component(cdev); ··· 385 380 return -EINVAL; 386 381 } 387 382 388 - static ssize_t get_component_active(struct class_device *cdev, char *buf) 383 + static ssize_t get_component_active(struct device *cdev, 384 + struct device_attribute *attr, char *buf) 389 385 { 390 386 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 391 387 struct enclosure_component *ecomp = to_enclosure_component(cdev); ··· 396 390 return snprintf(buf, 40, "%d\n", ecomp->active); 397 391 } 398 392 399 - static ssize_t set_component_active(struct class_device *cdev, const char *buf, 400 - size_t count) 393 + static ssize_t set_component_active(struct device *cdev, 394 + struct device_attribute *attr, 395 + const char *buf, size_t count) 401 396 { 402 397 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 403 398 struct enclosure_component *ecomp = to_enclosure_component(cdev); ··· 409 402 return count; 410 403 } 411 404 412 - static ssize_t get_component_locate(struct class_device *cdev, char *buf) 405 + static ssize_t get_component_locate(struct device *cdev, 406 + struct device_attribute *attr, char *buf) 413 407 { 414 408 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 415 409 struct enclosure_component *ecomp = to_enclosure_component(cdev); ··· 420 412 return snprintf(buf, 40, "%d\n", ecomp->locate); 421 413 } 422 414 423 - static ssize_t set_component_locate(struct class_device *cdev, const char *buf, 424 - size_t count) 415 + static ssize_t set_component_locate(struct device *cdev, 416 + struct device_attribute *attr, 417 + const char *buf, size_t count) 425 418 { 426 419 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 427 420 struct enclosure_component *ecomp = to_enclosure_component(cdev); ··· 433 424 return count; 434 425 } 435 426 436 - static ssize_t get_component_type(struct class_device *cdev, char *buf) 427 + static ssize_t get_component_type(struct device *cdev, 428 + struct device_attribute *attr, char *buf) 437 429 { 438 430 struct enclosure_component *ecomp = to_enclosure_component(cdev); 439 431 ··· 442 432 } 443 433 444 434 445 - static struct class_device_attribute enclosure_component_attrs[] = { 435 + static struct device_attribute enclosure_component_attrs[] = { 446 436 __ATTR(fault, S_IRUGO | S_IWUSR, get_component_fault, 447 437 set_component_fault), 448 438 __ATTR(status, S_IRUGO | S_IWUSR, get_component_status, ··· 458 448 static struct class enclosure_component_class = { 459 449 .name = "enclosure_component", 460 450 .owner = THIS_MODULE, 461 - .class_dev_attrs = enclosure_component_attrs, 462 - .release = enclosure_component_release, 451 + .dev_attrs = enclosure_component_attrs, 452 + .dev_release = enclosure_component_release, 463 453 }; 464 454 465 455 static int __init enclosure_init(void)
+1 -4
drivers/net/wireless/b43/leds.c
··· 116 116 { 117 117 if (!led->dev) 118 118 return; 119 - if (led->dev->suspend_in_progress) 120 - led_classdev_unregister_suspended(&led->led_dev); 121 - else 122 - led_classdev_unregister(&led->led_dev); 119 + led_classdev_unregister(&led->led_dev); 123 120 b43_led_turn_off(led->dev, led->index, led->activelow); 124 121 led->dev = NULL; 125 122 }
+4 -4
drivers/net/wireless/b43/main.c
··· 2804 2804 return (sizeof(u16)); 2805 2805 } 2806 2806 2807 - static void b43_rng_exit(struct b43_wl *wl, bool suspended) 2807 + static void b43_rng_exit(struct b43_wl *wl) 2808 2808 { 2809 2809 if (wl->rng_initialized) 2810 - __hwrng_unregister(&wl->rng, suspended); 2810 + hwrng_unregister(&wl->rng); 2811 2811 } 2812 2812 2813 2813 static int b43_rng_init(struct b43_wl *wl) ··· 3824 3824 3825 3825 if (!dev->suspend_in_progress) { 3826 3826 b43_leds_exit(dev); 3827 - b43_rng_exit(dev->wl, false); 3827 + b43_rng_exit(dev->wl); 3828 3828 } 3829 3829 b43_dma_free(dev); 3830 3830 b43_pio_free(dev); ··· 4589 4589 err = b43_wireless_core_start(wldev); 4590 4590 if (err) { 4591 4591 b43_leds_exit(wldev); 4592 - b43_rng_exit(wldev->wl, true); 4592 + b43_rng_exit(wldev->wl); 4593 4593 b43_wireless_core_exit(wldev); 4594 4594 b43err(wl, "Resume failed at core start\n"); 4595 4595 goto out;
+5 -4
drivers/scsi/3w-9xxx.c
··· 140 140 /* Functions */ 141 141 142 142 /* Show some statistics about the card */ 143 - static ssize_t twa_show_stats(struct class_device *class_dev, char *buf) 143 + static ssize_t twa_show_stats(struct device *dev, 144 + struct device_attribute *attr, char *buf) 144 145 { 145 - struct Scsi_Host *host = class_to_shost(class_dev); 146 + struct Scsi_Host *host = class_to_shost(dev); 146 147 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; 147 148 unsigned long flags = 0; 148 149 ssize_t len; ··· 185 184 } /* End twa_change_queue_depth() */ 186 185 187 186 /* Create sysfs 'stats' entry */ 188 - static struct class_device_attribute twa_host_stats_attr = { 187 + static struct device_attribute twa_host_stats_attr = { 189 188 .attr = { 190 189 .name = "stats", 191 190 .mode = S_IRUGO, ··· 194 193 }; 195 194 196 195 /* Host attributes initializer */ 197 - static struct class_device_attribute *twa_host_attrs[] = { 196 + static struct device_attribute *twa_host_attrs[] = { 198 197 &twa_host_stats_attr, 199 198 NULL, 200 199 };
+5 -4
drivers/scsi/3w-xxxx.c
··· 484 484 } /* End tw_state_request_start() */ 485 485 486 486 /* Show some statistics about the card */ 487 - static ssize_t tw_show_stats(struct class_device *class_dev, char *buf) 487 + static ssize_t tw_show_stats(struct device *dev, struct device_attribute *attr, 488 + char *buf) 488 489 { 489 - struct Scsi_Host *host = class_to_shost(class_dev); 490 + struct Scsi_Host *host = class_to_shost(dev); 490 491 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; 491 492 unsigned long flags = 0; 492 493 ssize_t len; ··· 529 528 } /* End tw_change_queue_depth() */ 530 529 531 530 /* Create sysfs 'stats' entry */ 532 - static struct class_device_attribute tw_host_stats_attr = { 531 + static struct device_attribute tw_host_stats_attr = { 533 532 .attr = { 534 533 .name = "stats", 535 534 .mode = S_IRUGO, ··· 538 537 }; 539 538 540 539 /* Host attributes initializer */ 541 - static struct class_device_attribute *tw_host_attrs[] = { 540 + static struct device_attribute *tw_host_attrs[] = { 542 541 &tw_host_stats_attr, 543 542 NULL, 544 543 };
+1 -1
drivers/scsi/aacraid/aachba.c
··· 1315 1315 tmp>>24,(tmp>>16)&0xff,tmp&0xff, 1316 1316 le32_to_cpu(dev->adapter_info.biosbuild)); 1317 1317 buffer[0] = '\0'; 1318 - if (aac_show_serial_number( 1318 + if (aac_get_serial_number( 1319 1319 shost_to_class(dev->scsi_host_ptr), buffer)) 1320 1320 printk(KERN_INFO "%s%d: serial %s", 1321 1321 dev->name, dev->id, buffer);
+2 -2
drivers/scsi/aacraid/aacraid.h
··· 1850 1850 int aac_scsi_cmd(struct scsi_cmnd *cmd); 1851 1851 int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg); 1852 1852 #ifndef shost_to_class 1853 - #define shost_to_class(shost) &shost->shost_classdev 1853 + #define shost_to_class(shost) &shost->shost_dev 1854 1854 #endif 1855 - ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf); 1855 + ssize_t aac_get_serial_number(struct device *dev, char *buf); 1856 1856 int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg); 1857 1857 int aac_rx_init(struct aac_dev *dev); 1858 1858 int aac_rkt_init(struct aac_dev *dev);
+53 -40
drivers/scsi/aacraid/linit.c
··· 754 754 } 755 755 #endif 756 756 757 - static ssize_t aac_show_model(struct class_device *class_dev, 758 - char *buf) 757 + static ssize_t aac_show_model(struct device *device, 758 + struct device_attribute *attr, char *buf) 759 759 { 760 - struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 760 + struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; 761 761 int len; 762 762 763 763 if (dev->supplement_adapter_info.AdapterTypeText[0]) { ··· 773 773 return len; 774 774 } 775 775 776 - static ssize_t aac_show_vendor(struct class_device *class_dev, 777 - char *buf) 776 + static ssize_t aac_show_vendor(struct device *device, 777 + struct device_attribute *attr, char *buf) 778 778 { 779 - struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 779 + struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; 780 780 int len; 781 781 782 782 if (dev->supplement_adapter_info.AdapterTypeText[0]) { ··· 792 792 return len; 793 793 } 794 794 795 - static ssize_t aac_show_flags(struct class_device *class_dev, char *buf) 795 + static ssize_t aac_show_flags(struct device *cdev, 796 + struct device_attribute *attr, char *buf) 796 797 { 797 798 int len = 0; 798 - struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 799 + struct aac_dev *dev = (struct aac_dev*)class_to_shost(cdev)->hostdata; 799 800 800 801 if (nblank(dprintk(x))) 801 802 len = snprintf(buf, PAGE_SIZE, "dprintk\n"); ··· 812 811 return len; 813 812 } 814 813 815 - static ssize_t aac_show_kernel_version(struct class_device *class_dev, 816 - char *buf) 814 + static ssize_t aac_show_kernel_version(struct device *device, 815 + struct device_attribute *attr, 816 + char *buf) 817 817 { 818 - struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 818 + struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; 819 819 int len, tmp; 820 820 821 821 tmp = le32_to_cpu(dev->adapter_info.kernelrev); ··· 826 824 return len; 827 825 } 828 826 829 - static ssize_t aac_show_monitor_version(struct class_device *class_dev, 830 - char *buf) 827 + static ssize_t aac_show_monitor_version(struct device *device, 828 + struct device_attribute *attr, 829 + char *buf) 831 830 { 832 - struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 831 + struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; 833 832 int len, tmp; 834 833 835 834 tmp = le32_to_cpu(dev->adapter_info.monitorrev); ··· 840 837 return len; 841 838 } 842 839 843 - static ssize_t aac_show_bios_version(struct class_device *class_dev, 844 - char *buf) 840 + static ssize_t aac_show_bios_version(struct device *device, 841 + struct device_attribute *attr, 842 + char *buf) 845 843 { 846 - struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 844 + struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; 847 845 int len, tmp; 848 846 849 847 tmp = le32_to_cpu(dev->adapter_info.biosrev); ··· 854 850 return len; 855 851 } 856 852 857 - ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf) 853 + ssize_t aac_show_serial_number(struct device *device, 854 + struct device_attribute *attr, char *buf) 858 855 { 859 - struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 856 + struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; 860 857 int len = 0; 861 858 862 859 if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0) ··· 873 868 return len; 874 869 } 875 870 876 - static ssize_t aac_show_max_channel(struct class_device *class_dev, char *buf) 871 + static ssize_t aac_show_max_channel(struct device *device, 872 + struct device_attribute *attr, char *buf) 877 873 { 878 874 return snprintf(buf, PAGE_SIZE, "%d\n", 879 - class_to_shost(class_dev)->max_channel); 875 + class_to_shost(device)->max_channel); 880 876 } 881 877 882 - static ssize_t aac_show_max_id(struct class_device *class_dev, char *buf) 878 + static ssize_t aac_show_max_id(struct device *device, 879 + struct device_attribute *attr, char *buf) 883 880 { 884 881 return snprintf(buf, PAGE_SIZE, "%d\n", 885 - class_to_shost(class_dev)->max_id); 882 + class_to_shost(device)->max_id); 886 883 } 887 884 888 - static ssize_t aac_store_reset_adapter(struct class_device *class_dev, 889 - const char *buf, size_t count) 885 + static ssize_t aac_store_reset_adapter(struct device *device, 886 + struct device_attribute *attr, 887 + const char *buf, size_t count) 890 888 { 891 889 int retval = -EACCES; 892 890 893 891 if (!capable(CAP_SYS_ADMIN)) 894 892 return retval; 895 - retval = aac_reset_adapter((struct aac_dev*)class_to_shost(class_dev)->hostdata, buf[0] == '!'); 893 + retval = aac_reset_adapter((struct aac_dev*)class_to_shost(device)->hostdata, buf[0] == '!'); 896 894 if (retval >= 0) 897 895 retval = count; 898 896 return retval; 899 897 } 900 898 901 - static ssize_t aac_show_reset_adapter(struct class_device *class_dev, 902 - char *buf) 899 + static ssize_t aac_show_reset_adapter(struct device *device, 900 + struct device_attribute *attr, 901 + char *buf) 903 902 { 904 - struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 903 + struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; 905 904 int len, tmp; 906 905 907 906 tmp = aac_adapter_check_health(dev); ··· 915 906 return len; 916 907 } 917 908 918 - static struct class_device_attribute aac_model = { 909 + static struct device_attribute aac_model = { 919 910 .attr = { 920 911 .name = "model", 921 912 .mode = S_IRUGO, 922 913 }, 923 914 .show = aac_show_model, 924 915 }; 925 - static struct class_device_attribute aac_vendor = { 916 + static struct device_attribute aac_vendor = { 926 917 .attr = { 927 918 .name = "vendor", 928 919 .mode = S_IRUGO, 929 920 }, 930 921 .show = aac_show_vendor, 931 922 }; 932 - static struct class_device_attribute aac_flags = { 923 + static struct device_attribute aac_flags = { 933 924 .attr = { 934 925 .name = "flags", 935 926 .mode = S_IRUGO, 936 927 }, 937 928 .show = aac_show_flags, 938 929 }; 939 - static struct class_device_attribute aac_kernel_version = { 930 + static struct device_attribute aac_kernel_version = { 940 931 .attr = { 941 932 .name = "hba_kernel_version", 942 933 .mode = S_IRUGO, 943 934 }, 944 935 .show = aac_show_kernel_version, 945 936 }; 946 - static struct class_device_attribute aac_monitor_version = { 937 + static struct device_attribute aac_monitor_version = { 947 938 .attr = { 948 939 .name = "hba_monitor_version", 949 940 .mode = S_IRUGO, 950 941 }, 951 942 .show = aac_show_monitor_version, 952 943 }; 953 - static struct class_device_attribute aac_bios_version = { 944 + static struct device_attribute aac_bios_version = { 954 945 .attr = { 955 946 .name = "hba_bios_version", 956 947 .mode = S_IRUGO, 957 948 }, 958 949 .show = aac_show_bios_version, 959 950 }; 960 - static struct class_device_attribute aac_serial_number = { 951 + static struct device_attribute aac_serial_number = { 961 952 .attr = { 962 953 .name = "serial_number", 963 954 .mode = S_IRUGO, 964 955 }, 965 956 .show = aac_show_serial_number, 966 957 }; 967 - static struct class_device_attribute aac_max_channel = { 958 + static struct device_attribute aac_max_channel = { 968 959 .attr = { 969 960 .name = "max_channel", 970 961 .mode = S_IRUGO, 971 962 }, 972 963 .show = aac_show_max_channel, 973 964 }; 974 - static struct class_device_attribute aac_max_id = { 965 + static struct device_attribute aac_max_id = { 975 966 .attr = { 976 967 .name = "max_id", 977 968 .mode = S_IRUGO, 978 969 }, 979 970 .show = aac_show_max_id, 980 971 }; 981 - static struct class_device_attribute aac_reset = { 972 + static struct device_attribute aac_reset = { 982 973 .attr = { 983 974 .name = "reset_host", 984 975 .mode = S_IWUSR|S_IRUGO, ··· 987 978 .show = aac_show_reset_adapter, 988 979 }; 989 980 990 - static struct class_device_attribute *aac_attrs[] = { 981 + static struct device_attribute *aac_attrs[] = { 991 982 &aac_model, 992 983 &aac_vendor, 993 984 &aac_flags, ··· 1001 992 NULL 1002 993 }; 1003 994 995 + ssize_t aac_get_serial_number(struct device *device, char *buf) 996 + { 997 + return aac_show_serial_number(device, &aac_serial_number, buf); 998 + } 1004 999 1005 1000 static const struct file_operations aac_cfg_fops = { 1006 1001 .owner = THIS_MODULE,
+2 -2
drivers/scsi/arcmsr/arcmsr.h
··· 44 44 */ 45 45 #include <linux/interrupt.h> 46 46 47 - struct class_device_attribute; 47 + struct device_attribute; 48 48 /*The limit of outstanding scsi command that firmware can handle*/ 49 49 #define ARCMSR_MAX_OUTSTANDING_CMD 256 50 50 #define ARCMSR_MAX_FREECCB_NUM 320 ··· 556 556 extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *); 557 557 extern void arcmsr_iop_message_read(struct AdapterControlBlock *); 558 558 extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *); 559 - extern struct class_device_attribute *arcmsr_host_attrs[]; 559 + extern struct device_attribute *arcmsr_host_attrs[]; 560 560 extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *); 561 561 void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb);
+95 -66
drivers/scsi/arcmsr/arcmsr_attr.c
··· 57 57 #include <scsi/scsi_transport.h> 58 58 #include "arcmsr.h" 59 59 60 - struct class_device_attribute *arcmsr_host_attrs[]; 60 + struct device_attribute *arcmsr_host_attrs[]; 61 61 62 62 static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj, 63 63 struct bin_attribute *bin, 64 64 char *buf, loff_t off, 65 65 size_t count) 66 66 { 67 - struct class_device *cdev = container_of(kobj,struct class_device,kobj); 68 - struct Scsi_Host *host = class_to_shost(cdev); 67 + struct device *dev = container_of(kobj,struct device,kobj); 68 + struct Scsi_Host *host = class_to_shost(dev); 69 69 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 70 70 uint8_t *pQbuffer,*ptmpQbuffer; 71 71 int32_t allxfer_len = 0; ··· 110 110 char *buf, loff_t off, 111 111 size_t count) 112 112 { 113 - struct class_device *cdev = container_of(kobj,struct class_device,kobj); 114 - struct Scsi_Host *host = class_to_shost(cdev); 113 + struct device *dev = container_of(kobj,struct device,kobj); 114 + struct Scsi_Host *host = class_to_shost(dev); 115 115 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 116 116 int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex; 117 117 uint8_t *pQbuffer, *ptmpuserbuffer; ··· 158 158 char *buf, loff_t off, 159 159 size_t count) 160 160 { 161 - struct class_device *cdev = container_of(kobj,struct class_device,kobj); 162 - struct Scsi_Host *host = class_to_shost(cdev); 161 + struct device *dev = container_of(kobj,struct device,kobj); 162 + struct Scsi_Host *host = class_to_shost(dev); 163 163 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 164 164 uint8_t *pQbuffer; 165 165 ··· 220 220 struct Scsi_Host *host = acb->host; 221 221 int error; 222 222 223 - error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr); 223 + error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); 224 224 if (error) { 225 225 printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n"); 226 226 goto error_bin_file_message_read; 227 227 } 228 - error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr); 228 + error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); 229 229 if (error) { 230 230 printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed\n"); 231 231 goto error_bin_file_message_write; 232 232 } 233 - error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_clear_attr); 233 + error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); 234 234 if (error) { 235 235 printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n"); 236 236 goto error_bin_file_message_clear; 237 237 } 238 238 return 0; 239 239 error_bin_file_message_clear: 240 - sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr); 240 + sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); 241 241 error_bin_file_message_write: 242 - sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr); 242 + sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); 243 243 error_bin_file_message_read: 244 244 return error; 245 245 } 246 246 247 - void 248 - arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb) { 247 + void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb) 248 + { 249 249 struct Scsi_Host *host = acb->host; 250 250 251 - sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_clear_attr); 252 - sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr); 253 - sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr); 251 + sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); 252 + sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); 253 + sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); 254 254 } 255 255 256 256 257 257 static ssize_t 258 - arcmsr_attr_host_driver_version(struct class_device *cdev, char *buf) { 258 + arcmsr_attr_host_driver_version(struct device *dev, 259 + struct device_attribute *attr, char *buf) 260 + { 259 261 return snprintf(buf, PAGE_SIZE, 260 262 "%s\n", 261 263 ARCMSR_DRIVER_VERSION); 262 264 } 263 265 264 266 static ssize_t 265 - arcmsr_attr_host_driver_posted_cmd(struct class_device *cdev, char *buf) { 266 - struct Scsi_Host *host = class_to_shost(cdev); 267 - struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 267 + arcmsr_attr_host_driver_posted_cmd(struct device *dev, 268 + struct device_attribute *attr, char *buf) 269 + { 270 + struct Scsi_Host *host = class_to_shost(dev); 271 + struct AdapterControlBlock *acb = 272 + (struct AdapterControlBlock *) host->hostdata; 268 273 return snprintf(buf, PAGE_SIZE, 269 274 "%4d\n", 270 275 atomic_read(&acb->ccboutstandingcount)); 271 276 } 272 277 273 278 static ssize_t 274 - arcmsr_attr_host_driver_reset(struct class_device *cdev, char *buf) { 275 - struct Scsi_Host *host = class_to_shost(cdev); 276 - struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 279 + arcmsr_attr_host_driver_reset(struct device *dev, 280 + struct device_attribute *attr, char *buf) 281 + { 282 + struct Scsi_Host *host = class_to_shost(dev); 283 + struct AdapterControlBlock *acb = 284 + (struct AdapterControlBlock *) host->hostdata; 277 285 return snprintf(buf, PAGE_SIZE, 278 286 "%4d\n", 279 287 acb->num_resets); 280 288 } 281 289 282 290 static ssize_t 283 - arcmsr_attr_host_driver_abort(struct class_device *cdev, char *buf) { 284 - struct Scsi_Host *host = class_to_shost(cdev); 285 - struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 291 + arcmsr_attr_host_driver_abort(struct device *dev, 292 + struct device_attribute *attr, char *buf) 293 + { 294 + struct Scsi_Host *host = class_to_shost(dev); 295 + struct AdapterControlBlock *acb = 296 + (struct AdapterControlBlock *) host->hostdata; 286 297 return snprintf(buf, PAGE_SIZE, 287 298 "%4d\n", 288 299 acb->num_aborts); 289 300 } 290 301 291 302 static ssize_t 292 - arcmsr_attr_host_fw_model(struct class_device *cdev, char *buf) { 293 - struct Scsi_Host *host = class_to_shost(cdev); 294 - struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 303 + arcmsr_attr_host_fw_model(struct device *dev, struct device_attribute *attr, 304 + char *buf) 305 + { 306 + struct Scsi_Host *host = class_to_shost(dev); 307 + struct AdapterControlBlock *acb = 308 + (struct AdapterControlBlock *) host->hostdata; 295 309 return snprintf(buf, PAGE_SIZE, 296 310 "%s\n", 297 311 acb->firm_model); 298 312 } 299 313 300 314 static ssize_t 301 - arcmsr_attr_host_fw_version(struct class_device *cdev, char *buf) { 302 - struct Scsi_Host *host = class_to_shost(cdev); 303 - struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 315 + arcmsr_attr_host_fw_version(struct device *dev, 316 + struct device_attribute *attr, char *buf) 317 + { 318 + struct Scsi_Host *host = class_to_shost(dev); 319 + struct AdapterControlBlock *acb = 320 + (struct AdapterControlBlock *) host->hostdata; 304 321 305 322 return snprintf(buf, PAGE_SIZE, 306 323 "%s\n", ··· 325 308 } 326 309 327 310 static ssize_t 328 - arcmsr_attr_host_fw_request_len(struct class_device *cdev, char *buf) { 329 - struct Scsi_Host *host = class_to_shost(cdev); 330 - struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 311 + arcmsr_attr_host_fw_request_len(struct device *dev, 312 + struct device_attribute *attr, char *buf) 313 + { 314 + struct Scsi_Host *host = class_to_shost(dev); 315 + struct AdapterControlBlock *acb = 316 + (struct AdapterControlBlock *) host->hostdata; 331 317 332 318 return snprintf(buf, PAGE_SIZE, 333 319 "%4d\n", ··· 338 318 } 339 319 340 320 static ssize_t 341 - arcmsr_attr_host_fw_numbers_queue(struct class_device *cdev, char *buf) { 342 - struct Scsi_Host *host = class_to_shost(cdev); 343 - struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 321 + arcmsr_attr_host_fw_numbers_queue(struct device *dev, 322 + struct device_attribute *attr, char *buf) 323 + { 324 + struct Scsi_Host *host = class_to_shost(dev); 325 + struct AdapterControlBlock *acb = 326 + (struct AdapterControlBlock *) host->hostdata; 344 327 345 328 return snprintf(buf, PAGE_SIZE, 346 329 "%4d\n", ··· 351 328 } 352 329 353 330 static ssize_t 354 - arcmsr_attr_host_fw_sdram_size(struct class_device *cdev, char *buf) { 355 - struct Scsi_Host *host = class_to_shost(cdev); 356 - struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 331 + arcmsr_attr_host_fw_sdram_size(struct device *dev, 332 + struct device_attribute *attr, char *buf) 333 + { 334 + struct Scsi_Host *host = class_to_shost(dev); 335 + struct AdapterControlBlock *acb = 336 + (struct AdapterControlBlock *) host->hostdata; 357 337 358 338 return snprintf(buf, PAGE_SIZE, 359 339 "%4d\n", ··· 364 338 } 365 339 366 340 static ssize_t 367 - arcmsr_attr_host_fw_hd_channels(struct class_device *cdev, char *buf) { 368 - struct Scsi_Host *host = class_to_shost(cdev); 369 - struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 341 + arcmsr_attr_host_fw_hd_channels(struct device *dev, 342 + struct device_attribute *attr, char *buf) 343 + { 344 + struct Scsi_Host *host = class_to_shost(dev); 345 + struct AdapterControlBlock *acb = 346 + (struct AdapterControlBlock *) host->hostdata; 370 347 371 348 return snprintf(buf, PAGE_SIZE, 372 349 "%4d\n", 373 350 acb->firm_hd_channels); 374 351 } 375 352 376 - static CLASS_DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL); 377 - static CLASS_DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL); 378 - static CLASS_DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL); 379 - static CLASS_DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL); 380 - static CLASS_DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL); 381 - static CLASS_DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL); 382 - static CLASS_DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL); 383 - static CLASS_DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL); 384 - static CLASS_DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL); 385 - static CLASS_DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL); 353 + static DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL); 354 + static DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL); 355 + static DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL); 356 + static DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL); 357 + static DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL); 358 + static DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL); 359 + static DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL); 360 + static DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL); 361 + static DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL); 362 + static DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL); 386 363 387 - struct class_device_attribute *arcmsr_host_attrs[] = { 388 - &class_device_attr_host_driver_version, 389 - &class_device_attr_host_driver_posted_cmd, 390 - &class_device_attr_host_driver_reset, 391 - &class_device_attr_host_driver_abort, 392 - &class_device_attr_host_fw_model, 393 - &class_device_attr_host_fw_version, 394 - &class_device_attr_host_fw_request_len, 395 - &class_device_attr_host_fw_numbers_queue, 396 - &class_device_attr_host_fw_sdram_size, 397 - &class_device_attr_host_fw_hd_channels, 364 + struct device_attribute *arcmsr_host_attrs[] = { 365 + &dev_attr_host_driver_version, 366 + &dev_attr_host_driver_posted_cmd, 367 + &dev_attr_host_driver_reset, 368 + &dev_attr_host_driver_abort, 369 + &dev_attr_host_fw_model, 370 + &dev_attr_host_fw_version, 371 + &dev_attr_host_fw_request_len, 372 + &dev_attr_host_fw_numbers_queue, 373 + &dev_attr_host_fw_sdram_size, 374 + &dev_attr_host_fw_hd_channels, 398 375 NULL, 399 376 };
+6 -7
drivers/scsi/ch.c
··· 881 881 static int ch_probe(struct device *dev) 882 882 { 883 883 struct scsi_device *sd = to_scsi_device(dev); 884 - struct class_device *class_dev; 884 + struct device *class_dev; 885 885 int minor, ret = -ENOMEM; 886 886 scsi_changer *ch; 887 887 ··· 910 910 ch->minor = minor; 911 911 sprintf(ch->name,"ch%d",ch->minor); 912 912 913 - class_dev = class_device_create(ch_sysfs_class, NULL, 914 - MKDEV(SCSI_CHANGER_MAJOR, ch->minor), 915 - dev, "s%s", ch->name); 913 + class_dev = device_create(ch_sysfs_class, dev, 914 + MKDEV(SCSI_CHANGER_MAJOR,ch->minor), 915 + "s%s", ch->name); 916 916 if (IS_ERR(class_dev)) { 917 - printk(KERN_WARNING "ch%d: class_device_create failed\n", 917 + printk(KERN_WARNING "ch%d: device_create failed\n", 918 918 ch->minor); 919 919 ret = PTR_ERR(class_dev); 920 920 goto remove_idr; ··· 945 945 idr_remove(&ch_index_idr, ch->minor); 946 946 spin_unlock(&ch_index_lock); 947 947 948 - class_device_destroy(ch_sysfs_class, 949 - MKDEV(SCSI_CHANGER_MAJOR,ch->minor)); 948 + device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR,ch->minor)); 950 949 kfree(ch->dt); 951 950 kfree(ch); 952 951 return 0;
+17 -17
drivers/scsi/hosts.c
··· 43 43 static int scsi_host_next_hn; /* host_no for next new host */ 44 44 45 45 46 - static void scsi_host_cls_release(struct class_device *class_dev) 46 + static void scsi_host_cls_release(struct device *dev) 47 47 { 48 - put_device(&class_to_shost(class_dev)->shost_gendev); 48 + put_device(&class_to_shost(dev)->shost_gendev); 49 49 } 50 50 51 51 static struct class shost_class = { 52 52 .name = "scsi_host", 53 - .release = scsi_host_cls_release, 53 + .dev_release = scsi_host_cls_release, 54 54 }; 55 55 56 56 /** ··· 174 174 spin_unlock_irqrestore(shost->host_lock, flags); 175 175 176 176 transport_unregister_device(&shost->shost_gendev); 177 - class_device_unregister(&shost->shost_classdev); 177 + device_unregister(&shost->shost_dev); 178 178 device_del(&shost->shost_gendev); 179 179 scsi_proc_hostdir_rm(shost->hostt); 180 180 } ··· 212 212 scsi_host_set_state(shost, SHOST_RUNNING); 213 213 get_device(shost->shost_gendev.parent); 214 214 215 - error = class_device_add(&shost->shost_classdev); 215 + error = device_add(&shost->shost_dev); 216 216 if (error) 217 217 goto out_del_gendev; 218 218 ··· 223 223 GFP_KERNEL); 224 224 if (shost->shost_data == NULL) { 225 225 error = -ENOMEM; 226 - goto out_del_classdev; 226 + goto out_del_dev; 227 227 } 228 228 } 229 229 ··· 250 250 destroy_workqueue(shost->work_q); 251 251 out_free_shost_data: 252 252 kfree(shost->shost_data); 253 - out_del_classdev: 254 - class_device_del(&shost->shost_classdev); 253 + out_del_dev: 254 + device_del(&shost->shost_dev); 255 255 out_del_gendev: 256 256 device_del(&shost->shost_gendev); 257 257 out: ··· 385 385 shost->host_no); 386 386 shost->shost_gendev.release = scsi_host_dev_release; 387 387 388 - class_device_initialize(&shost->shost_classdev); 389 - shost->shost_classdev.dev = &shost->shost_gendev; 390 - shost->shost_classdev.class = &shost_class; 391 - snprintf(shost->shost_classdev.class_id, BUS_ID_SIZE, "host%d", 392 - shost->host_no); 388 + device_initialize(&shost->shost_dev); 389 + shost->shost_dev.parent = &shost->shost_gendev; 390 + shost->shost_dev.class = &shost_class; 391 + snprintf(shost->shost_dev.bus_id, BUS_ID_SIZE, "host%d", 392 + shost->host_no); 393 393 394 394 shost->ehandler = kthread_run(scsi_error_handler, shost, 395 395 "scsi_eh_%d", shost->host_no); ··· 432 432 } 433 433 EXPORT_SYMBOL(scsi_unregister); 434 434 435 - static int __scsi_host_match(struct class_device *cdev, void *data) 435 + static int __scsi_host_match(struct device *dev, void *data) 436 436 { 437 437 struct Scsi_Host *p; 438 438 unsigned short *hostnum = (unsigned short *)data; 439 439 440 - p = class_to_shost(cdev); 440 + p = class_to_shost(dev); 441 441 return p->host_no == *hostnum; 442 442 } 443 443 ··· 450 450 **/ 451 451 struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) 452 452 { 453 - struct class_device *cdev; 453 + struct device *cdev; 454 454 struct Scsi_Host *shost = ERR_PTR(-ENXIO); 455 455 456 - cdev = class_find_child(&shost_class, &hostnum, __scsi_host_match); 456 + cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match); 457 457 if (cdev) 458 458 shost = scsi_host_get(class_to_shost(cdev)); 459 459
+8 -6
drivers/scsi/hptiop.c
··· 859 859 return queue_depth; 860 860 } 861 861 862 - static ssize_t hptiop_show_version(struct class_device *class_dev, char *buf) 862 + static ssize_t hptiop_show_version(struct device *dev, 863 + struct device_attribute *attr, char *buf) 863 864 { 864 865 return snprintf(buf, PAGE_SIZE, "%s\n", driver_ver); 865 866 } 866 867 867 - static ssize_t hptiop_show_fw_version(struct class_device *class_dev, char *buf) 868 + static ssize_t hptiop_show_fw_version(struct device *dev, 869 + struct device_attribute *attr, char *buf) 868 870 { 869 - struct Scsi_Host *host = class_to_shost(class_dev); 871 + struct Scsi_Host *host = class_to_shost(dev); 870 872 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; 871 873 872 874 return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", ··· 878 876 hba->firmware_version & 0xff); 879 877 } 880 878 881 - static struct class_device_attribute hptiop_attr_version = { 879 + static struct device_attribute hptiop_attr_version = { 882 880 .attr = { 883 881 .name = "driver-version", 884 882 .mode = S_IRUGO, ··· 886 884 .show = hptiop_show_version, 887 885 }; 888 886 889 - static struct class_device_attribute hptiop_attr_fw_version = { 887 + static struct device_attribute hptiop_attr_fw_version = { 890 888 .attr = { 891 889 .name = "firmware-version", 892 890 .mode = S_IRUGO, ··· 894 892 .show = hptiop_show_fw_version, 895 893 }; 896 894 897 - static struct class_device_attribute *hptiop_attrs[] = { 895 + static struct device_attribute *hptiop_attrs[] = { 898 896 &hptiop_attr_version, 899 897 &hptiop_attr_fw_version, 900 898 NULL
+25 -19
drivers/scsi/ibmvscsi/ibmvscsi.c
··· 1456 1456 /* ------------------------------------------------------------ 1457 1457 * sysfs attributes 1458 1458 */ 1459 - static ssize_t show_host_srp_version(struct class_device *class_dev, char *buf) 1459 + static ssize_t show_host_srp_version(struct device *dev, 1460 + struct device_attribute *attr, char *buf) 1460 1461 { 1461 - struct Scsi_Host *shost = class_to_shost(class_dev); 1462 + struct Scsi_Host *shost = class_to_shost(dev); 1462 1463 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1463 1464 int len; 1464 1465 ··· 1468 1467 return len; 1469 1468 } 1470 1469 1471 - static struct class_device_attribute ibmvscsi_host_srp_version = { 1470 + static struct device_attribute ibmvscsi_host_srp_version = { 1472 1471 .attr = { 1473 1472 .name = "srp_version", 1474 1473 .mode = S_IRUGO, ··· 1476 1475 .show = show_host_srp_version, 1477 1476 }; 1478 1477 1479 - static ssize_t show_host_partition_name(struct class_device *class_dev, 1478 + static ssize_t show_host_partition_name(struct device *dev, 1479 + struct device_attribute *attr, 1480 1480 char *buf) 1481 1481 { 1482 - struct Scsi_Host *shost = class_to_shost(class_dev); 1482 + struct Scsi_Host *shost = class_to_shost(dev); 1483 1483 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1484 1484 int len; 1485 1485 ··· 1489 1487 return len; 1490 1488 } 1491 1489 1492 - static struct class_device_attribute ibmvscsi_host_partition_name = { 1490 + static struct device_attribute ibmvscsi_host_partition_name = { 1493 1491 .attr = { 1494 1492 .name = "partition_name", 1495 1493 .mode = S_IRUGO, ··· 1497 1495 .show = show_host_partition_name, 1498 1496 }; 1499 1497 1500 - static ssize_t show_host_partition_number(struct class_device *class_dev, 1498 + static ssize_t show_host_partition_number(struct device *dev, 1499 + struct device_attribute *attr, 1501 1500 char *buf) 1502 1501 { 1503 - struct Scsi_Host *shost = class_to_shost(class_dev); 1502 + struct Scsi_Host *shost = class_to_shost(dev); 1504 1503 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1505 1504 int len; 1506 1505 ··· 1510 1507 return len; 1511 1508 } 1512 1509 1513 - static struct class_device_attribute ibmvscsi_host_partition_number = { 1510 + static struct device_attribute ibmvscsi_host_partition_number = { 1514 1511 .attr = { 1515 1512 .name = "partition_number", 1516 1513 .mode = S_IRUGO, ··· 1518 1515 .show = show_host_partition_number, 1519 1516 }; 1520 1517 1521 - static ssize_t show_host_mad_version(struct class_device *class_dev, char *buf) 1518 + static ssize_t show_host_mad_version(struct device *dev, 1519 + struct device_attribute *attr, char *buf) 1522 1520 { 1523 - struct Scsi_Host *shost = class_to_shost(class_dev); 1521 + struct Scsi_Host *shost = class_to_shost(dev); 1524 1522 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1525 1523 int len; 1526 1524 ··· 1530 1526 return len; 1531 1527 } 1532 1528 1533 - static struct class_device_attribute ibmvscsi_host_mad_version = { 1529 + static struct device_attribute ibmvscsi_host_mad_version = { 1534 1530 .attr = { 1535 1531 .name = "mad_version", 1536 1532 .mode = S_IRUGO, ··· 1538 1534 .show = show_host_mad_version, 1539 1535 }; 1540 1536 1541 - static ssize_t show_host_os_type(struct class_device *class_dev, char *buf) 1537 + static ssize_t show_host_os_type(struct device *dev, 1538 + struct device_attribute *attr, char *buf) 1542 1539 { 1543 - struct Scsi_Host *shost = class_to_shost(class_dev); 1540 + struct Scsi_Host *shost = class_to_shost(dev); 1544 1541 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1545 1542 int len; 1546 1543 ··· 1549 1544 return len; 1550 1545 } 1551 1546 1552 - static struct class_device_attribute ibmvscsi_host_os_type = { 1547 + static struct device_attribute ibmvscsi_host_os_type = { 1553 1548 .attr = { 1554 1549 .name = "os_type", 1555 1550 .mode = S_IRUGO, ··· 1557 1552 .show = show_host_os_type, 1558 1553 }; 1559 1554 1560 - static ssize_t show_host_config(struct class_device *class_dev, char *buf) 1555 + static ssize_t show_host_config(struct device *dev, 1556 + struct device_attribute *attr, char *buf) 1561 1557 { 1562 - struct Scsi_Host *shost = class_to_shost(class_dev); 1558 + struct Scsi_Host *shost = class_to_shost(dev); 1563 1559 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1564 1560 1565 1561 /* returns null-terminated host config data */ ··· 1570 1564 return 0; 1571 1565 } 1572 1566 1573 - static struct class_device_attribute ibmvscsi_host_config = { 1567 + static struct device_attribute ibmvscsi_host_config = { 1574 1568 .attr = { 1575 1569 .name = "config", 1576 1570 .mode = S_IRUGO, ··· 1578 1572 .show = show_host_config, 1579 1573 }; 1580 1574 1581 - static struct class_device_attribute *ibmvscsi_attrs[] = { 1575 + static struct device_attribute *ibmvscsi_attrs[] = { 1582 1576 &ibmvscsi_host_srp_version, 1583 1577 &ibmvscsi_host_partition_name, 1584 1578 &ibmvscsi_host_partition_number,
+14 -11
drivers/scsi/ibmvscsi/ibmvstgt.c
··· 780 780 return 0; 781 781 } 782 782 783 - static ssize_t system_id_show(struct class_device *cdev, char *buf) 783 + static ssize_t system_id_show(struct device *dev, 784 + struct device_attribute *attr, char *buf) 784 785 { 785 786 return snprintf(buf, PAGE_SIZE, "%s\n", system_id); 786 787 } 787 788 788 - static ssize_t partition_number_show(struct class_device *cdev, char *buf) 789 + static ssize_t partition_number_show(struct device *dev, 790 + struct device_attribute *attr, char *buf) 789 791 { 790 792 return snprintf(buf, PAGE_SIZE, "%x\n", partition_number); 791 793 } 792 794 793 - static ssize_t unit_address_show(struct class_device *cdev, char *buf) 795 + static ssize_t unit_address_show(struct device *dev, 796 + struct device_attribute *attr, char *buf) 794 797 { 795 - struct Scsi_Host *shost = class_to_shost(cdev); 798 + struct Scsi_Host *shost = class_to_shost(dev); 796 799 struct srp_target *target = host_to_srp_target(shost); 797 800 struct vio_port *vport = target_to_port(target); 798 801 return snprintf(buf, PAGE_SIZE, "%x\n", vport->dma_dev->unit_address); 799 802 } 800 803 801 - static CLASS_DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL); 802 - static CLASS_DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL); 803 - static CLASS_DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL); 804 + static DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL); 805 + static DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL); 806 + static DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL); 804 807 805 - static struct class_device_attribute *ibmvstgt_attrs[] = { 806 - &class_device_attr_system_id, 807 - &class_device_attr_partition_number, 808 - &class_device_attr_unit_address, 808 + static struct device_attribute *ibmvstgt_attrs[] = { 809 + &dev_attr_system_id, 810 + &dev_attr_partition_number, 811 + &dev_attr_unit_address, 809 812 NULL, 810 813 }; 811 814
+75 -65
drivers/scsi/ipr.c
··· 2431 2431 } 2432 2432 2433 2433 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 2434 - kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE); 2434 + kobject_uevent(&ioa_cfg->host->shost_dev.kobj, KOBJ_CHANGE); 2435 2435 LEAVE; 2436 2436 } 2437 2437 ··· 2451 2451 struct bin_attribute *bin_attr, 2452 2452 char *buf, loff_t off, size_t count) 2453 2453 { 2454 - struct class_device *cdev = container_of(kobj,struct class_device,kobj); 2455 - struct Scsi_Host *shost = class_to_shost(cdev); 2454 + struct device *dev = container_of(kobj, struct device, kobj); 2455 + struct Scsi_Host *shost = class_to_shost(dev); 2456 2456 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2457 2457 unsigned long lock_flags = 0; 2458 2458 int size = IPR_TRACE_SIZE; ··· 2492 2492 2493 2493 /** 2494 2494 * ipr_show_write_caching - Show the write caching attribute 2495 - * @class_dev: class device struct 2496 - * @buf: buffer 2495 + * @dev: device struct 2496 + * @buf: buffer 2497 2497 * 2498 2498 * Return value: 2499 2499 * number of bytes printed to buffer 2500 2500 **/ 2501 - static ssize_t ipr_show_write_caching(struct class_device *class_dev, char *buf) 2501 + static ssize_t ipr_show_write_caching(struct device *dev, 2502 + struct device_attribute *attr, char *buf) 2502 2503 { 2503 - struct Scsi_Host *shost = class_to_shost(class_dev); 2504 + struct Scsi_Host *shost = class_to_shost(dev); 2504 2505 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2505 2506 unsigned long lock_flags = 0; 2506 2507 int i, len = 0; ··· 2520 2519 2521 2520 /** 2522 2521 * ipr_store_write_caching - Enable/disable adapter write cache 2523 - * @class_dev: class_device struct 2524 - * @buf: buffer 2525 - * @count: buffer size 2522 + * @dev: device struct 2523 + * @buf: buffer 2524 + * @count: buffer size 2526 2525 * 2527 2526 * This function will enable/disable adapter write cache. 2528 2527 * 2529 2528 * Return value: 2530 2529 * count on success / other on failure 2531 2530 **/ 2532 - static ssize_t ipr_store_write_caching(struct class_device *class_dev, 2533 - const char *buf, size_t count) 2531 + static ssize_t ipr_store_write_caching(struct device *dev, 2532 + struct device_attribute *attr, 2533 + const char *buf, size_t count) 2534 2534 { 2535 - struct Scsi_Host *shost = class_to_shost(class_dev); 2535 + struct Scsi_Host *shost = class_to_shost(dev); 2536 2536 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2537 2537 unsigned long lock_flags = 0; 2538 2538 enum ipr_cache_state new_state = CACHE_INVALID; ··· 2571 2569 return count; 2572 2570 } 2573 2571 2574 - static struct class_device_attribute ipr_ioa_cache_attr = { 2572 + static struct device_attribute ipr_ioa_cache_attr = { 2575 2573 .attr = { 2576 2574 .name = "write_cache", 2577 2575 .mode = S_IRUGO | S_IWUSR, ··· 2582 2580 2583 2581 /** 2584 2582 * ipr_show_fw_version - Show the firmware version 2585 - * @class_dev: class device struct 2586 - * @buf: buffer 2583 + * @dev: class device struct 2584 + * @buf: buffer 2587 2585 * 2588 2586 * Return value: 2589 2587 * number of bytes printed to buffer 2590 2588 **/ 2591 - static ssize_t ipr_show_fw_version(struct class_device *class_dev, char *buf) 2589 + static ssize_t ipr_show_fw_version(struct device *dev, 2590 + struct device_attribute *attr, char *buf) 2592 2591 { 2593 - struct Scsi_Host *shost = class_to_shost(class_dev); 2592 + struct Scsi_Host *shost = class_to_shost(dev); 2594 2593 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2595 2594 struct ipr_inquiry_page3 *ucode_vpd = &ioa_cfg->vpd_cbs->page3_data; 2596 2595 unsigned long lock_flags = 0; ··· 2606 2603 return len; 2607 2604 } 2608 2605 2609 - static struct class_device_attribute ipr_fw_version_attr = { 2606 + static struct device_attribute ipr_fw_version_attr = { 2610 2607 .attr = { 2611 2608 .name = "fw_version", 2612 2609 .mode = S_IRUGO, ··· 2616 2613 2617 2614 /** 2618 2615 * ipr_show_log_level - Show the adapter's error logging level 2619 - * @class_dev: class device struct 2620 - * @buf: buffer 2616 + * @dev: class device struct 2617 + * @buf: buffer 2621 2618 * 2622 2619 * Return value: 2623 2620 * number of bytes printed to buffer 2624 2621 **/ 2625 - static ssize_t ipr_show_log_level(struct class_device *class_dev, char *buf) 2622 + static ssize_t ipr_show_log_level(struct device *dev, 2623 + struct device_attribute *attr, char *buf) 2626 2624 { 2627 - struct Scsi_Host *shost = class_to_shost(class_dev); 2625 + struct Scsi_Host *shost = class_to_shost(dev); 2628 2626 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2629 2627 unsigned long lock_flags = 0; 2630 2628 int len; ··· 2638 2634 2639 2635 /** 2640 2636 * ipr_store_log_level - Change the adapter's error logging level 2641 - * @class_dev: class device struct 2642 - * @buf: buffer 2637 + * @dev: class device struct 2638 + * @buf: buffer 2643 2639 * 2644 2640 * Return value: 2645 2641 * number of bytes printed to buffer 2646 2642 **/ 2647 - static ssize_t ipr_store_log_level(struct class_device *class_dev, 2643 + static ssize_t ipr_store_log_level(struct device *dev, 2644 + struct device_attribute *attr, 2648 2645 const char *buf, size_t count) 2649 2646 { 2650 - struct Scsi_Host *shost = class_to_shost(class_dev); 2647 + struct Scsi_Host *shost = class_to_shost(dev); 2651 2648 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2652 2649 unsigned long lock_flags = 0; 2653 2650 ··· 2658 2653 return strlen(buf); 2659 2654 } 2660 2655 2661 - static struct class_device_attribute ipr_log_level_attr = { 2656 + static struct device_attribute ipr_log_level_attr = { 2662 2657 .attr = { 2663 2658 .name = "log_level", 2664 2659 .mode = S_IRUGO | S_IWUSR, ··· 2669 2664 2670 2665 /** 2671 2666 * ipr_store_diagnostics - IOA Diagnostics interface 2672 - * @class_dev: class_device struct 2673 - * @buf: buffer 2674 - * @count: buffer size 2667 + * @dev: device struct 2668 + * @buf: buffer 2669 + * @count: buffer size 2675 2670 * 2676 2671 * This function will reset the adapter and wait a reasonable 2677 2672 * amount of time for any errors that the adapter might log. ··· 2679 2674 * Return value: 2680 2675 * count on success / other on failure 2681 2676 **/ 2682 - static ssize_t ipr_store_diagnostics(struct class_device *class_dev, 2677 + static ssize_t ipr_store_diagnostics(struct device *dev, 2678 + struct device_attribute *attr, 2683 2679 const char *buf, size_t count) 2684 2680 { 2685 - struct Scsi_Host *shost = class_to_shost(class_dev); 2681 + struct Scsi_Host *shost = class_to_shost(dev); 2686 2682 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2687 2683 unsigned long lock_flags = 0; 2688 2684 int rc = count; ··· 2720 2714 return rc; 2721 2715 } 2722 2716 2723 - static struct class_device_attribute ipr_diagnostics_attr = { 2717 + static struct device_attribute ipr_diagnostics_attr = { 2724 2718 .attr = { 2725 2719 .name = "run_diagnostics", 2726 2720 .mode = S_IWUSR, ··· 2730 2724 2731 2725 /** 2732 2726 * ipr_show_adapter_state - Show the adapter's state 2733 - * @class_dev: class device struct 2734 - * @buf: buffer 2727 + * @class_dev: device struct 2728 + * @buf: buffer 2735 2729 * 2736 2730 * Return value: 2737 2731 * number of bytes printed to buffer 2738 2732 **/ 2739 - static ssize_t ipr_show_adapter_state(struct class_device *class_dev, char *buf) 2733 + static ssize_t ipr_show_adapter_state(struct device *dev, 2734 + struct device_attribute *attr, char *buf) 2740 2735 { 2741 - struct Scsi_Host *shost = class_to_shost(class_dev); 2736 + struct Scsi_Host *shost = class_to_shost(dev); 2742 2737 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2743 2738 unsigned long lock_flags = 0; 2744 2739 int len; ··· 2755 2748 2756 2749 /** 2757 2750 * ipr_store_adapter_state - Change adapter state 2758 - * @class_dev: class_device struct 2759 - * @buf: buffer 2760 - * @count: buffer size 2751 + * @dev: device struct 2752 + * @buf: buffer 2753 + * @count: buffer size 2761 2754 * 2762 2755 * This function will change the adapter's state. 2763 2756 * 2764 2757 * Return value: 2765 2758 * count on success / other on failure 2766 2759 **/ 2767 - static ssize_t ipr_store_adapter_state(struct class_device *class_dev, 2760 + static ssize_t ipr_store_adapter_state(struct device *dev, 2761 + struct device_attribute *attr, 2768 2762 const char *buf, size_t count) 2769 2763 { 2770 - struct Scsi_Host *shost = class_to_shost(class_dev); 2764 + struct Scsi_Host *shost = class_to_shost(dev); 2771 2765 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2772 2766 unsigned long lock_flags; 2773 2767 int result = count; ··· 2789 2781 return result; 2790 2782 } 2791 2783 2792 - static struct class_device_attribute ipr_ioa_state_attr = { 2784 + static struct device_attribute ipr_ioa_state_attr = { 2793 2785 .attr = { 2794 2786 .name = "state", 2795 2787 .mode = S_IRUGO | S_IWUSR, ··· 2800 2792 2801 2793 /** 2802 2794 * ipr_store_reset_adapter - Reset the adapter 2803 - * @class_dev: class_device struct 2804 - * @buf: buffer 2805 - * @count: buffer size 2795 + * @dev: device struct 2796 + * @buf: buffer 2797 + * @count: buffer size 2806 2798 * 2807 2799 * This function will reset the adapter. 2808 2800 * 2809 2801 * Return value: 2810 2802 * count on success / other on failure 2811 2803 **/ 2812 - static ssize_t ipr_store_reset_adapter(struct class_device *class_dev, 2804 + static ssize_t ipr_store_reset_adapter(struct device *dev, 2805 + struct device_attribute *attr, 2813 2806 const char *buf, size_t count) 2814 2807 { 2815 - struct Scsi_Host *shost = class_to_shost(class_dev); 2808 + struct Scsi_Host *shost = class_to_shost(dev); 2816 2809 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2817 2810 unsigned long lock_flags; 2818 2811 int result = count; ··· 2830 2821 return result; 2831 2822 } 2832 2823 2833 - static struct class_device_attribute ipr_ioa_reset_attr = { 2824 + static struct device_attribute ipr_ioa_reset_attr = { 2834 2825 .attr = { 2835 2826 .name = "reset_host", 2836 2827 .mode = S_IWUSR, ··· 3063 3054 3064 3055 /** 3065 3056 * ipr_store_update_fw - Update the firmware on the adapter 3066 - * @class_dev: class_device struct 3067 - * @buf: buffer 3068 - * @count: buffer size 3057 + * @class_dev: device struct 3058 + * @buf: buffer 3059 + * @count: buffer size 3069 3060 * 3070 3061 * This function will update the firmware on the adapter. 3071 3062 * 3072 3063 * Return value: 3073 3064 * count on success / other on failure 3074 3065 **/ 3075 - static ssize_t ipr_store_update_fw(struct class_device *class_dev, 3076 - const char *buf, size_t count) 3066 + static ssize_t ipr_store_update_fw(struct device *dev, 3067 + struct device_attribute *attr, 3068 + const char *buf, size_t count) 3077 3069 { 3078 - struct Scsi_Host *shost = class_to_shost(class_dev); 3070 + struct Scsi_Host *shost = class_to_shost(dev); 3079 3071 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 3080 3072 struct ipr_ucode_image_header *image_hdr; 3081 3073 const struct firmware *fw_entry; ··· 3134 3124 return result; 3135 3125 } 3136 3126 3137 - static struct class_device_attribute ipr_update_fw_attr = { 3127 + static struct device_attribute ipr_update_fw_attr = { 3138 3128 .attr = { 3139 3129 .name = "update_fw", 3140 3130 .mode = S_IWUSR, ··· 3142 3132 .store = ipr_store_update_fw 3143 3133 }; 3144 3134 3145 - static struct class_device_attribute *ipr_ioa_attrs[] = { 3135 + static struct device_attribute *ipr_ioa_attrs[] = { 3146 3136 &ipr_fw_version_attr, 3147 3137 &ipr_log_level_attr, 3148 3138 &ipr_diagnostics_attr, ··· 3169 3159 struct bin_attribute *bin_attr, 3170 3160 char *buf, loff_t off, size_t count) 3171 3161 { 3172 - struct class_device *cdev = container_of(kobj,struct class_device,kobj); 3162 + struct device *cdev = container_of(kobj, struct device, kobj); 3173 3163 struct Scsi_Host *shost = class_to_shost(cdev); 3174 3164 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 3175 3165 struct ipr_dump *dump; ··· 3332 3322 struct bin_attribute *bin_attr, 3333 3323 char *buf, loff_t off, size_t count) 3334 3324 { 3335 - struct class_device *cdev = container_of(kobj,struct class_device,kobj); 3325 + struct device *cdev = container_of(kobj, struct device, kobj); 3336 3326 struct Scsi_Host *shost = class_to_shost(cdev); 3337 3327 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 3338 3328 int rc; ··· 7681 7671 7682 7672 ENTER; 7683 7673 7684 - ipr_remove_trace_file(&ioa_cfg->host->shost_classdev.kobj, 7674 + ipr_remove_trace_file(&ioa_cfg->host->shost_dev.kobj, 7685 7675 &ipr_trace_attr); 7686 - ipr_remove_dump_file(&ioa_cfg->host->shost_classdev.kobj, 7676 + ipr_remove_dump_file(&ioa_cfg->host->shost_dev.kobj, 7687 7677 &ipr_dump_attr); 7688 7678 scsi_remove_host(ioa_cfg->host); 7689 7679 ··· 7724 7714 return rc; 7725 7715 } 7726 7716 7727 - rc = ipr_create_trace_file(&ioa_cfg->host->shost_classdev.kobj, 7717 + rc = ipr_create_trace_file(&ioa_cfg->host->shost_dev.kobj, 7728 7718 &ipr_trace_attr); 7729 7719 7730 7720 if (rc) { ··· 7733 7723 return rc; 7734 7724 } 7735 7725 7736 - rc = ipr_create_dump_file(&ioa_cfg->host->shost_classdev.kobj, 7726 + rc = ipr_create_dump_file(&ioa_cfg->host->shost_dev.kobj, 7737 7727 &ipr_dump_attr); 7738 7728 7739 7729 if (rc) { 7740 - ipr_remove_trace_file(&ioa_cfg->host->shost_classdev.kobj, 7730 + ipr_remove_trace_file(&ioa_cfg->host->shost_dev.kobj, 7741 7731 &ipr_trace_attr); 7742 7732 scsi_remove_host(ioa_cfg->host); 7743 7733 __ipr_remove(pdev);
+256 -226
drivers/scsi/lpfc/lpfc_attr.c
··· 66 66 } 67 67 68 68 static ssize_t 69 - lpfc_drvr_version_show(struct class_device *cdev, char *buf) 69 + lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, 70 + char *buf) 70 71 { 71 72 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); 72 73 } 73 74 74 75 static ssize_t 75 - lpfc_info_show(struct class_device *cdev, char *buf) 76 + lpfc_info_show(struct device *dev, struct device_attribute *attr, 77 + char *buf) 76 78 { 77 - struct Scsi_Host *host = class_to_shost(cdev); 79 + struct Scsi_Host *host = class_to_shost(dev); 78 80 79 81 return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); 80 82 } 81 83 82 84 static ssize_t 83 - lpfc_serialnum_show(struct class_device *cdev, char *buf) 85 + lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, 86 + char *buf) 84 87 { 85 - struct Scsi_Host *shost = class_to_shost(cdev); 88 + struct Scsi_Host *shost = class_to_shost(dev); 86 89 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 87 90 struct lpfc_hba *phba = vport->phba; 88 91 ··· 93 90 } 94 91 95 92 static ssize_t 96 - lpfc_temp_sensor_show(struct class_device *cdev, char *buf) 93 + lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, 94 + char *buf) 97 95 { 98 - struct Scsi_Host *shost = class_to_shost(cdev); 96 + struct Scsi_Host *shost = class_to_shost(dev); 99 97 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 100 98 struct lpfc_hba *phba = vport->phba; 101 99 return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); 102 100 } 103 101 104 102 static ssize_t 105 - lpfc_modeldesc_show(struct class_device *cdev, char *buf) 103 + lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, 104 + char *buf) 106 105 { 107 - struct Scsi_Host *shost = class_to_shost(cdev); 106 + struct Scsi_Host *shost = class_to_shost(dev); 108 107 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 109 108 struct lpfc_hba *phba = vport->phba; 110 109 ··· 114 109 } 115 110 116 111 static ssize_t 117 - lpfc_modelname_show(struct class_device *cdev, char *buf) 112 + lpfc_modelname_show(struct device *dev, struct device_attribute *attr, 113 + char *buf) 118 114 { 119 - struct Scsi_Host *shost = class_to_shost(cdev); 115 + struct Scsi_Host *shost = class_to_shost(dev); 120 116 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 121 117 struct lpfc_hba *phba = vport->phba; 122 118 ··· 125 119 } 126 120 127 121 static ssize_t 128 - lpfc_programtype_show(struct class_device *cdev, char *buf) 122 + lpfc_programtype_show(struct device *dev, struct device_attribute *attr, 123 + char *buf) 129 124 { 130 - struct Scsi_Host *shost = class_to_shost(cdev); 125 + struct Scsi_Host *shost = class_to_shost(dev); 131 126 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 132 127 struct lpfc_hba *phba = vport->phba; 133 128 ··· 136 129 } 137 130 138 131 static ssize_t 139 - lpfc_vportnum_show(struct class_device *cdev, char *buf) 132 + lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, 133 + char *buf) 140 134 { 141 - struct Scsi_Host *shost = class_to_shost(cdev); 135 + struct Scsi_Host *shost = class_to_shost(dev); 142 136 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 143 137 struct lpfc_hba *phba = vport->phba; 144 138 ··· 147 139 } 148 140 149 141 static ssize_t 150 - lpfc_fwrev_show(struct class_device *cdev, char *buf) 142 + lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, 143 + char *buf) 151 144 { 152 - struct Scsi_Host *shost = class_to_shost(cdev); 145 + struct Scsi_Host *shost = class_to_shost(dev); 153 146 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 154 147 struct lpfc_hba *phba = vport->phba; 155 148 char fwrev[32]; ··· 160 151 } 161 152 162 153 static ssize_t 163 - lpfc_hdw_show(struct class_device *cdev, char *buf) 154 + lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) 164 155 { 165 156 char hdw[9]; 166 - struct Scsi_Host *shost = class_to_shost(cdev); 157 + struct Scsi_Host *shost = class_to_shost(dev); 167 158 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 168 159 struct lpfc_hba *phba = vport->phba; 169 160 lpfc_vpd_t *vp = &phba->vpd; ··· 172 163 return snprintf(buf, PAGE_SIZE, "%s\n", hdw); 173 164 } 174 165 static ssize_t 175 - lpfc_option_rom_version_show(struct class_device *cdev, char *buf) 166 + lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, 167 + char *buf) 176 168 { 177 - struct Scsi_Host *shost = class_to_shost(cdev); 169 + struct Scsi_Host *shost = class_to_shost(dev); 178 170 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 179 171 struct lpfc_hba *phba = vport->phba; 180 172 181 173 return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); 182 174 } 183 175 static ssize_t 184 - lpfc_state_show(struct class_device *cdev, char *buf) 176 + lpfc_state_show(struct device *dev, struct device_attribute *attr, 177 + char *buf) 185 178 { 186 - struct Scsi_Host *shost = class_to_shost(cdev); 179 + struct Scsi_Host *shost = class_to_shost(dev); 187 180 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 188 181 struct lpfc_hba *phba = vport->phba; 189 182 int len = 0; ··· 254 243 } 255 244 256 245 static ssize_t 257 - lpfc_num_discovered_ports_show(struct class_device *cdev, char *buf) 246 + lpfc_num_discovered_ports_show(struct device *dev, 247 + struct device_attribute *attr, char *buf) 258 248 { 259 - struct Scsi_Host *shost = class_to_shost(cdev); 249 + struct Scsi_Host *shost = class_to_shost(dev); 260 250 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 261 251 262 252 return snprintf(buf, PAGE_SIZE, "%d\n", ··· 379 367 } 380 368 381 369 static ssize_t 382 - lpfc_issue_reset(struct class_device *cdev, const char *buf, size_t count) 370 + lpfc_issue_reset(struct device *dev, struct device_attribute *attr, 371 + const char *buf, size_t count) 383 372 { 384 - struct Scsi_Host *shost = class_to_shost(cdev); 373 + struct Scsi_Host *shost = class_to_shost(dev); 385 374 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 386 375 struct lpfc_hba *phba = vport->phba; 387 376 ··· 398 385 } 399 386 400 387 static ssize_t 401 - lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf) 388 + lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, 389 + char *buf) 402 390 { 403 - struct Scsi_Host *shost = class_to_shost(cdev); 391 + struct Scsi_Host *shost = class_to_shost(dev); 404 392 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 405 393 struct lpfc_hba *phba = vport->phba; 406 394 ··· 409 395 } 410 396 411 397 static ssize_t 412 - lpfc_board_mode_show(struct class_device *cdev, char *buf) 398 + lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, 399 + char *buf) 413 400 { 414 - struct Scsi_Host *shost = class_to_shost(cdev); 401 + struct Scsi_Host *shost = class_to_shost(dev); 415 402 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 416 403 struct lpfc_hba *phba = vport->phba; 417 404 char * state; ··· 430 415 } 431 416 432 417 static ssize_t 433 - lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count) 418 + lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, 419 + const char *buf, size_t count) 434 420 { 435 - struct Scsi_Host *shost = class_to_shost(cdev); 421 + struct Scsi_Host *shost = class_to_shost(dev); 436 422 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 437 423 struct lpfc_hba *phba = vport->phba; 438 424 struct completion online_compl; ··· 525 509 } 526 510 527 511 static ssize_t 528 - lpfc_max_rpi_show(struct class_device *cdev, char *buf) 512 + lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, 513 + char *buf) 529 514 { 530 - struct Scsi_Host *shost = class_to_shost(cdev); 515 + struct Scsi_Host *shost = class_to_shost(dev); 531 516 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 532 517 struct lpfc_hba *phba = vport->phba; 533 518 uint32_t cnt; ··· 539 522 } 540 523 541 524 static ssize_t 542 - lpfc_used_rpi_show(struct class_device *cdev, char *buf) 525 + lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, 526 + char *buf) 543 527 { 544 - struct Scsi_Host *shost = class_to_shost(cdev); 528 + struct Scsi_Host *shost = class_to_shost(dev); 545 529 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 546 530 struct lpfc_hba *phba = vport->phba; 547 531 uint32_t cnt, acnt; ··· 553 535 } 554 536 555 537 static ssize_t 556 - lpfc_max_xri_show(struct class_device *cdev, char *buf) 538 + lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, 539 + char *buf) 557 540 { 558 - struct Scsi_Host *shost = class_to_shost(cdev); 541 + struct Scsi_Host *shost = class_to_shost(dev); 559 542 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 560 543 struct lpfc_hba *phba = vport->phba; 561 544 uint32_t cnt; ··· 567 548 } 568 549 569 550 static ssize_t 570 - lpfc_used_xri_show(struct class_device *cdev, char *buf) 551 + lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, 552 + char *buf) 571 553 { 572 - struct Scsi_Host *shost = class_to_shost(cdev); 554 + struct Scsi_Host *shost = class_to_shost(dev); 573 555 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 574 556 struct lpfc_hba *phba = vport->phba; 575 557 uint32_t cnt, acnt; ··· 581 561 } 582 562 583 563 static ssize_t 584 - lpfc_max_vpi_show(struct class_device *cdev, char *buf) 564 + lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, 565 + char *buf) 585 566 { 586 - struct Scsi_Host *shost = class_to_shost(cdev); 567 + struct Scsi_Host *shost = class_to_shost(dev); 587 568 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 588 569 struct lpfc_hba *phba = vport->phba; 589 570 uint32_t cnt; ··· 595 574 } 596 575 597 576 static ssize_t 598 - lpfc_used_vpi_show(struct class_device *cdev, char *buf) 577 + lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, 578 + char *buf) 599 579 { 600 - struct Scsi_Host *shost = class_to_shost(cdev); 580 + struct Scsi_Host *shost = class_to_shost(dev); 601 581 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 602 582 struct lpfc_hba *phba = vport->phba; 603 583 uint32_t cnt, acnt; ··· 609 587 } 610 588 611 589 static ssize_t 612 - lpfc_npiv_info_show(struct class_device *cdev, char *buf) 590 + lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, 591 + char *buf) 613 592 { 614 - struct Scsi_Host *shost = class_to_shost(cdev); 593 + struct Scsi_Host *shost = class_to_shost(dev); 615 594 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 616 595 struct lpfc_hba *phba = vport->phba; 617 596 ··· 624 601 } 625 602 626 603 static ssize_t 627 - lpfc_poll_show(struct class_device *cdev, char *buf) 604 + lpfc_poll_show(struct device *dev, struct device_attribute *attr, 605 + char *buf) 628 606 { 629 - struct Scsi_Host *shost = class_to_shost(cdev); 607 + struct Scsi_Host *shost = class_to_shost(dev); 630 608 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 631 609 struct lpfc_hba *phba = vport->phba; 632 610 ··· 635 611 } 636 612 637 613 static ssize_t 638 - lpfc_poll_store(struct class_device *cdev, const char *buf, 639 - size_t count) 614 + lpfc_poll_store(struct device *dev, struct device_attribute *attr, 615 + const char *buf, size_t count) 640 616 { 641 - struct Scsi_Host *shost = class_to_shost(cdev); 617 + struct Scsi_Host *shost = class_to_shost(dev); 642 618 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 643 619 struct lpfc_hba *phba = vport->phba; 644 620 uint32_t creg_val; ··· 694 670 695 671 #define lpfc_param_show(attr) \ 696 672 static ssize_t \ 697 - lpfc_##attr##_show(struct class_device *cdev, char *buf) \ 673 + lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ 674 + char *buf) \ 698 675 { \ 699 - struct Scsi_Host *shost = class_to_shost(cdev);\ 676 + struct Scsi_Host *shost = class_to_shost(dev);\ 700 677 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 701 678 struct lpfc_hba *phba = vport->phba;\ 702 679 int val = 0;\ ··· 708 683 709 684 #define lpfc_param_hex_show(attr) \ 710 685 static ssize_t \ 711 - lpfc_##attr##_show(struct class_device *cdev, char *buf) \ 686 + lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ 687 + char *buf) \ 712 688 { \ 713 - struct Scsi_Host *shost = class_to_shost(cdev);\ 689 + struct Scsi_Host *shost = class_to_shost(dev);\ 714 690 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 715 691 struct lpfc_hba *phba = vport->phba;\ 716 692 int val = 0;\ ··· 751 725 752 726 #define lpfc_param_store(attr) \ 753 727 static ssize_t \ 754 - lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \ 728 + lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ 729 + const char *buf, size_t count) \ 755 730 { \ 756 - struct Scsi_Host *shost = class_to_shost(cdev);\ 731 + struct Scsi_Host *shost = class_to_shost(dev);\ 757 732 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 758 733 struct lpfc_hba *phba = vport->phba;\ 759 734 int val=0;\ ··· 770 743 771 744 #define lpfc_vport_param_show(attr) \ 772 745 static ssize_t \ 773 - lpfc_##attr##_show(struct class_device *cdev, char *buf) \ 746 + lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ 747 + char *buf) \ 774 748 { \ 775 - struct Scsi_Host *shost = class_to_shost(cdev);\ 749 + struct Scsi_Host *shost = class_to_shost(dev);\ 776 750 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 777 751 int val = 0;\ 778 752 val = vport->cfg_##attr;\ ··· 782 754 783 755 #define lpfc_vport_param_hex_show(attr) \ 784 756 static ssize_t \ 785 - lpfc_##attr##_show(struct class_device *cdev, char *buf) \ 757 + lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ 758 + char *buf) \ 786 759 { \ 787 - struct Scsi_Host *shost = class_to_shost(cdev);\ 760 + struct Scsi_Host *shost = class_to_shost(dev);\ 788 761 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 789 762 int val = 0;\ 790 763 val = vport->cfg_##attr;\ ··· 823 794 824 795 #define lpfc_vport_param_store(attr) \ 825 796 static ssize_t \ 826 - lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \ 797 + lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ 798 + const char *buf, size_t count) \ 827 799 { \ 828 - struct Scsi_Host *shost = class_to_shost(cdev);\ 800 + struct Scsi_Host *shost = class_to_shost(dev);\ 829 801 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 830 802 int val=0;\ 831 803 if (!isdigit(buf[0]))\ ··· 852 822 MODULE_PARM_DESC(lpfc_##name, desc);\ 853 823 lpfc_param_show(name)\ 854 824 lpfc_param_init(name, defval, minval, maxval)\ 855 - static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 825 + static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 856 826 857 827 #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ 858 828 static int lpfc_##name = defval;\ ··· 862 832 lpfc_param_init(name, defval, minval, maxval)\ 863 833 lpfc_param_set(name, defval, minval, maxval)\ 864 834 lpfc_param_store(name)\ 865 - static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 866 - lpfc_##name##_show, lpfc_##name##_store) 835 + static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 836 + lpfc_##name##_show, lpfc_##name##_store) 867 837 868 838 #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ 869 839 static int lpfc_##name = defval;\ ··· 871 841 MODULE_PARM_DESC(lpfc_##name, desc);\ 872 842 lpfc_param_hex_show(name)\ 873 843 lpfc_param_init(name, defval, minval, maxval)\ 874 - static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 844 + static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 875 845 876 846 #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ 877 847 static int lpfc_##name = defval;\ ··· 881 851 lpfc_param_init(name, defval, minval, maxval)\ 882 852 lpfc_param_set(name, defval, minval, maxval)\ 883 853 lpfc_param_store(name)\ 884 - static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 885 - lpfc_##name##_show, lpfc_##name##_store) 854 + static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 855 + lpfc_##name##_show, lpfc_##name##_store) 886 856 887 857 #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ 888 858 static int lpfc_##name = defval;\ ··· 896 866 MODULE_PARM_DESC(lpfc_##name, desc);\ 897 867 lpfc_vport_param_show(name)\ 898 868 lpfc_vport_param_init(name, defval, minval, maxval)\ 899 - static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 869 + static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 900 870 901 871 #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ 902 872 static int lpfc_##name = defval;\ ··· 906 876 lpfc_vport_param_init(name, defval, minval, maxval)\ 907 877 lpfc_vport_param_set(name, defval, minval, maxval)\ 908 878 lpfc_vport_param_store(name)\ 909 - static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 910 - lpfc_##name##_show, lpfc_##name##_store) 879 + static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 880 + lpfc_##name##_show, lpfc_##name##_store) 911 881 912 882 #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ 913 883 static int lpfc_##name = defval;\ ··· 915 885 MODULE_PARM_DESC(lpfc_##name, desc);\ 916 886 lpfc_vport_param_hex_show(name)\ 917 887 lpfc_vport_param_init(name, defval, minval, maxval)\ 918 - static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 888 + static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 919 889 920 890 #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ 921 891 static int lpfc_##name = defval;\ ··· 925 895 lpfc_vport_param_init(name, defval, minval, maxval)\ 926 896 lpfc_vport_param_set(name, defval, minval, maxval)\ 927 897 lpfc_vport_param_store(name)\ 928 - static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 929 - lpfc_##name##_show, lpfc_##name##_store) 898 + static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 899 + lpfc_##name##_show, lpfc_##name##_store) 930 900 931 - static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); 932 - static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); 933 - static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); 934 - static CLASS_DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); 935 - static CLASS_DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); 936 - static CLASS_DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); 937 - static CLASS_DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); 938 - static CLASS_DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); 939 - static CLASS_DEVICE_ATTR(state, S_IRUGO, lpfc_state_show, NULL); 940 - static CLASS_DEVICE_ATTR(option_rom_version, S_IRUGO, 941 - lpfc_option_rom_version_show, NULL); 942 - static CLASS_DEVICE_ATTR(num_discovered_ports, S_IRUGO, 943 - lpfc_num_discovered_ports_show, NULL); 944 - static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); 945 - static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, 946 - NULL); 947 - static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, 948 - lpfc_board_mode_show, lpfc_board_mode_store); 949 - static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 950 - static CLASS_DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); 951 - static CLASS_DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); 952 - static CLASS_DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); 953 - static CLASS_DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); 954 - static CLASS_DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); 955 - static CLASS_DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); 956 - static CLASS_DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); 957 - static CLASS_DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, 958 - NULL); 901 + static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); 902 + static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); 903 + static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); 904 + static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); 905 + static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); 906 + static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); 907 + static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); 908 + static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); 909 + static DEVICE_ATTR(state, S_IRUGO, lpfc_state_show, NULL); 910 + static DEVICE_ATTR(option_rom_version, S_IRUGO, 911 + lpfc_option_rom_version_show, NULL); 912 + static DEVICE_ATTR(num_discovered_ports, S_IRUGO, 913 + lpfc_num_discovered_ports_show, NULL); 914 + static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); 915 + static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL); 916 + static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, 917 + lpfc_board_mode_show, lpfc_board_mode_store); 918 + static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 919 + static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); 920 + static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); 921 + static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); 922 + static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); 923 + static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); 924 + static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); 925 + static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); 926 + static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL); 959 927 960 928 961 929 static char *lpfc_soft_wwn_key = "C99G71SL8032A"; 962 930 963 931 static ssize_t 964 - lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf, 965 - size_t count) 932 + lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, 933 + const char *buf, size_t count) 966 934 { 967 - struct Scsi_Host *shost = class_to_shost(cdev); 935 + struct Scsi_Host *shost = class_to_shost(dev); 968 936 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 969 937 struct lpfc_hba *phba = vport->phba; 970 938 unsigned int cnt = count; ··· 991 963 phba->soft_wwn_enable = 1; 992 964 return count; 993 965 } 994 - static CLASS_DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, 995 - lpfc_soft_wwn_enable_store); 966 + static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, 967 + lpfc_soft_wwn_enable_store); 996 968 997 969 static ssize_t 998 - lpfc_soft_wwpn_show(struct class_device *cdev, char *buf) 970 + lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, 971 + char *buf) 999 972 { 1000 - struct Scsi_Host *shost = class_to_shost(cdev); 973 + struct Scsi_Host *shost = class_to_shost(dev); 1001 974 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1002 975 struct lpfc_hba *phba = vport->phba; 1003 976 ··· 1008 979 1009 980 1010 981 static ssize_t 1011 - lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count) 982 + lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, 983 + const char *buf, size_t count) 1012 984 { 1013 - struct Scsi_Host *shost = class_to_shost(cdev); 985 + struct Scsi_Host *shost = class_to_shost(dev); 1014 986 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1015 987 struct lpfc_hba *phba = vport->phba; 1016 988 struct completion online_compl; ··· 1077 1047 "reinit adapter - %d\n", stat2); 1078 1048 return (stat1 || stat2) ? -EIO : count; 1079 1049 } 1080 - static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ 1081 - lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); 1050 + static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ 1051 + lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); 1082 1052 1083 1053 static ssize_t 1084 - lpfc_soft_wwnn_show(struct class_device *cdev, char *buf) 1054 + lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, 1055 + char *buf) 1085 1056 { 1086 - struct Scsi_Host *shost = class_to_shost(cdev); 1057 + struct Scsi_Host *shost = class_to_shost(dev); 1087 1058 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; 1088 1059 return snprintf(buf, PAGE_SIZE, "0x%llx\n", 1089 1060 (unsigned long long)phba->cfg_soft_wwnn); ··· 1092 1061 1093 1062 1094 1063 static ssize_t 1095 - lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count) 1064 + lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, 1065 + const char *buf, size_t count) 1096 1066 { 1097 - struct Scsi_Host *shost = class_to_shost(cdev); 1067 + struct Scsi_Host *shost = class_to_shost(dev); 1098 1068 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; 1099 1069 unsigned int i, j, cnt=count; 1100 1070 u8 wwnn[8]; ··· 1139 1107 1140 1108 return count; 1141 1109 } 1142 - static CLASS_DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ 1143 - lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); 1110 + static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ 1111 + lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); 1144 1112 1145 1113 1146 1114 static int lpfc_poll = 0; ··· 1150 1118 " 1 - poll with interrupts enabled" 1151 1119 " 3 - poll and disable FCP ring interrupts"); 1152 1120 1153 - static CLASS_DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, 1154 - lpfc_poll_show, lpfc_poll_store); 1121 + static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, 1122 + lpfc_poll_show, lpfc_poll_store); 1155 1123 1156 1124 int lpfc_sli_mode = 0; 1157 1125 module_param(lpfc_sli_mode, int, 0); ··· 1165 1133 MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality"); 1166 1134 lpfc_param_show(enable_npiv); 1167 1135 lpfc_param_init(enable_npiv, 0, 0, 1); 1168 - static CLASS_DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO, 1136 + static DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO, 1169 1137 lpfc_enable_npiv_show, NULL); 1170 1138 1171 1139 /* ··· 1179 1147 "Seconds driver will hold I/O waiting " 1180 1148 "for a device to come back"); 1181 1149 static ssize_t 1182 - lpfc_nodev_tmo_show(struct class_device *cdev, char *buf) 1150 + lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, 1151 + char *buf) 1183 1152 { 1184 - struct Scsi_Host *shost = class_to_shost(cdev); 1153 + struct Scsi_Host *shost = class_to_shost(dev); 1185 1154 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1186 1155 int val = 0; 1187 1156 val = vport->cfg_devloss_tmo; ··· 1254 1221 1255 1222 lpfc_vport_param_store(nodev_tmo) 1256 1223 1257 - static CLASS_DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, 1258 - lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); 1224 + static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, 1225 + lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); 1259 1226 1260 1227 /* 1261 1228 # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that ··· 1288 1255 } 1289 1256 1290 1257 lpfc_vport_param_store(devloss_tmo) 1291 - static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, 1292 - lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); 1258 + static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, 1259 + lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); 1293 1260 1294 1261 /* 1295 1262 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being ··· 1407 1374 return 0; 1408 1375 } 1409 1376 lpfc_vport_param_store(restrict_login); 1410 - static CLASS_DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, 1411 - lpfc_restrict_login_show, lpfc_restrict_login_store); 1377 + static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, 1378 + lpfc_restrict_login_show, lpfc_restrict_login_store); 1412 1379 1413 1380 /* 1414 1381 # Some disk devices have a "select ID" or "select Target" capability. ··· 1466 1433 lpfc_param_show(topology) 1467 1434 lpfc_param_init(topology, 0, 0, 6) 1468 1435 lpfc_param_store(topology) 1469 - static CLASS_DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, 1436 + static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, 1470 1437 lpfc_topology_show, lpfc_topology_store); 1471 1438 1472 1439 /* ··· 1530 1497 } 1531 1498 1532 1499 lpfc_param_store(link_speed) 1533 - static CLASS_DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, 1500 + static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, 1534 1501 lpfc_link_speed_show, lpfc_link_speed_store); 1535 1502 1536 1503 /* ··· 1656 1623 LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, 1657 1624 LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); 1658 1625 1659 - struct class_device_attribute *lpfc_hba_attrs[] = { 1660 - &class_device_attr_info, 1661 - &class_device_attr_serialnum, 1662 - &class_device_attr_modeldesc, 1663 - &class_device_attr_modelname, 1664 - &class_device_attr_programtype, 1665 - &class_device_attr_portnum, 1666 - &class_device_attr_fwrev, 1667 - &class_device_attr_hdw, 1668 - &class_device_attr_option_rom_version, 1669 - &class_device_attr_state, 1670 - &class_device_attr_num_discovered_ports, 1671 - &class_device_attr_lpfc_drvr_version, 1672 - &class_device_attr_lpfc_temp_sensor, 1673 - &class_device_attr_lpfc_log_verbose, 1674 - &class_device_attr_lpfc_lun_queue_depth, 1675 - &class_device_attr_lpfc_hba_queue_depth, 1676 - &class_device_attr_lpfc_peer_port_login, 1677 - &class_device_attr_lpfc_nodev_tmo, 1678 - &class_device_attr_lpfc_devloss_tmo, 1679 - &class_device_attr_lpfc_fcp_class, 1680 - &class_device_attr_lpfc_use_adisc, 1681 - &class_device_attr_lpfc_ack0, 1682 - &class_device_attr_lpfc_topology, 1683 - &class_device_attr_lpfc_scan_down, 1684 - &class_device_attr_lpfc_link_speed, 1685 - &class_device_attr_lpfc_cr_delay, 1686 - &class_device_attr_lpfc_cr_count, 1687 - &class_device_attr_lpfc_multi_ring_support, 1688 - &class_device_attr_lpfc_multi_ring_rctl, 1689 - &class_device_attr_lpfc_multi_ring_type, 1690 - &class_device_attr_lpfc_fdmi_on, 1691 - &class_device_attr_lpfc_max_luns, 1692 - &class_device_attr_lpfc_enable_npiv, 1693 - &class_device_attr_nport_evt_cnt, 1694 - &class_device_attr_board_mode, 1695 - &class_device_attr_max_vpi, 1696 - &class_device_attr_used_vpi, 1697 - &class_device_attr_max_rpi, 1698 - &class_device_attr_used_rpi, 1699 - &class_device_attr_max_xri, 1700 - &class_device_attr_used_xri, 1701 - &class_device_attr_npiv_info, 1702 - &class_device_attr_issue_reset, 1703 - &class_device_attr_lpfc_poll, 1704 - &class_device_attr_lpfc_poll_tmo, 1705 - &class_device_attr_lpfc_use_msi, 1706 - &class_device_attr_lpfc_soft_wwnn, 1707 - &class_device_attr_lpfc_soft_wwpn, 1708 - &class_device_attr_lpfc_soft_wwn_enable, 1709 - &class_device_attr_lpfc_enable_hba_reset, 1710 - &class_device_attr_lpfc_enable_hba_heartbeat, 1711 - &class_device_attr_lpfc_sg_seg_cnt, 1626 + struct device_attribute *lpfc_hba_attrs[] = { 1627 + &dev_attr_info, 1628 + &dev_attr_serialnum, 1629 + &dev_attr_modeldesc, 1630 + &dev_attr_modelname, 1631 + &dev_attr_programtype, 1632 + &dev_attr_portnum, 1633 + &dev_attr_fwrev, 1634 + &dev_attr_hdw, 1635 + &dev_attr_option_rom_version, 1636 + &dev_attr_state, 1637 + &dev_attr_num_discovered_ports, 1638 + &dev_attr_lpfc_drvr_version, 1639 + &dev_attr_lpfc_temp_sensor, 1640 + &dev_attr_lpfc_log_verbose, 1641 + &dev_attr_lpfc_lun_queue_depth, 1642 + &dev_attr_lpfc_hba_queue_depth, 1643 + &dev_attr_lpfc_peer_port_login, 1644 + &dev_attr_lpfc_nodev_tmo, 1645 + &dev_attr_lpfc_devloss_tmo, 1646 + &dev_attr_lpfc_fcp_class, 1647 + &dev_attr_lpfc_use_adisc, 1648 + &dev_attr_lpfc_ack0, 1649 + &dev_attr_lpfc_topology, 1650 + &dev_attr_lpfc_scan_down, 1651 + &dev_attr_lpfc_link_speed, 1652 + &dev_attr_lpfc_cr_delay, 1653 + &dev_attr_lpfc_cr_count, 1654 + &dev_attr_lpfc_multi_ring_support, 1655 + &dev_attr_lpfc_multi_ring_rctl, 1656 + &dev_attr_lpfc_multi_ring_type, 1657 + &dev_attr_lpfc_fdmi_on, 1658 + &dev_attr_lpfc_max_luns, 1659 + &dev_attr_lpfc_enable_npiv, 1660 + &dev_attr_nport_evt_cnt, 1661 + &dev_attr_board_mode, 1662 + &dev_attr_max_vpi, 1663 + &dev_attr_used_vpi, 1664 + &dev_attr_max_rpi, 1665 + &dev_attr_used_rpi, 1666 + &dev_attr_max_xri, 1667 + &dev_attr_used_xri, 1668 + &dev_attr_npiv_info, 1669 + &dev_attr_issue_reset, 1670 + &dev_attr_lpfc_poll, 1671 + &dev_attr_lpfc_poll_tmo, 1672 + &dev_attr_lpfc_use_msi, 1673 + &dev_attr_lpfc_soft_wwnn, 1674 + &dev_attr_lpfc_soft_wwpn, 1675 + &dev_attr_lpfc_soft_wwn_enable, 1676 + &dev_attr_lpfc_enable_hba_reset, 1677 + &dev_attr_lpfc_enable_hba_heartbeat, 1678 + &dev_attr_lpfc_sg_seg_cnt, 1712 1679 NULL, 1713 1680 }; 1714 1681 1715 - struct class_device_attribute *lpfc_vport_attrs[] = { 1716 - &class_device_attr_info, 1717 - &class_device_attr_state, 1718 - &class_device_attr_num_discovered_ports, 1719 - &class_device_attr_lpfc_drvr_version, 1720 - 1721 - &class_device_attr_lpfc_log_verbose, 1722 - &class_device_attr_lpfc_lun_queue_depth, 1723 - &class_device_attr_lpfc_nodev_tmo, 1724 - &class_device_attr_lpfc_devloss_tmo, 1725 - &class_device_attr_lpfc_hba_queue_depth, 1726 - &class_device_attr_lpfc_peer_port_login, 1727 - &class_device_attr_lpfc_restrict_login, 1728 - &class_device_attr_lpfc_fcp_class, 1729 - &class_device_attr_lpfc_use_adisc, 1730 - &class_device_attr_lpfc_fdmi_on, 1731 - &class_device_attr_lpfc_max_luns, 1732 - &class_device_attr_nport_evt_cnt, 1733 - &class_device_attr_npiv_info, 1734 - &class_device_attr_lpfc_enable_da_id, 1682 + struct device_attribute *lpfc_vport_attrs[] = { 1683 + &dev_attr_info, 1684 + &dev_attr_state, 1685 + &dev_attr_num_discovered_ports, 1686 + &dev_attr_lpfc_drvr_version, 1687 + &dev_attr_lpfc_log_verbose, 1688 + &dev_attr_lpfc_lun_queue_depth, 1689 + &dev_attr_lpfc_nodev_tmo, 1690 + &dev_attr_lpfc_devloss_tmo, 1691 + &dev_attr_lpfc_hba_queue_depth, 1692 + &dev_attr_lpfc_peer_port_login, 1693 + &dev_attr_lpfc_restrict_login, 1694 + &dev_attr_lpfc_fcp_class, 1695 + &dev_attr_lpfc_use_adisc, 1696 + &dev_attr_lpfc_fdmi_on, 1697 + &dev_attr_lpfc_max_luns, 1698 + &dev_attr_nport_evt_cnt, 1699 + &dev_attr_npiv_info, 1700 + &dev_attr_lpfc_enable_da_id, 1735 1701 NULL, 1736 1702 }; 1737 1703 ··· 1739 1707 char *buf, loff_t off, size_t count) 1740 1708 { 1741 1709 size_t buf_off; 1742 - struct class_device *cdev = container_of(kobj, struct class_device, 1743 - kobj); 1744 - struct Scsi_Host *shost = class_to_shost(cdev); 1710 + struct device *dev = container_of(kobj, struct device, kobj); 1711 + struct Scsi_Host *shost = class_to_shost(dev); 1745 1712 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1746 1713 struct lpfc_hba *phba = vport->phba; 1747 1714 ··· 1772 1741 { 1773 1742 size_t buf_off; 1774 1743 uint32_t * tmp_ptr; 1775 - struct class_device *cdev = container_of(kobj, struct class_device, 1776 - kobj); 1777 - struct Scsi_Host *shost = class_to_shost(cdev); 1744 + struct device *dev = container_of(kobj, struct device, kobj); 1745 + struct Scsi_Host *shost = class_to_shost(dev); 1778 1746 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1779 1747 struct lpfc_hba *phba = vport->phba; 1780 1748 ··· 1828 1798 sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, 1829 1799 char *buf, loff_t off, size_t count) 1830 1800 { 1831 - struct class_device *cdev = container_of(kobj, struct class_device, 1832 - kobj); 1833 - struct Scsi_Host *shost = class_to_shost(cdev); 1801 + struct device *dev = container_of(kobj, struct device, kobj); 1802 + struct Scsi_Host *shost = class_to_shost(dev); 1834 1803 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1835 1804 struct lpfc_hba *phba = vport->phba; 1836 1805 struct lpfcMboxq *mbox = NULL; ··· 1882 1853 sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, 1883 1854 char *buf, loff_t off, size_t count) 1884 1855 { 1885 - struct class_device *cdev = container_of(kobj, struct class_device, 1886 - kobj); 1887 - struct Scsi_Host *shost = class_to_shost(cdev); 1856 + struct device *dev = container_of(kobj, struct device, kobj); 1857 + struct Scsi_Host *shost = class_to_shost(dev); 1888 1858 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1889 1859 struct lpfc_hba *phba = vport->phba; 1890 1860 int rc; ··· 2066 2038 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2067 2039 int error; 2068 2040 2069 - error = sysfs_create_bin_file(&shost->shost_classdev.kobj, 2041 + error = sysfs_create_bin_file(&shost->shost_dev.kobj, 2070 2042 &sysfs_ctlreg_attr); 2071 2043 if (error) 2072 2044 goto out; 2073 2045 2074 - error = sysfs_create_bin_file(&shost->shost_classdev.kobj, 2046 + error = sysfs_create_bin_file(&shost->shost_dev.kobj, 2075 2047 &sysfs_mbox_attr); 2076 2048 if (error) 2077 2049 goto out_remove_ctlreg_attr; 2078 2050 2079 2051 return 0; 2080 2052 out_remove_ctlreg_attr: 2081 - sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_ctlreg_attr); 2053 + sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); 2082 2054 out: 2083 2055 return error; 2084 2056 } ··· 2088 2060 { 2089 2061 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2090 2062 2091 - sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_mbox_attr); 2092 - sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_ctlreg_attr); 2063 + sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); 2064 + sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); 2093 2065 } 2094 2066 2095 2067 ··· 2471 2443 2472 2444 #define lpfc_rport_show_function(field, format_string, sz, cast) \ 2473 2445 static ssize_t \ 2474 - lpfc_show_rport_##field (struct class_device *cdev, char *buf) \ 2446 + lpfc_show_rport_##field (struct device *dev, \ 2447 + struct device_attribute *attr, \ 2448 + char *buf) \ 2475 2449 { \ 2476 - struct fc_rport *rport = transport_class_to_rport(cdev); \ 2450 + struct fc_rport *rport = transport_class_to_rport(dev); \ 2477 2451 struct lpfc_rport_data *rdata = rport->hostdata; \ 2478 2452 return snprintf(buf, sz, format_string, \ 2479 2453 (rdata->target) ? cast rdata->target->field : 0); \
+2 -2
drivers/scsi/lpfc/lpfc_crtn.h
··· 253 253 void lpfc_get_vport_cfgparam(struct lpfc_vport *); 254 254 int lpfc_alloc_sysfs_attr(struct lpfc_vport *); 255 255 void lpfc_free_sysfs_attr(struct lpfc_vport *); 256 - extern struct class_device_attribute *lpfc_hba_attrs[]; 257 - extern struct class_device_attribute *lpfc_vport_attrs[]; 256 + extern struct device_attribute *lpfc_hba_attrs[]; 257 + extern struct device_attribute *lpfc_vport_attrs[]; 258 258 extern struct scsi_host_template lpfc_template; 259 259 extern struct scsi_host_template lpfc_vport_template; 260 260 extern struct fc_function_template lpfc_transport_functions;
+7 -6
drivers/scsi/megaraid/megaraid_mbox.c
··· 125 125 126 126 static void megaraid_mbox_dpc(unsigned long); 127 127 128 - static ssize_t megaraid_sysfs_show_app_hndl(struct class_device *, char *); 128 + static ssize_t megaraid_sysfs_show_app_hndl(struct device *, struct device_attribute *attr, char *); 129 129 static ssize_t megaraid_sysfs_show_ldnum(struct device *, struct device_attribute *attr, char *); 130 130 131 131 static int megaraid_cmm_register(adapter_t *); ··· 313 313 // definitions for the device attributes for exporting logical drive number 314 314 // for a scsi address (Host, Channel, Id, Lun) 315 315 316 - CLASS_DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl, 316 + DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl, 317 317 NULL); 318 318 319 319 // Host template initializer for megaraid mbox sysfs device attributes 320 - static struct class_device_attribute *megaraid_shost_attrs[] = { 321 - &class_device_attr_megaraid_mbox_app_hndl, 320 + static struct device_attribute *megaraid_shost_attrs[] = { 321 + &dev_attr_megaraid_mbox_app_hndl, 322 322 NULL, 323 323 }; 324 324 ··· 4063 4063 * handle, since we do not interface with applications directly. 4064 4064 */ 4065 4065 static ssize_t 4066 - megaraid_sysfs_show_app_hndl(struct class_device *cdev, char *buf) 4066 + megaraid_sysfs_show_app_hndl(struct device *dev, struct device_attribute *attr, 4067 + char *buf) 4067 4068 { 4068 - struct Scsi_Host *shost = class_to_shost(cdev); 4069 + struct Scsi_Host *shost = class_to_shost(dev); 4069 4070 adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(shost); 4070 4071 uint32_t app_hndl; 4071 4072
+4 -3
drivers/scsi/ncr53c8xx.c
··· 8243 8243 8244 8244 #undef next_wcmd 8245 8245 8246 - static ssize_t show_ncr53c8xx_revision(struct class_device *dev, char *buf) 8246 + static ssize_t show_ncr53c8xx_revision(struct device *dev, 8247 + struct device_attribute *attr, char *buf) 8247 8248 { 8248 8249 struct Scsi_Host *host = class_to_shost(dev); 8249 8250 struct host_data *host_data = (struct host_data *)host->hostdata; ··· 8252 8251 return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id); 8253 8252 } 8254 8253 8255 - static struct class_device_attribute ncr53c8xx_revision_attr = { 8254 + static struct device_attribute ncr53c8xx_revision_attr = { 8256 8255 .attr = { .name = "revision", .mode = S_IRUGO, }, 8257 8256 .show = show_ncr53c8xx_revision, 8258 8257 }; 8259 8258 8260 - static struct class_device_attribute *ncr53c8xx_host_attrs[] = { 8259 + static struct device_attribute *ncr53c8xx_host_attrs[] = { 8261 8260 &ncr53c8xx_revision_attr, 8262 8261 NULL 8263 8262 };
+39 -37
drivers/scsi/osst.c
··· 5591 5591 * sysfs support for accessing ADR header information 5592 5592 */ 5593 5593 5594 - static ssize_t osst_adr_rev_show(struct class_device *class_dev, char *buf) 5594 + static ssize_t osst_adr_rev_show(struct device *dev, 5595 + struct device_attribute *attr, char *buf) 5595 5596 { 5596 - struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5597 + struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); 5597 5598 ssize_t l = 0; 5598 5599 5599 5600 if (STp && STp->header_ok && STp->linux_media) ··· 5602 5601 return l; 5603 5602 } 5604 5603 5605 - CLASS_DEVICE_ATTR(ADR_rev, S_IRUGO, osst_adr_rev_show, NULL); 5604 + DEVICE_ATTR(ADR_rev, S_IRUGO, osst_adr_rev_show, NULL); 5606 5605 5607 - static ssize_t osst_linux_media_version_show(struct class_device *class_dev, char *buf) 5606 + static ssize_t osst_linux_media_version_show(struct device *dev, 5607 + struct device_attribute *attr, 5608 + char *buf) 5608 5609 { 5609 - struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5610 + struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); 5610 5611 ssize_t l = 0; 5611 5612 5612 5613 if (STp && STp->header_ok && STp->linux_media) ··· 5616 5613 return l; 5617 5614 } 5618 5615 5619 - CLASS_DEVICE_ATTR(media_version, S_IRUGO, osst_linux_media_version_show, NULL); 5616 + DEVICE_ATTR(media_version, S_IRUGO, osst_linux_media_version_show, NULL); 5620 5617 5621 - static ssize_t osst_capacity_show(struct class_device *class_dev, char *buf) 5618 + static ssize_t osst_capacity_show(struct device *dev, 5619 + struct device_attribute *attr, char *buf) 5622 5620 { 5623 - struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5621 + struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); 5624 5622 ssize_t l = 0; 5625 5623 5626 5624 if (STp && STp->header_ok && STp->linux_media) ··· 5629 5625 return l; 5630 5626 } 5631 5627 5632 - CLASS_DEVICE_ATTR(capacity, S_IRUGO, osst_capacity_show, NULL); 5628 + DEVICE_ATTR(capacity, S_IRUGO, osst_capacity_show, NULL); 5633 5629 5634 - static ssize_t osst_first_data_ppos_show(struct class_device *class_dev, char *buf) 5630 + static ssize_t osst_first_data_ppos_show(struct device *dev, 5631 + struct device_attribute *attr, 5632 + char *buf) 5635 5633 { 5636 - struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5634 + struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); 5637 5635 ssize_t l = 0; 5638 5636 5639 5637 if (STp && STp->header_ok && STp->linux_media) ··· 5643 5637 return l; 5644 5638 } 5645 5639 5646 - CLASS_DEVICE_ATTR(BOT_frame, S_IRUGO, osst_first_data_ppos_show, NULL); 5640 + DEVICE_ATTR(BOT_frame, S_IRUGO, osst_first_data_ppos_show, NULL); 5647 5641 5648 - static ssize_t osst_eod_frame_ppos_show(struct class_device *class_dev, char *buf) 5642 + static ssize_t osst_eod_frame_ppos_show(struct device *dev, 5643 + struct device_attribute *attr, 5644 + char *buf) 5649 5645 { 5650 - struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5646 + struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); 5651 5647 ssize_t l = 0; 5652 5648 5653 5649 if (STp && STp->header_ok && STp->linux_media) ··· 5657 5649 return l; 5658 5650 } 5659 5651 5660 - CLASS_DEVICE_ATTR(EOD_frame, S_IRUGO, osst_eod_frame_ppos_show, NULL); 5652 + DEVICE_ATTR(EOD_frame, S_IRUGO, osst_eod_frame_ppos_show, NULL); 5661 5653 5662 - static ssize_t osst_filemark_cnt_show(struct class_device *class_dev, char *buf) 5654 + static ssize_t osst_filemark_cnt_show(struct device *dev, 5655 + struct device_attribute *attr, char *buf) 5663 5656 { 5664 - struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5657 + struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); 5665 5658 ssize_t l = 0; 5666 5659 5667 5660 if (STp && STp->header_ok && STp->linux_media) ··· 5670 5661 return l; 5671 5662 } 5672 5663 5673 - CLASS_DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL); 5664 + DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL); 5674 5665 5675 5666 static struct class *osst_sysfs_class; 5676 5667 ··· 5687 5678 5688 5679 static void osst_sysfs_destroy(dev_t dev) 5689 5680 { 5690 - class_device_destroy(osst_sysfs_class, dev); 5681 + device_destroy(osst_sysfs_class, dev); 5691 5682 } 5692 5683 5693 5684 static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * STp, char * name) 5694 5685 { 5695 - struct class_device *osst_class_member; 5686 + struct device *osst_member; 5696 5687 int err; 5697 5688 5698 - osst_class_member = class_device_create(osst_sysfs_class, NULL, dev, 5699 - device, "%s", name); 5700 - if (IS_ERR(osst_class_member)) { 5689 + osst_member = device_create(osst_sysfs_class, device, dev, "%s", name); 5690 + if (IS_ERR(osst_member)) { 5701 5691 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); 5702 - return PTR_ERR(osst_class_member); 5692 + return PTR_ERR(osst_member); 5703 5693 } 5704 5694 5705 - class_set_devdata(osst_class_member, STp); 5706 - err = class_device_create_file(osst_class_member, 5707 - &class_device_attr_ADR_rev); 5695 + dev_set_drvdata(osst_member, STp); 5696 + err = device_create_file(osst_member, &dev_attr_ADR_rev); 5708 5697 if (err) 5709 5698 goto err_out; 5710 - err = class_device_create_file(osst_class_member, 5711 - &class_device_attr_media_version); 5699 + err = device_create_file(osst_member, &dev_attr_media_version); 5712 5700 if (err) 5713 5701 goto err_out; 5714 - err = class_device_create_file(osst_class_member, 5715 - &class_device_attr_capacity); 5702 + err = device_create_file(osst_member, &dev_attr_capacity); 5716 5703 if (err) 5717 5704 goto err_out; 5718 - err = class_device_create_file(osst_class_member, 5719 - &class_device_attr_BOT_frame); 5705 + err = device_create_file(osst_member, &dev_attr_BOT_frame); 5720 5706 if (err) 5721 5707 goto err_out; 5722 - err = class_device_create_file(osst_class_member, 5723 - &class_device_attr_EOD_frame); 5708 + err = device_create_file(osst_member, &dev_attr_EOD_frame); 5724 5709 if (err) 5725 5710 goto err_out; 5726 - err = class_device_create_file(osst_class_member, 5727 - &class_device_attr_file_count); 5711 + err = device_create_file(osst_member, &dev_attr_file_count); 5728 5712 if (err) 5729 5713 goto err_out; 5730 5714
+8 -6
drivers/scsi/pcmcia/sym53c500_cs.c
··· 632 632 } 633 633 634 634 static ssize_t 635 - SYM53C500_show_pio(struct class_device *cdev, char *buf) 635 + SYM53C500_show_pio(struct device *dev, struct device_attribute *attr, 636 + char *buf) 636 637 { 637 - struct Scsi_Host *SHp = class_to_shost(cdev); 638 + struct Scsi_Host *SHp = class_to_shost(dev); 638 639 struct sym53c500_data *data = 639 640 (struct sym53c500_data *)SHp->hostdata; 640 641 ··· 643 642 } 644 643 645 644 static ssize_t 646 - SYM53C500_store_pio(struct class_device *cdev, const char *buf, size_t count) 645 + SYM53C500_store_pio(struct device *dev, struct device_attribute *attr, 646 + const char *buf, size_t count) 647 647 { 648 648 int pio; 649 - struct Scsi_Host *SHp = class_to_shost(cdev); 649 + struct Scsi_Host *SHp = class_to_shost(dev); 650 650 struct sym53c500_data *data = 651 651 (struct sym53c500_data *)SHp->hostdata; 652 652 ··· 664 662 * SCSI HBA device attributes we want to 665 663 * make available via sysfs. 666 664 */ 667 - static struct class_device_attribute SYM53C500_pio_attr = { 665 + static struct device_attribute SYM53C500_pio_attr = { 668 666 .attr = { 669 667 .name = "fast_pio", 670 668 .mode = (S_IRUGO | S_IWUSR), ··· 673 671 .store = SYM53C500_store_pio, 674 672 }; 675 673 676 - static struct class_device_attribute *SYM53C500_shost_attrs[] = { 674 + static struct device_attribute *SYM53C500_shost_attrs[] = { 677 675 &SYM53C500_pio_attr, 678 676 NULL, 679 677 };
+95 -80
drivers/scsi/qla2xxx/qla_attr.c
··· 530 530 /* Scsi_Host attributes. */ 531 531 532 532 static ssize_t 533 - qla2x00_drvr_version_show(struct class_device *cdev, char *buf) 533 + qla2x00_drvr_version_show(struct device *dev, 534 + struct device_attribute *attr, char *buf) 534 535 { 535 536 return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str); 536 537 } 537 538 538 539 static ssize_t 539 - qla2x00_fw_version_show(struct class_device *cdev, char *buf) 540 + qla2x00_fw_version_show(struct device *dev, 541 + struct device_attribute *attr, char *buf) 540 542 { 541 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 543 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 542 544 char fw_str[30]; 543 545 544 546 return snprintf(buf, PAGE_SIZE, "%s\n", ··· 548 546 } 549 547 550 548 static ssize_t 551 - qla2x00_serial_num_show(struct class_device *cdev, char *buf) 549 + qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr, 550 + char *buf) 552 551 { 553 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 552 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 554 553 uint32_t sn; 555 554 556 555 if (IS_FWI2_CAPABLE(ha)) ··· 563 560 } 564 561 565 562 static ssize_t 566 - qla2x00_isp_name_show(struct class_device *cdev, char *buf) 563 + qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr, 564 + char *buf) 567 565 { 568 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 566 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 569 567 return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device); 570 568 } 571 569 572 570 static ssize_t 573 - qla2x00_isp_id_show(struct class_device *cdev, char *buf) 571 + qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr, 572 + char *buf) 574 573 { 575 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 574 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 576 575 return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", 577 576 ha->product_id[0], ha->product_id[1], ha->product_id[2], 578 577 ha->product_id[3]); 579 578 } 580 579 581 580 static ssize_t 582 - qla2x00_model_name_show(struct class_device *cdev, char *buf) 581 + qla2x00_model_name_show(struct device *dev, struct device_attribute *attr, 582 + char *buf) 583 583 { 584 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 584 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 585 585 return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number); 586 586 } 587 587 588 588 static ssize_t 589 - qla2x00_model_desc_show(struct class_device *cdev, char *buf) 589 + qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr, 590 + char *buf) 590 591 { 591 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 592 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 592 593 return snprintf(buf, PAGE_SIZE, "%s\n", 593 594 ha->model_desc ? ha->model_desc: ""); 594 595 } 595 596 596 597 static ssize_t 597 - qla2x00_pci_info_show(struct class_device *cdev, char *buf) 598 + qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr, 599 + char *buf) 598 600 { 599 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 601 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 600 602 char pci_info[30]; 601 603 602 604 return snprintf(buf, PAGE_SIZE, "%s\n", ··· 609 601 } 610 602 611 603 static ssize_t 612 - qla2x00_state_show(struct class_device *cdev, char *buf) 604 + qla2x00_state_show(struct device *dev, struct device_attribute *attr, 605 + char *buf) 613 606 { 614 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 607 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 615 608 int len = 0; 616 609 617 610 if (atomic_read(&ha->loop_state) == LOOP_DOWN || ··· 648 639 } 649 640 650 641 static ssize_t 651 - qla2x00_zio_show(struct class_device *cdev, char *buf) 642 + qla2x00_zio_show(struct device *dev, struct device_attribute *attr, 643 + char *buf) 652 644 { 653 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 645 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 654 646 int len = 0; 655 647 656 648 switch (ha->zio_mode) { ··· 666 656 } 667 657 668 658 static ssize_t 669 - qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count) 659 + qla2x00_zio_store(struct device *dev, struct device_attribute *attr, 660 + const char *buf, size_t count) 670 661 { 671 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 662 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 672 663 int val = 0; 673 664 uint16_t zio_mode; 674 665 ··· 693 682 } 694 683 695 684 static ssize_t 696 - qla2x00_zio_timer_show(struct class_device *cdev, char *buf) 685 + qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr, 686 + char *buf) 697 687 { 698 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 688 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 699 689 700 690 return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100); 701 691 } 702 692 703 693 static ssize_t 704 - qla2x00_zio_timer_store(struct class_device *cdev, const char *buf, 705 - size_t count) 694 + qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr, 695 + const char *buf, size_t count) 706 696 { 707 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 697 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 708 698 int val = 0; 709 699 uint16_t zio_timer; 710 700 ··· 721 709 } 722 710 723 711 static ssize_t 724 - qla2x00_beacon_show(struct class_device *cdev, char *buf) 712 + qla2x00_beacon_show(struct device *dev, struct device_attribute *attr, 713 + char *buf) 725 714 { 726 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 715 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 727 716 int len = 0; 728 717 729 718 if (ha->beacon_blink_led) ··· 735 722 } 736 723 737 724 static ssize_t 738 - qla2x00_beacon_store(struct class_device *cdev, const char *buf, 739 - size_t count) 725 + qla2x00_beacon_store(struct device *dev, struct device_attribute *attr, 726 + const char *buf, size_t count) 740 727 { 741 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 728 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 742 729 int val = 0; 743 730 int rval; 744 731 ··· 766 753 } 767 754 768 755 static ssize_t 769 - qla2x00_optrom_bios_version_show(struct class_device *cdev, char *buf) 756 + qla2x00_optrom_bios_version_show(struct device *dev, 757 + struct device_attribute *attr, char *buf) 770 758 { 771 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 759 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 772 760 773 761 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1], 774 762 ha->bios_revision[0]); 775 763 } 776 764 777 765 static ssize_t 778 - qla2x00_optrom_efi_version_show(struct class_device *cdev, char *buf) 766 + qla2x00_optrom_efi_version_show(struct device *dev, 767 + struct device_attribute *attr, char *buf) 779 768 { 780 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 769 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 781 770 782 771 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1], 783 772 ha->efi_revision[0]); 784 773 } 785 774 786 775 static ssize_t 787 - qla2x00_optrom_fcode_version_show(struct class_device *cdev, char *buf) 776 + qla2x00_optrom_fcode_version_show(struct device *dev, 777 + struct device_attribute *attr, char *buf) 788 778 { 789 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 779 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 790 780 791 781 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1], 792 782 ha->fcode_revision[0]); 793 783 } 794 784 795 785 static ssize_t 796 - qla2x00_optrom_fw_version_show(struct class_device *cdev, char *buf) 786 + qla2x00_optrom_fw_version_show(struct device *dev, 787 + struct device_attribute *attr, char *buf) 797 788 { 798 - scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 789 + scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 799 790 800 791 return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n", 801 792 ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2], 802 793 ha->fw_revision[3]); 803 794 } 804 795 805 - static CLASS_DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, 806 - NULL); 807 - static CLASS_DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); 808 - static CLASS_DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); 809 - static CLASS_DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); 810 - static CLASS_DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL); 811 - static CLASS_DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL); 812 - static CLASS_DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL); 813 - static CLASS_DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL); 814 - static CLASS_DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL); 815 - static CLASS_DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, 816 - qla2x00_zio_store); 817 - static CLASS_DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show, 818 - qla2x00_zio_timer_store); 819 - static CLASS_DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show, 820 - qla2x00_beacon_store); 821 - static CLASS_DEVICE_ATTR(optrom_bios_version, S_IRUGO, 822 - qla2x00_optrom_bios_version_show, NULL); 823 - static CLASS_DEVICE_ATTR(optrom_efi_version, S_IRUGO, 824 - qla2x00_optrom_efi_version_show, NULL); 825 - static CLASS_DEVICE_ATTR(optrom_fcode_version, S_IRUGO, 826 - qla2x00_optrom_fcode_version_show, NULL); 827 - static CLASS_DEVICE_ATTR(optrom_fw_version, S_IRUGO, 828 - qla2x00_optrom_fw_version_show, NULL); 796 + static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL); 797 + static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); 798 + static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); 799 + static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); 800 + static DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL); 801 + static DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL); 802 + static DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL); 803 + static DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL); 804 + static DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL); 805 + static DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, qla2x00_zio_store); 806 + static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show, 807 + qla2x00_zio_timer_store); 808 + static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show, 809 + qla2x00_beacon_store); 810 + static DEVICE_ATTR(optrom_bios_version, S_IRUGO, 811 + qla2x00_optrom_bios_version_show, NULL); 812 + static DEVICE_ATTR(optrom_efi_version, S_IRUGO, 813 + qla2x00_optrom_efi_version_show, NULL); 814 + static DEVICE_ATTR(optrom_fcode_version, S_IRUGO, 815 + qla2x00_optrom_fcode_version_show, NULL); 816 + static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show, 817 + NULL); 829 818 830 - struct class_device_attribute *qla2x00_host_attrs[] = { 831 - &class_device_attr_driver_version, 832 - &class_device_attr_fw_version, 833 - &class_device_attr_serial_num, 834 - &class_device_attr_isp_name, 835 - &class_device_attr_isp_id, 836 - &class_device_attr_model_name, 837 - &class_device_attr_model_desc, 838 - &class_device_attr_pci_info, 839 - &class_device_attr_state, 840 - &class_device_attr_zio, 841 - &class_device_attr_zio_timer, 842 - &class_device_attr_beacon, 843 - &class_device_attr_optrom_bios_version, 844 - &class_device_attr_optrom_efi_version, 845 - &class_device_attr_optrom_fcode_version, 846 - &class_device_attr_optrom_fw_version, 819 + struct device_attribute *qla2x00_host_attrs[] = { 820 + &dev_attr_driver_version, 821 + &dev_attr_fw_version, 822 + &dev_attr_serial_num, 823 + &dev_attr_isp_name, 824 + &dev_attr_isp_id, 825 + &dev_attr_model_name, 826 + &dev_attr_model_desc, 827 + &dev_attr_pci_info, 828 + &dev_attr_state, 829 + &dev_attr_zio, 830 + &dev_attr_zio_timer, 831 + &dev_attr_beacon, 832 + &dev_attr_optrom_bios_version, 833 + &dev_attr_optrom_efi_version, 834 + &dev_attr_optrom_fcode_version, 835 + &dev_attr_optrom_fw_version, 847 836 NULL, 848 837 }; 849 838
+2 -2
drivers/scsi/qla2xxx/qla_gbl.h
··· 347 347 /* 348 348 * Global Function Prototypes in qla_attr.c source file. 349 349 */ 350 - struct class_device_attribute; 351 - extern struct class_device_attribute *qla2x00_host_attrs[]; 350 + struct device_attribute; 351 + extern struct device_attribute *qla2x00_host_attrs[]; 352 352 struct fc_function_template; 353 353 extern struct fc_function_template qla2xxx_transport_functions; 354 354 extern struct fc_function_template qla2xxx_transport_vport_functions;
+37 -36
drivers/scsi/raid_class.c
··· 24 24 struct raid_template r; 25 25 struct raid_function_template *f; 26 26 /* The actual attributes */ 27 - struct class_device_attribute private_attrs[RAID_NUM_ATTRS]; 27 + struct device_attribute private_attrs[RAID_NUM_ATTRS]; 28 28 /* The array of null terminated pointers to attributes 29 29 * needed by scsi_sysfs.c */ 30 - struct class_device_attribute *attrs[RAID_NUM_ATTRS + 1]; 30 + struct device_attribute *attrs[RAID_NUM_ATTRS + 1]; 31 31 }; 32 32 33 33 struct raid_component { 34 34 struct list_head node; 35 - struct class_device cdev; 35 + struct device dev; 36 36 int num; 37 37 }; 38 38 ··· 50 50 tc_to_raid_internal(tc); \ 51 51 }) 52 52 53 - #define class_device_to_raid_internal(cdev) ({ \ 53 + #define device_to_raid_internal(dev) ({ \ 54 54 struct attribute_container *ac = \ 55 - attribute_container_classdev_to_container(cdev); \ 55 + attribute_container_classdev_to_container(dev); \ 56 56 ac_to_raid_internal(ac); \ 57 57 }) 58 58 ··· 76 76 } 77 77 78 78 static int raid_setup(struct transport_container *tc, struct device *dev, 79 - struct class_device *cdev) 79 + struct device *cdev) 80 80 { 81 81 struct raid_data *rd; 82 82 83 - BUG_ON(class_get_devdata(cdev)); 83 + BUG_ON(dev_get_drvdata(cdev)); 84 84 85 85 rd = kzalloc(sizeof(*rd), GFP_KERNEL); 86 86 if (!rd) 87 87 return -ENOMEM; 88 88 89 89 INIT_LIST_HEAD(&rd->component_list); 90 - class_set_devdata(cdev, rd); 90 + dev_set_drvdata(cdev, rd); 91 91 92 92 return 0; 93 93 } 94 94 95 95 static int raid_remove(struct transport_container *tc, struct device *dev, 96 - struct class_device *cdev) 96 + struct device *cdev) 97 97 { 98 - struct raid_data *rd = class_get_devdata(cdev); 98 + struct raid_data *rd = dev_get_drvdata(cdev); 99 99 struct raid_component *rc, *next; 100 100 dev_printk(KERN_ERR, dev, "RAID REMOVE\n"); 101 - class_set_devdata(cdev, NULL); 101 + dev_set_drvdata(cdev, NULL); 102 102 list_for_each_entry_safe(rc, next, &rd->component_list, node) { 103 103 list_del(&rc->node); 104 - dev_printk(KERN_ERR, rc->cdev.dev, "RAID COMPONENT REMOVE\n"); 105 - class_device_unregister(&rc->cdev); 104 + dev_printk(KERN_ERR, rc->dev.parent, "RAID COMPONENT REMOVE\n"); 105 + device_unregister(&rc->dev); 106 106 } 107 107 dev_printk(KERN_ERR, dev, "RAID REMOVE DONE\n"); 108 108 kfree(rd); ··· 171 171 } 172 172 173 173 #define raid_attr_show_internal(attr, fmt, var, code) \ 174 - static ssize_t raid_show_##attr(struct class_device *cdev, char *buf) \ 174 + static ssize_t raid_show_##attr(struct device *dev, \ 175 + struct device_attribute *attr, \ 176 + char *buf) \ 175 177 { \ 176 - struct raid_data *rd = class_get_devdata(cdev); \ 178 + struct raid_data *rd = dev_get_drvdata(dev); \ 177 179 code \ 178 180 return snprintf(buf, 20, #fmt "\n", var); \ 179 181 } ··· 186 184 code \ 187 185 name = raid_##states##_name(rd->attr); \ 188 186 ) \ 189 - static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) 187 + static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) 190 188 191 189 192 190 #define raid_attr_ro_internal(attr, code) \ 193 191 raid_attr_show_internal(attr, %d, rd->attr, code) \ 194 - static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) 192 + static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) 195 193 196 194 #define ATTR_CODE(attr) \ 197 - struct raid_internal *i = class_device_to_raid_internal(cdev); \ 195 + struct raid_internal *i = device_to_raid_internal(dev); \ 198 196 if (i->f->get_##attr) \ 199 - i->f->get_##attr(cdev->dev); 197 + i->f->get_##attr(dev->parent); 200 198 201 199 #define raid_attr_ro(attr) raid_attr_ro_internal(attr, ) 202 200 #define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr)) ··· 208 206 raid_attr_ro_fn(resync); 209 207 raid_attr_ro_state_fn(state); 210 208 211 - static void raid_component_release(struct class_device *cdev) 209 + static void raid_component_release(struct device *dev) 212 210 { 213 - struct raid_component *rc = container_of(cdev, struct raid_component, 214 - cdev); 215 - dev_printk(KERN_ERR, rc->cdev.dev, "COMPONENT RELEASE\n"); 216 - put_device(rc->cdev.dev); 211 + struct raid_component *rc = 212 + container_of(dev, struct raid_component, dev); 213 + dev_printk(KERN_ERR, rc->dev.parent, "COMPONENT RELEASE\n"); 214 + put_device(rc->dev.parent); 217 215 kfree(rc); 218 216 } 219 217 220 218 int raid_component_add(struct raid_template *r,struct device *raid_dev, 221 219 struct device *component_dev) 222 220 { 223 - struct class_device *cdev = 221 + struct device *cdev = 224 222 attribute_container_find_class_device(&r->raid_attrs.ac, 225 223 raid_dev); 226 224 struct raid_component *rc; 227 - struct raid_data *rd = class_get_devdata(cdev); 225 + struct raid_data *rd = dev_get_drvdata(cdev); 228 226 int err; 229 227 230 228 rc = kzalloc(sizeof(*rc), GFP_KERNEL); ··· 232 230 return -ENOMEM; 233 231 234 232 INIT_LIST_HEAD(&rc->node); 235 - class_device_initialize(&rc->cdev); 236 - rc->cdev.release = raid_component_release; 237 - rc->cdev.dev = get_device(component_dev); 233 + device_initialize(&rc->dev); 234 + rc->dev.release = raid_component_release; 235 + rc->dev.parent = get_device(component_dev); 238 236 rc->num = rd->component_count++; 239 237 240 - snprintf(rc->cdev.class_id, sizeof(rc->cdev.class_id), 238 + snprintf(rc->dev.bus_id, sizeof(rc->dev.bus_id), 241 239 "component-%d", rc->num); 242 240 list_add_tail(&rc->node, &rd->component_list); 243 - rc->cdev.parent = cdev; 244 - rc->cdev.class = &raid_class.class; 245 - err = class_device_add(&rc->cdev); 241 + rc->dev.class = &raid_class.class; 242 + err = device_add(&rc->dev); 246 243 if (err) 247 244 goto err_out; 248 245 ··· 274 273 275 274 attribute_container_register(&i->r.raid_attrs.ac); 276 275 277 - i->attrs[count++] = &class_device_attr_level; 278 - i->attrs[count++] = &class_device_attr_resync; 279 - i->attrs[count++] = &class_device_attr_state; 276 + i->attrs[count++] = &dev_attr_level; 277 + i->attrs[count++] = &dev_attr_resync; 278 + i->attrs[count++] = &dev_attr_state; 280 279 281 280 i->attrs[count] = NULL; 282 281 BUG_ON(count > RAID_NUM_ATTRS);
+12 -12
drivers/scsi/scsi_sas_internal.h
··· 13 13 struct sas_function_template *f; 14 14 struct sas_domain_function_template *dft; 15 15 16 - struct class_device_attribute private_host_attrs[SAS_HOST_ATTRS]; 17 - struct class_device_attribute private_phy_attrs[SAS_PHY_ATTRS]; 18 - struct class_device_attribute private_port_attrs[SAS_PORT_ATTRS]; 19 - struct class_device_attribute private_rphy_attrs[SAS_RPORT_ATTRS]; 20 - struct class_device_attribute private_end_dev_attrs[SAS_END_DEV_ATTRS]; 21 - struct class_device_attribute private_expander_attrs[SAS_EXPANDER_ATTRS]; 16 + struct device_attribute private_host_attrs[SAS_HOST_ATTRS]; 17 + struct device_attribute private_phy_attrs[SAS_PHY_ATTRS]; 18 + struct device_attribute private_port_attrs[SAS_PORT_ATTRS]; 19 + struct device_attribute private_rphy_attrs[SAS_RPORT_ATTRS]; 20 + struct device_attribute private_end_dev_attrs[SAS_END_DEV_ATTRS]; 21 + struct device_attribute private_expander_attrs[SAS_EXPANDER_ATTRS]; 22 22 23 23 struct transport_container phy_attr_cont; 24 24 struct transport_container port_attr_cont; ··· 30 30 * The array of null terminated pointers to attributes 31 31 * needed by scsi_sysfs.c 32 32 */ 33 - struct class_device_attribute *host_attrs[SAS_HOST_ATTRS + 1]; 34 - struct class_device_attribute *phy_attrs[SAS_PHY_ATTRS + 1]; 35 - struct class_device_attribute *port_attrs[SAS_PORT_ATTRS + 1]; 36 - struct class_device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1]; 37 - struct class_device_attribute *end_dev_attrs[SAS_END_DEV_ATTRS + 1]; 38 - struct class_device_attribute *expander_attrs[SAS_EXPANDER_ATTRS + 1]; 33 + struct device_attribute *host_attrs[SAS_HOST_ATTRS + 1]; 34 + struct device_attribute *phy_attrs[SAS_PHY_ATTRS + 1]; 35 + struct device_attribute *port_attrs[SAS_PORT_ATTRS + 1]; 36 + struct device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1]; 37 + struct device_attribute *end_dev_attrs[SAS_END_DEV_ATTRS + 1]; 38 + struct device_attribute *expander_attrs[SAS_EXPANDER_ATTRS + 1]; 39 39 }; 40 40 #define to_sas_internal(tmpl) container_of(tmpl, struct sas_internal, t) 41 41
+85 -65
drivers/scsi/scsi_sysfs.c
··· 119 119 */ 120 120 #define shost_show_function(name, field, format_string) \ 121 121 static ssize_t \ 122 - show_##name (struct class_device *class_dev, char *buf) \ 122 + show_##name (struct device *dev, struct device_attribute *attr, \ 123 + char *buf) \ 123 124 { \ 124 - struct Scsi_Host *shost = class_to_shost(class_dev); \ 125 + struct Scsi_Host *shost = class_to_shost(dev); \ 125 126 return snprintf (buf, 20, format_string, shost->field); \ 126 127 } 127 128 ··· 132 131 */ 133 132 #define shost_rd_attr2(name, field, format_string) \ 134 133 shost_show_function(name, field, format_string) \ 135 - static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); 134 + static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); 136 135 137 136 #define shost_rd_attr(field, format_string) \ 138 137 shost_rd_attr2(field, field, format_string) ··· 141 140 * Create the actual show/store functions and data structures. 142 141 */ 143 142 144 - static ssize_t store_scan(struct class_device *class_dev, const char *buf, 145 - size_t count) 143 + static ssize_t 144 + store_scan(struct device *dev, struct device_attribute *attr, 145 + const char *buf, size_t count) 146 146 { 147 - struct Scsi_Host *shost = class_to_shost(class_dev); 147 + struct Scsi_Host *shost = class_to_shost(dev); 148 148 int res; 149 149 150 150 res = scsi_scan(shost, buf); ··· 153 151 res = count; 154 152 return res; 155 153 }; 156 - static CLASS_DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); 154 + static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); 157 155 158 156 static ssize_t 159 - store_shost_state(struct class_device *class_dev, const char *buf, size_t count) 157 + store_shost_state(struct device *dev, struct device_attribute *attr, 158 + const char *buf, size_t count) 160 159 { 161 160 int i; 162 - struct Scsi_Host *shost = class_to_shost(class_dev); 161 + struct Scsi_Host *shost = class_to_shost(dev); 163 162 enum scsi_host_state state = 0; 164 163 165 164 for (i = 0; i < ARRAY_SIZE(shost_states); i++) { ··· 180 177 } 181 178 182 179 static ssize_t 183 - show_shost_state(struct class_device *class_dev, char *buf) 180 + show_shost_state(struct device *dev, struct device_attribute *attr, char *buf) 184 181 { 185 - struct Scsi_Host *shost = class_to_shost(class_dev); 182 + struct Scsi_Host *shost = class_to_shost(dev); 186 183 const char *name = scsi_host_state_name(shost->shost_state); 187 184 188 185 if (!name) ··· 191 188 return snprintf(buf, 20, "%s\n", name); 192 189 } 193 190 194 - static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); 191 + /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */ 192 + struct device_attribute dev_attr_hstate = 193 + __ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); 195 194 196 195 static ssize_t 197 196 show_shost_mode(unsigned int mode, char *buf) ··· 211 206 return len; 212 207 } 213 208 214 - static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *buf) 209 + static ssize_t 210 + show_shost_supported_mode(struct device *dev, struct device_attribute *attr, 211 + char *buf) 215 212 { 216 - struct Scsi_Host *shost = class_to_shost(class_dev); 213 + struct Scsi_Host *shost = class_to_shost(dev); 217 214 unsigned int supported_mode = shost->hostt->supported_mode; 218 215 219 216 if (supported_mode == MODE_UNKNOWN) ··· 225 218 return show_shost_mode(supported_mode, buf); 226 219 } 227 220 228 - static CLASS_DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL); 221 + static DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL); 229 222 230 - static ssize_t show_shost_active_mode(struct class_device *class_dev, char *buf) 223 + static ssize_t 224 + show_shost_active_mode(struct device *dev, 225 + struct device_attribute *attr, char *buf) 231 226 { 232 - struct Scsi_Host *shost = class_to_shost(class_dev); 227 + struct Scsi_Host *shost = class_to_shost(dev); 233 228 234 229 if (shost->active_mode == MODE_UNKNOWN) 235 230 return snprintf(buf, 20, "unknown\n"); ··· 239 230 return show_shost_mode(shost->active_mode, buf); 240 231 } 241 232 242 - static CLASS_DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); 233 + static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); 243 234 244 235 shost_rd_attr(unique_id, "%u\n"); 245 236 shost_rd_attr(host_busy, "%hu\n"); ··· 249 240 shost_rd_attr(unchecked_isa_dma, "%d\n"); 250 241 shost_rd_attr2(proc_name, hostt->proc_name, "%s\n"); 251 242 252 - static struct class_device_attribute *scsi_sysfs_shost_attrs[] = { 253 - &class_device_attr_unique_id, 254 - &class_device_attr_host_busy, 255 - &class_device_attr_cmd_per_lun, 256 - &class_device_attr_can_queue, 257 - &class_device_attr_sg_tablesize, 258 - &class_device_attr_unchecked_isa_dma, 259 - &class_device_attr_proc_name, 260 - &class_device_attr_scan, 261 - &class_device_attr_state, 262 - &class_device_attr_supported_mode, 263 - &class_device_attr_active_mode, 243 + static struct device_attribute *scsi_sysfs_shost_attrs[] = { 244 + &dev_attr_unique_id, 245 + &dev_attr_host_busy, 246 + &dev_attr_cmd_per_lun, 247 + &dev_attr_can_queue, 248 + &dev_attr_sg_tablesize, 249 + &dev_attr_unchecked_isa_dma, 250 + &dev_attr_proc_name, 251 + &dev_attr_scan, 252 + &dev_attr_hstate, 253 + &dev_attr_supported_mode, 254 + &dev_attr_active_mode, 264 255 NULL 265 256 }; 266 257 267 - static void scsi_device_cls_release(struct class_device *class_dev) 258 + static void scsi_device_cls_release(struct device *class_dev) 268 259 { 269 260 struct scsi_device *sdev; 270 261 ··· 329 320 330 321 static struct class sdev_class = { 331 322 .name = "scsi_device", 332 - .release = scsi_device_cls_release, 323 + .dev_release = scsi_device_cls_release, 333 324 }; 334 325 335 326 /* all probing is done in the individual ->probe routines */ ··· 433 424 */ 434 425 #define sdev_show_function(field, format_string) \ 435 426 static ssize_t \ 436 - sdev_show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ 427 + sdev_show_##field (struct device *dev, struct device_attribute *attr, \ 428 + char *buf) \ 437 429 { \ 438 430 struct scsi_device *sdev; \ 439 431 sdev = to_scsi_device(dev); \ ··· 458 448 sdev_show_function(field, format_string) \ 459 449 \ 460 450 static ssize_t \ 461 - sdev_store_##field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ 451 + sdev_store_##field (struct device *dev, struct device_attribute *attr, \ 452 + const char *buf, size_t count) \ 462 453 { \ 463 454 struct scsi_device *sdev; \ 464 455 sdev = to_scsi_device(dev); \ ··· 479 468 sdev_show_function(field, "%d\n") \ 480 469 \ 481 470 static ssize_t \ 482 - sdev_store_##field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ 471 + sdev_store_##field (struct device *dev, struct device_attribute *attr, \ 472 + const char *buf, size_t count) \ 483 473 { \ 484 474 int ret; \ 485 475 struct scsi_device *sdev; \ ··· 531 519 } 532 520 533 521 static ssize_t 534 - sdev_store_timeout (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 522 + sdev_store_timeout (struct device *dev, struct device_attribute *attr, 523 + const char *buf, size_t count) 535 524 { 536 525 struct scsi_device *sdev; 537 526 int timeout; ··· 544 531 static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout); 545 532 546 533 static ssize_t 547 - store_rescan_field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 534 + store_rescan_field (struct device *dev, struct device_attribute *attr, 535 + const char *buf, size_t count) 548 536 { 549 537 scsi_rescan_device(dev); 550 538 return count; ··· 557 543 scsi_remove_device(to_scsi_device(dev)); 558 544 } 559 545 560 - static ssize_t sdev_store_delete(struct device *dev, struct device_attribute *attr, const char *buf, 561 - size_t count) 546 + static ssize_t 547 + sdev_store_delete(struct device *dev, struct device_attribute *attr, 548 + const char *buf, size_t count) 562 549 { 563 550 int rc; 564 551 ··· 574 559 static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete); 575 560 576 561 static ssize_t 577 - store_state_field(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 562 + store_state_field(struct device *dev, struct device_attribute *attr, 563 + const char *buf, size_t count) 578 564 { 579 565 int i; 580 566 struct scsi_device *sdev = to_scsi_device(dev); ··· 612 596 static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field); 613 597 614 598 static ssize_t 615 - show_queue_type_field(struct device *dev, struct device_attribute *attr, char *buf) 599 + show_queue_type_field(struct device *dev, struct device_attribute *attr, 600 + char *buf) 616 601 { 617 602 struct scsi_device *sdev = to_scsi_device(dev); 618 603 const char *name = "none"; ··· 629 612 static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL); 630 613 631 614 static ssize_t 632 - show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf) 615 + show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf) 633 616 { 634 617 return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8); 635 618 } ··· 638 621 639 622 #define show_sdev_iostat(field) \ 640 623 static ssize_t \ 641 - show_iostat_##field(struct device *dev, struct device_attribute *attr, char *buf) \ 624 + show_iostat_##field(struct device *dev, struct device_attribute *attr, \ 625 + char *buf) \ 642 626 { \ 643 627 struct scsi_device *sdev = to_scsi_device(dev); \ 644 628 unsigned long long count = atomic_read(&sdev->field); \ ··· 663 645 #define DECLARE_EVT_SHOW(name, Cap_name) \ 664 646 static ssize_t \ 665 647 sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \ 666 - char *buf) \ 648 + char *buf) \ 667 649 { \ 668 650 struct scsi_device *sdev = to_scsi_device(dev); \ 669 651 int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\ ··· 672 654 673 655 #define DECLARE_EVT_STORE(name, Cap_name) \ 674 656 static ssize_t \ 675 - sdev_store_evt_##name(struct device *dev, struct device_attribute *attr, \ 657 + sdev_store_evt_##name(struct device *dev, struct device_attribute *attr,\ 676 658 const char *buf, size_t count) \ 677 659 { \ 678 660 struct scsi_device *sdev = to_scsi_device(dev); \ ··· 725 707 NULL 726 708 }; 727 709 728 - static ssize_t sdev_store_queue_depth_rw(struct device *dev, struct device_attribute *attr, const char *buf, 729 - size_t count) 710 + static ssize_t 711 + sdev_store_queue_depth_rw(struct device *dev, struct device_attribute *attr, 712 + const char *buf, size_t count) 730 713 { 731 714 int depth, retval; 732 715 struct scsi_device *sdev = to_scsi_device(dev); ··· 752 733 __ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth, 753 734 sdev_store_queue_depth_rw); 754 735 755 - static ssize_t sdev_store_queue_type_rw(struct device *dev, struct device_attribute *attr, const char *buf, 756 - size_t count) 736 + static ssize_t 737 + sdev_store_queue_type_rw(struct device *dev, struct device_attribute *attr, 738 + const char *buf, size_t count) 757 739 { 758 740 struct scsi_device *sdev = to_scsi_device(dev); 759 741 struct scsi_host_template *sht = sdev->host->hostt; ··· 806 786 printk(KERN_INFO "error 1\n"); 807 787 return error; 808 788 } 809 - error = class_device_add(&sdev->sdev_classdev); 789 + error = device_add(&sdev->sdev_dev); 810 790 if (error) { 811 791 printk(KERN_INFO "error 2\n"); 812 792 goto clean_device; 813 793 } 814 794 815 - /* take a reference for the sdev_classdev; this is 795 + /* take a reference for the sdev_dev; this is 816 796 * released by the sdev_class .release */ 817 797 get_device(&sdev->sdev_gendev); 818 798 ··· 878 858 return; 879 859 880 860 bsg_unregister_queue(sdev->request_queue); 881 - class_device_unregister(&sdev->sdev_classdev); 861 + device_unregister(&sdev->sdev_dev); 882 862 transport_remove_device(dev); 883 863 device_del(dev); 884 864 scsi_device_set_state(sdev, SDEV_DEL); ··· 972 952 EXPORT_SYMBOL(scsi_register_interface); 973 953 974 954 975 - static struct class_device_attribute *class_attr_overridden( 976 - struct class_device_attribute **attrs, 977 - struct class_device_attribute *attr) 955 + static struct device_attribute *class_attr_overridden( 956 + struct device_attribute **attrs, 957 + struct device_attribute *attr) 978 958 { 979 959 int i; 980 960 ··· 986 966 return NULL; 987 967 } 988 968 989 - static int class_attr_add(struct class_device *classdev, 990 - struct class_device_attribute *attr) 969 + static int class_attr_add(struct device *classdev, 970 + struct device_attribute *attr) 991 971 { 992 - struct class_device_attribute *base_attr; 972 + struct device_attribute *base_attr; 993 973 994 974 /* 995 975 * Spare the caller from having to copy things it's not interested in. ··· 1006 986 attr->store = base_attr->store; 1007 987 } 1008 988 1009 - return class_device_create_file(classdev, attr); 989 + return device_create_file(classdev, attr); 1010 990 } 1011 991 1012 992 /** ··· 1020 1000 1021 1001 if (shost->hostt->shost_attrs) { 1022 1002 for (i = 0; shost->hostt->shost_attrs[i]; i++) { 1023 - error = class_attr_add(&shost->shost_classdev, 1003 + error = class_attr_add(&shost->shost_dev, 1024 1004 shost->hostt->shost_attrs[i]); 1025 1005 if (error) 1026 1006 return error; ··· 1030 1010 for (i = 0; scsi_sysfs_shost_attrs[i]; i++) { 1031 1011 if (!class_attr_overridden(shost->hostt->shost_attrs, 1032 1012 scsi_sysfs_shost_attrs[i])) { 1033 - error = class_device_create_file(&shost->shost_classdev, 1013 + error = device_create_file(&shost->shost_dev, 1034 1014 scsi_sysfs_shost_attrs[i]); 1035 1015 if (error) 1036 1016 return error; ··· 1061 1041 sdev->host->host_no, sdev->channel, sdev->id, 1062 1042 sdev->lun); 1063 1043 1064 - class_device_initialize(&sdev->sdev_classdev); 1065 - sdev->sdev_classdev.dev = &sdev->sdev_gendev; 1066 - sdev->sdev_classdev.class = &sdev_class; 1067 - snprintf(sdev->sdev_classdev.class_id, BUS_ID_SIZE, 1044 + device_initialize(&sdev->sdev_dev); 1045 + sdev->sdev_dev.parent = &sdev->sdev_gendev; 1046 + sdev->sdev_dev.class = &sdev_class; 1047 + snprintf(sdev->sdev_dev.bus_id, BUS_ID_SIZE, 1068 1048 "%d:%d:%d:%d", sdev->host->host_no, 1069 1049 sdev->channel, sdev->id, sdev->lun); 1070 1050 sdev->scsi_level = starget->scsi_level;
+208 -177
drivers/scsi/scsi_transport_fc.c
··· 72 72 * Redefine so that we can have same named attributes in the 73 73 * sdev/starget/host objects. 74 74 */ 75 - #define FC_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ 76 - struct class_device_attribute class_device_attr_##_prefix##_##_name = \ 75 + #define FC_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ 76 + struct device_attribute device_attr_##_prefix##_##_name = \ 77 77 __ATTR(_name,_mode,_show,_store) 78 78 79 79 #define fc_enum_name_search(title, table_type, table) \ ··· 326 326 * part of the midlayer. As the remote port is specific to the 327 327 * fc transport, we must provide the attribute container. 328 328 */ 329 - struct class_device_attribute private_starget_attrs[ 329 + struct device_attribute private_starget_attrs[ 330 330 FC_STARGET_NUM_ATTRS]; 331 - struct class_device_attribute *starget_attrs[FC_STARGET_NUM_ATTRS + 1]; 331 + struct device_attribute *starget_attrs[FC_STARGET_NUM_ATTRS + 1]; 332 332 333 - struct class_device_attribute private_host_attrs[FC_HOST_NUM_ATTRS]; 334 - struct class_device_attribute *host_attrs[FC_HOST_NUM_ATTRS + 1]; 333 + struct device_attribute private_host_attrs[FC_HOST_NUM_ATTRS]; 334 + struct device_attribute *host_attrs[FC_HOST_NUM_ATTRS + 1]; 335 335 336 336 struct transport_container rport_attr_cont; 337 - struct class_device_attribute private_rport_attrs[FC_RPORT_NUM_ATTRS]; 338 - struct class_device_attribute *rport_attrs[FC_RPORT_NUM_ATTRS + 1]; 337 + struct device_attribute private_rport_attrs[FC_RPORT_NUM_ATTRS]; 338 + struct device_attribute *rport_attrs[FC_RPORT_NUM_ATTRS + 1]; 339 339 340 340 struct transport_container vport_attr_cont; 341 - struct class_device_attribute private_vport_attrs[FC_VPORT_NUM_ATTRS]; 342 - struct class_device_attribute *vport_attrs[FC_VPORT_NUM_ATTRS + 1]; 341 + struct device_attribute private_vport_attrs[FC_VPORT_NUM_ATTRS]; 342 + struct device_attribute *vport_attrs[FC_VPORT_NUM_ATTRS + 1]; 343 343 }; 344 344 345 345 #define to_fc_internal(tmpl) container_of(tmpl, struct fc_internal, t) 346 346 347 347 static int fc_target_setup(struct transport_container *tc, struct device *dev, 348 - struct class_device *cdev) 348 + struct device *cdev) 349 349 { 350 350 struct scsi_target *starget = to_scsi_target(dev); 351 351 struct fc_rport *rport = starget_to_rport(starget); ··· 375 375 NULL); 376 376 377 377 static int fc_host_setup(struct transport_container *tc, struct device *dev, 378 - struct class_device *cdev) 378 + struct device *cdev) 379 379 { 380 380 struct Scsi_Host *shost = dev_to_shost(dev); 381 381 struct fc_host_attrs *fc_host = shost_to_fc_host(shost); ··· 682 682 683 683 #define fc_rport_show_function(field, format_string, sz, cast) \ 684 684 static ssize_t \ 685 - show_fc_rport_##field (struct class_device *cdev, char *buf) \ 685 + show_fc_rport_##field (struct device *dev, \ 686 + struct device_attribute *attr, char *buf) \ 686 687 { \ 687 - struct fc_rport *rport = transport_class_to_rport(cdev); \ 688 + struct fc_rport *rport = transport_class_to_rport(dev); \ 688 689 struct Scsi_Host *shost = rport_to_shost(rport); \ 689 690 struct fc_internal *i = to_fc_internal(shost->transportt); \ 690 691 if ((i->f->get_rport_##field) && \ ··· 698 697 699 698 #define fc_rport_store_function(field) \ 700 699 static ssize_t \ 701 - store_fc_rport_##field(struct class_device *cdev, const char *buf, \ 702 - size_t count) \ 700 + store_fc_rport_##field(struct device *dev, \ 701 + struct device_attribute *attr, \ 702 + const char *buf, size_t count) \ 703 703 { \ 704 704 int val; \ 705 - struct fc_rport *rport = transport_class_to_rport(cdev); \ 705 + struct fc_rport *rport = transport_class_to_rport(dev); \ 706 706 struct Scsi_Host *shost = rport_to_shost(rport); \ 707 707 struct fc_internal *i = to_fc_internal(shost->transportt); \ 708 708 char *cp; \ ··· 720 718 721 719 #define fc_rport_rd_attr(field, format_string, sz) \ 722 720 fc_rport_show_function(field, format_string, sz, ) \ 723 - static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ 721 + static FC_DEVICE_ATTR(rport, field, S_IRUGO, \ 724 722 show_fc_rport_##field, NULL) 725 723 726 724 #define fc_rport_rd_attr_cast(field, format_string, sz, cast) \ 727 725 fc_rport_show_function(field, format_string, sz, (cast)) \ 728 - static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ 726 + static FC_DEVICE_ATTR(rport, field, S_IRUGO, \ 729 727 show_fc_rport_##field, NULL) 730 728 731 729 #define fc_rport_rw_attr(field, format_string, sz) \ 732 730 fc_rport_show_function(field, format_string, sz, ) \ 733 731 fc_rport_store_function(field) \ 734 - static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \ 732 + static FC_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \ 735 733 show_fc_rport_##field, \ 736 734 store_fc_rport_##field) 737 735 738 736 739 737 #define fc_private_rport_show_function(field, format_string, sz, cast) \ 740 738 static ssize_t \ 741 - show_fc_rport_##field (struct class_device *cdev, char *buf) \ 739 + show_fc_rport_##field (struct device *dev, \ 740 + struct device_attribute *attr, char *buf) \ 742 741 { \ 743 - struct fc_rport *rport = transport_class_to_rport(cdev); \ 742 + struct fc_rport *rport = transport_class_to_rport(dev); \ 744 743 return snprintf(buf, sz, format_string, cast rport->field); \ 745 744 } 746 745 747 746 #define fc_private_rport_rd_attr(field, format_string, sz) \ 748 747 fc_private_rport_show_function(field, format_string, sz, ) \ 749 - static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ 748 + static FC_DEVICE_ATTR(rport, field, S_IRUGO, \ 750 749 show_fc_rport_##field, NULL) 751 750 752 751 #define fc_private_rport_rd_attr_cast(field, format_string, sz, cast) \ 753 752 fc_private_rport_show_function(field, format_string, sz, (cast)) \ 754 - static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ 753 + static FC_DEVICE_ATTR(rport, field, S_IRUGO, \ 755 754 show_fc_rport_##field, NULL) 756 755 757 756 758 757 #define fc_private_rport_rd_enum_attr(title, maxlen) \ 759 758 static ssize_t \ 760 - show_fc_rport_##title (struct class_device *cdev, char *buf) \ 759 + show_fc_rport_##title (struct device *dev, \ 760 + struct device_attribute *attr, char *buf) \ 761 761 { \ 762 - struct fc_rport *rport = transport_class_to_rport(cdev); \ 762 + struct fc_rport *rport = transport_class_to_rport(dev); \ 763 763 const char *name; \ 764 764 name = get_fc_##title##_name(rport->title); \ 765 765 if (!name) \ 766 766 return -EINVAL; \ 767 767 return snprintf(buf, maxlen, "%s\n", name); \ 768 768 } \ 769 - static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \ 769 + static FC_DEVICE_ATTR(rport, title, S_IRUGO, \ 770 770 show_fc_rport_##title, NULL) 771 771 772 772 773 773 #define SETUP_RPORT_ATTRIBUTE_RD(field) \ 774 - i->private_rport_attrs[count] = class_device_attr_rport_##field; \ 774 + i->private_rport_attrs[count] = device_attr_rport_##field; \ 775 775 i->private_rport_attrs[count].attr.mode = S_IRUGO; \ 776 776 i->private_rport_attrs[count].store = NULL; \ 777 777 i->rport_attrs[count] = &i->private_rport_attrs[count]; \ ··· 781 777 count++ 782 778 783 779 #define SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(field) \ 784 - i->private_rport_attrs[count] = class_device_attr_rport_##field; \ 780 + i->private_rport_attrs[count] = device_attr_rport_##field; \ 785 781 i->private_rport_attrs[count].attr.mode = S_IRUGO; \ 786 782 i->private_rport_attrs[count].store = NULL; \ 787 783 i->rport_attrs[count] = &i->private_rport_attrs[count]; \ 788 784 count++ 789 785 790 786 #define SETUP_RPORT_ATTRIBUTE_RW(field) \ 791 - i->private_rport_attrs[count] = class_device_attr_rport_##field; \ 787 + i->private_rport_attrs[count] = device_attr_rport_##field; \ 792 788 if (!i->f->set_rport_##field) { \ 793 789 i->private_rport_attrs[count].attr.mode = S_IRUGO; \ 794 790 i->private_rport_attrs[count].store = NULL; \ ··· 799 795 800 796 #define SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(field) \ 801 797 { \ 802 - i->private_rport_attrs[count] = class_device_attr_rport_##field; \ 798 + i->private_rport_attrs[count] = device_attr_rport_##field; \ 803 799 i->rport_attrs[count] = &i->private_rport_attrs[count]; \ 804 800 count++; \ 805 801 } ··· 812 808 fc_private_rport_rd_attr(maxframe_size, "%u bytes\n", 20); 813 809 814 810 static ssize_t 815 - show_fc_rport_supported_classes (struct class_device *cdev, char *buf) 811 + show_fc_rport_supported_classes (struct device *dev, 812 + struct device_attribute *attr, char *buf) 816 813 { 817 - struct fc_rport *rport = transport_class_to_rport(cdev); 814 + struct fc_rport *rport = transport_class_to_rport(dev); 818 815 if (rport->supported_classes == FC_COS_UNSPECIFIED) 819 816 return snprintf(buf, 20, "unspecified\n"); 820 817 return get_fc_cos_names(rport->supported_classes, buf); 821 818 } 822 - static FC_CLASS_DEVICE_ATTR(rport, supported_classes, S_IRUGO, 819 + static FC_DEVICE_ATTR(rport, supported_classes, S_IRUGO, 823 820 show_fc_rport_supported_classes, NULL); 824 821 825 822 /* Dynamic Remote Port Attributes */ ··· 830 825 */ 831 826 fc_rport_show_function(dev_loss_tmo, "%d\n", 20, ) 832 827 static ssize_t 833 - store_fc_rport_dev_loss_tmo(struct class_device *cdev, const char *buf, 834 - size_t count) 828 + store_fc_rport_dev_loss_tmo(struct device *dev, struct device_attribute *attr, 829 + const char *buf, size_t count) 835 830 { 836 831 int val; 837 - struct fc_rport *rport = transport_class_to_rport(cdev); 832 + struct fc_rport *rport = transport_class_to_rport(dev); 838 833 struct Scsi_Host *shost = rport_to_shost(rport); 839 834 struct fc_internal *i = to_fc_internal(shost->transportt); 840 835 char *cp; ··· 849 844 i->f->set_rport_dev_loss_tmo(rport, val); 850 845 return count; 851 846 } 852 - static FC_CLASS_DEVICE_ATTR(rport, dev_loss_tmo, S_IRUGO | S_IWUSR, 847 + static FC_DEVICE_ATTR(rport, dev_loss_tmo, S_IRUGO | S_IWUSR, 853 848 show_fc_rport_dev_loss_tmo, store_fc_rport_dev_loss_tmo); 854 849 855 850 ··· 860 855 fc_private_rport_rd_attr(port_id, "0x%06x\n", 20); 861 856 862 857 static ssize_t 863 - show_fc_rport_roles (struct class_device *cdev, char *buf) 858 + show_fc_rport_roles (struct device *dev, struct device_attribute *attr, 859 + char *buf) 864 860 { 865 - struct fc_rport *rport = transport_class_to_rport(cdev); 861 + struct fc_rport *rport = transport_class_to_rport(dev); 866 862 867 863 /* identify any roles that are port_id specific */ 868 864 if ((rport->port_id != -1) && ··· 889 883 return get_fc_port_roles_names(rport->roles, buf); 890 884 } 891 885 } 892 - static FC_CLASS_DEVICE_ATTR(rport, roles, S_IRUGO, 886 + static FC_DEVICE_ATTR(rport, roles, S_IRUGO, 893 887 show_fc_rport_roles, NULL); 894 888 895 889 fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN); ··· 899 893 * fast_io_fail_tmo attribute 900 894 */ 901 895 static ssize_t 902 - show_fc_rport_fast_io_fail_tmo (struct class_device *cdev, char *buf) 896 + show_fc_rport_fast_io_fail_tmo (struct device *dev, 897 + struct device_attribute *attr, char *buf) 903 898 { 904 - struct fc_rport *rport = transport_class_to_rport(cdev); 899 + struct fc_rport *rport = transport_class_to_rport(dev); 905 900 906 901 if (rport->fast_io_fail_tmo == -1) 907 902 return snprintf(buf, 5, "off\n"); ··· 910 903 } 911 904 912 905 static ssize_t 913 - store_fc_rport_fast_io_fail_tmo(struct class_device *cdev, const char *buf, 914 - size_t count) 906 + store_fc_rport_fast_io_fail_tmo(struct device *dev, 907 + struct device_attribute *attr, const char *buf, 908 + size_t count) 915 909 { 916 910 int val; 917 911 char *cp; 918 - struct fc_rport *rport = transport_class_to_rport(cdev); 912 + struct fc_rport *rport = transport_class_to_rport(dev); 919 913 920 914 if ((rport->port_state == FC_PORTSTATE_BLOCKED) || 921 915 (rport->port_state == FC_PORTSTATE_DELETED) || ··· 933 925 } 934 926 return count; 935 927 } 936 - static FC_CLASS_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR, 928 + static FC_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR, 937 929 show_fc_rport_fast_io_fail_tmo, store_fc_rport_fast_io_fail_tmo); 938 930 939 931 ··· 949 941 */ 950 942 #define fc_starget_show_function(field, format_string, sz, cast) \ 951 943 static ssize_t \ 952 - show_fc_starget_##field (struct class_device *cdev, char *buf) \ 944 + show_fc_starget_##field (struct device *dev, \ 945 + struct device_attribute *attr, char *buf) \ 953 946 { \ 954 - struct scsi_target *starget = transport_class_to_starget(cdev); \ 947 + struct scsi_target *starget = transport_class_to_starget(dev); \ 955 948 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ 956 949 struct fc_internal *i = to_fc_internal(shost->transportt); \ 957 950 struct fc_rport *rport = starget_to_rport(starget); \ ··· 966 957 967 958 #define fc_starget_rd_attr(field, format_string, sz) \ 968 959 fc_starget_show_function(field, format_string, sz, ) \ 969 - static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \ 960 + static FC_DEVICE_ATTR(starget, field, S_IRUGO, \ 970 961 show_fc_starget_##field, NULL) 971 962 972 963 #define fc_starget_rd_attr_cast(field, format_string, sz, cast) \ 973 964 fc_starget_show_function(field, format_string, sz, (cast)) \ 974 - static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \ 965 + static FC_DEVICE_ATTR(starget, field, S_IRUGO, \ 975 966 show_fc_starget_##field, NULL) 976 967 977 968 #define SETUP_STARGET_ATTRIBUTE_RD(field) \ 978 - i->private_starget_attrs[count] = class_device_attr_starget_##field; \ 969 + i->private_starget_attrs[count] = device_attr_starget_##field; \ 979 970 i->private_starget_attrs[count].attr.mode = S_IRUGO; \ 980 971 i->private_starget_attrs[count].store = NULL; \ 981 972 i->starget_attrs[count] = &i->private_starget_attrs[count]; \ ··· 983 974 count++ 984 975 985 976 #define SETUP_STARGET_ATTRIBUTE_RW(field) \ 986 - i->private_starget_attrs[count] = class_device_attr_starget_##field; \ 977 + i->private_starget_attrs[count] = device_attr_starget_##field; \ 987 978 if (!i->f->set_starget_##field) { \ 988 979 i->private_starget_attrs[count].attr.mode = S_IRUGO; \ 989 980 i->private_starget_attrs[count].store = NULL; \ ··· 1004 995 1005 996 #define fc_vport_show_function(field, format_string, sz, cast) \ 1006 997 static ssize_t \ 1007 - show_fc_vport_##field (struct class_device *cdev, char *buf) \ 998 + show_fc_vport_##field (struct device *dev, \ 999 + struct device_attribute *attr, char *buf) \ 1008 1000 { \ 1009 - struct fc_vport *vport = transport_class_to_vport(cdev); \ 1001 + struct fc_vport *vport = transport_class_to_vport(dev); \ 1010 1002 struct Scsi_Host *shost = vport_to_shost(vport); \ 1011 1003 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1012 1004 if ((i->f->get_vport_##field) && \ ··· 1018 1008 1019 1009 #define fc_vport_store_function(field) \ 1020 1010 static ssize_t \ 1021 - store_fc_vport_##field(struct class_device *cdev, const char *buf, \ 1022 - size_t count) \ 1011 + store_fc_vport_##field(struct device *dev, \ 1012 + struct device_attribute *attr, \ 1013 + const char *buf, size_t count) \ 1023 1014 { \ 1024 1015 int val; \ 1025 - struct fc_vport *vport = transport_class_to_vport(cdev); \ 1016 + struct fc_vport *vport = transport_class_to_vport(dev); \ 1026 1017 struct Scsi_Host *shost = vport_to_shost(vport); \ 1027 1018 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1028 1019 char *cp; \ ··· 1038 1027 1039 1028 #define fc_vport_store_str_function(field, slen) \ 1040 1029 static ssize_t \ 1041 - store_fc_vport_##field(struct class_device *cdev, const char *buf, \ 1042 - size_t count) \ 1030 + store_fc_vport_##field(struct device *dev, \ 1031 + struct device_attribute *attr, \ 1032 + const char *buf, size_t count) \ 1043 1033 { \ 1044 - struct fc_vport *vport = transport_class_to_vport(cdev); \ 1034 + struct fc_vport *vport = transport_class_to_vport(dev); \ 1045 1035 struct Scsi_Host *shost = vport_to_shost(vport); \ 1046 1036 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1047 1037 unsigned int cnt=count; \ ··· 1059 1047 1060 1048 #define fc_vport_rd_attr(field, format_string, sz) \ 1061 1049 fc_vport_show_function(field, format_string, sz, ) \ 1062 - static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ 1050 + static FC_DEVICE_ATTR(vport, field, S_IRUGO, \ 1063 1051 show_fc_vport_##field, NULL) 1064 1052 1065 1053 #define fc_vport_rd_attr_cast(field, format_string, sz, cast) \ 1066 1054 fc_vport_show_function(field, format_string, sz, (cast)) \ 1067 - static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ 1055 + static FC_DEVICE_ATTR(vport, field, S_IRUGO, \ 1068 1056 show_fc_vport_##field, NULL) 1069 1057 1070 1058 #define fc_vport_rw_attr(field, format_string, sz) \ 1071 1059 fc_vport_show_function(field, format_string, sz, ) \ 1072 1060 fc_vport_store_function(field) \ 1073 - static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \ 1061 + static FC_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \ 1074 1062 show_fc_vport_##field, \ 1075 1063 store_fc_vport_##field) 1076 1064 1077 1065 #define fc_private_vport_show_function(field, format_string, sz, cast) \ 1078 1066 static ssize_t \ 1079 - show_fc_vport_##field (struct class_device *cdev, char *buf) \ 1067 + show_fc_vport_##field (struct device *dev, \ 1068 + struct device_attribute *attr, char *buf) \ 1080 1069 { \ 1081 - struct fc_vport *vport = transport_class_to_vport(cdev); \ 1070 + struct fc_vport *vport = transport_class_to_vport(dev); \ 1082 1071 return snprintf(buf, sz, format_string, cast vport->field); \ 1083 1072 } 1084 1073 1085 1074 #define fc_private_vport_store_u32_function(field) \ 1086 1075 static ssize_t \ 1087 - store_fc_vport_##field(struct class_device *cdev, const char *buf, \ 1088 - size_t count) \ 1076 + store_fc_vport_##field(struct device *dev, \ 1077 + struct device_attribute *attr, \ 1078 + const char *buf, size_t count) \ 1089 1079 { \ 1090 1080 u32 val; \ 1091 - struct fc_vport *vport = transport_class_to_vport(cdev); \ 1081 + struct fc_vport *vport = transport_class_to_vport(dev); \ 1092 1082 char *cp; \ 1093 1083 if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING)) \ 1094 1084 return -EBUSY; \ ··· 1104 1090 1105 1091 #define fc_private_vport_rd_attr(field, format_string, sz) \ 1106 1092 fc_private_vport_show_function(field, format_string, sz, ) \ 1107 - static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ 1093 + static FC_DEVICE_ATTR(vport, field, S_IRUGO, \ 1108 1094 show_fc_vport_##field, NULL) 1109 1095 1110 1096 #define fc_private_vport_rd_attr_cast(field, format_string, sz, cast) \ 1111 1097 fc_private_vport_show_function(field, format_string, sz, (cast)) \ 1112 - static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ 1098 + static FC_DEVICE_ATTR(vport, field, S_IRUGO, \ 1113 1099 show_fc_vport_##field, NULL) 1114 1100 1115 1101 #define fc_private_vport_rw_u32_attr(field, format_string, sz) \ 1116 1102 fc_private_vport_show_function(field, format_string, sz, ) \ 1117 1103 fc_private_vport_store_u32_function(field) \ 1118 - static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \ 1104 + static FC_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \ 1119 1105 show_fc_vport_##field, \ 1120 1106 store_fc_vport_##field) 1121 1107 1122 1108 1123 1109 #define fc_private_vport_rd_enum_attr(title, maxlen) \ 1124 1110 static ssize_t \ 1125 - show_fc_vport_##title (struct class_device *cdev, char *buf) \ 1111 + show_fc_vport_##title (struct device *dev, \ 1112 + struct device_attribute *attr, \ 1113 + char *buf) \ 1126 1114 { \ 1127 - struct fc_vport *vport = transport_class_to_vport(cdev); \ 1115 + struct fc_vport *vport = transport_class_to_vport(dev); \ 1128 1116 const char *name; \ 1129 1117 name = get_fc_##title##_name(vport->title); \ 1130 1118 if (!name) \ 1131 1119 return -EINVAL; \ 1132 1120 return snprintf(buf, maxlen, "%s\n", name); \ 1133 1121 } \ 1134 - static FC_CLASS_DEVICE_ATTR(vport, title, S_IRUGO, \ 1122 + static FC_DEVICE_ATTR(vport, title, S_IRUGO, \ 1135 1123 show_fc_vport_##title, NULL) 1136 1124 1137 1125 1138 1126 #define SETUP_VPORT_ATTRIBUTE_RD(field) \ 1139 - i->private_vport_attrs[count] = class_device_attr_vport_##field; \ 1127 + i->private_vport_attrs[count] = device_attr_vport_##field; \ 1140 1128 i->private_vport_attrs[count].attr.mode = S_IRUGO; \ 1141 1129 i->private_vport_attrs[count].store = NULL; \ 1142 1130 i->vport_attrs[count] = &i->private_vport_attrs[count]; \ ··· 1147 1131 /* NOTE: Above MACRO differs: checks function not show bit */ 1148 1132 1149 1133 #define SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(field) \ 1150 - i->private_vport_attrs[count] = class_device_attr_vport_##field; \ 1134 + i->private_vport_attrs[count] = device_attr_vport_##field; \ 1151 1135 i->private_vport_attrs[count].attr.mode = S_IRUGO; \ 1152 1136 i->private_vport_attrs[count].store = NULL; \ 1153 1137 i->vport_attrs[count] = &i->private_vport_attrs[count]; \ 1154 1138 count++ 1155 1139 1156 1140 #define SETUP_VPORT_ATTRIBUTE_WR(field) \ 1157 - i->private_vport_attrs[count] = class_device_attr_vport_##field; \ 1141 + i->private_vport_attrs[count] = device_attr_vport_##field; \ 1158 1142 i->vport_attrs[count] = &i->private_vport_attrs[count]; \ 1159 1143 if (i->f->field) \ 1160 1144 count++ 1161 1145 /* NOTE: Above MACRO differs: checks function */ 1162 1146 1163 1147 #define SETUP_VPORT_ATTRIBUTE_RW(field) \ 1164 - i->private_vport_attrs[count] = class_device_attr_vport_##field; \ 1148 + i->private_vport_attrs[count] = device_attr_vport_##field; \ 1165 1149 if (!i->f->set_vport_##field) { \ 1166 1150 i->private_vport_attrs[count].attr.mode = S_IRUGO; \ 1167 1151 i->private_vport_attrs[count].store = NULL; \ ··· 1172 1156 1173 1157 #define SETUP_PRIVATE_VPORT_ATTRIBUTE_RW(field) \ 1174 1158 { \ 1175 - i->private_vport_attrs[count] = class_device_attr_vport_##field; \ 1159 + i->private_vport_attrs[count] = device_attr_vport_##field; \ 1176 1160 i->vport_attrs[count] = &i->private_vport_attrs[count]; \ 1177 1161 count++; \ 1178 1162 } ··· 1192 1176 fc_private_vport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long); 1193 1177 1194 1178 static ssize_t 1195 - show_fc_vport_roles (struct class_device *cdev, char *buf) 1179 + show_fc_vport_roles (struct device *dev, struct device_attribute *attr, 1180 + char *buf) 1196 1181 { 1197 - struct fc_vport *vport = transport_class_to_vport(cdev); 1182 + struct fc_vport *vport = transport_class_to_vport(dev); 1198 1183 1199 1184 if (vport->roles == FC_PORT_ROLE_UNKNOWN) 1200 1185 return snprintf(buf, 20, "unknown\n"); 1201 1186 return get_fc_port_roles_names(vport->roles, buf); 1202 1187 } 1203 - static FC_CLASS_DEVICE_ATTR(vport, roles, S_IRUGO, show_fc_vport_roles, NULL); 1188 + static FC_DEVICE_ATTR(vport, roles, S_IRUGO, show_fc_vport_roles, NULL); 1204 1189 1205 1190 fc_private_vport_rd_enum_attr(vport_type, FC_PORTTYPE_MAX_NAMELEN); 1206 1191 1207 1192 fc_private_vport_show_function(symbolic_name, "%s\n", 1208 1193 FC_VPORT_SYMBOLIC_NAMELEN + 1, ) 1209 1194 fc_vport_store_str_function(symbolic_name, FC_VPORT_SYMBOLIC_NAMELEN) 1210 - static FC_CLASS_DEVICE_ATTR(vport, symbolic_name, S_IRUGO | S_IWUSR, 1195 + static FC_DEVICE_ATTR(vport, symbolic_name, S_IRUGO | S_IWUSR, 1211 1196 show_fc_vport_symbolic_name, store_fc_vport_symbolic_name); 1212 1197 1213 1198 static ssize_t 1214 - store_fc_vport_delete(struct class_device *cdev, const char *buf, 1215 - size_t count) 1199 + store_fc_vport_delete(struct device *dev, struct device_attribute *attr, 1200 + const char *buf, size_t count) 1216 1201 { 1217 - struct fc_vport *vport = transport_class_to_vport(cdev); 1202 + struct fc_vport *vport = transport_class_to_vport(dev); 1218 1203 struct Scsi_Host *shost = vport_to_shost(vport); 1219 1204 1220 1205 fc_queue_work(shost, &vport->vport_delete_work); 1221 1206 return count; 1222 1207 } 1223 - static FC_CLASS_DEVICE_ATTR(vport, vport_delete, S_IWUSR, 1208 + static FC_DEVICE_ATTR(vport, vport_delete, S_IWUSR, 1224 1209 NULL, store_fc_vport_delete); 1225 1210 1226 1211 ··· 1230 1213 * Write "1" to disable, write "0" to enable 1231 1214 */ 1232 1215 static ssize_t 1233 - store_fc_vport_disable(struct class_device *cdev, const char *buf, 1216 + store_fc_vport_disable(struct device *dev, struct device_attribute *attr, 1217 + const char *buf, 1234 1218 size_t count) 1235 1219 { 1236 - struct fc_vport *vport = transport_class_to_vport(cdev); 1220 + struct fc_vport *vport = transport_class_to_vport(dev); 1237 1221 struct Scsi_Host *shost = vport_to_shost(vport); 1238 1222 struct fc_internal *i = to_fc_internal(shost->transportt); 1239 1223 int stat; ··· 1254 1236 stat = i->f->vport_disable(vport, ((*buf == '0') ? false : true)); 1255 1237 return stat ? stat : count; 1256 1238 } 1257 - static FC_CLASS_DEVICE_ATTR(vport, vport_disable, S_IWUSR, 1239 + static FC_DEVICE_ATTR(vport, vport_disable, S_IWUSR, 1258 1240 NULL, store_fc_vport_disable); 1259 1241 1260 1242 ··· 1264 1246 1265 1247 #define fc_host_show_function(field, format_string, sz, cast) \ 1266 1248 static ssize_t \ 1267 - show_fc_host_##field (struct class_device *cdev, char *buf) \ 1249 + show_fc_host_##field (struct device *dev, \ 1250 + struct device_attribute *attr, char *buf) \ 1268 1251 { \ 1269 - struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1252 + struct Scsi_Host *shost = transport_class_to_shost(dev); \ 1270 1253 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1271 1254 if (i->f->get_host_##field) \ 1272 1255 i->f->get_host_##field(shost); \ ··· 1276 1257 1277 1258 #define fc_host_store_function(field) \ 1278 1259 static ssize_t \ 1279 - store_fc_host_##field(struct class_device *cdev, const char *buf, \ 1280 - size_t count) \ 1260 + store_fc_host_##field(struct device *dev, \ 1261 + struct device_attribute *attr, \ 1262 + const char *buf, size_t count) \ 1281 1263 { \ 1282 1264 int val; \ 1283 - struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1265 + struct Scsi_Host *shost = transport_class_to_shost(dev); \ 1284 1266 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1285 1267 char *cp; \ 1286 1268 \ ··· 1294 1274 1295 1275 #define fc_host_store_str_function(field, slen) \ 1296 1276 static ssize_t \ 1297 - store_fc_host_##field(struct class_device *cdev, const char *buf, \ 1298 - size_t count) \ 1277 + store_fc_host_##field(struct device *dev, \ 1278 + struct device_attribute *attr, \ 1279 + const char *buf, size_t count) \ 1299 1280 { \ 1300 - struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1281 + struct Scsi_Host *shost = transport_class_to_shost(dev); \ 1301 1282 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1302 1283 unsigned int cnt=count; \ 1303 1284 \ ··· 1314 1293 1315 1294 #define fc_host_rd_attr(field, format_string, sz) \ 1316 1295 fc_host_show_function(field, format_string, sz, ) \ 1317 - static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ 1296 + static FC_DEVICE_ATTR(host, field, S_IRUGO, \ 1318 1297 show_fc_host_##field, NULL) 1319 1298 1320 1299 #define fc_host_rd_attr_cast(field, format_string, sz, cast) \ 1321 1300 fc_host_show_function(field, format_string, sz, (cast)) \ 1322 - static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ 1301 + static FC_DEVICE_ATTR(host, field, S_IRUGO, \ 1323 1302 show_fc_host_##field, NULL) 1324 1303 1325 1304 #define fc_host_rw_attr(field, format_string, sz) \ 1326 1305 fc_host_show_function(field, format_string, sz, ) \ 1327 1306 fc_host_store_function(field) \ 1328 - static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO | S_IWUSR, \ 1307 + static FC_DEVICE_ATTR(host, field, S_IRUGO | S_IWUSR, \ 1329 1308 show_fc_host_##field, \ 1330 1309 store_fc_host_##field) 1331 1310 1332 1311 #define fc_host_rd_enum_attr(title, maxlen) \ 1333 1312 static ssize_t \ 1334 - show_fc_host_##title (struct class_device *cdev, char *buf) \ 1313 + show_fc_host_##title (struct device *dev, \ 1314 + struct device_attribute *attr, char *buf) \ 1335 1315 { \ 1336 - struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1316 + struct Scsi_Host *shost = transport_class_to_shost(dev); \ 1337 1317 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1338 1318 const char *name; \ 1339 1319 if (i->f->get_host_##title) \ ··· 1344 1322 return -EINVAL; \ 1345 1323 return snprintf(buf, maxlen, "%s\n", name); \ 1346 1324 } \ 1347 - static FC_CLASS_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL) 1325 + static FC_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL) 1348 1326 1349 1327 #define SETUP_HOST_ATTRIBUTE_RD(field) \ 1350 - i->private_host_attrs[count] = class_device_attr_host_##field; \ 1328 + i->private_host_attrs[count] = device_attr_host_##field; \ 1351 1329 i->private_host_attrs[count].attr.mode = S_IRUGO; \ 1352 1330 i->private_host_attrs[count].store = NULL; \ 1353 1331 i->host_attrs[count] = &i->private_host_attrs[count]; \ ··· 1355 1333 count++ 1356 1334 1357 1335 #define SETUP_HOST_ATTRIBUTE_RD_NS(field) \ 1358 - i->private_host_attrs[count] = class_device_attr_host_##field; \ 1336 + i->private_host_attrs[count] = device_attr_host_##field; \ 1359 1337 i->private_host_attrs[count].attr.mode = S_IRUGO; \ 1360 1338 i->private_host_attrs[count].store = NULL; \ 1361 1339 i->host_attrs[count] = &i->private_host_attrs[count]; \ 1362 1340 count++ 1363 1341 1364 1342 #define SETUP_HOST_ATTRIBUTE_RW(field) \ 1365 - i->private_host_attrs[count] = class_device_attr_host_##field; \ 1343 + i->private_host_attrs[count] = device_attr_host_##field; \ 1366 1344 if (!i->f->set_host_##field) { \ 1367 1345 i->private_host_attrs[count].attr.mode = S_IRUGO; \ 1368 1346 i->private_host_attrs[count].store = NULL; \ ··· 1374 1352 1375 1353 #define fc_private_host_show_function(field, format_string, sz, cast) \ 1376 1354 static ssize_t \ 1377 - show_fc_host_##field (struct class_device *cdev, char *buf) \ 1355 + show_fc_host_##field (struct device *dev, \ 1356 + struct device_attribute *attr, char *buf) \ 1378 1357 { \ 1379 - struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1358 + struct Scsi_Host *shost = transport_class_to_shost(dev); \ 1380 1359 return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \ 1381 1360 } 1382 1361 1383 1362 #define fc_private_host_rd_attr(field, format_string, sz) \ 1384 1363 fc_private_host_show_function(field, format_string, sz, ) \ 1385 - static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ 1364 + static FC_DEVICE_ATTR(host, field, S_IRUGO, \ 1386 1365 show_fc_host_##field, NULL) 1387 1366 1388 1367 #define fc_private_host_rd_attr_cast(field, format_string, sz, cast) \ 1389 1368 fc_private_host_show_function(field, format_string, sz, (cast)) \ 1390 - static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ 1369 + static FC_DEVICE_ATTR(host, field, S_IRUGO, \ 1391 1370 show_fc_host_##field, NULL) 1392 1371 1393 1372 #define SETUP_PRIVATE_HOST_ATTRIBUTE_RD(field) \ 1394 - i->private_host_attrs[count] = class_device_attr_host_##field; \ 1373 + i->private_host_attrs[count] = device_attr_host_##field; \ 1395 1374 i->private_host_attrs[count].attr.mode = S_IRUGO; \ 1396 1375 i->private_host_attrs[count].store = NULL; \ 1397 1376 i->host_attrs[count] = &i->private_host_attrs[count]; \ ··· 1400 1377 1401 1378 #define SETUP_PRIVATE_HOST_ATTRIBUTE_RW(field) \ 1402 1379 { \ 1403 - i->private_host_attrs[count] = class_device_attr_host_##field; \ 1380 + i->private_host_attrs[count] = device_attr_host_##field; \ 1404 1381 i->host_attrs[count] = &i->private_host_attrs[count]; \ 1405 1382 count++; \ 1406 1383 } ··· 1409 1386 /* Fixed Host Attributes */ 1410 1387 1411 1388 static ssize_t 1412 - show_fc_host_supported_classes (struct class_device *cdev, char *buf) 1389 + show_fc_host_supported_classes (struct device *dev, 1390 + struct device_attribute *attr, char *buf) 1413 1391 { 1414 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1392 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1415 1393 1416 1394 if (fc_host_supported_classes(shost) == FC_COS_UNSPECIFIED) 1417 1395 return snprintf(buf, 20, "unspecified\n"); 1418 1396 1419 1397 return get_fc_cos_names(fc_host_supported_classes(shost), buf); 1420 1398 } 1421 - static FC_CLASS_DEVICE_ATTR(host, supported_classes, S_IRUGO, 1399 + static FC_DEVICE_ATTR(host, supported_classes, S_IRUGO, 1422 1400 show_fc_host_supported_classes, NULL); 1423 1401 1424 1402 static ssize_t 1425 - show_fc_host_supported_fc4s (struct class_device *cdev, char *buf) 1403 + show_fc_host_supported_fc4s (struct device *dev, 1404 + struct device_attribute *attr, char *buf) 1426 1405 { 1427 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1406 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1428 1407 return (ssize_t)show_fc_fc4s(buf, fc_host_supported_fc4s(shost)); 1429 1408 } 1430 - static FC_CLASS_DEVICE_ATTR(host, supported_fc4s, S_IRUGO, 1409 + static FC_DEVICE_ATTR(host, supported_fc4s, S_IRUGO, 1431 1410 show_fc_host_supported_fc4s, NULL); 1432 1411 1433 1412 static ssize_t 1434 - show_fc_host_supported_speeds (struct class_device *cdev, char *buf) 1413 + show_fc_host_supported_speeds (struct device *dev, 1414 + struct device_attribute *attr, char *buf) 1435 1415 { 1436 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1416 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1437 1417 1438 1418 if (fc_host_supported_speeds(shost) == FC_PORTSPEED_UNKNOWN) 1439 1419 return snprintf(buf, 20, "unknown\n"); 1440 1420 1441 1421 return get_fc_port_speed_names(fc_host_supported_speeds(shost), buf); 1442 1422 } 1443 - static FC_CLASS_DEVICE_ATTR(host, supported_speeds, S_IRUGO, 1423 + static FC_DEVICE_ATTR(host, supported_speeds, S_IRUGO, 1444 1424 show_fc_host_supported_speeds, NULL); 1445 1425 1446 1426 ··· 1459 1433 /* Dynamic Host Attributes */ 1460 1434 1461 1435 static ssize_t 1462 - show_fc_host_active_fc4s (struct class_device *cdev, char *buf) 1436 + show_fc_host_active_fc4s (struct device *dev, 1437 + struct device_attribute *attr, char *buf) 1463 1438 { 1464 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1439 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1465 1440 struct fc_internal *i = to_fc_internal(shost->transportt); 1466 1441 1467 1442 if (i->f->get_host_active_fc4s) ··· 1470 1443 1471 1444 return (ssize_t)show_fc_fc4s(buf, fc_host_active_fc4s(shost)); 1472 1445 } 1473 - static FC_CLASS_DEVICE_ATTR(host, active_fc4s, S_IRUGO, 1446 + static FC_DEVICE_ATTR(host, active_fc4s, S_IRUGO, 1474 1447 show_fc_host_active_fc4s, NULL); 1475 1448 1476 1449 static ssize_t 1477 - show_fc_host_speed (struct class_device *cdev, char *buf) 1450 + show_fc_host_speed (struct device *dev, 1451 + struct device_attribute *attr, char *buf) 1478 1452 { 1479 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1453 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1480 1454 struct fc_internal *i = to_fc_internal(shost->transportt); 1481 1455 1482 1456 if (i->f->get_host_speed) ··· 1488 1460 1489 1461 return get_fc_port_speed_names(fc_host_speed(shost), buf); 1490 1462 } 1491 - static FC_CLASS_DEVICE_ATTR(host, speed, S_IRUGO, 1463 + static FC_DEVICE_ATTR(host, speed, S_IRUGO, 1492 1464 show_fc_host_speed, NULL); 1493 1465 1494 1466 ··· 1501 1473 fc_private_host_show_function(system_hostname, "%s\n", 1502 1474 FC_SYMBOLIC_NAME_SIZE + 1, ) 1503 1475 fc_host_store_str_function(system_hostname, FC_SYMBOLIC_NAME_SIZE) 1504 - static FC_CLASS_DEVICE_ATTR(host, system_hostname, S_IRUGO | S_IWUSR, 1476 + static FC_DEVICE_ATTR(host, system_hostname, S_IRUGO | S_IWUSR, 1505 1477 show_fc_host_system_hostname, store_fc_host_system_hostname); 1506 1478 1507 1479 1508 1480 /* Private Host Attributes */ 1509 1481 1510 1482 static ssize_t 1511 - show_fc_private_host_tgtid_bind_type(struct class_device *cdev, char *buf) 1483 + show_fc_private_host_tgtid_bind_type(struct device *dev, 1484 + struct device_attribute *attr, char *buf) 1512 1485 { 1513 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1486 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1514 1487 const char *name; 1515 1488 1516 1489 name = get_fc_tgtid_bind_type_name(fc_host_tgtid_bind_type(shost)); ··· 1524 1495 pos = list_entry((head)->next, typeof(*pos), member) 1525 1496 1526 1497 static ssize_t 1527 - store_fc_private_host_tgtid_bind_type(struct class_device *cdev, 1528 - const char *buf, size_t count) 1498 + store_fc_private_host_tgtid_bind_type(struct device *dev, 1499 + struct device_attribute *attr, const char *buf, size_t count) 1529 1500 { 1530 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1501 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1531 1502 struct fc_rport *rport; 1532 1503 enum fc_tgtid_binding_type val; 1533 1504 unsigned long flags; ··· 1552 1523 return count; 1553 1524 } 1554 1525 1555 - static FC_CLASS_DEVICE_ATTR(host, tgtid_bind_type, S_IRUGO | S_IWUSR, 1526 + static FC_DEVICE_ATTR(host, tgtid_bind_type, S_IRUGO | S_IWUSR, 1556 1527 show_fc_private_host_tgtid_bind_type, 1557 1528 store_fc_private_host_tgtid_bind_type); 1558 1529 1559 1530 static ssize_t 1560 - store_fc_private_host_issue_lip(struct class_device *cdev, 1561 - const char *buf, size_t count) 1531 + store_fc_private_host_issue_lip(struct device *dev, 1532 + struct device_attribute *attr, const char *buf, size_t count) 1562 1533 { 1563 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1534 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1564 1535 struct fc_internal *i = to_fc_internal(shost->transportt); 1565 1536 int ret; 1566 1537 ··· 1573 1544 return -ENOENT; 1574 1545 } 1575 1546 1576 - static FC_CLASS_DEVICE_ATTR(host, issue_lip, S_IWUSR, NULL, 1547 + static FC_DEVICE_ATTR(host, issue_lip, S_IWUSR, NULL, 1577 1548 store_fc_private_host_issue_lip); 1578 1549 1579 1550 fc_private_host_rd_attr(npiv_vports_inuse, "%u\n", 20); ··· 1585 1556 1586 1557 /* Show a given an attribute in the statistics group */ 1587 1558 static ssize_t 1588 - fc_stat_show(const struct class_device *cdev, char *buf, unsigned long offset) 1559 + fc_stat_show(const struct device *dev, char *buf, unsigned long offset) 1589 1560 { 1590 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1561 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1591 1562 struct fc_internal *i = to_fc_internal(shost->transportt); 1592 1563 struct fc_host_statistics *stats; 1593 1564 ssize_t ret = -ENOENT; ··· 1608 1579 1609 1580 /* generate a read-only statistics attribute */ 1610 1581 #define fc_host_statistic(name) \ 1611 - static ssize_t show_fcstat_##name(struct class_device *cd, char *buf) \ 1582 + static ssize_t show_fcstat_##name(struct device *cd, \ 1583 + struct device_attribute *attr, \ 1584 + char *buf) \ 1612 1585 { \ 1613 1586 return fc_stat_show(cd, buf, \ 1614 1587 offsetof(struct fc_host_statistics, name)); \ 1615 1588 } \ 1616 - static FC_CLASS_DEVICE_ATTR(host, name, S_IRUGO, show_fcstat_##name, NULL) 1589 + static FC_DEVICE_ATTR(host, name, S_IRUGO, show_fcstat_##name, NULL) 1617 1590 1618 1591 fc_host_statistic(seconds_since_last_reset); 1619 1592 fc_host_statistic(tx_frames); ··· 1639 1608 fc_host_statistic(fcp_output_megabytes); 1640 1609 1641 1610 static ssize_t 1642 - fc_reset_statistics(struct class_device *cdev, const char *buf, 1643 - size_t count) 1611 + fc_reset_statistics(struct device *dev, struct device_attribute *attr, 1612 + const char *buf, size_t count) 1644 1613 { 1645 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1614 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1646 1615 struct fc_internal *i = to_fc_internal(shost->transportt); 1647 1616 1648 1617 /* ignore any data value written to the attribute */ ··· 1653 1622 1654 1623 return -ENOENT; 1655 1624 } 1656 - static FC_CLASS_DEVICE_ATTR(host, reset_statistics, S_IWUSR, NULL, 1625 + static FC_DEVICE_ATTR(host, reset_statistics, S_IWUSR, NULL, 1657 1626 fc_reset_statistics); 1658 1627 1659 1628 static struct attribute *fc_statistics_attrs[] = { 1660 - &class_device_attr_host_seconds_since_last_reset.attr, 1661 - &class_device_attr_host_tx_frames.attr, 1662 - &class_device_attr_host_tx_words.attr, 1663 - &class_device_attr_host_rx_frames.attr, 1664 - &class_device_attr_host_rx_words.attr, 1665 - &class_device_attr_host_lip_count.attr, 1666 - &class_device_attr_host_nos_count.attr, 1667 - &class_device_attr_host_error_frames.attr, 1668 - &class_device_attr_host_dumped_frames.attr, 1669 - &class_device_attr_host_link_failure_count.attr, 1670 - &class_device_attr_host_loss_of_sync_count.attr, 1671 - &class_device_attr_host_loss_of_signal_count.attr, 1672 - &class_device_attr_host_prim_seq_protocol_err_count.attr, 1673 - &class_device_attr_host_invalid_tx_word_count.attr, 1674 - &class_device_attr_host_invalid_crc_count.attr, 1675 - &class_device_attr_host_fcp_input_requests.attr, 1676 - &class_device_attr_host_fcp_output_requests.attr, 1677 - &class_device_attr_host_fcp_control_requests.attr, 1678 - &class_device_attr_host_fcp_input_megabytes.attr, 1679 - &class_device_attr_host_fcp_output_megabytes.attr, 1680 - &class_device_attr_host_reset_statistics.attr, 1629 + &device_attr_host_seconds_since_last_reset.attr, 1630 + &device_attr_host_tx_frames.attr, 1631 + &device_attr_host_tx_words.attr, 1632 + &device_attr_host_rx_frames.attr, 1633 + &device_attr_host_rx_words.attr, 1634 + &device_attr_host_lip_count.attr, 1635 + &device_attr_host_nos_count.attr, 1636 + &device_attr_host_error_frames.attr, 1637 + &device_attr_host_dumped_frames.attr, 1638 + &device_attr_host_link_failure_count.attr, 1639 + &device_attr_host_loss_of_sync_count.attr, 1640 + &device_attr_host_loss_of_signal_count.attr, 1641 + &device_attr_host_prim_seq_protocol_err_count.attr, 1642 + &device_attr_host_invalid_tx_word_count.attr, 1643 + &device_attr_host_invalid_crc_count.attr, 1644 + &device_attr_host_fcp_input_requests.attr, 1645 + &device_attr_host_fcp_output_requests.attr, 1646 + &device_attr_host_fcp_control_requests.attr, 1647 + &device_attr_host_fcp_input_megabytes.attr, 1648 + &device_attr_host_fcp_output_megabytes.attr, 1649 + &device_attr_host_reset_statistics.attr, 1681 1650 NULL 1682 1651 }; 1683 1652 ··· 1726 1695 * as hex characters, and may *not* contain any prefixes (e.g. 0x, x, etc) 1727 1696 */ 1728 1697 static ssize_t 1729 - store_fc_host_vport_create(struct class_device *cdev, const char *buf, 1730 - size_t count) 1698 + store_fc_host_vport_create(struct device *dev, struct device_attribute *attr, 1699 + const char *buf, size_t count) 1731 1700 { 1732 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1701 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1733 1702 struct fc_vport_identifiers vid; 1734 1703 struct fc_vport *vport; 1735 1704 unsigned int cnt=count; ··· 1762 1731 stat = fc_vport_create(shost, 0, &shost->shost_gendev, &vid, &vport); 1763 1732 return stat ? stat : count; 1764 1733 } 1765 - static FC_CLASS_DEVICE_ATTR(host, vport_create, S_IWUSR, NULL, 1734 + static FC_DEVICE_ATTR(host, vport_create, S_IWUSR, NULL, 1766 1735 store_fc_host_vport_create); 1767 1736 1768 1737 ··· 1773 1742 * any prefixes (e.g. 0x, x, etc) 1774 1743 */ 1775 1744 static ssize_t 1776 - store_fc_host_vport_delete(struct class_device *cdev, const char *buf, 1777 - size_t count) 1745 + store_fc_host_vport_delete(struct device *dev, struct device_attribute *attr, 1746 + const char *buf, size_t count) 1778 1747 { 1779 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 1748 + struct Scsi_Host *shost = transport_class_to_shost(dev); 1780 1749 struct fc_host_attrs *fc_host = shost_to_fc_host(shost); 1781 1750 struct fc_vport *vport; 1782 1751 u64 wwpn, wwnn; ··· 1818 1787 stat = fc_vport_terminate(vport); 1819 1788 return stat ? stat : count; 1820 1789 } 1821 - static FC_CLASS_DEVICE_ATTR(host, vport_delete, S_IWUSR, NULL, 1790 + static FC_DEVICE_ATTR(host, vport_delete, S_IWUSR, NULL, 1822 1791 store_fc_host_vport_delete); 1823 1792 1824 1793
+55 -52
drivers/scsi/scsi_transport_iscsi.c
··· 40 40 struct scsi_transport_template t; 41 41 struct iscsi_transport *iscsi_transport; 42 42 struct list_head list; 43 - struct class_device cdev; 43 + struct device dev; 44 44 45 - struct class_device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1]; 45 + struct device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1]; 46 46 struct transport_container conn_cont; 47 - struct class_device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1]; 47 + struct device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1]; 48 48 struct transport_container session_cont; 49 - struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; 49 + struct device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; 50 50 }; 51 51 52 52 static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ ··· 63 63 #define to_iscsi_internal(tmpl) \ 64 64 container_of(tmpl, struct iscsi_internal, t) 65 65 66 - #define cdev_to_iscsi_internal(_cdev) \ 67 - container_of(_cdev, struct iscsi_internal, cdev) 66 + #define dev_to_iscsi_internal(_dev) \ 67 + container_of(_dev, struct iscsi_internal, dev) 68 68 69 - static void iscsi_transport_release(struct class_device *cdev) 69 + static void iscsi_transport_release(struct device *dev) 70 70 { 71 - struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); 71 + struct iscsi_internal *priv = dev_to_iscsi_internal(dev); 72 72 kfree(priv); 73 73 } 74 74 ··· 78 78 */ 79 79 static struct class iscsi_transport_class = { 80 80 .name = "iscsi_transport", 81 - .release = iscsi_transport_release, 81 + .dev_release = iscsi_transport_release, 82 82 }; 83 83 84 84 static ssize_t 85 - show_transport_handle(struct class_device *cdev, char *buf) 85 + show_transport_handle(struct device *dev, struct device_attribute *attr, 86 + char *buf) 86 87 { 87 - struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); 88 + struct iscsi_internal *priv = dev_to_iscsi_internal(dev); 88 89 return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport)); 89 90 } 90 - static CLASS_DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL); 91 + static DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL); 91 92 92 93 #define show_transport_attr(name, format) \ 93 94 static ssize_t \ 94 - show_transport_##name(struct class_device *cdev, char *buf) \ 95 + show_transport_##name(struct device *dev, \ 96 + struct device_attribute *attr,char *buf) \ 95 97 { \ 96 - struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); \ 98 + struct iscsi_internal *priv = dev_to_iscsi_internal(dev); \ 97 99 return sprintf(buf, format"\n", priv->iscsi_transport->name); \ 98 100 } \ 99 - static CLASS_DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL); 101 + static DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL); 100 102 101 103 show_transport_attr(caps, "0x%x"); 102 104 show_transport_attr(max_lun, "%d"); ··· 106 104 show_transport_attr(max_cmd_len, "%d"); 107 105 108 106 static struct attribute *iscsi_transport_attrs[] = { 109 - &class_device_attr_handle.attr, 110 - &class_device_attr_caps.attr, 111 - &class_device_attr_max_lun.attr, 112 - &class_device_attr_max_conn.attr, 113 - &class_device_attr_max_cmd_len.attr, 107 + &dev_attr_handle.attr, 108 + &dev_attr_caps.attr, 109 + &dev_attr_max_lun.attr, 110 + &dev_attr_max_conn.attr, 111 + &dev_attr_max_cmd_len.attr, 114 112 NULL, 115 113 }; 116 114 ··· 121 119 122 120 123 121 static int iscsi_setup_host(struct transport_container *tc, struct device *dev, 124 - struct class_device *cdev) 122 + struct device *cdev) 125 123 { 126 124 struct Scsi_Host *shost = dev_to_shost(dev); 127 125 struct iscsi_host *ihost = shost->shost_data; ··· 141 139 } 142 140 143 141 static int iscsi_remove_host(struct transport_container *tc, struct device *dev, 144 - struct class_device *cdev) 142 + struct device *cdev) 145 143 { 146 144 struct Scsi_Host *shost = dev_to_shost(dev); 147 145 struct iscsi_host *ihost = shost->shost_data; ··· 1339 1337 mutex_unlock(&rx_queue_mutex); 1340 1338 } 1341 1339 1342 - #define iscsi_cdev_to_conn(_cdev) \ 1343 - iscsi_dev_to_conn(_cdev->dev) 1344 - 1345 1340 #define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \ 1346 - struct class_device_attribute class_device_attr_##_prefix##_##_name = \ 1341 + struct device_attribute dev_attr_##_prefix##_##_name = \ 1347 1342 __ATTR(_name,_mode,_show,_store) 1348 1343 1349 1344 /* ··· 1348 1349 */ 1349 1350 #define iscsi_conn_attr_show(param) \ 1350 1351 static ssize_t \ 1351 - show_conn_param_##param(struct class_device *cdev, char *buf) \ 1352 + show_conn_param_##param(struct device *dev, \ 1353 + struct device_attribute *attr, char *buf) \ 1352 1354 { \ 1353 - struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \ 1355 + struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); \ 1354 1356 struct iscsi_transport *t = conn->transport; \ 1355 1357 return t->get_conn_param(conn, param, buf); \ 1356 1358 } ··· 1375 1375 iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); 1376 1376 iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); 1377 1377 1378 - #define iscsi_cdev_to_session(_cdev) \ 1379 - iscsi_dev_to_session(_cdev->dev) 1380 - 1381 1378 /* 1382 1379 * iSCSI session attrs 1383 1380 */ 1384 1381 #define iscsi_session_attr_show(param, perm) \ 1385 1382 static ssize_t \ 1386 - show_session_param_##param(struct class_device *cdev, char *buf) \ 1383 + show_session_param_##param(struct device *dev, \ 1384 + struct device_attribute *attr, char *buf) \ 1387 1385 { \ 1388 - struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \ 1386 + struct iscsi_cls_session *session = \ 1387 + iscsi_dev_to_session(dev->parent); \ 1389 1388 struct iscsi_transport *t = session->transport; \ 1390 1389 \ 1391 1390 if (perm && !capable(CAP_SYS_ADMIN)) \ ··· 1416 1417 iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0); 1417 1418 1418 1419 static ssize_t 1419 - show_priv_session_state(struct class_device *cdev, char *buf) 1420 + show_priv_session_state(struct device *dev, struct device_attribute *attr, 1421 + char *buf) 1420 1422 { 1421 - struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); 1423 + struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent); 1422 1424 return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); 1423 1425 } 1424 1426 static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, ··· 1427 1427 1428 1428 #define iscsi_priv_session_attr_show(field, format) \ 1429 1429 static ssize_t \ 1430 - show_priv_session_##field(struct class_device *cdev, char *buf) \ 1430 + show_priv_session_##field(struct device *dev, \ 1431 + struct device_attribute *attr, char *buf) \ 1431 1432 { \ 1432 - struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev);\ 1433 + struct iscsi_cls_session *session = \ 1434 + iscsi_dev_to_session(dev->parent); \ 1433 1435 return sprintf(buf, format"\n", session->field); \ 1434 1436 } 1435 1437 ··· 1446 1444 */ 1447 1445 #define iscsi_host_attr_show(param) \ 1448 1446 static ssize_t \ 1449 - show_host_param_##param(struct class_device *cdev, char *buf) \ 1447 + show_host_param_##param(struct device *dev, \ 1448 + struct device_attribute *attr, char *buf) \ 1450 1449 { \ 1451 - struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1450 + struct Scsi_Host *shost = transport_class_to_shost(dev); \ 1452 1451 struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ 1453 1452 return priv->iscsi_transport->get_host_param(shost, param, buf); \ 1454 1453 } ··· 1466 1463 1467 1464 #define SETUP_PRIV_SESSION_RD_ATTR(field) \ 1468 1465 do { \ 1469 - priv->session_attrs[count] = &class_device_attr_priv_sess_##field; \ 1466 + priv->session_attrs[count] = &dev_attr_priv_sess_##field; \ 1470 1467 count++; \ 1471 1468 } while (0) 1472 1469 ··· 1474 1471 #define SETUP_SESSION_RD_ATTR(field, param_flag) \ 1475 1472 do { \ 1476 1473 if (tt->param_mask & param_flag) { \ 1477 - priv->session_attrs[count] = &class_device_attr_sess_##field; \ 1474 + priv->session_attrs[count] = &dev_attr_sess_##field; \ 1478 1475 count++; \ 1479 1476 } \ 1480 1477 } while (0) ··· 1482 1479 #define SETUP_CONN_RD_ATTR(field, param_flag) \ 1483 1480 do { \ 1484 1481 if (tt->param_mask & param_flag) { \ 1485 - priv->conn_attrs[count] = &class_device_attr_conn_##field; \ 1482 + priv->conn_attrs[count] = &dev_attr_conn_##field; \ 1486 1483 count++; \ 1487 1484 } \ 1488 1485 } while (0) ··· 1490 1487 #define SETUP_HOST_RD_ATTR(field, param_flag) \ 1491 1488 do { \ 1492 1489 if (tt->host_param_mask & param_flag) { \ 1493 - priv->host_attrs[count] = &class_device_attr_host_##field; \ 1490 + priv->host_attrs[count] = &dev_attr_host_##field; \ 1494 1491 count++; \ 1495 1492 } \ 1496 1493 } while (0) ··· 1581 1578 priv->iscsi_transport = tt; 1582 1579 priv->t.user_scan = iscsi_user_scan; 1583 1580 1584 - priv->cdev.class = &iscsi_transport_class; 1585 - snprintf(priv->cdev.class_id, BUS_ID_SIZE, "%s", tt->name); 1586 - err = class_device_register(&priv->cdev); 1581 + priv->dev.class = &iscsi_transport_class; 1582 + snprintf(priv->dev.bus_id, BUS_ID_SIZE, "%s", tt->name); 1583 + err = device_register(&priv->dev); 1587 1584 if (err) 1588 1585 goto free_priv; 1589 1586 1590 - err = sysfs_create_group(&priv->cdev.kobj, &iscsi_transport_group); 1587 + err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group); 1591 1588 if (err) 1592 - goto unregister_cdev; 1589 + goto unregister_dev; 1593 1590 1594 1591 /* host parameters */ 1595 1592 priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; ··· 1666 1663 printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); 1667 1664 return &priv->t; 1668 1665 1669 - unregister_cdev: 1670 - class_device_unregister(&priv->cdev); 1666 + unregister_dev: 1667 + device_unregister(&priv->dev); 1671 1668 free_priv: 1672 1669 kfree(priv); 1673 1670 return NULL; ··· 1694 1691 transport_container_unregister(&priv->session_cont); 1695 1692 transport_container_unregister(&priv->t.host_attrs); 1696 1693 1697 - sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group); 1698 - class_device_unregister(&priv->cdev); 1694 + sysfs_remove_group(&priv->dev.kobj, &iscsi_transport_group); 1695 + device_unregister(&priv->dev); 1699 1696 mutex_unlock(&rx_queue_mutex); 1700 1697 1701 1698 return 0;
+88 -69
drivers/scsi/scsi_transport_sas.c
··· 53 53 /* 54 54 * Hack to allow attributes of the same name in different objects. 55 55 */ 56 - #define SAS_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ 57 - struct class_device_attribute class_device_attr_##_prefix##_##_name = \ 56 + #define SAS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ 57 + struct device_attribute dev_attr_##_prefix##_##_name = \ 58 58 __ATTR(_name,_mode,_show,_store) 59 59 60 60 ··· 261 261 */ 262 262 263 263 static int sas_host_setup(struct transport_container *tc, struct device *dev, 264 - struct class_device *cdev) 264 + struct device *cdev) 265 265 { 266 266 struct Scsi_Host *shost = dev_to_shost(dev); 267 267 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); ··· 280 280 } 281 281 282 282 static int sas_host_remove(struct transport_container *tc, struct device *dev, 283 - struct class_device *cdev) 283 + struct device *cdev) 284 284 { 285 285 struct Scsi_Host *shost = dev_to_shost(dev); 286 286 ··· 356 356 357 357 #define sas_phy_show_simple(field, name, format_string, cast) \ 358 358 static ssize_t \ 359 - show_sas_phy_##name(struct class_device *cdev, char *buf) \ 359 + show_sas_phy_##name(struct device *dev, \ 360 + struct device_attribute *attr, char *buf) \ 360 361 { \ 361 - struct sas_phy *phy = transport_class_to_phy(cdev); \ 362 + struct sas_phy *phy = transport_class_to_phy(dev); \ 362 363 \ 363 364 return snprintf(buf, 20, format_string, cast phy->field); \ 364 365 } 365 366 366 367 #define sas_phy_simple_attr(field, name, format_string, type) \ 367 368 sas_phy_show_simple(field, name, format_string, (type)) \ 368 - static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL) 369 + static DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL) 369 370 370 371 #define sas_phy_show_protocol(field, name) \ 371 372 static ssize_t \ 372 - show_sas_phy_##name(struct class_device *cdev, char *buf) \ 373 + show_sas_phy_##name(struct device *dev, \ 374 + struct device_attribute *attr, char *buf) \ 373 375 { \ 374 - struct sas_phy *phy = transport_class_to_phy(cdev); \ 376 + struct sas_phy *phy = transport_class_to_phy(dev); \ 375 377 \ 376 378 if (!phy->field) \ 377 379 return snprintf(buf, 20, "none\n"); \ ··· 382 380 383 381 #define sas_phy_protocol_attr(field, name) \ 384 382 sas_phy_show_protocol(field, name) \ 385 - static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL) 383 + static DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL) 386 384 387 385 #define sas_phy_show_linkspeed(field) \ 388 386 static ssize_t \ 389 - show_sas_phy_##field(struct class_device *cdev, char *buf) \ 387 + show_sas_phy_##field(struct device *dev, \ 388 + struct device_attribute *attr, char *buf) \ 390 389 { \ 391 - struct sas_phy *phy = transport_class_to_phy(cdev); \ 390 + struct sas_phy *phy = transport_class_to_phy(dev); \ 392 391 \ 393 392 return get_sas_linkspeed_names(phy->field, buf); \ 394 393 } ··· 397 394 /* Fudge to tell if we're minimum or maximum */ 398 395 #define sas_phy_store_linkspeed(field) \ 399 396 static ssize_t \ 400 - store_sas_phy_##field(struct class_device *cdev, const char *buf, \ 401 - size_t count) \ 397 + store_sas_phy_##field(struct device *dev, \ 398 + struct device_attribute *attr, \ 399 + const char *buf, size_t count) \ 402 400 { \ 403 - struct sas_phy *phy = transport_class_to_phy(cdev); \ 401 + struct sas_phy *phy = transport_class_to_phy(dev); \ 404 402 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \ 405 403 struct sas_internal *i = to_sas_internal(shost->transportt); \ 406 404 u32 value; \ ··· 420 416 #define sas_phy_linkspeed_rw_attr(field) \ 421 417 sas_phy_show_linkspeed(field) \ 422 418 sas_phy_store_linkspeed(field) \ 423 - static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, \ 419 + static DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, \ 424 420 store_sas_phy_##field) 425 421 426 422 #define sas_phy_linkspeed_attr(field) \ 427 423 sas_phy_show_linkspeed(field) \ 428 - static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL) 424 + static DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL) 429 425 430 426 431 427 #define sas_phy_show_linkerror(field) \ 432 428 static ssize_t \ 433 - show_sas_phy_##field(struct class_device *cdev, char *buf) \ 429 + show_sas_phy_##field(struct device *dev, \ 430 + struct device_attribute *attr, char *buf) \ 434 431 { \ 435 - struct sas_phy *phy = transport_class_to_phy(cdev); \ 432 + struct sas_phy *phy = transport_class_to_phy(dev); \ 436 433 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \ 437 434 struct sas_internal *i = to_sas_internal(shost->transportt); \ 438 435 int error; \ ··· 446 441 447 442 #define sas_phy_linkerror_attr(field) \ 448 443 sas_phy_show_linkerror(field) \ 449 - static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL) 444 + static DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL) 450 445 451 446 452 447 static ssize_t 453 - show_sas_device_type(struct class_device *cdev, char *buf) 448 + show_sas_device_type(struct device *dev, 449 + struct device_attribute *attr, char *buf) 454 450 { 455 - struct sas_phy *phy = transport_class_to_phy(cdev); 451 + struct sas_phy *phy = transport_class_to_phy(dev); 456 452 457 453 if (!phy->identify.device_type) 458 454 return snprintf(buf, 20, "none\n"); 459 455 return get_sas_device_type_names(phy->identify.device_type, buf); 460 456 } 461 - static CLASS_DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL); 457 + static DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL); 462 458 463 - static ssize_t do_sas_phy_enable(struct class_device *cdev, 459 + static ssize_t do_sas_phy_enable(struct device *dev, 464 460 size_t count, int enable) 465 461 { 466 - struct sas_phy *phy = transport_class_to_phy(cdev); 462 + struct sas_phy *phy = transport_class_to_phy(dev); 467 463 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); 468 464 struct sas_internal *i = to_sas_internal(shost->transportt); 469 465 int error; ··· 476 470 return count; 477 471 }; 478 472 479 - static ssize_t store_sas_phy_enable(struct class_device *cdev, 480 - const char *buf, size_t count) 473 + static ssize_t 474 + store_sas_phy_enable(struct device *dev, struct device_attribute *attr, 475 + const char *buf, size_t count) 481 476 { 482 477 if (count < 1) 483 478 return -EINVAL; 484 479 485 480 switch (buf[0]) { 486 481 case '0': 487 - do_sas_phy_enable(cdev, count, 0); 482 + do_sas_phy_enable(dev, count, 0); 488 483 break; 489 484 case '1': 490 - do_sas_phy_enable(cdev, count, 1); 485 + do_sas_phy_enable(dev, count, 1); 491 486 break; 492 487 default: 493 488 return -EINVAL; ··· 497 490 return count; 498 491 } 499 492 500 - static ssize_t show_sas_phy_enable(struct class_device *cdev, char *buf) 493 + static ssize_t 494 + show_sas_phy_enable(struct device *dev, struct device_attribute *attr, 495 + char *buf) 501 496 { 502 - struct sas_phy *phy = transport_class_to_phy(cdev); 497 + struct sas_phy *phy = transport_class_to_phy(dev); 503 498 504 499 return snprintf(buf, 20, "%d", phy->enabled); 505 500 } 506 501 507 - static CLASS_DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, show_sas_phy_enable, 502 + static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, show_sas_phy_enable, 508 503 store_sas_phy_enable); 509 504 510 - static ssize_t do_sas_phy_reset(struct class_device *cdev, 511 - size_t count, int hard_reset) 505 + static ssize_t 506 + do_sas_phy_reset(struct device *dev, size_t count, int hard_reset) 512 507 { 513 - struct sas_phy *phy = transport_class_to_phy(cdev); 508 + struct sas_phy *phy = transport_class_to_phy(dev); 514 509 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); 515 510 struct sas_internal *i = to_sas_internal(shost->transportt); 516 511 int error; ··· 523 514 return count; 524 515 }; 525 516 526 - static ssize_t store_sas_link_reset(struct class_device *cdev, 527 - const char *buf, size_t count) 517 + static ssize_t 518 + store_sas_link_reset(struct device *dev, struct device_attribute *attr, 519 + const char *buf, size_t count) 528 520 { 529 - return do_sas_phy_reset(cdev, count, 0); 521 + return do_sas_phy_reset(dev, count, 0); 530 522 } 531 - static CLASS_DEVICE_ATTR(link_reset, S_IWUSR, NULL, store_sas_link_reset); 523 + static DEVICE_ATTR(link_reset, S_IWUSR, NULL, store_sas_link_reset); 532 524 533 - static ssize_t store_sas_hard_reset(struct class_device *cdev, 534 - const char *buf, size_t count) 525 + static ssize_t 526 + store_sas_hard_reset(struct device *dev, struct device_attribute *attr, 527 + const char *buf, size_t count) 535 528 { 536 - return do_sas_phy_reset(cdev, count, 1); 529 + return do_sas_phy_reset(dev, count, 1); 537 530 } 538 - static CLASS_DEVICE_ATTR(hard_reset, S_IWUSR, NULL, store_sas_hard_reset); 531 + static DEVICE_ATTR(hard_reset, S_IWUSR, NULL, store_sas_hard_reset); 539 532 540 533 sas_phy_protocol_attr(identify.initiator_port_protocols, 541 534 initiator_port_protocols); ··· 706 695 */ 707 696 #define sas_port_show_simple(field, name, format_string, cast) \ 708 697 static ssize_t \ 709 - show_sas_port_##name(struct class_device *cdev, char *buf) \ 698 + show_sas_port_##name(struct device *dev, \ 699 + struct device_attribute *attr, char *buf) \ 710 700 { \ 711 - struct sas_port *port = transport_class_to_sas_port(cdev); \ 701 + struct sas_port *port = transport_class_to_sas_port(dev); \ 712 702 \ 713 703 return snprintf(buf, 20, format_string, cast port->field); \ 714 704 } 715 705 716 706 #define sas_port_simple_attr(field, name, format_string, type) \ 717 707 sas_port_show_simple(field, name, format_string, (type)) \ 718 - static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_port_##name, NULL) 708 + static DEVICE_ATTR(name, S_IRUGO, show_sas_port_##name, NULL) 719 709 720 710 sas_port_simple_attr(num_phys, num_phys, "%d\n", int); 721 711 ··· 1029 1017 1030 1018 #define sas_rphy_show_simple(field, name, format_string, cast) \ 1031 1019 static ssize_t \ 1032 - show_sas_rphy_##name(struct class_device *cdev, char *buf) \ 1020 + show_sas_rphy_##name(struct device *dev, \ 1021 + struct device_attribute *attr, char *buf) \ 1033 1022 { \ 1034 - struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ 1023 + struct sas_rphy *rphy = transport_class_to_rphy(dev); \ 1035 1024 \ 1036 1025 return snprintf(buf, 20, format_string, cast rphy->field); \ 1037 1026 } 1038 1027 1039 1028 #define sas_rphy_simple_attr(field, name, format_string, type) \ 1040 1029 sas_rphy_show_simple(field, name, format_string, (type)) \ 1041 - static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \ 1030 + static SAS_DEVICE_ATTR(rphy, name, S_IRUGO, \ 1042 1031 show_sas_rphy_##name, NULL) 1043 1032 1044 1033 #define sas_rphy_show_protocol(field, name) \ 1045 1034 static ssize_t \ 1046 - show_sas_rphy_##name(struct class_device *cdev, char *buf) \ 1035 + show_sas_rphy_##name(struct device *dev, \ 1036 + struct device_attribute *attr, char *buf) \ 1047 1037 { \ 1048 - struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ 1038 + struct sas_rphy *rphy = transport_class_to_rphy(dev); \ 1049 1039 \ 1050 1040 if (!rphy->field) \ 1051 1041 return snprintf(buf, 20, "none\n"); \ ··· 1056 1042 1057 1043 #define sas_rphy_protocol_attr(field, name) \ 1058 1044 sas_rphy_show_protocol(field, name) \ 1059 - static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \ 1045 + static SAS_DEVICE_ATTR(rphy, name, S_IRUGO, \ 1060 1046 show_sas_rphy_##name, NULL) 1061 1047 1062 1048 static ssize_t 1063 - show_sas_rphy_device_type(struct class_device *cdev, char *buf) 1049 + show_sas_rphy_device_type(struct device *dev, 1050 + struct device_attribute *attr, char *buf) 1064 1051 { 1065 - struct sas_rphy *rphy = transport_class_to_rphy(cdev); 1052 + struct sas_rphy *rphy = transport_class_to_rphy(dev); 1066 1053 1067 1054 if (!rphy->identify.device_type) 1068 1055 return snprintf(buf, 20, "none\n"); ··· 1071 1056 rphy->identify.device_type, buf); 1072 1057 } 1073 1058 1074 - static SAS_CLASS_DEVICE_ATTR(rphy, device_type, S_IRUGO, 1059 + static SAS_DEVICE_ATTR(rphy, device_type, S_IRUGO, 1075 1060 show_sas_rphy_device_type, NULL); 1076 1061 1077 1062 static ssize_t 1078 - show_sas_rphy_enclosure_identifier(struct class_device *cdev, char *buf) 1063 + show_sas_rphy_enclosure_identifier(struct device *dev, 1064 + struct device_attribute *attr, char *buf) 1079 1065 { 1080 - struct sas_rphy *rphy = transport_class_to_rphy(cdev); 1066 + struct sas_rphy *rphy = transport_class_to_rphy(dev); 1081 1067 struct sas_phy *phy = dev_to_phy(rphy->dev.parent); 1082 1068 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); 1083 1069 struct sas_internal *i = to_sas_internal(shost->transportt); ··· 1098 1082 return sprintf(buf, "0x%llx\n", (unsigned long long)identifier); 1099 1083 } 1100 1084 1101 - static SAS_CLASS_DEVICE_ATTR(rphy, enclosure_identifier, S_IRUGO, 1085 + static SAS_DEVICE_ATTR(rphy, enclosure_identifier, S_IRUGO, 1102 1086 show_sas_rphy_enclosure_identifier, NULL); 1103 1087 1104 1088 static ssize_t 1105 - show_sas_rphy_bay_identifier(struct class_device *cdev, char *buf) 1089 + show_sas_rphy_bay_identifier(struct device *dev, 1090 + struct device_attribute *attr, char *buf) 1106 1091 { 1107 - struct sas_rphy *rphy = transport_class_to_rphy(cdev); 1092 + struct sas_rphy *rphy = transport_class_to_rphy(dev); 1108 1093 struct sas_phy *phy = dev_to_phy(rphy->dev.parent); 1109 1094 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); 1110 1095 struct sas_internal *i = to_sas_internal(shost->transportt); ··· 1120 1103 return sprintf(buf, "%d\n", val); 1121 1104 } 1122 1105 1123 - static SAS_CLASS_DEVICE_ATTR(rphy, bay_identifier, S_IRUGO, 1106 + static SAS_DEVICE_ATTR(rphy, bay_identifier, S_IRUGO, 1124 1107 show_sas_rphy_bay_identifier, NULL); 1125 1108 1126 1109 sas_rphy_protocol_attr(identify.initiator_port_protocols, ··· 1178 1161 1179 1162 #define sas_end_dev_show_simple(field, name, format_string, cast) \ 1180 1163 static ssize_t \ 1181 - show_sas_end_dev_##name(struct class_device *cdev, char *buf) \ 1164 + show_sas_end_dev_##name(struct device *dev, \ 1165 + struct device_attribute *attr, char *buf) \ 1182 1166 { \ 1183 - struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ 1167 + struct sas_rphy *rphy = transport_class_to_rphy(dev); \ 1184 1168 struct sas_end_device *rdev = rphy_to_end_device(rphy); \ 1185 1169 \ 1186 1170 return snprintf(buf, 20, format_string, cast rdev->field); \ ··· 1189 1171 1190 1172 #define sas_end_dev_simple_attr(field, name, format_string, type) \ 1191 1173 sas_end_dev_show_simple(field, name, format_string, (type)) \ 1192 - static SAS_CLASS_DEVICE_ATTR(end_dev, name, S_IRUGO, \ 1174 + static SAS_DEVICE_ATTR(end_dev, name, S_IRUGO, \ 1193 1175 show_sas_end_dev_##name, NULL) 1194 1176 1195 1177 sas_end_dev_simple_attr(ready_led_meaning, ready_led_meaning, "%d\n", int); ··· 1203 1185 1204 1186 #define sas_expander_show_simple(field, name, format_string, cast) \ 1205 1187 static ssize_t \ 1206 - show_sas_expander_##name(struct class_device *cdev, char *buf) \ 1188 + show_sas_expander_##name(struct device *dev, \ 1189 + struct device_attribute *attr, char *buf) \ 1207 1190 { \ 1208 - struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ 1191 + struct sas_rphy *rphy = transport_class_to_rphy(dev); \ 1209 1192 struct sas_expander_device *edev = rphy_to_expander_device(rphy); \ 1210 1193 \ 1211 1194 return snprintf(buf, 20, format_string, cast edev->field); \ ··· 1214 1195 1215 1196 #define sas_expander_simple_attr(field, name, format_string, type) \ 1216 1197 sas_expander_show_simple(field, name, format_string, (type)) \ 1217 - static SAS_CLASS_DEVICE_ATTR(expander, name, S_IRUGO, \ 1198 + static SAS_DEVICE_ATTR(expander, name, S_IRUGO, \ 1218 1199 show_sas_expander_##name, NULL) 1219 1200 1220 1201 sas_expander_simple_attr(vendor_id, vendor_id, "%s\n", char *); ··· 1573 1554 */ 1574 1555 1575 1556 #define SETUP_TEMPLATE(attrb, field, perm, test) \ 1576 - i->private_##attrb[count] = class_device_attr_##field; \ 1557 + i->private_##attrb[count] = dev_attr_##field; \ 1577 1558 i->private_##attrb[count].attr.mode = perm; \ 1578 1559 i->attrb[count] = &i->private_##attrb[count]; \ 1579 1560 if (test) \ 1580 1561 count++ 1581 1562 1582 1563 #define SETUP_TEMPLATE_RW(attrb, field, perm, test, ro_test, ro_perm) \ 1583 - i->private_##attrb[count] = class_device_attr_##field; \ 1564 + i->private_##attrb[count] = dev_attr_##field; \ 1584 1565 i->private_##attrb[count].attr.mode = perm; \ 1585 1566 if (ro_test) { \ 1586 1567 i->private_##attrb[count].attr.mode = ro_perm; \
+98 -87
drivers/scsi/scsi_transport_spi.c
··· 158 158 } 159 159 160 160 static int spi_host_setup(struct transport_container *tc, struct device *dev, 161 - struct class_device *cdev) 161 + struct device *cdev) 162 162 { 163 163 struct Scsi_Host *shost = dev_to_shost(dev); 164 164 ··· 169 169 170 170 static int spi_host_configure(struct transport_container *tc, 171 171 struct device *dev, 172 - struct class_device *cdev); 172 + struct device *cdev); 173 173 174 174 static DECLARE_TRANSPORT_CLASS(spi_host_class, 175 175 "spi_host", ··· 195 195 196 196 static int spi_target_configure(struct transport_container *tc, 197 197 struct device *dev, 198 - struct class_device *cdev); 198 + struct device *cdev); 199 199 200 200 static int spi_device_configure(struct transport_container *tc, 201 201 struct device *dev, 202 - struct class_device *cdev) 202 + struct device *cdev) 203 203 { 204 204 struct scsi_device *sdev = to_scsi_device(dev); 205 205 struct scsi_target *starget = sdev->sdev_target; ··· 219 219 220 220 static int spi_setup_transport_attrs(struct transport_container *tc, 221 221 struct device *dev, 222 - struct class_device *cdev) 222 + struct device *cdev) 223 223 { 224 224 struct scsi_target *starget = to_scsi_target(dev); 225 225 ··· 248 248 #define spi_transport_show_simple(field, format_string) \ 249 249 \ 250 250 static ssize_t \ 251 - show_spi_transport_##field(struct class_device *cdev, char *buf) \ 251 + show_spi_transport_##field(struct device *dev, \ 252 + struct device_attribute *attr, char *buf) \ 252 253 { \ 253 - struct scsi_target *starget = transport_class_to_starget(cdev); \ 254 + struct scsi_target *starget = transport_class_to_starget(dev); \ 254 255 struct spi_transport_attrs *tp; \ 255 256 \ 256 257 tp = (struct spi_transport_attrs *)&starget->starget_data; \ ··· 261 260 #define spi_transport_store_simple(field, format_string) \ 262 261 \ 263 262 static ssize_t \ 264 - store_spi_transport_##field(struct class_device *cdev, const char *buf, \ 265 - size_t count) \ 263 + store_spi_transport_##field(struct device *dev, \ 264 + struct device_attribute *attr, \ 265 + const char *buf, size_t count) \ 266 266 { \ 267 267 int val; \ 268 - struct scsi_target *starget = transport_class_to_starget(cdev); \ 268 + struct scsi_target *starget = transport_class_to_starget(dev); \ 269 269 struct spi_transport_attrs *tp; \ 270 270 \ 271 271 tp = (struct spi_transport_attrs *)&starget->starget_data; \ ··· 278 276 #define spi_transport_show_function(field, format_string) \ 279 277 \ 280 278 static ssize_t \ 281 - show_spi_transport_##field(struct class_device *cdev, char *buf) \ 279 + show_spi_transport_##field(struct device *dev, \ 280 + struct device_attribute *attr, char *buf) \ 282 281 { \ 283 - struct scsi_target *starget = transport_class_to_starget(cdev); \ 282 + struct scsi_target *starget = transport_class_to_starget(dev); \ 284 283 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ 285 284 struct spi_transport_attrs *tp; \ 286 285 struct spi_internal *i = to_spi_internal(shost->transportt); \ ··· 293 290 294 291 #define spi_transport_store_function(field, format_string) \ 295 292 static ssize_t \ 296 - store_spi_transport_##field(struct class_device *cdev, const char *buf, \ 297 - size_t count) \ 293 + store_spi_transport_##field(struct device *dev, \ 294 + struct device_attribute *attr, \ 295 + const char *buf, size_t count) \ 298 296 { \ 299 297 int val; \ 300 - struct scsi_target *starget = transport_class_to_starget(cdev); \ 298 + struct scsi_target *starget = transport_class_to_starget(dev); \ 301 299 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ 302 300 struct spi_internal *i = to_spi_internal(shost->transportt); \ 303 301 \ ··· 311 307 312 308 #define spi_transport_store_max(field, format_string) \ 313 309 static ssize_t \ 314 - store_spi_transport_##field(struct class_device *cdev, const char *buf, \ 315 - size_t count) \ 310 + store_spi_transport_##field(struct device *dev, \ 311 + struct device_attribute *attr, \ 312 + const char *buf, size_t count) \ 316 313 { \ 317 314 int val; \ 318 - struct scsi_target *starget = transport_class_to_starget(cdev); \ 315 + struct scsi_target *starget = transport_class_to_starget(dev); \ 319 316 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ 320 317 struct spi_internal *i = to_spi_internal(shost->transportt); \ 321 318 struct spi_transport_attrs *tp \ ··· 334 329 #define spi_transport_rd_attr(field, format_string) \ 335 330 spi_transport_show_function(field, format_string) \ 336 331 spi_transport_store_function(field, format_string) \ 337 - static CLASS_DEVICE_ATTR(field, S_IRUGO, \ 338 - show_spi_transport_##field, \ 339 - store_spi_transport_##field); 332 + static DEVICE_ATTR(field, S_IRUGO, \ 333 + show_spi_transport_##field, \ 334 + store_spi_transport_##field); 340 335 341 336 #define spi_transport_simple_attr(field, format_string) \ 342 337 spi_transport_show_simple(field, format_string) \ 343 338 spi_transport_store_simple(field, format_string) \ 344 - static CLASS_DEVICE_ATTR(field, S_IRUGO, \ 345 - show_spi_transport_##field, \ 346 - store_spi_transport_##field); 339 + static DEVICE_ATTR(field, S_IRUGO, \ 340 + show_spi_transport_##field, \ 341 + store_spi_transport_##field); 347 342 348 343 #define spi_transport_max_attr(field, format_string) \ 349 344 spi_transport_show_function(field, format_string) \ 350 345 spi_transport_store_max(field, format_string) \ 351 346 spi_transport_simple_attr(max_##field, format_string) \ 352 - static CLASS_DEVICE_ATTR(field, S_IRUGO, \ 353 - show_spi_transport_##field, \ 354 - store_spi_transport_##field); 347 + static DEVICE_ATTR(field, S_IRUGO, \ 348 + show_spi_transport_##field, \ 349 + store_spi_transport_##field); 355 350 356 351 /* The Parallel SCSI Tranport Attributes: */ 357 352 spi_transport_max_attr(offset, "%d\n"); ··· 375 370 } 376 371 377 372 static ssize_t 378 - store_spi_revalidate(struct class_device *cdev, const char *buf, size_t count) 373 + store_spi_revalidate(struct device *dev, struct device_attribute *attr, 374 + const char *buf, size_t count) 379 375 { 380 - struct scsi_target *starget = transport_class_to_starget(cdev); 376 + struct scsi_target *starget = transport_class_to_starget(dev); 381 377 382 378 device_for_each_child(&starget->dev, NULL, child_iter); 383 379 return count; 384 380 } 385 - static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate); 381 + static DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate); 386 382 387 383 /* Translate the period into ns according to the current spec 388 384 * for SDTR/PPR messages */ ··· 418 412 } 419 413 420 414 static ssize_t 421 - store_spi_transport_period_helper(struct class_device *cdev, const char *buf, 415 + store_spi_transport_period_helper(struct device *dev, const char *buf, 422 416 size_t count, int *periodp) 423 417 { 424 418 int j, picosec, period = -1; ··· 455 449 } 456 450 457 451 static ssize_t 458 - show_spi_transport_period(struct class_device *cdev, char *buf) 452 + show_spi_transport_period(struct device *dev, 453 + struct device_attribute *attr, char *buf) 459 454 { 460 - struct scsi_target *starget = transport_class_to_starget(cdev); 455 + struct scsi_target *starget = transport_class_to_starget(dev); 461 456 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 462 457 struct spi_internal *i = to_spi_internal(shost->transportt); 463 458 struct spi_transport_attrs *tp = ··· 471 464 } 472 465 473 466 static ssize_t 474 - store_spi_transport_period(struct class_device *cdev, const char *buf, 475 - size_t count) 467 + store_spi_transport_period(struct device *cdev, struct device_attribute *attr, 468 + const char *buf, size_t count) 476 469 { 477 470 struct scsi_target *starget = transport_class_to_starget(cdev); 478 471 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); ··· 494 487 return retval; 495 488 } 496 489 497 - static CLASS_DEVICE_ATTR(period, S_IRUGO, 498 - show_spi_transport_period, 499 - store_spi_transport_period); 490 + static DEVICE_ATTR(period, S_IRUGO, 491 + show_spi_transport_period, 492 + store_spi_transport_period); 500 493 501 494 static ssize_t 502 - show_spi_transport_min_period(struct class_device *cdev, char *buf) 495 + show_spi_transport_min_period(struct device *cdev, 496 + struct device_attribute *attr, char *buf) 503 497 { 504 498 struct scsi_target *starget = transport_class_to_starget(cdev); 505 499 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); ··· 515 507 } 516 508 517 509 static ssize_t 518 - store_spi_transport_min_period(struct class_device *cdev, const char *buf, 519 - size_t count) 510 + store_spi_transport_min_period(struct device *cdev, 511 + struct device_attribute *attr, 512 + const char *buf, size_t count) 520 513 { 521 514 struct scsi_target *starget = transport_class_to_starget(cdev); 522 515 struct spi_transport_attrs *tp = ··· 528 519 } 529 520 530 521 531 - static CLASS_DEVICE_ATTR(min_period, S_IRUGO, 532 - show_spi_transport_min_period, 533 - store_spi_transport_min_period); 522 + static DEVICE_ATTR(min_period, S_IRUGO, 523 + show_spi_transport_min_period, 524 + store_spi_transport_min_period); 534 525 535 526 536 - static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf) 527 + static ssize_t show_spi_host_signalling(struct device *cdev, 528 + struct device_attribute *attr, 529 + char *buf) 537 530 { 538 531 struct Scsi_Host *shost = transport_class_to_shost(cdev); 539 532 struct spi_internal *i = to_spi_internal(shost->transportt); ··· 545 534 546 535 return sprintf(buf, "%s\n", spi_signal_to_string(spi_signalling(shost))); 547 536 } 548 - static ssize_t store_spi_host_signalling(struct class_device *cdev, 537 + static ssize_t store_spi_host_signalling(struct device *dev, 538 + struct device_attribute *attr, 549 539 const char *buf, size_t count) 550 540 { 551 - struct Scsi_Host *shost = transport_class_to_shost(cdev); 541 + struct Scsi_Host *shost = transport_class_to_shost(dev); 552 542 struct spi_internal *i = to_spi_internal(shost->transportt); 553 543 enum spi_signal_type type = spi_signal_to_value(buf); 554 544 ··· 561 549 562 550 return count; 563 551 } 564 - static CLASS_DEVICE_ATTR(signalling, S_IRUGO, 565 - show_spi_host_signalling, 566 - store_spi_host_signalling); 552 + static DEVICE_ATTR(signalling, S_IRUGO, 553 + show_spi_host_signalling, 554 + store_spi_host_signalling); 567 555 568 556 #define DV_SET(x, y) \ 569 557 if(i->f->set_##x) \ ··· 1346 1334 spi_device_configure); 1347 1335 1348 1336 static struct attribute *host_attributes[] = { 1349 - &class_device_attr_signalling.attr, 1337 + &dev_attr_signalling.attr, 1350 1338 NULL 1351 1339 }; 1352 1340 ··· 1356 1344 1357 1345 static int spi_host_configure(struct transport_container *tc, 1358 1346 struct device *dev, 1359 - struct class_device *cdev) 1347 + struct device *cdev) 1360 1348 { 1361 1349 struct kobject *kobj = &cdev->kobj; 1362 1350 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1363 1351 struct spi_internal *si = to_spi_internal(shost->transportt); 1364 - struct attribute *attr = &class_device_attr_signalling.attr; 1352 + struct attribute *attr = &dev_attr_signalling.attr; 1365 1353 int rc = 0; 1366 1354 1367 1355 if (si->f->set_signalling) ··· 1380 1368 static int target_attribute_is_visible(struct kobject *kobj, 1381 1369 struct attribute *attr, int i) 1382 1370 { 1383 - struct class_device *cdev = 1384 - container_of(kobj, struct class_device, kobj); 1371 + struct device *cdev = container_of(kobj, struct device, kobj); 1385 1372 struct scsi_target *starget = transport_class_to_starget(cdev); 1386 1373 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1387 1374 struct spi_internal *si = to_spi_internal(shost->transportt); 1388 1375 1389 - if (attr == &class_device_attr_period.attr && 1376 + if (attr == &dev_attr_period.attr && 1390 1377 spi_support_sync(starget)) 1391 1378 return TARGET_ATTRIBUTE_HELPER(period); 1392 - else if (attr == &class_device_attr_min_period.attr && 1379 + else if (attr == &dev_attr_min_period.attr && 1393 1380 spi_support_sync(starget)) 1394 1381 return TARGET_ATTRIBUTE_HELPER(period); 1395 - else if (attr == &class_device_attr_offset.attr && 1382 + else if (attr == &dev_attr_offset.attr && 1396 1383 spi_support_sync(starget)) 1397 1384 return TARGET_ATTRIBUTE_HELPER(offset); 1398 - else if (attr == &class_device_attr_max_offset.attr && 1385 + else if (attr == &dev_attr_max_offset.attr && 1399 1386 spi_support_sync(starget)) 1400 1387 return TARGET_ATTRIBUTE_HELPER(offset); 1401 - else if (attr == &class_device_attr_width.attr && 1388 + else if (attr == &dev_attr_width.attr && 1402 1389 spi_support_wide(starget)) 1403 1390 return TARGET_ATTRIBUTE_HELPER(width); 1404 - else if (attr == &class_device_attr_max_width.attr && 1391 + else if (attr == &dev_attr_max_width.attr && 1405 1392 spi_support_wide(starget)) 1406 1393 return TARGET_ATTRIBUTE_HELPER(width); 1407 - else if (attr == &class_device_attr_iu.attr && 1394 + else if (attr == &dev_attr_iu.attr && 1408 1395 spi_support_ius(starget)) 1409 1396 return TARGET_ATTRIBUTE_HELPER(iu); 1410 - else if (attr == &class_device_attr_dt.attr && 1397 + else if (attr == &dev_attr_dt.attr && 1411 1398 spi_support_dt(starget)) 1412 1399 return TARGET_ATTRIBUTE_HELPER(dt); 1413 - else if (attr == &class_device_attr_qas.attr && 1400 + else if (attr == &dev_attr_qas.attr && 1414 1401 spi_support_qas(starget)) 1415 1402 return TARGET_ATTRIBUTE_HELPER(qas); 1416 - else if (attr == &class_device_attr_wr_flow.attr && 1403 + else if (attr == &dev_attr_wr_flow.attr && 1417 1404 spi_support_ius(starget)) 1418 1405 return TARGET_ATTRIBUTE_HELPER(wr_flow); 1419 - else if (attr == &class_device_attr_rd_strm.attr && 1406 + else if (attr == &dev_attr_rd_strm.attr && 1420 1407 spi_support_ius(starget)) 1421 1408 return TARGET_ATTRIBUTE_HELPER(rd_strm); 1422 - else if (attr == &class_device_attr_rti.attr && 1409 + else if (attr == &dev_attr_rti.attr && 1423 1410 spi_support_ius(starget)) 1424 1411 return TARGET_ATTRIBUTE_HELPER(rti); 1425 - else if (attr == &class_device_attr_pcomp_en.attr && 1412 + else if (attr == &dev_attr_pcomp_en.attr && 1426 1413 spi_support_ius(starget)) 1427 1414 return TARGET_ATTRIBUTE_HELPER(pcomp_en); 1428 - else if (attr == &class_device_attr_hold_mcs.attr && 1415 + else if (attr == &dev_attr_hold_mcs.attr && 1429 1416 spi_support_ius(starget)) 1430 1417 return TARGET_ATTRIBUTE_HELPER(hold_mcs); 1431 - else if (attr == &class_device_attr_revalidate.attr) 1418 + else if (attr == &dev_attr_revalidate.attr) 1432 1419 return 1; 1433 1420 1434 1421 return 0; 1435 1422 } 1436 1423 1437 1424 static struct attribute *target_attributes[] = { 1438 - &class_device_attr_period.attr, 1439 - &class_device_attr_min_period.attr, 1440 - &class_device_attr_offset.attr, 1441 - &class_device_attr_max_offset.attr, 1442 - &class_device_attr_width.attr, 1443 - &class_device_attr_max_width.attr, 1444 - &class_device_attr_iu.attr, 1445 - &class_device_attr_dt.attr, 1446 - &class_device_attr_qas.attr, 1447 - &class_device_attr_wr_flow.attr, 1448 - &class_device_attr_rd_strm.attr, 1449 - &class_device_attr_rti.attr, 1450 - &class_device_attr_pcomp_en.attr, 1451 - &class_device_attr_hold_mcs.attr, 1452 - &class_device_attr_revalidate.attr, 1425 + &dev_attr_period.attr, 1426 + &dev_attr_min_period.attr, 1427 + &dev_attr_offset.attr, 1428 + &dev_attr_max_offset.attr, 1429 + &dev_attr_width.attr, 1430 + &dev_attr_max_width.attr, 1431 + &dev_attr_iu.attr, 1432 + &dev_attr_dt.attr, 1433 + &dev_attr_qas.attr, 1434 + &dev_attr_wr_flow.attr, 1435 + &dev_attr_rd_strm.attr, 1436 + &dev_attr_rti.attr, 1437 + &dev_attr_pcomp_en.attr, 1438 + &dev_attr_hold_mcs.attr, 1439 + &dev_attr_revalidate.attr, 1453 1440 NULL 1454 1441 }; 1455 1442 ··· 1459 1448 1460 1449 static int spi_target_configure(struct transport_container *tc, 1461 1450 struct device *dev, 1462 - struct class_device *cdev) 1451 + struct device *cdev) 1463 1452 { 1464 1453 struct kobject *kobj = &cdev->kobj; 1465 1454 int i; ··· 1473 1462 * to ignore, sysfs also does a WARN_ON and dumps a trace, 1474 1463 * which is bad, so temporarily, skip attributes that are 1475 1464 * already visible (the revalidate one) */ 1476 - if (j && attr != &class_device_attr_revalidate.attr) 1465 + if (j && attr != &dev_attr_revalidate.attr) 1477 1466 rc = sysfs_add_file_to_group(kobj, attr, 1478 1467 target_attribute_group.name); 1479 1468 /* and make the attribute writeable if we have a set
+14 -12
drivers/scsi/scsi_transport_srp.c
··· 44 44 struct scsi_transport_template t; 45 45 struct srp_function_template *f; 46 46 47 - struct class_device_attribute *host_attrs[SRP_HOST_ATTRS + 1]; 47 + struct device_attribute *host_attrs[SRP_HOST_ATTRS + 1]; 48 48 49 - struct class_device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1]; 50 - struct class_device_attribute private_rport_attrs[SRP_RPORT_ATTRS]; 49 + struct device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1]; 50 + struct device_attribute private_rport_attrs[SRP_RPORT_ATTRS]; 51 51 struct transport_container rport_attr_cont; 52 52 }; 53 53 54 54 #define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t) 55 55 56 56 #define dev_to_rport(d) container_of(d, struct srp_rport, dev) 57 - #define transport_class_to_srp_rport(cdev) dev_to_rport((cdev)->dev) 57 + #define transport_class_to_srp_rport(dev) dev_to_rport((dev)->parent) 58 58 59 59 static int srp_host_setup(struct transport_container *tc, struct device *dev, 60 - struct class_device *cdev) 60 + struct device *cdev) 61 61 { 62 62 struct Scsi_Host *shost = dev_to_shost(dev); 63 63 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost); ··· 73 73 NULL, NULL, NULL); 74 74 75 75 #define SETUP_TEMPLATE(attrb, field, perm, test, ro_test, ro_perm) \ 76 - i->private_##attrb[count] = class_device_attr_##field; \ 76 + i->private_##attrb[count] = dev_attr_##field; \ 77 77 i->private_##attrb[count].attr.mode = perm; \ 78 78 if (ro_test) { \ 79 79 i->private_##attrb[count].attr.mode = ro_perm; \ ··· 100 100 "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" 101 101 102 102 static ssize_t 103 - show_srp_rport_id(struct class_device *cdev, char *buf) 103 + show_srp_rport_id(struct device *dev, struct device_attribute *attr, 104 + char *buf) 104 105 { 105 - struct srp_rport *rport = transport_class_to_srp_rport(cdev); 106 + struct srp_rport *rport = transport_class_to_srp_rport(dev); 106 107 return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport)); 107 108 } 108 109 109 - static CLASS_DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL); 110 + static DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL); 110 111 111 112 static const struct { 112 113 u32 value; ··· 118 117 }; 119 118 120 119 static ssize_t 121 - show_srp_rport_roles(struct class_device *cdev, char *buf) 120 + show_srp_rport_roles(struct device *dev, struct device_attribute *attr, 121 + char *buf) 122 122 { 123 - struct srp_rport *rport = transport_class_to_srp_rport(cdev); 123 + struct srp_rport *rport = transport_class_to_srp_rport(dev); 124 124 int i; 125 125 char *name = NULL; 126 126 ··· 133 131 return sprintf(buf, "%s\n", name ? : "unknown"); 134 132 } 135 133 136 - static CLASS_DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL); 134 + static DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL); 137 135 138 136 static void srp_rport_release(struct device *dev) 139 137 {
+44 -34
drivers/scsi/sd.c
··· 95 95 static void sd_rescan(struct device *); 96 96 static int sd_done(struct scsi_cmnd *); 97 97 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); 98 - static void scsi_disk_release(struct class_device *cdev); 98 + static void scsi_disk_release(struct device *cdev); 99 99 static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); 100 100 static void sd_print_result(struct scsi_disk *, int); 101 101 ··· 112 112 "write back, no read (daft)" 113 113 }; 114 114 115 - static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf, 116 - size_t count) 115 + static ssize_t 116 + sd_store_cache_type(struct device *dev, struct device_attribute *attr, 117 + const char *buf, size_t count) 117 118 { 118 119 int i, ct = -1, rcd, wce, sp; 119 - struct scsi_disk *sdkp = to_scsi_disk(cdev); 120 + struct scsi_disk *sdkp = to_scsi_disk(dev); 120 121 struct scsi_device *sdp = sdkp->device; 121 122 char buffer[64]; 122 123 char *buffer_data; ··· 164 163 return count; 165 164 } 166 165 167 - static ssize_t sd_store_manage_start_stop(struct class_device *cdev, 168 - const char *buf, size_t count) 166 + static ssize_t 167 + sd_store_manage_start_stop(struct device *dev, struct device_attribute *attr, 168 + const char *buf, size_t count) 169 169 { 170 - struct scsi_disk *sdkp = to_scsi_disk(cdev); 170 + struct scsi_disk *sdkp = to_scsi_disk(dev); 171 171 struct scsi_device *sdp = sdkp->device; 172 172 173 173 if (!capable(CAP_SYS_ADMIN)) ··· 179 177 return count; 180 178 } 181 179 182 - static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf, 183 - size_t count) 180 + static ssize_t 181 + sd_store_allow_restart(struct device *dev, struct device_attribute *attr, 182 + const char *buf, size_t count) 184 183 { 185 - struct scsi_disk *sdkp = to_scsi_disk(cdev); 184 + struct scsi_disk *sdkp = to_scsi_disk(dev); 186 185 struct scsi_device *sdp = sdkp->device; 187 186 188 187 if (!capable(CAP_SYS_ADMIN)) ··· 197 194 return count; 198 195 } 199 196 200 - static ssize_t sd_show_cache_type(struct class_device *cdev, char *buf) 197 + static ssize_t 198 + sd_show_cache_type(struct device *dev, struct device_attribute *attr, 199 + char *buf) 201 200 { 202 - struct scsi_disk *sdkp = to_scsi_disk(cdev); 201 + struct scsi_disk *sdkp = to_scsi_disk(dev); 203 202 int ct = sdkp->RCD + 2*sdkp->WCE; 204 203 205 204 return snprintf(buf, 40, "%s\n", sd_cache_types[ct]); 206 205 } 207 206 208 - static ssize_t sd_show_fua(struct class_device *cdev, char *buf) 207 + static ssize_t 208 + sd_show_fua(struct device *dev, struct device_attribute *attr, char *buf) 209 209 { 210 - struct scsi_disk *sdkp = to_scsi_disk(cdev); 210 + struct scsi_disk *sdkp = to_scsi_disk(dev); 211 211 212 212 return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); 213 213 } 214 214 215 - static ssize_t sd_show_manage_start_stop(struct class_device *cdev, char *buf) 215 + static ssize_t 216 + sd_show_manage_start_stop(struct device *dev, struct device_attribute *attr, 217 + char *buf) 216 218 { 217 - struct scsi_disk *sdkp = to_scsi_disk(cdev); 219 + struct scsi_disk *sdkp = to_scsi_disk(dev); 218 220 struct scsi_device *sdp = sdkp->device; 219 221 220 222 return snprintf(buf, 20, "%u\n", sdp->manage_start_stop); 221 223 } 222 224 223 - static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf) 225 + static ssize_t 226 + sd_show_allow_restart(struct device *dev, struct device_attribute *attr, 227 + char *buf) 224 228 { 225 - struct scsi_disk *sdkp = to_scsi_disk(cdev); 229 + struct scsi_disk *sdkp = to_scsi_disk(dev); 226 230 227 231 return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart); 228 232 } 229 233 230 - static struct class_device_attribute sd_disk_attrs[] = { 234 + static struct device_attribute sd_disk_attrs[] = { 231 235 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, 232 236 sd_store_cache_type), 233 237 __ATTR(FUA, S_IRUGO, sd_show_fua, NULL), ··· 248 238 static struct class sd_disk_class = { 249 239 .name = "scsi_disk", 250 240 .owner = THIS_MODULE, 251 - .release = scsi_disk_release, 252 - .class_dev_attrs = sd_disk_attrs, 241 + .dev_release = scsi_disk_release, 242 + .dev_attrs = sd_disk_attrs, 253 243 }; 254 244 255 245 static struct scsi_driver sd_template = { ··· 307 297 if (disk->private_data) { 308 298 sdkp = scsi_disk(disk); 309 299 if (scsi_device_get(sdkp->device) == 0) 310 - class_device_get(&sdkp->cdev); 300 + get_device(&sdkp->dev); 311 301 else 312 302 sdkp = NULL; 313 303 } ··· 341 331 struct scsi_device *sdev = sdkp->device; 342 332 343 333 mutex_lock(&sd_ref_mutex); 344 - class_device_put(&sdkp->cdev); 334 + put_device(&sdkp->dev); 345 335 scsi_device_put(sdev); 346 336 mutex_unlock(&sd_ref_mutex); 347 337 } ··· 1673 1663 sdp->timeout = SD_MOD_TIMEOUT; 1674 1664 } 1675 1665 1676 - class_device_initialize(&sdkp->cdev); 1677 - sdkp->cdev.dev = &sdp->sdev_gendev; 1678 - sdkp->cdev.class = &sd_disk_class; 1679 - strncpy(sdkp->cdev.class_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE); 1666 + device_initialize(&sdkp->dev); 1667 + sdkp->dev.parent = &sdp->sdev_gendev; 1668 + sdkp->dev.class = &sd_disk_class; 1669 + strncpy(sdkp->dev.bus_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE); 1680 1670 1681 - if (class_device_add(&sdkp->cdev)) 1671 + if (device_add(&sdkp->dev)) 1682 1672 goto out_put; 1683 1673 1684 1674 get_device(&sdp->sdev_gendev); ··· 1744 1734 { 1745 1735 struct scsi_disk *sdkp = dev_get_drvdata(dev); 1746 1736 1747 - class_device_del(&sdkp->cdev); 1737 + device_del(&sdkp->dev); 1748 1738 del_gendisk(sdkp->disk); 1749 1739 sd_shutdown(dev); 1750 1740 1751 1741 mutex_lock(&sd_ref_mutex); 1752 1742 dev_set_drvdata(dev, NULL); 1753 - class_device_put(&sdkp->cdev); 1743 + put_device(&sdkp->dev); 1754 1744 mutex_unlock(&sd_ref_mutex); 1755 1745 1756 1746 return 0; ··· 1758 1748 1759 1749 /** 1760 1750 * scsi_disk_release - Called to free the scsi_disk structure 1761 - * @cdev: pointer to embedded class device 1751 + * @dev: pointer to embedded class device 1762 1752 * 1763 1753 * sd_ref_mutex must be held entering this routine. Because it is 1764 1754 * called on last put, you should always use the scsi_disk_get() 1765 1755 * scsi_disk_put() helpers which manipulate the semaphore directly 1766 - * and never do a direct class_device_put(). 1756 + * and never do a direct put_device. 1767 1757 **/ 1768 - static void scsi_disk_release(struct class_device *cdev) 1758 + static void scsi_disk_release(struct device *dev) 1769 1759 { 1770 - struct scsi_disk *sdkp = to_scsi_disk(cdev); 1760 + struct scsi_disk *sdkp = to_scsi_disk(dev); 1771 1761 struct gendisk *disk = sdkp->disk; 1772 1762 1773 1763 spin_lock(&sd_index_lock);
+14 -14
drivers/scsi/ses.c
··· 107 107 unsigned char *desc) 108 108 { 109 109 int i, j, count = 0, descriptor = ecomp->number; 110 - struct scsi_device *sdev = to_scsi_device(edev->cdev.dev); 110 + struct scsi_device *sdev = to_scsi_device(edev->edev.parent); 111 111 struct ses_device *ses_dev = edev->scratch; 112 112 unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; 113 113 unsigned char *desc_ptr = ses_dev->page2 + 8; ··· 137 137 struct enclosure_component *ecomp) 138 138 { 139 139 int i, j, count = 0, descriptor = ecomp->number; 140 - struct scsi_device *sdev = to_scsi_device(edev->cdev.dev); 140 + struct scsi_device *sdev = to_scsi_device(edev->edev.parent); 141 141 struct ses_device *ses_dev = edev->scratch; 142 142 unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; 143 143 unsigned char *desc_ptr = ses_dev->page2 + 8; ··· 269 269 struct ses_host_edev *sed = data; 270 270 struct scsi_device *sdev; 271 271 272 - if (!scsi_is_sdev_device(edev->cdev.dev)) 272 + if (!scsi_is_sdev_device(edev->edev.parent)) 273 273 return 0; 274 274 275 - sdev = to_scsi_device(edev->cdev.dev); 275 + sdev = to_scsi_device(edev->edev.parent); 276 276 277 277 if (sdev->host != sed->shost) 278 278 return 0; ··· 407 407 408 408 #define INIT_ALLOC_SIZE 32 409 409 410 - static int ses_intf_add(struct class_device *cdev, 410 + static int ses_intf_add(struct device *cdev, 411 411 struct class_interface *intf) 412 412 { 413 - struct scsi_device *sdev = to_scsi_device(cdev->dev); 413 + struct scsi_device *sdev = to_scsi_device(cdev->parent); 414 414 struct scsi_device *tmp_sdev; 415 415 unsigned char *buf = NULL, *hdr_buf, *type_ptr, *desc_ptr = NULL, 416 416 *addl_desc_ptr = NULL; ··· 426 426 edev = enclosure_find(&sdev->host->shost_gendev); 427 427 if (edev) { 428 428 ses_match_to_enclosure(edev, sdev); 429 - class_device_put(&edev->cdev); 429 + put_device(&edev->edev); 430 430 } 431 431 return -ENODEV; 432 432 } ··· 515 515 if (!scomp) 516 516 goto err_free; 517 517 518 - edev = enclosure_register(cdev->dev, sdev->sdev_gendev.bus_id, 518 + edev = enclosure_register(cdev->parent, sdev->sdev_gendev.bus_id, 519 519 components, &ses_enclosure_callbacks); 520 520 if (IS_ERR(edev)) { 521 521 err = PTR_ERR(edev); ··· 625 625 return 0; 626 626 } 627 627 628 - static void ses_intf_remove(struct class_device *cdev, 628 + static void ses_intf_remove(struct device *cdev, 629 629 struct class_interface *intf) 630 630 { 631 - struct scsi_device *sdev = to_scsi_device(cdev->dev); 631 + struct scsi_device *sdev = to_scsi_device(cdev->parent); 632 632 struct enclosure_device *edev; 633 633 struct ses_device *ses_dev; 634 634 635 635 if (!scsi_device_enclosure(sdev)) 636 636 return; 637 637 638 - edev = enclosure_find(cdev->dev); 638 + edev = enclosure_find(cdev->parent); 639 639 if (!edev) 640 640 return; 641 641 ··· 649 649 650 650 kfree(edev->component[0].scratch); 651 651 652 - class_device_put(&edev->cdev); 652 + put_device(&edev->edev); 653 653 enclosure_unregister(edev); 654 654 } 655 655 656 656 static struct class_interface ses_interface = { 657 - .add = ses_intf_add, 658 - .remove = ses_intf_remove, 657 + .add_dev = ses_intf_add, 658 + .remove_dev = ses_intf_remove, 659 659 }; 660 660 661 661 static struct scsi_driver ses_template = {
+18 -18
drivers/scsi/sg.c
··· 101 101 #define SG_SECTOR_SZ 512 102 102 #define SG_SECTOR_MSK (SG_SECTOR_SZ - 1) 103 103 104 - static int sg_add(struct class_device *, struct class_interface *); 105 - static void sg_remove(struct class_device *, struct class_interface *); 104 + static int sg_add(struct device *, struct class_interface *); 105 + static void sg_remove(struct device *, struct class_interface *); 106 106 107 107 static DEFINE_IDR(sg_index_idr); 108 108 static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock 109 109 file descriptor list for device */ 110 110 111 111 static struct class_interface sg_interface = { 112 - .add = sg_add, 113 - .remove = sg_remove, 112 + .add_dev = sg_add, 113 + .remove_dev = sg_remove, 114 114 }; 115 115 116 116 typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info */ ··· 1401 1401 } 1402 1402 1403 1403 static int 1404 - sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) 1404 + sg_add(struct device *cl_dev, struct class_interface *cl_intf) 1405 1405 { 1406 - struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); 1406 + struct scsi_device *scsidp = to_scsi_device(cl_dev->parent); 1407 1407 struct gendisk *disk; 1408 1408 Sg_device *sdp = NULL; 1409 1409 struct cdev * cdev = NULL; ··· 1439 1439 1440 1440 sdp->cdev = cdev; 1441 1441 if (sg_sysfs_valid) { 1442 - struct class_device * sg_class_member; 1442 + struct device *sg_class_member; 1443 1443 1444 - sg_class_member = class_device_create(sg_sysfs_class, NULL, 1445 - MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1446 - cl_dev->dev, "%s", 1447 - disk->disk_name); 1444 + sg_class_member = device_create(sg_sysfs_class, cl_dev->parent, 1445 + MKDEV(SCSI_GENERIC_MAJOR, 1446 + sdp->index), 1447 + "%s", disk->disk_name); 1448 1448 if (IS_ERR(sg_class_member)) { 1449 1449 printk(KERN_ERR "sg_add: " 1450 - "class_device_create failed\n"); 1450 + "device_create failed\n"); 1451 1451 error = PTR_ERR(sg_class_member); 1452 1452 goto cdev_add_err; 1453 1453 } 1454 - class_set_devdata(sg_class_member, sdp); 1454 + dev_set_drvdata(sg_class_member, sdp); 1455 1455 error = sysfs_create_link(&scsidp->sdev_gendev.kobj, 1456 1456 &sg_class_member->kobj, "generic"); 1457 1457 if (error) ··· 1464 1464 "Attached scsi generic sg%d type %d\n", sdp->index, 1465 1465 scsidp->type); 1466 1466 1467 - class_set_devdata(cl_dev, sdp); 1467 + dev_set_drvdata(cl_dev, sdp); 1468 1468 1469 1469 return 0; 1470 1470 ··· 1482 1482 } 1483 1483 1484 1484 static void 1485 - sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf) 1485 + sg_remove(struct device *cl_dev, struct class_interface *cl_intf) 1486 1486 { 1487 - struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); 1488 - Sg_device *sdp = class_get_devdata(cl_dev); 1487 + struct scsi_device *scsidp = to_scsi_device(cl_dev->parent); 1488 + Sg_device *sdp = dev_get_drvdata(cl_dev); 1489 1489 unsigned long iflags; 1490 1490 Sg_fd *sfp; 1491 1491 Sg_fd *tsfp; ··· 1528 1528 write_unlock_irqrestore(&sg_index_lock, iflags); 1529 1529 1530 1530 sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic"); 1531 - class_device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index)); 1531 + device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index)); 1532 1532 cdev_del(sdp->cdev); 1533 1533 sdp->cdev = NULL; 1534 1534 put_disk(sdp->disk);
+44 -38
drivers/scsi/st.c
··· 4108 4108 if (STm->cdevs[j]) { 4109 4109 if (cdev == STm->cdevs[j]) 4110 4110 cdev = NULL; 4111 - class_device_destroy(st_sysfs_class, 4112 - MKDEV(SCSI_TAPE_MAJOR, 4113 - TAPE_MINOR(i, mode, j))); 4111 + device_destroy(st_sysfs_class, 4112 + MKDEV(SCSI_TAPE_MAJOR, 4113 + TAPE_MINOR(i, mode, j))); 4114 4114 cdev_del(STm->cdevs[j]); 4115 4115 } 4116 4116 } ··· 4148 4148 "tape"); 4149 4149 for (mode = 0; mode < ST_NBR_MODES; ++mode) { 4150 4150 for (j=0; j < 2; j++) { 4151 - class_device_destroy(st_sysfs_class, 4152 - MKDEV(SCSI_TAPE_MAJOR, 4153 - TAPE_MINOR(i, mode, j))); 4151 + device_destroy(st_sysfs_class, 4152 + MKDEV(SCSI_TAPE_MAJOR, 4153 + TAPE_MINOR(i, mode, j))); 4154 4154 cdev_del(tpnt->modes[mode].cdevs[j]); 4155 4155 tpnt->modes[mode].cdevs[j] = NULL; 4156 4156 } ··· 4319 4319 4320 4320 4321 4321 /* The sysfs simple class interface */ 4322 - static ssize_t st_defined_show(struct class_device *class_dev, char *buf) 4322 + static ssize_t 4323 + st_defined_show(struct device *dev, struct device_attribute *attr, char *buf) 4323 4324 { 4324 - struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); 4325 + struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev); 4325 4326 ssize_t l = 0; 4326 4327 4327 4328 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->defined); 4328 4329 return l; 4329 4330 } 4330 4331 4331 - CLASS_DEVICE_ATTR(defined, S_IRUGO, st_defined_show, NULL); 4332 + DEVICE_ATTR(defined, S_IRUGO, st_defined_show, NULL); 4332 4333 4333 - static ssize_t st_defblk_show(struct class_device *class_dev, char *buf) 4334 + static ssize_t 4335 + st_defblk_show(struct device *dev, struct device_attribute *attr, char *buf) 4334 4336 { 4335 - struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); 4337 + struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev); 4336 4338 ssize_t l = 0; 4337 4339 4338 4340 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_blksize); 4339 4341 return l; 4340 4342 } 4341 4343 4342 - CLASS_DEVICE_ATTR(default_blksize, S_IRUGO, st_defblk_show, NULL); 4344 + DEVICE_ATTR(default_blksize, S_IRUGO, st_defblk_show, NULL); 4343 4345 4344 - static ssize_t st_defdensity_show(struct class_device *class_dev, char *buf) 4346 + static ssize_t 4347 + st_defdensity_show(struct device *dev, struct device_attribute *attr, char *buf) 4345 4348 { 4346 - struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); 4349 + struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev); 4347 4350 ssize_t l = 0; 4348 4351 char *fmt; 4349 4352 ··· 4355 4352 return l; 4356 4353 } 4357 4354 4358 - CLASS_DEVICE_ATTR(default_density, S_IRUGO, st_defdensity_show, NULL); 4355 + DEVICE_ATTR(default_density, S_IRUGO, st_defdensity_show, NULL); 4359 4356 4360 - static ssize_t st_defcompression_show(struct class_device *class_dev, char *buf) 4357 + static ssize_t 4358 + st_defcompression_show(struct device *dev, struct device_attribute *attr, 4359 + char *buf) 4361 4360 { 4362 - struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); 4361 + struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev); 4363 4362 ssize_t l = 0; 4364 4363 4365 4364 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_compression - 1); 4366 4365 return l; 4367 4366 } 4368 4367 4369 - CLASS_DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL); 4368 + DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL); 4370 4369 4371 - static ssize_t st_options_show(struct class_device *class_dev, char *buf) 4370 + static ssize_t 4371 + st_options_show(struct device *dev, struct device_attribute *attr, char *buf) 4372 4372 { 4373 - struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); 4373 + struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev); 4374 4374 struct scsi_tape *STp; 4375 4375 int i, j, options; 4376 4376 ssize_t l = 0; ··· 4409 4403 return l; 4410 4404 } 4411 4405 4412 - CLASS_DEVICE_ATTR(options, S_IRUGO, st_options_show, NULL); 4406 + DEVICE_ATTR(options, S_IRUGO, st_options_show, NULL); 4413 4407 4414 4408 static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) 4415 4409 { 4416 4410 int i, rew, error; 4417 4411 char name[10]; 4418 - struct class_device *st_class_member; 4412 + struct device *st_class_member; 4419 4413 4420 4414 for (rew=0; rew < 2; rew++) { 4421 4415 /* Make sure that the minor numbers corresponding to the four ··· 4424 4418 snprintf(name, 10, "%s%s%s", rew ? "n" : "", 4425 4419 STp->disk->disk_name, st_formats[i]); 4426 4420 st_class_member = 4427 - class_device_create(st_sysfs_class, NULL, 4428 - MKDEV(SCSI_TAPE_MAJOR, 4429 - TAPE_MINOR(dev_num, mode, rew)), 4430 - &STp->device->sdev_gendev, "%s", name); 4421 + device_create(st_sysfs_class, &STp->device->sdev_gendev, 4422 + MKDEV(SCSI_TAPE_MAJOR, 4423 + TAPE_MINOR(dev_num, mode, rew)), 4424 + "%s", name); 4431 4425 if (IS_ERR(st_class_member)) { 4432 - printk(KERN_WARNING "st%d: class_device_create failed\n", 4426 + printk(KERN_WARNING "st%d: device_create failed\n", 4433 4427 dev_num); 4434 4428 error = PTR_ERR(st_class_member); 4435 4429 goto out; 4436 4430 } 4437 - class_set_devdata(st_class_member, &STp->modes[mode]); 4431 + dev_set_drvdata(st_class_member, &STp->modes[mode]); 4438 4432 4439 - error = class_device_create_file(st_class_member, 4440 - &class_device_attr_defined); 4433 + error = device_create_file(st_class_member, 4434 + &dev_attr_defined); 4441 4435 if (error) goto out; 4442 - error = class_device_create_file(st_class_member, 4443 - &class_device_attr_default_blksize); 4436 + error = device_create_file(st_class_member, 4437 + &dev_attr_default_blksize); 4444 4438 if (error) goto out; 4445 - error = class_device_create_file(st_class_member, 4446 - &class_device_attr_default_density); 4439 + error = device_create_file(st_class_member, 4440 + &dev_attr_default_density); 4447 4441 if (error) goto out; 4448 - error = class_device_create_file(st_class_member, 4449 - &class_device_attr_default_compression); 4442 + error = device_create_file(st_class_member, 4443 + &dev_attr_default_compression); 4450 4444 if (error) goto out; 4451 - error = class_device_create_file(st_class_member, 4452 - &class_device_attr_options); 4445 + error = device_create_file(st_class_member, 4446 + &dev_attr_options); 4453 4447 if (error) goto out; 4454 4448 4455 4449 if (mode == 0 && rew == 0) {
+1 -1
drivers/serial/serial_core.c
··· 2422 2422 */ 2423 2423 tty_dev = tty_register_device(drv->tty_driver, port->line, port->dev); 2424 2424 if (likely(!IS_ERR(tty_dev))) { 2425 - device_can_wakeup(tty_dev) = 1; 2425 + device_init_wakeup(tty_dev, 1); 2426 2426 device_set_wakeup_enable(tty_dev, 0); 2427 2427 } else 2428 2428 printk(KERN_ERR "Cannot register tty device on line %d\n",
+18 -5
drivers/uio/Kconfig
··· 1 - menu "Userspace I/O" 2 - depends on !S390 3 - 4 - config UIO 1 + menuconfig UIO 5 2 tristate "Userspace I/O drivers" 3 + depends on !S390 6 4 default n 7 5 help 8 6 Enable this to allow the userspace driver core code to be ··· 10 12 is also required for interrupt handling to work properly. 11 13 12 14 If you don't know what to do here, say N. 15 + 16 + if UIO 13 17 14 18 config UIO_CIF 15 19 tristate "generic Hilscher CIF Card driver" ··· 26 26 To compile this driver as a module, choose M here: the module 27 27 will be called uio_cif. 28 28 29 - endmenu 29 + config UIO_SMX 30 + tristate "SMX cryptengine UIO interface" 31 + depends on UIO 32 + default n 33 + help 34 + Userspace IO interface to the Cryptography engine found on the 35 + Nias Digital SMX boards. These will be available from Q4 2008 36 + from http://www.niasdigital.com. The userspace part of this 37 + driver will be released under the GPL at the same time as the 38 + hardware and will be able to be downloaded from the same site. 39 + 40 + If you compile this as a module, it will be called uio_smx. 41 + 42 + endif
+1
drivers/uio/Makefile
··· 1 1 obj-$(CONFIG_UIO) += uio.o 2 2 obj-$(CONFIG_UIO_CIF) += uio_cif.o 3 + obj-$(CONFIG_UIO_SMX) += uio_smx.o
+21 -15
drivers/uio/uio.c
··· 301 301 if (!idev) 302 302 return -ENODEV; 303 303 304 + if (!try_module_get(idev->owner)) 305 + return -ENODEV; 306 + 304 307 listener = kmalloc(sizeof(*listener), GFP_KERNEL); 305 - if (!listener) 306 - return -ENOMEM; 308 + if (!listener) { 309 + ret = -ENOMEM; 310 + goto err_alloc_listener; 311 + } 307 312 308 313 listener->dev = idev; 309 314 listener->event_count = atomic_read(&idev->event); 310 315 filep->private_data = listener; 311 316 312 317 if (idev->info->open) { 313 - if (!try_module_get(idev->owner)) 314 - return -ENODEV; 315 318 ret = idev->info->open(idev->info, inode); 316 - module_put(idev->owner); 319 + if (ret) 320 + goto err_infoopen; 317 321 } 318 322 319 - if (ret) 320 - kfree(listener); 323 + return 0; 324 + 325 + err_infoopen: 326 + 327 + kfree(listener); 328 + err_alloc_listener: 329 + 330 + module_put(idev->owner); 321 331 322 332 return ret; 323 333 } ··· 346 336 struct uio_listener *listener = filep->private_data; 347 337 struct uio_device *idev = listener->dev; 348 338 349 - if (idev->info->release) { 350 - if (!try_module_get(idev->owner)) 351 - return -ENODEV; 339 + if (idev->info->release) 352 340 ret = idev->info->release(idev->info, inode); 353 - module_put(idev->owner); 354 - } 341 + 342 + module_put(idev->owner); 343 + 355 344 if (filep->f_flags & FASYNC) 356 345 ret = uio_fasync(-1, filep, 0); 357 346 kfree(listener); ··· 519 510 return -EINVAL; 520 511 521 512 if (idev->info->mmap) { 522 - if (!try_module_get(idev->owner)) 523 - return -ENODEV; 524 513 ret = idev->info->mmap(idev->info, vma); 525 - module_put(idev->owner); 526 514 return ret; 527 515 } 528 516
+1 -5
drivers/uio/uio_cif.c
··· 15 15 16 16 #include <asm/io.h> 17 17 18 - #ifndef PCI_DEVICE_ID_PLX_9030 19 - #define PCI_DEVICE_ID_PLX_9030 0x9030 20 - #endif 21 - 22 18 #define PLX9030_INTCSR 0x4C 23 19 #define INTSCR_INT1_ENABLE 0x01 24 20 #define INTSCR_INT1_STATUS 0x04 ··· 112 116 kfree (info); 113 117 } 114 118 115 - static struct pci_device_id hilscher_pci_ids[] = { 119 + static struct pci_device_id hilscher_pci_ids[] __devinitdata = { 116 120 { 117 121 .vendor = PCI_VENDOR_ID_PLX, 118 122 .device = PCI_DEVICE_ID_PLX_9030,
+140
drivers/uio/uio_smx.c
··· 1 + /* 2 + * UIO SMX Cryptengine driver. 3 + * 4 + * (C) 2008 Nias Digital P/L <bn@niasdigital.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + * 10 + */ 11 + 12 + #include <linux/device.h> 13 + #include <linux/module.h> 14 + #include <linux/platform_device.h> 15 + #include <linux/uio_driver.h> 16 + #include <linux/io.h> 17 + 18 + #define DRV_NAME "smx-ce" 19 + #define DRV_VERSION "0.03" 20 + 21 + #define SMX_CSR 0x00000000 22 + #define SMX_EnD 0x00000001 23 + #define SMX_RUN 0x00000002 24 + #define SMX_DRDY 0x00000004 25 + #define SMX_ERR 0x00000008 26 + 27 + static irqreturn_t smx_handler(int irq, struct uio_info *dev_info) 28 + { 29 + void __iomem *csr = dev_info->mem[0].internal_addr + SMX_CSR; 30 + 31 + u32 status = ioread32(csr); 32 + 33 + if (!(status & SMX_DRDY)) 34 + return IRQ_NONE; 35 + 36 + /* Disable interrupt */ 37 + iowrite32(status & ~SMX_DRDY, csr); 38 + return IRQ_HANDLED; 39 + } 40 + 41 + static int __devinit smx_ce_probe(struct platform_device *dev) 42 + { 43 + 44 + int ret = -ENODEV; 45 + struct uio_info *info; 46 + struct resource *regs; 47 + 48 + info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); 49 + if (!info) 50 + return -ENOMEM; 51 + 52 + regs = platform_get_resource(dev, IORESOURCE_MEM, 0); 53 + if (!regs) { 54 + dev_err(&dev->dev, "No memory resource specified\n"); 55 + goto out_free; 56 + } 57 + 58 + info->mem[0].addr = regs->start; 59 + if (!info->mem[0].addr) { 60 + dev_err(&dev->dev, "Invalid memory resource\n"); 61 + goto out_free; 62 + } 63 + 64 + info->mem[0].size = regs->end - regs->start + 1; 65 + info->mem[0].internal_addr = ioremap(regs->start, info->mem[0].size); 66 + 67 + if (!info->mem[0].internal_addr) { 68 + dev_err(&dev->dev, "Can't remap memory address range\n"); 69 + goto out_free; 70 + } 71 + 72 + info->mem[0].memtype = UIO_MEM_PHYS; 73 + 74 + info->name = "smx-ce"; 75 + info->version = "0.03"; 76 + 77 + info->irq = platform_get_irq(dev, 0); 78 + if (info->irq < 0) { 79 + ret = info->irq; 80 + dev_err(&dev->dev, "No (or invalid) IRQ resource specified\n"); 81 + goto out_unmap; 82 + } 83 + 84 + info->irq_flags = IRQF_SHARED; 85 + info->handler = smx_handler; 86 + 87 + platform_set_drvdata(dev, info); 88 + 89 + ret = uio_register_device(&dev->dev, info); 90 + 91 + if (ret) 92 + goto out_unmap; 93 + 94 + return 0; 95 + 96 + out_unmap: 97 + iounmap(info->mem[0].internal_addr); 98 + out_free: 99 + kfree(info); 100 + 101 + return ret; 102 + } 103 + 104 + static int __devexit smx_ce_remove(struct platform_device *dev) 105 + { 106 + struct uio_info *info = platform_get_drvdata(dev); 107 + 108 + uio_unregister_device(info); 109 + platform_set_drvdata(dev, NULL); 110 + iounmap(info->mem[0].internal_addr); 111 + 112 + kfree(info); 113 + 114 + return 0; 115 + } 116 + 117 + static struct platform_driver smx_ce_driver = { 118 + .probe = smx_ce_probe, 119 + .remove = __devexit_p(smx_ce_remove), 120 + .driver = { 121 + .name = DRV_NAME, 122 + .owner = THIS_MODULE, 123 + }, 124 + }; 125 + 126 + static int __init smx_ce_init_module(void) 127 + { 128 + return platform_driver_register(&smx_ce_driver); 129 + } 130 + module_init(smx_ce_init_module); 131 + 132 + static void __exit smx_ce_exit_module(void) 133 + { 134 + platform_driver_unregister(&smx_ce_driver); 135 + } 136 + module_exit(smx_ce_exit_module); 137 + 138 + MODULE_LICENSE("GPL v2"); 139 + MODULE_VERSION(DRV_VERSION); 140 + MODULE_AUTHOR("Ben Nizette <bn@niasdigital.com>");
+4
fs/partitions/check.c
··· 473 473 return 0; 474 474 if (IS_ERR(state)) /* I/O error reading the partition table */ 475 475 return -EIO; 476 + 477 + /* tell userspace that the media / partition table may have changed */ 478 + kobject_uevent(&disk->dev.kobj, KOBJ_CHANGE); 479 + 476 480 for (p = 1; p < state->limit; p++) { 477 481 sector_t size = state->parts[p].size; 478 482 sector_t from = state->parts[p].from;
+1
fs/sysfs/dir.c
··· 20 20 #include <linux/idr.h> 21 21 #include <linux/completion.h> 22 22 #include <linux/mutex.h> 23 + #include <linux/slab.h> 23 24 #include "sysfs.h" 24 25 25 26 DEFINE_MUTEX(sysfs_mutex);
+3 -3
fs/sysfs/file.c
··· 13 13 #include <linux/module.h> 14 14 #include <linux/kobject.h> 15 15 #include <linux/kallsyms.h> 16 + #include <linux/slab.h> 16 17 #include <linux/namei.h> 17 18 #include <linux/poll.h> 18 19 #include <linux/list.h> ··· 129 128 ssize_t retval = 0; 130 129 131 130 mutex_lock(&buffer->mutex); 132 - if (buffer->needs_read_fill) { 131 + if (buffer->needs_read_fill || *ppos == 0) { 133 132 retval = fill_read_buffer(file->f_path.dentry,buffer); 134 133 if (retval) 135 134 goto out; ··· 410 409 * return POLLERR|POLLPRI, and select will return the fd whether 411 410 * it is waiting for read, write, or exceptions. 412 411 * Once poll/select indicates that the value has changed, you 413 - * need to close and re-open the file, as simply seeking and reading 414 - * again will not get new data, or reset the state of 'poll'. 412 + * need to close and re-open the file, or seek to 0 and read again. 415 413 * Reminder: this only works for attributes which actively support 416 414 * it, and it is not possible to test an attribute from userspace 417 415 * to see if it supports poll (Neither 'poll' nor 'select' return
+14 -14
include/linux/attribute_container.h
··· 1 1 /* 2 - * class_container.h - a generic container for all classes 2 + * attribute_container.h - a generic container for all classes 3 3 * 4 4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com> 5 5 * ··· 18 18 struct klist containers; 19 19 struct class *class; 20 20 struct attribute_group *grp; 21 - struct class_device_attribute **attrs; 21 + struct device_attribute **attrs; 22 22 int (*match)(struct attribute_container *, struct device *); 23 23 #define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01 24 24 unsigned long flags; ··· 41 41 void attribute_container_create_device(struct device *dev, 42 42 int (*fn)(struct attribute_container *, 43 43 struct device *, 44 - struct class_device *)); 44 + struct device *)); 45 45 void attribute_container_add_device(struct device *dev, 46 46 int (*fn)(struct attribute_container *, 47 47 struct device *, 48 - struct class_device *)); 48 + struct device *)); 49 49 void attribute_container_remove_device(struct device *dev, 50 50 void (*fn)(struct attribute_container *, 51 51 struct device *, 52 - struct class_device *)); 52 + struct device *)); 53 53 void attribute_container_device_trigger(struct device *dev, 54 54 int (*fn)(struct attribute_container *, 55 55 struct device *, 56 - struct class_device *)); 56 + struct device *)); 57 57 void attribute_container_trigger(struct device *dev, 58 58 int (*fn)(struct attribute_container *, 59 59 struct device *)); 60 - int attribute_container_add_attrs(struct class_device *classdev); 61 - int attribute_container_add_class_device(struct class_device *classdev); 60 + int attribute_container_add_attrs(struct device *classdev); 61 + int attribute_container_add_class_device(struct device *classdev); 62 62 int attribute_container_add_class_device_adapter(struct attribute_container *cont, 63 63 struct device *dev, 64 - struct class_device *classdev); 65 - void attribute_container_remove_attrs(struct class_device *classdev); 66 - void attribute_container_class_device_del(struct class_device *classdev); 67 - struct attribute_container *attribute_container_classdev_to_container(struct class_device *); 68 - struct class_device *attribute_container_find_class_device(struct attribute_container *, struct device *); 69 - struct class_device_attribute **attribute_container_classdev_to_attrs(const struct class_device *classdev); 64 + struct device *classdev); 65 + void attribute_container_remove_attrs(struct device *classdev); 66 + void attribute_container_class_device_del(struct device *classdev); 67 + struct attribute_container *attribute_container_classdev_to_container(struct device *); 68 + struct device *attribute_container_find_class_device(struct attribute_container *, struct device *); 69 + struct device_attribute **attribute_container_classdev_to_attrs(const struct device *classdev); 70 70 71 71 #endif
+1 -1
include/linux/bsg.h
··· 55 55 56 56 #if defined(CONFIG_BLK_DEV_BSG) 57 57 struct bsg_class_device { 58 - struct class_device *class_dev; 58 + struct device *class_dev; 59 59 struct device *dev; 60 60 int minor; 61 61 struct request_queue *queue;
+9 -26
include/linux/device.h
··· 429 429 struct kobject kobj; 430 430 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 431 431 struct device_type *type; 432 - unsigned is_registered:1; 433 432 unsigned uevent_suppress:1; 434 433 435 434 struct semaphore sem; /* semaphore to synchronize calls to ··· 474 475 void (*release)(struct device *dev); 475 476 }; 476 477 478 + /* Get the wakeup routines, which depend on struct device */ 479 + #include <linux/pm_wakeup.h> 480 + 477 481 #ifdef CONFIG_NUMA 478 482 static inline int dev_to_node(struct device *dev) 479 483 { ··· 508 506 509 507 static inline int device_is_registered(struct device *dev) 510 508 { 511 - return dev->is_registered; 509 + return dev->kobj.state_in_sysfs; 512 510 } 513 511 514 512 void driver_init(void); ··· 545 543 dev_t devt, const char *fmt, ...) 546 544 __attribute__((format(printf, 4, 5))); 547 545 extern void device_destroy(struct class *cls, dev_t devt); 548 - #ifdef CONFIG_PM_SLEEP 549 - extern void destroy_suspended_device(struct class *cls, dev_t devt); 550 - extern void device_pm_schedule_removal(struct device *); 551 - #else /* !CONFIG_PM_SLEEP */ 552 - static inline void destroy_suspended_device(struct class *cls, dev_t devt) 553 - { 554 - device_destroy(cls, devt); 555 - } 556 - 557 - static inline void device_pm_schedule_removal(struct device *dev) 558 - { 559 - device_unregister(dev); 560 - } 561 - #endif /* !CONFIG_PM_SLEEP */ 562 546 563 547 /* 564 548 * Platform "fixup" functions - allow the platform to have their say ··· 596 608 #define dev_dbg(dev, format, arg...) \ 597 609 dev_printk(KERN_DEBUG , dev , format , ## arg) 598 610 #else 599 - static inline int __attribute__ ((format (printf, 2, 3))) 600 - dev_dbg(struct device *dev, const char *fmt, ...) 601 - { 602 - return 0; 603 - } 611 + #define dev_dbg(dev, format, arg...) \ 612 + ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) 604 613 #endif 605 614 606 615 #ifdef VERBOSE_DEBUG 607 616 #define dev_vdbg dev_dbg 608 617 #else 609 - static inline int __attribute__ ((format (printf, 2, 3))) 610 - dev_vdbg(struct device *dev, const char *fmt, ...) 611 - { 612 - return 0; 613 - } 618 + 619 + #define dev_vdbg(dev, format, arg...) \ 620 + ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) 614 621 #endif 615 622 616 623 /* Create alias, so I can be autoloaded. */
+6 -5
include/linux/enclosure.h
··· 82 82 83 83 struct enclosure_component { 84 84 void *scratch; 85 - struct class_device cdev; 85 + struct device cdev; 86 + struct device *dev; 86 87 enum enclosure_component_type type; 87 88 int number; 88 89 int fault; ··· 95 94 struct enclosure_device { 96 95 void *scratch; 97 96 struct list_head node; 98 - struct class_device cdev; 97 + struct device edev; 99 98 struct enclosure_component_callbacks *cb; 100 99 int components; 101 100 struct enclosure_component component[0]; 102 101 }; 103 102 104 103 static inline struct enclosure_device * 105 - to_enclosure_device(struct class_device *dev) 104 + to_enclosure_device(struct device *dev) 106 105 { 107 - return container_of(dev, struct enclosure_device, cdev); 106 + return container_of(dev, struct enclosure_device, edev); 108 107 } 109 108 110 109 static inline struct enclosure_component * 111 - to_enclosure_component(struct class_device *dev) 110 + to_enclosure_component(struct device *dev) 112 111 { 113 112 return container_of(dev, struct enclosure_component, cdev); 114 113 }
+1 -9
include/linux/hw_random.h
··· 44 44 /** Register a new Hardware Random Number Generator driver. */ 45 45 extern int hwrng_register(struct hwrng *rng); 46 46 /** Unregister a Hardware Random Number Generator driver. */ 47 - extern void __hwrng_unregister(struct hwrng *rng, bool suspended); 48 - static inline void hwrng_unregister(struct hwrng *rng) 49 - { 50 - __hwrng_unregister(rng, false); 51 - } 52 - static inline void hwrng_unregister_suspended(struct hwrng *rng) 53 - { 54 - __hwrng_unregister(rng, true); 55 - } 47 + extern void hwrng_unregister(struct hwrng *rng); 56 48 57 49 #endif /* __KERNEL__ */ 58 50 #endif /* LINUX_HWRANDOM_H_ */
+50
include/linux/iscsi_ibft.h
··· 1 + /* 2 + * Copyright 2007 Red Hat, Inc. 3 + * by Peter Jones <pjones@redhat.com> 4 + * Copyright 2007 IBM, Inc. 5 + * by Konrad Rzeszutek <konradr@linux.vnet.ibm.com> 6 + * Copyright 2008 7 + * by Konrad Rzeszutek <ketuzsezr@darnok.org> 8 + * 9 + * This code exposes the iSCSI Boot Format Table to userland via sysfs. 10 + * 11 + * This program is free software; you can redistribute it and/or modify 12 + * it under the terms of the GNU General Public License v2.0 as published by 13 + * the Free Software Foundation 14 + * 15 + * This program is distributed in the hope that it will be useful, 16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 + * GNU General Public License for more details. 19 + */ 20 + 21 + #ifndef ISCSI_IBFT_H 22 + #define ISCSI_IBFT_H 23 + 24 + struct ibft_table_header { 25 + char signature[4]; 26 + u32 length; 27 + u8 revision; 28 + u8 checksum; 29 + char oem_id[6]; 30 + char oem_table_id[8]; 31 + char reserved[24]; 32 + } __attribute__((__packed__)); 33 + 34 + /* 35 + * Logical location of iSCSI Boot Format Table. 36 + * If the value is NULL there is no iBFT on the machine. 37 + */ 38 + extern struct ibft_table_header *ibft_addr; 39 + 40 + /* 41 + * Routine used to find and reserve the iSCSI Boot Format Table. The 42 + * mapped address is set in the ibft_addr variable. 43 + */ 44 + #ifdef CONFIG_ISCSI_IBFT_FIND 45 + extern void __init reserve_ibft_region(void); 46 + #else 47 + static inline void reserve_ibft_region(void) { } 48 + #endif 49 + 50 + #endif /* ISCSI_IBFT_H */
+2 -4
include/linux/kernel.h
··· 293 293 #define pr_debug(fmt, arg...) \ 294 294 printk(KERN_DEBUG fmt, ##arg) 295 295 #else 296 - static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char * fmt, ...) 297 - { 298 - return 0; 299 - } 296 + #define pr_debug(fmt, arg...) \ 297 + ({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; }) 300 298 #endif 301 299 302 300 /*
+1 -9
include/linux/leds.h
··· 59 59 60 60 extern int led_classdev_register(struct device *parent, 61 61 struct led_classdev *led_cdev); 62 - extern void __led_classdev_unregister(struct led_classdev *led_cdev, bool sus); 63 - static inline void led_classdev_unregister(struct led_classdev *lcd) 64 - { 65 - __led_classdev_unregister(lcd, false); 66 - } 67 - static inline void led_classdev_unregister_suspended(struct led_classdev *lcd) 68 - { 69 - __led_classdev_unregister(lcd, true); 70 - } 62 + extern void led_classdev_unregister(struct led_classdev *lcd); 71 63 extern void led_classdev_suspend(struct led_classdev *led_cdev); 72 64 extern void led_classdev_resume(struct led_classdev *led_cdev); 73 65
+1 -1
include/linux/libata.h
··· 443 443 MAX_PERFORMANCE, 444 444 MEDIUM_POWER, 445 445 }; 446 - extern struct class_device_attribute class_device_attr_link_power_management_policy; 446 + extern struct device_attribute dev_attr_link_power_management_policy; 447 447 448 448 #ifdef CONFIG_ATA_SFF 449 449 struct ata_ioports {
+2 -2
include/linux/memory.h
··· 18 18 #include <linux/sysdev.h> 19 19 #include <linux/node.h> 20 20 #include <linux/compiler.h> 21 - #include <linux/semaphore.h> 21 + #include <linux/mutex.h> 22 22 23 23 struct memory_block { 24 24 unsigned long phys_index; ··· 29 29 * created long after the critical areas during 30 30 * initialization. 31 31 */ 32 - struct semaphore state_sem; 32 + struct mutex state_mutex; 33 33 int phys_device; /* to which fru does this belong? */ 34 34 void *hw; /* optional pointer to fw/hw data */ 35 35 int (*phys_callback)(struct memory_block *);
+1 -1
include/linux/memstick.h
··· 276 276 #define MEMSTICK_CAP_PAR8 4 277 277 278 278 struct work_struct media_checker; 279 - struct class_device cdev; 279 + struct device dev; 280 280 281 281 struct memstick_dev *card; 282 282 unsigned int retries;
+1 -9
include/linux/miscdevice.h
··· 43 43 }; 44 44 45 45 extern int misc_register(struct miscdevice * misc); 46 - extern int __misc_deregister(struct miscdevice *misc, bool suspended); 47 - static inline int misc_deregister(struct miscdevice *misc) 48 - { 49 - return __misc_deregister(misc, false); 50 - } 51 - static inline int misc_deregister_suspended(struct miscdevice *misc) 52 - { 53 - return __misc_deregister(misc, true); 54 - } 46 + extern int misc_deregister(struct miscdevice *misc); 55 47 56 48 #define MODULE_ALIAS_MISCDEV(minor) \ 57 49 MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \
+3 -40
include/linux/pm.h
··· 183 183 struct dev_pm_info { 184 184 pm_message_t power_state; 185 185 unsigned can_wakeup:1; 186 - #ifdef CONFIG_PM_SLEEP 187 186 unsigned should_wakeup:1; 187 + bool sleeping:1; /* Owned by the PM core */ 188 + #ifdef CONFIG_PM_SLEEP 188 189 struct list_head entry; 189 190 #endif 190 191 }; ··· 198 197 extern int device_suspend(pm_message_t state); 199 198 extern int device_prepare_suspend(pm_message_t state); 200 199 201 - #define device_set_wakeup_enable(dev,val) \ 202 - ((dev)->power.should_wakeup = !!(val)) 203 - #define device_may_wakeup(dev) \ 204 - (device_can_wakeup(dev) && (dev)->power.should_wakeup) 205 - 206 200 extern void __suspend_report_result(const char *function, void *fn, int ret); 207 201 208 202 #define suspend_report_result(fn, ret) \ 209 203 do { \ 210 204 __suspend_report_result(__FUNCTION__, fn, ret); \ 211 205 } while (0) 212 - 213 - /* 214 - * Platform hook to activate device wakeup capability, if that's not already 215 - * handled by enable_irq_wake() etc. 216 - * Returns zero on success, else negative errno 217 - */ 218 - extern int (*platform_enable_wakeup)(struct device *dev, int is_on); 219 - 220 - static inline int call_platform_enable_wakeup(struct device *dev, int is_on) 221 - { 222 - if (platform_enable_wakeup) 223 - return (*platform_enable_wakeup)(dev, is_on); 224 - return 0; 225 - } 226 206 227 207 #else /* !CONFIG_PM_SLEEP */ 228 208 ··· 212 230 return 0; 213 231 } 214 232 215 - #define device_set_wakeup_enable(dev,val) do{}while(0) 216 - #define device_may_wakeup(dev) (0) 217 - 218 - #define suspend_report_result(fn, ret) do { } while (0) 219 - 220 - static inline int call_platform_enable_wakeup(struct device *dev, int is_on) 221 - { 222 - return 0; 223 - } 233 + #define suspend_report_result(fn, ret) do {} while (0) 224 234 225 235 #endif /* !CONFIG_PM_SLEEP */ 226 - 227 - /* changes to device_may_wakeup take effect on the next pm state change. 228 - * by default, devices should wakeup if they can. 229 - */ 230 - #define device_can_wakeup(dev) \ 231 - ((dev)->power.can_wakeup) 232 - #define device_init_wakeup(dev,val) \ 233 - do { \ 234 - device_can_wakeup(dev) = !!(val); \ 235 - device_set_wakeup_enable(dev,val); \ 236 - } while(0) 237 236 238 237 /* 239 238 * Global Power Management flags
+90
include/linux/pm_wakeup.h
··· 1 + /* 2 + * pm_wakeup.h - Power management wakeup interface 3 + * 4 + * Copyright (C) 2008 Alan Stern 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; either version 2 of the License, or 9 + * (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + * 16 + * You should have received a copy of the GNU General Public License 17 + * along with this program; if not, write to the Free Software 18 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 + */ 20 + 21 + #ifndef _LINUX_PM_WAKEUP_H 22 + #define _LINUX_PM_WAKEUP_H 23 + 24 + #ifndef _DEVICE_H_ 25 + # error "please don't include this file directly" 26 + #endif 27 + 28 + #ifdef CONFIG_PM 29 + 30 + /* changes to device_may_wakeup take effect on the next pm state change. 31 + * by default, devices should wakeup if they can. 32 + */ 33 + static inline void device_init_wakeup(struct device *dev, int val) 34 + { 35 + dev->power.can_wakeup = dev->power.should_wakeup = !!val; 36 + } 37 + 38 + static inline int device_can_wakeup(struct device *dev) 39 + { 40 + return dev->power.can_wakeup; 41 + } 42 + 43 + static inline void device_set_wakeup_enable(struct device *dev, int val) 44 + { 45 + dev->power.should_wakeup = !!val; 46 + } 47 + 48 + static inline int device_may_wakeup(struct device *dev) 49 + { 50 + return dev->power.can_wakeup & dev->power.should_wakeup; 51 + } 52 + 53 + /* 54 + * Platform hook to activate device wakeup capability, if that's not already 55 + * handled by enable_irq_wake() etc. 56 + * Returns zero on success, else negative errno 57 + */ 58 + extern int (*platform_enable_wakeup)(struct device *dev, int is_on); 59 + 60 + static inline int call_platform_enable_wakeup(struct device *dev, int is_on) 61 + { 62 + if (platform_enable_wakeup) 63 + return (*platform_enable_wakeup)(dev, is_on); 64 + return 0; 65 + } 66 + 67 + #else /* !CONFIG_PM */ 68 + 69 + /* For some reason the next two routines work even without CONFIG_PM */ 70 + static inline void device_init_wakeup(struct device *dev, int val) 71 + { 72 + dev->power.can_wakeup = !!val; 73 + } 74 + 75 + static inline int device_can_wakeup(struct device *dev) 76 + { 77 + return dev->power.can_wakeup; 78 + } 79 + 80 + #define device_set_wakeup_enable(dev, val) do {} while (0) 81 + #define device_may_wakeup(dev) 0 82 + 83 + static inline int call_platform_enable_wakeup(struct device *dev, int is_on) 84 + { 85 + return 0; 86 + } 87 + 88 + #endif /* !CONFIG_PM */ 89 + 90 + #endif /* _LINUX_PM_WAKEUP_H */
+6 -6
include/linux/raid_class.h
··· 53 53 #define DEFINE_RAID_ATTRIBUTE(type, attr) \ 54 54 static inline void \ 55 55 raid_set_##attr(struct raid_template *r, struct device *dev, type value) { \ 56 - struct class_device *cdev = \ 56 + struct device *device = \ 57 57 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\ 58 58 struct raid_data *rd; \ 59 - BUG_ON(!cdev); \ 60 - rd = class_get_devdata(cdev); \ 59 + BUG_ON(!device); \ 60 + rd = dev_get_drvdata(device); \ 61 61 rd->attr = value; \ 62 62 } \ 63 63 static inline type \ 64 64 raid_get_##attr(struct raid_template *r, struct device *dev) { \ 65 - struct class_device *cdev = \ 65 + struct device *device = \ 66 66 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\ 67 67 struct raid_data *rd; \ 68 - BUG_ON(!cdev); \ 69 - rd = class_get_devdata(cdev); \ 68 + BUG_ON(!device); \ 69 + rd = dev_get_drvdata(device); \ 70 70 return rd->attr; \ 71 71 } 72 72
+2 -7
include/linux/sysfs.h
··· 131 131 132 132 static inline void sysfs_remove_dir(struct kobject *kobj) 133 133 { 134 - ; 135 134 } 136 135 137 136 static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name) ··· 159 160 static inline void sysfs_remove_file(struct kobject *kobj, 160 161 const struct attribute *attr) 161 162 { 162 - ; 163 163 } 164 164 165 165 static inline int sysfs_create_bin_file(struct kobject *kobj, ··· 167 169 return 0; 168 170 } 169 171 170 - static inline int sysfs_remove_bin_file(struct kobject *kobj, 171 - struct bin_attribute *attr) 172 + static inline void sysfs_remove_bin_file(struct kobject *kobj, 173 + struct bin_attribute *attr) 172 174 { 173 - return 0; 174 175 } 175 176 176 177 static inline int sysfs_create_link(struct kobject *kobj, ··· 180 183 181 184 static inline void sysfs_remove_link(struct kobject *kobj, const char *name) 182 185 { 183 - ; 184 186 } 185 187 186 188 static inline int sysfs_create_group(struct kobject *kobj, ··· 191 195 static inline void sysfs_remove_group(struct kobject *kobj, 192 196 const struct attribute_group *grp) 193 197 { 194 - ; 195 198 } 196 199 197 200 static inline int sysfs_add_file_to_group(struct kobject *kobj,
+3 -3
include/linux/transport_class.h
··· 17 17 struct transport_class { 18 18 struct class class; 19 19 int (*setup)(struct transport_container *, struct device *, 20 - struct class_device *); 20 + struct device *); 21 21 int (*configure)(struct transport_container *, struct device *, 22 - struct class_device *); 22 + struct device *); 23 23 int (*remove)(struct transport_container *, struct device *, 24 - struct class_device *); 24 + struct device *); 25 25 }; 26 26 27 27 #define DECLARE_TRANSPORT_CLASS(cls, nm, su, rm, cfg) \
+1 -1
include/rdma/ib_verbs.h
··· 1051 1051 struct ib_dma_mapping_ops *dma_ops; 1052 1052 1053 1053 struct module *owner; 1054 - struct class_device class_dev; 1054 + struct device dev; 1055 1055 struct kobject *ports_parent; 1056 1056 struct list_head port_list; 1057 1057
+5 -5
include/scsi/scsi_device.h
··· 156 156 157 157 int timeout; 158 158 159 - struct device sdev_gendev; 160 - struct class_device sdev_classdev; 159 + struct device sdev_gendev, 160 + sdev_dev; 161 161 162 162 struct execute_work ew; /* used to get process context on put */ 163 163 ··· 167 167 #define to_scsi_device(d) \ 168 168 container_of(d, struct scsi_device, sdev_gendev) 169 169 #define class_to_sdev(d) \ 170 - container_of(d, struct scsi_device, sdev_classdev) 170 + container_of(d, struct scsi_device, sdev_dev) 171 171 #define transport_class_to_sdev(class_dev) \ 172 - to_scsi_device(class_dev->dev) 172 + to_scsi_device(class_dev->parent) 173 173 174 174 #define sdev_printk(prefix, sdev, fmt, a...) \ 175 175 dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a) ··· 220 220 return to_scsi_target(sdev->sdev_gendev.parent); 221 221 } 222 222 #define transport_class_to_starget(class_dev) \ 223 - to_scsi_target(class_dev->dev) 223 + to_scsi_target(class_dev->parent) 224 224 225 225 #define starget_printk(prefix, starget, fmt, a...) \ 226 226 dev_printk(prefix, &(starget)->dev, fmt, ##a)
+3 -4
include/scsi/scsi_host.h
··· 470 470 /* 471 471 * Pointer to the sysfs class properties for this host, NULL terminated. 472 472 */ 473 - struct class_device_attribute **shost_attrs; 473 + struct device_attribute **shost_attrs; 474 474 475 475 /* 476 476 * Pointer to the SCSI device properties for this host, NULL terminated. ··· 655 655 enum scsi_host_state shost_state; 656 656 657 657 /* ldm bits */ 658 - struct device shost_gendev; 659 - struct class_device shost_classdev; 658 + struct device shost_gendev, shost_dev; 660 659 661 660 /* 662 661 * List of hosts per template. ··· 682 683 }; 683 684 684 685 #define class_to_shost(d) \ 685 - container_of(d, struct Scsi_Host, shost_classdev) 686 + container_of(d, struct Scsi_Host, shost_dev) 686 687 687 688 #define shost_printk(prefix, shost, fmt, a...) \ 688 689 dev_printk(prefix, &(shost)->shost_gendev, fmt, ##a)
+1 -1
include/scsi/scsi_transport.h
··· 80 80 }; 81 81 82 82 #define transport_class_to_shost(tc) \ 83 - dev_to_shost((tc)->dev) 83 + dev_to_shost((tc)->parent) 84 84 85 85 86 86 /* Private area maintenance. The driver requested allocations come
+7 -7
include/scsi/scsi_transport_fc.h
··· 163 163 164 164 165 165 /* Macro for use in defining Virtual Port attributes */ 166 - #define FC_VPORT_ATTR(_name,_mode,_show,_store) \ 167 - struct class_device_attribute class_device_attr_vport_##_name = \ 166 + #define FC_VPORT_ATTR(_name,_mode,_show,_store) \ 167 + struct device_attribute dev_attr_vport_##_name = \ 168 168 __ATTR(_name,_mode,_show,_store) 169 169 170 170 ··· 234 234 235 235 #define dev_to_vport(d) \ 236 236 container_of(d, struct fc_vport, dev) 237 - #define transport_class_to_vport(classdev) \ 238 - dev_to_vport(classdev->dev) 237 + #define transport_class_to_vport(dev) \ 238 + dev_to_vport(dev->parent) 239 239 #define vport_to_shost(v) \ 240 240 (v->shost) 241 241 #define vport_to_shost_channel(v) \ ··· 271 271 272 272 /* Macro for use in defining Remote Port attributes */ 273 273 #define FC_RPORT_ATTR(_name,_mode,_show,_store) \ 274 - struct class_device_attribute class_device_attr_rport_##_name = \ 274 + struct device_attribute dev_attr_rport_##_name = \ 275 275 __ATTR(_name,_mode,_show,_store) 276 276 277 277 ··· 341 341 342 342 #define dev_to_rport(d) \ 343 343 container_of(d, struct fc_rport, dev) 344 - #define transport_class_to_rport(classdev) \ 345 - dev_to_rport(classdev->dev) 344 + #define transport_class_to_rport(dev) \ 345 + dev_to_rport(dev->parent) 346 346 #define rport_to_shost(r) \ 347 347 dev_to_shost(r->dev.parent) 348 348
+6 -6
include/scsi/scsi_transport_sas.h
··· 80 80 81 81 #define dev_to_phy(d) \ 82 82 container_of((d), struct sas_phy, dev) 83 - #define transport_class_to_phy(cdev) \ 84 - dev_to_phy((cdev)->dev) 83 + #define transport_class_to_phy(dev) \ 84 + dev_to_phy((dev)->parent) 85 85 #define phy_to_shost(phy) \ 86 86 dev_to_shost((phy)->dev.parent) 87 87 ··· 96 96 97 97 #define dev_to_rphy(d) \ 98 98 container_of((d), struct sas_rphy, dev) 99 - #define transport_class_to_rphy(cdev) \ 100 - dev_to_rphy((cdev)->dev) 99 + #define transport_class_to_rphy(dev) \ 100 + dev_to_rphy((dev)->parent) 101 101 #define rphy_to_shost(rphy) \ 102 102 dev_to_shost((rphy)->dev.parent) 103 103 #define target_to_rphy(targ) \ ··· 152 152 153 153 #define dev_to_sas_port(d) \ 154 154 container_of((d), struct sas_port, dev) 155 - #define transport_class_to_sas_port(cdev) \ 156 - dev_to_sas_port((cdev)->dev) 155 + #define transport_class_to_sas_port(dev) \ 156 + dev_to_sas_port((dev)->parent) 157 157 158 158 struct sas_phy_linkrates { 159 159 enum sas_linkrate maximum_linkrate;
+2 -2
include/scsi/sd.h
··· 34 34 struct scsi_disk { 35 35 struct scsi_driver *driver; /* always &sd_template */ 36 36 struct scsi_device *device; 37 - struct class_device cdev; 37 + struct device dev; 38 38 struct gendisk *disk; 39 39 unsigned int openers; /* protected by BKL for now, yuck */ 40 40 sector_t capacity; /* size in 512-byte sectors */ ··· 46 46 unsigned RCD : 1; /* state of disk RCD bit, unused */ 47 47 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ 48 48 }; 49 - #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev) 49 + #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) 50 50 51 51 #define sd_printk(prefix, sdsk, fmt, a...) \ 52 52 (sdsk)->disk ? \
+10 -9
lib/kobject.c
··· 58 58 return error; 59 59 } 60 60 61 - static inline struct kobject *to_kobj(struct list_head *entry) 62 - { 63 - return container_of(entry, struct kobject, entry); 64 - } 65 - 66 61 static int get_kobj_path_length(struct kobject *kobj) 67 62 { 68 63 int length = 1; ··· 587 592 */ 588 593 void kobject_put(struct kobject *kobj) 589 594 { 590 - if (kobj) 595 + if (kobj) { 596 + if (!kobj->state_initialized) { 597 + printk(KERN_WARNING "kobject: '%s' (%p): is not " 598 + "initialized, yet kobject_put() is being " 599 + "called.\n", kobject_name(kobj), kobj); 600 + WARN_ON(1); 601 + } 591 602 kref_put(&kobj->kref, kobject_release); 603 + } 592 604 } 593 605 594 606 static void dynamic_kobj_release(struct kobject *kobj) ··· 747 745 */ 748 746 struct kobject *kset_find_obj(struct kset *kset, const char *name) 749 747 { 750 - struct list_head *entry; 748 + struct kobject *k; 751 749 struct kobject *ret = NULL; 752 750 753 751 spin_lock(&kset->list_lock); 754 - list_for_each(entry, &kset->list) { 755 - struct kobject *k = to_kobj(entry); 752 + list_for_each_entry(k, &kset->list, entry) { 756 753 if (kobject_name(k) && !strcmp(kobject_name(k), name)) { 757 754 ret = kobject_get(k); 758 755 break;
+1 -1
mm/memory_hotplug.c
··· 208 208 /* 209 209 * This doesn't need a lock to do pfn_to_page(). 210 210 * The section can't be removed here because of the 211 - * memory_block->state_sem. 211 + * memory_block->state_mutex. 212 212 */ 213 213 zone = page_zone(pfn_to_page(pfn)); 214 214 pgdat_resize_lock(zone->zone_pgdat, &flags);
+44 -13
scripts/mod/file2alias.c
··· 328 328 return 1; 329 329 } 330 330 331 - /* looks like: "pnp:cCdD..." */ 332 - static int do_pnp_card_entry(const char *filename, 333 - struct pnp_card_device_id *id, char *alias) 331 + /* looks like: "pnp:dD" for every device of the card */ 332 + static void do_pnp_card_entries(void *symval, unsigned long size, 333 + struct module *mod) 334 334 { 335 - int i; 335 + const unsigned long id_size = sizeof(struct pnp_card_device_id); 336 + const unsigned int count = (size / id_size)-1; 337 + const struct pnp_card_device_id *cards = symval; 338 + unsigned int i; 336 339 337 - sprintf(alias, "pnp:c%s", id->id); 338 - for (i = 0; i < PNP_MAX_DEVICES; i++) { 339 - if (! *id->devs[i].id) 340 - break; 341 - sprintf(alias + strlen(alias), "d%s", id->devs[i].id); 340 + device_id_check(mod->name, "pnp", size, id_size, symval); 341 + 342 + for (i = 0; i < count; i++) { 343 + unsigned int j; 344 + const struct pnp_card_device_id *card = &cards[i]; 345 + 346 + for (j = 0; j < PNP_MAX_DEVICES; j++) { 347 + const char *id = (char *)card->devs[j].id; 348 + int i2, j2; 349 + int dup = 0; 350 + 351 + if (!id[0]) 352 + break; 353 + 354 + /* find duplicate, already added value */ 355 + for (i2 = 0; i2 < i && !dup; i2++) { 356 + const struct pnp_card_device_id *card2 = &cards[i2]; 357 + 358 + for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { 359 + const char *id2 = (char *)card2->devs[j2].id; 360 + 361 + if (!id2[0]) 362 + break; 363 + 364 + if (!strcmp(id, id2)) { 365 + dup = 1; 366 + break; 367 + } 368 + } 369 + } 370 + 371 + /* add an individual alias for every device entry */ 372 + if (!dup) 373 + buf_printf(&mod->dev_table_buf, 374 + "MODULE_ALIAS(\"pnp:d%s*\");\n", id); 375 + } 342 376 } 343 - return 1; 344 377 } 345 378 346 379 /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */ ··· 667 634 sizeof(struct pnp_device_id), "pnp", 668 635 do_pnp_entry, mod); 669 636 else if (sym_is(symname, "__mod_pnp_card_device_table")) 670 - do_table(symval, sym->st_size, 671 - sizeof(struct pnp_card_device_id), "pnp_card", 672 - do_pnp_card_entry, mod); 637 + do_pnp_card_entries(symval, sym->st_size, mod); 673 638 else if (sym_is(symname, "__mod_pcmcia_device_table")) 674 639 do_table(symval, sym->st_size, 675 640 sizeof(struct pcmcia_device_id), "pcmcia",