* [PATCH 1/6] sh: sh7785lcr: add GPIO lookup table for i2c controller reset
[not found] <20170630005408.23968-1-chris.packham@alliedtelesis.co.nz>
@ 2017-06-30 0:54 ` Chris Packham
2017-07-02 16:47 ` kbuild test robot
2017-06-30 0:54 ` [PATCH 2/6] i2c: pca-platform: correctly set algo_data.reset_chip Chris Packham
` (4 subsequent siblings)
5 siblings, 1 reply; 18+ messages in thread
From: Chris Packham @ 2017-06-30 0:54 UTC (permalink / raw)
To: wsa, andy.shevchenko, linux-i2c
Cc: ysato, linux-sh, Chris Packham, Rich Felker, linux-kernel
Define the GPIO connected to the PCA9564 using a GPIO lookup table. This
will allow the i2c-pca-platform driver to use the device managed APIs to
lookup the gpio instead of using platform_data.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
arch/sh/boards/board-sh7785lcr.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/sh/boards/board-sh7785lcr.c b/arch/sh/boards/board-sh7785lcr.c
index 2c4771ee84cd..4c321d0da945 100644
--- a/arch/sh/boards/board-sh7785lcr.c
+++ b/arch/sh/boards/board-sh7785lcr.c
@@ -25,6 +25,7 @@
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/errno.h>
+#include <linux/gpio/machine.h>
#include <mach/sh7785lcr.h>
#include <cpu/sh7785.h>
#include <asm/heartbeat.h>
@@ -243,6 +244,14 @@ static struct resource i2c_resources[] = {
},
};
+static struct gpiod_lookup_table i2c_gpio_table = {
+ .dev_id = "i2c.0",
+ .table = {
+ GPIO_LOOKUP("pfc-sh7757", 0, "reset-gpios", GPIO_ACTIVE_LOW),
+ { },
+ },
+};
+
static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
.gpio = 0,
.i2c_clock_speed = I2C_PCA_CON_330kHz,
@@ -283,6 +292,7 @@ static int __init sh7785lcr_devices_setup(void)
i2c_device.num_resources = ARRAY_SIZE(i2c_proto_resources);
}
+ gpiod_add_lookup(&i2c_gpio_table);
return platform_add_devices(sh7785lcr_devices,
ARRAY_SIZE(sh7785lcr_devices));
}
--
2.13.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 2/6] i2c: pca-platform: correctly set algo_data.reset_chip
[not found] <20170630005408.23968-1-chris.packham@alliedtelesis.co.nz>
2017-06-30 0:54 ` [PATCH 1/6] sh: sh7785lcr: add GPIO lookup table for i2c controller reset Chris Packham
@ 2017-06-30 0:54 ` Chris Packham
2017-07-04 14:03 ` Wolfram Sang
2017-06-30 0:54 ` [PATCH 3/6] i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus Chris Packham
` (3 subsequent siblings)
5 siblings, 1 reply; 18+ messages in thread
From: Chris Packham @ 2017-06-30 0:54 UTC (permalink / raw)
To: wsa, andy.shevchenko, linux-i2c
Cc: ysato, linux-sh, Chris Packham, linux-kernel
When device tree support was added the setting of algo_data.reset_chip
was moved. There were two problems with this. The first being that
i2c_pca_pf_resetchip was only used if platform data was provided. The
second that it was unconditionally overridden with
i2c_pca_pf_dummyreset. Ensure that however the reset gpio is defined the
correct reset_chip function is used.
Fixes: commit 4cc7229daa46 ("i2c: pca-platform: switch to struct gpio_desc")
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
drivers/i2c/busses/i2c-pca-platform.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index 395eca0cbb1f..daccef6865e8 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -184,7 +184,6 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
if (ret == 0) {
i2c->gpio = gpio_to_desc(platform_data->gpio);
gpiod_direction_output(i2c->gpio, 0);
- i2c->algo_data.reset_chip = i2c_pca_pf_resetchip;
} else {
dev_warn(&pdev->dev, "Registering gpio failed!\n");
i2c->gpio = NULL;
@@ -205,7 +204,10 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
i2c->algo_data.data = i2c;
i2c->algo_data.wait_for_completion = i2c_pca_pf_waitforcompletion;
- i2c->algo_data.reset_chip = i2c_pca_pf_dummyreset;
+ if (i2c->gpio)
+ i2c->algo_data.reset_chip = i2c_pca_pf_resetchip;
+ else
+ i2c->algo_data.reset_chip = i2c_pca_pf_dummyreset;
switch (res->flags & IORESOURCE_MEM_TYPE_MASK) {
case IORESOURCE_MEM_32BIT:
--
2.13.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 3/6] i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus
[not found] <20170630005408.23968-1-chris.packham@alliedtelesis.co.nz>
2017-06-30 0:54 ` [PATCH 1/6] sh: sh7785lcr: add GPIO lookup table for i2c controller reset Chris Packham
2017-06-30 0:54 ` [PATCH 2/6] i2c: pca-platform: correctly set algo_data.reset_chip Chris Packham
@ 2017-06-30 0:54 ` Chris Packham
2017-06-30 8:40 ` Andy Shevchenko
2017-07-04 14:04 ` Wolfram Sang
2017-06-30 0:54 ` [PATCH 4/6] i2c: pca-platform: unconditionally use devm_gpiod_get_optional Chris Packham
` (2 subsequent siblings)
5 siblings, 2 replies; 18+ messages in thread
From: Chris Packham @ 2017-06-30 0:54 UTC (permalink / raw)
To: wsa, andy.shevchenko, linux-i2c
Cc: ysato, linux-sh, Chris Packham, linux-kernel
Rather than returning -ENODEV if i2c_pca_add_numbered_bus() fails,
propagate the error to aid debugging.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
drivers/i2c/busses/i2c-pca-platform.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index daccef6865e8..853a2abedb05 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -232,9 +232,9 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
return ret;
}
- if (i2c_pca_add_numbered_bus(&i2c->adap) < 0) {
- return -ENODEV;
- }
+ ret = i2c_pca_add_numbered_bus(&i2c->adap);
+ if (ret)
+ return ret;
platform_set_drvdata(pdev, i2c);
--
2.13.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 4/6] i2c: pca-platform: unconditionally use devm_gpiod_get_optional
[not found] <20170630005408.23968-1-chris.packham@alliedtelesis.co.nz>
` (2 preceding siblings ...)
2017-06-30 0:54 ` [PATCH 3/6] i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus Chris Packham
@ 2017-06-30 0:54 ` Chris Packham
2017-06-30 0:54 ` [PATCH 5/6] i2c: pca-platform: use device_property_read_u32 Chris Packham
2017-06-30 0:54 ` [PATCH 6/6] i2c: pca-platform: drop gpio from platform data Chris Packham
5 siblings, 0 replies; 18+ messages in thread
From: Chris Packham @ 2017-06-30 0:54 UTC (permalink / raw)
To: wsa, andy.shevchenko, linux-i2c
Cc: ysato, linux-sh, Chris Packham, linux-kernel
Allow for the reset-gpios property to be defined in the device tree
or via a GPIO lookup table.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
drivers/i2c/busses/i2c-pca-platform.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index 853a2abedb05..1e3c247de8f8 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -176,32 +176,19 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
if (platform_data) {
i2c->adap.timeout = platform_data->timeout;
i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed;
- if (gpio_is_valid(platform_data->gpio)) {
- ret = devm_gpio_request_one(&pdev->dev,
- platform_data->gpio,
- GPIOF_ACTIVE_LOW,
- i2c->adap.name);
- if (ret == 0) {
- i2c->gpio = gpio_to_desc(platform_data->gpio);
- gpiod_direction_output(i2c->gpio, 0);
- } else {
- dev_warn(&pdev->dev, "Registering gpio failed!\n");
- i2c->gpio = NULL;
- }
- }
} else if (np) {
i2c->adap.timeout = HZ;
- i2c->gpio = devm_gpiod_get_optional(&pdev->dev, "reset-gpios", GPIOD_OUT_LOW);
- if (IS_ERR(i2c->gpio))
- return PTR_ERR(i2c->gpio);
of_property_read_u32_index(np, "clock-frequency", 0,
&i2c->algo_data.i2c_clock);
} else {
i2c->adap.timeout = HZ;
i2c->algo_data.i2c_clock = 59000;
- i2c->gpio = NULL;
}
+ i2c->gpio = devm_gpiod_get_optional(&pdev->dev, "reset-gpios", GPIOD_OUT_LOW);
+ if (IS_ERR(i2c->gpio))
+ return PTR_ERR(i2c->gpio);
+
i2c->algo_data.data = i2c;
i2c->algo_data.wait_for_completion = i2c_pca_pf_waitforcompletion;
if (i2c->gpio)
--
2.13.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 5/6] i2c: pca-platform: use device_property_read_u32
[not found] <20170630005408.23968-1-chris.packham@alliedtelesis.co.nz>
` (3 preceding siblings ...)
2017-06-30 0:54 ` [PATCH 4/6] i2c: pca-platform: unconditionally use devm_gpiod_get_optional Chris Packham
@ 2017-06-30 0:54 ` Chris Packham
2017-06-30 8:44 ` Andy Shevchenko
2017-06-30 0:54 ` [PATCH 6/6] i2c: pca-platform: drop gpio from platform data Chris Packham
5 siblings, 1 reply; 18+ messages in thread
From: Chris Packham @ 2017-06-30 0:54 UTC (permalink / raw)
To: wsa, andy.shevchenko, linux-i2c
Cc: ysato, linux-sh, Chris Packham, linux-kernel
Use device_property_read_u32 instead of of_property_read_u32_index to
lookup the "clock-frequency" property.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
drivers/i2c/busses/i2c-pca-platform.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index 1e3c247de8f8..80420f753a87 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -176,13 +176,12 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
if (platform_data) {
i2c->adap.timeout = platform_data->timeout;
i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed;
- } else if (np) {
- i2c->adap.timeout = HZ;
- of_property_read_u32_index(np, "clock-frequency", 0,
- &i2c->algo_data.i2c_clock);
} else {
i2c->adap.timeout = HZ;
- i2c->algo_data.i2c_clock = 59000;
+ ret = device_property_read_u32(&pdev->dev, "clock-frequency",
+ &i2c->algo_data.i2c_clock);
+ if (ret)
+ i2c->algo_data.i2c_clock = 59000;
}
i2c->gpio = devm_gpiod_get_optional(&pdev->dev, "reset-gpios", GPIOD_OUT_LOW);
--
2.13.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 6/6] i2c: pca-platform: drop gpio from platform data
[not found] <20170630005408.23968-1-chris.packham@alliedtelesis.co.nz>
` (4 preceding siblings ...)
2017-06-30 0:54 ` [PATCH 5/6] i2c: pca-platform: use device_property_read_u32 Chris Packham
@ 2017-06-30 0:54 ` Chris Packham
5 siblings, 0 replies; 18+ messages in thread
From: Chris Packham @ 2017-06-30 0:54 UTC (permalink / raw)
To: wsa, andy.shevchenko, linux-i2c
Cc: ysato, linux-sh, Chris Packham, Steven Miao, Rich Felker,
adi-buildroot-devel, linux-kernel
Now that the i2c-pca-plaform driver is using the device managed API for
gpios there is no need for the reset gpio to be specified via
i2c_pca9564_pf_platform_data.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
arch/blackfin/mach-bf561/boards/acvilon.c | 1 -
arch/sh/boards/board-sh7785lcr.c | 1 -
include/linux/i2c-pca-platform.h | 3 ---
3 files changed, 5 deletions(-)
diff --git a/arch/blackfin/mach-bf561/boards/acvilon.c b/arch/blackfin/mach-bf561/boards/acvilon.c
index 37f8f25a1347..192404318a36 100644
--- a/arch/blackfin/mach-bf561/boards/acvilon.c
+++ b/arch/blackfin/mach-bf561/boards/acvilon.c
@@ -112,7 +112,6 @@ static struct resource bfin_i2c_pca_resources[] = {
};
struct i2c_pca9564_pf_platform_data pca9564_platform_data = {
- .gpio = -1,
.i2c_clock_speed = 330000,
.timeout = HZ,
};
diff --git a/arch/sh/boards/board-sh7785lcr.c b/arch/sh/boards/board-sh7785lcr.c
index 4c321d0da945..1170fc536db7 100644
--- a/arch/sh/boards/board-sh7785lcr.c
+++ b/arch/sh/boards/board-sh7785lcr.c
@@ -253,7 +253,6 @@ static struct gpiod_lookup_table i2c_gpio_table = {
};
static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
- .gpio = 0,
.i2c_clock_speed = I2C_PCA_CON_330kHz,
.timeout = HZ,
};
diff --git a/include/linux/i2c-pca-platform.h b/include/linux/i2c-pca-platform.h
index aba33759dec4..6331eaef9352 100644
--- a/include/linux/i2c-pca-platform.h
+++ b/include/linux/i2c-pca-platform.h
@@ -2,9 +2,6 @@
#define I2C_PCA9564_PLATFORM_H
struct i2c_pca9564_pf_platform_data {
- int gpio; /* pin to reset chip. driver will work when
- * not supplied (negative value), but it
- * cannot exit some error conditions then */
int i2c_clock_speed; /* values are defined in linux/i2c-algo-pca.h */
int timeout; /* timeout in jiffies */
};
--
2.13.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 3/6] i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus
2017-06-30 0:54 ` [PATCH 3/6] i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus Chris Packham
@ 2017-06-30 8:40 ` Andy Shevchenko
2017-06-30 9:01 ` Wolfram Sang
2017-07-02 21:30 ` Chris Packham
2017-07-04 14:04 ` Wolfram Sang
1 sibling, 2 replies; 18+ messages in thread
From: Andy Shevchenko @ 2017-06-30 8:40 UTC (permalink / raw)
To: Chris Packham
Cc: Wolfram Sang, linux-i2c, Yoshinori Sato, Linux-SH, linux-kernel
On Fri, Jun 30, 2017 at 3:54 AM, Chris Packham
<chris.packham@alliedtelesis.co.nz> wrote:
> Rather than returning -ENODEV if i2c_pca_add_numbered_bus() fails,
> propagate the error to aid debugging.
>
+ Suggested-by ?
You or Wolfram can use below if you agree on it (I'm fine either way):
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> drivers/i2c/busses/i2c-pca-platform.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
> index daccef6865e8..853a2abedb05 100644
> --- a/drivers/i2c/busses/i2c-pca-platform.c
> +++ b/drivers/i2c/busses/i2c-pca-platform.c
> @@ -232,9 +232,9 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
> return ret;
> }
>
> - if (i2c_pca_add_numbered_bus(&i2c->adap) < 0) {
> - return -ENODEV;
> - }
> + ret = i2c_pca_add_numbered_bus(&i2c->adap);
> + if (ret)
> + return ret;
>
> platform_set_drvdata(pdev, i2c);
>
> --
> 2.13.0
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/6] i2c: pca-platform: use device_property_read_u32
2017-06-30 0:54 ` [PATCH 5/6] i2c: pca-platform: use device_property_read_u32 Chris Packham
@ 2017-06-30 8:44 ` Andy Shevchenko
2017-06-30 9:03 ` Wolfram Sang
0 siblings, 1 reply; 18+ messages in thread
From: Andy Shevchenko @ 2017-06-30 8:44 UTC (permalink / raw)
To: Chris Packham
Cc: Wolfram Sang, linux-i2c, Yoshinori Sato, Linux-SH, linux-kernel
On Fri, Jun 30, 2017 at 3:54 AM, Chris Packham
<chris.packham@alliedtelesis.co.nz> wrote:
> Use device_property_read_u32 instead of of_property_read_u32_index to
> lookup the "clock-frequency" property.
My comments below.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> drivers/i2c/busses/i2c-pca-platform.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
> index 1e3c247de8f8..80420f753a87 100644
> --- a/drivers/i2c/busses/i2c-pca-platform.c
> +++ b/drivers/i2c/busses/i2c-pca-platform.c
> @@ -176,13 +176,12 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
> if (platform_data) {
> i2c->adap.timeout = platform_data->timeout;
> i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed;
> } else {
> i2c->adap.timeout = HZ;
> - i2c->algo_data.i2c_clock = 59000;
> + ret = device_property_read_u32(&pdev->dev, "clock-frequency",
> + &i2c->algo_data.i2c_clock);
> + if (ret)
> + i2c->algo_data.i2c_clock = 59000;
My idea is to get rid of legacy platform data completely.
That's why I suggested device_* in the first place.
In similar way like you did with GPIO lookup table, you may use
PROPERTY_ENTRY*() macros in the board files.
Does it make sense?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/6] i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus
2017-06-30 8:40 ` Andy Shevchenko
@ 2017-06-30 9:01 ` Wolfram Sang
2017-07-02 21:30 ` Chris Packham
1 sibling, 0 replies; 18+ messages in thread
From: Wolfram Sang @ 2017-06-30 9:01 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Chris Packham, linux-i2c, Yoshinori Sato, Linux-SH, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 468 bytes --]
On Fri, Jun 30, 2017 at 11:40:51AM +0300, Andy Shevchenko wrote:
> On Fri, Jun 30, 2017 at 3:54 AM, Chris Packham
> <chris.packham@alliedtelesis.co.nz> wrote:
> > Rather than returning -ENODEV if i2c_pca_add_numbered_bus() fails,
> > propagate the error to aid debugging.
> >
>
> + Suggested-by ?
>
> You or Wolfram can use below if you agree on it (I'm fine either way):
>
> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
I'll pick it.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/6] i2c: pca-platform: use device_property_read_u32
2017-06-30 8:44 ` Andy Shevchenko
@ 2017-06-30 9:03 ` Wolfram Sang
2017-06-30 10:56 ` Andy Shevchenko
0 siblings, 1 reply; 18+ messages in thread
From: Wolfram Sang @ 2017-06-30 9:03 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Chris Packham, linux-i2c, Yoshinori Sato, Linux-SH, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 670 bytes --]
> > - i2c->algo_data.i2c_clock = 59000;
> > + ret = device_property_read_u32(&pdev->dev, "clock-frequency",
> > + &i2c->algo_data.i2c_clock);
> > + if (ret)
> > + i2c->algo_data.i2c_clock = 59000;
>
> My idea is to get rid of legacy platform data completely.
> That's why I suggested device_* in the first place.
>
> In similar way like you did with GPIO lookup table, you may use
> PROPERTY_ENTRY*() macros in the board files.
>
> Does it make sense?
Frankly, I am not a big fan of converting board files if we cannot test
the changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/6] i2c: pca-platform: use device_property_read_u32
2017-06-30 9:03 ` Wolfram Sang
@ 2017-06-30 10:56 ` Andy Shevchenko
2017-07-02 21:51 ` Chris Packham
0 siblings, 1 reply; 18+ messages in thread
From: Andy Shevchenko @ 2017-06-30 10:56 UTC (permalink / raw)
To: Wolfram Sang
Cc: Chris Packham, linux-i2c, Yoshinori Sato, Linux-SH, linux-kernel
On Fri, Jun 30, 2017 at 12:03 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
>
>> > - i2c->algo_data.i2c_clock = 59000;
>> > + ret = device_property_read_u32(&pdev->dev, "clock-frequency",
>> > + &i2c->algo_data.i2c_clock);
>> > + if (ret)
>> > + i2c->algo_data.i2c_clock = 59000;
>>
>> My idea is to get rid of legacy platform data completely.
>> That's why I suggested device_* in the first place.
>>
>> In similar way like you did with GPIO lookup table, you may use
>> PROPERTY_ENTRY*() macros in the board files.
>>
>> Does it make sense?
>
> Frankly, I am not a big fan of converting board files if we cannot test
> the changes.
So, if no one is using that old boards, should we really take care
more than just compile test?
P.S. Legacy platform data makes a burden of development nowadays.
Built-in device properties API (as a part of Unified Device
Properties) is exactly for getting rid of legacy stuff and make things
much cleaner.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/6] sh: sh7785lcr: add GPIO lookup table for i2c controller reset
2017-06-30 0:54 ` [PATCH 1/6] sh: sh7785lcr: add GPIO lookup table for i2c controller reset Chris Packham
@ 2017-07-02 16:47 ` kbuild test robot
2017-07-02 17:15 ` Geert Uytterhoeven
0 siblings, 1 reply; 18+ messages in thread
From: kbuild test robot @ 2017-07-02 16:47 UTC (permalink / raw)
To: Chris Packham
Cc: kbuild-all, wsa, andy.shevchenko, linux-i2c, ysato, linux-sh,
Chris Packham, Rich Felker, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1711 bytes --]
Hi Chris,
[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on v4.12-rc7 next-20170630]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Chris-Packham/sh-sh7785lcr-add-GPIO-lookup-table-for-i2c-controller-reset/20170702-214426
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: sh-sh7785lcr_32bit_defconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sh
All errors (new ones prefixed by >>):
arch/sh/boards/board-sh7785lcr.c: In function 'sh7785lcr_devices_setup':
>> arch/sh/boards/board-sh7785lcr.c:295:2: error: implicit declaration of function 'gpiod_add_lookup' [-Werror=implicit-function-declaration]
gpiod_add_lookup(&i2c_gpio_table);
^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/gpiod_add_lookup +295 arch/sh/boards/board-sh7785lcr.c
289
290 if (mach_is_sh7785lcr_pt()) {
291 i2c_device.resource = i2c_proto_resources;
292 i2c_device.num_resources = ARRAY_SIZE(i2c_proto_resources);
293 }
294
> 295 gpiod_add_lookup(&i2c_gpio_table);
296 return platform_add_devices(sh7785lcr_devices,
297 ARRAY_SIZE(sh7785lcr_devices));
298 }
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 16934 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/6] sh: sh7785lcr: add GPIO lookup table for i2c controller reset
2017-07-02 16:47 ` kbuild test robot
@ 2017-07-02 17:15 ` Geert Uytterhoeven
0 siblings, 0 replies; 18+ messages in thread
From: Geert Uytterhoeven @ 2017-07-02 17:15 UTC (permalink / raw)
To: Chris Packham
Cc: kbuild-all, kbuild test robot, Wolfram Sang, Andy Shevchenko,
Linux I2C, Yoshinori Sato, Linux-sh list, Rich Felker,
linux-kernel
Hi Chris,
On Sun, Jul 2, 2017 at 6:47 PM, kbuild test robot <lkp@intel.com> wrote:
> [auto build test ERROR on wsa/i2c/for-next]
> [also build test ERROR on v4.12-rc7 next-20170630]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url: https://github.com/0day-ci/linux/commits/Chris-Packham/sh-sh7785lcr-add-GPIO-lookup-table-for-i2c-controller-reset/20170702-214426
> base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
> config: sh-sh7785lcr_32bit_defconfig (attached as .config)
> compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
> wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=sh
>
> All errors (new ones prefixed by >>):
>
> arch/sh/boards/board-sh7785lcr.c: In function 'sh7785lcr_devices_setup':
>>> arch/sh/boards/board-sh7785lcr.c:295:2: error: implicit declaration of function 'gpiod_add_lookup' [-Werror=implicit-function-declaration]
> gpiod_add_lookup(&i2c_gpio_table);
It's called gpiod_add_lookup_table()
https://www.kernel.org/pub/tools/crosstool/ is your friend...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/6] i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus
2017-06-30 8:40 ` Andy Shevchenko
2017-06-30 9:01 ` Wolfram Sang
@ 2017-07-02 21:30 ` Chris Packham
1 sibling, 0 replies; 18+ messages in thread
From: Chris Packham @ 2017-07-02 21:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Wolfram Sang, linux-i2c, Yoshinori Sato, Linux-SH, linux-kernel
On 30/06/17 20:40, Andy Shevchenko wrote:
> On Fri, Jun 30, 2017 at 3:54 AM, Chris Packham
> <chris.packham@alliedtelesis.co.nz> wrote:
>> Rather than returning -ENODEV if i2c_pca_add_numbered_bus() fails,
>> propagate the error to aid debugging.
>>
>
> + Suggested-by ?
>
> You or Wolfram can use below if you agree on it (I'm fine either way):
>
> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
I'll include it (and the Reviewed-by) in v2 if there is one.
>> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
>
>> ---
>> drivers/i2c/busses/i2c-pca-platform.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
>> index daccef6865e8..853a2abedb05 100644
>> --- a/drivers/i2c/busses/i2c-pca-platform.c
>> +++ b/drivers/i2c/busses/i2c-pca-platform.c
>> @@ -232,9 +232,9 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
>> return ret;
>> }
>>
>> - if (i2c_pca_add_numbered_bus(&i2c->adap) < 0) {
>> - return -ENODEV;
>> - }
>> + ret = i2c_pca_add_numbered_bus(&i2c->adap);
>> + if (ret)
>> + return ret;
>>
>> platform_set_drvdata(pdev, i2c);
>>
>> --
>> 2.13.0
>>
>
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/6] i2c: pca-platform: use device_property_read_u32
2017-06-30 10:56 ` Andy Shevchenko
@ 2017-07-02 21:51 ` Chris Packham
2017-07-04 14:07 ` Wolfram Sang
0 siblings, 1 reply; 18+ messages in thread
From: Chris Packham @ 2017-07-02 21:51 UTC (permalink / raw)
To: Andy Shevchenko, Wolfram Sang
Cc: linux-i2c, Yoshinori Sato, Linux-SH, linux-kernel
On 30/06/17 22:56, Andy Shevchenko wrote:
> On Fri, Jun 30, 2017 at 12:03 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
>>
>>>> - i2c->algo_data.i2c_clock = 59000;
>>>> + ret = device_property_read_u32(&pdev->dev, "clock-frequency",
>>>> + &i2c->algo_data.i2c_clock);
>>>> + if (ret)
>>>> + i2c->algo_data.i2c_clock = 59000;
>>>
>>> My idea is to get rid of legacy platform data completely.
>>> That's why I suggested device_* in the first place.
>>>
>>> In similar way like you did with GPIO lookup table, you may use
>>> PROPERTY_ENTRY*() macros in the board files.
>>>
>>> Does it make sense?
>>
>> Frankly, I am not a big fan of converting board files if we cannot test
>> the changes.
>
> So, if no one is using that old boards, should we really take care
> more than just compile test?
>
> P.S. Legacy platform data makes a burden of development nowadays.
> Built-in device properties API (as a part of Unified Device
> Properties) is exactly for getting rid of legacy stuff and make things
> much cleaner.
We could probably go with an approach of making the device properties
the default which would suit the new style and leave the platform_data
to override things if it is present.
If/when the older platforms go away we can drop struct
i2c_pca9564_pf_platform_data.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/6] i2c: pca-platform: correctly set algo_data.reset_chip
2017-06-30 0:54 ` [PATCH 2/6] i2c: pca-platform: correctly set algo_data.reset_chip Chris Packham
@ 2017-07-04 14:03 ` Wolfram Sang
0 siblings, 0 replies; 18+ messages in thread
From: Wolfram Sang @ 2017-07-04 14:03 UTC (permalink / raw)
To: Chris Packham; +Cc: andy.shevchenko, linux-i2c, ysato, linux-sh, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 696 bytes --]
On Fri, Jun 30, 2017 at 12:54:04PM +1200, Chris Packham wrote:
> When device tree support was added the setting of algo_data.reset_chip
> was moved. There were two problems with this. The first being that
> i2c_pca_pf_resetchip was only used if platform data was provided. The
> second that it was unconditionally overridden with
> i2c_pca_pf_dummyreset. Ensure that however the reset gpio is defined the
> correct reset_chip function is used.
>
> Fixes: commit 4cc7229daa46 ("i2c: pca-platform: switch to struct gpio_desc")
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
It's a bugfix, so I'll include it in this merge window.
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/6] i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus
2017-06-30 0:54 ` [PATCH 3/6] i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus Chris Packham
2017-06-30 8:40 ` Andy Shevchenko
@ 2017-07-04 14:04 ` Wolfram Sang
1 sibling, 0 replies; 18+ messages in thread
From: Wolfram Sang @ 2017-07-04 14:04 UTC (permalink / raw)
To: Chris Packham; +Cc: andy.shevchenko, linux-i2c, ysato, linux-sh, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 341 bytes --]
On Fri, Jun 30, 2017 at 12:54:05PM +1200, Chris Packham wrote:
> Rather than returning -ENODEV if i2c_pca_add_numbered_bus() fails,
> propagate the error to aid debugging.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Easy one and nice to have. Will be in this merge window.
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/6] i2c: pca-platform: use device_property_read_u32
2017-07-02 21:51 ` Chris Packham
@ 2017-07-04 14:07 ` Wolfram Sang
0 siblings, 0 replies; 18+ messages in thread
From: Wolfram Sang @ 2017-07-04 14:07 UTC (permalink / raw)
To: Chris Packham
Cc: Andy Shevchenko, linux-i2c, Yoshinori Sato, Linux-SH, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 870 bytes --]
> >> Frankly, I am not a big fan of converting board files if we cannot test
> >> the changes.
> >
> > So, if no one is using that old boards, should we really take care
> > more than just compile test?
> >
> > P.S. Legacy platform data makes a burden of development nowadays.
> > Built-in device properties API (as a part of Unified Device
> > Properties) is exactly for getting rid of legacy stuff and make things
> > much cleaner.
>
> We could probably go with an approach of making the device properties
> the default which would suit the new style and leave the platform_data
> to override things if it is present.
>
> If/when the older platforms go away we can drop struct
> i2c_pca9564_pf_platform_data.
I don't have a super strong opinion, so we can discuss this for 4.14.
For 4.13, I picked the two easy patches already. Thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2017-07-04 14:07 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20170630005408.23968-1-chris.packham@alliedtelesis.co.nz>
2017-06-30 0:54 ` [PATCH 1/6] sh: sh7785lcr: add GPIO lookup table for i2c controller reset Chris Packham
2017-07-02 16:47 ` kbuild test robot
2017-07-02 17:15 ` Geert Uytterhoeven
2017-06-30 0:54 ` [PATCH 2/6] i2c: pca-platform: correctly set algo_data.reset_chip Chris Packham
2017-07-04 14:03 ` Wolfram Sang
2017-06-30 0:54 ` [PATCH 3/6] i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus Chris Packham
2017-06-30 8:40 ` Andy Shevchenko
2017-06-30 9:01 ` Wolfram Sang
2017-07-02 21:30 ` Chris Packham
2017-07-04 14:04 ` Wolfram Sang
2017-06-30 0:54 ` [PATCH 4/6] i2c: pca-platform: unconditionally use devm_gpiod_get_optional Chris Packham
2017-06-30 0:54 ` [PATCH 5/6] i2c: pca-platform: use device_property_read_u32 Chris Packham
2017-06-30 8:44 ` Andy Shevchenko
2017-06-30 9:03 ` Wolfram Sang
2017-06-30 10:56 ` Andy Shevchenko
2017-07-02 21:51 ` Chris Packham
2017-07-04 14:07 ` Wolfram Sang
2017-06-30 0:54 ` [PATCH 6/6] i2c: pca-platform: drop gpio from platform data Chris Packham
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).