diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-03-30 11:03:19 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-03-30 11:03:19 -0700 |
commit | c03cb66464742cf4b196b4863e4101b8cf9eb9be (patch) | |
tree | 82ba8b59e83c53692571ac4da0a21fff4e858913 | |
parent | 0f751396346f5cfb6d02abe1985af53717b23c3d (diff) | |
parent | c4b9de11d0101792c4d5458b18581f4f527862d1 (diff) | |
download | linux-c03cb66464742cf4b196b4863e4101b8cf9eb9be.tar.gz linux-c03cb66464742cf4b196b4863e4101b8cf9eb9be.tar.bz2 linux-c03cb66464742cf4b196b4863e4101b8cf9eb9be.zip |
Merge tag 'i3c/for-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux
Pull i3c updates from Boris Brezillon:
- Fix driver auto-probing related issues
- Stop using the deprecated i2c_new_device() function
- Replace zero-length array with flexible-array member
* tag 'i3c/for-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux:
i3c: convert to use i2c_new_client_device()
i3c: master: Replace zero-length array with flexible-array member
i3c: Simplify i3c_device_match_id()
i3c: Generate aliases for i3c modules
i3c: Add a modalias sysfs attribute
i3c: Fix MODALIAS uevents
i3c: master: no need to iterate master device twice
-rw-r--r-- | drivers/i3c/device.c | 50 | ||||
-rw-r--r-- | drivers/i3c/master.c | 28 | ||||
-rw-r--r-- | drivers/i3c/master/dw-i3c-master.c | 2 | ||||
-rw-r--r-- | drivers/i3c/master/i3c-master-cdns.c | 2 | ||||
-rw-r--r-- | scripts/mod/devicetable-offsets.c | 7 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 19 |
6 files changed, 75 insertions, 33 deletions
diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c index 9e2e1406f85e..bb8e60dff988 100644 --- a/drivers/i3c/device.c +++ b/drivers/i3c/device.c @@ -213,40 +213,34 @@ i3c_device_match_id(struct i3c_device *i3cdev, { struct i3c_device_info devinfo; const struct i3c_device_id *id; + u16 manuf, part, ext_info; + bool rndpid; i3c_device_get_info(i3cdev, &devinfo); - /* - * The lower 32bits of the provisional ID is just filled with a random - * value, try to match using DCR info. - */ - if (!I3C_PID_RND_LOWER_32BITS(devinfo.pid)) { - u16 manuf = I3C_PID_MANUF_ID(devinfo.pid); - u16 part = I3C_PID_PART_ID(devinfo.pid); - u16 ext_info = I3C_PID_EXTRA_INFO(devinfo.pid); - - /* First try to match by manufacturer/part ID. */ - for (id = id_table; id->match_flags != 0; id++) { - if ((id->match_flags & I3C_MATCH_MANUF_AND_PART) != - I3C_MATCH_MANUF_AND_PART) - continue; - - if (manuf != id->manuf_id || part != id->part_id) - continue; - - if ((id->match_flags & I3C_MATCH_EXTRA_INFO) && - ext_info != id->extra_info) - continue; - - return id; - } - } + manuf = I3C_PID_MANUF_ID(devinfo.pid); + part = I3C_PID_PART_ID(devinfo.pid); + ext_info = I3C_PID_EXTRA_INFO(devinfo.pid); + rndpid = I3C_PID_RND_LOWER_32BITS(devinfo.pid); - /* Fallback to DCR match. */ for (id = id_table; id->match_flags != 0; id++) { if ((id->match_flags & I3C_MATCH_DCR) && - id->dcr == devinfo.dcr) - return id; + id->dcr != devinfo.dcr) + continue; + + if ((id->match_flags & I3C_MATCH_MANUF) && + id->manuf_id != manuf) + continue; + + if ((id->match_flags & I3C_MATCH_PART) && + (rndpid || id->part_id != part)) + continue; + + if ((id->match_flags & I3C_MATCH_EXTRA_INFO) && + (rndpid || id->extra_info != ext_info)) + continue; + + return id; } return NULL; diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 7f8f896fa0c3..d79cd6d54b3a 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -241,12 +241,34 @@ out: } 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); @@ -267,7 +289,7 @@ static int i3c_device_uevent(struct device *dev, struct kobj_uevent_env *env) devinfo.dcr, manuf); return add_uevent_var(env, - "MODALIAS=i3c:dcr%02Xmanuf%04Xpart%04xext%04x", + "MODALIAS=i3c:dcr%02Xmanuf%04Xpart%04Xext%04X", devinfo.dcr, manuf, part, ext); } @@ -1953,7 +1975,7 @@ of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master, * DEFSLVS command. */ if (boardinfo->base.flags & I2C_CLIENT_TEN) { - dev_err(&master->dev, "I2C device with 10 bit address not supported."); + dev_err(dev, "I2C device with 10 bit address not supported."); return -ENOTSUPP; } @@ -2138,7 +2160,7 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master) * correctly even if one or more i2c devices are not registered. */ i3c_bus_for_each_i2cdev(&master->bus, i2cdev) - i2cdev->dev = i2c_new_device(adap, &i2cdev->boardinfo->base); + i2cdev->dev = i2c_new_client_device(adap, &i2cdev->boardinfo->base); return 0; } diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c index bd26c3b9634e..5c5306cd50ec 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -221,7 +221,7 @@ struct dw_i3c_xfer { struct completion comp; int ret; unsigned int ncmds; - struct dw_i3c_cmd cmds[0]; + struct dw_i3c_cmd cmds[]; }; struct dw_i3c_master { diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c index 54712793709e..3fee8bd7fe20 100644 --- a/drivers/i3c/master/i3c-master-cdns.c +++ b/drivers/i3c/master/i3c-master-cdns.c @@ -388,7 +388,7 @@ struct cdns_i3c_xfer { struct completion comp; int ret; unsigned int ncmds; - struct cdns_i3c_cmd cmds[0]; + struct cdns_i3c_cmd cmds[]; }; struct cdns_i3c_data { diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index 054405b90ba4..d3c237b9b7c0 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -145,6 +145,13 @@ int main(void) DEVID(i2c_device_id); DEVID_FIELD(i2c_device_id, name); + DEVID(i3c_device_id); + DEVID_FIELD(i3c_device_id, match_flags); + DEVID_FIELD(i3c_device_id, dcr); + DEVID_FIELD(i3c_device_id, manuf_id); + DEVID_FIELD(i3c_device_id, part_id); + DEVID_FIELD(i3c_device_id, extra_info); + DEVID(spi_device_id); DEVID_FIELD(spi_device_id, name); diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index c91eba751804..f81cbe021a47 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -919,6 +919,24 @@ static int do_i2c_entry(const char *filename, void *symval, return 1; } +static int do_i3c_entry(const char *filename, void *symval, + char *alias) +{ + DEF_FIELD(symval, i3c_device_id, match_flags); + DEF_FIELD(symval, i3c_device_id, dcr); + DEF_FIELD(symval, i3c_device_id, manuf_id); + DEF_FIELD(symval, i3c_device_id, part_id); + DEF_FIELD(symval, i3c_device_id, extra_info); + + strcpy(alias, "i3c:"); + ADD(alias, "dcr", match_flags & I3C_MATCH_DCR, dcr); + ADD(alias, "manuf", match_flags & I3C_MATCH_MANUF, manuf_id); + ADD(alias, "part", match_flags & I3C_MATCH_PART, part_id); + ADD(alias, "ext", match_flags & I3C_MATCH_EXTRA_INFO, extra_info); + + return 1; +} + /* Looks like: spi:S */ static int do_spi_entry(const char *filename, void *symval, char *alias) @@ -1386,6 +1404,7 @@ static const struct devtable devtable[] = { {"vmbus", SIZE_hv_vmbus_device_id, do_vmbus_entry}, {"rpmsg", SIZE_rpmsg_device_id, do_rpmsg_entry}, {"i2c", SIZE_i2c_device_id, do_i2c_entry}, + {"i3c", SIZE_i3c_device_id, do_i3c_entry}, {"spi", SIZE_spi_device_id, do_spi_entry}, {"dmi", SIZE_dmi_system_id, do_dmi_entry}, {"platform", SIZE_platform_device_id, do_platform_entry}, |