Commit b37719c3 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

mei: bus: fix drivers and devices names confusion

In the mei bus layer there is use of different variables
of driver and device types with no clear naming convention.
There are generic struct device and struct driver,
then mei_cl_{device, driver}, and finally mei_device which
in this context serves as a bus device.

The patch sets following naming convention:

the variables of type struct device remains dev
the variables of type struct driver remains drv
the variables of type struct mei_cl_device are now cldev
the variables of type struct mei_cl_driver are now cldrv
the variables of type struct mei_device are now bus, in bus
layer context
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 23253c31
This diff is collapsed.
......@@ -240,7 +240,7 @@ struct mei_cl_cb {
* @rd_pending: pending read credits
* @rd_completed: completed read
*
* @device: device on the mei client bus
* @cldev: device on the mei client bus
* @device_link: link to bus clients
*/
struct mei_cl {
......@@ -261,7 +261,7 @@ struct mei_cl {
struct list_head rd_completed;
/* MEI CL bus data */
struct mei_cl_device *device;
struct mei_cl_device *cldev;
struct list_head device_link;
};
......@@ -330,20 +330,20 @@ struct mei_hw_ops {
/* MEI bus API*/
struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
struct mei_cl_device *mei_cl_add_device(struct mei_device *bus,
struct mei_me_client *me_cl,
struct mei_cl *cl,
char *name);
void mei_cl_remove_device(struct mei_cl_device *device);
void mei_cl_remove_device(struct mei_cl_device *cldev);
ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
bool blocking);
ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length);
void mei_cl_bus_rx_event(struct mei_cl *cl);
void mei_cl_bus_remove_devices(struct mei_device *dev);
void mei_cl_bus_remove_devices(struct mei_device *bus);
int mei_cl_bus_init(void);
void mei_cl_bus_exit(void);
struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *dev, uuid_le uuid);
struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *bus, uuid_le uuid);
/**
* enum mei_pg_event - power gating transition events
......
......@@ -152,12 +152,12 @@ static void mei_nfc_free(struct mei_nfc_dev *ndev)
static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev)
{
struct mei_device *dev;
struct mei_device *bus;
if (!ndev->cl)
return -ENODEV;
dev = ndev->cl->dev;
bus = ndev->cl->dev;
switch (ndev->vendor_id) {
case MEI_NFC_VENDOR_INSIDE:
......@@ -167,7 +167,7 @@ static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev)
return 0;
default:
dev_err(dev->dev, "Unknown radio type 0x%x\n",
dev_err(bus->dev, "Unknown radio type 0x%x\n",
ndev->radio_type);
return -EINVAL;
......@@ -179,14 +179,14 @@ static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev)
ndev->bus_name = "pn544";
return 0;
default:
dev_err(dev->dev, "Unknown radio type 0x%x\n",
dev_err(bus->dev, "Unknown radio type 0x%x\n",
ndev->radio_type);
return -EINVAL;
}
default:
dev_err(dev->dev, "Unknown vendor ID 0x%x\n",
dev_err(bus->dev, "Unknown vendor ID 0x%x\n",
ndev->vendor_id);
return -EINVAL;
......@@ -197,7 +197,7 @@ static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev)
static int mei_nfc_if_version(struct mei_nfc_dev *ndev)
{
struct mei_device *dev;
struct mei_device *bus;
struct mei_cl *cl;
struct mei_nfc_cmd cmd;
......@@ -207,7 +207,7 @@ static int mei_nfc_if_version(struct mei_nfc_dev *ndev)
int bytes_recv, ret;
cl = ndev->cl_info;
dev = cl->dev;
bus = cl->dev;
memset(&cmd, 0, sizeof(struct mei_nfc_cmd));
cmd.command = MEI_NFC_CMD_MAINTENANCE;
......@@ -216,7 +216,7 @@ static int mei_nfc_if_version(struct mei_nfc_dev *ndev)
ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(struct mei_nfc_cmd), 1);
if (ret < 0) {
dev_err(dev->dev, "Could not send IF version cmd\n");
dev_err(bus->dev, "Could not send IF version cmd\n");
return ret;
}
......@@ -230,7 +230,7 @@ static int mei_nfc_if_version(struct mei_nfc_dev *ndev)
bytes_recv = __mei_cl_recv(cl, (u8 *)reply, if_version_length);
if (bytes_recv < 0 || bytes_recv < sizeof(struct mei_nfc_reply)) {
dev_err(dev->dev, "Could not read IF version\n");
dev_err(bus->dev, "Could not read IF version\n");
ret = -EIO;
goto err;
}
......@@ -248,7 +248,7 @@ static int mei_nfc_if_version(struct mei_nfc_dev *ndev)
static void mei_nfc_init(struct work_struct *work)
{
struct mei_device *dev;
struct mei_device *bus;
struct mei_cl_device *cldev;
struct mei_nfc_dev *ndev;
struct mei_cl *cl_info;
......@@ -257,57 +257,57 @@ static void mei_nfc_init(struct work_struct *work)
ndev = container_of(work, struct mei_nfc_dev, init_work);
cl_info = ndev->cl_info;
dev = cl_info->dev;
bus = cl_info->dev;
mutex_lock(&dev->device_lock);
mutex_lock(&bus->device_lock);
/* check for valid client id */
me_cl_info = mei_me_cl_by_uuid(dev, &mei_nfc_info_guid);
me_cl_info = mei_me_cl_by_uuid(bus, &mei_nfc_info_guid);
if (!me_cl_info) {
mutex_unlock(&dev->device_lock);
dev_info(dev->dev, "nfc: failed to find the info client\n");
mutex_unlock(&bus->device_lock);
dev_info(bus->dev, "nfc: failed to find the info client\n");
goto err;
}
if (mei_cl_connect(cl_info, me_cl_info, NULL) < 0) {
mei_me_cl_put(me_cl_info);
mutex_unlock(&dev->device_lock);
dev_err(dev->dev, "Could not connect to the NFC INFO ME client");
mutex_unlock(&bus->device_lock);
dev_err(bus->dev, "Could not connect to the NFC INFO ME client");
goto err;
}
mei_me_cl_put(me_cl_info);
mutex_unlock(&dev->device_lock);
mutex_unlock(&bus->device_lock);
if (mei_nfc_if_version(ndev) < 0) {
dev_err(dev->dev, "Could not get the NFC interface version");
dev_err(bus->dev, "Could not get the NFC interface version");
goto err;
}
dev_info(dev->dev, "NFC MEI VERSION: IVN 0x%x Vendor ID 0x%x Type 0x%x\n",
dev_info(bus->dev, "NFC MEI VERSION: IVN 0x%x Vendor ID 0x%x Type 0x%x\n",
ndev->fw_ivn, ndev->vendor_id, ndev->radio_type);
mutex_lock(&dev->device_lock);
mutex_lock(&bus->device_lock);
if (mei_cl_disconnect(cl_info) < 0) {
mutex_unlock(&dev->device_lock);
dev_err(dev->dev, "Could not disconnect the NFC INFO ME client");
mutex_unlock(&bus->device_lock);
dev_err(bus->dev, "Could not disconnect the NFC INFO ME client");
goto err;
}
mutex_unlock(&dev->device_lock);
mutex_unlock(&bus->device_lock);
if (mei_nfc_build_bus_name(ndev) < 0) {
dev_err(dev->dev, "Could not build the bus ID name\n");
dev_err(bus->dev, "Could not build the bus ID name\n");
return;
}
cldev = mei_cl_add_device(dev, ndev->me_cl, ndev->cl,
cldev = mei_cl_add_device(bus, ndev->me_cl, ndev->cl,
ndev->bus_name);
if (!cldev) {
dev_err(dev->dev, "Could not add the NFC device to the MEI bus\n");
dev_err(bus->dev, "Could not add the NFC device to the MEI bus\n");
goto err;
}
......@@ -318,14 +318,14 @@ static void mei_nfc_init(struct work_struct *work)
return;
err:
mutex_lock(&dev->device_lock);
mutex_lock(&bus->device_lock);
mei_nfc_free(ndev);
mutex_unlock(&dev->device_lock);
mutex_unlock(&bus->device_lock);
}
int mei_nfc_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
int mei_nfc_host_init(struct mei_device *bus, struct mei_me_client *me_cl)
{
struct mei_nfc_dev *ndev;
struct mei_cl *cl_info, *cl;
......@@ -335,7 +335,7 @@ int mei_nfc_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
/* in case of internal reset bail out
* as the device is already setup
*/
cl = mei_cl_bus_find_cl_by_uuid(dev, mei_nfc_guid);
cl = mei_cl_bus_find_cl_by_uuid(bus, mei_nfc_guid);
if (cl)
return 0;
......@@ -351,23 +351,23 @@ int mei_nfc_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
goto err;
}
cl_info = mei_cl_alloc_linked(dev, MEI_HOST_CLIENT_ID_ANY);
cl_info = mei_cl_alloc_linked(bus, MEI_HOST_CLIENT_ID_ANY);
if (IS_ERR(cl_info)) {
ret = PTR_ERR(cl_info);
goto err;
}
list_add_tail(&cl_info->device_link, &dev->device_list);
list_add_tail(&cl_info->device_link, &bus->device_list);
ndev->cl_info = cl_info;
cl = mei_cl_alloc_linked(dev, MEI_HOST_CLIENT_ID_ANY);
cl = mei_cl_alloc_linked(bus, MEI_HOST_CLIENT_ID_ANY);
if (IS_ERR(cl)) {
ret = PTR_ERR(cl);
goto err;
}
list_add_tail(&cl->device_link, &dev->device_list);
list_add_tail(&cl->device_link, &bus->device_list);
ndev->cl = cl;
......@@ -382,17 +382,17 @@ int mei_nfc_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
return ret;
}
void mei_nfc_host_exit(struct mei_device *dev)
void mei_nfc_host_exit(struct mei_device *bus)
{
struct mei_nfc_dev *ndev;
struct mei_cl *cl;
struct mei_cl_device *cldev;
cl = mei_cl_bus_find_cl_by_uuid(dev, mei_nfc_guid);
cl = mei_cl_bus_find_cl_by_uuid(bus, mei_nfc_guid);
if (!cl)
return;
cldev = cl->device;
cldev = cl->cldev;
if (!cldev)
return;
......@@ -407,9 +407,9 @@ void mei_nfc_host_exit(struct mei_device *dev)
*/
mei_cl_remove_device(cldev);
mutex_lock(&dev->device_lock);
mutex_lock(&bus->device_lock);
mei_nfc_free(ndev);
mutex_unlock(&dev->device_lock);
mutex_unlock(&bus->device_lock);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment