return count;
}
-static const struct bin_attribute ds2780_param_eeprom_bin_attr = {
+static struct bin_attribute ds2780_param_eeprom_bin_attr = {
.attr = {
.name = "param_eeprom",
.mode = S_IRUGO | S_IWUSR,
return count;
}
-static const struct bin_attribute ds2780_user_eeprom_bin_attr = {
+static struct bin_attribute ds2780_user_eeprom_bin_attr = {
.attr = {
.name = "user_eeprom",
.mode = S_IRUGO | S_IWUSR,
static DEVICE_ATTR(pio_pin, S_IRUGO | S_IWUSR, ds2780_get_pio_pin,
ds2780_set_pio_pin);
-
static struct attribute *ds2780_sysfs_attrs[] = {
&dev_attr_pmod_enabled.attr,
&dev_attr_sense_resistor_value.attr,
NULL
};
-ATTRIBUTE_GROUPS(ds2780_sysfs);
+static struct bin_attribute *ds2780_sysfs_bin_attrs[] = {
+ &ds2780_param_eeprom_bin_attr,
+ &ds2780_user_eeprom_bin_attr,
+ NULL
+};
+
+static const struct attribute_group ds2780_sysfs_group = {
+ .attrs = ds2780_sysfs_attrs,
+ .bin_attrs = ds2780_sysfs_bin_attrs,
+};
+
+static const struct attribute_group *ds2780_sysfs_groups[] = {
+ &ds2780_sysfs_group,
+ NULL,
+};
static int ds2780_battery_probe(struct platform_device *pdev)
{
struct power_supply_config psy_cfg = {};
- int ret = 0;
struct ds2780_device_info *dev_info;
dev_info = devm_kzalloc(&pdev->dev, sizeof(*dev_info), GFP_KERNEL);
- if (!dev_info) {
- ret = -ENOMEM;
- goto fail;
- }
+ if (!dev_info)
+ return -ENOMEM;
platform_set_drvdata(pdev, dev_info);
&psy_cfg);
if (IS_ERR(dev_info->bat)) {
dev_err(dev_info->dev, "failed to register battery\n");
- ret = PTR_ERR(dev_info->bat);
- goto fail;
- }
-
- ret = sysfs_create_bin_file(&dev_info->bat->dev.kobj,
- &ds2780_param_eeprom_bin_attr);
- if (ret) {
- dev_err(dev_info->dev,
- "failed to create param eeprom bin file");
- goto fail_unregister;
- }
-
- ret = sysfs_create_bin_file(&dev_info->bat->dev.kobj,
- &ds2780_user_eeprom_bin_attr);
- if (ret) {
- dev_err(dev_info->dev,
- "failed to create user eeprom bin file");
- goto fail_remove_bin_file;
+ return PTR_ERR(dev_info->bat);
}
return 0;
-
-fail_remove_bin_file:
- sysfs_remove_bin_file(&dev_info->bat->dev.kobj,
- &ds2780_param_eeprom_bin_attr);
-fail_unregister:
- power_supply_unregister(dev_info->bat);
-fail:
- return ret;
}
static int ds2780_battery_remove(struct platform_device *pdev)