mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
sysfs: Introducing binary attributes for struct class
Added dev_bin_attrs to struct class similar to existing dev_attrs. Signed-off-by: Stefan Achatz <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
This commit is contained in:
parent
a7153258b7
commit
c97415a725
2 changed files with 40 additions and 2 deletions
|
|
@ -338,6 +338,35 @@ static void device_remove_attributes(struct device *dev,
|
|||
device_remove_file(dev, &attrs[i]);
|
||||
}
|
||||
|
||||
static int device_add_bin_attributes(struct device *dev,
|
||||
struct bin_attribute *attrs)
|
||||
{
|
||||
int error = 0;
|
||||
int i;
|
||||
|
||||
if (attrs) {
|
||||
for (i = 0; attr_name(attrs[i]); i++) {
|
||||
error = device_create_bin_file(dev, &attrs[i]);
|
||||
if (error)
|
||||
break;
|
||||
}
|
||||
if (error)
|
||||
while (--i >= 0)
|
||||
device_remove_bin_file(dev, &attrs[i]);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
static void device_remove_bin_attributes(struct device *dev,
|
||||
struct bin_attribute *attrs)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (attrs)
|
||||
for (i = 0; attr_name(attrs[i]); i++)
|
||||
device_remove_bin_file(dev, &attrs[i]);
|
||||
}
|
||||
|
||||
static int device_add_groups(struct device *dev,
|
||||
const struct attribute_group **groups)
|
||||
{
|
||||
|
|
@ -378,12 +407,15 @@ static int device_add_attrs(struct device *dev)
|
|||
error = device_add_attributes(dev, class->dev_attrs);
|
||||
if (error)
|
||||
return error;
|
||||
error = device_add_bin_attributes(dev, class->dev_bin_attrs);
|
||||
if (error)
|
||||
goto err_remove_class_attrs;
|
||||
}
|
||||
|
||||
if (type) {
|
||||
error = device_add_groups(dev, type->groups);
|
||||
if (error)
|
||||
goto err_remove_class_attrs;
|
||||
goto err_remove_class_bin_attrs;
|
||||
}
|
||||
|
||||
error = device_add_groups(dev, dev->groups);
|
||||
|
|
@ -395,6 +427,9 @@ static int device_add_attrs(struct device *dev)
|
|||
err_remove_type_groups:
|
||||
if (type)
|
||||
device_remove_groups(dev, type->groups);
|
||||
err_remove_class_bin_attrs:
|
||||
if (class)
|
||||
device_remove_bin_attributes(dev, class->dev_bin_attrs);
|
||||
err_remove_class_attrs:
|
||||
if (class)
|
||||
device_remove_attributes(dev, class->dev_attrs);
|
||||
|
|
@ -412,8 +447,10 @@ static void device_remove_attrs(struct device *dev)
|
|||
if (type)
|
||||
device_remove_groups(dev, type->groups);
|
||||
|
||||
if (class)
|
||||
if (class) {
|
||||
device_remove_attributes(dev, class->dev_attrs);
|
||||
device_remove_bin_attributes(dev, class->dev_bin_attrs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue