lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 30 Mar 2015 08:49:52 +1100
From:	NeilBrown <neilb@...e.de>
To:	Peter Hurley <peter@...leysoftware.com>
Cc:	NeilBrown <neil@...wn.name>, Mark Rutland <mark.rutland@....com>,
	One Thousand Gnomes <gnomes@...rguk.ukuu.org.uk>,
	Arnd Bergmann <arnd@...db.de>, devicetree@...r.kernel.org,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Sebastian Reichel <sre@...nel.org>,
	linux-kernel@...r.kernel.org,
	GTA04 owners <gta04-owner@...delico.com>,
	Pavel Machek <pavel@....cz>,
	Grant Likely <grant.likely@...aro.org>,
	Jiri Slaby <jslaby@...e.cz>
Subject: Re: [Gta04-owner] [PATCH 1/3] TTY: use class_find_device to find
 port in uart_suspend/resume.

On Wed, 25 Mar 2015 12:20:20 -0400 Peter Hurley <peter@...leysoftware.com>
wrote:

> 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@...wn.name>
> > ---
> >  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())?
> 

I was wondering what would be the best thing to do to tty_get_device.
As there is only one caller, replacing at you suggest seems best.
I've done that - thanks.

NeilBrown

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists