* [PATCH] Add static bus numbering support to i2c-versatile
@ 2009-02-09 18:03 Catalin Marinas
[not found] ` <20090209180338.27227.77460.stgit-hhZApKj8DF/YkXV2EHHjLW3o5bpOHsLO@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Catalin Marinas @ 2009-02-09 18:03 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA; +Cc: Russell King
If dev->id is not -1, the platform code may use static bus numbering
rather than dynamic. The patch also changes the i2c_versatile_init to a
subsys_initcall rather than module_init to make sure it is initialised
before the I2C devices initialisation.
Signed-off-by: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org>
Cc: Russell King <rmk-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
---
drivers/i2c/busses/i2c-versatile.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c
index 4678bab..15b5e8a 100644
--- a/drivers/i2c/busses/i2c-versatile.c
+++ b/drivers/i2c/busses/i2c-versatile.c
@@ -96,13 +96,20 @@ static int i2c_versatile_probe(struct platform_device *dev)
writel(SCL | SDA, i2c->base + I2C_CONTROLS);
i2c->adap.owner = THIS_MODULE;
+ if (dev->id >= 0)
+ i2c->adap.nr = dev->id;
strlcpy(i2c->adap.name, "Versatile I2C adapter", sizeof(i2c->adap.name));
i2c->adap.algo_data = &i2c->algo;
i2c->adap.dev.parent = &dev->dev;
i2c->algo = i2c_versatile_algo;
i2c->algo.data = i2c;
- ret = i2c_bit_add_bus(&i2c->adap);
+ if (dev->id >= 0)
+ /* static bus numbering */
+ ret = i2c_bit_add_numbered_bus(&i2c->adap);
+ else
+ /* dynamic bus numbering */
+ ret = i2c_bit_add_bus(&i2c->adap);
if (ret >= 0) {
platform_set_drvdata(dev, i2c);
return 0;
@@ -146,7 +153,7 @@ static void __exit i2c_versatile_exit(void)
platform_driver_unregister(&i2c_versatile_driver);
}
-module_init(i2c_versatile_init);
+subsys_initcall(i2c_versatile_init);
module_exit(i2c_versatile_exit);
MODULE_DESCRIPTION("ARM Versatile I2C bus driver");
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <20090209180338.27227.77460.stgit-hhZApKj8DF/YkXV2EHHjLW3o5bpOHsLO@public.gmane.org>]
* Re: [PATCH] Add static bus numbering support to i2c-versatile [not found] ` <20090209180338.27227.77460.stgit-hhZApKj8DF/YkXV2EHHjLW3o5bpOHsLO@public.gmane.org> @ 2009-02-09 19:30 ` Jean Delvare [not found] ` <20090209203045.0c7a32a4-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Jean Delvare @ 2009-02-09 19:30 UTC (permalink / raw) To: Catalin Marinas; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Russell King On Mon, 09 Feb 2009 18:03:38 +0000, Catalin Marinas wrote: > If dev->id is not -1, the platform code may use static bus numbering > rather than dynamic. The patch also changes the i2c_versatile_init to a > subsys_initcall rather than module_init to make sure it is initialised > before the I2C devices initialisation. > > Signed-off-by: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org> > Cc: Russell King <rmk-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org> > --- > drivers/i2c/busses/i2c-versatile.c | 11 +++++++++-- > 1 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c > index 4678bab..15b5e8a 100644 > --- a/drivers/i2c/busses/i2c-versatile.c > +++ b/drivers/i2c/busses/i2c-versatile.c > @@ -96,13 +96,20 @@ static int i2c_versatile_probe(struct platform_device *dev) > writel(SCL | SDA, i2c->base + I2C_CONTROLS); > > i2c->adap.owner = THIS_MODULE; > + if (dev->id >= 0) > + i2c->adap.nr = dev->id; > strlcpy(i2c->adap.name, "Versatile I2C adapter", sizeof(i2c->adap.name)); > i2c->adap.algo_data = &i2c->algo; > i2c->adap.dev.parent = &dev->dev; > i2c->algo = i2c_versatile_algo; > i2c->algo.data = i2c; > > - ret = i2c_bit_add_bus(&i2c->adap); > + if (dev->id >= 0) > + /* static bus numbering */ > + ret = i2c_bit_add_numbered_bus(&i2c->adap); > + else > + /* dynamic bus numbering */ > + ret = i2c_bit_add_bus(&i2c->adap); Why don't you merge both tests? This would simplify the code and make it clearer. > if (ret >= 0) { > platform_set_drvdata(dev, i2c); > return 0; > @@ -146,7 +153,7 @@ static void __exit i2c_versatile_exit(void) > platform_driver_unregister(&i2c_versatile_driver); > } > > -module_init(i2c_versatile_init); > +subsys_initcall(i2c_versatile_init); > module_exit(i2c_versatile_exit); > > MODULE_DESCRIPTION("ARM Versatile I2C bus driver"); -- Jean Delvare ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20090209203045.0c7a32a4-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>]
* Re: [PATCH] Add static bus numbering support to i2c-versatile [not found] ` <20090209203045.0c7a32a4-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org> @ 2009-02-10 12:24 ` Catalin Marinas [not found] ` <1234268669.8798.10.camel-hhZApKj8DF/YkXV2EHHjLW3o5bpOHsLO@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Catalin Marinas @ 2009-02-10 12:24 UTC (permalink / raw) To: Jean Delvare; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Russell King On Mon, 2009-02-09 at 19:30 +0000, Jean Delvare wrote: > On Mon, 09 Feb 2009 18:03:38 +0000, Catalin Marinas wrote: > > diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c > > index 4678bab..15b5e8a 100644 > > --- a/drivers/i2c/busses/i2c-versatile.c > > +++ b/drivers/i2c/busses/i2c-versatile.c > > @@ -96,13 +96,20 @@ static int i2c_versatile_probe(struct platform_device *dev) > > writel(SCL | SDA, i2c->base + I2C_CONTROLS); > > > > i2c->adap.owner = THIS_MODULE; > > + if (dev->id >= 0) > > + i2c->adap.nr = dev->id; > > strlcpy(i2c->adap.name, "Versatile I2C adapter", sizeof(i2c->adap.name)); > > i2c->adap.algo_data = &i2c->algo; > > i2c->adap.dev.parent = &dev->dev; > > i2c->algo = i2c_versatile_algo; > > i2c->algo.data = i2c; > > > > - ret = i2c_bit_add_bus(&i2c->adap); > > + if (dev->id >= 0) > > + /* static bus numbering */ > > + ret = i2c_bit_add_numbered_bus(&i2c->adap); > > + else > > + /* dynamic bus numbering */ > > + ret = i2c_bit_add_bus(&i2c->adap); > > Why don't you merge both tests? This would simplify the code and make > it clearer. Good point. Please see below. Thanks. Add static bus numbering support to i2c-versatile From: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org> If dev->id is not -1, the platform code may use static bus numbering rather than dynamic. The patch also changes the i2c_versatile_init to a subsys_initcall rather than module_init to make sure it is initialised before the I2C devices initialisation. Signed-off-by: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org> Cc: Russell King <rmk-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org> --- drivers/i2c/busses/i2c-versatile.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c index 4678bab..fede619 100644 --- a/drivers/i2c/busses/i2c-versatile.c +++ b/drivers/i2c/busses/i2c-versatile.c @@ -102,7 +102,13 @@ static int i2c_versatile_probe(struct platform_device *dev) i2c->algo = i2c_versatile_algo; i2c->algo.data = i2c; - ret = i2c_bit_add_bus(&i2c->adap); + if (dev->id >= 0) { + /* static bus numbering */ + i2c->adap.nr = dev->id; + ret = i2c_bit_add_numbered_bus(&i2c->adap); + } else + /* dynamic bus numbering */ + ret = i2c_bit_add_bus(&i2c->adap); if (ret >= 0) { platform_set_drvdata(dev, i2c); return 0; @@ -146,7 +152,7 @@ static void __exit i2c_versatile_exit(void) platform_driver_unregister(&i2c_versatile_driver); } -module_init(i2c_versatile_init); +subsys_initcall(i2c_versatile_init); module_exit(i2c_versatile_exit); MODULE_DESCRIPTION("ARM Versatile I2C bus driver"); -- Catalin ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1234268669.8798.10.camel-hhZApKj8DF/YkXV2EHHjLW3o5bpOHsLO@public.gmane.org>]
* Re: [PATCH] Add static bus numbering support to i2c-versatile [not found] ` <1234268669.8798.10.camel-hhZApKj8DF/YkXV2EHHjLW3o5bpOHsLO@public.gmane.org> @ 2009-02-10 13:27 ` Jean Delvare [not found] ` <20090210142701.37bc4717-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Jean Delvare @ 2009-02-10 13:27 UTC (permalink / raw) To: Catalin Marinas; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Russell King, Ben Dooks > Add static bus numbering support to i2c-versatile > > From: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org> > > If dev->id is not -1, the platform code may use static bus numbering > rather than dynamic. The patch also changes the i2c_versatile_init to a > subsys_initcall rather than module_init to make sure it is initialised > before the I2C devices initialisation. > > Signed-off-by: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org> > Cc: Russell King <rmk-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org> > --- > drivers/i2c/busses/i2c-versatile.c | 10 ++++++++-- > 1 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c > index 4678bab..fede619 100644 > --- a/drivers/i2c/busses/i2c-versatile.c > +++ b/drivers/i2c/busses/i2c-versatile.c > @@ -102,7 +102,13 @@ static int i2c_versatile_probe(struct platform_device *dev) > i2c->algo = i2c_versatile_algo; > i2c->algo.data = i2c; > > - ret = i2c_bit_add_bus(&i2c->adap); > + if (dev->id >= 0) { > + /* static bus numbering */ > + i2c->adap.nr = dev->id; > + ret = i2c_bit_add_numbered_bus(&i2c->adap); > + } else > + /* dynamic bus numbering */ > + ret = i2c_bit_add_bus(&i2c->adap); > if (ret >= 0) { > platform_set_drvdata(dev, i2c); > return 0; > @@ -146,7 +152,7 @@ static void __exit i2c_versatile_exit(void) > platform_driver_unregister(&i2c_versatile_driver); > } > > -module_init(i2c_versatile_init); > +subsys_initcall(i2c_versatile_init); > module_exit(i2c_versatile_exit); > > MODULE_DESCRIPTION("ARM Versatile I2C bus driver"); Acked-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> Note that i2c-versatile is not under my jurisdiction so you will have to push this patch through either Ben Dooks or the arm tree. -- Jean Delvare ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20090210142701.37bc4717-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>]
* Re: [PATCH] Add static bus numbering support to i2c-versatile [not found] ` <20090210142701.37bc4717-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org> @ 2009-02-10 17:00 ` Catalin Marinas 0 siblings, 0 replies; 5+ messages in thread From: Catalin Marinas @ 2009-02-10 17:00 UTC (permalink / raw) To: Jean Delvare; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Russell King, Ben Dooks On Tue, 2009-02-10 at 14:27 +0100, Jean Delvare wrote: > > Add static bus numbering support to i2c-versatile [...] > Acked-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> > > Note that i2c-versatile is not under my jurisdiction so you will have > to push this patch through either Ben Dooks or the arm tree. Russell, since you wrote the code originally, are you OK with me sending it to your patch system? Thanks. -- Catalin ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-02-10 17:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-09 18:03 [PATCH] Add static bus numbering support to i2c-versatile Catalin Marinas
[not found] ` <20090209180338.27227.77460.stgit-hhZApKj8DF/YkXV2EHHjLW3o5bpOHsLO@public.gmane.org>
2009-02-09 19:30 ` Jean Delvare
[not found] ` <20090209203045.0c7a32a4-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-10 12:24 ` Catalin Marinas
[not found] ` <1234268669.8798.10.camel-hhZApKj8DF/YkXV2EHHjLW3o5bpOHsLO@public.gmane.org>
2009-02-10 13:27 ` Jean Delvare
[not found] ` <20090210142701.37bc4717-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-10 17:00 ` Catalin Marinas
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox