devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Hurley <peter-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org>
To: NeilBrown <neil-+NVA1uvv1dVBDLzU/O5InQ@public.gmane.org>
Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	One Thousand Gnomes
	<gnomes-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	Sebastian Reichel <sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Jiri Slaby <jslaby-AlSwsSmVLrQ@public.gmane.org>,
	GTA04 owners
	<gta04-owner-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/3] TTY: use class_find_device to find port in uart_suspend/resume.
Date: Wed, 25 Mar 2015 12:20:20 -0400	[thread overview]
Message-ID: <5512E044.4080700@hurleysoftware.com> (raw)
In-Reply-To: <20150318055831.21025.27864.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>

Hi Neil,

On 03/18/2015 01:58 AM, NeilBrown wrote:
> uart_{suspend,resume}_port seach the children of a uart device
> to find a particular tty device.
> This requires all the ttys to be direct children of the uart.
> 
> A future patch will allow a 'tty_slave' to intervene between
> the port and the uart, voiding this requirement.
> 
> So change to use class_find_device.  This is made possibly by
> exporting a "tty_find_device" from tty_io.c

Comments below.

> Signed-off-by: NeilBrown <neil-+NVA1uvv1dVBDLzU/O5InQ@public.gmane.org>
> ---
>  drivers/tty/serial/serial_core.c |   21 ++++++++-------------
>  drivers/tty/tty_io.c             |    6 ++++++
>  include/linux/tty.h              |    1 +
>  3 files changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 6a1055ae3437..7abb7474870a 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -1960,26 +1960,19 @@ struct uart_match {
>  	struct uart_driver *driver;
>  };
>  
> -static int serial_match_port(struct device *dev, void *data)
> -{
> -	struct uart_match *match = data;
> -	struct tty_driver *tty_drv = match->driver->tty_driver;
> -	dev_t devt = MKDEV(tty_drv->major, tty_drv->minor_start) +
> -		match->port->line;
> -
> -	return dev->devt == devt; /* Actually, only one tty per port */
> -}
>  
>  int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
>  {
>  	struct uart_state *state = drv->state + uport->line;
>  	struct tty_port *port = &state->port;
>  	struct device *tty_dev;
> -	struct uart_match match = {uport, drv};
> +	dev_t devt = MKDEV(drv->tty_driver->major,
> +			   drv->tty_driver->minor_start) +
> +		uport->line;
>  
>  	mutex_lock(&port->mutex);
>  
> -	tty_dev = device_find_child(uport->dev, &match, serial_match_port);
> +	tty_dev = tty_find_device(devt);
>  	if (device_may_wakeup(tty_dev)) {
>  		if (!enable_irq_wake(uport->irq))
>  			uport->irq_wake = 1;
> @@ -2039,12 +2032,14 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
>  	struct uart_state *state = drv->state + uport->line;
>  	struct tty_port *port = &state->port;
>  	struct device *tty_dev;
> -	struct uart_match match = {uport, drv};
>  	struct ktermios termios;
> +	dev_t devt = MKDEV(drv->tty_driver->major,
> +			   drv->tty_driver->minor_start) +
> +		uport->line;
>  
>  	mutex_lock(&port->mutex);
>  
> -	tty_dev = device_find_child(uport->dev, &match, serial_match_port);
> +	tty_dev = tty_find_device(devt);
>  	if (!uport->suspended && device_may_wakeup(tty_dev)) {
>  		if (uport->irq_wake) {
>  			disable_irq_wake(uport->irq);
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 51f066aa375e..27632ad17d6f 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -3077,6 +3077,12 @@ static struct device *tty_get_device(struct tty_struct *tty)
>  	return class_find_device(tty_class, NULL, &devt, dev_match_devt);
>  }
>
> +struct device *tty_find_device(dev_t devt)
> +{
> +	return class_find_device(tty_class, NULL, &devt, dev_match_devt);
> +}
> +EXPORT_SYMBOL(tty_find_device);
> +

Would you please replace tty_get_device() usage with tty_find_device()
(and keep the function comment from tty_get_device())?

Regards,
Peter Hurley

>  
>  /**
>   *	alloc_tty_struct
> diff --git a/include/linux/tty.h b/include/linux/tty.h
> index 358a337af598..04d5f1213700 100644
> --- a/include/linux/tty.h
> +++ b/include/linux/tty.h
> @@ -461,6 +461,7 @@ extern void tty_vhangup(struct tty_struct *tty);
>  extern int tty_hung_up_p(struct file *filp);
>  extern void do_SAK(struct tty_struct *tty);
>  extern void __do_SAK(struct tty_struct *tty);
> +extern struct device *tty_find_device(dev_t devt);
>  extern void no_tty(void);
>  extern void tty_flush_to_ldisc(struct tty_struct *tty);
>  extern void tty_buffer_free_all(struct tty_port *port);
> 
> 

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

  parent reply	other threads:[~2015-03-25 16:20 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18  5:58 [PATCH 0/3] tty slave device support - version 3 NeilBrown
2015-03-18  5:58 ` [PATCH 3/3] tty/slaves: add a driver to power on/off UART attached devices NeilBrown
     [not found]   ` <20150318055831.21025.33670.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-03-20  7:54     ` [Gta04-owner] " Dr. H. Nikolaus Schaller
     [not found]       ` <C53A3E5D-5AEA-4F0F-88A9-F9BC8CB0D0D6-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-03-20  8:54         ` NeilBrown
2015-03-20  9:34           ` Dr. H. Nikolaus Schaller
     [not found]             ` <14FB51CF-9568-4BF4-B917-2C019D992FDB-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-03-20 19:50               ` Pavel Machek
2015-03-20 23:31             ` NeilBrown
2015-03-24 17:58               ` Dr. H. Nikolaus Schaller
2015-03-25  1:45                 ` Sebastian Reichel
2015-03-25  7:59                   ` Dr. H. Nikolaus Schaller
2015-03-25 15:21                     ` Sebastian Reichel
2015-03-25 16:44                       ` Dr. H. Nikolaus Schaller
2015-03-26 18:08                         ` Sebastian Reichel
2015-03-27  9:22                           ` Dr. H. Nikolaus Schaller
2015-03-27 16:31                             ` Sebastian Reichel
2015-03-27 17:11                               ` Dr. H. Nikolaus Schaller
2015-04-27 20:35                                 ` Pavel Machek
2015-04-29  6:56                                   ` Dr. H. Nikolaus Schaller
2015-03-25 20:53                     ` Pavel Machek
2015-03-25 21:25                       ` Dr. H. Nikolaus Schaller
     [not found]                         ` <1F3B5E32-1330-457C-AE25-791319293C38-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-03-26  5:56                           ` Pavel Machek
2015-03-26  6:44                             ` Dr. H. Nikolaus Schaller
     [not found]                               ` <365B2C25-1782-4ADE-B620-190A4CC5E8E3-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-04-04  7:52                                 ` Pavel Machek
2015-03-25 20:42                 ` Pavel Machek
2015-03-25 21:22                   ` Dr. H. Nikolaus Schaller
2015-03-18  5:58 ` [PATCH 1/3] TTY: use class_find_device to find port in uart_suspend/resume NeilBrown
     [not found]   ` <20150318055831.21025.27864.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-03-25 16:20     ` Peter Hurley [this message]
2015-03-29 21:49       ` [Gta04-owner] " NeilBrown
2015-03-18  5:58 ` [PATCH 2/3] TTY: add support for tty_slave devices NeilBrown
2015-03-18  9:11   ` Paul Bolle
2015-03-22  3:32     ` NeilBrown
2015-03-20 19:41   ` Pavel Machek
2015-03-22  3:42     ` [Gta04-owner] " NeilBrown
     [not found]       ` <20150322144209.14abc603-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-03-22  7:58         ` Pavel Machek
2015-03-24 10:31   ` Jiri Slaby
2015-03-30 23:45     ` NeilBrown
2015-03-25 16:30   ` Peter Hurley
2015-03-25 21:17     ` [Gta04-owner] " NeilBrown
2015-03-27 11:09       ` Peter Hurley
2015-03-31  0:33         ` NeilBrown
2015-03-20  7:54 ` [Gta04-owner] [PATCH 0/3] tty slave device support - version 3 Dr. H. Nikolaus Schaller
     [not found]   ` <80D7E742-4633-4CCD-B754-221387D82922-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-03-20  8:43     ` NeilBrown
2015-03-20  8:54       ` Dr. H. Nikolaus Schaller
2015-03-20 13:08         ` Sebastian Reichel
2015-03-20 13:57           ` Dr. H. Nikolaus Schaller
     [not found]             ` <72268D51-F993-497A-B4F9-707C8DB7155C-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-03-20 17:14               ` Sebastian Reichel
2015-03-20 19:31 ` Pavel Machek
     [not found] ` <20150318055437.21025.13990.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-05-05 19:54   ` Peter Hurley
2015-05-05 20:46     ` NeilBrown
     [not found]     ` <55492001.30806-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org>
2015-05-06  5:19       ` [Gta04-owner] " Dr. H. Nikolaus Schaller
2015-05-06 11:10         ` Peter Hurley
     [not found]         ` <DE60E7AA-1BF4-4A68-9638-E09F85FD5C72-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-05-06  9:27           ` Pavel Machek
2015-05-06 11:50             ` Dr. H. Nikolaus Schaller
2015-05-06 12:05               ` Peter Hurley
2015-05-06 12:27                 ` Dr. H. Nikolaus Schaller
2015-05-06 12:36                   ` Mark Rutland
2015-05-06 13:28                     ` Dr. H. Nikolaus Schaller
2015-05-06 14:15                       ` Mark Rutland
2015-05-06 16:09                         ` Dr. H. Nikolaus Schaller
2015-05-06 17:18                           ` Mark Rutland
2015-05-07 12:46                             ` Dr. H. Nikolaus Schaller
2015-05-07 14:30                               ` Peter Hurley
2015-05-07 15:11                                 ` Dr. H. Nikolaus Schaller
2015-05-07 16:18                                   ` Peter Hurley
2015-05-07 16:57                                     ` Dr. H. Nikolaus Schaller
     [not found]                               ` <B4D487C5-C260-497B-A441-6C381D53616C-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-05-07 14:56                                 ` Peter Hurley
     [not found]                                   ` <554B7D33.602-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org>
2015-05-07 15:34                                     ` Dr. H. Nikolaus Schaller
2015-05-07 15:51                                       ` Peter Hurley
2015-05-07 16:46                                         ` Dr. H. Nikolaus Schaller
2015-05-13  8:09                                           ` Dr. H. Nikolaus Schaller
2015-06-03 11:49                                             ` [PATCH RFC 0/3] UART slave device support Dr. H. Nikolaus Schaller
     [not found]                                               ` <56C579D3-E8F8-4B5A-B6E8-993B113F3461-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-06-06 13:09                                                 ` Pavel Machek
     [not found]                                             ` <463356C5-E3C6-432C-A1C5-71F0287F1FEE@goldelico.com>
2015-06-03 12:09                                               ` [Gta04-owner] [PATCH RFC 3/3] misc: Add w2g0004 gps receiver driver Christ van Willegen
2015-05-07 15:37                       ` [Gta04-owner] [PATCH 0/3] tty slave device support - version 3 Peter Hurley
     [not found]               ` <A2594559-CA92-40C2-A06A-AC2483E85CB1-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-05-06 14:28                 ` Pavel Machek
2015-05-06 16:12                   ` Dr. H. Nikolaus Schaller
     [not found]                     ` <C68A105A-7147-4143-9B91-1A239726A780-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2015-06-06 13:09                       ` Pavel Machek
2015-06-06 18:53                         ` Belisko Marek
2015-06-06 18:55                           ` Belisko Marek
2015-05-07 15:48           ` Rob Herring

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=5512E044.4080700@hurleysoftware.com \
    --to=peter-wagbzjegnqdsbiue7sb01tbpr1lh4cv8@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=gnomes-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=gta04-owner-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org \
    --cc=jslaby-AlSwsSmVLrQ@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=neil-+NVA1uvv1dVBDLzU/O5InQ@public.gmane.org \
    --cc=pavel-+ZI9xUNit7I@public.gmane.org \
    --cc=sre-DgEjT+Ai2ygdnm+yROfE0A@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).