* [PATCH] i2c: mpc: Define unique I2C adapter names
@ 2013-07-10 19:03 Guenter Roeck
[not found] ` <1373483001-24951-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2013-07-10 19:03 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
Cc: Wolfram Sang, Jean Delvare, Guenter Roeck
The I2C adapters on Freescale MPC107/824x/85xx/512x/52xx/83xx/86xx all
have the same name "MPC adapter". Since I2C adapter numbers can change
across reboots and even after loading/unloading an I2C bus master driver,
adapter names have to be used to identify adapters and thus should be
unique and well defined. Since this is not the case with this driver,
it is difficult if not impossible to identify a specific adapter from
user space on affected platforms.
To remedy the problem, use the adapter memory address as part of the
adapter name.
With this patch, adapter names are:
On P2020:
MPC adapter at 0xfff703000
MPC adapter at 0xfff703100
On P5040:
MPC adapter at 0xffe118000
MPC adapter at 0xffe118100
MPC adapter at 0xffe119000
MPC adapter at 0xffe119100
Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
---
drivers/i2c/busses/i2c-mpc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 7607dc0..99acf63 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -609,7 +609,6 @@ static const struct i2c_algorithm mpc_algo = {
static struct i2c_adapter mpc_ops = {
.owner = THIS_MODULE,
- .name = "MPC adapter",
.algo = &mpc_algo,
.timeout = HZ,
};
@@ -623,6 +622,7 @@ static int fsl_i2c_probe(struct platform_device *op)
u32 clock = MPC_I2C_CLOCK_LEGACY;
int result = 0;
int plen;
+ struct resource res;
match = of_match_device(mpc_i2c_of_match, &op->dev);
if (!match)
@@ -682,6 +682,9 @@ static int fsl_i2c_probe(struct platform_device *op)
platform_set_drvdata(op, i2c);
i2c->adap = mpc_ops;
+ of_address_to_resource(op->dev.of_node, 0, &res);
+ scnprintf(i2c->adap.name, sizeof(i2c->adap.name),
+ "MPC adapter at 0x%llx", (unsigned long long)res.start);
i2c_set_adapdata(&i2c->adap, i2c);
i2c->adap.dev.parent = &op->dev;
i2c->adap.dev.of_node = of_node_get(op->dev.of_node);
--
1.7.9.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: mpc: Define unique I2C adapter names
[not found] ` <1373483001-24951-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
@ 2013-07-10 19:30 ` Jean Delvare
2013-07-18 21:34 ` Guenter Roeck
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2013-07-10 19:30 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang
Hi Guenter,
On Wed, 10 Jul 2013 12:03:21 -0700, Guenter Roeck wrote:
> The I2C adapters on Freescale MPC107/824x/85xx/512x/52xx/83xx/86xx all
> have the same name "MPC adapter". Since I2C adapter numbers can change
> across reboots and even after loading/unloading an I2C bus master driver,
> adapter names have to be used to identify adapters and thus should be
> unique and well defined. Since this is not the case with this driver,
> it is difficult if not impossible to identify a specific adapter from
> user space on affected platforms.
>
> To remedy the problem, use the adapter memory address as part of the
> adapter name.
>
> With this patch, adapter names are:
> On P2020:
> MPC adapter at 0xfff703000
> MPC adapter at 0xfff703100
>
> On P5040:
> MPC adapter at 0xffe118000
> MPC adapter at 0xffe118100
> MPC adapter at 0xffe119000
> MPC adapter at 0xffe119100
>
> Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
> ---
> drivers/i2c/busses/i2c-mpc.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 7607dc0..99acf63 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -609,7 +609,6 @@ static const struct i2c_algorithm mpc_algo = {
>
> static struct i2c_adapter mpc_ops = {
> .owner = THIS_MODULE,
> - .name = "MPC adapter",
> .algo = &mpc_algo,
> .timeout = HZ,
> };
> @@ -623,6 +622,7 @@ static int fsl_i2c_probe(struct platform_device *op)
> u32 clock = MPC_I2C_CLOCK_LEGACY;
> int result = 0;
> int plen;
> + struct resource res;
>
> match = of_match_device(mpc_i2c_of_match, &op->dev);
> if (!match)
> @@ -682,6 +682,9 @@ static int fsl_i2c_probe(struct platform_device *op)
> platform_set_drvdata(op, i2c);
>
> i2c->adap = mpc_ops;
> + of_address_to_resource(op->dev.of_node, 0, &res);
> + scnprintf(i2c->adap.name, sizeof(i2c->adap.name),
> + "MPC adapter at 0x%llx", (unsigned long long)res.start);
> i2c_set_adapdata(&i2c->adap, i2c);
> i2c->adap.dev.parent = &op->dev;
> i2c->adap.dev.of_node = of_node_get(op->dev.of_node);
I'm not familiar with the i2c-mpc driver but the fix looks good to me.
Acked-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
--
Jean Delvare
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: mpc: Define unique I2C adapter names
[not found] ` <1373483001-24951-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-07-10 19:30 ` Jean Delvare
@ 2013-07-18 21:34 ` Guenter Roeck
2013-08-03 14:31 ` Guenter Roeck
2013-08-07 15:34 ` Wolfram Sang
3 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2013-07-18 21:34 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA; +Cc: Wolfram Sang, Jean Delvare
On Wed, Jul 10, 2013 at 12:03:21PM -0700, Guenter Roeck wrote:
> The I2C adapters on Freescale MPC107/824x/85xx/512x/52xx/83xx/86xx all
> have the same name "MPC adapter". Since I2C adapter numbers can change
> across reboots and even after loading/unloading an I2C bus master driver,
> adapter names have to be used to identify adapters and thus should be
> unique and well defined. Since this is not the case with this driver,
> it is difficult if not impossible to identify a specific adapter from
> user space on affected platforms.
>
> To remedy the problem, use the adapter memory address as part of the
> adapter name.
>
ping ... any comments on this patch ?
Thanks,
Guenter
> With this patch, adapter names are:
> On P2020:
> MPC adapter at 0xfff703000
> MPC adapter at 0xfff703100
>
> On P5040:
> MPC adapter at 0xffe118000
> MPC adapter at 0xffe118100
> MPC adapter at 0xffe119000
> MPC adapter at 0xffe119100
>
> Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
> ---
> drivers/i2c/busses/i2c-mpc.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 7607dc0..99acf63 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -609,7 +609,6 @@ static const struct i2c_algorithm mpc_algo = {
>
> static struct i2c_adapter mpc_ops = {
> .owner = THIS_MODULE,
> - .name = "MPC adapter",
> .algo = &mpc_algo,
> .timeout = HZ,
> };
> @@ -623,6 +622,7 @@ static int fsl_i2c_probe(struct platform_device *op)
> u32 clock = MPC_I2C_CLOCK_LEGACY;
> int result = 0;
> int plen;
> + struct resource res;
>
> match = of_match_device(mpc_i2c_of_match, &op->dev);
> if (!match)
> @@ -682,6 +682,9 @@ static int fsl_i2c_probe(struct platform_device *op)
> platform_set_drvdata(op, i2c);
>
> i2c->adap = mpc_ops;
> + of_address_to_resource(op->dev.of_node, 0, &res);
> + scnprintf(i2c->adap.name, sizeof(i2c->adap.name),
> + "MPC adapter at 0x%llx", (unsigned long long)res.start);
> i2c_set_adapdata(&i2c->adap, i2c);
> i2c->adap.dev.parent = &op->dev;
> i2c->adap.dev.of_node = of_node_get(op->dev.of_node);
> --
> 1.7.9.7
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: mpc: Define unique I2C adapter names
[not found] ` <1373483001-24951-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-07-10 19:30 ` Jean Delvare
2013-07-18 21:34 ` Guenter Roeck
@ 2013-08-03 14:31 ` Guenter Roeck
2013-08-07 15:34 ` Wolfram Sang
3 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2013-08-03 14:31 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang, Jean Delvare
ping ... any comments/feedback on this patch ?
Thanks,
Guenter
On 07/10/2013 12:03 PM, Guenter Roeck wrote:
> The I2C adapters on Freescale MPC107/824x/85xx/512x/52xx/83xx/86xx all
> have the same name "MPC adapter". Since I2C adapter numbers can change
> across reboots and even after loading/unloading an I2C bus master driver,
> adapter names have to be used to identify adapters and thus should be
> unique and well defined. Since this is not the case with this driver,
> it is difficult if not impossible to identify a specific adapter from
> user space on affected platforms.
>
> To remedy the problem, use the adapter memory address as part of the
> adapter name.
>
> With this patch, adapter names are:
> On P2020:
> MPC adapter at 0xfff703000
> MPC adapter at 0xfff703100
>
> On P5040:
> MPC adapter at 0xffe118000
> MPC adapter at 0xffe118100
> MPC adapter at 0xffe119000
> MPC adapter at 0xffe119100
>
> Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
> ---
> drivers/i2c/busses/i2c-mpc.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 7607dc0..99acf63 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -609,7 +609,6 @@ static const struct i2c_algorithm mpc_algo = {
>
> static struct i2c_adapter mpc_ops = {
> .owner = THIS_MODULE,
> - .name = "MPC adapter",
> .algo = &mpc_algo,
> .timeout = HZ,
> };
> @@ -623,6 +622,7 @@ static int fsl_i2c_probe(struct platform_device *op)
> u32 clock = MPC_I2C_CLOCK_LEGACY;
> int result = 0;
> int plen;
> + struct resource res;
>
> match = of_match_device(mpc_i2c_of_match, &op->dev);
> if (!match)
> @@ -682,6 +682,9 @@ static int fsl_i2c_probe(struct platform_device *op)
> platform_set_drvdata(op, i2c);
>
> i2c->adap = mpc_ops;
> + of_address_to_resource(op->dev.of_node, 0, &res);
> + scnprintf(i2c->adap.name, sizeof(i2c->adap.name),
> + "MPC adapter at 0x%llx", (unsigned long long)res.start);
> i2c_set_adapdata(&i2c->adap, i2c);
> i2c->adap.dev.parent = &op->dev;
> i2c->adap.dev.of_node = of_node_get(op->dev.of_node);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: mpc: Define unique I2C adapter names
[not found] ` <1373483001-24951-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
` (2 preceding siblings ...)
2013-08-03 14:31 ` Guenter Roeck
@ 2013-08-07 15:34 ` Wolfram Sang
3 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2013-08-07 15:34 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Jean Delvare
[-- Attachment #1: Type: text/plain, Size: 1009 bytes --]
On Wed, Jul 10, 2013 at 12:03:21PM -0700, Guenter Roeck wrote:
> The I2C adapters on Freescale MPC107/824x/85xx/512x/52xx/83xx/86xx all
> have the same name "MPC adapter". Since I2C adapter numbers can change
> across reboots and even after loading/unloading an I2C bus master driver,
> adapter names have to be used to identify adapters and thus should be
> unique and well defined. Since this is not the case with this driver,
> it is difficult if not impossible to identify a specific adapter from
> user space on affected platforms.
>
> To remedy the problem, use the adapter memory address as part of the
> adapter name.
>
> With this patch, adapter names are:
> On P2020:
> MPC adapter at 0xfff703000
> MPC adapter at 0xfff703100
>
> On P5040:
> MPC adapter at 0xffe118000
> MPC adapter at 0xffe118100
> MPC adapter at 0xffe119000
> MPC adapter at 0xffe119100
>
> Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Applied to for-next, thanks!
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-07 15:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-10 19:03 [PATCH] i2c: mpc: Define unique I2C adapter names Guenter Roeck
[not found] ` <1373483001-24951-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-07-10 19:30 ` Jean Delvare
2013-07-18 21:34 ` Guenter Roeck
2013-08-03 14:31 ` Guenter Roeck
2013-08-07 15:34 ` Wolfram Sang
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).