linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Tony Lindgren <tony@atomide.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Johan Hovold" <johan@kernel.org>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	linux-serial@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] serial: core: Add port port device to flush TX on runtime resume
Date: Wed, 23 Nov 2022 20:37:03 +0200	[thread overview]
Message-ID: <Y35oT9/3OKRciWCP@smile.fi.intel.com> (raw)
In-Reply-To: <20221123082825.32820-2-tony@atomide.com>

On Wed, Nov 23, 2022 at 10:28:25AM +0200, Tony Lindgren wrote:
> With PM runtime enabled for the serial port controllers, we can now flush
> pending TX for the port on runtime PM resume as suggested by
> Johan Hovold <johan@kernel.org>.

I believe it's quite a duplication of email addresses (they are in Cc and will
be on lore.kernel.org) and also below.

> To flush the pending TX, let's set up each port as a proper device as
> suggested by Greg Kroah-Hartman <gregkh@linuxfoundation.org>.
> 
> We set up each port as a child device for the serial port controller
> device. We use platform device for this and pass the port information
> in platform_data.
> 
> Let's just do mimimal changes needed for now, more port specific code
> can be then moved from serial_core.c to serial_port.c as needed.

...

> +static int serial_core_add_port_device(struct uart_port *port)
> +{
> +	struct serial_port_platdata pd;
> +	struct platform_device *pdev;
> +	int ret;
> +
> +	pdev = platform_device_alloc("serial-port", PLATFORM_DEVID_AUTO);
> +	if (!pdev)
> +		return -ENOMEM;
> +
> +	pdev->dev.parent = port->dev;
> +	pd.state = port->state;
> +
> +	ret = platform_device_add_data(pdev, &pd, sizeof(pd));
> +	if (ret)
> +		goto err_put;
> +
> +	ret = platform_device_add(pdev);
> +	if (ret)
> +		goto err_put;
> +
> +	port->state->port_dev = &pdev->dev;
> +
> +	return 0;
> +
> +err_put:
> +	platform_device_put(pdev);
> +
> +	return ret;

Can we simply utilize platform_device_register_full()?

> +}

...

> +EXPORT_SYMBOL(serial_port_get);

Can we move these to namespace from day 1?

...

> +	return (!uart_tx_stopped(port) &&
> +		uart_circ_chars_pending(&port->state->xmit));

Outer parentheses are redundant.

...

> +static const struct dev_pm_ops serial_port_pm = {
> +	SET_RUNTIME_PM_OPS(NULL, serial_port_runtime_resume, NULL)
> +};

Can't we use new macros / helpers which starts from DEFINE_...

...

> +	pm_runtime_set_autosuspend_delay(&pdev->dev,
> +					 SERIAL_PORT_AUTOSUSPEND_DELAY_MS);

With temporary

	struct device *dev = &pdev->dev;

this in particular become one line.

...

> +		.pm = &serial_port_pm,

As per above, use pm_ptr() ?

...

> +

Unneeded blank line.

> +module_platform_driver(serial_port_driver);

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2022-11-23 18:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  8:28 [PATCH v3 1/2] serial: core: Start managing serial controllers to enable runtime PM Tony Lindgren
2022-11-23  8:28 ` [PATCH v3 2/2] serial: core: Add port port device to flush TX on runtime resume Tony Lindgren
2022-11-23 18:37   ` Andy Shevchenko [this message]
2022-11-24  6:50     ` Tony Lindgren
2022-11-24  8:41       ` Andy Shevchenko
2022-11-23 18:41 ` [PATCH v3 1/2] serial: core: Start managing serial controllers to enable runtime PM Andy Shevchenko
2022-11-25 14:02 ` Ilpo Järvinen
2022-11-28  6:45   ` Tony Lindgren

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=Y35oT9/3OKRciWCP@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=bigeasy@linutronix.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=tony@atomide.com \
    --cc=vigneshr@ti.com \
    /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).