lkml.org 
[lkml]   [2014]   [Jul]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] usb:serial:pl2303: add GPIOs interface on PL2303
> --- a/drivers/usb/serial/pl2303.c
> +++ b/drivers/usb/serial/pl2303.c
> @@ -28,6 +28,9 @@
> #include <linux/usb.h>
> #include <linux/usb/serial.h>
> #include <asm/unaligned.h>
> +#ifdef CONFIG_USB_SERIAL_PL2303_GPIO
> +#include <linux/gpio.h>
> +#endif
> #include "pl2303.h"

Just include the file anyway it does no harm

>
>
> @@ -143,9 +146,27 @@ struct pl2303_type_data {
> unsigned long quirks;
> };
>
> +#ifdef CONFIG_USB_SERIAL_PL2303_GPIO
> +struct pl2303_gpio {
> + /*
> + * 0..3: unknown (zero)
> + * 4: gp0 output enable (1: gp0 pin is output, 0: gp0 pin is input)
> + * 5: gp1 output enable (1: gp1 pin is output, 0: gp1 pin is input)
> + * 6: gp0 pin value
> + * 7: gp1 pin value
> + */
> + u8 index;
> + struct usb_serial *serial;
> + struct gpio_chip gpio_chip;
> +};
> +#endif

Declaring the struct anyway does no harm


> struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
>
> +#ifdef CONFIG_USB_SERIAL_PL2303_GPIO
> + if (spriv && spriv->gpio) {

Can spriv ever be NULL - how would that occur?


> + if (gpiochip_remove(&spriv->gpio->gpio_chip))
> + dev_err(&serial->interface->dev, "unable to remove gpio_chip?\n");
> + kfree(spriv->gpio);
> + }
> +#endif
> kfree(spriv);

Only other question I have - if I have multiple PL2303HX adapters how
will I work out which GPIO lines belong to which /dev/ttyUSB* interface ?

Do we need a way to actually ask the serial port for its GPIO range ?


\
 
 \ /
  Last update: 2014-07-23 19:41    [W:0.306 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site