From: Matthias Brugger <matthias.bgg@gmail.com>
To: Stephen Boyd <sboyd@kernel.org>,
Michael Turquette <mturquette@baylibre.com>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org,
Ryder Lee <ryder.lee@mediatek.com>,
Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>
Subject: Re: [PATCH 1/4] of/device: Add a way to probe drivers by match data
Date: Thu, 8 Nov 2018 09:29:46 +0100 [thread overview]
Message-ID: <efa13e0b-0daf-3bf3-27ba-ed90f15c7dfe@gmail.com> (raw)
In-Reply-To: <20181106183609.207702-2-sboyd@kernel.org>
On 06/11/2018 19:36, Stephen Boyd wrote:
> We have a handful of clk drivers that have a collection of slightly
> variant device support keyed off of the compatible string. In each of
> these drivers, we demux the variant and then call the "real" probe
> function based on whatever is stored in the match data for that
> compatible string. Let's generalize this function so that it can be
> re-used as the platform_driver probe function directly.
>
> Cc: Ryder Lee <ryder.lee@mediatek.com>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
> ---
> drivers/of/device.c | 31 +++++++++++++++++++++++++++++++
> include/linux/of_device.h | 1 +
> 2 files changed, 32 insertions(+)
>
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index 0f27fad9fe94..8381f33ed2d8 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -195,6 +195,37 @@ const void *of_device_get_match_data(const struct device *dev)
> }
> EXPORT_SYMBOL(of_device_get_match_data);
>
> +/**
> + * platform_driver_probe_by_of_match_data - Probe a platform device using match data
> + * @pdev: platform device to probe
> + *
> + * For use by device drivers that multiplex their probe function through DT
> + * match data. Drivers can use this function to call their platform
> + * device probe directly without having to implement a wrapper function.
> + *
> + * static const struct of_device_id probe_funcs[] = {
> + * { .compatible = "compat,foo", .data = foo_probe },
> + * {}
> + * };
> + *
> + * struct platform_driver foo_driver = {
> + * .probe = platform_driver_probe_by_of_match_data,
> + * .driver = {
> + * of_match_table = probe_funcs,
> + * },
> + * };
> + *
> + */
> +int platform_driver_probe_by_of_match_data(struct platform_device *pdev)
> +{
> + int (*probe_func)(struct platform_device *pdev);
> +
> + probe_func = of_device_get_match_data(&pdev->dev);
Shouldn't we check if probe_func is not NULL?
> +
> + return probe_func(pdev);
> +}
> +EXPORT_SYMBOL_GPL(platform_driver_probe_by_of_match_data);
> +
> static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
> {
> const char *compat;
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index 8d31e39dd564..4de84691d1c6 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -33,6 +33,7 @@ extern int of_device_add(struct platform_device *pdev);
> extern int of_device_register(struct platform_device *ofdev);
> extern void of_device_unregister(struct platform_device *ofdev);
>
> +extern int platform_driver_probe_by_of_match_data(struct platform_device *pdev);
> extern const void *of_device_get_match_data(const struct device *dev);
>
> extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);
>
next prev parent reply other threads:[~2018-11-08 8:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-06 18:36 [PATCH 0/4] Simplify mediatek clk driver probes Stephen Boyd
2018-11-06 18:36 ` [PATCH 1/4] of/device: Add a way to probe drivers by match data Stephen Boyd
2018-11-06 20:44 ` Rob Herring
2018-11-07 18:37 ` Stephen Boyd
2018-11-09 9:56 ` Geert Uytterhoeven
2018-11-09 16:59 ` Stephen Boyd
2018-11-09 19:18 ` Geert Uytterhoeven
2018-11-30 0:28 ` Stephen Boyd
2018-11-30 1:01 ` Rob Herring
2018-11-30 7:03 ` Stephen Boyd
2018-11-08 8:29 ` Matthias Brugger [this message]
2018-11-08 17:58 ` Stephen Boyd
2018-11-09 10:29 ` Matthias Brugger
2018-11-09 10:36 ` Geert Uytterhoeven
2018-11-09 16:30 ` Rob Herring
2018-11-09 16:56 ` Frank Rowand
2018-11-06 18:36 ` [PATCH 2/4] clk: mediatek: Convert to platform_driver_probe_by_match_data() Stephen Boyd
2018-11-06 18:36 ` [PATCH 3/4] clk: mediatek: Drop THIS_MODULE from platform_driver Stephen Boyd
2018-11-06 18:36 ` [PATCH 4/4] clk: mediatek: Simplify single driver probes Stephen Boyd
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=efa13e0b-0daf-3bf3-27ba-ed90f15c7dfe@gmail.com \
--to=matthias.bgg@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=mturquette@baylibre.com \
--cc=robh+dt@kernel.org \
--cc=ryder.lee@mediatek.com \
--cc=sboyd@kernel.org \
/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).