linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [char-misc-next 00/12 v3] Add MEI bus and NFC device
@ 2013-02-12 18:36 Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host Samuel Ortiz
                   ` (11 more replies)
  0 siblings, 12 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:36 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

This is take 3 on the MEI bus + NFC device patches addressing Arnd and Greg
comments.

This patch set adds implementation of MEI BUS abstraction
over MEI device, this allows standard Linux device drivers
to access functionality exposed by MEI device that was previously
available only to the user space through /dev/mei

The first exercises is to export the NFC radio

More information can be found under
Documentation/misc-devices/mei/mei-bus.txt

v2 -> v3:
- Renames:
        * mei_device to mei_host. The mei_host pointers are still called *dev
          as I didn't want the first patch to get too fat. 
        * mei_bus_driver to mei_driver
        * mei_bus_client to mei_device

- mei_driver structure changes:
	* name pointer addition
	* MEI id table
	* probe routine now takes the probed MEI id as an argument

- mei-bus.txt update according to the mei_driver changes and the structure
  renaming.
- All exported symbols converted to EXPORT_SYMBOL_GPL.
- to_mei_* macros moved to bus.c
- drivers/misc/mei/bus.h deleted, all API definitions moved to mei_dev.h
- mei_device structure clenup: mei_host, mei_driver, and name fields removed.
- Fixed driver owner: mei_driver_register() is now a macro over
  __mei_driver_register, using THIS_MODULE as the default owner.

Samuel Ortiz (12):
  mei: Rename mei_device to mei_host
  mei: bus: Initial MEI bus type implementation
  mei: bus: Implement driver registration
  mei: bus: Initial implementation for I/O routines
  mei: bus: Add bus related structures to mei_cl
  mei: bus: Call bus routines from the core code
  mei: bus: Synchronous API for the data transmission
  mei: bus: Implement bus driver data setter/getter
  mei: nfc: Initial nfc implementation
  mei: nfc: Connect also the regular ME client
  mei: nfc: Add NFC device to the MEI bus
  mei: nfc: Implement MEI bus IO ops

 Documentation/misc-devices/mei/mei-bus.txt |  138 ++++++++
 drivers/misc/mei/Kconfig                   |    7 +
 drivers/misc/mei/Makefile                  |    2 +
 drivers/misc/mei/amthif.c                  |   30 +-
 drivers/misc/mei/bus.c                     |  475 ++++++++++++++++++++++++++++
 drivers/misc/mei/client.c                  |   40 +--
 drivers/misc/mei/client.h                  |   14 +-
 drivers/misc/mei/hbm.c                     |   28 +-
 drivers/misc/mei/hbm.h                     |   10 +-
 drivers/misc/mei/hw-me.c                   |   42 +--
 drivers/misc/mei/hw-me.h                   |    2 +-
 drivers/misc/mei/init.c                    |    7 +-
 drivers/misc/mei/interrupt.c               |   20 +-
 drivers/misc/mei/main.c                    |   14 +-
 drivers/misc/mei/mei_dev.h                 |  206 ++++++++----
 drivers/misc/mei/nfc.c                     |  459 +++++++++++++++++++++++++++
 drivers/misc/mei/nfc.h                     |  141 +++++++++
 drivers/misc/mei/pci-me.c                  |   31 +-
 drivers/misc/mei/wd.c                      |   20 +-
 include/linux/mei_bus.h                    |  112 +++++++
 20 files changed, 1627 insertions(+), 171 deletions(-)
 create mode 100644 Documentation/misc-devices/mei/mei-bus.txt
 create mode 100644 drivers/misc/mei/bus.c
 create mode 100644 drivers/misc/mei/nfc.c
 create mode 100644 drivers/misc/mei/nfc.h
 create mode 100644 include/linux/mei_bus.h

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
@ 2013-02-12 18:36 ` Samuel Ortiz
  2013-02-12 21:17   ` Winkler, Tomas
  2013-02-12 18:36 ` [char-misc-next 02/12 v3] mei: bus: Initial MEI bus type implementation Samuel Ortiz
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:36 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

In preparation for the MEI bus code merge, we rename the mei_device
structure to mei_host.
struct mei_device will be used for devices on the MEI bus in order to follow
exisiting driver model implementations practices.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
---
 drivers/misc/mei/amthif.c    |   30 ++++++------
 drivers/misc/mei/client.c    |   36 +++++++-------
 drivers/misc/mei/client.h    |   14 +++---
 drivers/misc/mei/hbm.c       |   28 +++++------
 drivers/misc/mei/hbm.h       |   10 ++--
 drivers/misc/mei/hw-me.c     |   42 ++++++++--------
 drivers/misc/mei/hw-me.h     |    2 +-
 drivers/misc/mei/init.c      |    6 +--
 drivers/misc/mei/interrupt.c |   18 +++----
 drivers/misc/mei/main.c      |   14 +++---
 drivers/misc/mei/mei_dev.h   |  110 +++++++++++++++++++++---------------------
 drivers/misc/mei/pci-me.c    |    8 +--
 drivers/misc/mei/wd.c        |   20 ++++----
 13 files changed, 169 insertions(+), 169 deletions(-)

diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index c86d7e3..6f67a0a 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -47,7 +47,7 @@ const uuid_le mei_amthif_guid  = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d,
  *
  * @dev: the device structure
  */
