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

w1: slaves: w1_ds2780: 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_ds2780.c
··· 89 89 } 90 90 EXPORT_SYMBOL(w1_ds2780_eeprom_cmd); 91 91 92 - static ssize_t w1_ds2780_read_bin(struct file *filp, 93 - struct kobject *kobj, 94 - struct bin_attribute *bin_attr, 95 - char *buf, loff_t off, size_t count) 92 + static ssize_t w1_slave_read(struct file *filp, struct kobject *kobj, 93 + struct bin_attribute *bin_attr, char *buf, 94 + loff_t off, size_t count) 96 95 { 97 96 struct device *dev = container_of(kobj, struct device, kobj); 98 97 return w1_ds2780_io(dev, buf, off, count, 0); 99 98 } 100 99 101 - static struct bin_attribute w1_ds2780_bin_attr = { 102 - .attr = { 103 - .name = "w1_slave", 104 - .mode = S_IRUGO, 105 - }, 106 - .size = DS2780_DATA_SIZE, 107 - .read = w1_ds2780_read_bin, 100 + static BIN_ATTR_RO(w1_slave, DS2780_DATA_SIZE); 101 + 102 + static struct bin_attribute *w1_ds2780_bin_attrs[] = { 103 + &bin_attr_w1_slave, 104 + NULL, 105 + }; 106 + 107 + static const struct attribute_group w1_ds2780_group = { 108 + .bin_attrs = w1_ds2780_bin_attrs, 109 + }; 110 + 111 + static const struct attribute_group *w1_ds2780_groups[] = { 112 + &w1_ds2780_group, 113 + NULL, 108 114 }; 109 115 110 116 static DEFINE_IDA(bat_ida); ··· 138 132 if (ret) 139 133 goto pdev_add_failed; 140 134 141 - ret = sysfs_create_bin_file(&sl->dev.kobj, &w1_ds2780_bin_attr); 142 - if (ret) 143 - goto bin_attr_failed; 144 - 145 135 dev_set_drvdata(&sl->dev, pdev); 146 136 147 137 return 0; 148 138 149 - bin_attr_failed: 150 - platform_device_del(pdev); 151 139 pdev_add_failed: 152 140 platform_device_put(pdev); 153 141 pdev_alloc_failed: ··· 157 157 158 158 platform_device_unregister(pdev); 159 159 ida_simple_remove(&bat_ida, id); 160 - sysfs_remove_bin_file(&sl->dev.kobj, &w1_ds2780_bin_attr); 161 160 } 162 161 163 162 static struct w1_family_ops w1_ds2780_fops = { 164 163 .add_slave = w1_ds2780_add_slave, 165 164 .remove_slave = w1_ds2780_remove_slave, 165 + .groups = w1_ds2780_groups, 166 166 }; 167 167 168 168 static struct w1_family w1_ds2780_family = {