forked from luck/tmp_suning_uos_patched
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>
This commit is contained in:
parent
94c9e6d665
commit
b3c6061dac
|
@ -96,9 +96,9 @@ static int w1_f2d_readblock(struct w1_slave *sl, int off, int count, char *buf)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t w1_f2d_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);
|
||||||
int todo = count;
|
int todo = count;
|
||||||
|
@ -202,9 +202,9 @@ static int w1_f2d_write(struct w1_slave *sl, int addr, int len, const u8 *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t w1_f2d_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;
|
int addr, len;
|
||||||
|
@ -264,29 +264,24 @@ static ssize_t w1_f2d_write_bin(struct file *filp, struct kobject *kobj,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct bin_attribute w1_f2d_bin_attr = {
|
static BIN_ATTR_RW(eeprom, W1_F2D_EEPROM_SIZE);
|
||||||
.attr = {
|
|
||||||
.name = "eeprom",
|
static struct bin_attribute *w1_f2d_bin_attrs[] = {
|
||||||
.mode = S_IRUGO | S_IWUSR,
|
&bin_attr_eeprom,
|
||||||
},
|
NULL,
|
||||||
.size = W1_F2D_EEPROM_SIZE,
|
|
||||||
.read = w1_f2d_read_bin,
|
|
||||||
.write = w1_f2d_write_bin,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int w1_f2d_add_slave(struct w1_slave *sl)
|
static const struct attribute_group w1_f2d_group = {
|
||||||
{
|
.bin_attrs = w1_f2d_bin_attrs,
|
||||||
return sysfs_create_bin_file(&sl->dev.kobj, &w1_f2d_bin_attr);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
static void w1_f2d_remove_slave(struct w1_slave *sl)
|
static const struct attribute_group *w1_f2d_groups[] = {
|
||||||
{
|
&w1_f2d_group,
|
||||||
sysfs_remove_bin_file(&sl->dev.kobj, &w1_f2d_bin_attr);
|
NULL,
|
||||||
}
|
};
|
||||||
|
|
||||||
static struct w1_family_ops w1_f2d_fops = {
|
static struct w1_family_ops w1_f2d_fops = {
|
||||||
.add_slave = w1_f2d_add_slave,
|
.groups = w1_f2d_groups,
|
||||||
.remove_slave = w1_f2d_remove_slave,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct w1_family w1_family_2d = {
|
static struct w1_family w1_family_2d = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user