2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-28 07:04:00 +08:00

greybus: interface: make attributes type dependent

Make most interface attributes type dependent (e.g only UniPro and
Greybus interfaces should have a DDBL1 Manufacturer ID attribute).

Note that the power attributes (e.g. current_now) will only be visible
for UniPro- and Greybus-type interfaces (i.e. interfaces that can draw
power).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Johan Hovold 2016-07-19 15:24:48 +02:00 committed by Greg Kroah-Hartman
parent 441ac1fa9e
commit 835642526e

View File

@ -538,15 +538,62 @@ static struct attribute *interface_common_attrs[] = {
NULL
};
static umode_t interface_unipro_is_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
struct device *dev = container_of(kobj, struct device, kobj);
struct gb_interface *intf = to_gb_interface(dev);
switch (intf->type) {
case GB_SVC_INTF_TYPE_UNIPRO:
case GB_SVC_INTF_TYPE_GREYBUS:
return attr->mode;
default:
return 0;
}
}
static umode_t interface_greybus_is_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
struct device *dev = container_of(kobj, struct device, kobj);
struct gb_interface *intf = to_gb_interface(dev);
switch (intf->type) {
case GB_SVC_INTF_TYPE_GREYBUS:
return attr->mode;
default:
return 0;
}
}
static umode_t interface_power_is_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
struct device *dev = container_of(kobj, struct device, kobj);
struct gb_interface *intf = to_gb_interface(dev);
switch (intf->type) {
case GB_SVC_INTF_TYPE_UNIPRO:
case GB_SVC_INTF_TYPE_GREYBUS:
return attr->mode;
default:
return 0;
}
}
static const struct attribute_group interface_unipro_group = {
.is_visible = interface_unipro_is_visible,
.attrs = interface_unipro_attrs,
};
static const struct attribute_group interface_greybus_group = {
.is_visible = interface_greybus_is_visible,
.attrs = interface_greybus_attrs,
};
static const struct attribute_group interface_power_group = {
.is_visible = interface_power_is_visible,
.attrs = interface_power_attrs,
};