Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b26864ca authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman
Browse files

mei: bus: add client protocol version to the device alias



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: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 40b7320e
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -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;
		}

@@ -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;
@@ -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;
}
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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 */
	{ }
+1 −1
Original line number Diff line number Diff line
@@ -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 */
	{ }
+3 −0
Original line number Diff line number Diff line
@@ -601,11 +601,13 @@ 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
@@ -613,6 +615,7 @@ struct ipack_device_id {
struct mei_cl_device_id {
	char name[MEI_CL_NAME_SIZE];
	uuid_le uuid;
	__u8    version;
	kernel_ulong_t driver_info;
};

+1 −0
Original line number Diff line number Diff line
@@ -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);
Loading