All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Russell King <linux@armlinux.org.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	Rob Herring <robh@kernel.org>,
	Sascha Hauer <kernel@pengutronix.de>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/4] amba: Make use of bus_type functions
Date: Tue, 24 Nov 2020 11:56:57 +0100	[thread overview]
Message-ID: <CAPDyKFrBR3M2rsOzs9s7oTJ8UYY-XZ9CbMJR+sHJwFL2FvBReg@mail.gmail.com> (raw)
In-Reply-To: <20201124103242.2971199-4-u.kleine-koenig@pengutronix.de>

On Tue, 24 Nov 2020 at 11:33, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> Instead of assigning the needed functions for each driver separately do it
> only once in amba_bustype. Move the definition of the functions to their
> proper place among the other callbacks used there.
>
> This prepares getting rid of these callbacks in struct device_driver.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

> ---
>  drivers/amba/bus.c | 154 ++++++++++++++++++++++-----------------------
>  1 file changed, 77 insertions(+), 77 deletions(-)
>
> diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
> index 48b5d4b4e889..2f3799ac3edb 100644
> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -174,6 +174,80 @@ static int amba_uevent(struct device *dev, struct kobj_uevent_env *env)
>         return retval;
>  }
>
> +/*
> + * These are the device model conversion veneers; they convert the
> + * device model structures to our more specific structures.
> + */
> +static int amba_probe(struct device *dev)
> +{
> +       struct amba_device *pcdev = to_amba_device(dev);
> +       struct amba_driver *pcdrv = to_amba_driver(dev->driver);
> +       const struct amba_id *id = amba_lookup(pcdrv->id_table, pcdev);
> +       int ret;
> +
> +       do {
> +               ret = of_clk_set_defaults(dev->of_node, false);
> +               if (ret < 0)
> +                       break;
> +
> +               ret = dev_pm_domain_attach(dev, true);
> +               if (ret)
> +                       break;
> +
> +               ret = amba_get_enable_pclk(pcdev);
> +               if (ret) {
> +                       dev_pm_domain_detach(dev, true);
> +                       break;
> +               }
> +
> +               pm_runtime_get_noresume(dev);
> +               pm_runtime_set_active(dev);
> +               pm_runtime_enable(dev);
> +
> +               ret = pcdrv->probe(pcdev, id);
> +               if (ret == 0)
> +                       break;
> +
> +               pm_runtime_disable(dev);
> +               pm_runtime_set_suspended(dev);
> +               pm_runtime_put_noidle(dev);
> +
> +               amba_put_disable_pclk(pcdev);
> +               dev_pm_domain_detach(dev, true);
> +       } while (0);
> +
> +       return ret;
> +}
> +
> +static int amba_remove(struct device *dev)
> +{
> +       struct amba_device *pcdev = to_amba_device(dev);
> +       struct amba_driver *drv = to_amba_driver(dev->driver);
> +
> +       pm_runtime_get_sync(dev);
> +       if (drv->remove)
> +               drv->remove(pcdev);
> +       pm_runtime_put_noidle(dev);
> +
> +       /* Undo the runtime PM settings in amba_probe() */
> +       pm_runtime_disable(dev);
> +       pm_runtime_set_suspended(dev);
> +       pm_runtime_put_noidle(dev);
> +
> +       amba_put_disable_pclk(pcdev);
> +       dev_pm_domain_detach(dev, true);
> +
> +       return 0;
> +}
> +
> +static void amba_shutdown(struct device *dev)
> +{
> +       struct amba_driver *drv = to_amba_driver(dev->driver);
> +
> +       if (drv->shutdown)
> +               drv->shutdown(to_amba_device(dev));
> +}
> +
>  #ifdef CONFIG_PM
>  /*
>   * Hooks to provide runtime PM of the pclk (bus clock).  It is safe to
> @@ -239,6 +313,9 @@ struct bus_type amba_bustype = {
>         .dev_groups     = amba_dev_groups,
>         .match          = amba_match,
>         .uevent         = amba_uevent,
> +       .probe          = amba_probe,
> +       .remove         = amba_remove,
> +       .shutdown       = amba_shutdown,
>         .dma_configure  = platform_dma_configure,
>         .pm             = &amba_pm,
>  };
> @@ -251,80 +328,6 @@ static int __init amba_init(void)
>
>  postcore_initcall(amba_init);
>
> -/*
> - * These are the device model conversion veneers; they convert the
> - * device model structures to our more specific structures.
> - */
> -static int amba_probe(struct device *dev)
> -{
> -       struct amba_device *pcdev = to_amba_device(dev);
> -       struct amba_driver *pcdrv = to_amba_driver(dev->driver);
> -       const struct amba_id *id = amba_lookup(pcdrv->id_table, pcdev);
> -       int ret;
> -
> -       do {
> -               ret = of_clk_set_defaults(dev->of_node, false);
> -               if (ret < 0)
> -                       break;
> -
> -               ret = dev_pm_domain_attach(dev, true);
> -               if (ret)
> -                       break;
> -
> -               ret = amba_get_enable_pclk(pcdev);
> -               if (ret) {
> -                       dev_pm_domain_detach(dev, true);
> -                       break;
> -               }
> -
> -               pm_runtime_get_noresume(dev);
> -               pm_runtime_set_active(dev);
> -               pm_runtime_enable(dev);
> -
> -               ret = pcdrv->probe(pcdev, id);
> -               if (ret == 0)
> -                       break;
> -
> -               pm_runtime_disable(dev);
> -               pm_runtime_set_suspended(dev);
> -               pm_runtime_put_noidle(dev);
> -
> -               amba_put_disable_pclk(pcdev);
> -               dev_pm_domain_detach(dev, true);
> -       } while (0);
> -
> -       return ret;
> -}
> -
> -static int amba_remove(struct device *dev)
> -{
> -       struct amba_device *pcdev = to_amba_device(dev);
> -       struct amba_driver *drv = to_amba_driver(dev->driver);
> -
> -       pm_runtime_get_sync(dev);
> -       if (drv->remove)
> -               drv->remove(pcdev);
> -       pm_runtime_put_noidle(dev);
> -
> -       /* Undo the runtime PM settings in amba_probe() */
> -       pm_runtime_disable(dev);
> -       pm_runtime_set_suspended(dev);
> -       pm_runtime_put_noidle(dev);
> -
> -       amba_put_disable_pclk(pcdev);
> -       dev_pm_domain_detach(dev, true);
> -
> -       return 0;
> -}
> -
> -static void amba_shutdown(struct device *dev)
> -{
> -       struct amba_driver *drv = to_amba_driver(dev->driver);
> -
> -       if (drv->shutdown)
> -               drv->shutdown(to_amba_device(dev));
> -}
> -
>  /**
>   *     amba_driver_register - register an AMBA device driver
>   *     @drv: amba device driver structure
> @@ -339,9 +342,6 @@ int amba_driver_register(struct amba_driver *drv)
>                 return -EINVAL;
>
>         drv->drv.bus = &amba_bustype;
> -       drv->drv.probe = amba_probe;
> -       drv->drv.remove = amba_remove;
> -       drv->drv.shutdown = amba_shutdown;
>
>         return driver_register(&drv->drv);
>  }
> --
> 2.29.2
>

WARNING: multiple messages have this Message-ID (diff)
From: Ulf Hansson <ulf.hansson@linaro.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Rob Herring <robh@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Russell King <linux@armlinux.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Sascha Hauer <kernel@pengutronix.de>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 4/4] amba: Make use of bus_type functions
Date: Tue, 24 Nov 2020 11:56:57 +0100	[thread overview]
Message-ID: <CAPDyKFrBR3M2rsOzs9s7oTJ8UYY-XZ9CbMJR+sHJwFL2FvBReg@mail.gmail.com> (raw)
In-Reply-To: <20201124103242.2971199-4-u.kleine-koenig@pengutronix.de>

On Tue, 24 Nov 2020 at 11:33, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> Instead of assigning the needed functions for each driver separately do it
> only once in amba_bustype. Move the definition of the functions to their
> proper place among the other callbacks used there.
>
> This prepares getting rid of these callbacks in struct device_driver.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

> ---
>  drivers/amba/bus.c | 154 ++++++++++++++++++++++-----------------------
>  1 file changed, 77 insertions(+), 77 deletions(-)
>
> diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
> index 48b5d4b4e889..2f3799ac3edb 100644
> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -174,6 +174,80 @@ static int amba_uevent(struct device *dev, struct kobj_uevent_env *env)
>         return retval;
>  }
>
> +/*
> + * These are the device model conversion veneers; they convert the
> + * device model structures to our more specific structures.
> + */
> +static int amba_probe(struct device *dev)
> +{
> +       struct amba_device *pcdev = to_amba_device(dev);
> +       struct amba_driver *pcdrv = to_amba_driver(dev->driver);
> +       const struct amba_id *id = amba_lookup(pcdrv->id_table, pcdev);
> +       int ret;
> +
> +       do {
> +               ret = of_clk_set_defaults(dev->of_node, false);
> +               if (ret < 0)
> +                       break;
> +
> +               ret = dev_pm_domain_attach(dev, true);
> +               if (ret)
> +                       break;
> +
> +               ret = amba_get_enable_pclk(pcdev);
> +               if (ret) {
> +                       dev_pm_domain_detach(dev, true);
> +                       break;
> +               }
> +
> +               pm_runtime_get_noresume(dev);
> +               pm_runtime_set_active(dev);
> +               pm_runtime_enable(dev);
> +
> +               ret = pcdrv->probe(pcdev, id);
> +               if (ret == 0)
> +                       break;
> +
> +               pm_runtime_disable(dev);
> +               pm_runtime_set_suspended(dev);
> +               pm_runtime_put_noidle(dev);
> +
> +               amba_put_disable_pclk(pcdev);
> +               dev_pm_domain_detach(dev, true);
> +       } while (0);
> +
> +       return ret;
> +}
> +
> +static int amba_remove(struct device *dev)
> +{
> +       struct amba_device *pcdev = to_amba_device(dev);
> +       struct amba_driver *drv = to_amba_driver(dev->driver);
> +
> +       pm_runtime_get_sync(dev);
> +       if (drv->remove)
> +               drv->remove(pcdev);
> +       pm_runtime_put_noidle(dev);
> +
> +       /* Undo the runtime PM settings in amba_probe() */
> +       pm_runtime_disable(dev);
> +       pm_runtime_set_suspended(dev);
> +       pm_runtime_put_noidle(dev);
> +
> +       amba_put_disable_pclk(pcdev);
> +       dev_pm_domain_detach(dev, true);
> +
> +       return 0;
> +}
> +
> +static void amba_shutdown(struct device *dev)
> +{
> +       struct amba_driver *drv = to_amba_driver(dev->driver);
> +
> +       if (drv->shutdown)
> +               drv->shutdown(to_amba_device(dev));
> +}
> +
>  #ifdef CONFIG_PM
>  /*
>   * Hooks to provide runtime PM of the pclk (bus clock).  It is safe to
> @@ -239,6 +313,9 @@ struct bus_type amba_bustype = {
>         .dev_groups     = amba_dev_groups,
>         .match          = amba_match,
>         .uevent         = amba_uevent,
> +       .probe          = amba_probe,
> +       .remove         = amba_remove,
> +       .shutdown       = amba_shutdown,
>         .dma_configure  = platform_dma_configure,
>         .pm             = &amba_pm,
>  };
> @@ -251,80 +328,6 @@ static int __init amba_init(void)
>
>  postcore_initcall(amba_init);
>
> -/*
> - * These are the device model conversion veneers; they convert the
> - * device model structures to our more specific structures.
> - */
> -static int amba_probe(struct device *dev)
> -{
> -       struct amba_device *pcdev = to_amba_device(dev);
> -       struct amba_driver *pcdrv = to_amba_driver(dev->driver);
> -       const struct amba_id *id = amba_lookup(pcdrv->id_table, pcdev);
> -       int ret;
> -
> -       do {
> -               ret = of_clk_set_defaults(dev->of_node, false);
> -               if (ret < 0)
> -                       break;
> -
> -               ret = dev_pm_domain_attach(dev, true);
> -               if (ret)
> -                       break;
> -
> -               ret = amba_get_enable_pclk(pcdev);
> -               if (ret) {
> -                       dev_pm_domain_detach(dev, true);
> -                       break;
> -               }
> -
> -               pm_runtime_get_noresume(dev);
> -               pm_runtime_set_active(dev);
> -               pm_runtime_enable(dev);
> -
> -               ret = pcdrv->probe(pcdev, id);
> -               if (ret == 0)
> -                       break;
> -
> -               pm_runtime_disable(dev);
> -               pm_runtime_set_suspended(dev);
> -               pm_runtime_put_noidle(dev);
> -
> -               amba_put_disable_pclk(pcdev);
> -               dev_pm_domain_detach(dev, true);
> -       } while (0);
> -
> -       return ret;
> -}
> -
> -static int amba_remove(struct device *dev)
> -{
> -       struct amba_device *pcdev = to_amba_device(dev);
> -       struct amba_driver *drv = to_amba_driver(dev->driver);
> -
> -       pm_runtime_get_sync(dev);
> -       if (drv->remove)
> -               drv->remove(pcdev);
> -       pm_runtime_put_noidle(dev);
> -
> -       /* Undo the runtime PM settings in amba_probe() */
> -       pm_runtime_disable(dev);
> -       pm_runtime_set_suspended(dev);
> -       pm_runtime_put_noidle(dev);
> -
> -       amba_put_disable_pclk(pcdev);
> -       dev_pm_domain_detach(dev, true);
> -
> -       return 0;
> -}
> -
> -static void amba_shutdown(struct device *dev)
> -{
> -       struct amba_driver *drv = to_amba_driver(dev->driver);
> -
> -       if (drv->shutdown)
> -               drv->shutdown(to_amba_device(dev));
> -}
> -
>  /**
>   *     amba_driver_register - register an AMBA device driver
>   *     @drv: amba device driver structure
> @@ -339,9 +342,6 @@ int amba_driver_register(struct amba_driver *drv)
>                 return -EINVAL;
>
>         drv->drv.bus = &amba_bustype;
> -       drv->drv.probe = amba_probe;
> -       drv->drv.remove = amba_remove;
> -       drv->drv.shutdown = amba_shutdown;
>
>         return driver_register(&drv->drv);
>  }
> --
> 2.29.2
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-11-24 10:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24 10:32 [PATCH 1/4] amba: reorder functions Uwe Kleine-König
2020-11-24 10:32 ` Uwe Kleine-König
2020-11-24 10:32 ` [PATCH 2/4] amba: Fix resource leak for drivers without .remove Uwe Kleine-König
2020-11-24 10:32   ` Uwe Kleine-König
2020-11-24 10:56   ` Ulf Hansson
2020-11-24 10:56     ` Ulf Hansson
2020-11-24 10:32 ` [PATCH 3/4] amba: Make the remove callback return void Uwe Kleine-König
2020-11-24 10:32   ` Uwe Kleine-König
2020-11-24 10:56   ` Ulf Hansson
2020-11-24 10:56     ` Ulf Hansson
2020-11-24 11:48   ` Arnd Bergmann
2020-11-24 11:48     ` Arnd Bergmann
2020-11-24 12:19     ` Uwe Kleine-König
2020-11-24 12:19       ` Uwe Kleine-König
2020-11-24 10:32 ` [PATCH 4/4] amba: Make use of bus_type functions Uwe Kleine-König
2020-11-24 10:32   ` Uwe Kleine-König
2020-11-24 10:56   ` Ulf Hansson [this message]
2020-11-24 10:56     ` Ulf Hansson
2020-11-24 10:56 ` [PATCH 1/4] amba: reorder functions Ulf Hansson
2020-11-24 10:56   ` Ulf Hansson
2020-11-24 11:49 ` Arnd Bergmann
2020-11-24 11:49   ` Arnd Bergmann

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=CAPDyKFrBR3M2rsOzs9s7oTJ8UYY-XZ9CbMJR+sHJwFL2FvBReg@mail.gmail.com \
    --to=ulf.hansson@linaro.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=robh@kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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.