Commit 38f40982 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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: default avatarEvgeniy Polyakov <zbr@ioremap.net>
Cc: Alexander Stein <alexander.stein@informatik.tu-chemnitz.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b3c6061d
...@@ -93,9 +93,9 @@ static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data, ...@@ -93,9 +93,9 @@ static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data,
} }
#endif /* CONFIG_W1_SLAVE_DS2433_CRC */ #endif /* CONFIG_W1_SLAVE_DS2433_CRC */
static ssize_t w1_f23_read_bin(struct file *filp, struct kobject *kobj, static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, struct bin_attribute *bin_attr, char *buf,
char *buf, loff_t off, size_t count) loff_t off, size_t count)
{ {
struct w1_slave *sl = kobj_to_w1_slave(kobj); struct w1_slave *sl = kobj_to_w1_slave(kobj);
#ifdef CONFIG_W1_SLAVE_DS2433_CRC #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,9 +207,9 @@ static int w1_f23_write(struct w1_slave *sl, int addr, int len, const u8 *data)
return 0; return 0;
} }
static ssize_t w1_f23_write_bin(struct file *filp, struct kobject *kobj, static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, struct bin_attribute *bin_attr, char *buf,
char *buf, loff_t off, size_t count) loff_t off, size_t count)
{ {
struct w1_slave *sl = kobj_to_w1_slave(kobj); struct w1_slave *sl = kobj_to_w1_slave(kobj);
int addr, len, idx; int addr, len, idx;
...@@ -257,19 +257,24 @@ static ssize_t w1_f23_write_bin(struct file *filp, struct kobject *kobj, ...@@ -257,19 +257,24 @@ static ssize_t w1_f23_write_bin(struct file *filp, struct kobject *kobj,
return count; return count;
} }
static struct bin_attribute w1_f23_bin_attr = { static BIN_ATTR_RW(eeprom, W1_EEPROM_SIZE);
.attr = {
.name = "eeprom", static struct bin_attribute *w1_f23_bin_attributes[] = {
.mode = S_IRUGO | S_IWUSR, &bin_attr_eeprom,
}, NULL,
.size = W1_EEPROM_SIZE, };
.read = w1_f23_read_bin,
.write = w1_f23_write_bin, static const struct attribute_group w1_f23_group = {
.bin_attrs = w1_f23_bin_attributes,
};
static const struct attribute_group *w1_f23_groups[] = {
&w1_f23_group,
NULL,
}; };
static int w1_f23_add_slave(struct w1_slave *sl) static int w1_f23_add_slave(struct w1_slave *sl)
{ {
int err;
#ifdef CONFIG_W1_SLAVE_DS2433_CRC #ifdef CONFIG_W1_SLAVE_DS2433_CRC
struct w1_f23_data *data; struct w1_f23_data *data;
...@@ -279,15 +284,7 @@ static int w1_f23_add_slave(struct w1_slave *sl) ...@@ -279,15 +284,7 @@ static int w1_f23_add_slave(struct w1_slave *sl)
sl->family_data = data; sl->family_data = data;
#endif /* CONFIG_W1_SLAVE_DS2433_CRC */ #endif /* CONFIG_W1_SLAVE_DS2433_CRC */
return 0;
err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
#ifdef CONFIG_W1_SLAVE_DS2433_CRC
if (err)
kfree(data);
#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
return err;
} }
static void w1_f23_remove_slave(struct w1_slave *sl) 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,12 +293,12 @@ static void w1_f23_remove_slave(struct w1_slave *sl)
kfree(sl->family_data); kfree(sl->family_data);
sl->family_data = NULL; sl->family_data = NULL;
#endif /* CONFIG_W1_SLAVE_DS2433_CRC */ #endif /* CONFIG_W1_SLAVE_DS2433_CRC */
sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
} }
static struct w1_family_ops w1_f23_fops = { static struct w1_family_ops w1_f23_fops = {
.add_slave = w1_f23_add_slave, .add_slave = w1_f23_add_slave,
.remove_slave = w1_f23_remove_slave, .remove_slave = w1_f23_remove_slave,
.groups = w1_f23_groups,
}; };
static struct w1_family w1_family_23 = { static struct w1_family w1_family_23 = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment