]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mei: enable to set the internal flag for client write
authorAlexander Usyskin <alexander.usyskin@intel.com>
Tue, 8 Nov 2016 16:26:08 +0000 (18:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2016 12:18:02 +0000 (13:18 +0100)
Prepare the client write functions to set the internal flag in message
header. Carry both blocking and internal modes inside the transmit cb,
and call internal bus function  __mei_cl_send() with send mode bit mask.
The Internal flag should be added only on messages generated by the
driver.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/amthif.c
drivers/misc/mei/bus-fixup.c
drivers/misc/mei/bus.c
drivers/misc/mei/client.c
drivers/misc/mei/client.h
drivers/misc/mei/main.c
drivers/misc/mei/mei_dev.h

index 7ae89b4a21d5de5b884d943b0a906b2571e3e7e9..466afb2611c6592b05e98c1c1a0abe1eb1088cea 100644 (file)
@@ -144,7 +144,7 @@ int mei_amthif_run_next_cmd(struct mei_device *dev)
        dev->iamthif_state = MEI_IAMTHIF_WRITING;
        cl->fp = cb->fp;
 
-       ret = mei_cl_write(cl, cb, false);
+       ret = mei_cl_write(cl, cb);
        if (ret < 0)
                return ret;
 
index e9e6ea3ab73cf3500657d8c6001cb4eff5712568..db60d57ebda946cff1de05f26b26b286ef3942cb 100644 (file)
@@ -162,7 +162,8 @@ static int mei_nfc_if_version(struct mei_cl *cl,
 
        WARN_ON(mutex_is_locked(&bus->device_lock));
 
-       ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(struct mei_nfc_cmd), 1);
+       ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(struct mei_nfc_cmd),
+                           MEI_CL_IO_TX_BLOCKING);
        if (ret < 0) {
                dev_err(bus->dev, "Could not send IF version cmd\n");
                return ret;
index 8a1e813a548dd40086ca3e1149e30780554a9a0a..7c075e9b25e5ee837364750bab05133827e4bfc2 100644 (file)
  * @cl: host client
  * @buf: buffer to send
  * @length: buffer length
- * @blocking: wait for write completion
+ * @mode: sending mode
  *
  * Return: written size bytes or < 0 on error
  */
 ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
-                       bool blocking)
+                     unsigned int mode)
 {
        struct mei_device *bus;
        struct mei_cl_cb *cb;
@@ -80,9 +80,11 @@ ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
                goto out;
        }
 
+       cb->internal = !!(mode & MEI_CL_IO_TX_INTERNAL);
+       cb->blocking = !!(mode & MEI_CL_IO_TX_BLOCKING);
        memcpy(cb->buf.data, buf, length);
 
-       rets = mei_cl_write(cl, cb, blocking);
+       rets = mei_cl_write(cl, cb);
 
 out:
        mutex_unlock(&bus->device_lock);
@@ -188,7 +190,7 @@ ssize_t mei_cldev_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
        if (cl == NULL)
                return -ENODEV;
 
-       return __mei_cl_send(cl, buf, length, 1);
+       return __mei_cl_send(cl, buf, length, MEI_CL_IO_TX_BLOCKING);
 }
 EXPORT_SYMBOL_GPL(mei_cldev_send);
 
index 6fe02350578dce04a0ded5f34da8d69274986397..beb942e6c24855ed348f6ed0a995ec723546f1b1 100644 (file)
@@ -1598,18 +1598,17 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
  *
  * @cl: host client
  * @cb: write callback with filled data
- * @blocking: block until completed
  *
  * Return: number of bytes sent on success, <0 on failure.
  */
-int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)
+int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
 {
        struct mei_device *dev;
        struct mei_msg_data *buf;
        struct mei_msg_hdr mei_hdr;
        int size;
        int rets;
-
+       bool blocking;
 
        if (WARN_ON(!cl || !cl->dev))
                return -ENODEV;
@@ -1621,6 +1620,7 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)
 
        buf = &cb->buf;
        size = buf->size;
+       blocking = cb->blocking;
 
        cl_dbg(dev, cl, "size=%d\n", size);
 
index d2bfabecd882c1d963f14f504914857ba06f1a98..f2545af9be7be47ff29f225814d01719108be3fc 100644 (file)
@@ -219,7 +219,7 @@ int mei_cl_irq_connect(struct mei_cl *cl, struct mei_cl_cb *cb,
 int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp);
 int mei_cl_irq_read_msg(struct mei_cl *cl, struct mei_msg_hdr *hdr,
                        struct mei_cl_cb *cmpl_list);
-int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking);
+int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb);
 int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
                     struct mei_cl_cb *cmpl_list);
 
index a1484574cfa8973f01e83a9aa6cd37a0485fe5ae..e1bf54481fd682f0477211190726908e9933b349 100644 (file)
@@ -322,7 +322,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
                goto out;
        }
 
-       rets = mei_cl_write(cl, cb, false);
+       rets = mei_cl_write(cl, cb);
 out:
        mutex_unlock(&dev->device_lock);
        return rets;
index 1169fd9e7d02940a5c1f9b34f928e2b0f33ff204..d50f70b4a05eec56475ab2c0d4c94616eeafd19f 100644 (file)
@@ -109,6 +109,17 @@ enum mei_cb_file_ops {
        MEI_FOP_NOTIFY_STOP,
 };
 
+/**
+ * enum mei_cl_io_mode - io mode between driver and fw
+ *
+ * @MEI_CL_IO_TX_BLOCKING: send is blocking
+ * @MEI_CL_IO_TX_INTERNAL: internal communication between driver and FW
+ */
+enum mei_cl_io_mode {
+       MEI_CL_IO_TX_BLOCKING = BIT(0),
+       MEI_CL_IO_TX_INTERNAL = BIT(1),
+};
+
 /*
  * Intel MEI message data struct
  */
@@ -169,6 +180,7 @@ struct mei_cl;
  * @fp: pointer to file structure
  * @status: io status of the cb
  * @internal: communication between driver and FW flag
+ * @blocking: transmission blocking mode
  * @completed: the transfer or reception has completed
  */
 struct mei_cl_cb {
@@ -180,6 +192,7 @@ struct mei_cl_cb {
        const struct file *fp;
        int status;
        u32 internal:1;
+       u32 blocking:1;
        u32 completed:1;
 };
 
@@ -304,7 +317,7 @@ void mei_cl_bus_rescan(struct mei_device *bus);
 void mei_cl_bus_rescan_work(struct work_struct *work);
 void mei_cl_bus_dev_fixup(struct mei_cl_device *dev);
 ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
-                       bool blocking);
+                     unsigned int mode);
 ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length);
 bool mei_cl_bus_rx_event(struct mei_cl *cl);
 bool mei_cl_bus_notify_event(struct mei_cl *cl);