From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: linux-gpio@vger.kernel.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>,
linus.walleij@linaro.org, narmstrong@baylibre.com,
linux-kernel@vger.kernel.org, cphealy@gmail.com
Subject: [PATCH v2 01/15] pinctrl-sx150x: Improve OF device matching code
Date: Mon, 7 Nov 2016 08:53:09 -0800 [thread overview]
Message-ID: <1478537603-23653-2-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1478537603-23653-1-git-send-email-andrew.smirnov@gmail.com>
Add proper device specific information to of_device_id table of the
driver and add code to match against and fetch said data from it.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/pinctrl/pinctrl-sx150x.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c
index d2d4211..0523f5a 100644
--- a/drivers/pinctrl/pinctrl-sx150x.c
+++ b/drivers/pinctrl/pinctrl-sx150x.c
@@ -25,6 +25,7 @@
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/gpio.h>
#include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinconf.h>
@@ -862,10 +863,10 @@ static const struct i2c_device_id sx150x_id[] = {
};
static const struct of_device_id sx150x_of_match[] = {
- { .compatible = "semtech,sx1508q" },
- { .compatible = "semtech,sx1509q" },
- { .compatible = "semtech,sx1506q" },
- { .compatible = "semtech,sx1502q" },
+ { .compatible = "semtech,sx1508q", .data = &sx1508q_device_data },
+ { .compatible = "semtech,sx1509q", .data = &sx1509q_device_data },
+ { .compatible = "semtech,sx1506q", .data = &sx1506q_device_data },
+ { .compatible = "semtech,sx1502q", .data = &sx1502q_device_data },
{},
};
@@ -956,9 +957,6 @@ static int sx150x_probe(struct i2c_client *client,
struct sx150x_pinctrl *pctl;
int ret;
- if (!id->driver_data)
- return -EINVAL;
-
if (!i2c_check_functionality(client->adapter, i2c_funcs))
return -ENOSYS;
@@ -968,7 +966,14 @@ static int sx150x_probe(struct i2c_client *client,
pctl->dev = dev;
pctl->client = client;
- pctl->data = (void *)id->driver_data;
+
+ if (dev->of_node)
+ pctl->data = of_device_get_match_data(dev);
+ else
+ pctl->data = (struct sx150x_device_data *)id->driver_data;
+
+ if (!pctl->data)
+ return -EINVAL;
mutex_init(&pctl->lock);
--
2.5.5
next prev parent reply other threads:[~2016-11-07 16:54 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-07 16:53 [PATCH v2 00/15] pinctrl-sx150x: Various bug-fixes and code simplifications Andrey Smirnov
2016-11-07 16:53 ` Andrey Smirnov [this message]
2016-11-08 8:34 ` [PATCH v2 01/15] pinctrl-sx150x: Improve OF device matching code Linus Walleij
2016-11-07 16:53 ` [PATCH v2 02/15] pinctrl-sx150x: Add SX1503 specific data Andrey Smirnov
2016-11-08 8:35 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 03/15] bindings: pinctrl-sx150x: Document SX1503 compatibility string Andrey Smirnov
2016-11-08 8:35 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 04/15] pinctrl-sx150x: Replace magic number in sx150x_init_hw Andrey Smirnov
2016-11-08 8:36 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 05/15] pinctrl-sx150x: Fix incorrect constant " Andrey Smirnov
2016-11-08 8:37 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 06/15] pinctrl-sx150x: Move some code out of sx150x_init_hw Andrey Smirnov
2016-11-08 8:38 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 07/15] pinctrl-sx150x: Improve sx150x_init_misc for SX1504/5/6 Andrey Smirnov
2016-11-08 8:38 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 08/15] pinctrl-sx150x: Convert driver to use regmap API Andrey Smirnov
2016-11-08 8:39 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 09/15] pinctrl-sx150x: Replace sx150x_*_cfg by means of " Andrey Smirnov
2016-11-08 8:43 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 10/15] pinctrl-sx150x: Remove excessive locking Andrey Smirnov
2016-11-08 8:44 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 11/15] pinctrl-sx150x: Improve oscio GPIO functions Andrey Smirnov
2016-11-08 8:45 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 12/15] pinctrl-sx150x: Simplify interrupt handler Andrey Smirnov
2016-11-08 8:46 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 13/15] pinctrl-sx150x: Use handle_bad_irq instead of handle_edge_irq Andrey Smirnov
2016-11-08 8:47 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 14/15] pinctrl-sx150x: Remove magic numbers from sx150x_irq_set_type Andrey Smirnov
2016-11-08 8:48 ` Linus Walleij
2016-11-07 16:53 ` [PATCH v2 15/15] pinctrl-sx150x: Remove magic numbers from sx150x_reset Andrey Smirnov
2016-11-08 8:49 ` Linus Walleij
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=1478537603-23653-2-git-send-email-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=cphealy@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=narmstrong@baylibre.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).