From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Peter Rosin <peda@axentia.se>,
linux-i2c@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 2/5] i2c: mux: pca954x: Make use of device properties
Date: Thu, 5 Mar 2020 17:53:49 +0200 [thread overview]
Message-ID: <20200305155352.39095-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200305155352.39095-1-andriy.shevchenko@linux.intel.com>
Device property API allows to gather device resources from different sources,
such as ACPI. Convert the drivers to unleash the power of device property API.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/muxes/i2c-mux-pca954x.c | 39 +++++++++++++----------------
1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index 819ff95e64ba..2e42a113ef1f 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -43,10 +43,8 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
-#include <linux/of_irq.h>
#include <linux/pm.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <dt-bindings/mux/mux.h>
@@ -182,23 +180,22 @@ static const struct chip_desc chips[] = {
};
static const struct i2c_device_id pca954x_id[] = {
- { "pca9540", pca_9540 },
- { "pca9542", pca_9542 },
- { "pca9543", pca_9543 },
- { "pca9544", pca_9544 },
- { "pca9545", pca_9545 },
- { "pca9546", pca_9546 },
- { "pca9547", pca_9547 },
- { "pca9548", pca_9548 },
- { "pca9846", pca_9846 },
- { "pca9847", pca_9847 },
- { "pca9848", pca_9848 },
- { "pca9849", pca_9849 },
+ { "pca9540", .driver_data = (kernel_ulong_t)&chips[pca_9540] },
+ { "pca9542", .driver_data = (kernel_ulong_t)&chips[pca_9542] },
+ { "pca9543", .driver_data = (kernel_ulong_t)&chips[pca_9543] },
+ { "pca9544", .driver_data = (kernel_ulong_t)&chips[pca_9544] },
+ { "pca9545", .driver_data = (kernel_ulong_t)&chips[pca_9545] },
+ { "pca9546", .driver_data = (kernel_ulong_t)&chips[pca_9546] },
+ { "pca9547", .driver_data = (kernel_ulong_t)&chips[pca_9547] },
+ { "pca9548", .driver_data = (kernel_ulong_t)&chips[pca_9548] },
+ { "pca9846", .driver_data = (kernel_ulong_t)&chips[pca_9846] },
+ { "pca9847", .driver_data = (kernel_ulong_t)&chips[pca_9847] },
+ { "pca9848", .driver_data = (kernel_ulong_t)&chips[pca_9848] },
+ { "pca9849", .driver_data = (kernel_ulong_t)&chips[pca_9849] },
{ }
};
MODULE_DEVICE_TABLE(i2c, pca954x_id);
-#ifdef CONFIG_OF
static const struct of_device_id pca954x_of_match[] = {
{ .compatible = "nxp,pca9540", .data = &chips[pca_9540] },
{ .compatible = "nxp,pca9542", .data = &chips[pca_9542] },
@@ -215,7 +212,6 @@ static const struct of_device_id pca954x_of_match[] = {
{}
};
MODULE_DEVICE_TABLE(of, pca954x_of_match);
-#endif
/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer()
for this as they will try to lock adapter a second time */
@@ -426,7 +422,6 @@ static int pca954x_probe(struct i2c_client *client,
{
struct i2c_adapter *adap = client->adapter;
struct device *dev = &client->dev;
- struct device_node *np = dev->of_node;
struct gpio_desc *gpio;
struct i2c_mux_core *muxc;
struct pca954x *data;
@@ -456,7 +451,7 @@ static int pca954x_probe(struct i2c_client *client,
udelay(1);
}
- data->chip = of_device_get_match_data(dev);
+ data->chip = device_get_match_data(dev);
if (!data->chip)
data->chip = &chips[id->driver_data];
@@ -478,8 +473,8 @@ static int pca954x_probe(struct i2c_client *client,
}
data->idle_state = MUX_IDLE_AS_IS;
- if (of_property_read_u32(np, "idle-state", &data->idle_state)) {
- if (np && of_property_read_bool(np, "i2c-mux-idle-disconnect"))
+ if (device_property_read_u32(dev, "idle-state", &data->idle_state)) {
+ if (device_property_read_bool(dev, "i2c-mux-idle-disconnect"))
data->idle_state = MUX_IDLE_DISCONNECT;
}
@@ -562,7 +557,7 @@ static struct i2c_driver pca954x_driver = {
.driver = {
.name = "pca954x",
.pm = &pca954x_pm,
- .of_match_table = of_match_ptr(pca954x_of_match),
+ .of_match_table = pca954x_of_match,
},
.probe = pca954x_probe,
.remove = pca954x_remove,
--
2.25.1
next prev parent reply other threads:[~2020-03-05 15:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 15:53 [PATCH v1 1/5] i2c: mux: pca954x: Refactor pca954x_irq_handler() Andy Shevchenko
2020-03-05 15:53 ` Andy Shevchenko [this message]
2020-03-05 21:05 ` [PATCH v1 2/5] i2c: mux: pca954x: Make use of device properties Peter Rosin
2020-03-06 9:54 ` Andy Shevchenko
2020-03-06 11:48 ` Peter Rosin
2020-03-06 13:58 ` Andy Shevchenko
2020-03-06 14:57 ` Peter Rosin
2020-03-06 15:07 ` Andy Shevchenko
2020-03-05 15:53 ` [PATCH v1 3/5] i2c: mux: pca954x: Drop useless validation for optional GPIO descriptor Andy Shevchenko
2020-03-05 21:19 ` Peter Rosin
2020-03-06 9:56 ` Andy Shevchenko
2020-03-05 15:53 ` [PATCH v1 4/5] i2c: mux: pca954x: Move device_remove_file() out of pca954x_cleanup() Andy Shevchenko
2020-03-05 15:53 ` [PATCH v1 5/5] i2c: mux: pca954x: Convert license to SPDX identifier Andy Shevchenko
2020-03-05 21:34 ` [PATCH v1 1/5] i2c: mux: pca954x: Refactor pca954x_irq_handler() Peter Rosin
2020-03-06 10:02 ` Andy Shevchenko
2020-03-06 10:58 ` Peter Rosin
2020-03-16 16:08 ` Andy Shevchenko
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=20200305155352.39095-2-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=peda@axentia.se \
--cc=wsa@the-dreams.de \
/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