All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
To: Alan Cox <alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
Cc: Preston Fick <pffick-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	preston.fick-S6d6foEdJf7QT0dZR+AlfA@public.gmane.org,
	"linux-arm-kernel-xIg/pKzrS19vn6HldHNs0ANdhmdF6hFW@public.gmane.org"
	<linux-arm-kernel-xIg/pKzrS19vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
Subject: Re: [PATCH] usb: cp210x: Added support for GPIO (CP2103/4/5)
Date: Wed, 16 May 2012 16:41:28 -0700	[thread overview]
Message-ID: <20120516234128.GB2641@kroah.com> (raw)
In-Reply-To: <20120516163347.1721406e-38n7/U1jhRXW96NNrWNlrekiAK3p4hvP@public.gmane.org>

On Wed, May 16, 2012 at 04:33:47PM +0100, Alan Cox wrote:
> So the patch looks like this, which seems nice and compact (UNTESTED)
> 
> commit 4164f9b7074e682fe71dad3b57e78521ef9df492
> Author: Alan Cox <alan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Date:   Wed May 16 15:13:02 2012 +0100
> 
>     tty: Add a gpio helper set
>     
>     Various tty devices have additional control lines which are sometimes used
>     as GPIO pins and sometimes also tied with the serial port to implement
>     protocols such as ISO7816.
>     
>     This code provides a kernel interface for querying the GPIO range of a tty,
>     and to describe the mapping between GPIO pins and control lines. The latter
>     will be needed for some upcoming line discipline support.
>     
>     [Proposal do not merge yet]
>     
>     Not-Signed-off-by: Alan Cox <alan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

Wow, that looks really nice and tiny, if that's all that is needed in
the core, that's great.

> diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
> index a1b9a2f..60550e7 100644
> --- a/drivers/tty/tty_ioctl.c
> +++ b/drivers/tty/tty_ioctl.c
> @@ -1071,6 +1071,39 @@ int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
>  	case TCSETXF:
>  		return set_termiox(real_tty, p, TERMIOS_FLUSH);
>  #endif		
> +#ifdef TCGGPIO
> +	case TCGGPIO: {
> +		struct tcgpio gpio;
> +
> +		if (tty->gpio == NULL)
> +			return -EOPNOTSUPP;
> +		mutex_lock(&real_tty->termios_mutex);
> +		memset(&gpio, 0, sizeof(gpio));
> +		gpio.base = tty->gpio->base;
> +		gpio.num = tty->gpio->num;
> +		memcpy(gpio.map, tty->gpio->map, sizeof(gpio.map));
> +		mutex_unlock(&real_tty->termios_mutex);
> +		if (copy_to_user(p, &gpio, sizeof(gpio)))
> +			return -EFAULT;
> +		return 0;
> +	}
> +	case TCSGPIO:
> +        {
> +		struct tcgpio gpio;
> +
> +		if (tty->gpio == NULL)
> +			return -EOPNOTSUPP;
> +		if (copy_from_user(&gpio, p, sizeof(gpio)))
> +			return -EFAULT;
> +		mutex_lock(&real_tty->termios_mutex);
> +		memcpy(tty->gpio->map, gpio.map, sizeof(tty->gpio->map));
> +		/* An ldisc can see this by watching the ioctl go through
> +		but we may want to add a hook */
> +		mutex_unlock(&real_tty->termios_mutex);
> +                return 0;

So how would the lower tty driver get the ioctl to know to now set these
values to the hardware?  I think we at least need a hook for that,
right?  Or would that go through the ldisc?


> +        }
> +                
> +#endif
>  	case TIOCGSOFTCAR:
>  		copy_termios(real_tty, &kterm);
>  		ret = put_user((kterm.c_cflag & CLOCAL) ? 1 : 0,
> diff --git a/include/asm-generic/ioctls.h b/include/asm-generic/ioctls.h
> index 199975f..fee17d3 100644
> --- a/include/asm-generic/ioctls.h
> +++ b/include/asm-generic/ioctls.h
> @@ -74,6 +74,8 @@
>  #define TCSETXW		0x5435
>  #define TIOCSIG		_IOW('T', 0x36, int)  /* pty: generate signal */
>  #define TIOCVHANGUP	0x5437
> +#define TCGGPIO		_IOR('T', 0x38, struct tcgpio)
> +#define TCSGPIO		_IOW('T', 0x39, struct tcgpio)
>  
>  #define FIONCLEX	0x5450
>  #define FIOCLEX		0x5451
> diff --git a/include/asm-generic/termios.h b/include/asm-generic/termios.h
> index d0922ad..3adda38 100644
> --- a/include/asm-generic/termios.h
> +++ b/include/asm-generic/termios.h
> @@ -18,6 +18,18 @@ struct winsize {
>  	unsigned short ws_ypixel;
>  };
>  
> +
> +/* GPIO handling */
> +#define NR_TTY_GPIOMAP	8
> +struct tcgpio			/* User copied version */
> +{
> +	u32 base;
> +	u16 num;
> +	u16 reserved;
> +	u32 map[NR_TTY_GPIOMAP];
> +	u32 reserved2[6];
> +};

__u32 and friends instead?

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

WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Preston Fick <pffick@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-serial@vger.kernel.org, preston.fick@silabs.com,
	"linux-arm-kernel@lists.arm.linux.org.uk" 
	<linux-arm-kernel@lists.arm.linux.org.uk>
Subject: Re: [PATCH] usb: cp210x: Added support for GPIO (CP2103/4/5)
Date: Wed, 16 May 2012 16:41:28 -0700	[thread overview]
Message-ID: <20120516234128.GB2641@kroah.com> (raw)
In-Reply-To: <20120516163347.1721406e@pyramind.ukuu.org.uk>

On Wed, May 16, 2012 at 04:33:47PM +0100, Alan Cox wrote:
> So the patch looks like this, which seems nice and compact (UNTESTED)
> 
> commit 4164f9b7074e682fe71dad3b57e78521ef9df492
> Author: Alan Cox <alan@linux.intel.com>
> Date:   Wed May 16 15:13:02 2012 +0100
> 
>     tty: Add a gpio helper set
>     
>     Various tty devices have additional control lines which are sometimes used
>     as GPIO pins and sometimes also tied with the serial port to implement
>     protocols such as ISO7816.
>     
>     This code provides a kernel interface for querying the GPIO range of a tty,
>     and to describe the mapping between GPIO pins and control lines. The latter
>     will be needed for some upcoming line discipline support.
>     
>     [Proposal do not merge yet]
>     
>     Not-Signed-off-by: Alan Cox <alan@linux.intel.com>

Wow, that looks really nice and tiny, if that's all that is needed in
the core, that's great.

> diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
> index a1b9a2f..60550e7 100644
> --- a/drivers/tty/tty_ioctl.c
> +++ b/drivers/tty/tty_ioctl.c
> @@ -1071,6 +1071,39 @@ int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
>  	case TCSETXF:
>  		return set_termiox(real_tty, p, TERMIOS_FLUSH);
>  #endif		
> +#ifdef TCGGPIO
> +	case TCGGPIO: {
> +		struct tcgpio gpio;
> +
> +		if (tty->gpio == NULL)
> +			return -EOPNOTSUPP;
> +		mutex_lock(&real_tty->termios_mutex);
> +		memset(&gpio, 0, sizeof(gpio));
> +		gpio.base = tty->gpio->base;
> +		gpio.num = tty->gpio->num;
> +		memcpy(gpio.map, tty->gpio->map, sizeof(gpio.map));
> +		mutex_unlock(&real_tty->termios_mutex);
> +		if (copy_to_user(p, &gpio, sizeof(gpio)))
> +			return -EFAULT;
> +		return 0;
> +	}
> +	case TCSGPIO:
> +        {
> +		struct tcgpio gpio;
> +
> +		if (tty->gpio == NULL)
> +			return -EOPNOTSUPP;
> +		if (copy_from_user(&gpio, p, sizeof(gpio)))
> +			return -EFAULT;
> +		mutex_lock(&real_tty->termios_mutex);
> +		memcpy(tty->gpio->map, gpio.map, sizeof(tty->gpio->map));
> +		/* An ldisc can see this by watching the ioctl go through
> +		but we may want to add a hook */
> +		mutex_unlock(&real_tty->termios_mutex);
> +                return 0;

So how would the lower tty driver get the ioctl to know to now set these
values to the hardware?  I think we at least need a hook for that,
right?  Or would that go through the ldisc?


> +        }
> +                
> +#endif
>  	case TIOCGSOFTCAR:
>  		copy_termios(real_tty, &kterm);
>  		ret = put_user((kterm.c_cflag & CLOCAL) ? 1 : 0,
> diff --git a/include/asm-generic/ioctls.h b/include/asm-generic/ioctls.h
> index 199975f..fee17d3 100644
> --- a/include/asm-generic/ioctls.h
> +++ b/include/asm-generic/ioctls.h
> @@ -74,6 +74,8 @@
>  #define TCSETXW		0x5435
>  #define TIOCSIG		_IOW('T', 0x36, int)  /* pty: generate signal */
>  #define TIOCVHANGUP	0x5437
> +#define TCGGPIO		_IOR('T', 0x38, struct tcgpio)
> +#define TCSGPIO		_IOW('T', 0x39, struct tcgpio)
>  
>  #define FIONCLEX	0x5450
>  #define FIOCLEX		0x5451
> diff --git a/include/asm-generic/termios.h b/include/asm-generic/termios.h
> index d0922ad..3adda38 100644
> --- a/include/asm-generic/termios.h
> +++ b/include/asm-generic/termios.h
> @@ -18,6 +18,18 @@ struct winsize {
>  	unsigned short ws_ypixel;
>  };
>  
> +
> +/* GPIO handling */
> +#define NR_TTY_GPIOMAP	8
> +struct tcgpio			/* User copied version */
> +{
> +	u32 base;
> +	u16 num;
> +	u16 reserved;
> +	u32 map[NR_TTY_GPIOMAP];
> +	u32 reserved2[6];
> +};

__u32 and friends instead?

greg k-h

  parent reply	other threads:[~2012-05-16 23:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-30 20:27 [PATCH] usb: cp210x: Added support for GPIO (CP2103/4/5) Preston Fick
     [not found] ` <1335817637-2862-1-git-send-email-preston.fick-S6d6foEdJf7QT0dZR+AlfA@public.gmane.org>
2012-04-30 20:32   ` Greg KH
2012-04-30 20:32     ` Greg KH
2012-05-03 20:34   ` Alan Cox
2012-05-03 20:34     ` Alan Cox
     [not found]     ` <20120503213456.77c55c51-38n7/U1jhRXW96NNrWNlrekiAK3p4hvP@public.gmane.org>
2012-05-04 15:27       ` Preston Fick
2012-05-04 15:27         ` Preston Fick
2012-05-05  0:32       ` Greg KH
2012-05-05  0:32         ` Greg KH
2012-05-05 11:01         ` Alan Cox
2012-05-05 14:57           ` Greg KH
2012-05-16 15:33         ` Alan Cox
     [not found]           ` <20120516163347.1721406e-38n7/U1jhRXW96NNrWNlrekiAK3p4hvP@public.gmane.org>
2012-05-16 23:41             ` Greg KH [this message]
2012-05-16 23:41               ` Greg KH
2012-05-04 16:26 ` Alexander Stein
2012-05-04 16:33   ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2012-04-28 16:55 Preston Fick
2012-04-28 18:05 ` Alan Cox
2012-04-28 18:17   ` Uwe Bonnes
2012-04-28 19:33     ` Alan Cox
2012-04-29 13:02       ` Uwe Bonnes
2012-04-29 14:35         ` Xiaofan Chen
     [not found]   ` <20120428190502.32eaf294-38n7/U1jhRXW96NNrWNlrekiAK3p4hvP@public.gmane.org>
2012-04-28 20:30     ` Preston Fick
2012-04-28 20:30       ` Preston Fick
2012-04-28 21:08       ` Alan Cox
     [not found]         ` <20120428220808.4674a8df-38n7/U1jhRXW96NNrWNlrekiAK3p4hvP@public.gmane.org>
2012-04-28 21:44           ` Preston Fick
2012-04-28 21:44             ` Preston Fick

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120516234128.GB2641@kroah.com \
    --to=gregkh-hqyy1w1ycw8ekmwlsbkhg0b+6bgklq7r@public.gmane.org \
    --cc=alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org \
    --cc=linux-arm-kernel-xIg/pKzrS19vn6HldHNs0ANdhmdF6hFW@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pffick-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=preston.fick-S6d6foEdJf7QT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.