Messages in this thread | | | Subject | Re: [PATCH 09/15] firmware: arm_scmi: Add scmi protocol version and id device attributes | From | Cristian Marussi <> | Date | Wed, 11 Dec 2019 18:08:43 +0000 |
| |
On 10/12/2019 14:53, Sudeep Holla wrote: > Linux kernel bus driver management layer provides way to add set of > default attributes of the devices on the bus. Using the same, let's add > the scmi per protocol version and id attributes to the sysfs. > > It helps to identify the individual protocol details from the sysfs > entries similar to the SCMI protocol and firmware version. > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> > --- > drivers/firmware/arm_scmi/bus.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c > index f619da2634a6..ed0ed02f7158 100644 > --- a/drivers/firmware/arm_scmi/bus.c > +++ b/drivers/firmware/arm_scmi/bus.c > @@ -92,11 +92,38 @@ static int scmi_dev_remove(struct device *dev) > return 0; > } > > +static ssize_t protocol_version_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct scmi_device *scmi_dev = to_scmi_dev(dev); > + > + return sprintf(buf, "%u.%u\n", PROTOCOL_REV_MAJOR(scmi_dev->version), > + PROTOCOL_REV_MINOR(scmi_dev->version)); > +} > +static DEVICE_ATTR_RO(protocol_version); > +
Similar issue related to proto/device mixup as said. Here bus exposes sysfs attributes depending on an scmi_dev
Cristian
> +static ssize_t protocol_id_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct scmi_device *scmi_dev = to_scmi_dev(dev); > + > + return sprintf(buf, "%u\n", scmi_dev->protocol_id); > +} > +static DEVICE_ATTR_RO(protocol_id); > + > +static struct attribute *versions_attrs[] = { > + &dev_attr_protocol_version.attr, > + &dev_attr_protocol_id.attr, > + NULL, > +}; > +ATTRIBUTE_GROUPS(versions); > + > static struct bus_type scmi_bus_type = { > .name = "scmi_protocol", > .match = scmi_dev_match, > .probe = scmi_dev_probe, > .remove = scmi_dev_remove, > + .dev_groups = versions_groups, > }; > > int scmi_driver_register(struct scmi_driver *driver, struct module *owner, > -- > 2.17.1 >
| |