All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	linux-mediatek@lists.infradead.org,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	linux-serial@vger.kernel.org, Alan Cox <alan@linux.intel.com>
Subject: Re: [PATCH 3/4] tty: serial: 8250_mtk: use pm_runtime callbacks for enabling
Date: Mon, 4 May 2015 14:06:51 +0200	[thread overview]
Message-ID: <20150504120651.GR6325@pengutronix.de> (raw)
In-Reply-To: <CABuKBeJwduxLuyXcy7Ho+k+_Ye3+nHiGvdr8vTFsJzdHDBQPSA@mail.gmail.com>

On Mon, May 04, 2015 at 01:05:27PM +0200, Matthias Brugger wrote:
> 2015-04-27 8:49 GMT+02:00 Sascha Hauer <s.hauer@pengutronix.de>:
> > The pm_runtime callbacks already enable and disable the device.
> > Use them in probe() and remove() instead of duplicating the
> > code. This allows us to concentrate more code for enabling/disabling
> > the UART in a single place.
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  drivers/tty/serial/8250/8250_mtk.c | 69 ++++++++++++++++++++------------------
> >  1 file changed, 36 insertions(+), 33 deletions(-)
> >
> > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> > index bcfaa8dc..2f28bd0 100644
> > --- a/drivers/tty/serial/8250/8250_mtk.c
> > +++ b/drivers/tty/serial/8250/8250_mtk.c
> > @@ -115,6 +115,29 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
> >                 tty_termios_encode_baud_rate(termios, baud, baud);
> >  }
> >
> > +static int mtk8250_runtime_suspend(struct device *dev)
> > +{
> > +       struct mtk8250_data *data = dev_get_drvdata(dev);
> > +
> > +       clk_disable_unprepare(data->uart_clk);
> > +
> > +       return 0;
> > +}
> > +
> > +static int mtk8250_runtime_resume(struct device *dev)
> > +{
> > +       struct mtk8250_data *data = dev_get_drvdata(dev);
> > +       int err;
> > +
> > +       err = clk_prepare_enable(data->uart_clk);
> > +       if (err) {
> > +               dev_warn(dev, "Can't enable clock\n");
> > +               return err;
> > +       }
> > +
> > +       return 0;
> > +}
> > +
> >  static void
> >  mtk8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)
> >  {
> > @@ -130,19 +153,12 @@ mtk8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)
> >  static int mtk8250_probe_of(struct platform_device *pdev, struct uart_port *p,
> >                            struct mtk8250_data *data)
> >  {
> > -       int err;
> > -
> >         data->uart_clk = devm_clk_get(&pdev->dev, NULL);
> >         if (IS_ERR(data->uart_clk)) {
> >                 dev_warn(&pdev->dev, "Can't get uart clock\n");
> >                 return PTR_ERR(data->uart_clk);
> >         }
> >
> > -       err = clk_prepare_enable(data->uart_clk);
> > -       if (err) {
> > -               dev_warn(&pdev->dev, "Can't prepare clock\n");
> > -               return err;
> > -       }
> >         p->uartclk = clk_get_rate(data->uart_clk);
> >
> >         return 0;
> > @@ -193,14 +209,18 @@ static int mtk8250_probe(struct platform_device *pdev)
> >         writel(0x0, uart.port.membase +
> >                         (MTK_UART_RATE_FIX << uart.port.regshift));
> >
> > -       data->line = serial8250_register_8250_port(&uart);
> > -       if (data->line < 0)
> > -               return data->line;
> > -
> >         platform_set_drvdata(pdev, data);
> >
> > -       pm_runtime_set_active(&pdev->dev);
> >         pm_runtime_enable(&pdev->dev);
> > +       if (!pm_runtime_enabled(&pdev->dev)) {
> > +               err = mtk8250_runtime_resume(&pdev->dev);
> > +               if (err)
> > +                       return err;
> > +       }
> > +
> > +       data->line = serial8250_register_8250_port(&uart);
> > +       if (data->line < 0)
> > +               return data->line;
> 
> Why do you delete pm_runtime_set_active here?

pm_runtime_set_active() communicates the initial state of the device to
the pm core. Previously the driver activated the device manually by
directly calling clk_prepare_enable(). Since this manual enabling of
the clock is removed in this patch, the device is no longer active,
hence pm_runtime_set_active() has to be removed.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

WARNING: multiple messages have this Message-ID (diff)
From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Matthias Brugger <matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Greg KH
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	Alan Cox <alan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: Re: [PATCH 3/4] tty: serial: 8250_mtk: use pm_runtime callbacks for enabling
Date: Mon, 4 May 2015 14:06:51 +0200	[thread overview]
Message-ID: <20150504120651.GR6325@pengutronix.de> (raw)
In-Reply-To: <CABuKBeJwduxLuyXcy7Ho+k+_Ye3+nHiGvdr8vTFsJzdHDBQPSA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Mon, May 04, 2015 at 01:05:27PM +0200, Matthias Brugger wrote:
> 2015-04-27 8:49 GMT+02:00 Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>:
> > The pm_runtime callbacks already enable and disable the device.
> > Use them in probe() and remove() instead of duplicating the
> > code. This allows us to concentrate more code for enabling/disabling
> > the UART in a single place.
> >
> > Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > ---
> >  drivers/tty/serial/8250/8250_mtk.c | 69 ++++++++++++++++++++------------------
> >  1 file changed, 36 insertions(+), 33 deletions(-)
> >
> > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> > index bcfaa8dc..2f28bd0 100644
> > --- a/drivers/tty/serial/8250/8250_mtk.c
> > +++ b/drivers/tty/serial/8250/8250_mtk.c
> > @@ -115,6 +115,29 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
> >                 tty_termios_encode_baud_rate(termios, baud, baud);
> >  }
> >
> > +static int mtk8250_runtime_suspend(struct device *dev)
> > +{
> > +       struct mtk8250_data *data = dev_get_drvdata(dev);
> > +
> > +       clk_disable_unprepare(data->uart_clk);
> > +
> > +       return 0;
> > +}
> > +
> > +static int mtk8250_runtime_resume(struct device *dev)
> > +{
> > +       struct mtk8250_data *data = dev_get_drvdata(dev);
> > +       int err;
> > +
> > +       err = clk_prepare_enable(data->uart_clk);
> > +       if (err) {
> > +               dev_warn(dev, "Can't enable clock\n");
> > +               return err;
> > +       }
> > +
> > +       return 0;
> > +}
> > +
> >  static void
> >  mtk8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)
> >  {
> > @@ -130,19 +153,12 @@ mtk8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)
> >  static int mtk8250_probe_of(struct platform_device *pdev, struct uart_port *p,
> >                            struct mtk8250_data *data)
> >  {
> > -       int err;
> > -
> >         data->uart_clk = devm_clk_get(&pdev->dev, NULL);
> >         if (IS_ERR(data->uart_clk)) {
> >                 dev_warn(&pdev->dev, "Can't get uart clock\n");
> >                 return PTR_ERR(data->uart_clk);
> >         }
> >
> > -       err = clk_prepare_enable(data->uart_clk);
> > -       if (err) {
> > -               dev_warn(&pdev->dev, "Can't prepare clock\n");
> > -               return err;
> > -       }
> >         p->uartclk = clk_get_rate(data->uart_clk);
> >
> >         return 0;
> > @@ -193,14 +209,18 @@ static int mtk8250_probe(struct platform_device *pdev)
> >         writel(0x0, uart.port.membase +
> >                         (MTK_UART_RATE_FIX << uart.port.regshift));
> >
> > -       data->line = serial8250_register_8250_port(&uart);
> > -       if (data->line < 0)
> > -               return data->line;
> > -
> >         platform_set_drvdata(pdev, data);
> >
> > -       pm_runtime_set_active(&pdev->dev);
> >         pm_runtime_enable(&pdev->dev);
> > +       if (!pm_runtime_enabled(&pdev->dev)) {
> > +               err = mtk8250_runtime_resume(&pdev->dev);
> > +               if (err)
> > +                       return err;
> > +       }
> > +
> > +       data->line = serial8250_register_8250_port(&uart);
> > +       if (data->line < 0)
> > +               return data->line;
> 
> Why do you delete pm_runtime_set_active here?

pm_runtime_set_active() communicates the initial state of the device to
the pm core. Previously the driver activated the device manually by
directly calling clk_prepare_enable(). Since this manual enabling of
the clock is removed in this patch, the device is no longer active,
hence pm_runtime_set_active() has to be removed.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

WARNING: multiple messages have this Message-ID (diff)
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] tty: serial: 8250_mtk: use pm_runtime callbacks for enabling
Date: Mon, 4 May 2015 14:06:51 +0200	[thread overview]
Message-ID: <20150504120651.GR6325@pengutronix.de> (raw)
In-Reply-To: <CABuKBeJwduxLuyXcy7Ho+k+_Ye3+nHiGvdr8vTFsJzdHDBQPSA@mail.gmail.com>

