Skip to content

Commit

Permalink
i3c: Add a modalias sysfs attribute
Browse files Browse the repository at this point in the history
Create a modalias sysfs attribute for i3c devices.

Signed-off-by: Boris Brezillon <[email protected]>
Signed-off-by: Vitor Soares <[email protected]>
Link: https://lore.kernel.org/linux-i3c/a90f64f830128cd12762153de7828b775574c156.1582796652.git.vitor.soares@synopsys.com
  • Loading branch information
bbrezillon committed Feb 28, 2020
1 parent 12e21a2 commit 7ec0ddb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions drivers/i3c/master.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,34 @@ static ssize_t hdrcap_show(struct device *dev,
}
static DEVICE_ATTR_RO(hdrcap);

static ssize_t modalias_show(struct device *dev,
struct device_attribute *da, char *buf)
{
struct i3c_device *i3c = dev_to_i3cdev(dev);
struct i3c_device_info devinfo;
u16 manuf, part, ext;

i3c_device_get_info(i3c, &devinfo);
manuf = I3C_PID_MANUF_ID(devinfo.pid);
part = I3C_PID_PART_ID(devinfo.pid);
ext = I3C_PID_EXTRA_INFO(devinfo.pid);

if (I3C_PID_RND_LOWER_32BITS(devinfo.pid))
return sprintf(buf, "i3c:dcr%02Xmanuf%04X", devinfo.dcr,
manuf);

return sprintf(buf, "i3c:dcr%02Xmanuf%04Xpart%04Xext%04X",
devinfo.dcr, manuf, part, ext);
}
static DEVICE_ATTR_RO(modalias);

static struct attribute *i3c_device_attrs[] = {
&dev_attr_bcr.attr,
&dev_attr_dcr.attr,
&dev_attr_pid.attr,
&dev_attr_dynamic_address.attr,
&dev_attr_hdrcap.attr,
&dev_attr_modalias.attr,
NULL,
};
ATTRIBUTE_GROUPS(i3c_device);
Expand Down

0 comments on commit 7ec0ddb

Please sign in to comment.