tc1100-wmi - switch to using attribute group
Sysfs attribute group takes care of proper creation of a set of attributes and implements proper error unwinding so the driver does not have to do it. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
committed by
Len Brown
parent
22763c5cf3
commit
0ad3dc3af8
@@ -183,30 +183,15 @@ static DEVICE_ATTR(value, S_IWUGO | S_IRUGO | S_IWUSR, \
|
|||||||
show_set_bool(wireless, TC1100_INSTANCE_WIRELESS);
|
show_set_bool(wireless, TC1100_INSTANCE_WIRELESS);
|
||||||
show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL);
|
show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL);
|
||||||
|
|
||||||
static void remove_fs(void)
|
static struct attribute *tc1100_attributes[] = {
|
||||||
{
|
&dev_attr_wireless.attr,
|
||||||
device_remove_file(&tc1100_device->dev, &dev_attr_wireless);
|
&dev_attr_jogdial.attr,
|
||||||
device_remove_file(&tc1100_device->dev, &dev_attr_jogdial);
|
NULL
|
||||||
}
|
};
|
||||||
|
|
||||||
static int add_fs(void)
|
static struct attribute_group tc1100_attribute_group = {
|
||||||
{
|
.attrs = tc1100_attributes,
|
||||||
int ret;
|
};
|
||||||
|
|
||||||
ret = device_create_file(&tc1100_device->dev, &dev_attr_wireless);
|
|
||||||
if (ret)
|
|
||||||
goto add_sysfs_error;
|
|
||||||
|
|
||||||
ret = device_create_file(&tc1100_device->dev, &dev_attr_jogdial);
|
|
||||||
if (ret)
|
|
||||||
goto add_sysfs_error;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
add_sysfs_error:
|
|
||||||
remove_fs();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
Driver Model
|
Driver Model
|
||||||
@@ -214,16 +199,14 @@ add_sysfs_error:
|
|||||||
|
|
||||||
static int tc1100_probe(struct platform_device *device)
|
static int tc1100_probe(struct platform_device *device)
|
||||||
{
|
{
|
||||||
int result = 0;
|
return sysfs_create_group(&device->dev.kobj, &tc1100_attribute_group);
|
||||||
|
|
||||||
result = add_fs();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int tc1100_remove(struct platform_device *device)
|
static int tc1100_remove(struct platform_device *device)
|
||||||
{
|
{
|
||||||
remove_fs();
|
sysfs_remove_group(&device->dev.kobj, &tc1100_attribute_group);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user