From: Antoine Tenart <antoine.tenart@free-electrons.com>
To: Jisheng Zhang <jszhang@marvell.com>
Cc: sebastian.hesselbarth@gmail.com, linus.walleij@linaro.org,
antoine.tenart@free-electrons.com, catalin.marinas@arm.com,
will.deacon@arm.com, mark.rutland@arm.com, robh+dt@kernel.org,
pawel.moll@arm.com, ijc+devicetree@hellion.org.uk,
galak@codeaurora.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/6] pinctrl: berlin: regmap as an extra argument of berlin_pinctrl_probe()
Date: Fri, 2 Oct 2015 15:04:56 +0200 [thread overview]
Message-ID: <20151002130456.GC3162@kwain> (raw)
In-Reply-To: <1442829860-4647-2-git-send-email-jszhang@marvell.com>
Hi Jisheng,
Thanks for providing this!
On Mon, Sep 21, 2015 at 06:04:15PM +0800, Jisheng Zhang wrote:
> Let berlin_pinctrl_probe() accepts an extra argument: regmap, this is to
> prepare for the next berlin4ct support, where we won't use simple-mfd
> any more.
Just a question here: why don't we have instead one
berlin_pinctrl_probe() and one berlin_pinctrl_probe_regmap(), both
calling a static probe function in berlin.c, to avoid duplicating code?
Antoine
> Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
> ---
> drivers/pinctrl/berlin/berlin-bg2.c | 10 +++++++++-
> drivers/pinctrl/berlin/berlin-bg2cd.c | 10 +++++++++-
> drivers/pinctrl/berlin/berlin-bg2q.c | 10 +++++++++-
> drivers/pinctrl/berlin/berlin.c | 9 +--------
> drivers/pinctrl/berlin/berlin.h | 1 +
> 5 files changed, 29 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/pinctrl/berlin/berlin-bg2.c b/drivers/pinctrl/berlin/berlin-bg2.c
> index 274c553..4aede2e 100644
> --- a/drivers/pinctrl/berlin/berlin-bg2.c
> +++ b/drivers/pinctrl/berlin/berlin-bg2.c
> @@ -10,6 +10,7 @@
> * warranty of any kind, whether express or implied.
> */
>
> +#include <linux/mfd/syscon.h>
> #include <linux/module.h>
> #include <linux/of_device.h>
> #include <linux/platform_device.h>
> @@ -233,8 +234,15 @@ static int berlin2_pinctrl_probe(struct platform_device *pdev)
> {
> const struct of_device_id *match =
> of_match_device(berlin2_pinctrl_match, &pdev->dev);
> + struct device *dev = &pdev->dev;
> + struct device_node *parent_np = of_get_parent(dev->of_node);
> + struct regmap *regmap = syscon_node_to_regmap(parent_np);
>
> - return berlin_pinctrl_probe(pdev, match->data);
> + of_node_put(parent_np);
> + if (IS_ERR(regmap))
> + return PTR_ERR(regmap);
> +
> + return berlin_pinctrl_probe(pdev, regmap, match->data);
> }
>
> static struct platform_driver berlin2_pinctrl_driver = {
> diff --git a/drivers/pinctrl/berlin/berlin-bg2cd.c b/drivers/pinctrl/berlin/berlin-bg2cd.c
> index 0cb793a..6378dd8 100644
> --- a/drivers/pinctrl/berlin/berlin-bg2cd.c
> +++ b/drivers/pinctrl/berlin/berlin-bg2cd.c
> @@ -10,6 +10,7 @@
> * warranty of any kind, whether express or implied.
> */
>
> +#include <linux/mfd/syscon.h>
> #include <linux/module.h>
> #include <linux/of_device.h>
> #include <linux/platform_device.h>
> @@ -176,8 +177,15 @@ static int berlin2cd_pinctrl_probe(struct platform_device *pdev)
> {
> const struct of_device_id *match =
> of_match_device(berlin2cd_pinctrl_match, &pdev->dev);
> + struct device *dev = &pdev->dev;
> + struct device_node *parent_np = of_get_parent(dev->of_node);
> + struct regmap *regmap = syscon_node_to_regmap(parent_np);
>
> - return berlin_pinctrl_probe(pdev, match->data);
> + of_node_put(parent_np);
> + if (IS_ERR(regmap))
> + return PTR_ERR(regmap);
> +
> + return berlin_pinctrl_probe(pdev, regmap, match->data);
> }
>
> static struct platform_driver berlin2cd_pinctrl_driver = {
> diff --git a/drivers/pinctrl/berlin/berlin-bg2q.c b/drivers/pinctrl/berlin/berlin-bg2q.c
> index a466054..907bdf0 100644
> --- a/drivers/pinctrl/berlin/berlin-bg2q.c
> +++ b/drivers/pinctrl/berlin/berlin-bg2q.c
> @@ -10,6 +10,7 @@
> * warranty of any kind, whether express or implied.
> */
>
> +#include <linux/mfd/syscon.h>
> #include <linux/module.h>
> #include <linux/of_device.h>
> #include <linux/platform_device.h>
> @@ -395,8 +396,15 @@ static int berlin2q_pinctrl_probe(struct platform_device *pdev)
> {
> const struct of_device_id *match =
> of_match_device(berlin2q_pinctrl_match, &pdev->dev);
> + struct device *dev = &pdev->dev;
> + struct device_node *parent_np = of_get_parent(dev->of_node);
> + struct regmap *regmap = syscon_node_to_regmap(parent_np);
>
> - return berlin_pinctrl_probe(pdev, match->data);
> + of_node_put(parent_np);
> + if (IS_ERR(regmap))
> + return PTR_ERR(regmap);
> +
> + return berlin_pinctrl_probe(pdev, regmap, match->data);
> }
>
> static struct platform_driver berlin2q_pinctrl_driver = {
> diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
> index f495806..0557bbe 100644
> --- a/drivers/pinctrl/berlin/berlin.c
> +++ b/drivers/pinctrl/berlin/berlin.c
> @@ -11,7 +11,6 @@
> */
>
> #include <linux/io.h>
> -#include <linux/mfd/syscon.h>
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
> @@ -293,19 +292,13 @@ static struct pinctrl_desc berlin_pctrl_desc = {
> };
>
> int berlin_pinctrl_probe(struct platform_device *pdev,
> + struct regmap *regmap,
> const struct berlin_pinctrl_desc *desc)
> {
> struct device *dev = &pdev->dev;
> - struct device_node *parent_np = of_get_parent(dev->of_node);
> struct berlin_pinctrl *pctrl;
> - struct regmap *regmap;
> int ret;
>
> - regmap = syscon_node_to_regmap(parent_np);
> - of_node_put(parent_np);
> - if (IS_ERR(regmap))
> - return PTR_ERR(regmap);
> -
> pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL);
> if (!pctrl)
> return -ENOMEM;
> diff --git a/drivers/pinctrl/berlin/berlin.h b/drivers/pinctrl/berlin/berlin.h
> index e1aa841..bf5781a 100644
> --- a/drivers/pinctrl/berlin/berlin.h
> +++ b/drivers/pinctrl/berlin/berlin.h
> @@ -56,6 +56,7 @@ struct berlin_pinctrl_function {
> #define BERLIN_PINCTRL_FUNCTION_UNKNOWN {}
>
> int berlin_pinctrl_probe(struct platform_device *pdev,
> + struct regmap *regmap,
> const struct berlin_pinctrl_desc *desc);
>
> #endif /* __PINCTRL_BERLIN_H */
> --
> 2.5.3
>
--
Antoine Ténart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
next prev parent reply other threads:[~2015-10-02 13:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-21 10:04 [PATCH v2 0/6] arm64: berlin: add pinctrl support Jisheng Zhang
[not found] ` <1442829860-4647-1-git-send-email-jszhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2015-09-21 10:04 ` [PATCH v2 1/6] pinctrl: berlin: regmap as an extra argument of berlin_pinctrl_probe() Jisheng Zhang
2015-10-02 10:37 ` Linus Walleij
2015-10-02 13:04 ` Antoine Tenart [this message]
2015-10-08 10:32 ` Jisheng Zhang
2015-09-21 10:04 ` [PATCH v2 2/6] pinctrl: berlin: add the berlin4ct pinctrl driver Jisheng Zhang
2015-10-02 13:21 ` Antoine Tenart
2015-10-08 10:46 ` Jisheng Zhang
2015-10-09 7:05 ` Jisheng Zhang
2015-09-21 10:04 ` [PATCH v2 3/6] arm64: berlin: add the pinctrl dependency for Marvell Berlin SoCs Jisheng Zhang
2015-09-21 10:04 ` [PATCH v2 4/6] pinctrl: dt-binding: document berlin4ct SoC pinctrl Jisheng Zhang
2015-09-21 10:04 ` [PATCH v2 5/6] arm64: dts: berlin4ct: add the pinctrl node Jisheng Zhang
2015-10-02 13:24 ` Antoine Tenart
2015-09-21 10:04 ` [PATCH v2 6/6] arm64: dts: berlin4ct: add default pinmux for uart0 Jisheng Zhang
2015-10-02 13:26 ` Antoine Tenart
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=20151002130456.GC3162@kwain \
--to=antoine.tenart@free-electrons.com \
--cc=catalin.marinas@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jszhang@marvell.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=will.deacon@arm.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).