From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>, linux-gpio@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 7/9] pinctrl: mcp23s08: Make use of device properties
Date: Tue, 7 Apr 2020 20:38:47 +0300 [thread overview]
Message-ID: <20200407173849.43628-7-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200407173849.43628-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/pinctrl/pinctrl-mcp23s08.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
index 515d1aa32732..330c2203e0f2 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08.c
@@ -4,6 +4,7 @@
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/mutex.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/gpio/driver.h>
#include <linux/i2c.h>
@@ -11,7 +12,6 @@
#include <linux/slab.h>
#include <asm/byteorder.h>
#include <linux/interrupt.h>
-#include <linux/of_device.h>
#include <linux/regmap.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinconf.h>
@@ -20,12 +20,12 @@
/*
* MCP types supported by driver
*/
-#define MCP_TYPE_S08 0
-#define MCP_TYPE_S17 1
-#define MCP_TYPE_008 2
-#define MCP_TYPE_017 3
-#define MCP_TYPE_S18 4
-#define MCP_TYPE_018 5
+#define MCP_TYPE_S08 1
+#define MCP_TYPE_S17 2
+#define MCP_TYPE_008 3
+#define MCP_TYPE_017 4
+#define MCP_TYPE_S18 5
+#define MCP_TYPE_018 6
/* Registers are all 8 bits wide.
*
@@ -757,7 +757,6 @@ static const struct i2c_device_id mcp230xx_id[] = {
};
MODULE_DEVICE_TABLE(i2c, mcp230xx_id);
-#ifdef CONFIG_OF
static const struct of_device_id mcp23s08_i2c_of_match[] = {
{
.compatible = "microchip,mcp23008",
@@ -783,12 +782,11 @@ static const struct of_device_id mcp23s08_i2c_of_match[] = {
{ },
};
MODULE_DEVICE_TABLE(of, mcp23s08_i2c_of_match);
-#endif /* CONFIG_OF */
static struct i2c_driver mcp230xx_driver = {
.driver = {
.name = "mcp230xx",
- .of_match_table = of_match_ptr(mcp23s08_i2c_of_match),
+ .of_match_table = mcp23s08_i2c_of_match,
},
.probe = mcp230xx_probe,
.id_table = mcp230xx_id,
@@ -942,17 +940,17 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev,
static int mcp23s08_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
+ const void *match;
unsigned addr;
int chips = 0;
struct mcp23s08_driver_data *data;
int status, type;
unsigned ngpio = 0;
- const struct of_device_id *match;
u32 spi_present_mask;
- match = of_match_device(of_match_ptr(mcp23s08_spi_of_match), &spi->dev);
+ match = device_get_match_data(dev);
if (match)
- type = (int)(uintptr_t)match->data;
+ type = (int)(uintptr_t)match;
else
type = spi_get_device_id(spi)->driver_data;
@@ -1022,7 +1020,6 @@ static const struct spi_device_id mcp23s08_ids[] = {
};
MODULE_DEVICE_TABLE(spi, mcp23s08_ids);
-#ifdef CONFIG_OF
static const struct of_device_id mcp23s08_spi_of_match[] = {
{
.compatible = "microchip,mcp23s08",
@@ -1048,14 +1045,13 @@ static const struct of_device_id mcp23s08_spi_of_match[] = {
{ },
};
MODULE_DEVICE_TABLE(of, mcp23s08_spi_of_match);
-#endif
static struct spi_driver mcp23s08_driver = {
.probe = mcp23s08_probe,
.id_table = mcp23s08_ids,
.driver = {
.name = "mcp23s08",
- .of_match_table = of_match_ptr(mcp23s08_spi_of_match),
+ .of_match_table = mcp23s08_spi_of_match,
},
};
--
2.25.1
next prev parent reply other threads:[~2020-04-07 17:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-07 17:38 [PATCH v1 1/9] pinctrl: mcp23s08: Get rid of legacy platform data Andy Shevchenko
2020-04-07 17:38 ` [PATCH v1 2/9] pinctrl: mcp23s08: Deduplicate IRQ chip filling Andy Shevchenko
2020-04-07 17:38 ` [PATCH v1 3/9] pinctrl: mcp23s08: Consolidate SPI and I²C code Andy Shevchenko
2020-04-07 17:38 ` [PATCH v1 4/9] pinctrl: mcp23s08: Drop unused parameter in mcp23s08_probe_one() Andy Shevchenko
2020-04-07 17:38 ` [PATCH v1 5/9] pinctrl: mcp23s08: Refactor mcp23s08_spi_regmap_init() Andy Shevchenko
2020-04-07 17:38 ` [PATCH v1 6/9] pinctrl: mcp23s08: Propagate error code from device_property_read_u32() Andy Shevchenko
2020-04-07 17:38 ` Andy Shevchenko [this message]
2020-04-07 17:38 ` [PATCH v1 8/9] pinctrl: mcp23s08: Use for_each_set_bit() and hweight_long() Andy Shevchenko
2020-04-07 17:38 ` [PATCH v1 9/9] pinctrl: mcp23s08: Split to three parts: core, I²C, SPI Andy Shevchenko
2020-04-16 10:35 ` [PATCH v1 1/9] pinctrl: mcp23s08: Get rid of legacy platform data Linus Walleij
2020-10-09 9:15 ` Martin Hundebøll
2020-10-09 14:02 ` Andy Shevchenko
2020-10-09 16:02 ` Andy Shevchenko
2021-09-16 12:51 ` Florian Eckert
2021-09-22 6:36 ` Andy Shevchenko
2021-09-22 7:53 ` Andy Shevchenko
2021-09-23 14:17 ` Add a SSDT ACPI description to recognize my I2C device connected via SMBus Florian Eckert
2021-09-23 16:24 ` Mika Westerberg
2021-09-23 20:26 ` Andy Shevchenko
2021-09-23 20:29 ` Andy Shevchenko
2021-09-29 22:40 ` Florian Eckert
2021-09-30 6:15 ` Andy Shevchenko
2021-09-30 6:19 ` 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=20200407173849.43628-7-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.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).