Skip to content

Commit c03cb66

Browse files
committed
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
2 parents 0f75139 + c4b9de1 commit c03cb66

6 files changed

Lines changed: 75 additions & 33 deletions

File tree

‎drivers/i3c/device.c‎

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -213,40 +213,34 @@ i3c_device_match_id(struct i3c_device *i3cdev,
213213
{
214214
struct i3c_device_info devinfo;
215215
const struct i3c_device_id *id;
216+
u16 manuf, part, ext_info;
217+
bool rndpid;
216218

217219
i3c_device_get_info(i3cdev, &devinfo);
218220

219-
/*
220-
* The lower 32bits of the provisional ID is just filled with a random
221-
* value, try to match using DCR info.
222-
*/
223-
if (!I3C_PID_RND_LOWER_32BITS(devinfo.pid)) {
224-
u16 manuf = I3C_PID_MANUF_ID(devinfo.pid);
225-
u16 part = I3C_PID_PART_ID(devinfo.pid);
226-
u16 ext_info = I3C_PID_EXTRA_INFO(devinfo.pid);
227-
228-
/* First try to match by manufacturer/part ID. */
229-
for (id = id_table; id->match_flags != 0; id++) {
230-
if ((id->match_flags & I3C_MATCH_MANUF_AND_PART) !=
231-
I3C_MATCH_MANUF_AND_PART)
232-
continue;
233-
234-
if (manuf != id->manuf_id || part != id->part_id)
235-
continue;
236-
237-
if ((id->match_flags & I3C_MATCH_EXTRA_INFO) &&
238-
ext_info != id->extra_info)
239-
continue;
240-
241-
return id;
242-
}
243-
}
221+
manuf = I3C_PID_MANUF_ID(devinfo.pid);
222+
part = I3C_PID_PART_ID(devinfo.pid);
223+
ext_info = I3C_PID_EXTRA_INFO(devinfo.pid);
224+
rndpid = I3C_PID_RND_LOWER_32BITS(devinfo.pid);
244225

245-
/* Fallback to DCR match. */
246226
for (id = id_table; id->match_flags != 0; id++) {
247227
if ((id->match_flags & I3C_MATCH_DCR) &&
248-
id->dcr == devinfo.dcr)
249-
return id;
228+
id->dcr != devinfo.dcr)
229+
continue;
230+
231+
if ((id->match_flags & I3C_MATCH_MANUF) &&
232+
id->manuf_id != manuf)
233+
continue;
234+
235+
if ((id->match_flags & I3C_MATCH_PART) &&
236+
(rndpid || id->part_id != part))
237+
continue;
238+
239+
if ((id->match_flags & I3C_MATCH_EXTRA_INFO) &&
240+
(rndpid || id->extra_info != ext_info))
241+
continue;
242+
243+
return id;
250244
}
251245

252246
return NULL;

‎drivers/i3c/master.c‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,34 @@ static ssize_t hdrcap_show(struct device *dev,
241241
}
242242
static DEVICE_ATTR_RO(hdrcap);
243243

244+
static ssize_t modalias_show(struct device *dev,
245+
struct device_attribute *da, char *buf)
246+
{
247+
struct i3c_device *i3c = dev_to_i3cdev(dev);
248+
struct i3c_device_info devinfo;
249+
u16 manuf, part, ext;
250+
251+
i3c_device_get_info(i3c, &devinfo);
252+
manuf = I3C_PID_MANUF_ID(devinfo.pid);
253+
part = I3C_PID_PART_ID(devinfo.pid);
254+
ext = I3C_PID_EXTRA_INFO(devinfo.pid);
255+
256+
if (I3C_PID_RND_LOWER_32BITS(devinfo.pid))
257+
return sprintf(buf, "i3c:dcr%02Xmanuf%04X", devinfo.dcr,
258+
manuf);
259+
260+
return sprintf(buf, "i3c:dcr%02Xmanuf%04Xpart%04Xext%04X",
261+
devinfo.dcr, manuf, part, ext);
262+
}
263+
static DEVICE_ATTR_RO(modalias);
264+
244265
static struct attribute *i3c_device_attrs[] = {
245266
&dev_attr_bcr.attr,
246267
&dev_attr_dcr.attr,
247268
&dev_attr_pid.attr,
248269
&dev_attr_dynamic_address.attr,
249270
&dev_attr_hdrcap.attr,
271+
&dev_attr_modalias.attr,
250272
NULL,
251273
};
252274
ATTRIBUTE_GROUPS(i3c_device);
@@ -267,7 +289,7 @@ static int i3c_device_uevent(struct device *dev, struct kobj_uevent_env *env)
267289
devinfo.dcr, manuf);
268290

269291
return add_uevent_var(env,
270-
"MODALIAS=i3c:dcr%02Xmanuf%04Xpart%04xext%04x",
292+
"MODALIAS=i3c:dcr%02Xmanuf%04Xpart%04Xext%04X",
271293
devinfo.dcr, manuf, part, ext);
272294
}
273295

@@ -1953,7 +1975,7 @@ of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
19531975
* DEFSLVS command.
19541976
*/
19551977
if (boardinfo->base.flags & I2C_CLIENT_TEN) {
1956-
dev_err(&master->dev, "I2C device with 10 bit address not supported.");
1978+
dev_err(dev, "I2C device with 10 bit address not supported.");
19571979
return -ENOTSUPP;
19581980
}
19591981

@@ -2138,7 +2160,7 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
21382160
* correctly even if one or more i2c devices are not registered.
21392161
*/
21402162
i3c_bus_for_each_i2cdev(&master->bus, i2cdev)
2141-
i2cdev->dev = i2c_new_device(adap, &i2cdev->boardinfo->base);
2163+
i2cdev->dev = i2c_new_client_device(adap, &i2cdev->boardinfo->base);
21422164

21432165
return 0;
21442166
}

‎drivers/i3c/master/dw-i3c-master.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ struct dw_i3c_xfer {
221221
struct completion comp;
222222
int ret;
223223
unsigned int ncmds;
224-
struct dw_i3c_cmd cmds[0];
224+
struct dw_i3c_cmd cmds[];
225225
};
226226

227227
struct dw_i3c_master {

‎drivers/i3c/master/i3c-master-cdns.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ struct cdns_i3c_xfer {
388388
struct completion comp;
389389
int ret;
390390
unsigned int ncmds;
391-
struct cdns_i3c_cmd cmds[0];
391+
struct cdns_i3c_cmd cmds[];
392392
};
393393

394394
struct cdns_i3c_data {

‎scripts/mod/devicetable-offsets.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ int main(void)
145145
DEVID(i2c_device_id);
146146
DEVID_FIELD(i2c_device_id, name);
147147

148+
DEVID(i3c_device_id);
149+
DEVID_FIELD(i3c_device_id, match_flags);
150+
DEVID_FIELD(i3c_device_id, dcr);
151+
DEVID_FIELD(i3c_device_id, manuf_id);
152+
DEVID_FIELD(i3c_device_id, part_id);
153+
DEVID_FIELD(i3c_device_id, extra_info);
154+
148155
DEVID(spi_device_id);
149156
DEVID_FIELD(spi_device_id, name);
150157

‎scripts/mod/file2alias.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,24 @@ static int do_i2c_entry(const char *filename, void *symval,
919919
return 1;
920920
}
921921

922+
static int do_i3c_entry(const char *filename, void *symval,
923+
char *alias)
924+
{
925+
DEF_FIELD(symval, i3c_device_id, match_flags);
926+
DEF_FIELD(symval, i3c_device_id, dcr);
927+
DEF_FIELD(symval, i3c_device_id, manuf_id);
928+
DEF_FIELD(symval, i3c_device_id, part_id);
929+
DEF_FIELD(symval, i3c_device_id, extra_info);
930+
931+
strcpy(alias, "i3c:");
932+
ADD(alias, "dcr", match_flags & I3C_MATCH_DCR, dcr);
933+
ADD(alias, "manuf", match_flags & I3C_MATCH_MANUF, manuf_id);
934+
ADD(alias, "part", match_flags & I3C_MATCH_PART, part_id);
935+
ADD(alias, "ext", match_flags & I3C_MATCH_EXTRA_INFO, extra_info);
936+
937+
return 1;
938+
}
939+
922940
/* Looks like: spi:S */
923941
static int do_spi_entry(const char *filename, void *symval,
924942
char *alias)
@@ -1386,6 +1404,7 @@ static const struct devtable devtable[] = {
13861404
{"vmbus", SIZE_hv_vmbus_device_id, do_vmbus_entry},
13871405
{"rpmsg", SIZE_rpmsg_device_id, do_rpmsg_entry},
13881406
{"i2c", SIZE_i2c_device_id, do_i2c_entry},
1407+
{"i3c", SIZE_i3c_device_id, do_i3c_entry},
13891408
{"spi", SIZE_spi_device_id, do_spi_entry},
13901409
{"dmi", SIZE_dmi_system_id, do_dmi_entry},
13911410
{"platform", SIZE_platform_device_id, do_platform_entry},

0 commit comments

Comments
 (0)