diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-21 18:45:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-22 14:05:43 -0400 |
commit | 38f40982e16fde872b8c11bb1cc6553cc42884b0 (patch) | |
tree | 96519d5ec59c370ce763b3db4432abb08821a2bf /drivers/w1 | |
parent | b3c6061daca33c1e97b8da675a2529fc5d49c05e (diff) |
w1: slaves: w1_ds2433: convert to use w1_family_ops.groups
This moves the sysfs file creation/removal to the w1 core by using the
.groups field, saving code in the slave driver.
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Cc: Alexander Stein <alexander.stein@informatik.tu-chemnitz.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1')
-rw-r--r-- | drivers/w1/slaves/w1_ds2433.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c index 10cc1b6176e6..72319a968a9e 100644 --- a/drivers/w1/slaves/w1_ds2433.c +++ b/drivers/w1/slaves/w1_ds2433.c | |||
@@ -93,9 +93,9 @@ static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data, | |||
93 | } | 93 | } |
94 | #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ | 94 | #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ |
95 | 95 | ||
96 | static ssize_t w1_f23_read_bin(struct file *filp, struct kobject *kobj, | 96 | static ssize_t eeprom_read(struct file *filp, struct kobject *kobj, |
97 | struct bin_attribute *bin_attr, | 97 | struct bin_attribute *bin_attr, char *buf, |
98 | char *buf, loff_t off, size_t count) | 98 | loff_t off, size_t count) |
99 | { | 99 | { |
100 | struct w1_slave *sl = kobj_to_w1_slave(kobj); | 100 | struct w1_slave *sl = kobj_to_w1_slave(kobj); |
101 | #ifdef CONFIG_W1_SLAVE_DS2433_CRC | 101 | #ifdef CONFIG_W1_SLAVE_DS2433_CRC |
@@ -207,9 +207,9 @@ static int w1_f23_write(struct w1_slave *sl, int addr, int len, const u8 *data) | |||
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | 209 | ||
210 | static ssize_t w1_f23_write_bin(struct file *filp, struct kobject *kobj, | 210 | static ssize_t eeprom_write(struct file *filp, struct kobject *kobj, |
211 | struct bin_attribute *bin_attr, | 211 | struct bin_attribute *bin_attr, char *buf, |
212 | char *buf, loff_t off, size_t count) | 212 | loff_t off, size_t count) |
213 | { | 213 | { |
214 | struct w1_slave *sl = kobj_to_w1_slave(kobj); | 214 | struct w1_slave *sl = kobj_to_w1_slave(kobj); |
215 | int addr, len, idx; | 215 | int addr, len, idx; |
@@ -257,19 +257,24 @@ out_up: | |||
257 | return count; | 257 | return count; |
258 | } | 258 | } |
259 | 259 | ||
260 | static struct bin_attribute w1_f23_bin_attr = { | 260 | static BIN_ATTR_RW(eeprom, W1_EEPROM_SIZE); |
261 | .attr = { | 261 | |
262 | .name = "eeprom", | 262 | static struct bin_attribute *w1_f23_bin_attributes[] = { |
263 | .mode = S_IRUGO | S_IWUSR, | 263 | &bin_attr_eeprom, |
264 | }, | 264 | NULL, |
265 | .size = W1_EEPROM_SIZE, | 265 | }; |
266 | .read = w1_f23_read_bin, | 266 | |
267 | .write = w1_f23_write_bin, | 267 | static const struct attribute_group w1_f23_group = { |
268 | .bin_attrs = w1_f23_bin_attributes, | ||
269 | }; | ||
270 | |||
271 | static const struct attribute_group *w1_f23_groups[] = { | ||
272 | &w1_f23_group, | ||
273 | NULL, | ||
268 | }; | 274 | }; |
269 | 275 | ||
270 | static int w1_f23_add_slave(struct w1_slave *sl) | 276 | static int w1_f23_add_slave(struct w1_slave *sl) |
271 | { | 277 | { |
272 | int err; | ||
273 | #ifdef CONFIG_W1_SLAVE_DS2433_CRC | 278 | #ifdef CONFIG_W1_SLAVE_DS2433_CRC |
274 | struct w1_f23_data *data; | 279 | struct w1_f23_data *data; |
275 | 280 | ||
@@ -279,15 +284,7 @@ static int w1_f23_add_slave(struct w1_slave *sl) | |||
279 | sl->family_data = data; | 284 | sl->family_data = data; |
280 | 285 | ||
281 | #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ | 286 | #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ |
282 | 287 | return 0; | |
283 | err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); | ||
284 | |||
285 | #ifdef CONFIG_W1_SLAVE_DS2433_CRC | ||
286 | if (err) | ||
287 | kfree(data); | ||
288 | #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ | ||
289 | |||
290 | return err; | ||
291 | } | 288 | } |
292 | 289 | ||
293 | static void w1_f23_remove_slave(struct w1_slave *sl) | 290 | static void w1_f23_remove_slave(struct w1_slave *sl) |
@@ -296,12 +293,12 @@ static void w1_f23_remove_slave(struct w1_slave *sl) | |||
296 | kfree(sl->family_data); | 293 | kfree(sl->family_data); |
297 | sl->family_data = NULL; | 294 | sl->family_data = NULL; |
298 | #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ | 295 | #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ |
299 | sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); | ||
300 | } | 296 | } |
301 | 297 | ||
302 | static struct w1_family_ops w1_f23_fops = { | 298 | static struct w1_family_ops w1_f23_fops = { |
303 | .add_slave = w1_f23_add_slave, | 299 | .add_slave = w1_f23_add_slave, |
304 | .remove_slave = w1_f23_remove_slave, | 300 | .remove_slave = w1_f23_remove_slave, |
301 | .groups = w1_f23_groups, | ||
305 | }; | 302 | }; |
306 | 303 | ||
307 | static struct w1_family w1_family_23 = { | 304 | static struct w1_family w1_family_23 = { |