Skip to content

Commit e2d1812

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
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: Andy Shevchenko <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 91a0192 commit e2d1812

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

drivers/gpio/gpio-pcf857x.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#include <linux/irq.h>
1212
#include <linux/irqdomain.h>
1313
#include <linux/kernel.h>
14+
#include <linux/mod_devicetable.h>
1415
#include <linux/module.h>
15-
#include <linux/of.h>
16-
#include <linux/of_device.h>
16+
#include <linux/property.h>
1717
#include <linux/slab.h>
1818
#include <linux/spinlock.h>
1919

@@ -35,7 +35,6 @@ static const struct i2c_device_id pcf857x_id[] = {
3535
};
3636
MODULE_DEVICE_TABLE(i2c, pcf857x_id);
3737

38-
#ifdef CONFIG_OF
3938
static const struct of_device_id pcf857x_of_table[] = {
4039
{ .compatible = "nxp,pcf8574" },
4140
{ .compatible = "nxp,pcf8574a" },
@@ -53,7 +52,6 @@ static const struct of_device_id pcf857x_of_table[] = {
5352
{ }
5453
};
5554
MODULE_DEVICE_TABLE(of, pcf857x_of_table);
56-
#endif
5755

5856
/*
5957
* The pcf857x, pca857x, and pca967x chips only expose one read and one
@@ -275,12 +273,11 @@ static const struct irq_chip pcf857x_irq_chip = {
275273
static int pcf857x_probe(struct i2c_client *client)
276274
{
277275
const struct i2c_device_id *id = i2c_client_get_device_id(client);
278-
struct device_node *np = client->dev.of_node;
279276
struct pcf857x *gpio;
280277
unsigned int n_latch = 0;
281278
int status;
282279

283-
of_property_read_u32(np, "lines-initial-states", &n_latch);
280+
device_property_read_u32(&client->dev, "lines-initial-states", &n_latch);
284281

285282
/* Allocate, initialize, and register this gpio_chip. */
286283
gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL);
@@ -420,7 +417,7 @@ static void pcf857x_shutdown(struct i2c_client *client)
420417
static struct i2c_driver pcf857x_driver = {
421418
.driver = {
422419
.name = "pcf857x",
423-
.of_match_table = of_match_ptr(pcf857x_of_table),
420+
.of_match_table = pcf857x_of_table,
424421
},
425422
.probe_new = pcf857x_probe,
426423
.shutdown = pcf857x_shutdown,

0 commit comments

Comments
 (0)