Re: [PATCH v3] USB: serial: cp210x: Adding GPIO support for CP2105

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

 





On 15/01/16 21:59, Konstantin Shkolnyy wrote:
From: linux-usb-owner@xxxxxxxxxxxxxxx [mailto:linux-usb-
owner@xxxxxxxxxxxxxxx] On Behalf Of Martyn Welch
Sent: Friday, January 15, 2016 04:51
To: Johan Hovold; Linus Walleij; Alexandre Courbot
Cc: Greg Kroah-Hartman; linux-usb@xxxxxxxxxxxxxxx; linux-
gpio@xxxxxxxxxxxxxxx; Martyn Welch
Subject: [PATCH v3] USB: serial: cp210x: Adding GPIO support for CP2105

...

+static int cp210x_gpio_get(struct gpio_chip *gc, unsigned gpio)
+{
+	struct cp210x_port_private *port_priv =
+			 container_of(gc, struct cp210x_port_private, gc);
+	struct usb_serial *serial = port_priv->serial;
+	u8 *buf;
+	int result;
+
+	buf = kzalloc(sizeof(*buf), GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,
0),
+				 CP210X_VENDOR_SPECIFIC,
+				 REQTYPE_INTERFACE_TO_HOST,
CP210X_READ_LATCH,
+				 port_priv->bInterfaceNumber, buf, 1,
+				 USB_CTRL_GET_TIMEOUT);
+	if (result != 1) {
+		dev_err(&serial->port[port_priv->bInterfaceNumber]->dev,
+			"failed to get gpio state: %d\n", result);
+		result = 0;
+		goto err;

leaking buf


Oops. Thanks.

+	}
+
+	result = (*buf >> gpio) & 0x1;
+
+	kfree(buf);
+err:
+	return result;
+}
...
--
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

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



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux