Re: [PATCH RESEND 3/7] USB: serial: metro-usb: get data from device in Uni-Directional mode.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

On 20-03-2012 0:46, Aleksey Babahin wrote:

We should send special control command to tell device start or stop
transmitting a data.

In Bi-Directional mode that cmd`s are not required.

Signed-off-by: Aleksey Babahin<tamerlan311@xxxxxxxxx>
---
  drivers/usb/serial/metro-usb.c |   53 ++++++++++++++++++++++++++++++++++++++++
  1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 92b6f85..2df2217 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -56,6 +56,47 @@ MODULE_DEVICE_TABLE(usb, id_table);
  /* Input parameter constants. */
  static bool debug;

+/* UNI-Directional mode commands for device configure */
+#define UNI_CMD_OPEN	0x80
+#define UNI_CMD_CLOSE	0xFF
+
+inline int metrousb_is_unidirectional_mode(struct usb_serial_port *port)
+{
+	__u16 product_id = le16_to_cpu(
+		port->serial->dev->descriptor.idProduct);
+
+	return product_id == FOCUS_PRODUCT_ID_UNI;
+}
+
+static int metrousb_send_unidirectional_cmd(u8 cmd, struct usb_serial_port *port)
+{
+	int ret;
+	int actual_len;
+	u8 *buffer_cmd = NULL;
+
+	if (!metrousb_is_unidirectional_mode(port))
+		return 0;
+
+	buffer_cmd = kzalloc(sizeof(cmd), GFP_KERNEL);

   Why use kzalloc() if you assign the value immediately after?

+	if (!buffer_cmd)
+		return -ENOMEM;
+
+	*buffer_cmd = cmd;
[...]

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux