Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

w1: slaves: w1_ds2781: 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>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+18 -18
+18 -18
drivers/w1/slaves/w1_ds2781.c
··· 87 87 } 88 88 EXPORT_SYMBOL(w1_ds2781_eeprom_cmd); 89 89 90 - static ssize_t w1_ds2781_read_bin(struct file *filp, 91 - struct kobject *kobj, 92 - struct bin_attribute *bin_attr, 93 - char *buf, loff_t off, size_t count) 90 + static ssize_t w1_slave_read(struct file *filp, struct kobject *kobj, 91 + struct bin_attribute *bin_attr, char *buf, 92 + loff_t off, size_t count) 94 93 { 95 94 struct device *dev = container_of(kobj, struct device, kobj); 96 95 return w1_ds2781_io(dev, buf, off, count, 0); 97 96 } 98 97 99 - static struct bin_attribute w1_ds2781_bin_attr = { 100 - .attr = { 101 - .name = "w1_slave", 102 - .mode = S_IRUGO, 103 - }, 104 - .size = DS2781_DATA_SIZE, 105 - .read = w1_ds2781_read_bin, 98 + static BIN_ATTR_RO(w1_slave, DS2781_DATA_SIZE); 99 + 100 + static struct bin_attribute *w1_ds2781_bin_attrs[] = { 101 + &bin_attr_w1_slave, 102 + NULL, 103 + }; 104 + 105 + static const struct attribute_group w1_ds2781_group = { 106 + .bin_attrs = w1_ds2781_bin_attrs, 107 + }; 108 + 109 + static const struct attribute_group *w1_ds2781_groups[] = { 110 + &w1_ds2781_group, 111 + NULL, 106 112 }; 107 113 108 114 static DEFINE_IDA(bat_ida); ··· 136 130 if (ret) 137 131 goto pdev_add_failed; 138 132 139 - ret = sysfs_create_bin_file(&sl->dev.kobj, &w1_ds2781_bin_attr); 140 - if (ret) 141 - goto bin_attr_failed; 142 - 143 133 dev_set_drvdata(&sl->dev, pdev); 144 134 145 135 return 0; 146 136 147 - bin_attr_failed: 148 - platform_device_del(pdev); 149 137 pdev_add_failed: 150 138 platform_device_put(pdev); 151 139 pdev_alloc_failed: ··· 155 155 156 156 platform_device_unregister(pdev); 157 157 ida_simple_remove(&bat_ida, id); 158 - sysfs_remove_bin_file(&sl->dev.kobj, &w1_ds2781_bin_attr); 159 158 } 160 159 161 160 static struct w1_family_ops w1_ds2781_fops = { 162 161 .add_slave = w1_ds2781_add_slave, 163 162 .remove_slave = w1_ds2781_remove_slave, 163 + .groups = w1_ds2781_groups, 164 164 }; 165 165 166 166 static struct w1_family w1_ds2781_family = {