[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMpxmJX5t=LWpLkY=uYNK9r4rmStuSfmGc7=zcnu4_oHkQevWQ@mail.gmail.com>
Date: Wed, 16 Dec 2020 11:35:43 +0100
From: Bartosz Golaszewski <bgolaszewski@...libre.com>
To: Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
Cc: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>,
LKML <linux-kernel@...r.kernel.org>,
Florian Fainelli <f.fainelli@...il.com>,
Ray Jui <rjui@...adcom.com>,
Scott Branden <sbranden@...adcom.com>,
bcm-kernel-feedback-list@...adcom.com, linux-pwm@...r.kernel.org,
arm-soc <linux-arm-kernel@...ts.infradead.org>,
linux-devicetree <devicetree@...r.kernel.org>, wahrenst@....net,
Linux Input <linux-input@...r.kernel.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Greg KH <gregkh@...uxfoundation.org>,
devel@...verdev.osuosl.org, Philipp Zabel <p.zabel@...gutronix.de>,
linux-gpio <linux-gpio@...r.kernel.org>,
Linus Walleij <linus.walleij@...aro.org>,
linux-clk <linux-clk@...r.kernel.org>,
Stephen Boyd <sboyd@...nel.org>,
linux-rpi-kernel@...ts.infradead.org,
Andy Shevchenko <andy.shevchenko@...il.com>
Subject: Re: [PATCH v6 02/11] firmware: raspberrypi: Introduce devm_rpi_firmware_get()
On Fri, Dec 11, 2020 at 5:48 PM Nicolas Saenz Julienne
<nsaenzjulienne@...e.de> wrote:
>
> It'll simplify the firmware handling for most consumers.
>
> Suggested-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
> Reviewed-by: Florian Fainelli <f.fainelli@...il.com>
> ---
>
> Changes since v4:
> - Rearrange function calls for clarity, same functionality
>
> Changes since v2:
> - Create devm_rpi_firmware_get()
>
> drivers/firmware/raspberrypi.c | 29 ++++++++++++++++++++++
> include/soc/bcm2835/raspberrypi-firmware.h | 8 ++++++
> 2 files changed, 37 insertions(+)
>
> diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
> index b65e4c495772..250e01680742 100644
> --- a/drivers/firmware/raspberrypi.c
> +++ b/drivers/firmware/raspberrypi.c
> @@ -243,6 +243,13 @@ void rpi_firmware_put(struct rpi_firmware *fw)
> }
> EXPORT_SYMBOL_GPL(rpi_firmware_put);
>
> +static void devm_rpi_firmware_put(void *data)
> +{
> + struct rpi_firmware *fw = data;
> +
> + rpi_firmware_put(fw);
> +}
> +
> static int rpi_firmware_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -331,6 +338,28 @@ struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node)
> }
> EXPORT_SYMBOL_GPL(rpi_firmware_get);
>
> +/**
> + * devm_rpi_firmware_get - Get pointer to rpi_firmware structure.
> + * @firmware_node: Pointer to the firmware Device Tree node.
> + *
> + * Returns NULL is the firmware device is not ready.
> + */
> +struct rpi_firmware *devm_rpi_firmware_get(struct device *dev,
> + struct device_node *firmware_node)
> +{
> + struct rpi_firmware *fw;
> +
> + fw = rpi_firmware_get(firmware_node);
> + if (!fw)
> + return NULL;
> +
> + if (devm_add_action_or_reset(dev, devm_rpi_firmware_put, fw))
> + return NULL;
> +
> + return fw;
> +}
> +EXPORT_SYMBOL_GPL(devm_rpi_firmware_get);
> +
> static const struct of_device_id rpi_firmware_of_match[] = {
> { .compatible = "raspberrypi,bcm2835-firmware", },
> {},
> diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h
> index fdfef7fe40df..73ad784fca96 100644
> --- a/include/soc/bcm2835/raspberrypi-firmware.h
> +++ b/include/soc/bcm2835/raspberrypi-firmware.h
> @@ -142,6 +142,8 @@ int rpi_firmware_property_list(struct rpi_firmware *fw,
> void *data, size_t tag_size);
> void rpi_firmware_put(struct rpi_firmware *fw);
> struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node);
> +struct rpi_firmware *devm_rpi_firmware_get(struct device *dev,
> + struct device_node *firmware_node);
> #else
> static inline int rpi_firmware_property(struct rpi_firmware *fw, u32 tag,
> void *data, size_t len)
> @@ -160,6 +162,12 @@ static inline struct rpi_firmware *rpi_firmware_get(struct device_node *firmware
> {
> return NULL;
> }
> +
> +static inline struct rpi_firmware *devm_rpi_firmware_get(struct device *dev,
> + struct device_node *firmware_node)
> +{
> + return NULL;
> +}
> #endif
>
> #endif /* __SOC_RASPBERRY_FIRMWARE_H__ */
> --
> 2.29.2
>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
Powered by blists - more mailing lists