diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-12 11:00:10 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-07 13:37:11 -0500 |
commit | 873733188a019acdb7fa253011cbdc0a8afd97f3 (patch) | |
tree | 99828bd5db2f183e1b2d2204dc2c94bd1f8fdbbb /drivers/pcmcia/socket_sysfs.c | |
parent | 31b9025aa0f89b392077db3f87458fd46bcc4f58 (diff) |
Driver core: convert pcmcia code to use struct device
Converts from using struct "class_device" to "struct device" making
everything show up properly in /sys/devices/ with symlinks from the
/sys/class directory.
Cc: <linux-pcmcia@lists.infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pcmcia/socket_sysfs.c')
-rw-r--r-- | drivers/pcmcia/socket_sysfs.c | 104 |
1 files changed, 61 insertions, 43 deletions
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index b005602d6b53..ea5765c3bdc0 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c | |||
@@ -40,7 +40,8 @@ | |||
40 | 40 | ||
41 | #define to_socket(_dev) container_of(_dev, struct pcmcia_socket, dev) | 41 | #define to_socket(_dev) container_of(_dev, struct pcmcia_socket, dev) |
42 | 42 | ||
43 | static ssize_t pccard_show_type(struct class_device *dev, char *buf) | 43 | static ssize_t pccard_show_type(struct device *dev, struct device_attribute *attr, |
44 | char *buf) | ||
44 | { | 45 | { |
45 | struct pcmcia_socket *s = to_socket(dev); | 46 | struct pcmcia_socket *s = to_socket(dev); |
46 | 47 | ||
@@ -50,9 +51,10 @@ static ssize_t pccard_show_type(struct class_device *dev, char *buf) | |||
50 | return sprintf(buf, "32-bit\n"); | 51 | return sprintf(buf, "32-bit\n"); |
51 | return sprintf(buf, "16-bit\n"); | 52 | return sprintf(buf, "16-bit\n"); |
52 | } | 53 | } |
53 | static CLASS_DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL); | 54 | static DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL); |
54 | 55 | ||
55 | static ssize_t pccard_show_voltage(struct class_device *dev, char *buf) | 56 | static ssize_t pccard_show_voltage(struct device *dev, struct device_attribute *attr, |
57 | char *buf) | ||
56 | { | 58 | { |
57 | struct pcmcia_socket *s = to_socket(dev); | 59 | struct pcmcia_socket *s = to_socket(dev); |
58 | 60 | ||
@@ -63,28 +65,31 @@ static ssize_t pccard_show_voltage(struct class_device *dev, char *buf) | |||
63 | s->socket.Vcc % 10); | 65 | s->socket.Vcc % 10); |
64 | return sprintf(buf, "X.XV\n"); | 66 | return sprintf(buf, "X.XV\n"); |
65 | } | 67 | } |
66 | static CLASS_DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL); | 68 | static DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL); |
67 | 69 | ||
68 | static ssize_t pccard_show_vpp(struct class_device *dev, char *buf) | 70 | static ssize_t pccard_show_vpp(struct device *dev, struct device_attribute *attr, |
71 | char *buf) | ||
69 | { | 72 | { |
70 | struct pcmcia_socket *s = to_socket(dev); | 73 | struct pcmcia_socket *s = to_socket(dev); |
71 | if (!(s->state & SOCKET_PRESENT)) | 74 | if (!(s->state & SOCKET_PRESENT)) |
72 | return -ENODEV; | 75 | return -ENODEV; |
73 | return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10); | 76 | return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10); |
74 | } | 77 | } |
75 | static CLASS_DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL); | 78 | static DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL); |
76 | 79 | ||
77 | static ssize_t pccard_show_vcc(struct class_device *dev, char *buf) | 80 | static ssize_t pccard_show_vcc(struct device *dev, struct device_attribute *attr, |
81 | char *buf) | ||
78 | { | 82 | { |
79 | struct pcmcia_socket *s = to_socket(dev); | 83 | struct pcmcia_socket *s = to_socket(dev); |
80 | if (!(s->state & SOCKET_PRESENT)) | 84 | if (!(s->state & SOCKET_PRESENT)) |
81 | return -ENODEV; | 85 | return -ENODEV; |
82 | return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10); | 86 | return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10); |
83 | } | 87 | } |
84 | static CLASS_DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL); | 88 | static DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL); |
85 | 89 | ||
86 | 90 | ||
87 | static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, size_t count) | 91 | static ssize_t pccard_store_insert(struct device *dev, struct device_attribute *attr, |
92 | const char *buf, size_t count) | ||
88 | { | 93 | { |
89 | ssize_t ret; | 94 | ssize_t ret; |
90 | struct pcmcia_socket *s = to_socket(dev); | 95 | struct pcmcia_socket *s = to_socket(dev); |
@@ -96,16 +101,20 @@ static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, si | |||
96 | 101 | ||
97 | return ret ? ret : count; | 102 | return ret ? ret : count; |
98 | } | 103 | } |
99 | static CLASS_DEVICE_ATTR(card_insert, 0200, NULL, pccard_store_insert); | 104 | static DEVICE_ATTR(card_insert, 0200, NULL, pccard_store_insert); |
100 | 105 | ||
101 | 106 | ||
102 | static ssize_t pccard_show_card_pm_state(struct class_device *dev, char *buf) | 107 | static ssize_t pccard_show_card_pm_state(struct device *dev, |
108 | struct device_attribute *attr, | ||
109 | char *buf) | ||
103 | { | 110 | { |
104 | struct pcmcia_socket *s = to_socket(dev); | 111 | struct pcmcia_socket *s = to_socket(dev); |
105 | return sprintf(buf, "%s\n", s->state & SOCKET_SUSPEND ? "off" : "on"); | 112 | return sprintf(buf, "%s\n", s->state & SOCKET_SUSPEND ? "off" : "on"); |
106 | } | 113 | } |
107 | 114 | ||
108 | static ssize_t pccard_store_card_pm_state(struct class_device *dev, const char *buf, size_t count) | 115 | static ssize_t pccard_store_card_pm_state(struct device *dev, |
116 | struct device_attribute *attr, | ||
117 | const char *buf, size_t count) | ||
109 | { | 118 | { |
110 | ssize_t ret = -EINVAL; | 119 | ssize_t ret = -EINVAL; |
111 | struct pcmcia_socket *s = to_socket(dev); | 120 | struct pcmcia_socket *s = to_socket(dev); |
@@ -120,9 +129,11 @@ static ssize_t pccard_store_card_pm_state(struct class_device *dev, const char * | |||
120 | 129 | ||
121 | return ret ? -ENODEV : count; | 130 | return ret ? -ENODEV : count; |
122 | } | 131 | } |
123 | static CLASS_DEVICE_ATTR(card_pm_state, 0644, pccard_show_card_pm_state, pccard_store_card_pm_state); | 132 | static DEVICE_ATTR(card_pm_state, 0644, pccard_show_card_pm_state, pccard_store_card_pm_state); |
124 | 133 | ||
125 | static ssize_t pccard_store_eject(struct class_device *dev, const char *buf, size_t count) | 134 | static ssize_t pccard_store_eject(struct device *dev, |
135 | struct device_attribute *attr, | ||
136 | const char *buf, size_t count) | ||
126 | { | 137 | { |
127 | ssize_t ret; | 138 | ssize_t ret; |
128 | struct pcmcia_socket *s = to_socket(dev); | 139 | struct pcmcia_socket *s = to_socket(dev); |
@@ -134,16 +145,20 @@ static ssize_t pccard_store_eject(struct class_device *dev, const char *buf, siz | |||
134 | 145 | ||
135 | return ret ? ret : count; | 146 | return ret ? ret : count; |
136 | } | 147 | } |
137 | static CLASS_DEVICE_ATTR(card_eject, 0200, NULL, pccard_store_eject); | 148 | static DEVICE_ATTR(card_eject, 0200, NULL, pccard_store_eject); |
138 | 149 | ||
139 | 150 | ||
140 | static ssize_t pccard_show_irq_mask(struct class_device *dev, char *buf) | 151 | static ssize_t pccard_show_irq_mask(struct device *dev, |
152 | struct device_attribute *attr, | ||
153 | char *buf) | ||
141 | { | 154 | { |
142 | struct pcmcia_socket *s = to_socket(dev); | 155 | struct pcmcia_socket *s = to_socket(dev); |
143 | return sprintf(buf, "0x%04x\n", s->irq_mask); | 156 | return sprintf(buf, "0x%04x\n", s->irq_mask); |
144 | } | 157 | } |
145 | 158 | ||
146 | static ssize_t pccard_store_irq_mask(struct class_device *dev, const char *buf, size_t count) | 159 | static ssize_t pccard_store_irq_mask(struct device *dev, |
160 | struct device_attribute *attr, | ||
161 | const char *buf, size_t count) | ||
147 | { | 162 | { |
148 | ssize_t ret; | 163 | ssize_t ret; |
149 | struct pcmcia_socket *s = to_socket(dev); | 164 | struct pcmcia_socket *s = to_socket(dev); |
@@ -161,16 +176,19 @@ static ssize_t pccard_store_irq_mask(struct class_device *dev, const char *buf, | |||
161 | 176 | ||
162 | return ret ? ret : count; | 177 | return ret ? ret : count; |
163 | } | 178 | } |
164 | static CLASS_DEVICE_ATTR(card_irq_mask, 0600, pccard_show_irq_mask, pccard_store_irq_mask); | 179 | static DEVICE_ATTR(card_irq_mask, 0600, pccard_show_irq_mask, pccard_store_irq_mask); |
165 | 180 | ||
166 | 181 | ||
167 | static ssize_t pccard_show_resource(struct class_device *dev, char *buf) | 182 | static ssize_t pccard_show_resource(struct device *dev, |
183 | struct device_attribute *attr, char *buf) | ||
168 | { | 184 | { |
169 | struct pcmcia_socket *s = to_socket(dev); | 185 | struct pcmcia_socket *s = to_socket(dev); |
170 | return sprintf(buf, "%s\n", s->resource_setup_done ? "yes" : "no"); | 186 | return sprintf(buf, "%s\n", s->resource_setup_done ? "yes" : "no"); |
171 | } | 187 | } |
172 | 188 | ||
173 | static ssize_t pccard_store_resource(struct class_device *dev, const char *buf, size_t count) | 189 | static ssize_t pccard_store_resource(struct device *dev, |
190 | struct device_attribute *attr, | ||
191 | const char *buf, size_t count) | ||
174 | { | 192 | { |
175 | unsigned long flags; | 193 | unsigned long flags; |
176 | struct pcmcia_socket *s = to_socket(dev); | 194 | struct pcmcia_socket *s = to_socket(dev); |
@@ -196,7 +214,7 @@ static ssize_t pccard_store_resource(struct class_device *dev, const char *buf, | |||
196 | 214 | ||
197 | return count; | 215 | return count; |
198 | } | 216 | } |
199 | static CLASS_DEVICE_ATTR(available_resources_setup_done, 0600, pccard_show_resource, pccard_store_resource); | 217 | static DEVICE_ATTR(available_resources_setup_done, 0600, pccard_show_resource, pccard_store_resource); |
200 | 218 | ||
201 | 219 | ||
202 | static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf, loff_t off, size_t count) | 220 | static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf, loff_t off, size_t count) |
@@ -279,7 +297,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj, char *buf, loff_t off, size | |||
279 | if (off + count > size) | 297 | if (off + count > size) |
280 | count = size - off; | 298 | count = size - off; |
281 | 299 | ||
282 | s = to_socket(container_of(kobj, struct class_device, kobj)); | 300 | s = to_socket(container_of(kobj, struct device, kobj)); |
283 | 301 | ||
284 | if (!(s->state & SOCKET_PRESENT)) | 302 | if (!(s->state & SOCKET_PRESENT)) |
285 | return -ENODEV; | 303 | return -ENODEV; |
@@ -296,7 +314,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj, char *buf, loff_t off, size | |||
296 | 314 | ||
297 | static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, size_t count) | 315 | static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, size_t count) |
298 | { | 316 | { |
299 | struct pcmcia_socket *s = to_socket(container_of(kobj, struct class_device, kobj)); | 317 | struct pcmcia_socket *s = to_socket(container_of(kobj, struct device, kobj)); |
300 | cisdump_t *cis; | 318 | cisdump_t *cis; |
301 | int error; | 319 | int error; |
302 | 320 | ||
@@ -335,16 +353,16 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz | |||
335 | } | 353 | } |
336 | 354 | ||
337 | 355 | ||
338 | static struct class_device_attribute *pccard_socket_attributes[] = { | 356 | static struct device_attribute *pccard_socket_attributes[] = { |
339 | &class_device_attr_card_type, | 357 | &dev_attr_card_type, |
340 | &class_device_attr_card_voltage, | 358 | &dev_attr_card_voltage, |
341 | &class_device_attr_card_vpp, | 359 | &dev_attr_card_vpp, |
342 | &class_device_attr_card_vcc, | 360 | &dev_attr_card_vcc, |
343 | &class_device_attr_card_insert, | 361 | &dev_attr_card_insert, |
344 | &class_device_attr_card_pm_state, | 362 | &dev_attr_card_pm_state, |
345 | &class_device_attr_card_eject, | 363 | &dev_attr_card_eject, |
346 | &class_device_attr_card_irq_mask, | 364 | &dev_attr_card_irq_mask, |
347 | &class_device_attr_available_resources_setup_done, | 365 | &dev_attr_available_resources_setup_done, |
348 | NULL, | 366 | NULL, |
349 | }; | 367 | }; |
350 | 368 | ||
@@ -355,35 +373,35 @@ static struct bin_attribute pccard_cis_attr = { | |||
355 | .write = pccard_store_cis, | 373 | .write = pccard_store_cis, |
356 | }; | 374 | }; |
357 | 375 | ||
358 | static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev, | 376 | static int __devinit pccard_sysfs_add_socket(struct device *dev, |
359 | struct class_interface *class_intf) | 377 | struct class_interface *class_intf) |
360 | { | 378 | { |
361 | struct class_device_attribute **attr; | 379 | struct device_attribute **attr; |
362 | int ret = 0; | 380 | int ret = 0; |
363 | 381 | ||
364 | for (attr = pccard_socket_attributes; *attr; attr++) { | 382 | for (attr = pccard_socket_attributes; *attr; attr++) { |
365 | ret = class_device_create_file(class_dev, *attr); | 383 | ret = device_create_file(dev, *attr); |
366 | if (ret) | 384 | if (ret) |
367 | break; | 385 | break; |
368 | } | 386 | } |
369 | if (!ret) | 387 | if (!ret) |
370 | ret = sysfs_create_bin_file(&class_dev->kobj, &pccard_cis_attr); | 388 | ret = sysfs_create_bin_file(&dev->kobj, &pccard_cis_attr); |
371 | 389 | ||
372 | return ret; | 390 | return ret; |
373 | } | 391 | } |
374 | 392 | ||
375 | static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev, | 393 | static void __devexit pccard_sysfs_remove_socket(struct device *dev, |
376 | struct class_interface *class_intf) | 394 | struct class_interface *class_intf) |
377 | { | 395 | { |
378 | struct class_device_attribute **attr; | 396 | struct device_attribute **attr; |
379 | 397 | ||
380 | sysfs_remove_bin_file(&class_dev->kobj, &pccard_cis_attr); | 398 | sysfs_remove_bin_file(&dev->kobj, &pccard_cis_attr); |
381 | for (attr = pccard_socket_attributes; *attr; attr++) | 399 | for (attr = pccard_socket_attributes; *attr; attr++) |
382 | class_device_remove_file(class_dev, *attr); | 400 | device_remove_file(dev, *attr); |
383 | } | 401 | } |
384 | 402 | ||
385 | struct class_interface pccard_sysfs_interface = { | 403 | struct class_interface pccard_sysfs_interface = { |
386 | .class = &pcmcia_socket_class, | 404 | .class = &pcmcia_socket_class, |
387 | .add = &pccard_sysfs_add_socket, | 405 | .add_dev = &pccard_sysfs_add_socket, |
388 | .remove = __devexit_p(&pccard_sysfs_remove_socket), | 406 | .remove_dev = __devexit_p(&pccard_sysfs_remove_socket), |
389 | }; | 407 | }; |