-void mei_amthif_reset_params(struct mei_device *dev)
+void mei_amthif_reset_params(struct mei_host *dev)
 {
 	/* reset iamthif parameters. */
 	dev->iamthif_current_cb = NULL;
@@ -65,7 +65,7 @@ void mei_amthif_reset_params(struct mei_device *dev)
  * @dev: the device structure
  *
  */
-int mei_amthif_host_init(struct mei_device *dev)
+int mei_amthif_host_init(struct mei_host *dev)
 {
 	struct mei_cl *cl = &dev->iamthif_cl;
 	unsigned char *msg_buf;
@@ -129,7 +129,7 @@ int mei_amthif_host_init(struct mei_device *dev)
  *
  * returns   returned a list entry on success, NULL on failure.
  */
-struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
+struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_host *dev,
 						struct file *file)
 {
 	struct mei_cl_cb *pos = NULL;
@@ -162,7 +162,7 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
  *  zero if no data to read,
  *  negative on failure.
  */
-int mei_amthif_read(struct mei_device *dev, struct file *file,
+int mei_amthif_read(struct mei_host *dev, struct file *file,
 	       char __user *ubuf, size_t length, loff_t *offset)
 {
 	int rets;
@@ -274,7 +274,7 @@ out:
  * returns 0 on success, <0 on failure.
  *
  */
-static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
+static int mei_amthif_send_cmd(struct mei_host *dev, struct mei_cl_cb *cb)
 {
 	struct mei_msg_hdr mei_hdr;
 	int ret;
@@ -348,7 +348,7 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
  * returns 0 on success, <0 on failure.
  *
  */
-int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb)
+int mei_amthif_write(struct mei_host *dev, struct mei_cl_cb *cb)
 {
 	int ret;
 
@@ -378,7 +378,7 @@ int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb)
  *
  * returns 0 on success, <0 on failure.
  */
-void mei_amthif_run_next_cmd(struct mei_device *dev)
+void mei_amthif_run_next_cmd(struct mei_host *dev)
 {
 	struct mei_cl_cb *pos = NULL;
 	struct mei_cl_cb *next = NULL;
@@ -414,7 +414,7 @@ void mei_amthif_run_next_cmd(struct mei_device *dev)
 }
 
 
-unsigned int mei_amthif_poll(struct mei_device *dev,
+unsigned int mei_amthif_poll(struct mei_host *dev,
 		struct file *file, poll_table *wait)
 {
 	unsigned int mask = 0;
@@ -443,7 +443,7 @@ unsigned int mei_amthif_poll(struct mei_device *dev,
  *
  * returns 0, OK; otherwise, error.
  */
-int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
+int mei_amthif_irq_write_complete(struct mei_host *dev, s32 *slots,
 			struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list)
 {
 	struct mei_msg_hdr mei_hdr;
@@ -512,7 +512,7 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
  * returns 0 on success, <0 on failure.
  */
 int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
-		struct mei_device *dev, struct mei_msg_hdr *mei_hdr)
+		struct mei_host *dev, struct mei_msg_hdr *mei_hdr)
 {
 	struct mei_cl_cb *cb;
 	unsigned char *buffer;
@@ -564,7 +564,7 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
  *
  * returns 0, OK; otherwise, error.
  */
-int mei_amthif_irq_read(struct mei_device *dev, s32 *slots)
+int mei_amthif_irq_read(struct mei_host *dev, s32 *slots)
 {
 
 	if (((*slots) * sizeof(u32)) < (sizeof(struct mei_msg_hdr)
@@ -593,7 +593,7 @@ int mei_amthif_irq_read(struct mei_device *dev, s32 *slots)
  * @dev: the device structure.
  * @cb_pos: callback block.
  */
-void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)
+void mei_amthif_complete(struct mei_host *dev, struct mei_cl_cb *cb)
 {
 	if (dev->iamthif_canceled != 1) {
 		dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE;
@@ -627,7 +627,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)
  *
  * returns true if callback removed from the list, false otherwise
  */
-static bool mei_clear_list(struct mei_device *dev,
+static bool mei_clear_list(struct mei_host *dev,
 		const struct file *file, struct list_head *mei_cb_list)
 {
 	struct mei_cl_cb *cb_pos = NULL;
@@ -667,7 +667,7 @@ static bool mei_clear_list(struct mei_device *dev,
  *
  * returns true if callback removed from the list, false otherwise
  */
-static bool mei_clear_lists(struct mei_device *dev, struct file *file)
+static bool mei_clear_lists(struct mei_host *dev, struct file *file)
 {
 	bool removed = false;
 
@@ -708,7 +708,7 @@ static bool mei_clear_lists(struct mei_device *dev, struct file *file)
 *
 *  returns 0 on success, <0 on error
 */
-int mei_amthif_release(struct mei_device *dev, struct file *file)
+int mei_amthif_release(struct mei_host *dev, struct file *file)
 {
 	if (dev->open_handle_count > 0)
 		dev->open_handle_count--;
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 1569afe..79eda18 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -31,7 +31,7 @@
  * @dev: mei device
  * returns me client index or -ENOENT if not found
  */
-int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *uuid)
+int mei_me_cl_by_uuid(const struct mei_host *dev, const uuid_le *uuid)
 {
 	int i, res = -ENOENT;
 
@@ -57,7 +57,7 @@ int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *uuid)
  * returns index on success, -ENOENT on failure.
  */
 
-int mei_me_cl_by_id(struct mei_device *dev, u8 client_id)
+int mei_me_cl_by_id(struct mei_host *dev, u8 client_id)
 {
 	int i;
 	for (i = 0; i < dev->me_clients_num; i++)
@@ -209,7 +209,7 @@ int mei_cl_flush_queues(struct mei_cl *cl)
  * @cl: host client to be initialized
  * @dev: mei device
  */
-void mei_cl_init(struct mei_cl *cl, struct mei_device *dev)
+void mei_cl_init(struct mei_cl *cl, struct mei_host *dev)
 {
 	memset(cl, 0, sizeof(struct mei_cl));
 	init_waitqueue_head(&cl->wait);
@@ -227,7 +227,7 @@ void mei_cl_init(struct mei_cl *cl, struct mei_device *dev)
  * @dev: mei device
  * returns  The allocated file or NULL on failure
  */
-struct mei_cl *mei_cl_allocate(struct mei_device *dev)
+struct mei_cl *mei_cl_allocate(struct mei_host *dev)
 {
 	struct mei_cl *cl;
 
@@ -248,7 +248,7 @@ struct mei_cl *mei_cl_allocate(struct mei_device *dev)
  */
 struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl)
 {
-	struct mei_device *dev = cl->dev;
+	struct mei_host *dev = cl->dev;
 	struct mei_cl_cb *cb = NULL;
 	struct mei_cl_cb *next = NULL;
 
@@ -268,7 +268,7 @@ struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl)
  */
 int mei_cl_link(struct mei_cl *cl, int id)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 
 	if (WARN_ON(!cl || !cl->dev))
 		return -EINVAL;
@@ -305,7 +305,7 @@ int mei_cl_link(struct mei_cl *cl, int id)
  */
 int mei_cl_unlink(struct mei_cl *cl)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	struct mei_cl *pos, *next;
 
 	/* don't shout on error exit path */
@@ -332,8 +332,8 @@ int mei_cl_unlink(struct mei_cl *cl)
 
 void mei_host_client_init(struct work_struct *work)
 {
-	struct mei_device *dev = container_of(work,
-					      struct mei_device, init_work);
+	struct mei_host *dev = container_of(work,
+					      struct mei_host, init_work);
 	struct mei_client_properties *client_props;
 	int i;
 
@@ -376,7 +376,7 @@ void mei_host_client_init(struct work_struct *work)
  */
 int mei_cl_disconnect(struct mei_cl *cl)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	struct mei_cl_cb *cb;
 	int rets, err;
 
@@ -448,7 +448,7 @@ free:
  */
 bool mei_cl_is_other_connecting(struct mei_cl *cl)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	struct mei_cl *pos;
 	struct mei_cl *next;
 
@@ -478,7 +478,7 @@ bool mei_cl_is_other_connecting(struct mei_cl *cl)
  */
 int mei_cl_connect(struct mei_cl *cl, struct file *file)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	struct mei_cl_cb *cb;
 	long timeout = mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT);
 	int rets;
@@ -543,7 +543,7 @@ out:
  */
 int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	int i;
 
 	if (WARN_ON(!cl || !cl->dev))
@@ -584,7 +584,7 @@ int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
  */
 int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	int i;
 
 	if (WARN_ON(!cl || !cl->dev))
@@ -622,7 +622,7 @@ int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
  */
 int mei_cl_read_start(struct mei_cl *cl)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	struct mei_cl_cb *cb;
 	int rets;
 	int i;
@@ -682,7 +682,7 @@ err:
  * @dev - mei device
  */
 
-void mei_cl_all_disconnect(struct mei_device *dev)
+void mei_cl_all_disconnect(struct mei_host *dev)
 {
 	struct mei_cl *cl, *next;
 
@@ -700,7 +700,7 @@ void mei_cl_all_disconnect(struct mei_device *dev)
  *
  * @dev  - mei device
  */
-void mei_cl_all_read_wakeup(struct mei_device *dev)
+void mei_cl_all_read_wakeup(struct mei_host *dev)
 {
 	struct mei_cl *cl, *next;
 	list_for_each_entry_safe(cl, next, &dev->file_list, link) {
@@ -716,7 +716,7 @@ void mei_cl_all_read_wakeup(struct mei_device *dev)
 
  * @dev - mei device
  */
-void mei_cl_all_write_clear(struct mei_device *dev)
+void mei_cl_all_write_clear(struct mei_host *dev)
 {
 	struct mei_cl_cb *cb, *next;
 
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
index 214b239..9db03b0 100644
--- a/drivers/misc/mei/client.h
+++ b/drivers/misc/mei/client.h
@@ -24,8 +24,8 @@
 
 #include "mei_dev.h"
 
-int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *cuuid);
-int mei_me_cl_by_id(struct mei_device *dev, u8 client_id);
+int mei_me_cl_by_uuid(const struct mei_host *dev, const uuid_le *cuuid);
+int mei_me_cl_by_id(struct mei_host *dev, u8 client_id);
 
 /*
  * MEI IO Functions
@@ -51,8 +51,8 @@ void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl);
  * MEI Host Client Functions
  */
 
-struct mei_cl *mei_cl_allocate(struct mei_device *dev);
-void mei_cl_init(struct mei_cl *cl, struct mei_device *dev);
+struct mei_cl *mei_cl_allocate(struct mei_host *dev);
+void mei_cl_init(struct mei_cl *cl, struct mei_host *dev);
 
 
 int mei_cl_link(struct mei_cl *cl, int id);
@@ -94,9 +94,9 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file);
 void mei_host_client_init(struct work_struct *work);
 
 
-void mei_cl_all_disconnect(struct mei_device *dev);
-void mei_cl_all_read_wakeup(struct mei_device *dev);
-void mei_cl_all_write_clear(struct mei_device *dev);
+void mei_cl_all_disconnect(struct mei_host *dev);
+void mei_cl_all_read_wakeup(struct mei_host *dev);
+void mei_cl_all_write_clear(struct mei_host *dev);
 
 
 #endif /* _MEI_CLIENT_H_ */
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index fb9e63b..e71eb35 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -30,7 +30,7 @@
  *
  * returns none.
  */
-static void mei_hbm_me_cl_allocate(struct mei_device *dev)
+static void mei_hbm_me_cl_allocate(struct mei_host *dev)
 {
 	struct mei_me_client *clients;
 	int b;
@@ -128,7 +128,7 @@ static bool is_treat_specially_client(struct mei_cl *cl,
  *
  * @dev: the device structure
  */
-void mei_hbm_start_req(struct mei_device *dev)
+void mei_hbm_start_req(struct mei_host *dev)
 {
 	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
 	struct hbm_host_version_request *start_req;
@@ -161,7 +161,7 @@ void mei_hbm_start_req(struct mei_device *dev)
  *
  * returns none.
  */
-static void mei_hbm_enum_clients_req(struct mei_device *dev)
+static void mei_hbm_enum_clients_req(struct mei_host *dev)
 {
 	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
 	struct hbm_host_enum_request *enum_req;
@@ -191,7 +191,7 @@ static void mei_hbm_enum_clients_req(struct mei_device *dev)
  * returns none.
  */
 
-static int mei_hbm_prop_req(struct mei_device *dev)
+static int mei_hbm_prop_req(struct mei_host *dev)
 {
 
 	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
@@ -246,7 +246,7 @@ static int mei_hbm_prop_req(struct mei_device *dev)
  * @mei_hdr - mei message header
  * @data - hbm message body buffer
  */
-static void mei_hbm_stop_req_prepare(struct mei_device *dev,
+static void mei_hbm_stop_req_prepare(struct mei_host *dev,
 		struct mei_msg_hdr *mei_hdr, unsigned char *data)
 {
 	struct hbm_host_stop_request *req =
@@ -268,7 +268,7 @@ static void mei_hbm_stop_req_prepare(struct mei_device *dev,
  *
  * This function returns -EIO on write failure
  */
-int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
+int mei_hbm_cl_flow_control_req(struct mei_host *dev, struct mei_cl *cl)
 {
 	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
 	const size_t len = sizeof(struct hbm_flow_control);
@@ -288,7 +288,7 @@ int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
  * @file: private data ot the file object.
  * @flow: flow control.
  */
-static void mei_hbm_add_single_flow_creds(struct mei_device *dev,
+static void mei_hbm_add_single_flow_creds(struct mei_host *dev,
 				  struct hbm_flow_control *flow)
 {
 	struct mei_me_client *client;
@@ -316,7 +316,7 @@ static void mei_hbm_add_single_flow_creds(struct mei_device *dev,
  * @dev: the device structure
  * @flow_control: flow control response bus message
  */
-static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
+static void mei_hbm_cl_flow_control_res(struct mei_host *dev,
 		struct hbm_flow_control *flow_control)
 {
 	struct mei_cl *cl = NULL;
@@ -350,7 +350,7 @@ static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
  *
  * This function returns -EIO on write failure
  */
-int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
+int mei_hbm_cl_disconnect_req(struct mei_host *dev, struct mei_cl *cl)
 {
 	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
 	const size_t len = sizeof(struct hbm_client_connect_request);
@@ -367,7 +367,7 @@ int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
  * @dev: the device structure
  * @rs: disconnect response bus message
  */
-static void mei_hbm_cl_disconnect_res(struct mei_device *dev,
+static void mei_hbm_cl_disconnect_res(struct mei_host *dev,
 		struct hbm_client_connect_response *rs)
 {
 	struct mei_cl *cl;
@@ -411,7 +411,7 @@ static void mei_hbm_cl_disconnect_res(struct mei_device *dev,
  *
  * returns -EIO on write failure
  */
-int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
+int mei_hbm_cl_connect_req(struct mei_host *dev, struct mei_cl *cl)
 {
 	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
 	const size_t len = sizeof(struct hbm_client_connect_request);
@@ -428,7 +428,7 @@ int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
  * @dev: the device structure
  * @rs: connect response bus message
  */
-static void mei_hbm_cl_connect_res(struct mei_device *dev,
+static void mei_hbm_cl_connect_res(struct mei_host *dev,
 		struct hbm_client_connect_response *rs)
 {
 
@@ -483,7 +483,7 @@ static void mei_hbm_cl_connect_res(struct mei_device *dev,
  * @dev: the device structure.
  * @disconnect_req: disconnect request bus message from the me
  */
-static void mei_hbm_fw_disconnect_req(struct mei_device *dev,
+static void mei_hbm_fw_disconnect_req(struct mei_host *dev,
 		struct hbm_client_connect_request *disconnect_req)
 {
 	struct mei_cl *cl, *next;
@@ -518,7 +518,7 @@ static void mei_hbm_fw_disconnect_req(struct mei_device *dev,
  * @dev: the device structure
  * @mei_hdr: header of bus message
  */
-void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
+void mei_hbm_dispatch(struct mei_host *dev, struct mei_msg_hdr *hdr)
 {
 	struct mei_bus_message *mei_msg;
 	struct mei_me_client *me_client;
diff --git a/drivers/misc/mei/hbm.h b/drivers/misc/mei/hbm.h
index b552afb..ef87c98 100644
--- a/drivers/misc/mei/hbm.h
+++ b/drivers/misc/mei/hbm.h
@@ -17,7 +17,7 @@
 #ifndef _MEI_HBM_H_
 #define _MEI_HBM_H_
 
-void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr);
+void mei_hbm_dispatch(struct mei_host *dev, struct mei_msg_hdr *hdr);
 
 static inline void mei_hbm_hdr(struct mei_msg_hdr *hdr, size_t length)
 {
@@ -28,11 +28,11 @@ static inline void mei_hbm_hdr(struct mei_msg_hdr *hdr, size_t length)
 	hdr->reserved = 0;
 }
 
-void mei_hbm_start_req(struct mei_device *dev);
+void mei_hbm_start_req(struct mei_host *dev);
 
-int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl);
-int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl);
-int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl);
+int mei_hbm_cl_flow_control_req(struct mei_host *dev, struct mei_cl *cl);
+int mei_hbm_cl_disconnect_req(struct mei_host *dev, struct mei_cl *cl);
+int mei_hbm_cl_connect_req(struct mei_host *dev, struct mei_cl *cl);
 
 
 #endif /* _MEI_HBM_H_ */
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
index 45ea718..ebd8621 100644
--- a/drivers/misc/mei/hw-me.c
+++ b/drivers/misc/mei/hw-me.c
@@ -61,7 +61,7 @@ static inline void mei_reg_write(const struct mei_me_hw *hw,
  *
  * returns ME_CB_RW register value (u32)
  */
-static u32 mei_me_mecbrw_read(const struct mei_device *dev)
+static u32 mei_me_mecbrw_read(const struct mei_host *dev)
 {
 	return mei_reg_read(to_me_hw(dev), ME_CB_RW);
 }
@@ -107,7 +107,7 @@ static inline void mei_hcsr_set(struct mei_me_hw *hw, u32 hcsr)
  *
  * @dev: mei device
  */
-static void mei_me_hw_config(struct mei_device *dev)
+static void mei_me_hw_config(struct mei_host *dev)
 {
 	u32 hcsr = mei_hcsr_read(to_me_hw(dev));
 	/* Doesn't change in runtime */
@@ -118,7 +118,7 @@ static void mei_me_hw_config(struct mei_device *dev)
  *
  * @dev: the device structure
  */
-static void mei_me_intr_clear(struct mei_device *dev)
+static void mei_me_intr_clear(struct mei_host *dev)
 {
 	struct mei_me_hw *hw = to_me_hw(dev);
 	u32 hcsr = mei_hcsr_read(hw);
@@ -130,7 +130,7 @@ static void mei_me_intr_clear(struct mei_device *dev)
  *
  * @dev: the device structure
  */
-static void mei_me_intr_enable(struct mei_device *dev)
+static void mei_me_intr_enable(struct mei_host *dev)
 {
 	struct mei_me_hw *hw = to_me_hw(dev);
 	u32 hcsr = mei_hcsr_read(hw);
@@ -143,7 +143,7 @@ static void mei_me_intr_enable(struct mei_device *dev)
  *
  * @dev: the device structure
  */
-static void mei_me_intr_disable(struct mei_device *dev)
+static void mei_me_intr_disable(struct mei_host *dev)
 {
 	struct mei_me_hw *hw = to_me_hw(dev);
 	u32 hcsr = mei_hcsr_read(hw);
@@ -157,7 +157,7 @@ static void mei_me_intr_disable(struct mei_device *dev)
  * @dev: the device structure
  * @interrupts_enabled: if interrupt should be enabled after reset.
  */
-static void mei_me_hw_reset(struct mei_device *dev, bool intr_enable)
+static void mei_me_hw_reset(struct mei_host *dev, bool intr_enable)
 {
 	struct mei_me_hw *hw = to_me_hw(dev);
 	u32 hcsr = mei_hcsr_read(hw);
@@ -190,7 +190,7 @@ static void mei_me_hw_reset(struct mei_device *dev, bool intr_enable)
  * returns bool
  */
 
-static void mei_me_host_set_ready(struct mei_device *dev)
+static void mei_me_host_set_ready(struct mei_host *dev)
 {
 	struct mei_me_hw *hw = to_me_hw(dev);
 	hw->host_hw_state |= H_IE | H_IG | H_RDY;
@@ -202,7 +202,7 @@ static void mei_me_host_set_ready(struct mei_device *dev)
  * @dev - mei device
  * returns bool
  */
-static bool mei_me_host_is_ready(struct mei_device *dev)
+static bool mei_me_host_is_ready(struct mei_host *dev)
 {
 	struct mei_me_hw *hw = to_me_hw(dev);
 	hw->host_hw_state = mei_hcsr_read(hw);
@@ -215,7 +215,7 @@ static bool mei_me_host_is_ready(struct mei_device *dev)
  * @dev - mei device
  * returns bool
  */
-static bool mei_me_hw_is_ready(struct mei_device *dev)
+static bool mei_me_hw_is_ready(struct mei_host *dev)
 {
 	struct mei_me_hw *hw = to_me_hw(dev);
 	hw->me_hw_state = mei_mecsr_read(hw);
@@ -229,7 +229,7 @@ static bool mei_me_hw_is_ready(struct mei_device *dev)
  *
  * returns number of filled slots
  */
-static unsigned char mei_hbuf_filled_slots(struct mei_device *dev)
+static unsigned char mei_hbuf_filled_slots(struct mei_host *dev)
 {
 	struct mei_me_hw *hw = to_me_hw(dev);
 	char read_ptr, write_ptr;
@@ -249,7 +249,7 @@ static unsigned char mei_hbuf_filled_slots(struct mei_device *dev)
  *
  * returns true if empty, false - otherwise.
  */
-static bool mei_me_hbuf_is_empty(struct mei_device *dev)
+static bool mei_me_hbuf_is_empty(struct mei_host *dev)
 {
 	return mei_hbuf_filled_slots(dev) == 0;
 }
@@ -261,7 +261,7 @@ static bool mei_me_hbuf_is_empty(struct mei_device *dev)
  *
  * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count
  */
-static int mei_me_hbuf_empty_slots(struct mei_device *dev)
+static int mei_me_hbuf_empty_slots(struct mei_host *dev)
 {
 	unsigned char filled_slots, empty_slots;
 
@@ -275,7 +275,7 @@ static int mei_me_hbuf_empty_slots(struct mei_device *dev)
 	return empty_slots;
 }
 
-static size_t mei_me_hbuf_max_len(const struct mei_device *dev)
+static size_t mei_me_hbuf_max_len(const struct mei_host *dev)
 {
 	return dev->hbuf_depth * sizeof(u32) - sizeof(struct mei_msg_hdr);
 }
@@ -290,7 +290,7 @@ static size_t mei_me_hbuf_max_len(const struct mei_device *dev)
  *
  * This function returns -EIO if write has failed
  */
-static int mei_me_write_message(struct mei_device *dev,
+static int mei_me_write_message(struct mei_host *dev,
 			struct mei_msg_hdr *header,
 			unsigned char *buf)
 {
@@ -338,7 +338,7 @@ static int mei_me_write_message(struct mei_device *dev,
  *
  * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise filled slots count
  */
-static int mei_me_count_full_read_slots(struct mei_device *dev)
+static int mei_me_count_full_read_slots(struct mei_host *dev)
 {
 	struct mei_me_hw *hw = to_me_hw(dev);
 	char read_ptr, write_ptr;
@@ -365,7 +365,7 @@ static int mei_me_count_full_read_slots(struct mei_device *dev)
  * @buffer: message buffer will be written
  * @buffer_length: message size will be read
  */
-static int mei_me_read_slots(struct mei_device *dev, unsigned char *buffer,
+static int mei_me_read_slots(struct mei_host *dev, unsigned char *buffer,
 		    unsigned long buffer_length)
 {
 	struct mei_me_hw *hw = to_me_hw(dev);
@@ -396,7 +396,7 @@ static int mei_me_read_slots(struct mei_device *dev, unsigned char *buffer,
 
 irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id)
 {
-	struct mei_device *dev = (struct mei_device *) dev_id;
+	struct mei_host *dev = (struct mei_host *) dev_id;
 	struct mei_me_hw *hw = to_me_hw(dev);
 	u32 csr_reg = mei_hcsr_read(hw);
 
@@ -421,7 +421,7 @@ irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id)
  */
 irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)
 {
-	struct mei_device *dev = (struct mei_device *) dev_id;
+	struct mei_host *dev = (struct mei_host *) dev_id;
 	struct mei_cl_cb complete_list;
 	struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
 	struct mei_cl *cl;
@@ -549,11 +549,11 @@ static const struct mei_hw_ops mei_me_hw_ops = {
  *
  * returns The mei_device_device pointer on success, NULL on failure.
  */
-struct mei_device *mei_me_dev_init(struct pci_dev *pdev)
+struct mei_host *mei_me_dev_init(struct pci_dev *pdev)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 
-	dev = kzalloc(sizeof(struct mei_device) +
+	dev = kzalloc(sizeof(struct mei_host) +
 			 sizeof(struct mei_me_hw), GFP_KERNEL);
 	if (!dev)
 		return NULL;
diff --git a/drivers/misc/mei/hw-me.h b/drivers/misc/mei/hw-me.h
index 8518d3e..66d6755 100644
--- a/drivers/misc/mei/hw-me.h
+++ b/drivers/misc/mei/hw-me.h
@@ -34,7 +34,7 @@ struct mei_me_hw {
 
 #define to_me_hw(dev) (struct mei_me_hw *)((dev)->hw)
 
-struct mei_device *mei_me_dev_init(struct pci_dev *pdev);
+struct mei_host *mei_me_dev_init(struct pci_dev *pdev);
 
 /* get slots (dwords) from a message length + header (bytes) */
 static inline unsigned char mei_data2slots(size_t length)
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index 6ec5301..d4b48a7 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -42,7 +42,7 @@ const char *mei_dev_state_str(int state)
 #undef MEI_DEV_STATE
 }
 
-void mei_device_init(struct mei_device *dev)
+void mei_device_init(struct mei_host *dev)
 {
 	/* setup our list array */
 	INIT_LIST_HEAD(&dev->file_list);
@@ -65,7 +65,7 @@ void mei_device_init(struct mei_device *dev)
  *
  * returns 0 on success, <0 on failure.
  */
-int mei_hw_init(struct mei_device *dev)
+int mei_hw_init(struct mei_host *dev)
 {
 	int ret = 0;
 
@@ -133,7 +133,7 @@ err:
  * @dev: the device structure
  * @interrupts_enabled: if interrupt should be enabled after reset.
  */
-void mei_reset(struct mei_device *dev, int interrupts_enabled)
+void mei_reset(struct mei_host *dev, int interrupts_enabled)
 {
 	bool unexpected;
 
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 3535b26..30cc864 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -81,7 +81,7 @@ static int _mei_irq_thread_state_ok(struct mei_cl *cl,
  * returns 0 on success, <0 on failure.
  */
 static int mei_irq_thread_read_client_message(struct mei_cl_cb *complete_list,
-		struct mei_device *dev,
+		struct mei_host *dev,
 		struct mei_msg_hdr *mei_hdr)
 {
 	struct mei_cl *cl;
@@ -148,7 +148,7 @@ quit:
  *
  * returns 0, OK; otherwise, error.
  */
-static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
+static int _mei_irq_thread_close(struct mei_host *dev, s32 *slots,
 				struct mei_cl_cb *cb_pos,
 				struct mei_cl *cl,
 				struct mei_cl_cb *cmpl_list)
@@ -187,7 +187,7 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
  *
  * returns 0, OK; otherwise, error.
  */
-static int _mei_irq_thread_read(struct mei_device *dev,	s32 *slots,
+static int _mei_irq_thread_read(struct mei_host *dev,	s32 *slots,
 			struct mei_cl_cb *cb_pos,
 			struct mei_cl *cl,
 			struct mei_cl_cb *cmpl_list)
@@ -224,7 +224,7 @@ static int _mei_irq_thread_read(struct mei_device *dev,	s32 *slots,
  *
  * returns 0, OK; otherwise, error.
  */
-static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
+static int _mei_irq_thread_ioctl(struct mei_host *dev, s32 *slots,
 			struct mei_cl_cb *cb_pos,
 			struct mei_cl *cl,
 			struct mei_cl_cb *cmpl_list)
@@ -260,7 +260,7 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
  *
  * returns 0, OK; otherwise, error.
  */
-static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots,
+static int mei_irq_thread_write_complete(struct mei_host *dev, s32 *slots,
 			struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list)
 {
 	struct mei_msg_hdr mei_hdr;
@@ -319,7 +319,7 @@ static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots,
  *
  * returns 0 on success, <0 on failure.
  */
-int mei_irq_read_handler(struct mei_device *dev,
+int mei_irq_read_handler(struct mei_host *dev,
 		struct mei_cl_cb *cmpl_list, s32 *slots)
 {
 	struct mei_msg_hdr *mei_hdr;
@@ -419,7 +419,7 @@ end:
  *
  * returns 0 on success, <0 on failure.
  */
-int mei_irq_write_handler(struct mei_device *dev,
+int mei_irq_write_handler(struct mei_host *dev,
 				struct mei_cl_cb *cmpl_list)
 {
 
@@ -577,8 +577,8 @@ void mei_timer(struct work_struct *work)
 	struct mei_cl_cb  *cb_pos = NULL;
 	struct mei_cl_cb  *cb_next = NULL;
 
-	struct mei_device *dev = container_of(work,
-					struct mei_device, timer_work.work);
+	struct mei_host *dev = container_of(work,
+					struct mei_host, timer_work.work);
 
 
 	mutex_lock(&dev->device_lock);
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 903f809..da8cef5 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -56,7 +56,7 @@ static int mei_open(struct inode *inode, struct file *file)
 	struct miscdevice *misc = file->private_data;
 	struct pci_dev *pdev;
 	struct mei_cl *cl;
-	struct mei_device *dev;
+	struct mei_host *dev;
 
 	int err;
 
@@ -117,7 +117,7 @@ static int mei_release(struct inode *inode, struct file *file)
 {
 	struct mei_cl *cl = file->private_data;
 	struct mei_cl_cb *cb;
-	struct mei_device *dev;
+	struct mei_host *dev;
 	int rets = 0;
 
 	if (WARN_ON(!cl || !cl->dev))
@@ -193,7 +193,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
 	struct mei_cl *cl = file->private_data;
 	struct mei_cl_cb *cb_pos = NULL;
 	struct mei_cl_cb *cb = NULL;
-	struct mei_device *dev;
+	struct mei_host *dev;
 	int i;
 	int rets;
 	int err;
@@ -343,7 +343,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 	struct mei_cl *cl = file->private_data;
 	struct mei_cl_cb *write_cb = NULL;
 	struct mei_msg_hdr mei_hdr;
-	struct mei_device *dev;
+	struct mei_host *dev;
 	unsigned long timeout = 0;
 	int rets;
 	int i;
@@ -516,7 +516,7 @@ err:
 static int mei_ioctl_connect_client(struct file *file,
 			struct mei_connect_client_data *data)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	struct mei_client *client;
 	struct mei_cl *cl;
 	int i;
@@ -611,7 +611,7 @@ end:
  */
 static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	struct mei_cl *cl = file->private_data;
 	struct mei_connect_client_data *connect_data = NULL;
 	int rets;
@@ -697,7 +697,7 @@ static long mei_compat_ioctl(struct file *file,
 static unsigned int mei_poll(struct file *file, poll_table *wait)
 {
 	struct mei_cl *cl = file->private_data;
-	struct mei_device *dev;
+	struct mei_host *dev;
 	unsigned int mask = 0;
 
 	if (WARN_ON(!cl || !cl->dev))
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index cb80166..b521313 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -194,7 +194,7 @@ struct mei_cl_cb {
 /* MEI client instance carried as file->pirvate_data*/
 struct mei_cl {
 	struct list_head link;
-	struct mei_device *dev;
+	struct mei_host *dev;
 	enum file_state state;
 	wait_queue_head_t tx_wait;
 	wait_queue_head_t rx_wait;
@@ -237,34 +237,34 @@ struct mei_cl {
  */
 struct mei_hw_ops {
 
-	void (*host_set_ready) (struct mei_device *dev);
-	bool (*host_is_ready) (struct mei_device *dev);
+	void (*host_set_ready) (struct mei_host *dev);
+	bool (*host_is_ready) (struct mei_host *dev);
 
-	bool (*hw_is_ready) (struct mei_device *dev);
-	void (*hw_reset) (struct mei_device *dev, bool enable);
-	void (*hw_config) (struct mei_device *dev);
+	bool (*hw_is_ready) (struct mei_host *dev);
+	void (*hw_reset) (struct mei_host *dev, bool enable);
+	void (*hw_config) (struct mei_host *dev);
 
-	void (*intr_clear) (struct mei_device *dev);
-	void (*intr_enable) (struct mei_device *dev);
-	void (*intr_disable) (struct mei_device *dev);
+	void (*intr_clear) (struct mei_host *dev);
+	void (*intr_enable) (struct mei_host *dev);
+	void (*intr_disable) (struct mei_host *dev);
 
-	int (*hbuf_free_slots) (struct mei_device *dev);
-	bool (*hbuf_is_ready) (struct mei_device *dev);
-	size_t (*hbuf_max_len) (const struct mei_device *dev);
+	int (*hbuf_free_slots) (struct mei_host *dev);
+	bool (*hbuf_is_ready) (struct mei_host *dev);
+	size_t (*hbuf_max_len) (const struct mei_host *dev);
 
-	int (*write)(struct mei_device *dev,
+	int (*write)(struct mei_host *dev,
 		     struct mei_msg_hdr *hdr,
 		     unsigned char *buf);
 
-	int (*rdbuf_full_slots)(struct mei_device *dev);
+	int (*rdbuf_full_slots)(struct mei_host *dev);
 
-	u32 (*read_hdr)(const struct mei_device *dev);
-	int (*read) (struct mei_device *dev,
+	u32 (*read_hdr)(const struct mei_host *dev);
+	int (*read) (struct mei_host *dev,
 		     unsigned char *buf, unsigned long len);
 };
 
 /**
- * struct mei_device -  MEI private device struct
+ * struct mei_host -  MEI private host struct
 
  * @mem_addr - mem mapped base register address
 
@@ -273,7 +273,7 @@ struct mei_hw_ops {
  * @wr_msg - the buffer for hbm control messages
  * @wr_ext_msg - the buffer for hbm control responses (set in read cycle)
  */
-struct mei_device {
+struct mei_host {
 	struct pci_dev *pdev;	/* pointer to pci device struct */
 	/*
 	 * lists of queues
@@ -378,144 +378,144 @@ static inline unsigned long mei_secs_to_jiffies(unsigned long sec)
 /*
  * mei init function prototypes
  */
-void mei_device_init(struct mei_device *dev);
-void mei_reset(struct mei_device *dev, int interrupts);
-int mei_hw_init(struct mei_device *dev);
+void mei_device_init(struct mei_host *dev);
+void mei_reset(struct mei_host *dev, int interrupts);
+int mei_hw_init(struct mei_host *dev);
 
 /*
  *  MEI interrupt functions prototype
  */
 
 void mei_timer(struct work_struct *work);
-int mei_irq_read_handler(struct mei_device *dev,
+int mei_irq_read_handler(struct mei_host *dev,
 		struct mei_cl_cb *cmpl_list, s32 *slots);
 
-int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list);
+int mei_irq_write_handler(struct mei_host *dev, struct mei_cl_cb *cmpl_list);
 
 void mei_irq_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb_pos);
 
 /*
  * AMTHIF - AMT Host Interface Functions
  */
-void mei_amthif_reset_params(struct mei_device *dev);
+void mei_amthif_reset_params(struct mei_host *dev);
 
-int mei_amthif_host_init(struct mei_device *dev);
+int mei_amthif_host_init(struct mei_host *dev);
 
-int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *priv_cb);
+int mei_amthif_write(struct mei_host *dev, struct mei_cl_cb *priv_cb);
 
-int mei_amthif_read(struct mei_device *dev, struct file *file,
+int mei_amthif_read(struct mei_host *dev, struct file *file,
 		char __user *ubuf, size_t length, loff_t *offset);
 
-unsigned int mei_amthif_poll(struct mei_device *dev,
+unsigned int mei_amthif_poll(struct mei_host *dev,
 		struct file *file, poll_table *wait);
 
-int mei_amthif_release(struct mei_device *dev, struct file *file);
+int mei_amthif_release(struct mei_host *dev, struct file *file);
 
-struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
+struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_host *dev,
 						struct file *file);
 
-void mei_amthif_run_next_cmd(struct mei_device *dev);
+void mei_amthif_run_next_cmd(struct mei_host *dev);
 
 
-int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
+int mei_amthif_irq_write_complete(struct mei_host *dev, s32 *slots,
 			struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list);
 
-void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb);
+void mei_amthif_complete(struct mei_host *dev, struct mei_cl_cb *cb);
 int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
-		struct mei_device *dev, struct mei_msg_hdr *mei_hdr);
-int mei_amthif_irq_read(struct mei_device *dev, s32 *slots);
+		struct mei_host *dev, struct mei_msg_hdr *mei_hdr);
+int mei_amthif_irq_read(struct mei_host *dev, s32 *slots);
 
 
-int mei_wd_send(struct mei_device *dev);
-int mei_wd_stop(struct mei_device *dev);
-int mei_wd_host_init(struct mei_device *dev);
+int mei_wd_send(struct mei_host *dev);
+int mei_wd_stop(struct mei_host *dev);
+int mei_wd_host_init(struct mei_host *dev);
 /*
  * mei_watchdog_register  - Registering watchdog interface
  *   once we got connection to the WD Client
  * @dev - mei device
  */
-void mei_watchdog_register(struct mei_device *dev);
+void mei_watchdog_register(struct mei_host *dev);
 /*
  * mei_watchdog_unregister  - Unregistering watchdog interface
  * @dev - mei device
  */
-void mei_watchdog_unregister(struct mei_device *dev);
+void mei_watchdog_unregister(struct mei_host *dev);
 
 /*
  * Register Access Function
  */
 
-static inline void mei_hw_config(struct mei_device *dev)
+static inline void mei_hw_config(struct mei_host *dev)
 {
 	dev->ops->hw_config(dev);
 }
-static inline void mei_hw_reset(struct mei_device *dev, bool enable)
+static inline void mei_hw_reset(struct mei_host *dev, bool enable)
 {
 	dev->ops->hw_reset(dev, enable);
 }
 
-static inline void mei_clear_interrupts(struct mei_device *dev)
+static inline void mei_clear_interrupts(struct mei_host *dev)
 {
 	dev->ops->intr_clear(dev);
 }
 
-static inline void mei_enable_interrupts(struct mei_device *dev)
+static inline void mei_enable_interrupts(struct mei_host *dev)
 {
 	dev->ops->intr_enable(dev);
 }
 
-static inline void mei_disable_interrupts(struct mei_device *dev)
+static inline void mei_disable_interrupts(struct mei_host *dev)
 {
 	dev->ops->intr_disable(dev);
 }
 
-static inline void mei_host_set_ready(struct mei_device *dev)
+static inline void mei_host_set_ready(struct mei_host *dev)
 {
 	dev->ops->host_set_ready(dev);
 }
-static inline bool mei_host_is_ready(struct mei_device *dev)
+static inline bool mei_host_is_ready(struct mei_host *dev)
 {
 	return dev->ops->host_is_ready(dev);
 }
-static inline bool mei_hw_is_ready(struct mei_device *dev)
+static inline bool mei_hw_is_ready(struct mei_host *dev)
 {
 	return dev->ops->hw_is_ready(dev);
 }
 
-static inline bool mei_hbuf_is_ready(struct mei_device *dev)
+static inline bool mei_hbuf_is_ready(struct mei_host *dev)
 {
 	return dev->ops->hbuf_is_ready(dev);
 }
 
-static inline int mei_hbuf_empty_slots(struct mei_device *dev)
+static inline int mei_hbuf_empty_slots(struct mei_host *dev)
 {
 	return dev->ops->hbuf_free_slots(dev);
 }
 
-static inline size_t mei_hbuf_max_len(const struct mei_device *dev)
+static inline size_t mei_hbuf_max_len(const struct mei_host *dev)
 {
 	return dev->ops->hbuf_max_len(dev);
 }
 
-static inline int mei_write_message(struct mei_device *dev,
+static inline int mei_write_message(struct mei_host *dev,
 			struct mei_msg_hdr *hdr,
 			unsigned char *buf)
 {
 	return dev->ops->write(dev, hdr, buf);
 }
 
-static inline u32 mei_read_hdr(const struct mei_device *dev)
+static inline u32 mei_read_hdr(const struct mei_host *dev)
 {
 	return dev->ops->read_hdr(dev);
 }
 
-static inline void mei_read_slots(struct mei_device *dev,
+static inline void mei_read_slots(struct mei_host *dev,
 		     unsigned char *buf, unsigned long len)
 {
 	dev->ops->read(dev, buf, len);
 }
 
-static inline int mei_count_full_read_slots(struct mei_device *dev)
+static inline int mei_count_full_read_slots(struct mei_host *dev)
 {
 	return dev->ops->rdbuf_full_slots(dev);
 }
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index b40ec06..8e88ec0 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -121,7 +121,7 @@ static bool mei_quirk_probe(struct pci_dev *pdev,
  */
 static int mei_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	struct mei_me_hw *hw;
 	int err;
 
@@ -235,7 +235,7 @@ end:
  */
 static void mei_remove(struct pci_dev *pdev)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 	struct mei_me_hw *hw;
 
 	if (mei_pdev != pdev)
@@ -307,7 +307,7 @@ static void mei_remove(struct pci_dev *pdev)
 static int mei_pci_suspend(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
-	struct mei_device *dev = pci_get_drvdata(pdev);
+	struct mei_host *dev = pci_get_drvdata(pdev);
 	int err;
 
 	if (!dev)
@@ -335,7 +335,7 @@ static int mei_pci_suspend(struct device *device)
 static int mei_pci_resume(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
-	struct mei_device *dev;
+	struct mei_host *dev;
 	int err;
 
 	dev = pci_get_drvdata(pdev);
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
index 2413247..51cc54f 100644
--- a/drivers/misc/mei/wd.c
+++ b/drivers/misc/mei/wd.c
@@ -47,7 +47,7 @@ const uuid_le mei_wd_guid = UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, 0x89,
 						0x9D, 0xA9, 0x15, 0x14, 0xCB,
 						0x32, 0xAB);
 
-static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)
+static void mei_wd_set_start_timeout(struct mei_host *dev, u16 timeout)
 {
 	dev_dbg(&dev->pdev->dev, "wd: set timeout=%d.\n", timeout);
 	memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE);
@@ -62,7 +62,7 @@ static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)
  *         -EIO if write has failed
  *         0 on success
  */
-int mei_wd_host_init(struct mei_device *dev)
+int mei_wd_host_init(struct mei_host *dev)
 {
 	struct mei_cl *cl = &dev->wd_cl;
 	int i;
@@ -112,7 +112,7 @@ int mei_wd_host_init(struct mei_device *dev)
  *	-EIO when message send fails
  *	-EINVAL when invalid message is to be sent
  */
-int mei_wd_send(struct mei_device *dev)
+int mei_wd_send(struct mei_host *dev)
 {
 	struct mei_msg_hdr hdr;
 
@@ -141,7 +141,7 @@ int mei_wd_send(struct mei_device *dev)
  *	-EIO when message send fails
  *	-EINVAL when invalid message is to be sent
  */
-int mei_wd_stop(struct mei_device *dev)
+int mei_wd_stop(struct mei_host *dev)
 {
 	int ret;
 
@@ -204,7 +204,7 @@ out:
 static int mei_wd_ops_start(struct watchdog_device *wd_dev)
 {
 	int err = -ENODEV;
-	struct mei_device *dev;
+	struct mei_host *dev;
 
 	dev = watchdog_get_drvdata(wd_dev);
 	if (!dev)
@@ -242,7 +242,7 @@ end_unlock:
  */
 static int mei_wd_ops_stop(struct watchdog_device *wd_dev)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 
 	dev = watchdog_get_drvdata(wd_dev);
 	if (!dev)
@@ -265,7 +265,7 @@ static int mei_wd_ops_stop(struct watchdog_device *wd_dev)
 static int mei_wd_ops_ping(struct watchdog_device *wd_dev)
 {
 	int ret = 0;
-	struct mei_device *dev;
+	struct mei_host *dev;
 
 	dev = watchdog_get_drvdata(wd_dev);
 	if (!dev)
@@ -319,7 +319,7 @@ end:
  */
 static int mei_wd_ops_set_timeout(struct watchdog_device *wd_dev, unsigned int timeout)
 {
-	struct mei_device *dev;
+	struct mei_host *dev;
 
 	dev = watchdog_get_drvdata(wd_dev);
 	if (!dev)
@@ -366,7 +366,7 @@ static struct watchdog_device amt_wd_dev = {
 };
 
 
-void mei_watchdog_register(struct mei_device *dev)
+void mei_watchdog_register(struct mei_host *dev)
 {
 	if (watchdog_register_device(&amt_wd_dev)) {
 		dev_err(&dev->pdev->dev,
@@ -379,7 +379,7 @@ void mei_watchdog_register(struct mei_device *dev)
 	watchdog_set_drvdata(&amt_wd_dev, dev);
 }
 
-void mei_watchdog_unregister(struct mei_device *dev)
+void mei_watchdog_unregister(struct mei_host *dev)
 {
 	if (watchdog_get_drvdata(&amt_wd_dev) == NULL)
 		return;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 02/12 v3] mei: bus: Initial MEI bus type implementation
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host Samuel Ortiz
@ 2013-02-12 18:36 ` Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 03/12 v3] mei: bus: Implement driver registration Samuel Ortiz
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:36 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

mei bus will present some of the me clients
as devices for other standard subsystems

Implement the probe, remove, match and the device addtion routines.
A mei-bus.txt document describing the rationale and the API usage
is also added.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 Documentation/misc-devices/mei/mei-bus.txt |  138 +++++++++++++++++++++++++
 drivers/misc/mei/Makefile                  |    1 +
 drivers/misc/mei/bus.c                     |  151 ++++++++++++++++++++++++++++
 drivers/misc/mei/mei_dev.h                 |   27 +++++
 include/linux/mei_bus.h                    |   92 +++++++++++++++++
 5 files changed, 409 insertions(+)
 create mode 100644 Documentation/misc-devices/mei/mei-bus.txt
 create mode 100644 drivers/misc/mei/bus.c
 create mode 100644 include/linux/mei_bus.h

diff --git a/Documentation/misc-devices/mei/mei-bus.txt b/Documentation/misc-devices/mei/mei-bus.txt
new file mode 100644
index 0000000..1558343
--- /dev/null
+++ b/Documentation/misc-devices/mei/mei-bus.txt
@@ -0,0 +1,138 @@
+Intel(R) Management Engine (ME) bus API
+=======================================
+
+
+Rationale
+=========
+While a misc character device is useful for applications to send and receive
+data to the many IP blocks found in Intel's ME, kernel drivers rely on the
+device model to be probed.
+By adding a kernel virtual bus abstraction on top of the MEI driver we can
+implement drivers for the various MEI features as standalone ones, found in
+their respective subsystem. Existing drivers can even potentially be re-used
+by adding an MEI bus layer to the existing code.
+
+
+MEI bus API
+===========
+A driver implementation for an MEI IP block is very similar to existing bus
+based device drivers. The driver registers itself as an MEI bus driver through
+the mei_driver structure:
+
+struct mei_driver {
+	struct device_driver driver;
+	const char *name;
+
+	const struct mei_id *id_table;
+
+	int (*probe)(struct mei_device *dev, const struct mei_id *id);
+	int (*remove)(struct mei_device *dev);
+};
+
+struct mei_id {
+	char name[MEI_NAME_SIZE];
+	uuid_le uuid;
+};
+
+The mei_id structure allows the driver to bind itself against an ME UUID and a
+device name. There typically is one ME UUID per technology and the mei_id name
+field matches a specific device name within that technology. As an example,
+the ME supports several NFC devices: All of them have the same ME UUID but the
+ME bus code will assign each of them a different name.
+
+To actually register a driver on the ME bus one must call the mei_add_driver()
+API. This is typically called at module init time.
+
+Once registered on the ME bus, a driver will typically try to do some I/O on
+this bus and this should be done through the mei_send() and mei_recv()
+routines. The latter is synchronous (blocks and sleeps until data shows up).
+In order for drivers to be notified of pending events waiting for them (e.g.
+an Rx event) they can register an event handler through the
+mei_register_event_cb() routine. Currently only the MEI_EVENT_RX event
+will trigger an event handler call and the driver implementation is supposed
+to call mei_recv() from the event handler in order to fetch the pending
+received buffers.
+
+
+Example
+=======
+As a theoretical example let's pretend the ME comes with a "contact" NFC IP.
+The driver init and exit routines for this device would look like:
+
+#define CONTACT_DRIVER_NAME "contact"
+
+#define NFC_UUID UUID_LE(0x0bb17a78, 0x2a8e, 0x4c50, 0x94, \
+			       0xd4, 0x50, 0x26, 0x67, 0x23, 0x77, 0x5c)
+
+static struct mei_id contact_mei_tbl[] = {
+	{ CONTACT_DRIVER_NAME, NFC_UUID },
+
+	/* required last entry */
+	{ }
+};
+
+static struct mei_driver contact_driver = {
+       .id_table = contact_mei_tbl,
+       .name = CONTACT_DRIVER_NAME,
+
+       .probe = contact_probe,
+       .remove = contact_remove,
+};
+
+static int contact_init(void)
+{
+	int r;
+
+	r = mei_driver_register(&contact_driver);
+	if (r) {
+		pr_err(CONTACT_DRIVER_NAME ": driver registration failed\n");
+		return r;
+	}
+
+	return 0;
+}
+
+static void __exit contact_exit(void)
+{
+	mei_driver_unregister(&contact_driver);
+}
+
+module_init(contact_init);
+module_exit(contact_exit);
+
+And the driver's simplified probe routine would look like that:
+
+int contact_probe(struct mei_device *dev, struct mei_id *id)
+{
+	struct contact_driver *contact;
+
+	[...]
+	mei_register_event_cb(dev, contact_event_cb, contact);
+
+	return 0;
+ }
+
+In the probe routine the driver basically registers an ME bus event handler
+which is as close as it can get to registering a threaded IRQ handler.
+The handler implementation will typically call some I/O routine depending on
+the pending events:
+
+#define MAX_NFC_PAYLOAD 128
+
+static void contact_event_cb(struct mei_device *dev, u32 events,
+			     void *context)
+{
+	struct contact_driver *contact = context;
+
+	if (events & BIT(MEI_EVENT_RX)) {
+		u8 payload[MAX_NFC_PAYLOAD];
+		int payload_size;
+
+		payload_size = mei_recv(dev, payload, MAX_NFC_PAYLOAD);
+		if (payload_size <= 0)
+			return;
+
+		/* Hook to the NFC subsystem */
+		nfc_hci_recv_frame(contact->hdev, payload, payload_size);
+	}
+}
diff --git a/drivers/misc/mei/Makefile b/drivers/misc/mei/Makefile
index 040af6c..5948621 100644
--- a/drivers/misc/mei/Makefile
+++ b/drivers/misc/mei/Makefile
@@ -10,5 +10,6 @@ mei-objs += client.o
 mei-objs += main.o
 mei-objs += amthif.o
 mei-objs += wd.o
+mei-objs += bus.o
 mei-$(CONFIG_INTEL_MEI_ME) += pci-me.o
 mei-$(CONFIG_INTEL_MEI_ME) += hw-me.o
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
new file mode 100644
index 0000000..485fcf3c
--- /dev/null
+++ b/drivers/misc/mei/bus.c
@@ -0,0 +1,151 @@
+/*
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2012, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/mei_bus.h>
+
+#include "mei_dev.h"
+
+#define to_mei_driver(d) container_of(d, struct mei_driver, driver)
+#define to_mei_device(d) container_of(d, struct mei_device, dev)
+
+static int mei_device_match(struct device *dev, struct device_driver *drv)
+{
+	struct mei_device *device = to_mei_device(dev);
+	struct mei_driver *driver = to_mei_driver(drv);
+	const struct mei_id *id;
+
+	if (!device)
+		return 0;
+
+	if (!driver || !driver->id_table)
+		return 0;
+
+	id = driver->id_table;
+
+	while (id->name[0]) {
+		if (!uuid_le_cmp(device->uuid, id->uuid) &&
+		    !strcmp(dev_name(dev), id->name))
+			return 1;
+
+		id++;
+	}
+
+	return 0;
+}
+
+static int mei_device_probe(struct device *dev)
+{
+	struct mei_device *device = to_mei_device(dev);
+	struct mei_driver *driver;
+	struct mei_id id;
+
+	if (!device)
+		return 0;
+
+	driver = to_mei_driver(dev->driver);
+	if (!driver || !driver->probe)
+		return -ENODEV;
+
+	dev_dbg(dev, "Device probe\n");
+
+	id.uuid = device->uuid;
+	strncpy(id.name, dev_name(dev), MEI_NAME_SIZE);
+
+	return driver->probe(device, &id);
+}
+
+static int mei_device_remove(struct device *dev)
+{
+	struct mei_device *device = to_mei_device(dev);
+	struct mei_driver *driver;
+
+	if (!device || !dev->driver)
+		return 0;
+
+	driver = to_mei_driver(dev->driver);
+	if (!driver->remove) {
+		dev->driver = NULL;
+
+		return 0;
+	}
+
+	return driver->remove(device);
+}
+
+static struct bus_type mei_bus_type = {
+	.name		= "mei",
+	.match		= mei_device_match,
+	.probe		= mei_device_probe,
+	.remove		= mei_device_remove,
+};
+
+static void mei_client_dev_release(struct device *dev)
+{
+	kfree(to_mei_device(dev));
+}
+
+static struct device_type mei_client_type = {
+	.release	= mei_client_dev_release,
+};
+
+struct mei_device *mei_add_device(struct mei_host *mei_host,
+				  uuid_le uuid, char *name)
+{
+	struct mei_device *device;
+	int status;
+
+	device = kzalloc(sizeof(struct mei_device), GFP_KERNEL);
+	if (!device)
+		return NULL;
+
+	device->uuid = uuid;
+
+	device->dev.parent = &mei_host->pdev->dev;
+	device->dev.bus = &mei_bus_type;
+	device->dev.type = &mei_client_type;
+
+	dev_set_name(&device->dev, "%s", name);
+
+	status = device_register(&device->dev);
+	if (status)
+		goto out_err;
+
+	dev_dbg(&device->dev, "client %s registered\n", name);
+
+	return device;
+
+out_err:
+	dev_err(device->dev.parent, "Failed to register MEI client\n");
+
+	kfree(device);
+
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(mei_add_device);
+
+void mei_remove_device(struct mei_device *device)
+{
+	device_unregister(&device->dev);
+}
+EXPORT_SYMBOL_GPL(mei_remove_device);
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index b521313..5f65617 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -21,6 +21,7 @@
 #include <linux/watchdog.h>
 #include <linux/poll.h>
 #include <linux/mei.h>
+#include <linux/mei_bus.h>
 
 #include "hw.h"
 #include "hw-me-regs.h"
@@ -263,6 +264,32 @@ struct mei_hw_ops {
 		     unsigned char *buf, unsigned long len);
 };
 
+/* MEI bus API*/
+struct mei_device *mei_add_device(struct mei_host *mei_host,
+				  uuid_le uuid, char *name);
+void mei_remove_device(struct mei_device *device);
+
+/**
+ * struct mei_device - MEI device handle
+ * An mei_device pointer is returned from mei_add_device()
+ * and links MEI bus clients to their actual ME host client pointer.
+ * Drivers for MEI devices will get an mei_device pointer
+ * when being probed and shall use it for doing ME bus I/O.
+ *
+ * @dev: linux driver model device pointer
+ * @uuid: me client uuid
+ * @cl: mei client
+ * @priv_data: client private data
+ */
+struct mei_device {
+	struct device dev;
+
+	uuid_le uuid;
+	struct mei_cl *cl;
+
+	void *priv_data;
+};
+
 /**
  * struct mei_host -  MEI private host struct
 
diff --git a/include/linux/mei_bus.h b/include/linux/mei_bus.h
new file mode 100644
index 0000000..6506cb7
--- /dev/null
+++ b/include/linux/mei_bus.h
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Intel MEI Interface Header
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.
+ *
+ * Contact Information:
+ *	Intel Corporation.
+ *	linux-mei@linux.intel.com
+ *	http://www.intel.com
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+
+#ifndef _LINUX_MEI_BUS_H
+#define _LINUX_MEI_BUS_H
+
+#include <linux/device.h>
+#include <linux/uuid.h>
+
+struct mei_device;
+
+#define MEI_NAME_SIZE 32
+
+struct mei_id {
+	char name[MEI_NAME_SIZE];
+	uuid_le uuid;
+};
+
+struct mei_driver {
+	struct device_driver driver;
+	const char *name;
+
+	const struct mei_id *id_table;
+
+	int (*probe)(struct mei_device *dev, const struct mei_id *id);
+	int (*remove)(struct mei_device *dev);
+};
+
+#endif /* _LINUX_MEI_BUS_H */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 03/12 v3] mei: bus: Implement driver registration
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 02/12 v3] mei: bus: Initial MEI bus type implementation Samuel Ortiz
@ 2013-02-12 18:36 ` Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 04/12 v3] mei: bus: Initial implementation for I/O routines Samuel Ortiz
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:36 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/bus.c  |   26 ++++++++++++++++++++++++++
 include/linux/mei_bus.h |    6 ++++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 485fcf3c..04e7ada 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -149,3 +149,29 @@ void mei_remove_device(struct mei_device *device)
 	device_unregister(&device->dev);
 }
 EXPORT_SYMBOL_GPL(mei_remove_device);
+
+int __mei_driver_register(struct mei_driver *driver, struct module *owner)
+{
+	int err;
+
+	driver->driver.name = driver->name;
+	driver->driver.owner = owner;
+	driver->driver.bus = &mei_bus_type;
+
+	err = driver_register(&driver->driver);
+	if (err)
+		return err;
+
+	pr_debug("mei: driver [%s] registered\n", driver->driver.name);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(__mei_driver_register);
+
+void mei_driver_unregister(struct mei_driver *driver)
+{
+	driver_unregister(&driver->driver);
+
+	pr_debug("mei: driver [%s] unregistered\n", driver->driver.name);
+}
+EXPORT_SYMBOL_GPL(mei_driver_unregister);
diff --git a/include/linux/mei_bus.h b/include/linux/mei_bus.h
index 6506cb7..28be556 100644
--- a/include/linux/mei_bus.h
+++ b/include/linux/mei_bus.h
@@ -89,4 +89,10 @@ struct mei_driver {
 	int (*remove)(struct mei_device *dev);
 };
 
+int __mei_driver_register(struct mei_driver *driver, struct module *owner);
+#define mei_driver_register(driver)             \
+	__mei_driver_register(driver, THIS_MODULE)
+
+void mei_driver_unregister(struct mei_driver *driver);
+
 #endif /* _LINUX_MEI_BUS_H */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 04/12 v3] mei: bus: Initial implementation for I/O routines
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
                   ` (2 preceding siblings ...)
  2013-02-12 18:36 ` [char-misc-next 03/12 v3] mei: bus: Implement driver registration Samuel Ortiz
@ 2013-02-12 18:36 ` Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 05/12 v3] mei: bus: Add bus related structures to mei_cl Samuel Ortiz
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:36 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/bus.c     |  226 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/mei/mei_dev.h |   28 ++++++
 include/linux/mei_bus.h    |   11 +++
 3 files changed, 265 insertions(+)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 04e7ada..7229d3e 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
+#include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
@@ -25,6 +26,8 @@
 #include <linux/mei_bus.h>
 
 #include "mei_dev.h"
+#include "hw-me.h"
+#include "client.h"
 
 #define to_mei_driver(d) container_of(d, struct mei_driver, driver)
 #define to_mei_device(d) container_of(d, struct mei_device, dev)
@@ -83,6 +86,11 @@ static int mei_device_remove(struct device *dev)
 	if (!device || !dev->driver)
 		return 0;
 
+	if (device->event_cb) {
+		device->event_cb = NULL;
+		cancel_work_sync(&device->event_work);
+	}
+
 	driver = to_mei_driver(dev->driver);
 	if (!driver->remove) {
 		dev->driver = NULL;
@@ -175,3 +183,221 @@ void mei_driver_unregister(struct mei_driver *driver)
 	pr_debug("mei: driver [%s] unregistered\n", driver->driver.name);
 }
 EXPORT_SYMBOL_GPL(mei_driver_unregister);
+
+int __mei_send(struct mei_cl *cl, u8 *buf, size_t length)
+{
+	struct mei_host *dev;
+	struct mei_msg_hdr mei_hdr;
+	struct mei_cl_cb *cb;
+	int me_cl_id, err;
+
+	if (WARN_ON(!cl || !cl->dev))
+		return -ENODEV;
+
+	if (cl->state != MEI_FILE_CONNECTED)
+		return -ENODEV;
+
+	cb = mei_io_cb_init(cl, NULL);
+	if (!cb)
+		return -ENOMEM;
+
+	err = mei_io_cb_alloc_req_buf(cb, length);
+	if (err < 0) {
+		mei_io_cb_free(cb);
+		return err;
+	}
+
+	memcpy(cb->request_buffer.data, buf, length);
+	cb->fop_type = MEI_FOP_WRITE;
+
+	dev = cl->dev;
+
+	mutex_lock(&dev->device_lock);
+
+	/* Check if we have an ME client device */
+	me_cl_id = mei_me_cl_by_id(dev, cl->me_client_id);
+	if (me_cl_id == dev->me_clients_num) {
+		err = -ENODEV;
+		goto out_err;
+	}
+
+	if (length > dev->me_clients[me_cl_id].props.max_msg_length) {
+		err = -EINVAL;
+		goto out_err;
+	}
+
+	err = mei_cl_flow_ctrl_creds(cl);
+	if (err < 0)
+		goto out_err;
+
+	/* Host buffer is not ready, we queue the request */
+	if (err == 0 || !dev->hbuf_is_ready) {
+		cb->buf_idx = 0;
+		mei_hdr.msg_complete = 0;
+		cl->writing_state = MEI_WRITING;
+		list_add_tail(&cb->list, &dev->write_list.list);
+
+		mutex_unlock(&dev->device_lock);
+
+		return length;
+	}
+
+	dev->hbuf_is_ready = false;
+
+	/* Check for a maximum length */
+	if (length > mei_hbuf_max_len(dev)) {
+		mei_hdr.length = mei_hbuf_max_len(dev);
+		mei_hdr.msg_complete = 0;
+	} else {
+		mei_hdr.length = length;
+		mei_hdr.msg_complete = 1;
+	}
+
+	mei_hdr.host_addr = cl->host_client_id;
+	mei_hdr.me_addr = cl->me_client_id;
+	mei_hdr.reserved = 0;
+
+	if (mei_write_message(dev, &mei_hdr, buf)) {
+		err = -EIO;
+		goto out_err;
+	}
+
+	cl->writing_state = MEI_WRITING;
+	cb->buf_idx = mei_hdr.length;
+
+	if (!mei_hdr.msg_complete) {
+		list_add_tail(&cb->list, &dev->write_list.list);
+	} else {
+		if (mei_cl_flow_ctrl_reduce(cl)) {
+			err = -EIO;
+			goto out_err;
+		}
+
+		list_add_tail(&cb->list, &dev->write_waiting_list.list);
+	}
+
+	mutex_unlock(&dev->device_lock);
+
+	return mei_hdr.length;
+
+out_err:
+	mutex_unlock(&dev->device_lock);
+	mei_io_cb_free(cb);
+
+	return err;
+}
+
+int __mei_recv(struct mei_cl *cl, u8 *buf, size_t length)
+{
+	struct mei_host *dev;
+	struct mei_cl_cb *cb;
+	size_t r_length;
+	int err;
+
+	if (WARN_ON(!cl || !cl->dev))
+		return -ENODEV;
+
+	dev = cl->dev;
+
+	mutex_lock(&dev->device_lock);
+
+	if (!cl->read_cb) {
+		err = mei_cl_read_start(cl);
+		if (err < 0) {
+			mutex_unlock(&dev->device_lock);
+			return err;
+		}
+	}
+
+	if (cl->reading_state != MEI_READ_COMPLETE &&
+	    !waitqueue_active(&cl->rx_wait)) {
+		mutex_unlock(&dev->device_lock);
+
+		if (wait_event_interruptible(cl->rx_wait,
+				(MEI_READ_COMPLETE == cl->reading_state))) {
+			if (signal_pending(current))
+				return -EINTR;
+			return -ERESTARTSYS;
+		}
+
+		mutex_lock(&dev->device_lock);
+	}
+
+	cb = cl->read_cb;
+
+	if (cl->reading_state != MEI_READ_COMPLETE) {
+		r_length = 0;
+		goto out;
+	}
+
+	r_length = min_t(size_t, length, cb->buf_idx);
+
+	memcpy(buf, cb->response_buffer.data, r_length);
+
+	mei_io_cb_free(cb);
+	cl->reading_state = MEI_IDLE;
+	cl->read_cb = NULL;
+
+out:
+	mutex_unlock(&dev->device_lock);
+
+	return r_length;
+}
+
+int mei_send(struct mei_device *device, u8 *buf, size_t length)
+{
+	struct mei_cl *cl = NULL;
+
+	/* TODO: hook between mei_bus_client and mei_cl */
+
+	if (device->ops && device->ops->send)
+		return device->ops->send(device, buf, length);
+
+	return __mei_send(cl, buf, length);
+}
+EXPORT_SYMBOL_GPL(mei_send);
+
+int mei_recv(struct mei_device *device, u8 *buf, size_t length)
+{
+	struct mei_cl *cl = NULL;
+
+	/* TODO: hook between mei_bus_client and mei_cl */
+
+	if (device->ops && device->ops->recv)
+		return device->ops->recv(device, buf, length);
+
+	return __mei_recv(cl, buf, length);
+}
+EXPORT_SYMBOL_GPL(mei_recv);
+
+static void mei_bus_event_work(struct work_struct *work)
+{
+	struct mei_device *device;
+
+	device = container_of(work, struct mei_device, event_work);
+
+	if (device->event_cb)
+		device->event_cb(device, device->events, device->event_context);
+
+	device->events = 0;
+
+	/* Prepare for the next read */
+	mei_cl_read_start(device->cl);
+}
+
+int mei_register_event_cb(struct mei_device *device,
+			  mei_event_cb_t event_cb, void *context)
+{
+	if (device->event_cb)
+		return -EALREADY;
+
+	device->events = 0;
+	device->event_cb = event_cb;
+	device->event_context = context;
+	INIT_WORK(&device->event_work, mei_bus_event_work);
+
+	mei_cl_read_start(device->cl);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(mei_register_event_cb);
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 5f65617..ee75343 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -268,6 +268,23 @@ struct mei_hw_ops {
 struct mei_device *mei_add_device(struct mei_host *mei_host,
 				  uuid_le uuid, char *name);
 void mei_remove_device(struct mei_device *device);
+int __mei_send(struct mei_cl *cl, u8 *buf, size_t length);
+int __mei_recv(struct mei_cl *cl, u8 *buf, size_t length);
+
+/**
+ * struct mei_transport_ops - MEI device transport ops
+ * This structure allows ME host clients to implement technology
+ * specific transport layers.
+ *
+ * @send: Tx hook for the device. This allows ME host clients to trap
+ *	the device driver buffers before actually physically pushing it to the ME.
+ * @recv: Rx hook for the device. This allows ME host clients to trap the
+ *	ME buffers before forwarding them to the device driver.
+ */
+struct mei_transport_ops {
+	int (*send)(struct mei_device *device, u8 *buf, size_t length);
+	int (*recv)(struct mei_device *device, u8 *buf, size_t length);
+};
 
 /**
  * struct mei_device - MEI device handle
@@ -279,6 +296,10 @@ void mei_remove_device(struct mei_device *device);
  * @dev: linux driver model device pointer
  * @uuid: me client uuid
  * @cl: mei client
+ * @ops: ME transport ops
+ * @event_cb: Drivers register this callback to get asynchronous ME
+ *	events (e.g. Rx buffer pending) notifications.
+ * @events: Events bitmask sent to the driver.
  * @priv_data: client private data
  */
 struct mei_device {
@@ -287,6 +308,13 @@ struct mei_device {
 	uuid_le uuid;
 	struct mei_cl *cl;
 
+	const struct mei_transport_ops *ops;
+
+	struct work_struct event_work;
+	mei_event_cb_t event_cb;
+	void *event_context;
+	unsigned long events;
+
 	void *priv_data;
 };
 
diff --git a/include/linux/mei_bus.h b/include/linux/mei_bus.h
index 28be556..4ce6301 100644
--- a/include/linux/mei_bus.h
+++ b/include/linux/mei_bus.h
@@ -89,10 +89,21 @@ struct mei_driver {
 	int (*remove)(struct mei_device *dev);
 };
 
+#define MEI_EVENT_RX 0
+#define MEI_EVENT_TX 1
+
 int __mei_driver_register(struct mei_driver *driver, struct module *owner);
 #define mei_driver_register(driver)             \
 	__mei_driver_register(driver, THIS_MODULE)
 
 void mei_driver_unregister(struct mei_driver *driver);
 
+int mei_send(struct mei_device *device, u8 *buf, size_t length);
+int mei_recv(struct mei_device *device, u8 *buf, size_t length);
+
+typedef void (*mei_event_cb_t)(struct mei_device *device,
+			       u32 events, void *context);
+int mei_register_event_cb(struct mei_device *device,
+			  mei_event_cb_t read_cb, void *context);
+
 #endif /* _LINUX_MEI_BUS_H */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 05/12 v3] mei: bus: Add bus related structures to mei_cl
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
                   ` (3 preceding siblings ...)
  2013-02-12 18:36 ` [char-misc-next 04/12 v3] mei: bus: Initial implementation for I/O routines Samuel Ortiz
@ 2013-02-12 18:36 ` Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 06/12 v3] mei: bus: Call bus routines from the core code Samuel Ortiz
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:36 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

We keep track of all MEI devices on the bus through a specific linked list.
We also have a mei_device instance in the mei_cl structure.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/bus.c     |   46 +++++++++++++++++++++++++++++++-------------
 drivers/misc/mei/client.c  |    1 +
 drivers/misc/mei/init.c    |    1 +
 drivers/misc/mei/mei_dev.h |    8 ++++++++
 4 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 7229d3e..0d8caec 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -117,17 +117,37 @@ static struct device_type mei_client_type = {
 	.release	= mei_client_dev_release,
 };
 
+static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_host *mei_dev,
+						  uuid_le uuid)
+{
+	struct mei_cl *cl, *next;
+
+	list_for_each_entry_safe(cl, next,
+				 &mei_dev->device_list, device_link) {
+		if (!uuid_le_cmp(uuid, cl->device_uuid))
+			return cl;
+	}
+
+	return NULL;
+}
+
 struct mei_device *mei_add_device(struct mei_host *mei_host,
 				  uuid_le uuid, char *name)
 {
 	struct mei_device *device;
+	struct mei_cl *cl;
 	int status;
 
+	cl = mei_bus_find_mei_cl_by_uuid(mei_host, uuid);
+	if (cl == NULL)
+		return NULL;
+
 	device = kzalloc(sizeof(struct mei_device), GFP_KERNEL);
 	if (!device)
 		return NULL;
 
 	device->uuid = uuid;
+	device->cl = cl;
 
 	device->dev.parent = &mei_host->pdev->dev;
 	device->dev.bus = &mei_bus_type;
@@ -136,19 +156,17 @@ struct mei_device *mei_add_device(struct mei_host *mei_host,
 	dev_set_name(&device->dev, "%s", name);
 
 	status = device_register(&device->dev);
-	if (status)
-		goto out_err;
+	if (status) {
+		kfree(device);
+		dev_err(device->dev.parent, "Failed to register MEI device\n");
+		return NULL;
+	}
+
+	cl->device = device;
 
 	dev_dbg(&device->dev, "client %s registered\n", name);
 
 	return device;
-
-out_err:
-	dev_err(device->dev.parent, "Failed to register MEI client\n");
-
-	kfree(device);
-
-	return NULL;
 }
 EXPORT_SYMBOL_GPL(mei_add_device);
 
@@ -346,9 +364,10 @@ out:
 
 int mei_send(struct mei_device *device, u8 *buf, size_t length)
 {
-	struct mei_cl *cl = NULL;
+	struct mei_cl *cl = device->cl;
 
-	/* TODO: hook between mei_bus_client and mei_cl */
+	if (cl == NULL)
+		return -ENODEV;
 
 	if (device->ops && device->ops->send)
 		return device->ops->send(device, buf, length);
@@ -359,9 +378,10 @@ EXPORT_SYMBOL_GPL(mei_send);
 
 int mei_recv(struct mei_device *device, u8 *buf, size_t length)
 {
-	struct mei_cl *cl = NULL;
+	struct mei_cl *cl =  device->cl;
 
-	/* TODO: hook between mei_bus_client and mei_cl */
+	if (cl == NULL)
+		return -ENODEV;
 
 	if (device->ops && device->ops->recv)
 		return device->ops->recv(device, buf, length);
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 79eda18..ef5300a 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -216,6 +216,7 @@ void mei_cl_init(struct mei_cl *cl, struct mei_host *dev)
 	init_waitqueue_head(&cl->rx_wait);
 	init_waitqueue_head(&cl->tx_wait);
 	INIT_LIST_HEAD(&cl->link);
+	INIT_LIST_HEAD(&cl->device_link);
 	cl->reading_state = MEI_IDLE;
 	cl->writing_state = MEI_IDLE;
 	cl->dev = dev;
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index d4b48a7..6fb4a9e 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -46,6 +46,7 @@ void mei_device_init(struct mei_host *dev)
 {
 	/* setup our list array */
 	INIT_LIST_HEAD(&dev->file_list);
+	INIT_LIST_HEAD(&dev->device_list);
 	mutex_init(&dev->device_lock);
 	init_waitqueue_head(&dev->wait_recvd_msg);
 	init_waitqueue_head(&dev->wait_stop_wd);
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index ee75343..45d008b 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -210,6 +210,11 @@ struct mei_cl {
 	enum mei_file_transaction_states writing_state;
 	int sm_state;
 	struct mei_cl_cb *read_cb;
+
+	/* MEI bus data */
+	struct mei_device *device;
+	struct list_head device_link;
+	uuid_le device_uuid;
 };
 
 /** struct mei_hw_ops
@@ -420,6 +425,9 @@ struct mei_host {
 
 	struct work_struct init_work;
 
+	/* List of bus devices */
+	struct list_head device_list;
+
 	const struct mei_hw_ops *ops;
 	char hw[0] __aligned(sizeof(void *));
 };
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 06/12 v3] mei: bus: Call bus routines from the core code
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
                   ` (4 preceding siblings ...)
  2013-02-12 18:36 ` [char-misc-next 05/12 v3] mei: bus: Add bus related structures to mei_cl Samuel Ortiz
@ 2013-02-12 18:36 ` Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 07/12 v3] mei: bus: Synchronous API for the data transmission Samuel Ortiz
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:36 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

Register the MEI bus type against the kernel core bus APIs and
call the bus Rx handler from interrupt.c

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/bus.c       |   22 ++++++++++++++++++++++
 drivers/misc/mei/interrupt.c |    2 ++
 drivers/misc/mei/mei_dev.h   |    4 ++++
 drivers/misc/mei/pci-me.c    |   21 +++++++++++++++++++--
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 0d8caec..4565e9a 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -421,3 +421,25 @@ int mei_register_event_cb(struct mei_device *device,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(mei_register_event_cb);
+
+void mei_bus_rx_event(struct mei_cl *cl)
+{
+	struct mei_device *device = cl->device;
+
+	if (!device || !device->event_cb)
+		return;
+
+	set_bit(MEI_EVENT_RX, &device->events);
+
+	schedule_work(&device->event_work);
+}
+
+int __init mei_bus_init(struct pci_dev *pdev)
+{
+	return bus_register(&mei_bus_type);
+}
+
+void __exit mei_bus_exit(void)
+{
+	bus_unregister(&mei_bus_type);
+}
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 30cc864..9acfcaf 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -49,6 +49,8 @@ void mei_irq_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb_pos)
 		cl->reading_state = MEI_READ_COMPLETE;
 		if (waitqueue_active(&cl->rx_wait))
 			wake_up_interruptible(&cl->rx_wait);
+		else
+			mei_bus_rx_event(cl);
 
 	}
 }
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 45d008b..546cd87 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -437,6 +437,10 @@ static inline unsigned long mei_secs_to_jiffies(unsigned long sec)
 	return msecs_to_jiffies(sec * MSEC_PER_SEC);
 }
 
+void mei_bus_rx_event(struct mei_cl *cl);
+int mei_bus_init(struct pci_dev *pdev);
+void mei_bus_exit(void);
+
 
 /*
  * mei init function prototypes
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index 8e88ec0..e31090f 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -197,7 +197,6 @@ static int mei_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	mei_pdev = pdev;
 	pci_set_drvdata(pdev, dev);
 
-
 	schedule_delayed_work(&dev->timer_work, HZ);
 
 	mutex_unlock(&mei_mutex);
@@ -389,7 +388,25 @@ static struct pci_driver mei_driver = {
 	.driver.pm = MEI_PM_OPS,
 };
 
-module_pci_driver(mei_driver);
+static int __init mei_init(void)
+{
+	int err;
+
+	err = mei_bus_init(mei_pdev);
+	if (err)
+		return err;
+
+	return pci_register_driver(&mei_driver);
+}
+
+static void __exit mei_exit(void)
+{
+	pci_unregister_driver(&mei_driver);
+	mei_bus_exit();
+}
+
+module_init(mei_init);
+module_exit(mei_exit);
 
 MODULE_AUTHOR("Intel Corporation");
 MODULE_DESCRIPTION("Intel(R) Management Engine Interface");
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 07/12 v3] mei: bus: Synchronous API for the data transmission
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
                   ` (5 preceding siblings ...)
  2013-02-12 18:36 ` [char-misc-next 06/12 v3] mei: bus: Call bus routines from the core code Samuel Ortiz
@ 2013-02-12 18:36 ` Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 08/12 v3] mei: bus: Implement bus driver data setter/getter Samuel Ortiz
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:36 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

Define a truly synchronous API for the bus Tx path by putting all pending
request to the write list and wait for the interrupt tx handler to wake
us up.
The ___mei_send() out path is also slightly reworked to make it look more
like main.c:mei_write().

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/bus.c     |   38 ++++++++++++++++++++++++++++----------
 drivers/misc/mei/mei_dev.h |    1 +
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 4565e9a..85ca872 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -202,7 +202,7 @@ void mei_driver_unregister(struct mei_driver *driver)
 }
 EXPORT_SYMBOL_GPL(mei_driver_unregister);
 
-int __mei_send(struct mei_cl *cl, u8 *buf, size_t length)
+static int ___mei_send(struct mei_cl *cl, u8 *buf, size_t length, bool blocking)
 {
 	struct mei_host *dev;
 	struct mei_msg_hdr mei_hdr;
@@ -253,11 +253,8 @@ int __mei_send(struct mei_cl *cl, u8 *buf, size_t length)
 		cb->buf_idx = 0;
 		mei_hdr.msg_complete = 0;
 		cl->writing_state = MEI_WRITING;
-		list_add_tail(&cb->list, &dev->write_list.list);
-
-		mutex_unlock(&dev->device_lock);
 
-		return length;
+		goto out;
 	}
 
 	dev->hbuf_is_ready = false;
@@ -283,19 +280,30 @@ int __mei_send(struct mei_cl *cl, u8 *buf, size_t length)
 	cl->writing_state = MEI_WRITING;
 	cb->buf_idx = mei_hdr.length;
 
-	if (!mei_hdr.msg_complete) {
-		list_add_tail(&cb->list, &dev->write_list.list);
-	} else {
+out:
+	if (mei_hdr.msg_complete) {
 		if (mei_cl_flow_ctrl_reduce(cl)) {
-			err = -EIO;
+			err = -ENODEV;
 			goto out_err;
 		}
-
 		list_add_tail(&cb->list, &dev->write_waiting_list.list);
+	} else {
+		list_add_tail(&cb->list, &dev->write_list.list);
 	}
 
 	mutex_unlock(&dev->device_lock);
 
+	if (blocking && cl->writing_state != MEI_WRITE_COMPLETE) {
+		if (wait_event_interruptible(cl->tx_wait,
+			cl->writing_state == MEI_WRITE_COMPLETE)) {
+				if (signal_pending(current))
+					err = -EINTR;
+			err = -ERESTARTSYS;
+			mutex_lock(&dev->device_lock);
+			goto out_err;
+		}
+	}
+
 	return mei_hdr.length;
 
 out_err:
@@ -362,6 +370,16 @@ out:
 	return r_length;
 }
 
+inline int __mei_async_send(struct mei_cl *cl, u8 *buf, size_t length)
+{
+	return ___mei_send(cl, buf, length, 0);
+}
+
+inline int __mei_send(struct mei_cl *cl, u8 *buf, size_t length)
+{
+	return ___mei_send(cl, buf, length, 1);
+}
+
 int mei_send(struct mei_device *device, u8 *buf, size_t length)
 {
 	struct mei_cl *cl = device->cl;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 546cd87..fc485d4 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -273,6 +273,7 @@ struct mei_hw_ops {
 struct mei_device *mei_add_device(struct mei_host *mei_host,
 				  uuid_le uuid, char *name);
 void mei_remove_device(struct mei_device *device);
+int __mei_async_send(struct mei_cl *cl, u8 *buf, size_t length);
 int __mei_send(struct mei_cl *cl, u8 *buf, size_t length);
 int __mei_recv(struct mei_cl *cl, u8 *buf, size_t length);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 08/12 v3] mei: bus: Implement bus driver data setter/getter
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
                   ` (6 preceding siblings ...)
  2013-02-12 18:36 ` [char-misc-next 07/12 v3] mei: bus: Synchronous API for the data transmission Samuel Ortiz
@ 2013-02-12 18:36 ` Samuel Ortiz
  2013-02-12 18:36 ` [char-misc-next 09/12 v3] mei: nfc: Initial nfc implementation Samuel Ortiz
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:36 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

MEI drivers should be able to carry their private data around.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/bus.c  |   12 ++++++++++++
 include/linux/mei_bus.h |    3 +++
 2 files changed, 15 insertions(+)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 85ca872..163da66 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -440,6 +440,18 @@ int mei_register_event_cb(struct mei_device *device,
 }
 EXPORT_SYMBOL_GPL(mei_register_event_cb);
 
+void *mei_get_clientdata(const struct mei_device *device)
+{
+	return dev_get_drvdata(&device->dev);
+}
+EXPORT_SYMBOL_GPL(mei_get_clientdata);
+
+void mei_set_clientdata(struct mei_device *device, void *data)
+{
+	dev_set_drvdata(&device->dev, data);
+}
+EXPORT_SYMBOL_GPL(mei_set_clientdata);
+
 void mei_bus_rx_event(struct mei_cl *cl)
 {
 	struct mei_device *device = cl->device;
diff --git a/include/linux/mei_bus.h b/include/linux/mei_bus.h
index 4ce6301..e14182a 100644
--- a/include/linux/mei_bus.h
+++ b/include/linux/mei_bus.h
@@ -106,4 +106,7 @@ typedef void (*mei_event_cb_t)(struct mei_device *device,
 int mei_register_event_cb(struct mei_device *device,
 			  mei_event_cb_t read_cb, void *context);
 
+void *mei_get_clientdata(const struct mei_device *device);
+void mei_set_clientdata(struct mei_device *device, void *data);
+
 #endif /* _LINUX_MEI_BUS_H */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 09/12 v3] mei: nfc: Initial nfc implementation
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
                   ` (7 preceding siblings ...)
  2013-02-12 18:36 ` [char-misc-next 08/12 v3] mei: bus: Implement bus driver data setter/getter Samuel Ortiz
@ 2013-02-12 18:36 ` Samuel Ortiz
  2013-02-12 18:37 ` [char-misc-next 10/12 v3] mei: nfc: Connect also the regular ME client Samuel Ortiz
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:36 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

NFC ME device is exported through the MEI bus to be consumed by the
NFC subsystem.

NFC is represented by two mei clients: An info one and the actual
NFC one. In order to properly build the ME id we first need to retrieve
the firmware information from the info client.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/Kconfig   |    7 ++
 drivers/misc/mei/Makefile  |    1 +
 drivers/misc/mei/client.c  |    3 +
 drivers/misc/mei/mei_dev.h |   28 ++++++
 drivers/misc/mei/nfc.c     |  209 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/mei/nfc.h     |  122 ++++++++++++++++++++++++++
 drivers/misc/mei/pci-me.c  |    2 +
 7 files changed, 372 insertions(+)
 create mode 100644 drivers/misc/mei/nfc.c
 create mode 100644 drivers/misc/mei/nfc.h

diff --git a/drivers/misc/mei/Kconfig b/drivers/misc/mei/Kconfig
index d21b4d0..66e84ef 100644
--- a/drivers/misc/mei/Kconfig
+++ b/drivers/misc/mei/Kconfig
@@ -35,3 +35,10 @@ config INTEL_MEI_ME
 	  82Q33 Express
 	  82X38/X48 Express
 
+config INTEL_MEI_BUS_NFC
+        bool "MEI bus NFC support"
+        depends on INTEL_MEI
+	help
+	  When selecting this option the ME NFC device will be added to the
+	  MEI bus. This is needed by the NFC kernel subsystem for sending and
+	  receiving HCI frames to and from the NFC device.
diff --git a/drivers/misc/mei/Makefile b/drivers/misc/mei/Makefile
index 5948621..644f92e 100644
--- a/drivers/misc/mei/Makefile
+++ b/drivers/misc/mei/Makefile
@@ -11,5 +11,6 @@ mei-objs += main.o
 mei-objs += amthif.o
 mei-objs += wd.o
 mei-objs += bus.o
+mei-$(CONFIG_INTEL_MEI_BUS_NFC) += nfc.o
 mei-$(CONFIG_INTEL_MEI_ME) += pci-me.o
 mei-$(CONFIG_INTEL_MEI_ME) += hw-me.o
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index ef5300a..525fbdf 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -358,6 +358,9 @@ void mei_host_client_init(struct work_struct *work)
 			mei_amthif_host_init(dev);
 		else if (!uuid_le_cmp(client_props->protocol_name, mei_wd_guid))
 			mei_wd_host_init(dev);
+		else if (!uuid_le_cmp(client_props->protocol_name, mei_nfc_guid))
+			mei_nfc_host_init(dev);
+
 	}
 
 	dev->dev_state = MEI_DEV_ENABLED;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index fc485d4..c6e8c2e 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -484,6 +484,34 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_host *dev,
 
 void mei_amthif_run_next_cmd(struct mei_host *dev);
 
+#ifdef CONFIG_INTEL_MEI_BUS_NFC
+/*
+ * NFC functions
+ */
+int mei_nfc_host_init(struct mei_host *dev);
+void mei_nfc_host_exit(void);
+
+/*
+ * NFC Client UUID
+ */
+extern const uuid_le mei_nfc_guid;
+
+#else
+
+static inline int mei_nfc_host_init(struct mei_host *dev)
+{
+	return 0;
+}
+
+static inline void mei_nfc_host_exit(void)
+{
+	return;
+}
+
+static const uuid_le mei_nfc_guid = UUID_LE(0x0bb17a78, 0x2a8e, 0x4c50,
+					    0x94, 0xd4, 0x50, 0x26,
+					    0x67, 0x23, 0x77, 0x5c);
+#endif
 
 int mei_amthif_irq_write_complete(struct mei_host *dev, s32 *slots,
 			struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list);
diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
new file mode 100644
index 0000000..075ceb8
--- /dev/null
+++ b/drivers/misc/mei/nfc.c
@@ -0,0 +1,209 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2012, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/device.h>
+#include <linux/pci.h>
+#include <linux/mei.h>
+#include <linux/mei_bus.h>
+
+#include "mei_dev.h"
+#include "client.h"
+#include "nfc.h"
+
+/** mei_nfc_dev - NFC mei device
+ *
+ * @cl_info: NFC info host client
+ * @init_work: perform connection to the info client
+ * @fw_ivn: NFC Intervace Version Number
+ * @vendor_id: NFC manufacturer ID
+ * @radio_type: NFC radio type
+ */
+struct mei_nfc_dev {
+	struct mei_cl *cl_info;
+	struct work_struct init_work;
+	u8 fw_ivn;
+	u8 vendor_id;
+	u8 radio_type;
+};
+
+static struct mei_nfc_dev nfc_dev;
+
+/* UUIDs for NFC F/W clients */
+const uuid_le mei_nfc_guid = UUID_LE(0x0bb17a78, 0x2a8e, 0x4c50,
+				     0x94, 0xd4, 0x50, 0x26,
+				     0x67, 0x23, 0x77, 0x5c);
+
+static const uuid_le mei_nfc_info_guid = UUID_LE(0xd2de1625, 0x382d, 0x417d,
+					0x48, 0xa4, 0xef, 0xab,
+					0xba, 0x8a, 0x12, 0x06);
+
+static void mei_nfc_free(struct mei_nfc_dev *ndev)
+{
+	if (ndev->cl_info) {
+		list_del(&ndev->cl_info->device_link);
+		mei_cl_unlink(ndev->cl_info);
+		kfree(ndev->cl_info);
+	}
+}
+
+static int mei_nfc_if_version(struct mei_nfc_dev *ndev)
+{
+	struct mei_host *dev;
+	struct mei_cl *cl;
+
+	struct mei_nfc_cmd cmd;
+	struct mei_nfc_reply *reply = NULL;
+	struct mei_nfc_if_version *version;
+	size_t if_version_length;
+	int bytes_recv, ret;
+
+	cl = ndev->cl_info;
+	dev = cl->dev;
+
+	memset(&cmd, 0, sizeof(struct mei_nfc_cmd));
+	cmd.command = MEI_NFC_CMD_MAINTENANCE;
+	cmd.data_size = 1;
+	cmd.sub_command = MEI_NFC_SUBCMD_IF_VERSION;
+
+	ret = __mei_send(cl, (u8 *)&cmd, sizeof(struct mei_nfc_cmd));
+	if (ret < 0) {
+		dev_err(&dev->pdev->dev, "Could not send IF version cmd\n");
+		return ret;
+	}
+
+	/* to be sure on the stack we alloc memory */
+	if_version_length = sizeof(struct mei_nfc_reply) +
+		sizeof(struct mei_nfc_if_version);
+
+	reply = kzalloc(if_version_length, GFP_KERNEL);
+	if (!reply)
+		return -ENOMEM;
+
+	bytes_recv = __mei_recv(cl, (u8 *)reply, if_version_length);
+	if (bytes_recv < 0 || bytes_recv < sizeof(struct mei_nfc_reply)) {
+		dev_err(&dev->pdev->dev, "Could not read IF version\n");
+		ret = -EIO;
+		goto err;
+	}
+
+	version = (struct mei_nfc_if_version *)reply->data;
+
+	ndev->fw_ivn = version->fw_ivn;
+	ndev->vendor_id = version->vendor_id;
+	ndev->radio_type = version->radio_type;
+
+err:
+	kfree(reply);
+	return ret;
+}
+
+static void mei_nfc_init(struct work_struct *work)
+{
+	struct mei_host *dev;
+	struct mei_nfc_dev *ndev;
+	struct mei_cl *cl_info;
+	int ret;
+
+	ndev = container_of(work, struct mei_nfc_dev, init_work);
+
+	cl_info = ndev->cl_info;
+	dev = cl_info->dev;
+
+	mutex_lock(&dev->device_lock);
+
+	if (mei_cl_connect(cl_info, NULL) < 0) {
+		mutex_unlock(&dev->device_lock);
+		dev_err(&dev->pdev->dev,
+			"Could not connect to the NFC INFO ME client");
+
+		goto err;
+	}
+
+	mutex_unlock(&dev->device_lock);
+
+	ret = mei_nfc_if_version(ndev);
+	if (ret < 0) {
+		dev_err(&dev->pdev->dev, "Could not get the NFC interfave version");
+
+		goto err;
+	}
+
+	dev_info(&dev->pdev->dev,
+		"NFC MEI VERSION: IVN 0x%x Vendor ID 0x%x Type 0x%x\n",
+		ndev->fw_ivn, ndev->vendor_id, ndev->radio_type);
+
+	return;
+
+err:
+	mei_nfc_free(ndev);
+
+	return;
+}
+
+
+int mei_nfc_host_init(struct mei_host *dev)
+{
+	struct mei_nfc_dev *ndev = &nfc_dev;
+	struct mei_cl *cl_info;
+	int i, ret;
+
+	/* already initialzed */
+	if (ndev->cl_info)
+		return 0;
+
+	cl_info = mei_cl_allocate(dev);
+	if (!cl_info)
+		return -ENOMEM;
+
+	/* check for valid client id */
+	i = mei_me_cl_by_uuid(dev, &mei_nfc_info_guid);
+	if (i < 0) {
+		dev_info(&dev->pdev->dev, "nfc: failed to find the client\n");
+		return -ENOENT;
+	}
+
+	cl_info->me_client_id = dev->me_clients[i].client_id;
+
+	ret = mei_cl_link(cl_info, MEI_HOST_CLIENT_ID_ANY);
+	if (ret)
+		goto err;
+
+	cl_info->device_uuid = mei_nfc_info_guid;
+
+	list_add_tail(&cl_info->device_link, &dev->device_list);
+
+	ndev->cl_info = cl_info;
+
+	INIT_WORK(&ndev->init_work, mei_nfc_init);
+	schedule_work(&ndev->init_work);
+
+	return 0;
+
+err:
+	mei_nfc_free(ndev);
+
+	return ret;
+}
+
+void mei_nfc_host_exit(void)
+{
+	struct mei_nfc_dev *ndev = &nfc_dev;
+
+	mei_nfc_free(ndev);
+}
diff --git a/drivers/misc/mei/nfc.h b/drivers/misc/mei/nfc.h
new file mode 100644
index 0000000..59e6703
--- /dev/null
+++ b/drivers/misc/mei/nfc.h
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Intel MEI Interface Header
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.
+ *
+ * Contact Information:
+ *	Intel Corporation.
+ *	linux-mei@linux.intel.com
+ *	http://www.intel.com
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+
+#ifndef _MEI_NFC_H
+#define _MEI_NFC_H
+
+#include <linux/types.h>
+
+struct mei_nfc_cmd {
+	uint8_t command;
+	uint8_t status;
+	uint16_t req_id;
+	uint32_t reserved;
+	uint16_t data_size;
+	uint8_t sub_command;
+	uint8_t data[];
+} __packed;
+
+struct mei_nfc_reply {
+	uint8_t command;
+	uint8_t status;
+	uint16_t req_id;
+	uint32_t reserved;
+	uint16_t data_size;
+	uint8_t sub_command;
+	uint8_t reply_status;
+	uint8_t data[];
+} __packed;
+
+struct mei_nfc_if_version {
+	uint8_t radio_version_sw[3];
+	uint8_t reserved[3];
+	uint8_t radio_version_hw[3];
+	uint8_t i2c_addr;
+	uint8_t fw_ivn;
+	uint8_t vendor_id;
+	uint8_t radio_type;
+} __packed;
+
+struct mei_nfc_connect {
+	uint8_t fw_ivn;
+	uint8_t vendor_id;
+} __packed;
+
+struct mei_nfc_connect_resp {
+	uint8_t fw_ivn;
+	uint8_t vendor_id;
+	uint16_t me_major;
+	uint16_t me_minor;
+	uint16_t me_hotfix;
+	uint16_t me_build;
+} __packed;
+
+#define MEI_NFC_CMD_MAINTENANCE 0x00
+
+#define MEI_NFC_SUBCMD_CONNECT    0x00
+#define MEI_NFC_SUBCMD_IF_VERSION 0x01
+
+#endif /* _MEI_NFC_H */
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index e31090f..d0e4623 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -277,6 +277,8 @@ static void mei_remove(struct pci_dev *pdev)
 		dev->open_handle_count--;
 	mei_cl_unlink(&dev->iamthif_cl);
 
+	mei_nfc_host_exit();
+
 	dev->iamthif_current_cb = NULL;
 	dev->me_clients_num = 0;
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 10/12 v3] mei: nfc: Connect also the regular ME client
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
                   ` (8 preceding siblings ...)
  2013-02-12 18:36 ` [char-misc-next 09/12 v3] mei: nfc: Initial nfc implementation Samuel Ortiz
@ 2013-02-12 18:37 ` Samuel Ortiz
  2013-02-12 18:37 ` [char-misc-next 11/12 v3] mei: nfc: Add NFC device to the MEI bus Samuel Ortiz
  2013-02-12 18:37 ` [char-misc-next 12/12 v3] mei: nfc: Implement MEI bus IO ops Samuel Ortiz
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:37 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

After receiving the NFC interface version, IVN and radio type,
we can connect to the the actual nfc ME client and send the
initialization (nfc connect) message.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/nfc.c |  128 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 123 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
index 075ceb8..ddbf93f 100644
--- a/drivers/misc/mei/nfc.c
+++ b/drivers/misc/mei/nfc.c
@@ -28,6 +28,7 @@
 
 /** mei_nfc_dev - NFC mei device
  *
+ * @cl: NFC host client
  * @cl_info: NFC info host client
  * @init_work: perform connection to the info client
  * @fw_ivn: NFC Intervace Version Number
@@ -35,6 +36,7 @@
  * @radio_type: NFC radio type
  */
 struct mei_nfc_dev {
+	struct mei_cl *cl;
 	struct mei_cl *cl_info;
 	struct work_struct init_work;
 	u8 fw_ivn;
@@ -55,6 +57,12 @@ static const uuid_le mei_nfc_info_guid = UUID_LE(0xd2de1625, 0x382d, 0x417d,
 
 static void mei_nfc_free(struct mei_nfc_dev *ndev)
 {
+	if (ndev->cl) {
+		list_del(&ndev->cl->device_link);
+		mei_cl_unlink(ndev->cl);
+		kfree(ndev->cl);
+	}
+
 	if (ndev->cl_info) {
 		list_del(&ndev->cl_info->device_link);
 		mei_cl_unlink(ndev->cl_info);
@@ -62,6 +70,73 @@ static void mei_nfc_free(struct mei_nfc_dev *ndev)
 	}
 }
 
+static int mei_nfc_connect(struct mei_nfc_dev *ndev)
+{
+	struct mei_host *dev;
+	struct mei_cl *cl;
+	struct mei_nfc_cmd *cmd, *reply;
+	struct mei_nfc_connect *connect;
+	struct mei_nfc_connect_resp *connect_resp;
+	size_t connect_length, connect_resp_length;
+	int bytes_recv, ret;
+
+	cl = ndev->cl;
+	dev = cl->dev;
+
+	connect_length = sizeof(struct mei_nfc_cmd) +
+			sizeof(struct mei_nfc_connect);
+
+	connect_resp_length = sizeof(struct mei_nfc_cmd) +
+			sizeof(struct mei_nfc_connect_resp);
+
+	cmd = kzalloc(connect_length, GFP_KERNEL);
+	if (!cmd)
+		return -ENOMEM;
+	connect = (struct mei_nfc_connect *)cmd->data;
+
+	reply = kzalloc(connect_resp_length, GFP_KERNEL);
+	if (!reply) {
+		kfree(cmd);
+		return -ENOMEM;
+	}
+
+	connect_resp = (struct mei_nfc_connect_resp *)reply->data;
+
+	cmd->command = MEI_NFC_CMD_MAINTENANCE;
+	cmd->data_size = 3;
+	cmd->sub_command = MEI_NFC_SUBCMD_CONNECT;
+	connect->fw_ivn = ndev->fw_ivn;
+	connect->vendor_id = ndev->vendor_id;
+
+	ret = __mei_send(cl, (u8 *)cmd, connect_length);
+	if (ret < 0) {
+		dev_err(&dev->pdev->dev, "Could not send connect cmd\n");
+		goto err;
+	}
+
+	bytes_recv = __mei_recv(cl, (u8 *)reply, connect_resp_length);
+	if (bytes_recv < 0) {
+		dev_err(&dev->pdev->dev, "Could not read connect response\n");
+		ret = bytes_recv;
+		goto err;
+	}
+
+	dev_info(&dev->pdev->dev, "IVN 0x%x Vendor ID 0x%x\n",
+		connect_resp->fw_ivn, connect_resp->vendor_id);
+
+	dev_info(&dev->pdev->dev, "ME FW %d.%d.%d.%d\n",
+		connect_resp->me_major, connect_resp->me_minor,
+		connect_resp->me_hotfix, connect_resp->me_build);
+
+	ret = 0;
+
+err:
+	kfree(reply);
+	kfree(cmd);
+
+	return ret;
+}
+
 static int mei_nfc_if_version(struct mei_nfc_dev *ndev)
 {
 	struct mei_host *dev;
@@ -117,12 +192,13 @@ static void mei_nfc_init(struct work_struct *work)
 {
 	struct mei_host *dev;
 	struct mei_nfc_dev *ndev;
-	struct mei_cl *cl_info;
+	struct mei_cl *cl_info, *cl;
 	int ret;
 
 	ndev = container_of(work, struct mei_nfc_dev, init_work);
 
 	cl_info = ndev->cl_info;
+	cl = ndev->cl;
 	dev = cl_info->dev;
 
 	mutex_lock(&dev->device_lock);
@@ -148,6 +224,24 @@ static void mei_nfc_init(struct work_struct *work)
 		"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);
+
+	if (mei_cl_connect(cl, NULL) < 0) {
+		mutex_unlock(&dev->device_lock);
+		dev_err(&dev->pdev->dev,
+			"Could not connect to the NFC ME client");
+
+		goto err;
+	}
+
+	mutex_unlock(&dev->device_lock);
+
+	ret = mei_nfc_connect(ndev);
+	if (ret < 0) {
+		dev_err(&dev->pdev->dev, "Could not connect to NFC");
+		return;
+	}
+
 	return;
 
 err:
@@ -160,7 +254,7 @@ err:
 int mei_nfc_host_init(struct mei_host *dev)
 {
 	struct mei_nfc_dev *ndev = &nfc_dev;
-	struct mei_cl *cl_info;
+	struct mei_cl *cl_info, *cl  = NULL;
 	int i, ret;
 
 	/* already initialzed */
@@ -168,14 +262,19 @@ int mei_nfc_host_init(struct mei_host *dev)
 		return 0;
 
 	cl_info = mei_cl_allocate(dev);
-	if (!cl_info)
-		return -ENOMEM;
+	cl = mei_cl_allocate(dev);
+
+	if (!cl || !cl_info) {
+		ret = -ENOMEM;
+		goto err;
+	}
 
 	/* check for valid client id */
 	i = mei_me_cl_by_uuid(dev, &mei_nfc_info_guid);
 	if (i < 0) {
 		dev_info(&dev->pdev->dev, "nfc: failed to find the client\n");
-		return -ENOENT;
+		ret = -ENOENT;
+		goto err;
 	}
 
 	cl_info->me_client_id = dev->me_clients[i].client_id;
@@ -188,7 +287,26 @@ int mei_nfc_host_init(struct mei_host *dev)
 
 	list_add_tail(&cl_info->device_link, &dev->device_list);
 
+	/* check for valid client id */
+	i = mei_me_cl_by_uuid(dev, &mei_nfc_guid);
+	if (i < 0) {
+		dev_info(&dev->pdev->dev, "nfc: failed to find the client\n");
+		ret = -ENOENT;
+		goto err;
+	}
+
+	cl->me_client_id = dev->me_clients[i].client_id;
+
+	ret = mei_cl_link(cl, MEI_HOST_CLIENT_ID_ANY);
+	if (ret)
+		goto err;
+
+	cl->device_uuid = mei_nfc_guid;
+
+	list_add_tail(&cl->device_link, &dev->device_list);
+
 	ndev->cl_info = cl_info;
+	ndev->cl = cl;
 
 	INIT_WORK(&ndev->init_work, mei_nfc_init);
 	schedule_work(&ndev->init_work);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 11/12 v3] mei: nfc: Add NFC device to the MEI bus
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
                   ` (9 preceding siblings ...)
  2013-02-12 18:37 ` [char-misc-next 10/12 v3] mei: nfc: Connect also the regular ME client Samuel Ortiz
@ 2013-02-12 18:37 ` Samuel Ortiz
  2013-02-12 18:37 ` [char-misc-next 12/12 v3] mei: nfc: Implement MEI bus IO ops Samuel Ortiz
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:37 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

After building its bus name as a string based on its vendor id and radio
type, we can add it to the bus.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/nfc.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/mei/nfc.h |    6 ++++++
 2 files changed, 62 insertions(+)

diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
index ddbf93f..75381b8 100644
--- a/drivers/misc/mei/nfc.c
+++ b/drivers/misc/mei/nfc.c
@@ -42,6 +42,8 @@ struct mei_nfc_dev {
 	u8 fw_ivn;
 	u8 vendor_id;
 	u8 radio_type;
+
+	char *bus_name;
 };
 
 static struct mei_nfc_dev nfc_dev;
@@ -70,6 +72,39 @@ static void mei_nfc_free(struct mei_nfc_dev *ndev)
 	}
 }
 
+static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev)
+{
+	struct mei_host *dev;
+
+	if (!ndev->cl)
+		return -ENODEV;
+
+	dev = ndev->cl->dev;
+
+	switch (ndev->vendor_id) {
+	case MEI_NFC_VENDOR_INSIDE:
+		switch (ndev->radio_type) {
+		case MEI_NFC_VENDOR_INSIDE_UREAD:
+			ndev->bus_name = "microread";
+			return 0;
+
+		default:
+			dev_err(&dev->pdev->dev, "Unknow radio type 0x%x\n",
+				ndev->radio_type);
+
+			return -EINVAL;
+		}
+
+	default:
+		dev_err(&dev->pdev->dev, "Unknow vendor ID 0x%x\n",
+			ndev->vendor_id);
+
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int mei_nfc_connect(struct mei_nfc_dev *ndev)
 {
 	struct mei_host *dev;
@@ -191,6 +226,7 @@ err:
 static void mei_nfc_init(struct work_struct *work)
 {
 	struct mei_host *dev;
+	struct mei_device *device;
 	struct mei_nfc_dev *ndev;
 	struct mei_cl *cl_info, *cl;
 	int ret;
@@ -242,6 +278,23 @@ static void mei_nfc_init(struct work_struct *work)
 		return;
 	}
 
+	if (mei_nfc_build_bus_name(ndev) < 0) {
+		dev_err(&dev->pdev->dev,
+			"Could not build the bus ID name\n");
+		return;
+	}
+
+	device = mei_add_device(dev, mei_nfc_guid,
+				    ndev->bus_name);
+	if (!device) {
+		dev_err(&dev->pdev->dev,
+			"Could not add the NFC device to the MEI bus\n");
+
+		goto err;
+	}
+
+	device->priv_data = ndev;
+
 	return;
 
 err:
@@ -323,5 +376,8 @@ void mei_nfc_host_exit(void)
 {
 	struct mei_nfc_dev *ndev = &nfc_dev;
 
+	if (ndev->cl && ndev->cl->device)
+		mei_remove_device(ndev->cl->device);
+
 	mei_nfc_free(ndev);
 }
diff --git a/drivers/misc/mei/nfc.h b/drivers/misc/mei/nfc.h
index 59e6703..4440436 100644
--- a/drivers/misc/mei/nfc.h
+++ b/drivers/misc/mei/nfc.h
@@ -119,4 +119,10 @@ struct mei_nfc_connect_resp {
 #define MEI_NFC_SUBCMD_CONNECT    0x00
 #define MEI_NFC_SUBCMD_IF_VERSION 0x01
 
+/* Vendors */
+#define MEI_NFC_VENDOR_INSIDE 0x00
+
+/* Radio types */
+#define MEI_NFC_VENDOR_INSIDE_UREAD 0x00
+
 #endif /* _MEI_NFC_H */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [char-misc-next 12/12 v3] mei: nfc: Implement MEI bus IO ops
  2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
                   ` (10 preceding siblings ...)
  2013-02-12 18:37 ` [char-misc-next 11/12 v3] mei: nfc: Add NFC device to the MEI bus Samuel Ortiz
@ 2013-02-12 18:37 ` Samuel Ortiz
  11 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 18:37 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, tomas.winkler, Samuel Ortiz

The send ops for NFC builds the command header, updates the request id
and then waits for an ACK.
The recv ops check if it receives data or an ACK and in the latter case
wakes the send ops up.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/nfc.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/mei/nfc.h |   13 +++++++++
 2 files changed, 89 insertions(+)

diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
index 75381b8..f8889e0 100644
--- a/drivers/misc/mei/nfc.c
+++ b/drivers/misc/mei/nfc.c
@@ -15,6 +15,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/sched.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/device.h>
@@ -39,11 +40,15 @@ struct mei_nfc_dev {
 	struct mei_cl *cl;
 	struct mei_cl *cl_info;
 	struct work_struct init_work;
+	wait_queue_head_t send_wq;
 	u8 fw_ivn;
 	u8 vendor_id;
 	u8 radio_type;
 
 	char *bus_name;
+
+	u16 req_id;
+	u16 recv_req_id;
 };
 
 static struct mei_nfc_dev nfc_dev;
@@ -223,6 +228,74 @@ err:
 	return ret;
 }
 
+static int mei_nfc_send(struct mei_device *device, u8 *buf, size_t length)
+{
+	struct mei_host *dev;
+	struct mei_nfc_dev *ndev;
+	struct mei_nfc_hci_hdr *hdr;
+	u8 *mei_buf;
+	int err;
+
+	ndev = (struct mei_nfc_dev *) device->priv_data;
+	dev = ndev->cl->dev;
+
+	mei_buf = kzalloc(length + MEI_NFC_HEADER_SIZE, GFP_KERNEL);
+	if (!mei_buf)
+		return -ENOMEM;
+
+	hdr = (struct mei_nfc_hci_hdr *) mei_buf;
+	hdr->cmd = MEI_NFC_CMD_HCI_SEND;
+	hdr->status = 0;
+	hdr->req_id = ndev->req_id;
+	hdr->reserved = 0;
+	hdr->data_size = length;
+
+	memcpy(mei_buf + MEI_NFC_HEADER_SIZE, buf, length);
+
+	err = __mei_send(ndev->cl, mei_buf, length + MEI_NFC_HEADER_SIZE);
+
+	kfree(mei_buf);
+
+	if (!wait_event_interruptible_timeout(ndev->send_wq,
+				ndev->recv_req_id == ndev->req_id, HZ)) {
+		dev_err(&dev->pdev->dev, "NFC MEI command timeout\n");
+		err = -ETIMEDOUT;
+	} else {
+		ndev->req_id++;
+	}
+
+	return err;
+}
+
+static int mei_nfc_recv(struct mei_device *device, u8 *buf, size_t length)
+{
+	struct mei_nfc_dev *ndev;
+	struct mei_nfc_hci_hdr *hci_hdr;
+	int received_length;
+
+	ndev = (struct mei_nfc_dev *) device->priv_data;
+
+	received_length = __mei_recv(ndev->cl, buf, length);
+	if (received_length < 0)
+		return received_length;
+
+	hci_hdr = (struct mei_nfc_hci_hdr *) buf;
+
+	if (hci_hdr->cmd == MEI_NFC_CMD_HCI_SEND) {
+		ndev->recv_req_id = hci_hdr->req_id;
+		wake_up(&ndev->send_wq);
+
+		return 0;
+	}
+
+	return received_length;
+}
+
+static struct mei_transport_ops nfc_ops = {
+	.send = mei_nfc_send,
+	.recv = mei_nfc_recv,
+};
+
 static void mei_nfc_init(struct work_struct *work)
 {
 	struct mei_host *dev;
@@ -294,6 +367,7 @@ static void mei_nfc_init(struct work_struct *work)
 	}
 
 	device->priv_data = ndev;
+	device->ops = &nfc_ops;
 
 	return;
 
@@ -360,8 +434,10 @@ int mei_nfc_host_init(struct mei_host *dev)
 
 	ndev->cl_info = cl_info;
 	ndev->cl = cl;
+	ndev->req_id = 1;
 
 	INIT_WORK(&ndev->init_work, mei_nfc_init);
+	init_waitqueue_head(&ndev->send_wq);
 	schedule_work(&ndev->init_work);
 
 	return 0;
diff --git a/drivers/misc/mei/nfc.h b/drivers/misc/mei/nfc.h
index 4440436..12e48d3 100644
--- a/drivers/misc/mei/nfc.h
+++ b/drivers/misc/mei/nfc.h
@@ -114,11 +114,24 @@ struct mei_nfc_connect_resp {
 	uint16_t me_build;
 } __packed;
 
+struct mei_nfc_hci_hdr {
+	u8 cmd;
+	u8 status;
+	u16 req_id;
+	u32 reserved;
+	u16 data_size;
+} __packed;
+
 #define MEI_NFC_CMD_MAINTENANCE 0x00
+#define MEI_NFC_CMD_HCI_SEND 0x01
+#define MEI_NFC_CMD_HCI_RECV 0x02
 
 #define MEI_NFC_SUBCMD_CONNECT    0x00
 #define MEI_NFC_SUBCMD_IF_VERSION 0x01
 
+#define MEI_NFC_HEADER_SIZE 10
+#define MEI_NFC_MAX_HCI_PAYLOAD 300
+
 /* Vendors */
 #define MEI_NFC_VENDOR_INSIDE 0x00
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* RE: [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host
  2013-02-12 18:36 ` [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host Samuel Ortiz
@ 2013-02-12 21:17   ` Winkler, Tomas
  2013-02-12 21:29     ` Samuel Ortiz
  0 siblings, 1 reply; 22+ messages in thread
From: Winkler, Tomas @ 2013-02-12 21:17 UTC (permalink / raw)
  To: Samuel Ortiz, gregkh; +Cc: arnd, linux-kernel



> In preparation for the MEI bus code merge, we rename the mei_device
> structure to mei_host.
> struct mei_device will be used for devices on the MEI bus in order to follow
> exisiting driver model implementations practices.
> 
I'd like to NACK this name, we use  'host' for the host part of the MEI protocol, 

You can use the mei_controller, mei_adapter, and  I'm not sure what else can come into mind.

I prefer not to break the HW spec language.  I prefer to leave it mei_device as after all it's a device on pci bus it's not a pure host controller.
And call what is on the mei  bus mei_cl_dev or mei_app_dev . From the HW perspective it actually 
talks to a client/application residing inside MEI device, it is not always a physical device like NFC.

Please let's find something that makes both hw and Linux happy

Thanks
Tomas

> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
> ---
>  drivers/misc/mei/amthif.c    |   30 ++++++------
>  drivers/misc/mei/client.c    |   36 +++++++-------
>  drivers/misc/mei/client.h    |   14 +++---
>  drivers/misc/mei/hbm.c       |   28 +++++------
>  drivers/misc/mei/hbm.h       |   10 ++--
>  drivers/misc/mei/hw-me.c     |   42 ++++++++--------
>  drivers/misc/mei/hw-me.h     |    2 +-
>  drivers/misc/mei/init.c      |    6 +--
>  drivers/misc/mei/interrupt.c |   18 +++----
>  drivers/misc/mei/main.c      |   14 +++---
>  drivers/misc/mei/mei_dev.h   |  110 +++++++++++++++++++++---------------
> ------
>  drivers/misc/mei/pci-me.c    |    8 +--
>  drivers/misc/mei/wd.c        |   20 ++++----
>  13 files changed, 169 insertions(+), 169 deletions(-)
> 
> diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c index
> c86d7e3..6f67a0a 100644
> --- a/drivers/misc/mei/amthif.c
> +++ b/drivers/misc/mei/amthif.c
> @@ -47,7 +47,7 @@ const uuid_le mei_amthif_guid  = UUID_LE(0x12f80028,
> 0xb4b7, 0x4b2d,
>   *
>   * @dev: the device structure
>   */
> -void mei_amthif_reset_params(struct mei_device *dev)
> +void mei_amthif_reset_params(struct mei_host *dev)
>  {
>  	/* reset iamthif parameters. */
>  	dev->iamthif_current_cb = NULL;
> @@ -65,7 +65,7 @@ void mei_amthif_reset_params(struct mei_device
> *dev)
>   * @dev: the device structure
>   *
>   */
> -int mei_amthif_host_init(struct mei_device *dev)
> +int mei_amthif_host_init(struct mei_host *dev)
>  {
>  	struct mei_cl *cl = &dev->iamthif_cl;
>  	unsigned char *msg_buf;
> @@ -129,7 +129,7 @@ int mei_amthif_host_init(struct mei_device *dev)
>   *
>   * returns   returned a list entry on success, NULL on failure.
>   */
> -struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device
> *dev,
> +struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_host *dev,
>  						struct file *file)
>  {
>  	struct mei_cl_cb *pos = NULL;
> @@ -162,7 +162,7 @@ struct mei_cl_cb
> *mei_amthif_find_read_list_entry(struct mei_device *dev,
>   *  zero if no data to read,
>   *  negative on failure.
>   */
> -int mei_amthif_read(struct mei_device *dev, struct file *file,
> +int mei_amthif_read(struct mei_host *dev, struct file *file,
>  	       char __user *ubuf, size_t length, loff_t *offset)  {
>  	int rets;
> @@ -274,7 +274,7 @@ out:
>   * returns 0 on success, <0 on failure.
>   *
>   */
> -static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb
> *cb)
> +static int mei_amthif_send_cmd(struct mei_host *dev, struct mei_cl_cb
> +*cb)
>  {
>  	struct mei_msg_hdr mei_hdr;
>  	int ret;
> @@ -348,7 +348,7 @@ static int mei_amthif_send_cmd(struct mei_device
> *dev, struct mei_cl_cb *cb)
>   * returns 0 on success, <0 on failure.
>   *
>   */
> -int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb)
> +int mei_amthif_write(struct mei_host *dev, struct mei_cl_cb *cb)
>  {
>  	int ret;
> 
> @@ -378,7 +378,7 @@ int mei_amthif_write(struct mei_device *dev, struct
> mei_cl_cb *cb)
>   *
>   * returns 0 on success, <0 on failure.
>   */
> -void mei_amthif_run_next_cmd(struct mei_device *dev)
> +void mei_amthif_run_next_cmd(struct mei_host *dev)
>  {
>  	struct mei_cl_cb *pos = NULL;
>  	struct mei_cl_cb *next = NULL;
> @@ -414,7 +414,7 @@ void mei_amthif_run_next_cmd(struct mei_device
> *dev)  }
> 
> 
> -unsigned int mei_amthif_poll(struct mei_device *dev,
> +unsigned int mei_amthif_poll(struct mei_host *dev,
>  		struct file *file, poll_table *wait)
>  {
>  	unsigned int mask = 0;
> @@ -443,7 +443,7 @@ unsigned int mei_amthif_poll(struct mei_device
> *dev,
>   *
>   * returns 0, OK; otherwise, error.
>   */
> -int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
> +int mei_amthif_irq_write_complete(struct mei_host *dev, s32 *slots,
>  			struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list)  {
>  	struct mei_msg_hdr mei_hdr;
> @@ -512,7 +512,7 @@ int mei_amthif_irq_write_complete(struct
> mei_device *dev, s32 *slots,
>   * returns 0 on success, <0 on failure.
>   */
>  int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
> -		struct mei_device *dev, struct mei_msg_hdr *mei_hdr)
> +		struct mei_host *dev, struct mei_msg_hdr *mei_hdr)
>  {
>  	struct mei_cl_cb *cb;
>  	unsigned char *buffer;
> @@ -564,7 +564,7 @@ int mei_amthif_irq_read_message(struct mei_cl_cb
> *complete_list,
>   *
>   * returns 0, OK; otherwise, error.
>   */
> -int mei_amthif_irq_read(struct mei_device *dev, s32 *slots)
> +int mei_amthif_irq_read(struct mei_host *dev, s32 *slots)
>  {
> 
>  	if (((*slots) * sizeof(u32)) < (sizeof(struct mei_msg_hdr) @@ -593,7
> +593,7 @@ int mei_amthif_irq_read(struct mei_device *dev, s32 *slots)
>   * @dev: the device structure.
>   * @cb_pos: callback block.
>   */
> -void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)
> +void mei_amthif_complete(struct mei_host *dev, struct mei_cl_cb *cb)
>  {
>  	if (dev->iamthif_canceled != 1) {
>  		dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE; @@ -
> 627,7 +627,7 @@ void mei_amthif_complete(struct mei_device *dev, struct
> mei_cl_cb *cb)
>   *
>   * returns true if callback removed from the list, false otherwise
>   */
> -static bool mei_clear_list(struct mei_device *dev,
> +static bool mei_clear_list(struct mei_host *dev,
>  		const struct file *file, struct list_head *mei_cb_list)  {
>  	struct mei_cl_cb *cb_pos = NULL;
> @@ -667,7 +667,7 @@ static bool mei_clear_list(struct mei_device *dev,
>   *
>   * returns true if callback removed from the list, false otherwise
>   */
> -static bool mei_clear_lists(struct mei_device *dev, struct file *file)
> +static bool mei_clear_lists(struct mei_host *dev, struct file *file)
>  {
>  	bool removed = false;
> 
> @@ -708,7 +708,7 @@ static bool mei_clear_lists(struct mei_device *dev,
> struct file *file)
>  *
>  *  returns 0 on success, <0 on error
>  */
> -int mei_amthif_release(struct mei_device *dev, struct file *file)
> +int mei_amthif_release(struct mei_host *dev, struct file *file)
>  {
>  	if (dev->open_handle_count > 0)
>  		dev->open_handle_count--;
> diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index
> 1569afe..79eda18 100644
> --- a/drivers/misc/mei/client.c
> +++ b/drivers/misc/mei/client.c
> @@ -31,7 +31,7 @@
>   * @dev: mei device
>   * returns me client index or -ENOENT if not found
>   */
> -int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *uuid)
> +int mei_me_cl_by_uuid(const struct mei_host *dev, const uuid_le *uuid)
>  {
>  	int i, res = -ENOENT;
> 
> @@ -57,7 +57,7 @@ int mei_me_cl_by_uuid(const struct mei_device *dev,
> const uuid_le *uuid)
>   * returns index on success, -ENOENT on failure.
>   */
> 
> -int mei_me_cl_by_id(struct mei_device *dev, u8 client_id)
> +int mei_me_cl_by_id(struct mei_host *dev, u8 client_id)
>  {
>  	int i;
>  	for (i = 0; i < dev->me_clients_num; i++) @@ -209,7 +209,7 @@ int
> mei_cl_flush_queues(struct mei_cl *cl)
>   * @cl: host client to be initialized
>   * @dev: mei device
>   */
> -void mei_cl_init(struct mei_cl *cl, struct mei_device *dev)
> +void mei_cl_init(struct mei_cl *cl, struct mei_host *dev)
>  {
>  	memset(cl, 0, sizeof(struct mei_cl));
>  	init_waitqueue_head(&cl->wait);
> @@ -227,7 +227,7 @@ void mei_cl_init(struct mei_cl *cl, struct mei_device
> *dev)
>   * @dev: mei device
>   * returns  The allocated file or NULL on failure
>   */
> -struct mei_cl *mei_cl_allocate(struct mei_device *dev)
> +struct mei_cl *mei_cl_allocate(struct mei_host *dev)
>  {
>  	struct mei_cl *cl;
> 
> @@ -248,7 +248,7 @@ struct mei_cl *mei_cl_allocate(struct mei_device
> *dev)
>   */
>  struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl)  {
> -	struct mei_device *dev = cl->dev;
> +	struct mei_host *dev = cl->dev;
>  	struct mei_cl_cb *cb = NULL;
>  	struct mei_cl_cb *next = NULL;
> 
> @@ -268,7 +268,7 @@ struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl
> *cl)
>   */
>  int mei_cl_link(struct mei_cl *cl, int id)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
> 
>  	if (WARN_ON(!cl || !cl->dev))
>  		return -EINVAL;
> @@ -305,7 +305,7 @@ int mei_cl_link(struct mei_cl *cl, int id)
>   */
>  int mei_cl_unlink(struct mei_cl *cl)
>  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	struct mei_cl *pos, *next;
> 
>  	/* don't shout on error exit path */
> @@ -332,8 +332,8 @@ int mei_cl_unlink(struct mei_cl *cl)
> 
>  void mei_host_client_init(struct work_struct *work)  {
> -	struct mei_device *dev = container_of(work,
> -					      struct mei_device, init_work);
> +	struct mei_host *dev = container_of(work,
> +					      struct mei_host, init_work);
>  	struct mei_client_properties *client_props;
>  	int i;
> 
> @@ -376,7 +376,7 @@ void mei_host_client_init(struct work_struct *work)
>   */
>  int mei_cl_disconnect(struct mei_cl *cl)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	struct mei_cl_cb *cb;
>  	int rets, err;
> 
> @@ -448,7 +448,7 @@ free:
>   */
>  bool mei_cl_is_other_connecting(struct mei_cl *cl)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	struct mei_cl *pos;
>  	struct mei_cl *next;
> 
> @@ -478,7 +478,7 @@ bool mei_cl_is_other_connecting(struct mei_cl *cl)
>   */
>  int mei_cl_connect(struct mei_cl *cl, struct file *file)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	struct mei_cl_cb *cb;
>  	long timeout = mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT);
>  	int rets;
> @@ -543,7 +543,7 @@ out:
>   */
>  int mei_cl_flow_ctrl_creds(struct mei_cl *cl)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	int i;
> 
>  	if (WARN_ON(!cl || !cl->dev))
> @@ -584,7 +584,7 @@ int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
>   */
>  int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	int i;
> 
>  	if (WARN_ON(!cl || !cl->dev))
> @@ -622,7 +622,7 @@ int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
>   */
>  int mei_cl_read_start(struct mei_cl *cl)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	struct mei_cl_cb *cb;
>  	int rets;
>  	int i;
> @@ -682,7 +682,7 @@ err:
>   * @dev - mei device
>   */
> 
> -void mei_cl_all_disconnect(struct mei_device *dev)
> +void mei_cl_all_disconnect(struct mei_host *dev)
>  {
>  	struct mei_cl *cl, *next;
> 
> @@ -700,7 +700,7 @@ void mei_cl_all_disconnect(struct mei_device *dev)
>   *
>   * @dev  - mei device
>   */
> -void mei_cl_all_read_wakeup(struct mei_device *dev)
> +void mei_cl_all_read_wakeup(struct mei_host *dev)
>  {
>  	struct mei_cl *cl, *next;
>  	list_for_each_entry_safe(cl, next, &dev->file_list, link) { @@ -716,7
> +716,7 @@ void mei_cl_all_read_wakeup(struct mei_device *dev)
> 
>   * @dev - mei device
>   */
> -void mei_cl_all_write_clear(struct mei_device *dev)
> +void mei_cl_all_write_clear(struct mei_host *dev)
>  {
>  	struct mei_cl_cb *cb, *next;
> 
> diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h index
> 214b239..9db03b0 100644
> --- a/drivers/misc/mei/client.h
> +++ b/drivers/misc/mei/client.h
> @@ -24,8 +24,8 @@
> 
>  #include "mei_dev.h"
> 
> -int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le
> *cuuid); -int mei_me_cl_by_id(struct mei_device *dev, u8 client_id);
> +int mei_me_cl_by_uuid(const struct mei_host *dev, const uuid_le
> +*cuuid); int mei_me_cl_by_id(struct mei_host *dev, u8 client_id);
> 
>  /*
>   * MEI IO Functions
> @@ -51,8 +51,8 @@ void mei_io_list_flush(struct mei_cl_cb *list, struct
> mei_cl *cl);
>   * MEI Host Client Functions
>   */
> 
> -struct mei_cl *mei_cl_allocate(struct mei_device *dev); -void
> mei_cl_init(struct mei_cl *cl, struct mei_device *dev);
> +struct mei_cl *mei_cl_allocate(struct mei_host *dev); void
> +mei_cl_init(struct mei_cl *cl, struct mei_host *dev);
> 
> 
>  int mei_cl_link(struct mei_cl *cl, int id); @@ -94,9 +94,9 @@ int
> mei_cl_connect(struct mei_cl *cl, struct file *file);  void
> mei_host_client_init(struct work_struct *work);
> 
> 
> -void mei_cl_all_disconnect(struct mei_device *dev); -void
> mei_cl_all_read_wakeup(struct mei_device *dev); -void
> mei_cl_all_write_clear(struct mei_device *dev);
> +void mei_cl_all_disconnect(struct mei_host *dev); void
> +mei_cl_all_read_wakeup(struct mei_host *dev); void
> +mei_cl_all_write_clear(struct mei_host *dev);
> 
> 
>  #endif /* _MEI_CLIENT_H_ */
> diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c index
> fb9e63b..e71eb35 100644
> --- a/drivers/misc/mei/hbm.c
> +++ b/drivers/misc/mei/hbm.c
> @@ -30,7 +30,7 @@
>   *
>   * returns none.
>   */
> -static void mei_hbm_me_cl_allocate(struct mei_device *dev)
> +static void mei_hbm_me_cl_allocate(struct mei_host *dev)
>  {
>  	struct mei_me_client *clients;
>  	int b;
> @@ -128,7 +128,7 @@ static bool is_treat_specially_client(struct mei_cl *cl,
>   *
>   * @dev: the device structure
>   */
> -void mei_hbm_start_req(struct mei_device *dev)
> +void mei_hbm_start_req(struct mei_host *dev)
>  {
>  	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
>  	struct hbm_host_version_request *start_req; @@ -161,7 +161,7
> @@ void mei_hbm_start_req(struct mei_device *dev)
>   *
>   * returns none.
>   */
> -static void mei_hbm_enum_clients_req(struct mei_device *dev)
> +static void mei_hbm_enum_clients_req(struct mei_host *dev)
>  {
>  	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
>  	struct hbm_host_enum_request *enum_req; @@ -191,7 +191,7 @@
> static void mei_hbm_enum_clients_req(struct mei_device *dev)
>   * returns none.
>   */
> 
> -static int mei_hbm_prop_req(struct mei_device *dev)
> +static int mei_hbm_prop_req(struct mei_host *dev)
>  {
> 
>  	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr; @@ -246,7
> +246,7 @@ static int mei_hbm_prop_req(struct mei_device *dev)
>   * @mei_hdr - mei message header
>   * @data - hbm message body buffer
>   */
> -static void mei_hbm_stop_req_prepare(struct mei_device *dev,
> +static void mei_hbm_stop_req_prepare(struct mei_host *dev,
>  		struct mei_msg_hdr *mei_hdr, unsigned char *data)  {
>  	struct hbm_host_stop_request *req =
> @@ -268,7 +268,7 @@ static void mei_hbm_stop_req_prepare(struct
> mei_device *dev,
>   *
>   * This function returns -EIO on write failure
>   */
> -int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl
> *cl)
> +int mei_hbm_cl_flow_control_req(struct mei_host *dev, struct mei_cl
> +*cl)
>  {
>  	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
>  	const size_t len = sizeof(struct hbm_flow_control); @@ -288,7 +288,7
> @@ int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct
> mei_cl *cl)
>   * @file: private data ot the file object.
>   * @flow: flow control.
>   */
> -static void mei_hbm_add_single_flow_creds(struct mei_device *dev,
> +static void mei_hbm_add_single_flow_creds(struct mei_host *dev,
>  				  struct hbm_flow_control *flow)
>  {
>  	struct mei_me_client *client;
> @@ -316,7 +316,7 @@ static void mei_hbm_add_single_flow_creds(struct
> mei_device *dev,
>   * @dev: the device structure
>   * @flow_control: flow control response bus message
>   */
> -static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
> +static void mei_hbm_cl_flow_control_res(struct mei_host *dev,
>  		struct hbm_flow_control *flow_control)  {
>  	struct mei_cl *cl = NULL;
> @@ -350,7 +350,7 @@ static void mei_hbm_cl_flow_control_res(struct
> mei_device *dev,
>   *
>   * This function returns -EIO on write failure
>   */
> -int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
> +int mei_hbm_cl_disconnect_req(struct mei_host *dev, struct mei_cl *cl)
>  {
>  	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
>  	const size_t len = sizeof(struct hbm_client_connect_request); @@ -
> 367,7 +367,7 @@ int mei_hbm_cl_disconnect_req(struct mei_device *dev,
> struct mei_cl *cl)
>   * @dev: the device structure
>   * @rs: disconnect response bus message
>   */
> -static void mei_hbm_cl_disconnect_res(struct mei_device *dev,
> +static void mei_hbm_cl_disconnect_res(struct mei_host *dev,
>  		struct hbm_client_connect_response *rs)  {
>  	struct mei_cl *cl;
> @@ -411,7 +411,7 @@ static void mei_hbm_cl_disconnect_res(struct
> mei_device *dev,
>   *
>   * returns -EIO on write failure
>   */
> -int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
> +int mei_hbm_cl_connect_req(struct mei_host *dev, struct mei_cl *cl)
>  {
>  	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
>  	const size_t len = sizeof(struct hbm_client_connect_request); @@ -
> 428,7 +428,7 @@ int mei_hbm_cl_connect_req(struct mei_device *dev,
> struct mei_cl *cl)
>   * @dev: the device structure
>   * @rs: connect response bus message
>   */
> -static void mei_hbm_cl_connect_res(struct mei_device *dev,
> +static void mei_hbm_cl_connect_res(struct mei_host *dev,
>  		struct hbm_client_connect_response *rs)  {
> 
> @@ -483,7 +483,7 @@ static void mei_hbm_cl_connect_res(struct
> mei_device *dev,
>   * @dev: the device structure.
>   * @disconnect_req: disconnect request bus message from the me
>   */
> -static void mei_hbm_fw_disconnect_req(struct mei_device *dev,
> +static void mei_hbm_fw_disconnect_req(struct mei_host *dev,
>  		struct hbm_client_connect_request *disconnect_req)  {
>  	struct mei_cl *cl, *next;
> @@ -518,7 +518,7 @@ static void mei_hbm_fw_disconnect_req(struct
> mei_device *dev,
>   * @dev: the device structure
>   * @mei_hdr: header of bus message
>   */
> -void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
> +void mei_hbm_dispatch(struct mei_host *dev, struct mei_msg_hdr *hdr)
>  {
>  	struct mei_bus_message *mei_msg;
>  	struct mei_me_client *me_client;
> diff --git a/drivers/misc/mei/hbm.h b/drivers/misc/mei/hbm.h index
> b552afb..ef87c98 100644
> --- a/drivers/misc/mei/hbm.h
> +++ b/drivers/misc/mei/hbm.h
> @@ -17,7 +17,7 @@
>  #ifndef _MEI_HBM_H_
>  #define _MEI_HBM_H_
> 
> -void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr
> *hdr);
> +void mei_hbm_dispatch(struct mei_host *dev, struct mei_msg_hdr *hdr);
> 
>  static inline void mei_hbm_hdr(struct mei_msg_hdr *hdr, size_t length)  {
> @@ -28,11 +28,11 @@ static inline void mei_hbm_hdr(struct mei_msg_hdr
> *hdr, size_t length)
>  	hdr->reserved = 0;
>  }
> 
> -void mei_hbm_start_req(struct mei_device *dev);
> +void mei_hbm_start_req(struct mei_host *dev);
> 
> -int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl
> *cl); -int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl
> *cl); -int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl
> *cl);
> +int mei_hbm_cl_flow_control_req(struct mei_host *dev, struct mei_cl
> +*cl); int mei_hbm_cl_disconnect_req(struct mei_host *dev, struct mei_cl
> +*cl); int mei_hbm_cl_connect_req(struct mei_host *dev, struct mei_cl
> +*cl);
> 
> 
>  #endif /* _MEI_HBM_H_ */
> diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index
> 45ea718..ebd8621 100644
> --- a/drivers/misc/mei/hw-me.c
> +++ b/drivers/misc/mei/hw-me.c
> @@ -61,7 +61,7 @@ static inline void mei_reg_write(const struct
> mei_me_hw *hw,
>   *
>   * returns ME_CB_RW register value (u32)
>   */
> -static u32 mei_me_mecbrw_read(const struct mei_device *dev)
> +static u32 mei_me_mecbrw_read(const struct mei_host *dev)
>  {
>  	return mei_reg_read(to_me_hw(dev), ME_CB_RW);  } @@ -107,7
> +107,7 @@ static inline void mei_hcsr_set(struct mei_me_hw *hw, u32 hcsr)
>   *
>   * @dev: mei device
>   */
> -static void mei_me_hw_config(struct mei_device *dev)
> +static void mei_me_hw_config(struct mei_host *dev)
>  {
>  	u32 hcsr = mei_hcsr_read(to_me_hw(dev));
>  	/* Doesn't change in runtime */
> @@ -118,7 +118,7 @@ static void mei_me_hw_config(struct mei_device
> *dev)
>   *
>   * @dev: the device structure
>   */
> -static void mei_me_intr_clear(struct mei_device *dev)
> +static void mei_me_intr_clear(struct mei_host *dev)
>  {
>  	struct mei_me_hw *hw = to_me_hw(dev);
>  	u32 hcsr = mei_hcsr_read(hw);
> @@ -130,7 +130,7 @@ static void mei_me_intr_clear(struct mei_device
> *dev)
>   *
>   * @dev: the device structure
>   */
> -static void mei_me_intr_enable(struct mei_device *dev)
> +static void mei_me_intr_enable(struct mei_host *dev)
>  {
>  	struct mei_me_hw *hw = to_me_hw(dev);
>  	u32 hcsr = mei_hcsr_read(hw);
> @@ -143,7 +143,7 @@ static void mei_me_intr_enable(struct mei_device
> *dev)
>   *
>   * @dev: the device structure
>   */
> -static void mei_me_intr_disable(struct mei_device *dev)
> +static void mei_me_intr_disable(struct mei_host *dev)
>  {
>  	struct mei_me_hw *hw = to_me_hw(dev);
>  	u32 hcsr = mei_hcsr_read(hw);
> @@ -157,7 +157,7 @@ static void mei_me_intr_disable(struct mei_device
> *dev)
>   * @dev: the device structure
>   * @interrupts_enabled: if interrupt should be enabled after reset.
>   */
> -static void mei_me_hw_reset(struct mei_device *dev, bool intr_enable)
> +static void mei_me_hw_reset(struct mei_host *dev, bool intr_enable)
>  {
>  	struct mei_me_hw *hw = to_me_hw(dev);
>  	u32 hcsr = mei_hcsr_read(hw);
> @@ -190,7 +190,7 @@ static void mei_me_hw_reset(struct mei_device
> *dev, bool intr_enable)
>   * returns bool
>   */
> 
> -static void mei_me_host_set_ready(struct mei_device *dev)
> +static void mei_me_host_set_ready(struct mei_host *dev)
>  {
>  	struct mei_me_hw *hw = to_me_hw(dev);
>  	hw->host_hw_state |= H_IE | H_IG | H_RDY; @@ -202,7 +202,7 @@
> static void mei_me_host_set_ready(struct mei_device *dev)
>   * @dev - mei device
>   * returns bool
>   */
> -static bool mei_me_host_is_ready(struct mei_device *dev)
> +static bool mei_me_host_is_ready(struct mei_host *dev)
>  {
>  	struct mei_me_hw *hw = to_me_hw(dev);
>  	hw->host_hw_state = mei_hcsr_read(hw); @@ -215,7 +215,7 @@
> static bool mei_me_host_is_ready(struct mei_device *dev)
>   * @dev - mei device
>   * returns bool
>   */
> -static bool mei_me_hw_is_ready(struct mei_device *dev)
> +static bool mei_me_hw_is_ready(struct mei_host *dev)
>  {
>  	struct mei_me_hw *hw = to_me_hw(dev);
>  	hw->me_hw_state = mei_mecsr_read(hw);
> @@ -229,7 +229,7 @@ static bool mei_me_hw_is_ready(struct mei_device
> *dev)
>   *
>   * returns number of filled slots
>   */
> -static unsigned char mei_hbuf_filled_slots(struct mei_device *dev)
> +static unsigned char mei_hbuf_filled_slots(struct mei_host *dev)
>  {
>  	struct mei_me_hw *hw = to_me_hw(dev);
>  	char read_ptr, write_ptr;
> @@ -249,7 +249,7 @@ static unsigned char mei_hbuf_filled_slots(struct
> mei_device *dev)
>   *
>   * returns true if empty, false - otherwise.
>   */
> -static bool mei_me_hbuf_is_empty(struct mei_device *dev)
> +static bool mei_me_hbuf_is_empty(struct mei_host *dev)
>  {
>  	return mei_hbuf_filled_slots(dev) == 0;  } @@ -261,7 +261,7 @@
> static bool mei_me_hbuf_is_empty(struct mei_device *dev)
>   *
>   * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count
>   */
> -static int mei_me_hbuf_empty_slots(struct mei_device *dev)
> +static int mei_me_hbuf_empty_slots(struct mei_host *dev)
>  {
>  	unsigned char filled_slots, empty_slots;
> 
> @@ -275,7 +275,7 @@ static int mei_me_hbuf_empty_slots(struct
> mei_device *dev)
>  	return empty_slots;
>  }
> 
> -static size_t mei_me_hbuf_max_len(const struct mei_device *dev)
> +static size_t mei_me_hbuf_max_len(const struct mei_host *dev)
>  {
>  	return dev->hbuf_depth * sizeof(u32) - sizeof(struct mei_msg_hdr);
> } @@ -290,7 +290,7 @@ static size_t mei_me_hbuf_max_len(const struct
> mei_device *dev)
>   *
>   * This function returns -EIO if write has failed
>   */
> -static int mei_me_write_message(struct mei_device *dev,
> +static int mei_me_write_message(struct mei_host *dev,
>  			struct mei_msg_hdr *header,
>  			unsigned char *buf)
>  {
> @@ -338,7 +338,7 @@ static int mei_me_write_message(struct mei_device
> *dev,
>   *
>   * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise filled slots count
>   */
> -static int mei_me_count_full_read_slots(struct mei_device *dev)
> +static int mei_me_count_full_read_slots(struct mei_host *dev)
>  {
>  	struct mei_me_hw *hw = to_me_hw(dev);
>  	char read_ptr, write_ptr;
> @@ -365,7 +365,7 @@ static int mei_me_count_full_read_slots(struct
> mei_device *dev)
>   * @buffer: message buffer will be written
>   * @buffer_length: message size will be read
>   */
> -static int mei_me_read_slots(struct mei_device *dev, unsigned char
> *buffer,
> +static int mei_me_read_slots(struct mei_host *dev, unsigned char
> +*buffer,
>  		    unsigned long buffer_length)
>  {
>  	struct mei_me_hw *hw = to_me_hw(dev);
> @@ -396,7 +396,7 @@ static int mei_me_read_slots(struct mei_device *dev,
> unsigned char *buffer,
> 
>  irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id)  {
> -	struct mei_device *dev = (struct mei_device *) dev_id;
> +	struct mei_host *dev = (struct mei_host *) dev_id;
>  	struct mei_me_hw *hw = to_me_hw(dev);
>  	u32 csr_reg = mei_hcsr_read(hw);
> 
> @@ -421,7 +421,7 @@ irqreturn_t mei_me_irq_quick_handler(int irq, void
> *dev_id)
>   */
>  irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)  {
> -	struct mei_device *dev = (struct mei_device *) dev_id;
> +	struct mei_host *dev = (struct mei_host *) dev_id;
>  	struct mei_cl_cb complete_list;
>  	struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
>  	struct mei_cl *cl;
> @@ -549,11 +549,11 @@ static const struct mei_hw_ops mei_me_hw_ops =
> {
>   *
>   * returns The mei_device_device pointer on success, NULL on failure.
>   */
> -struct mei_device *mei_me_dev_init(struct pci_dev *pdev)
> +struct mei_host *mei_me_dev_init(struct pci_dev *pdev)
>  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
> 
> -	dev = kzalloc(sizeof(struct mei_device) +
> +	dev = kzalloc(sizeof(struct mei_host) +
>  			 sizeof(struct mei_me_hw), GFP_KERNEL);
>  	if (!dev)
>  		return NULL;
> diff --git a/drivers/misc/mei/hw-me.h b/drivers/misc/mei/hw-me.h index
> 8518d3e..66d6755 100644
> --- a/drivers/misc/mei/hw-me.h
> +++ b/drivers/misc/mei/hw-me.h
> @@ -34,7 +34,7 @@ struct mei_me_hw {
> 
>  #define to_me_hw(dev) (struct mei_me_hw *)((dev)->hw)
> 
> -struct mei_device *mei_me_dev_init(struct pci_dev *pdev);
> +struct mei_host *mei_me_dev_init(struct pci_dev *pdev);
> 
>  /* get slots (dwords) from a message length + header (bytes) */  static inline
> unsigned char mei_data2slots(size_t length) diff --git
> a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index 6ec5301..d4b48a7
> 100644
> --- a/drivers/misc/mei/init.c
> +++ b/drivers/misc/mei/init.c
> @@ -42,7 +42,7 @@ const char *mei_dev_state_str(int state)  #undef
> MEI_DEV_STATE  }
> 
> -void mei_device_init(struct mei_device *dev)
> +void mei_device_init(struct mei_host *dev)
>  {
>  	/* setup our list array */
>  	INIT_LIST_HEAD(&dev->file_list);
> @@ -65,7 +65,7 @@ void mei_device_init(struct mei_device *dev)
>   *
>   * returns 0 on success, <0 on failure.
>   */
> -int mei_hw_init(struct mei_device *dev)
> +int mei_hw_init(struct mei_host *dev)
>  {
>  	int ret = 0;
> 
> @@ -133,7 +133,7 @@ err:
>   * @dev: the device structure
>   * @interrupts_enabled: if interrupt should be enabled after reset.
>   */
> -void mei_reset(struct mei_device *dev, int interrupts_enabled)
> +void mei_reset(struct mei_host *dev, int interrupts_enabled)
>  {
>  	bool unexpected;
> 
> diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index
> 3535b26..30cc864 100644
> --- a/drivers/misc/mei/interrupt.c
> +++ b/drivers/misc/mei/interrupt.c
> @@ -81,7 +81,7 @@ static int _mei_irq_thread_state_ok(struct mei_cl *cl,
>   * returns 0 on success, <0 on failure.
>   */
>  static int mei_irq_thread_read_client_message(struct mei_cl_cb
> *complete_list,
> -		struct mei_device *dev,
> +		struct mei_host *dev,
>  		struct mei_msg_hdr *mei_hdr)
>  {
>  	struct mei_cl *cl;
> @@ -148,7 +148,7 @@ quit:
>   *
>   * returns 0, OK; otherwise, error.
>   */
> -static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
> +static int _mei_irq_thread_close(struct mei_host *dev, s32 *slots,
>  				struct mei_cl_cb *cb_pos,
>  				struct mei_cl *cl,
>  				struct mei_cl_cb *cmpl_list)
> @@ -187,7 +187,7 @@ static int _mei_irq_thread_close(struct mei_device
> *dev, s32 *slots,
>   *
>   * returns 0, OK; otherwise, error.
>   */
> -static int _mei_irq_thread_read(struct mei_device *dev,	s32 *slots,
> +static int _mei_irq_thread_read(struct mei_host *dev,	s32 *slots,
>  			struct mei_cl_cb *cb_pos,
>  			struct mei_cl *cl,
>  			struct mei_cl_cb *cmpl_list)
> @@ -224,7 +224,7 @@ static int _mei_irq_thread_read(struct mei_device
> *dev,	s32 *slots,
>   *
>   * returns 0, OK; otherwise, error.
>   */
> -static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
> +static int _mei_irq_thread_ioctl(struct mei_host *dev, s32 *slots,
>  			struct mei_cl_cb *cb_pos,
>  			struct mei_cl *cl,
>  			struct mei_cl_cb *cmpl_list)
> @@ -260,7 +260,7 @@ static int _mei_irq_thread_ioctl(struct mei_device
> *dev, s32 *slots,
>   *
>   * returns 0, OK; otherwise, error.
>   */
> -static int mei_irq_thread_write_complete(struct mei_device *dev, s32
> *slots,
> +static int mei_irq_thread_write_complete(struct mei_host *dev, s32
> +*slots,
>  			struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list)  {
>  	struct mei_msg_hdr mei_hdr;
> @@ -319,7 +319,7 @@ static int mei_irq_thread_write_complete(struct
> mei_device *dev, s32 *slots,
>   *
>   * returns 0 on success, <0 on failure.
>   */
> -int mei_irq_read_handler(struct mei_device *dev,
> +int mei_irq_read_handler(struct mei_host *dev,
>  		struct mei_cl_cb *cmpl_list, s32 *slots)  {
>  	struct mei_msg_hdr *mei_hdr;
> @@ -419,7 +419,7 @@ end:
>   *
>   * returns 0 on success, <0 on failure.
>   */
> -int mei_irq_write_handler(struct mei_device *dev,
> +int mei_irq_write_handler(struct mei_host *dev,
>  				struct mei_cl_cb *cmpl_list)
>  {
> 
> @@ -577,8 +577,8 @@ void mei_timer(struct work_struct *work)
>  	struct mei_cl_cb  *cb_pos = NULL;
>  	struct mei_cl_cb  *cb_next = NULL;
> 
> -	struct mei_device *dev = container_of(work,
> -					struct mei_device,
> timer_work.work);
> +	struct mei_host *dev = container_of(work,
> +					struct mei_host, timer_work.work);
> 
> 
>  	mutex_lock(&dev->device_lock);
> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index
> 903f809..da8cef5 100644
> --- a/drivers/misc/mei/main.c
> +++ b/drivers/misc/mei/main.c
> @@ -56,7 +56,7 @@ static int mei_open(struct inode *inode, struct file *file)
>  	struct miscdevice *misc = file->private_data;
>  	struct pci_dev *pdev;
>  	struct mei_cl *cl;
> -	struct mei_device *dev;
> +	struct mei_host *dev;
> 
>  	int err;
> 
> @@ -117,7 +117,7 @@ static int mei_release(struct inode *inode, struct file
> *file)  {
>  	struct mei_cl *cl = file->private_data;
>  	struct mei_cl_cb *cb;
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	int rets = 0;
> 
>  	if (WARN_ON(!cl || !cl->dev))
> @@ -193,7 +193,7 @@ static ssize_t mei_read(struct file *file, char __user
> *ubuf,
>  	struct mei_cl *cl = file->private_data;
>  	struct mei_cl_cb *cb_pos = NULL;
>  	struct mei_cl_cb *cb = NULL;
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	int i;
>  	int rets;
>  	int err;
> @@ -343,7 +343,7 @@ static ssize_t mei_write(struct file *file, const char
> __user *ubuf,
>  	struct mei_cl *cl = file->private_data;
>  	struct mei_cl_cb *write_cb = NULL;
>  	struct mei_msg_hdr mei_hdr;
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	unsigned long timeout = 0;
>  	int rets;
>  	int i;
> @@ -516,7 +516,7 @@ err:
>  static int mei_ioctl_connect_client(struct file *file,
>  			struct mei_connect_client_data *data)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	struct mei_client *client;
>  	struct mei_cl *cl;
>  	int i;
> @@ -611,7 +611,7 @@ end:
>   */
>  static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	struct mei_cl *cl = file->private_data;
>  	struct mei_connect_client_data *connect_data = NULL;
>  	int rets;
> @@ -697,7 +697,7 @@ static long mei_compat_ioctl(struct file *file,  static
> unsigned int mei_poll(struct file *file, poll_table *wait)  {
>  	struct mei_cl *cl = file->private_data;
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	unsigned int mask = 0;
> 
>  	if (WARN_ON(!cl || !cl->dev))
> diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
> index cb80166..b521313 100644
> --- a/drivers/misc/mei/mei_dev.h
> +++ b/drivers/misc/mei/mei_dev.h
> @@ -194,7 +194,7 @@ struct mei_cl_cb {
>  /* MEI client instance carried as file->pirvate_data*/  struct mei_cl {
>  	struct list_head link;
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	enum file_state state;
>  	wait_queue_head_t tx_wait;
>  	wait_queue_head_t rx_wait;
> @@ -237,34 +237,34 @@ struct mei_cl {
>   */
>  struct mei_hw_ops {
> 
> -	void (*host_set_ready) (struct mei_device *dev);
> -	bool (*host_is_ready) (struct mei_device *dev);
> +	void (*host_set_ready) (struct mei_host *dev);
> +	bool (*host_is_ready) (struct mei_host *dev);
> 
> -	bool (*hw_is_ready) (struct mei_device *dev);
> -	void (*hw_reset) (struct mei_device *dev, bool enable);
> -	void (*hw_config) (struct mei_device *dev);
> +	bool (*hw_is_ready) (struct mei_host *dev);
> +	void (*hw_reset) (struct mei_host *dev, bool enable);
> +	void (*hw_config) (struct mei_host *dev);
> 
> -	void (*intr_clear) (struct mei_device *dev);
> -	void (*intr_enable) (struct mei_device *dev);
> -	void (*intr_disable) (struct mei_device *dev);
> +	void (*intr_clear) (struct mei_host *dev);
> +	void (*intr_enable) (struct mei_host *dev);
> +	void (*intr_disable) (struct mei_host *dev);
> 
> -	int (*hbuf_free_slots) (struct mei_device *dev);
> -	bool (*hbuf_is_ready) (struct mei_device *dev);
> -	size_t (*hbuf_max_len) (const struct mei_device *dev);
> +	int (*hbuf_free_slots) (struct mei_host *dev);
> +	bool (*hbuf_is_ready) (struct mei_host *dev);
> +	size_t (*hbuf_max_len) (const struct mei_host *dev);
> 
> -	int (*write)(struct mei_device *dev,
> +	int (*write)(struct mei_host *dev,
>  		     struct mei_msg_hdr *hdr,
>  		     unsigned char *buf);
> 
> -	int (*rdbuf_full_slots)(struct mei_device *dev);
> +	int (*rdbuf_full_slots)(struct mei_host *dev);
> 
> -	u32 (*read_hdr)(const struct mei_device *dev);
> -	int (*read) (struct mei_device *dev,
> +	u32 (*read_hdr)(const struct mei_host *dev);
> +	int (*read) (struct mei_host *dev,
>  		     unsigned char *buf, unsigned long len);  };
> 
>  /**
> - * struct mei_device -  MEI private device struct
> + * struct mei_host -  MEI private host struct
> 
>   * @mem_addr - mem mapped base register address
> 
> @@ -273,7 +273,7 @@ struct mei_hw_ops {
>   * @wr_msg - the buffer for hbm control messages
>   * @wr_ext_msg - the buffer for hbm control responses (set in read cycle)
>   */
> -struct mei_device {
> +struct mei_host {
>  	struct pci_dev *pdev;	/* pointer to pci device struct */
>  	/*
>  	 * lists of queues
> @@ -378,144 +378,144 @@ static inline unsigned long
> mei_secs_to_jiffies(unsigned long sec)
>  /*
>   * mei init function prototypes
>   */
> -void mei_device_init(struct mei_device *dev); -void mei_reset(struct
> mei_device *dev, int interrupts); -int mei_hw_init(struct mei_device *dev);
> +void mei_device_init(struct mei_host *dev); void mei_reset(struct
> +mei_host *dev, int interrupts); int mei_hw_init(struct mei_host *dev);
> 
>  /*
>   *  MEI interrupt functions prototype
>   */
> 
>  void mei_timer(struct work_struct *work); -int mei_irq_read_handler(struct
> mei_device *dev,
> +int mei_irq_read_handler(struct mei_host *dev,
>  		struct mei_cl_cb *cmpl_list, s32 *slots);
> 
> -int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb
> *cmpl_list);
> +int mei_irq_write_handler(struct mei_host *dev, struct mei_cl_cb
> +*cmpl_list);
> 
>  void mei_irq_complete_handler(struct mei_cl *cl, struct mei_cl_cb
> *cb_pos);
> 
>  /*
>   * AMTHIF - AMT Host Interface Functions
>   */
> -void mei_amthif_reset_params(struct mei_device *dev);
> +void mei_amthif_reset_params(struct mei_host *dev);
> 
> -int mei_amthif_host_init(struct mei_device *dev);
> +int mei_amthif_host_init(struct mei_host *dev);
> 
> -int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *priv_cb);
> +int mei_amthif_write(struct mei_host *dev, struct mei_cl_cb *priv_cb);
> 
> -int mei_amthif_read(struct mei_device *dev, struct file *file,
> +int mei_amthif_read(struct mei_host *dev, struct file *file,
>  		char __user *ubuf, size_t length, loff_t *offset);
> 
> -unsigned int mei_amthif_poll(struct mei_device *dev,
> +unsigned int mei_amthif_poll(struct mei_host *dev,
>  		struct file *file, poll_table *wait);
> 
> -int mei_amthif_release(struct mei_device *dev, struct file *file);
> +int mei_amthif_release(struct mei_host *dev, struct file *file);
> 
> -struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device
> *dev,
> +struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_host *dev,
>  						struct file *file);
> 
> -void mei_amthif_run_next_cmd(struct mei_device *dev);
> +void mei_amthif_run_next_cmd(struct mei_host *dev);
> 
> 
> -int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
> +int mei_amthif_irq_write_complete(struct mei_host *dev, s32 *slots,
>  			struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list);
> 
> -void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb);
> +void mei_amthif_complete(struct mei_host *dev, struct mei_cl_cb *cb);
>  int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
> -		struct mei_device *dev, struct mei_msg_hdr *mei_hdr);
> -int mei_amthif_irq_read(struct mei_device *dev, s32 *slots);
> +		struct mei_host *dev, struct mei_msg_hdr *mei_hdr); int
> +mei_amthif_irq_read(struct mei_host *dev, s32 *slots);
> 
> 
> -int mei_wd_send(struct mei_device *dev); -int mei_wd_stop(struct
> mei_device *dev); -int mei_wd_host_init(struct mei_device *dev);
> +int mei_wd_send(struct mei_host *dev);
> +int mei_wd_stop(struct mei_host *dev);
> +int mei_wd_host_init(struct mei_host *dev);
>  /*
>   * mei_watchdog_register  - Registering watchdog interface
>   *   once we got connection to the WD Client
>   * @dev - mei device
>   */
> -void mei_watchdog_register(struct mei_device *dev);
> +void mei_watchdog_register(struct mei_host *dev);
>  /*
>   * mei_watchdog_unregister  - Unregistering watchdog interface
>   * @dev - mei device
>   */
> -void mei_watchdog_unregister(struct mei_device *dev);
> +void mei_watchdog_unregister(struct mei_host *dev);
> 
>  /*
>   * Register Access Function
>   */
> 
> -static inline void mei_hw_config(struct mei_device *dev)
> +static inline void mei_hw_config(struct mei_host *dev)
>  {
>  	dev->ops->hw_config(dev);
>  }
> -static inline void mei_hw_reset(struct mei_device *dev, bool enable)
> +static inline void mei_hw_reset(struct mei_host *dev, bool enable)
>  {
>  	dev->ops->hw_reset(dev, enable);
>  }
> 
> -static inline void mei_clear_interrupts(struct mei_device *dev)
> +static inline void mei_clear_interrupts(struct mei_host *dev)
>  {
>  	dev->ops->intr_clear(dev);
>  }
> 
> -static inline void mei_enable_interrupts(struct mei_device *dev)
> +static inline void mei_enable_interrupts(struct mei_host *dev)
>  {
>  	dev->ops->intr_enable(dev);
>  }
> 
> -static inline void mei_disable_interrupts(struct mei_device *dev)
> +static inline void mei_disable_interrupts(struct mei_host *dev)
>  {
>  	dev->ops->intr_disable(dev);
>  }
> 
> -static inline void mei_host_set_ready(struct mei_device *dev)
> +static inline void mei_host_set_ready(struct mei_host *dev)
>  {
>  	dev->ops->host_set_ready(dev);
>  }
> -static inline bool mei_host_is_ready(struct mei_device *dev)
> +static inline bool mei_host_is_ready(struct mei_host *dev)
>  {
>  	return dev->ops->host_is_ready(dev);
>  }
> -static inline bool mei_hw_is_ready(struct mei_device *dev)
> +static inline bool mei_hw_is_ready(struct mei_host *dev)
>  {
>  	return dev->ops->hw_is_ready(dev);
>  }
> 
> -static inline bool mei_hbuf_is_ready(struct mei_device *dev)
> +static inline bool mei_hbuf_is_ready(struct mei_host *dev)
>  {
>  	return dev->ops->hbuf_is_ready(dev);
>  }
> 
> -static inline int mei_hbuf_empty_slots(struct mei_device *dev)
> +static inline int mei_hbuf_empty_slots(struct mei_host *dev)
>  {
>  	return dev->ops->hbuf_free_slots(dev);  }
> 
> -static inline size_t mei_hbuf_max_len(const struct mei_device *dev)
> +static inline size_t mei_hbuf_max_len(const struct mei_host *dev)
>  {
>  	return dev->ops->hbuf_max_len(dev);
>  }
> 
> -static inline int mei_write_message(struct mei_device *dev,
> +static inline int mei_write_message(struct mei_host *dev,
>  			struct mei_msg_hdr *hdr,
>  			unsigned char *buf)
>  {
>  	return dev->ops->write(dev, hdr, buf);  }
> 
> -static inline u32 mei_read_hdr(const struct mei_device *dev)
> +static inline u32 mei_read_hdr(const struct mei_host *dev)
>  {
>  	return dev->ops->read_hdr(dev);
>  }
> 
> -static inline void mei_read_slots(struct mei_device *dev,
> +static inline void mei_read_slots(struct mei_host *dev,
>  		     unsigned char *buf, unsigned long len)  {
>  	dev->ops->read(dev, buf, len);
>  }
> 
> -static inline int mei_count_full_read_slots(struct mei_device *dev)
> +static inline int mei_count_full_read_slots(struct mei_host *dev)
>  {
>  	return dev->ops->rdbuf_full_slots(dev);  } diff --git
> a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index
> b40ec06..8e88ec0 100644
> --- a/drivers/misc/mei/pci-me.c
> +++ b/drivers/misc/mei/pci-me.c
> @@ -121,7 +121,7 @@ static bool mei_quirk_probe(struct pci_dev *pdev,
>   */
>  static int mei_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	struct mei_me_hw *hw;
>  	int err;
> 
> @@ -235,7 +235,7 @@ end:
>   */
>  static void mei_remove(struct pci_dev *pdev)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	struct mei_me_hw *hw;
> 
>  	if (mei_pdev != pdev)
> @@ -307,7 +307,7 @@ static void mei_remove(struct pci_dev *pdev)  static
> int mei_pci_suspend(struct device *device)  {
>  	struct pci_dev *pdev = to_pci_dev(device);
> -	struct mei_device *dev = pci_get_drvdata(pdev);
> +	struct mei_host *dev = pci_get_drvdata(pdev);
>  	int err;
> 
>  	if (!dev)
> @@ -335,7 +335,7 @@ static int mei_pci_suspend(struct device *device)
> static int mei_pci_resume(struct device *device)  {
>  	struct pci_dev *pdev = to_pci_dev(device);
> -	struct mei_device *dev;
> +	struct mei_host *dev;
>  	int err;
> 
>  	dev = pci_get_drvdata(pdev);
> diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c index
> 2413247..51cc54f 100644
> --- a/drivers/misc/mei/wd.c
> +++ b/drivers/misc/mei/wd.c
> @@ -47,7 +47,7 @@ const uuid_le mei_wd_guid = UUID_LE(0x05B79A6F,
> 0x4628, 0x4D7F, 0x89,
>  						0x9D, 0xA9, 0x15, 0x14, 0xCB,
>  						0x32, 0xAB);
> 
> -static void mei_wd_set_start_timeout(struct mei_device *dev, u16
> timeout)
> +static void mei_wd_set_start_timeout(struct mei_host *dev, u16 timeout)
>  {
>  	dev_dbg(&dev->pdev->dev, "wd: set timeout=%d.\n", timeout);
>  	memcpy(dev->wd_data, mei_start_wd_params,
> MEI_WD_HDR_SIZE); @@ -62,7 +62,7 @@ static void
> mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)
>   *         -EIO if write has failed
>   *         0 on success
>   */
> -int mei_wd_host_init(struct mei_device *dev)
> +int mei_wd_host_init(struct mei_host *dev)
>  {
>  	struct mei_cl *cl = &dev->wd_cl;
>  	int i;
> @@ -112,7 +112,7 @@ int mei_wd_host_init(struct mei_device *dev)
>   *	-EIO when message send fails
>   *	-EINVAL when invalid message is to be sent
>   */
> -int mei_wd_send(struct mei_device *dev)
> +int mei_wd_send(struct mei_host *dev)
>  {
>  	struct mei_msg_hdr hdr;
> 
> @@ -141,7 +141,7 @@ int mei_wd_send(struct mei_device *dev)
>   *	-EIO when message send fails
>   *	-EINVAL when invalid message is to be sent
>   */
> -int mei_wd_stop(struct mei_device *dev)
> +int mei_wd_stop(struct mei_host *dev)
>  {
>  	int ret;
> 
> @@ -204,7 +204,7 @@ out:
>  static int mei_wd_ops_start(struct watchdog_device *wd_dev)  {
>  	int err = -ENODEV;
> -	struct mei_device *dev;
> +	struct mei_host *dev;
> 
>  	dev = watchdog_get_drvdata(wd_dev);
>  	if (!dev)
> @@ -242,7 +242,7 @@ end_unlock:
>   */
>  static int mei_wd_ops_stop(struct watchdog_device *wd_dev)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
> 
>  	dev = watchdog_get_drvdata(wd_dev);
>  	if (!dev)
> @@ -265,7 +265,7 @@ static int mei_wd_ops_stop(struct watchdog_device
> *wd_dev)  static int mei_wd_ops_ping(struct watchdog_device *wd_dev)  {
>  	int ret = 0;
> -	struct mei_device *dev;
> +	struct mei_host *dev;
> 
>  	dev = watchdog_get_drvdata(wd_dev);
>  	if (!dev)
> @@ -319,7 +319,7 @@ end:
>   */
>  static int mei_wd_ops_set_timeout(struct watchdog_device *wd_dev,
> unsigned int timeout)  {
> -	struct mei_device *dev;
> +	struct mei_host *dev;
> 
>  	dev = watchdog_get_drvdata(wd_dev);
>  	if (!dev)
> @@ -366,7 +366,7 @@ static struct watchdog_device amt_wd_dev = {  };
> 
> 
> -void mei_watchdog_register(struct mei_device *dev)
> +void mei_watchdog_register(struct mei_host *dev)
>  {
>  	if (watchdog_register_device(&amt_wd_dev)) {
>  		dev_err(&dev->pdev->dev,
> @@ -379,7 +379,7 @@ void mei_watchdog_register(struct mei_device *dev)
>  	watchdog_set_drvdata(&amt_wd_dev, dev);  }
> 
> -void mei_watchdog_unregister(struct mei_device *dev)
> +void mei_watchdog_unregister(struct mei_host *dev)
>  {
>  	if (watchdog_get_drvdata(&amt_wd_dev) == NULL)
>  		return;
> --
> 1.7.10.4


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host
  2013-02-12 21:17   ` Winkler, Tomas
@ 2013-02-12 21:29     ` Samuel Ortiz
  2013-02-12 21:38       ` gregkh
  0 siblings, 1 reply; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-12 21:29 UTC (permalink / raw)
  To: Winkler, Tomas; +Cc: gregkh, arnd, linux-kernel

Hi Tomas,

On Tue, Feb 12, 2013 at 09:17:21PM +0000, Winkler, Tomas wrote:
> 
> 
> > In preparation for the MEI bus code merge, we rename the mei_device
> > structure to mei_host.
> > struct mei_device will be used for devices on the MEI bus in order to follow
> > exisiting driver model implementations practices.
> > 
> I'd like to NACK this name, we use  'host' for the host part of the MEI protocol, 
> 
> You can use the mei_controller, mei_adapter, and  I'm not sure what else can come into mind.
mei_controller sounds good to me.


> I prefer not to break the HW spec language.  I prefer to leave it mei_device as after all it's a device on pci bus it's not a pure host controller.
> And call what is on the mei  bus mei_cl_dev or mei_app_dev . From the HW perspective it actually 
> talks to a client/application residing inside MEI device, it is not always a physical device like NFC.
> 
The bus is not physical neither. It's really items that we add to this bus,
watchdog could be the next candidate for example.

> Please let's find something that makes both hw and Linux happy
I still believe it makes sense to use mei_device for what we add to the MEI
bus. I'd be fine with mei_bus_device as well, but that would somehow look
a bit awkward. Greg, Arnd, any preference ?

>From the MEI core code readers perspective, this will mostly be transparent
as only the technology specific parts of the MEI driver (e.g. nfc.c) will use
that mei_device structure.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host
  2013-02-12 21:29     ` Samuel Ortiz
@ 2013-02-12 21:38       ` gregkh
  2013-02-12 23:09         ` Arnd Bergmann
  0 siblings, 1 reply; 22+ messages in thread
From: gregkh @ 2013-02-12 21:38 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: Winkler, Tomas, arnd, linux-kernel

On Tue, Feb 12, 2013 at 10:29:35PM +0100, Samuel Ortiz wrote:
> Hi Tomas,
> 
> On Tue, Feb 12, 2013 at 09:17:21PM +0000, Winkler, Tomas wrote:
> > 
> > 
> > > In preparation for the MEI bus code merge, we rename the mei_device
> > > structure to mei_host.
> > > struct mei_device will be used for devices on the MEI bus in order to follow
> > > exisiting driver model implementations practices.
> > > 
> > I'd like to NACK this name, we use  'host' for the host part of the MEI protocol, 
> > 
> > You can use the mei_controller, mei_adapter, and  I'm not sure what else can come into mind.
> mei_controller sounds good to me.
> 
> 
> > I prefer not to break the HW spec language.  I prefer to leave it mei_device as after all it's a device on pci bus it's not a pure host controller.
> > And call what is on the mei  bus mei_cl_dev or mei_app_dev . From the HW perspective it actually 
> > talks to a client/application residing inside MEI device, it is not always a physical device like NFC.
> > 
> The bus is not physical neither. It's really items that we add to this bus,
> watchdog could be the next candidate for example.
> 
> > Please let's find something that makes both hw and Linux happy
> I still believe it makes sense to use mei_device for what we add to the MEI
> bus. I'd be fine with mei_bus_device as well, but that would somehow look
> a bit awkward. Greg, Arnd, any preference ?

"mei_device" works the best for me.  Tomas, what you think of as a "MEI
Device" really is a "MEI Controller", it bridges the difference between
the PCI bus and your new MEI bus, so you will need to start thinking of
these things a bit differently now that you have created your own little
virtual bus.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host
  2013-02-12 21:38       ` gregkh
@ 2013-02-12 23:09         ` Arnd Bergmann
  2013-02-13  9:39           ` Samuel Ortiz
  0 siblings, 1 reply; 22+ messages in thread
From: Arnd Bergmann @ 2013-02-12 23:09 UTC (permalink / raw)
  To: gregkh; +Cc: Samuel Ortiz, Winkler, Tomas, linux-kernel

On Tuesday 12 February 2013, gregkh@linuxfoundation.org wrote:
> > 
> > > Please let's find something that makes both hw and Linux happy
> > I still believe it makes sense to use mei_device for what we add to the MEI
> > bus. I'd be fine with mei_bus_device as well, but that would somehow look
> > a bit awkward. Greg, Arnd, any preference ?
> 
> "mei_device" works the best for me.  Tomas, what you think of as a "MEI
> Device" really is a "MEI Controller", it bridges the difference between
> the PCI bus and your new MEI bus, so you will need to start thinking of
> these things a bit differently now that you have created your own little
> virtual bus.

Yes, I agree. mei_bus_device would also work as the name for the controller,
but not for the devices attached to it IMO.

	Arnd

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host
  2013-02-12 23:09         ` Arnd Bergmann
@ 2013-02-13  9:39           ` Samuel Ortiz
  2013-02-19 13:32             ` Tomas Winkler
  0 siblings, 1 reply; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-13  9:39 UTC (permalink / raw)
  To: Arnd Bergmann, Winkler, Tomas; +Cc: gregkh, linux-kernel

On Tue, Feb 12, 2013 at 11:09:00PM +0000, Arnd Bergmann wrote:
> On Tuesday 12 February 2013, gregkh@linuxfoundation.org wrote:
> > > 
> > > > Please let's find something that makes both hw and Linux happy
> > > I still believe it makes sense to use mei_device for what we add to the MEI
> > > bus. I'd be fine with mei_bus_device as well, but that would somehow look
> > > a bit awkward. Greg, Arnd, any preference ?
> > 
> > "mei_device" works the best for me.  Tomas, what you think of as a "MEI
> > Device" really is a "MEI Controller", it bridges the difference between
> > the PCI bus and your new MEI bus, so you will need to start thinking of
> > these things a bit differently now that you have created your own little
> > virtual bus.
> 
> Yes, I agree. mei_bus_device would also work as the name for the controller,
> but not for the devices attached to it IMO.
Tomas, I propose to switch to mei_controller instead of mei_host and keep the
mei_device name for the devices we attach to the MEI bus.
Does that work for you ?

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host
  2013-02-13  9:39           ` Samuel Ortiz
@ 2013-02-19 13:32             ` Tomas Winkler
  2013-02-20 10:57               ` Samuel Ortiz
  0 siblings, 1 reply; 22+ messages in thread
From: Tomas Winkler @ 2013-02-19 13:32 UTC (permalink / raw)
  To: Samuel Ortiz, Arnd Bergmann, Greg KH; +Cc: linux-kernel

On Wed, Feb 13, 2013 at 11:39 AM, Samuel Ortiz <sameo@linux.intel.com> wrote:
>
> On Tue, Feb 12, 2013 at 11:09:00PM +0000, Arnd Bergmann wrote:
> > On Tuesday 12 February 2013, gregkh@linuxfoundation.org wrote:
> > > >
> > > > > Please let's find something that makes both hw and Linux happy
> > > > I still believe it makes sense to use mei_device for what we add to the MEI
> > > > bus. I'd be fine with mei_bus_device as well, but that would somehow look
> > > > a bit awkward. Greg, Arnd, any preference ?
> > >
> > > "mei_device" works the best for me.  Tomas, what you think of as a "MEI
> > > Device" really is a "MEI Controller", it bridges the difference between
> > > the PCI bus and your new MEI bus, so you will need to start thinking of
> > > these things a bit differently now that you have created your own little
> > > virtual bus.
> >
> > Yes, I agree. mei_bus_device would also work as the name for the controller,
> > but not for the devices attached to it IMO.
> Tomas, I propose to switch to mei_controller instead of mei_host and keep the
> mei_device name for the devices we attach to the MEI bus.
> Does that work for you ?
>

The issue is that when we added our virtual bus we haven't gave up on
/dev/mei backed by mei_device
This is the interface, defined in linux/mei.h  which user space
applications use to connect to ME Clients within ME device.
Any ME client can be connected through this interface and we have few
legacy applications running for few years that use this interface so
we are not going to break them.

What we've done now is we added a virtual bus so also in-kernel
applications/subsystems can more naturally connect to the ME Clients,
this connection is client specific.  So the device that connect to the
bus is not an mei device but mei client device hence the name I've
proposed mei_cl_device.

Does it make sense?


Thanks
>
> Cheers,
> Samuel.
>
> --
> Intel Open Source Technology Centre
> http://oss.intel.com/
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host
  2013-02-19 13:32             ` Tomas Winkler
@ 2013-02-20 10:57               ` Samuel Ortiz
  2013-03-11 10:44                 ` Samuel Ortiz
  0 siblings, 1 reply; 22+ messages in thread
From: Samuel Ortiz @ 2013-02-20 10:57 UTC (permalink / raw)
  To: Tomas Winkler; +Cc: Arnd Bergmann, Greg KH, linux-kernel

On Tue, Feb 19, 2013 at 03:32:44PM +0200, Tomas Winkler wrote:
> On Wed, Feb 13, 2013 at 11:39 AM, Samuel Ortiz <sameo@linux.intel.com> wrote:
> >
> > On Tue, Feb 12, 2013 at 11:09:00PM +0000, Arnd Bergmann wrote:
> > > On Tuesday 12 February 2013, gregkh@linuxfoundation.org wrote:
> > > > >
> > > > > > Please let's find something that makes both hw and Linux happy
> > > > > I still believe it makes sense to use mei_device for what we add to the MEI
> > > > > bus. I'd be fine with mei_bus_device as well, but that would somehow look
> > > > > a bit awkward. Greg, Arnd, any preference ?
> > > >
> > > > "mei_device" works the best for me.  Tomas, what you think of as a "MEI
> > > > Device" really is a "MEI Controller", it bridges the difference between
> > > > the PCI bus and your new MEI bus, so you will need to start thinking of
> > > > these things a bit differently now that you have created your own little
> > > > virtual bus.
> > >
> > > Yes, I agree. mei_bus_device would also work as the name for the controller,
> > > but not for the devices attached to it IMO.
> > Tomas, I propose to switch to mei_controller instead of mei_host and keep the
> > mei_device name for the devices we attach to the MEI bus.
> > Does that work for you ?
> >
> 
> The issue is that when we added our virtual bus we haven't gave up on
> /dev/mei backed by mei_device
> This is the interface, defined in linux/mei.h  which user space
> applications use to connect to ME Clients within ME device.
> Any ME client can be connected through this interface and we have few
> legacy applications running for few years that use this interface so
> we are not going to break them.
> 
> What we've done now is we added a virtual bus so also in-kernel
> applications/subsystems can more naturally connect to the ME Clients,
> this connection is client specific.  So the device that connect to the
> bus is not an mei device but mei client device hence the name I've
> proposed mei_cl_device.
I don't have a strong opinion here, so that would be fine with me.
Greg, Arnd, would mei_cl_device and mei_cl_driver be an acceptable compromise?

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host
  2013-02-20 10:57               ` Samuel Ortiz
@ 2013-03-11 10:44                 ` Samuel Ortiz
  2013-03-11 13:34                   ` Arnd Bergmann
  0 siblings, 1 reply; 22+ messages in thread
From: Samuel Ortiz @ 2013-03-11 10:44 UTC (permalink / raw)
  To: Arnd Bergmann, Greg KH; +Cc: linux-kernel, Winkler, Tomas

Hi Greg, Arnd,

On Wed, Feb 20, 2013 at 11:57:31AM +0100, Samuel Ortiz wrote:
> On Tue, Feb 19, 2013 at 03:32:44PM +0200, Tomas Winkler wrote:
> > On Wed, Feb 13, 2013 at 11:39 AM, Samuel Ortiz <sameo@linux.intel.com> wrote:
> > >
> > > On Tue, Feb 12, 2013 at 11:09:00PM +0000, Arnd Bergmann wrote:
> > > > On Tuesday 12 February 2013, gregkh@linuxfoundation.org wrote:
> > > > > >
> > > > > > > Please let's find something that makes both hw and Linux happy
> > > > > > I still believe it makes sense to use mei_device for what we add to the MEI
> > > > > > bus. I'd be fine with mei_bus_device as well, but that would somehow look
> > > > > > a bit awkward. Greg, Arnd, any preference ?
> > > > >
> > > > > "mei_device" works the best for me.  Tomas, what you think of as a "MEI
> > > > > Device" really is a "MEI Controller", it bridges the difference between
> > > > > the PCI bus and your new MEI bus, so you will need to start thinking of
> > > > > these things a bit differently now that you have created your own little
> > > > > virtual bus.
> > > >
> > > > Yes, I agree. mei_bus_device would also work as the name for the controller,
> > > > but not for the devices attached to it IMO.
> > > Tomas, I propose to switch to mei_controller instead of mei_host and keep the
> > > mei_device name for the devices we attach to the MEI bus.
> > > Does that work for you ?
> > >
> > 
> > The issue is that when we added our virtual bus we haven't gave up on
> > /dev/mei backed by mei_device
> > This is the interface, defined in linux/mei.h  which user space
> > applications use to connect to ME Clients within ME device.
> > Any ME client can be connected through this interface and we have few
> > legacy applications running for few years that use this interface so
> > we are not going to break them.
> > 
> > What we've done now is we added a virtual bus so also in-kernel
> > applications/subsystems can more naturally connect to the ME Clients,
> > this connection is client specific.  So the device that connect to the
> > bus is not an mei device but mei client device hence the name I've
> > proposed mei_cl_device.
> I don't have a strong opinion here, so that would be fine with me.
> Greg, Arnd, would mei_cl_device and mei_cl_driver be an acceptable compromise?
I'm re-opening this topic now that the merge window is closed: So would you
guys take mei_cl_device and mei_cl_driver as an acceptable solution or (as you
hinted earlier) are mei_device and mei_driver the only naming scheme that
you'd accept ?

Cheers,
Samuel. 

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host
  2013-03-11 10:44                 ` Samuel Ortiz
@ 2013-03-11 13:34                   ` Arnd Bergmann
  0 siblings, 0 replies; 22+ messages in thread
From: Arnd Bergmann @ 2013-03-11 13:34 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: Greg KH, linux-kernel, Winkler, Tomas

On Monday 11 March 2013, Samuel Ortiz wrote:
> > I don't have a strong opinion here, so that would be fine with me.
> > Greg, Arnd, would mei_cl_device and mei_cl_driver be an acceptable compromise?
> I'm re-opening this topic now that the merge window is closed: So would you
> guys take mei_cl_device and mei_cl_driver as an acceptable solution or (as you
> hinted earlier) are mei_device and mei_driver the only naming scheme that
> you'd accept ?

I'd prefer the latter, but I wouldn't insist on it if you have good reasons
to use the former.

	Arnd

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2013-03-11 13:34 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-12 18:36 [char-misc-next 00/12 v3] Add MEI bus and NFC device Samuel Ortiz
2013-02-12 18:36 ` [char-misc-next 01/12 v3] mei: Rename mei_device to mei_host Samuel Ortiz
2013-02-12 21:17   ` Winkler, Tomas
2013-02-12 21:29     ` Samuel Ortiz
2013-02-12 21:38       ` gregkh
2013-02-12 23:09         ` Arnd Bergmann
2013-02-13  9:39           ` Samuel Ortiz
2013-02-19 13:32             ` Tomas Winkler
2013-02-20 10:57               ` Samuel Ortiz
2013-03-11 10:44                 ` Samuel Ortiz
2013-03-11 13:34                   ` Arnd Bergmann
2013-02-12 18:36 ` [char-misc-next 02/12 v3] mei: bus: Initial MEI bus type implementation Samuel Ortiz
2013-02-12 18:36 ` [char-misc-next 03/12 v3] mei: bus: Implement driver registration Samuel Ortiz
2013-02-12 18:36 ` [char-misc-next 04/12 v3] mei: bus: Initial implementation for I/O routines Samuel Ortiz
2013-02-12 18:36 ` [char-misc-next 05/12 v3] mei: bus: Add bus related structures to mei_cl Samuel Ortiz
2013-02-12 18:36 ` [char-misc-next 06/12 v3] mei: bus: Call bus routines from the core code Samuel Ortiz
2013-02-12 18:36 ` [char-misc-next 07/12 v3] mei: bus: Synchronous API for the data transmission Samuel Ortiz
2013-02-12 18:36 ` [char-misc-next 08/12 v3] mei: bus: Implement bus driver data setter/getter Samuel Ortiz
2013-02-12 18:36 ` [char-misc-next 09/12 v3] mei: nfc: Initial nfc implementation Samuel Ortiz
2013-02-12 18:37 ` [char-misc-next 10/12 v3] mei: nfc: Connect also the regular ME client Samuel Ortiz
2013-02-12 18:37 ` [char-misc-next 11/12 v3] mei: nfc: Add NFC device to the MEI bus Samuel Ortiz
2013-02-12 18:37 ` [char-misc-next 12/12 v3] mei: nfc: Implement MEI bus IO ops Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).