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]>
---
 drivers/misc/mei/bus.c            | 28 +++++++++++++++++++++-------
 drivers/nfc/microread/mei.c       |  2 +-
 drivers/nfc/pn544/mei.c           |  2 +-
 include/linux/mod_devicetable.h   |  3 +++
 scripts/mod/devicetable-offsets.c |  1 +
 scripts/mod/file2alias.c          |  4 +++-
 6 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index d92017fa1630..38bc4380ad08 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -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;
diff --git a/drivers/nfc/microread/mei.c b/drivers/nfc/microread/mei.c
index f9f5fc97cdd7..93328bd45110 100644
--- a/drivers/nfc/microread/mei.c
+++ b/drivers/nfc/microread/mei.c
@@ -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 */
        { }
diff --git a/drivers/nfc/pn544/mei.c b/drivers/nfc/pn544/mei.c
index 101a37e12efa..80f897b4a401 100644
--- a/drivers/nfc/pn544/mei.c
+++ b/drivers/nfc/pn544/mei.c
@@ -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 */
        { }
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index becda6f6da5c..4f4c65d4a294 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -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;
 };
 
diff --git a/scripts/mod/devicetable-offsets.c 
b/scripts/mod/devicetable-offsets.c
index e70fcd12eeeb..5a6edacc85d9 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -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);
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index fa79d113f34c..9bc2cfe0ee37 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -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, ":*");
 
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to