On Mon, May 04, 2015 at 01:05:27PM +0200, Matthias Brugger wrote:
> 2015-04-27 8:49 GMT+02:00 Sascha Hauer <s.hauer@pengutronix.de>:
> > The pm_runtime callbacks already enable and disable the device.
> > Use them in probe() and remove() instead of duplicating the
> > code. This allows us to concentrate more code for enabling/disabling
> > the UART in a single place.
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  drivers/tty/serial/8250/8250_mtk.c | 69 ++++++++++++++++++++------------------
> >  1 file changed, 36 insertions(+), 33 deletions(-)
> >
> > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> > index bcfaa8dc..2f28bd0 100644
> > --- a/drivers/tty/serial/8250/8250_mtk.c
> > +++ b/drivers/tty/serial/8250/8250_mtk.c
> > @@ -115,6 +115,29 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
> >                 tty_termios_encode_baud_rate(termios, baud, baud);
> >  }
> >
> > +static int mtk8250_runtime_suspend(struct device *dev)
> > +{
> > +       struct mtk8250_data *data = dev_get_drvdata(dev);
> > +
> > +       clk_disable_unprepare(data->uart_clk);
> > +
> > +       return 0;
> > +}
> > +
> > +static int mtk8250_runtime_resume(struct device *dev)
> > +{
> > +       struct mtk8250_data *data = dev_get_drvdata(dev);
> > +       int err;
> > +
> > +       err = clk_prepare_enable(data->uart_clk);
> > +       if (err) {
> > +               dev_warn(dev, "Can't enable clock\n");
> > +               return err;
> > +       }
> > +
> > +       return 0;
> > +}
> > +
> >  static void
> >  mtk8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)
> >  {
> > @@ -130,19 +153,12 @@ mtk8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)
> >  static int mtk8250_probe_of(struct platform_device *pdev, struct uart_port *p,
> >                            struct mtk8250_data *data)
> >  {
> > -       int err;
> > -
> >         data->uart_clk = devm_clk_get(&pdev->dev, NULL);
> >         if (IS_ERR(data->uart_clk)) {
> >                 dev_warn(&pdev->dev, "Can't get uart clock\n");
> >                 return PTR_ERR(data->uart_clk);
> >         }
> >
> > -       err = clk_prepare_enable(data->uart_clk);
> > -       if (err) {
> > -               dev_warn(&pdev->dev, "Can't prepare clock\n");
> > -               return err;
> > -       }
> >         p->uartclk = clk_get_rate(data->uart_clk);
> >
> >         return 0;
> > @@ -193,14 +209,18 @@ static int mtk8250_probe(struct platform_device *pdev)
> >         writel(0x0, uart.port.membase +
> >                         (MTK_UART_RATE_FIX << uart.port.regshift));
> >
> > -       data->line = serial8250_register_8250_port(&uart);
> > -       if (data->line < 0)
> > -               return data->line;
> > -
> >         platform_set_drvdata(pdev, data);
> >
> > -       pm_runtime_set_active(&pdev->dev);
> >         pm_runtime_enable(&pdev->dev);
> > +       if (!pm_runtime_enabled(&pdev->dev)) {
> > +               err = mtk8250_runtime_resume(&pdev->dev);
> > +               if (err)
> > +                       return err;
> > +       }
> > +
> > +       data->line = serial8250_register_8250_port(&uart);
> > +       if (data->line < 0)
> > +               return data->line;
> 
> Why do you delete pm_runtime_set_active here?

pm_runtime_set_active() communicates the initial state of the device to
the pm core. Previously the driver activated the device manually by
directly calling clk_prepare_enable(). Since this manual enabling of
the clock is removed in this patch, the device is no longer active,
hence pm_runtime_set_active() has to be removed.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2015-05-04 12:07 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27  6:49 [PATCH v2] tty: serial: 8250_mtk: Add support for second clock Sascha Hauer
2015-04-27  6:49 ` Sascha Hauer
2015-04-27  6:49 ` [PATCH 1/4] tty: serial: 8250_mtk: remove unnecessary test Sascha Hauer
2015-04-27  6:49   ` Sascha Hauer
2015-05-04  9:32   ` Matthias Brugger
2015-05-04  9:32     ` Matthias Brugger
2015-05-04  9:32     ` Matthias Brugger
2015-04-27  6:49 ` [PATCH 2/4] tty: serial: 8250_mtk: Use devm_clk_get Sascha Hauer
2015-04-27  6:49   ` Sascha Hauer
2015-05-04  9:36   ` Matthias Brugger
2015-05-04  9:36     ` Matthias Brugger
2015-05-04  9:36     ` Matthias Brugger
2015-04-27  6:49 ` [PATCH 3/4] tty: serial: 8250_mtk: use pm_runtime callbacks for enabling Sascha Hauer
2015-04-27  6:49   ` Sascha Hauer
2015-04-27  6:49   ` Sascha Hauer
2015-05-04 11:05   ` Matthias Brugger
2015-05-04 11:05     ` Matthias Brugger
2015-05-04 11:05     ` Matthias Brugger
2015-05-04 12:06     ` Sascha Hauer [this message]
2015-05-04 12:06       ` Sascha Hauer
2015-05-04 12:06       ` Sascha Hauer
2015-05-05 15:29       ` Matthias Brugger
2015-05-05 15:29         ` Matthias Brugger
2015-05-05 15:29         ` Matthias Brugger
2015-04-27  6:49 ` [PATCH 4/4] tty: serial: 8250_mtk: Add support for bus clock Sascha Hauer
2015-04-27  6:49   ` Sascha Hauer
2015-05-05 15:41   ` Matthias Brugger
2015-05-05 15:41     ` Matthias Brugger
2015-05-05 15:41     ` Matthias Brugger
2015-05-05 15:50     ` Sascha Hauer
2015-05-05 15:50       ` Sascha Hauer
2015-05-05 15:50       ` Sascha Hauer
2015-05-08  8:59       ` Matthias Brugger
2015-05-08  8:59         ` Matthias Brugger
2015-05-08  8:59         ` Matthias Brugger
  -- strict thread matches above, loose matches on Subject: below --
2015-04-23  8:51 tty: serial: 8250_mtk: Add support for second clock Sascha Hauer
2015-04-23  8:51 ` [PATCH 3/4] tty: serial: 8250_mtk: use pm_runtime callbacks for enabling Sascha Hauer
2015-04-23  8:51   ` Sascha Hauer

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=20150504120651.GR6325@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=alan@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=matthias.bgg@gmail.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 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.