Skip to content

Commit

Permalink
mei: bus: add client protocol version to the device alias
Browse files Browse the repository at this point in the history
The device alias now looks like mei:S:uuid:N:*
In that way we can bind different drivers to clients with
different protocol versions if required.

Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Tomas Winkler authored and gregkh committed Sep 21, 2015
1 parent 40b7320 commit b26864c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
28 changes: 21 additions & 7 deletions drivers/misc/mei/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,17 +453,26 @@ struct mei_cl_device_id *mei_cl_device_find(struct mei_cl_device *cldev,
{
const struct mei_cl_device_id *id;
const uuid_le *uuid;
u8 version;
bool match;

uuid = mei_me_cl_uuid(cldev->me_cl);
version = mei_me_cl_ver(cldev->me_cl);

id = cldrv->id_table;
while (uuid_le_cmp(NULL_UUID_LE, id->uuid)) {
if (!uuid_le_cmp(*uuid, id->uuid)) {
match = true;

if (!cldev->name[0])
return id;
if (cldev->name[0])
if (strncmp(cldev->name, id->name,
sizeof(id->name)))
match = false;

if (!strncmp(cldev->name, id->name, sizeof(id->name)))
if (id->version != MEI_CL_VERSION_ANY)
if (id->version != version)
match = false;
if (match)
return id;
}

Expand Down Expand Up @@ -647,7 +656,8 @@ static int mei_cl_device_uevent(struct device *dev, struct kobj_uevent_env *env)
if (add_uevent_var(env, "MEI_CL_NAME=%s", cldev->name))
return -ENOMEM;

if (add_uevent_var(env, "MODALIAS=mei:%s:%pUl:", cldev->name, uuid))
if (add_uevent_var(env, "MODALIAS=mei:%s:%pUl:%02X:",
cldev->name, uuid, version))
return -ENOMEM;

return 0;
Expand Down Expand Up @@ -737,8 +747,10 @@ static bool mei_cl_dev_setup(struct mei_device *bus,
mei_cl_dev_fixup(cldev);

if (cldev->do_match)
dev_set_name(&cldev->dev, "mei:%s:%pUl",
cldev->name, mei_me_cl_uuid(cldev->me_cl));
dev_set_name(&cldev->dev, "mei:%s:%pUl:%02X",
cldev->name,
mei_me_cl_uuid(cldev->me_cl),
mei_me_cl_ver(cldev->me_cl));

return cldev->do_match == 1;
}
Expand All @@ -754,7 +766,9 @@ static int mei_cl_bus_dev_add(struct mei_cl_device *cldev)
{
int ret;

dev_dbg(cldev->bus->dev, "adding %pUL\n", mei_me_cl_uuid(cldev->me_cl));
dev_dbg(cldev->bus->dev, "adding %pUL:%02X\n",
mei_me_cl_uuid(cldev->me_cl),
mei_me_cl_ver(cldev->me_cl));
ret = device_add(&cldev->dev);
if (!ret)
cldev->is_added = 1;
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/microread/mei.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int microread_mei_remove(struct mei_cl_device *device)
}

static struct mei_cl_device_id microread_mei_tbl[] = {
{ MICROREAD_DRIVER_NAME, MEI_NFC_UUID},
{ MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},

/* required last entry */
{ }
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/pn544/mei.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int pn544_mei_remove(struct mei_cl_device *device)
}

static struct mei_cl_device_id pn544_mei_tbl[] = {
{ PN544_DRIVER_NAME, MEI_NFC_UUID},
{ PN544_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},

/* required last entry */
{ }
Expand Down
3 changes: 3 additions & 0 deletions include/linux/mod_devicetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,18 +601,21 @@ struct ipack_device_id {

#define MEI_CL_MODULE_PREFIX "mei:"
#define MEI_CL_NAME_SIZE 32
#define MEI_CL_VERSION_ANY 0xff

/**
* struct mei_cl_device_id - MEI client device identifier
* @name: helper name
* @uuid: client uuid
* @version: client protocol version
* @driver_info: information used by the driver.
*
* identifies mei client device by uuid and name
*/
struct mei_cl_device_id {
char name[MEI_CL_NAME_SIZE];
uuid_le uuid;
__u8 version;
kernel_ulong_t driver_info;
};

Expand Down
1 change: 1 addition & 0 deletions scripts/mod/devicetable-offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ int main(void)
DEVID(mei_cl_device_id);
DEVID_FIELD(mei_cl_device_id, name);
DEVID_FIELD(mei_cl_device_id, uuid);
DEVID_FIELD(mei_cl_device_id, version);

DEVID(rio_device_id);
DEVID_FIELD(rio_device_id, did);
Expand Down
4 changes: 3 additions & 1 deletion scripts/mod/file2alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,16 +1202,18 @@ static int do_cpu_entry(const char *filename, void *symval, char *alias)
}
ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry);

/* Looks like: mei:S:uuid */
/* Looks like: mei:S:uuid:N:* */
static int do_mei_entry(const char *filename, void *symval,
char *alias)
{
DEF_FIELD_ADDR(symval, mei_cl_device_id, name);
DEF_FIELD_ADDR(symval, mei_cl_device_id, uuid);
DEF_FIELD(symval, mei_cl_device_id, version);

sprintf(alias, MEI_CL_MODULE_PREFIX);
sprintf(alias + strlen(alias), "%s:", (*name)[0] ? *name : "*");
add_uuid(alias, *uuid);
ADD(alias, ":", version != MEI_CL_VERSION_ANY, version);

strcat(alias, ":*");

Expand Down

0 comments on commit b26864c

Please sign in to comment.