aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2007-06-09 01:57:22 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-11 19:09:09 -0400
commit91a6902958f052358899f58683d44e36228d85c2 (patch)
treea713792cf3bb09bdbd2ac6906aa44b3da3e49250 /drivers/scsi
parent51225039f3cf9d250596d1344494b293274b9169 (diff)
sysfs: add parameter "struct bin_attribute *" in .read/.write methods for sysfs binary attributes
Well, first of all, I don't want to change so many files either. What I do: Adding a new parameter "struct bin_attribute *" in the .read/.write methods for the sysfs binary attributes. In fact, only the four lines change in fs/sysfs/bin.c and include/linux/sysfs.h do the real work. But I have to update all the files that use binary attributes to make them compatible with the new .read and .write methods. I'm not sure if I missed any. :( Why I do this: For a sysfs attribute, we can get a pointer pointing to the struct attribute in the .show/.store method, while we can't do this for the binary attributes. I don't know why this is different, but this does make it not so handy to use the binary attributes as the regular ones. So I think this patch is reasonable. :) Who benefits from it: The patch that exposes ACPI tables in sysfs requires such an improvement. All the table binary attributes share the same .read method. Parameter "struct bin_attribute *" is used to get the table signature and instance number which are used to distinguish different ACPI table binary attributes. Without this parameter, we need to offer different .read methods for different ACPI table binary attributes. This is impossible as there are various ACPI tables on different platforms, and we don't know what they are until they are loaded. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/arcmsr/arcmsr_attr.c15
-rw-r--r--drivers/scsi/ipr.c18
-rw-r--r--drivers/scsi/libsas/sas_expander.c16
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c50
5 files changed, 69 insertions, 42 deletions
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c
index 8908228bc134..06c0dce3b839 100644
--- a/drivers/scsi/arcmsr/arcmsr_attr.c
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c
@@ -59,8 +59,9 @@
59struct class_device_attribute *arcmsr_host_attrs[]; 59struct class_device_attribute *arcmsr_host_attrs[];
60 60
61static ssize_t 61static ssize_t
62arcmsr_sysfs_iop_message_read(struct kobject *kobj, char *buf, loff_t off, 62arcmsr_sysfs_iop_message_read(struct kobject *kobj,
63 size_t count) 63 struct bin_attribute *bin_attr,
64 char *buf, loff_t off, size_t count)
64{ 65{
65 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 66 struct class_device *cdev = container_of(kobj,struct class_device,kobj);
66 struct Scsi_Host *host = class_to_shost(cdev); 67 struct Scsi_Host *host = class_to_shost(cdev);
@@ -105,8 +106,9 @@ arcmsr_sysfs_iop_message_read(struct kobject *kobj, char *buf, loff_t off,
105} 106}
106 107
107static ssize_t 108static ssize_t
108arcmsr_sysfs_iop_message_write(struct kobject *kobj, char *buf, loff_t off, 109arcmsr_sysfs_iop_message_write(struct kobject *kobj,
109 size_t count) 110 struct bin_attribute *bin_attr,
111 char *buf, loff_t off, size_t count)
110{ 112{
111 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 113 struct class_device *cdev = container_of(kobj,struct class_device,kobj);
112 struct Scsi_Host *host = class_to_shost(cdev); 114 struct Scsi_Host *host = class_to_shost(cdev);
@@ -152,8 +154,9 @@ arcmsr_sysfs_iop_message_write(struct kobject *kobj, char *buf, loff_t off,
152} 154}
153 155
154static ssize_t 156static ssize_t
155arcmsr_sysfs_iop_message_clear(struct kobject *kobj, char *buf, loff_t off, 157arcmsr_sysfs_iop_message_clear(struct kobject *kobj,
156 size_t count) 158 struct bin_attribute *bin_attr,
159 char *buf, loff_t off, size_t count)
157{ 160{
158 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 161 struct class_device *cdev = container_of(kobj,struct class_device,kobj);
159 struct Scsi_Host *host = class_to_shost(cdev); 162 struct Scsi_Host *host = class_to_shost(cdev);
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index fa6ff295e568..4a3083ea59d5 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -2465,6 +2465,7 @@ restart:
2465/** 2465/**
2466 * ipr_read_trace - Dump the adapter trace 2466 * ipr_read_trace - Dump the adapter trace
2467 * @kobj: kobject struct 2467 * @kobj: kobject struct
2468 * @bin_attr: bin_attribute struct
2468 * @buf: buffer 2469 * @buf: buffer
2469 * @off: offset 2470 * @off: offset
2470 * @count: buffer size 2471 * @count: buffer size
@@ -2472,8 +2473,9 @@ restart:
2472 * Return value: 2473 * Return value:
2473 * number of bytes printed to buffer 2474 * number of bytes printed to buffer
2474 **/ 2475 **/
2475static ssize_t ipr_read_trace(struct kobject *kobj, char *buf, 2476static ssize_t ipr_read_trace(struct kobject *kobj,
2476 loff_t off, size_t count) 2477 struct bin_attribute *bin_attr,
2478 char *buf, loff_t off, size_t count)
2477{ 2479{
2478 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 2480 struct class_device *cdev = container_of(kobj,struct class_device,kobj);
2479 struct Scsi_Host *shost = class_to_shost(cdev); 2481 struct Scsi_Host *shost = class_to_shost(cdev);
@@ -3166,6 +3168,7 @@ static struct class_device_attribute *ipr_ioa_attrs[] = {
3166/** 3168/**
3167 * ipr_read_dump - Dump the adapter 3169 * ipr_read_dump - Dump the adapter
3168 * @kobj: kobject struct 3170 * @kobj: kobject struct
3171 * @bin_attr: bin_attribute struct
3169 * @buf: buffer 3172 * @buf: buffer
3170 * @off: offset 3173 * @off: offset
3171 * @count: buffer size 3174 * @count: buffer size
@@ -3173,8 +3176,9 @@ static struct class_device_attribute *ipr_ioa_attrs[] = {
3173 * Return value: 3176 * Return value:
3174 * number of bytes printed to buffer 3177 * number of bytes printed to buffer
3175 **/ 3178 **/
3176static ssize_t ipr_read_dump(struct kobject *kobj, char *buf, 3179static ssize_t ipr_read_dump(struct kobject *kobj,
3177 loff_t off, size_t count) 3180 struct bin_attribute *bin_attr,
3181 char *buf, loff_t off, size_t count)
3178{ 3182{
3179 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 3183 struct class_device *cdev = container_of(kobj,struct class_device,kobj);
3180 struct Scsi_Host *shost = class_to_shost(cdev); 3184 struct Scsi_Host *shost = class_to_shost(cdev);
@@ -3327,6 +3331,7 @@ static int ipr_free_dump(struct ipr_ioa_cfg *ioa_cfg)
3327/** 3331/**
3328 * ipr_write_dump - Setup dump state of adapter 3332 * ipr_write_dump - Setup dump state of adapter
3329 * @kobj: kobject struct 3333 * @kobj: kobject struct
3334 * @bin_attr: bin_attribute struct
3330 * @buf: buffer 3335 * @buf: buffer
3331 * @off: offset 3336 * @off: offset
3332 * @count: buffer size 3337 * @count: buffer size
@@ -3334,8 +3339,9 @@ static int ipr_free_dump(struct ipr_ioa_cfg *ioa_cfg)
3334 * Return value: 3339 * Return value:
3335 * number of bytes printed to buffer 3340 * number of bytes printed to buffer
3336 **/ 3341 **/
3337static ssize_t ipr_write_dump(struct kobject *kobj, char *buf, 3342static ssize_t ipr_write_dump(struct kobject *kobj,
3338 loff_t off, size_t count) 3343 struct bin_attribute *bin_attr,
3344 char *buf, loff_t off, size_t count)
3339{ 3345{
3340 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 3346 struct class_device *cdev = container_of(kobj,struct class_device,kobj);
3341 struct Scsi_Host *shost = class_to_shost(cdev); 3347 struct Scsi_Host *shost = class_to_shost(cdev);
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 578ed79f4148..23e90c5f8f35 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -38,8 +38,10 @@ static int sas_disable_routing(struct domain_device *dev, u8 *sas_addr);
38 38
39#if 0 39#if 0
40/* FIXME: smp needs to migrate into the sas class */ 40/* FIXME: smp needs to migrate into the sas class */
41static ssize_t smp_portal_read(struct kobject *, char *, loff_t, size_t); 41static ssize_t smp_portal_read(struct kobject *, struct bin_attribute *,
42static ssize_t smp_portal_write(struct kobject *, char *, loff_t, size_t); 42 char *, loff_t, size_t);
43static ssize_t smp_portal_write(struct kobject *, struct bin_attribute *,
44 char *, loff_t, size_t);
43#endif 45#endif
44 46
45/* ---------- SMP task management ---------- */ 47/* ---------- SMP task management ---------- */
@@ -1845,8 +1847,9 @@ out:
1845#if 0 1847#if 0
1846/* ---------- SMP portal ---------- */ 1848/* ---------- SMP portal ---------- */
1847 1849
1848static ssize_t smp_portal_write(struct kobject *kobj, char *buf, loff_t offs, 1850static ssize_t smp_portal_write(struct kobject *kobj,
1849 size_t size) 1851 struct bin_attribute *bin_attr,
1852 char *buf, loff_t offs, size_t size)
1850{ 1853{
1851 struct domain_device *dev = to_dom_device(kobj); 1854 struct domain_device *dev = to_dom_device(kobj);
1852 struct expander_device *ex = &dev->ex_dev; 1855 struct expander_device *ex = &dev->ex_dev;
@@ -1872,8 +1875,9 @@ static ssize_t smp_portal_write(struct kobject *kobj, char *buf, loff_t offs,
1872 return size; 1875 return size;
1873} 1876}
1874 1877
1875static ssize_t smp_portal_read(struct kobject *kobj, char *buf, loff_t offs, 1878static ssize_t smp_portal_read(struct kobject *kobj,
1876 size_t size) 1879 struct bin_attribute *bin_attr,
1880 char *buf, loff_t offs, size_t size)
1877{ 1881{
1878 struct domain_device *dev = to_dom_device(kobj); 1882 struct domain_device *dev = to_dom_device(kobj);
1879 struct expander_device *ex = &dev->ex_dev; 1883 struct expander_device *ex = &dev->ex_dev;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index f81fe501a4a1..5dfda9778c80 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -1133,7 +1133,8 @@ struct class_device_attribute *lpfc_host_attrs[] = {
1133}; 1133};
1134 1134
1135static ssize_t 1135static ssize_t
1136sysfs_ctlreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count) 1136sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr,
1137 char *buf, loff_t off, size_t count)
1137{ 1138{
1138 size_t buf_off; 1139 size_t buf_off;
1139 struct Scsi_Host *host = class_to_shost(container_of(kobj, 1140 struct Scsi_Host *host = class_to_shost(container_of(kobj,
@@ -1165,7 +1166,8 @@ sysfs_ctlreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
1165} 1166}
1166 1167
1167static ssize_t 1168static ssize_t
1168sysfs_ctlreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count) 1169sysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr,
1170 char *buf, loff_t off, size_t count)
1169{ 1171{
1170 size_t buf_off; 1172 size_t buf_off;
1171 uint32_t * tmp_ptr; 1173 uint32_t * tmp_ptr;
@@ -1221,7 +1223,8 @@ sysfs_mbox_idle (struct lpfc_hba * phba)
1221} 1223}
1222 1224
1223static ssize_t 1225static ssize_t
1224sysfs_mbox_write(struct kobject *kobj, char *buf, loff_t off, size_t count) 1226sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr,
1227 char *buf, loff_t off, size_t count)
1225{ 1228{
1226 struct Scsi_Host * host = 1229 struct Scsi_Host * host =
1227 class_to_shost(container_of(kobj, struct class_device, kobj)); 1230 class_to_shost(container_of(kobj, struct class_device, kobj));
@@ -1273,7 +1276,8 @@ sysfs_mbox_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
1273} 1276}
1274 1277
1275static ssize_t 1278static ssize_t
1276sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count) 1279sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr,
1280 char *buf, loff_t off, size_t count)
1277{ 1281{
1278 struct Scsi_Host *host = 1282 struct Scsi_Host *host =
1279 class_to_shost(container_of(kobj, struct class_device, 1283 class_to_shost(container_of(kobj, struct class_device,
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 96587253bfa9..942db9de785e 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -11,8 +11,9 @@
11/* SYSFS attributes --------------------------------------------------------- */ 11/* SYSFS attributes --------------------------------------------------------- */
12 12
13static ssize_t 13static ssize_t
14qla2x00_sysfs_read_fw_dump(struct kobject *kobj, char *buf, loff_t off, 14qla2x00_sysfs_read_fw_dump(struct kobject *kobj,
15 size_t count) 15 struct bin_attribute *bin_attr,
16 char *buf, loff_t off, size_t count)
16{ 17{
17 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 18 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
18 struct device, kobj))); 19 struct device, kobj)));
@@ -31,8 +32,9 @@ qla2x00_sysfs_read_fw_dump(struct kobject *kobj, char *buf, loff_t off,
31} 32}
32 33
33static ssize_t 34static ssize_t
34qla2x00_sysfs_write_fw_dump(struct kobject *kobj, char *buf, loff_t off, 35qla2x00_sysfs_write_fw_dump(struct kobject *kobj,
35 size_t count) 36 struct bin_attribute *bin_attr,
37 char *buf, loff_t off, size_t count)
36{ 38{
37 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 39 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
38 struct device, kobj))); 40 struct device, kobj)));
@@ -80,8 +82,9 @@ static struct bin_attribute sysfs_fw_dump_attr = {
80}; 82};
81 83
82static ssize_t 84static ssize_t
83qla2x00_sysfs_read_nvram(struct kobject *kobj, char *buf, loff_t off, 85qla2x00_sysfs_read_nvram(struct kobject *kobj,
84 size_t count) 86 struct bin_attribute *bin_attr,
87 char *buf, loff_t off, size_t count)
85{ 88{
86 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 89 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
87 struct device, kobj))); 90 struct device, kobj)));
@@ -100,8 +103,9 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj, char *buf, loff_t off,
100} 103}
101 104
102static ssize_t 105static ssize_t
103qla2x00_sysfs_write_nvram(struct kobject *kobj, char *buf, loff_t off, 106qla2x00_sysfs_write_nvram(struct kobject *kobj,
104 size_t count) 107 struct bin_attribute *bin_attr,
108 char *buf, loff_t off, size_t count)
105{ 109{
106 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 110 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
107 struct device, kobj))); 111 struct device, kobj)));
@@ -155,8 +159,9 @@ static struct bin_attribute sysfs_nvram_attr = {
155}; 159};
156 160
157static ssize_t 161static ssize_t
158qla2x00_sysfs_read_optrom(struct kobject *kobj, char *buf, loff_t off, 162qla2x00_sysfs_read_optrom(struct kobject *kobj,
159 size_t count) 163 struct bin_attribute *bin_attr,
164 char *buf, loff_t off, size_t count)
160{ 165{
161 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 166 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
162 struct device, kobj))); 167 struct device, kobj)));
@@ -174,8 +179,9 @@ qla2x00_sysfs_read_optrom(struct kobject *kobj, char *buf, loff_t off,
174} 179}
175 180
176static ssize_t 181static ssize_t
177qla2x00_sysfs_write_optrom(struct kobject *kobj, char *buf, loff_t off, 182qla2x00_sysfs_write_optrom(struct kobject *kobj,
178 size_t count) 183 struct bin_attribute *bin_attr,
184 char *buf, loff_t off, size_t count)
179{ 185{
180 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 186 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
181 struct device, kobj))); 187 struct device, kobj)));
@@ -203,8 +209,9 @@ static struct bin_attribute sysfs_optrom_attr = {
203}; 209};
204 210
205static ssize_t 211static ssize_t
206qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj, char *buf, loff_t off, 212qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
207 size_t count) 213 struct bin_attribute *bin_attr,
214 char *buf, loff_t off, size_t count)
208{ 215{
209 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 216 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
210 struct device, kobj))); 217 struct device, kobj)));
@@ -282,8 +289,9 @@ static struct bin_attribute sysfs_optrom_ctl_attr = {
282}; 289};
283 290
284static ssize_t 291static ssize_t
285qla2x00_sysfs_read_vpd(struct kobject *kobj, char *buf, loff_t off, 292qla2x00_sysfs_read_vpd(struct kobject *kobj,
286 size_t count) 293 struct bin_attribute *bin_attr,
294 char *buf, loff_t off, size_t count)
287{ 295{
288 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 296 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
289 struct device, kobj))); 297 struct device, kobj)));
@@ -301,8 +309,9 @@ qla2x00_sysfs_read_vpd(struct kobject *kobj, char *buf, loff_t off,
301} 309}
302 310
303static ssize_t 311static ssize_t
304qla2x00_sysfs_write_vpd(struct kobject *kobj, char *buf, loff_t off, 312qla2x00_sysfs_write_vpd(struct kobject *kobj,
305 size_t count) 313 struct bin_attribute *bin_attr,
314 char *buf, loff_t off, size_t count)
306{ 315{
307 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 316 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
308 struct device, kobj))); 317 struct device, kobj)));
@@ -330,8 +339,9 @@ static struct bin_attribute sysfs_vpd_attr = {
330}; 339};
331 340
332static ssize_t 341static ssize_t
333qla2x00_sysfs_read_sfp(struct kobject *kobj, char *buf, loff_t off, 342qla2x00_sysfs_read_sfp(struct kobject *kobj,
334 size_t count) 343 struct bin_attribute *bin_attr,
344 char *buf, loff_t off, size_t count)
335{ 345{
336 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 346 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
337 struct device, kobj))); 347 struct device, kobj)));