提交 e2d18121 编写于 作者: A Andy Shevchenko 提交者: Bartosz Golaszewski

gpio: pcf857x: Make use of device properties

Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Add mod_devicetable.h include.
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NBartosz Golaszewski <bartosz.golaszewski@linaro.org>
上级 91a0192e
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/property.h>
#include <linux/of_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -35,7 +35,6 @@ static const struct i2c_device_id pcf857x_id[] = { ...@@ -35,7 +35,6 @@ static const struct i2c_device_id pcf857x_id[] = {
}; };
MODULE_DEVICE_TABLE(i2c, pcf857x_id); MODULE_DEVICE_TABLE(i2c, pcf857x_id);
#ifdef CONFIG_OF
static const struct of_device_id pcf857x_of_table[] = { static const struct of_device_id pcf857x_of_table[] = {
{ .compatible = "nxp,pcf8574" }, { .compatible = "nxp,pcf8574" },
{ .compatible = "nxp,pcf8574a" }, { .compatible = "nxp,pcf8574a" },
...@@ -53,7 +52,6 @@ static const struct of_device_id pcf857x_of_table[] = { ...@@ -53,7 +52,6 @@ static const struct of_device_id pcf857x_of_table[] = {
{ } { }
}; };
MODULE_DEVICE_TABLE(of, pcf857x_of_table); MODULE_DEVICE_TABLE(of, pcf857x_of_table);
#endif
/* /*
* The pcf857x, pca857x, and pca967x chips only expose one read and one * The pcf857x, pca857x, and pca967x chips only expose one read and one
...@@ -275,12 +273,11 @@ static const struct irq_chip pcf857x_irq_chip = { ...@@ -275,12 +273,11 @@ static const struct irq_chip pcf857x_irq_chip = {
static int pcf857x_probe(struct i2c_client *client) static int pcf857x_probe(struct i2c_client *client)
{ {
const struct i2c_device_id *id = i2c_client_get_device_id(client); const struct i2c_device_id *id = i2c_client_get_device_id(client);
struct device_node *np = client->dev.of_node;
struct pcf857x *gpio; struct pcf857x *gpio;
unsigned int n_latch = 0; unsigned int n_latch = 0;
int status; int status;
of_property_read_u32(np, "lines-initial-states", &n_latch); device_property_read_u32(&client->dev, "lines-initial-states", &n_latch);
/* Allocate, initialize, and register this gpio_chip. */ /* Allocate, initialize, and register this gpio_chip. */
gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL); gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL);
...@@ -420,7 +417,7 @@ static void pcf857x_shutdown(struct i2c_client *client) ...@@ -420,7 +417,7 @@ static void pcf857x_shutdown(struct i2c_client *client)
static struct i2c_driver pcf857x_driver = { static struct i2c_driver pcf857x_driver = {
.driver = { .driver = {
.name = "pcf857x", .name = "pcf857x",
.of_match_table = of_match_ptr(pcf857x_of_table), .of_match_table = pcf857x_of_table,
}, },
.probe_new = pcf857x_probe, .probe_new = pcf857x_probe,
.shutdown = pcf857x_shutdown, .shutdown = pcf857x_shutdown,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册