aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-21 18:45:00 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-22 14:05:43 -0400
commitb3c6061daca33c1e97b8da675a2529fc5d49c05e (patch)
tree2c90434dcfd66cd630d0739d18dea9dcb07aee0a
parent94c9e6d665011a9926c5f6fd349a6c665093e721 (diff)
w1: slaves: w1_ds2431: 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>
-rw-r--r--drivers/w1/slaves/w1_ds2431.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c
index cef8605e43ec..9c4ff9d28adc 100644
--- a/drivers/w1/slaves/w1_ds2431.c
+++ b/drivers/w1/slaves/w1_ds2431.c
@@ -96,9 +96,9 @@ static int w1_f2d_readblock(struct w1_slave *sl, int off, int count, char *buf)
96 return -1; 96 return -1;
97} 97}
98 98
99static ssize_t w1_f2d_read_bin(struct file *filp, struct kobject *kobj, 99static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
100 struct bin_attribute *bin_attr, 100 struct bin_attribute *bin_attr, char *buf,
101 char *buf, loff_t off, size_t count) 101 loff_t off, size_t count)
102{ 102{
103 struct w1_slave *sl = kobj_to_w1_slave(kobj); 103 struct w1_slave *sl = kobj_to_w1_slave(kobj);
104 int todo = count; 104 int todo = count;
@@ -202,9 +202,9 @@ retry:
202 return 0; 202 return 0;
203} 203}
204 204
205static ssize_t w1_f2d_write_bin(struct file *filp, struct kobject *kobj, 205static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
206 struct bin_attribute *bin_attr, 206 struct bin_attribute *bin_attr, char *buf,
207 char *buf, loff_t off, size_t count) 207 loff_t off, size_t count)
208{ 208{
209 struct w1_slave *sl = kobj_to_w1_slave(kobj); 209 struct w1_slave *sl = kobj_to_w1_slave(kobj);
210 int addr, len; 210 int addr, len;
@@ -264,29 +264,24 @@ out_up:
264 return count; 264 return count;
265} 265}
266 266
267static struct bin_attribute w1_f2d_bin_attr = { 267static BIN_ATTR_RW(eeprom, W1_F2D_EEPROM_SIZE);
268 .attr = { 268
269 .name = "eeprom", 269static struct bin_attribute *w1_f2d_bin_attrs[] = {
270 .mode = S_IRUGO | S_IWUSR, 270 &bin_attr_eeprom,
271 }, 271 NULL,
272 .size = W1_F2D_EEPROM_SIZE,
273 .read = w1_f2d_read_bin,
274 .write = w1_f2d_write_bin,
275}; 272};
276 273
277static int w1_f2d_add_slave(struct w1_slave *sl) 274static const struct attribute_group w1_f2d_group = {
278{ 275 .bin_attrs = w1_f2d_bin_attrs,
279 return sysfs_create_bin_file(&sl->dev.kobj, &w1_f2d_bin_attr); 276};
280}
281 277
282static void w1_f2d_remove_slave(struct w1_slave *sl) 278static const struct attribute_group *w1_f2d_groups[] = {
283{ 279 &w1_f2d_group,
284 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f2d_bin_attr); 280 NULL,
285} 281};
286 282
287static struct w1_family_ops w1_f2d_fops = { 283static struct w1_family_ops w1_f2d_fops = {
288 .add_slave = w1_f2d_add_slave, 284 .groups = w1_f2d_groups,
289 .remove_slave = w1_f2d_remove_slave,
290}; 285};
291 286
292static struct w1_family w1_family_2d = { 287static struct w1_family w1_family_2d = {