From: Mark Rutland <mark.rutland@arm.com>
To: Marek Belisko <marek@goldelico.com>
Cc: "robh+dt@kernel.org" <robh+dt@kernel.org>,
Pawel Moll <Pawel.Moll@arm.com>,
"ijc+devicetree@hellion.org.uk" <ijc+devicetree@hellion.org.uk>,
"galak@codeaurora.org" <galak@codeaurora.org>,
"rob@landley.net" <rob@landley.net>,
"linville@tuxdriver.com" <linville@tuxdriver.com>,
"johannes@sipsolutions.net" <johannes@sipsolutions.net>,
"davem@davemloft.net" <davem@davemloft.net>,
"grant.likely@linaro.org" <grant.likely@linaro.org>,
"neilb@suse.de" <neilb@suse.de>,
"hns@goldelico.com" <hns@goldelico.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH] net: rfkill-regulator: Add devicetree support.
Date: Mon, 10 Feb 2014 10:18:42 +0000 [thread overview]
Message-ID: <20140210101842.GS25314@e106331-lin.cambridge.arm.com> (raw)
In-Reply-To: <1391802529-29861-1-git-send-email-marek@goldelico.com>
On Fri, Feb 07, 2014 at 07:48:49PM +0000, Marek Belisko wrote:
> Signed-off-by: NeilBrown <neilb@suse.de>
> Signed-off-by: Marek Belisko <marek@goldelico.com>
> ---
> Based on Neil's patch and extend for documentation and bindings include.
>
> .../bindings/net/rfkill/rfkill-relugator.txt | 28 ++++++++++++++++
> include/dt-bindings/net/rfkill-regulator.h | 23 +++++++++++++
> net/rfkill/rfkill-regulator.c | 38 ++++++++++++++++++++++
> 3 files changed, 89 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/net/rfkill/rfkill-relugator.txt
> create mode 100644 include/dt-bindings/net/rfkill-regulator.h
>
> diff --git a/Documentation/devicetree/bindings/net/rfkill/rfkill-relugator.txt b/Documentation/devicetree/bindings/net/rfkill/rfkill-relugator.txt
> new file mode 100644
> index 0000000..cdb7dd7
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/rfkill/rfkill-relugator.txt
> @@ -0,0 +1,28 @@
> +Regulator consumer for rfkill devices
What exactly is an "rfkill" device? How is it used? How does it relate
to other devices in the DT?
To me, this looks like a leak of a Linux abstraction.
> +
> +Required properties:
> +- compatible : Must be "rfkill-regulator".
> +- label : Name of rfkill device.
What's this for? Why does this need a label in the DT? Surely this can
be implied by the relationship to a particular radio device?
> +- type : Type of rfkill device.
> +
> +Possible values (defined in include/dt-bindings/net/rfkill-regulator.h):
> + RFKILL_TYPE_ALL
> + RFKILL_TYPE_WLAN
> + RFKILL_TYPE_BLUETOOTH
> + RFKILL_TYPE_UWB
> + RFKILL_TYPE_WIMAX
> + RFKILL_TYPE_WWAN
> + RFKILL_TYPE_GPS
> + RFKILL_TYPE_FM
> + RFKILL_TYPE_NFC
What do these mean? Why can these not be implied by a relationship to
any devices of these particular types?
> +
> +- vrfkill-supply - regulator device.
Why isn't this described on the radio revice node? It's a supply to the
radio, not to the rfkill concept.
> +
> +Example:
> + gps-rfkill {
> + compatible = "rfkill-regulator";
> + label = "GPS";
> + type = <RFKILL_TYPE_GPS>;
> + vrfkill-supply = <®>;
> + };
Why is this not bound to the particular GPS device in some way?
What if I have more than one of any of the types of device this
supports, which device is this expected to control?
Why is it described as a separate device in the device tree at all?
I do not think this binding is the right way to describe this.
Thanks,
Mark.
> +
> diff --git a/include/dt-bindings/net/rfkill-regulator.h b/include/dt-bindings/net/rfkill-regulator.h
> new file mode 100644
> index 0000000..ae32273
> --- /dev/null
> +++ b/include/dt-bindings/net/rfkill-regulator.h
> @@ -0,0 +1,23 @@
> +/*
> + * This header provides macros for rfkill-regulator bindings.
> + *
> + * Copyright (C) 2014 Marek Belisko <marek@goldelico.com>
> + *
> + * GPLv2 only
> + */
> +
> +#ifndef __DT_BINDINGS_RFKILL_REGULATOR_H__
> +#define __DT_BINDINGS_RFKILL_REGULATOR_H__
> +
> +
> +#define RFKILL_TYPE_ALL (0)
> +#define RFKILL_TYPE_WLAN (1)
> +#define RFKILL_TYPE_BLUETOOTH (2)
> +#define RFKILL_TYPE_UWB (3)
> +#define RFKILL_TYPE_WIMAX (4)
> +#define RFKILL_TYPE_WWAN (5)
> +#define RFKILL_TYPE_GPS (6)
> +#define RFKILL_TYPE_FM (7)
> +#define RFKILL_TYPE_NFC (8)
> +
> +#endif /* __DT_BINDINGS_RFKILL_REGULATOR_H__ */
> diff --git a/net/rfkill/rfkill-regulator.c b/net/rfkill/rfkill-regulator.c
> index cf5b145..a04aff8 100644
> --- a/net/rfkill/rfkill-regulator.c
> +++ b/net/rfkill/rfkill-regulator.c
> @@ -19,6 +19,7 @@
> #include <linux/regulator/consumer.h>
> #include <linux/rfkill.h>
> #include <linux/rfkill-regulator.h>
> +#include <linux/of_platform.h>
>
> struct rfkill_regulator_data {
> struct rfkill *rf_kill;
> @@ -57,6 +58,31 @@ static struct rfkill_ops rfkill_regulator_ops = {
> .set_block = rfkill_regulator_set_block,
> };
>
> +#ifdef CONFIG_OF
> +static struct rfkill_regulator_platform_data *
> +rfkill_regulator_parse_pdata(struct device *dev)
> +{
> + struct rfkill_regulator_platform_data *pdata;
> + struct device_node *np = dev->of_node;
> + u32 num;
> + if (!np)
> + return NULL;
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + return NULL;
> + if (of_property_read_u32(np, "type", &num) == 0)
> + pdata->type = num;
> + of_property_read_string(np, "label", &pdata->name);
> + return pdata;
> +}
> +#else
> +static inline struct rfkill_regulator_platform_data *
> +rfkill_regulator_parse_pdata(struct device *dev)
> +{
> + return NULL;
> +}
> +#endif
> +
> static int rfkill_regulator_probe(struct platform_device *pdev)
> {
> struct rfkill_regulator_platform_data *pdata = pdev->dev.platform_data;
> @@ -65,6 +91,9 @@ static int rfkill_regulator_probe(struct platform_device *pdev)
> struct rfkill *rf_kill;
> int ret = 0;
>
> + if (!pdata)
> + pdata = rfkill_regulator_parse_pdata(&pdev->dev);
> +
> if (pdata == NULL) {
> dev_err(&pdev->dev, "no platform data\n");
> return -ENODEV;
> @@ -137,12 +166,21 @@ static int rfkill_regulator_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id rfkill_regulator_match[] = {
> + {.compatible = "rfkill-regulator"},
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, rfkill_regulator_match);
> +#endif
> +
> static struct platform_driver rfkill_regulator_driver = {
> .probe = rfkill_regulator_probe,
> .remove = rfkill_regulator_remove,
> .driver = {
> .name = "rfkill-regulator",
> .owner = THIS_MODULE,
> + .of_match_table = of_match_ptr(rfkill_regulator_match),
> },
> };
>
> --
> 1.8.3.2
>
>
next prev parent reply other threads:[~2014-02-10 10:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-07 19:48 [PATCH] net: rfkill-regulator: Add devicetree support Marek Belisko
2014-02-08 6:22 ` Bill Fink
2014-02-08 20:42 ` Belisko Marek
2014-02-10 8:27 ` Johannes Berg
2014-02-10 8:54 ` Dr. H. Nikolaus Schaller
2014-02-10 20:05 ` Belisko Marek
2014-02-10 10:18 ` Mark Rutland [this message]
2014-02-10 21:35 ` Belisko Marek
2014-02-11 8:42 ` Marc Dietrich
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=20140210101842.GS25314@e106331-lin.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=Pawel.Moll@arm.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=grant.likely@linaro.org \
--cc=hns@goldelico.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=johannes@sipsolutions.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=marek@goldelico.com \
--cc=neilb@suse.de \
--cc=netdev@vger.kernel.org \
--cc=rob@landley.net \
--cc=robh+dt@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).