From 6776f3d26aec60cb6e0fc770a00993accd09376f Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Mon, 21 May 2007 12:29:40 +0100 Subject: [ARM] 4403/1: Make the PXA-I2C driver work with lockdep validator Using lockdep validator causes warnings like INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. [] (dump_stack+0x0/0x14) from [] (__lock_acquire+0x150/0xc40) [] (__lock_acquire+0x0/0xc40) from [] (lock_acquire+0x5c/0x70) [] (lock_acquire+0x0/0x70) from [] (_spin_lock_irq+0x48/0x58) r7:c07e5144 r6:00000000 r5:c015fb94 r4:c07e50b8 [] (_spin_lock_irq+0x0/0x58) from [] (i2c_pxa_xfer+0x110/0x2e0) r5:c07e50b8 r4:0000001f This is caused by memcpy'ing a statical initialized spin-lock. This patch removes a static pxa_i2c structure which was used only as a source for this memcpy() operation. Instead of, members and the spinlock will be initialized manually. Signed-off-by: Enrico Scholz Signed-off-by: Russell King --- drivers/i2c/busses/i2c-pxa.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 8a0a99b9364..28e7b91a455 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -837,20 +837,10 @@ static const struct i2c_algorithm i2c_pxa_algorithm = { .functionality = i2c_pxa_functionality, }; -static struct pxa_i2c i2c_pxa = { - .lock = __SPIN_LOCK_UNLOCKED(i2c_pxa.lock), - .adap = { - .owner = THIS_MODULE, - .algo = &i2c_pxa_algorithm, - .name = "pxa2xx-i2c.0", - .retries = 5, - }, -}; - #define res_len(r) ((r)->end - (r)->start + 1) static int i2c_pxa_probe(struct platform_device *dev) { - struct pxa_i2c *i2c = &i2c_pxa; + struct pxa_i2c *i2c; struct resource *res; struct i2c_pxa_platform_data *plat = dev->dev.platform_data; int ret; @@ -864,15 +854,20 @@ static int i2c_pxa_probe(struct platform_device *dev) if (!request_mem_region(res->start, res_len(res), res->name)) return -ENOMEM; - i2c = kmalloc(sizeof(struct pxa_i2c), GFP_KERNEL); + i2c = kzalloc(sizeof(struct pxa_i2c), GFP_KERNEL); if (!i2c) { ret = -ENOMEM; goto emalloc; } - memcpy(i2c, &i2c_pxa, sizeof(struct pxa_i2c)); + i2c->adap.owner = THIS_MODULE; + i2c->adap.algo = &i2c_pxa_algorithm; + i2c->adap.retries = 5; + + spin_lock_init(&i2c->lock); init_waitqueue_head(&i2c->wait); - i2c->adap.name[strlen(i2c->adap.name) - 1] = '0' + dev->id % 10; + + sprintf(i2c->adap.name, "pxa_i2c-i2c.%u", dev->id); i2c->reg_base = ioremap(res->start, res_len(res)); if (!i2c->reg_base) { -- cgit v1.2.3