* [PATCH] i2c: nomadik: allocate adapter number dynamically
@ 2013-06-09 22:15 Linus Walleij
[not found] ` <1370816153-9838-1-git-send-email-linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2013-06-09 22:15 UTC (permalink / raw)
To: Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA; +Cc: Linus Walleij
The Nomadik I2C was using a local atomic counter to number
the I2C adapters. This does not work on configurations where
you also add, say a GPIO bit-banged adapter to the system.
They will start to conflict about being adapter 0.
There is no reason to use the numbered adapter function, and
the semantic effect on systems with only Nomadik I2C blocks
will be none - instead of increasing the number atomically
in the driver itself, it is done in the I2C core.
Signed-off-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
drivers/i2c/busses/i2c-nomadik.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 9f1423a..96c8515 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -15,7 +15,6 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/amba/bus.h>
-#include <linux/atomic.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/i2c.h>
@@ -981,8 +980,6 @@ static void nmk_i2c_of_probe(struct device_node *np,
pdata->sm = I2C_FREQ_MODE_FAST;
}
-static atomic_t adapter_id = ATOMIC_INIT(0);
-
static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
{
int ret = 0;
@@ -1095,10 +1092,9 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
adap->algo = &nmk_i2c_algo;
adap->timeout = msecs_to_jiffies(pdata->timeout);
- adap->nr = atomic_read(&adapter_id);
+ adap->nr = -1;
snprintf(adap->name, sizeof(adap->name),
- "Nomadik I2C%d at %pR", adap->nr, &adev->res);
- atomic_inc(&adapter_id);
+ "Nomadik I2C at %pR", &adev->res);
/* fetch the controller configuration from machine */
dev->cfg.clk_freq = pdata->clk_freq;
@@ -1113,7 +1109,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
"initialize %s on virtual base %p\n",
adap->name, dev->virtbase);
- ret = i2c_add_numbered_adapter(adap);
+ ret = i2c_add_adapter(adap);
if (ret) {
dev_err(&adev->dev, "failed to add adapter\n");
goto err_add_adap;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: nomadik: allocate adapter number dynamically
[not found] ` <1370816153-9838-1-git-send-email-linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2013-06-15 14:20 ` Wolfram Sang
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2013-06-15 14:20 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 2572 bytes --]
On Mon, Jun 10, 2013 at 12:15:53AM +0200, Linus Walleij wrote:
> The Nomadik I2C was using a local atomic counter to number
> the I2C adapters. This does not work on configurations where
> you also add, say a GPIO bit-banged adapter to the system.
> They will start to conflict about being adapter 0.
>
> There is no reason to use the numbered adapter function, and
> the semantic effect on systems with only Nomadik I2C blocks
> will be none - instead of increasing the number atomically
> in the driver itself, it is done in the I2C core.
>
> Signed-off-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Basically fine...
> ---
> drivers/i2c/busses/i2c-nomadik.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
> index 9f1423a..96c8515 100644
> --- a/drivers/i2c/busses/i2c-nomadik.c
> +++ b/drivers/i2c/busses/i2c-nomadik.c
> @@ -15,7 +15,6 @@
> #include <linux/init.h>
> #include <linux/module.h>
> #include <linux/amba/bus.h>
> -#include <linux/atomic.h>
> #include <linux/slab.h>
> #include <linux/interrupt.h>
> #include <linux/i2c.h>
> @@ -981,8 +980,6 @@ static void nmk_i2c_of_probe(struct device_node *np,
> pdata->sm = I2C_FREQ_MODE_FAST;
> }
>
> -static atomic_t adapter_id = ATOMIC_INIT(0);
> -
> static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
> {
> int ret = 0;
> @@ -1095,10 +1092,9 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
> adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
> adap->algo = &nmk_i2c_algo;
> adap->timeout = msecs_to_jiffies(pdata->timeout);
> - adap->nr = atomic_read(&adapter_id);
> + adap->nr = -1;
... only that line can be removed since you now use i2c_add_adapter
instead of i2c_add_numbered_adapter.
> snprintf(adap->name, sizeof(adap->name),
> - "Nomadik I2C%d at %pR", adap->nr, &adev->res);
> - atomic_inc(&adapter_id);
> + "Nomadik I2C at %pR", &adev->res);
>
> /* fetch the controller configuration from machine */
> dev->cfg.clk_freq = pdata->clk_freq;
> @@ -1113,7 +1109,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
> "initialize %s on virtual base %p\n",
> adap->name, dev->virtbase);
>
> - ret = i2c_add_numbered_adapter(adap);
> + ret = i2c_add_adapter(adap);
> if (ret) {
> dev_err(&adev->dev, "failed to add adapter\n");
> goto err_add_adap;
> --
> 1.8.1.4
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-15 14:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-09 22:15 [PATCH] i2c: nomadik: allocate adapter number dynamically Linus Walleij
[not found] ` <1370816153-9838-1-git-send-email-linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-06-15 14:20 ` 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).