upstream: [media] media: i2c: lm3560: use correct clientdata in lm3560_remove()
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Sat, 9 Nov 2013 00:24:18 +0000 (21:24 -0300)
committerChanho Park <chanho61.park@samsung.com>
Thu, 7 Aug 2014 05:26:32 +0000 (14:26 +0900)
We had set the i2c clientdata to &flash->subdev_led[LM3560_LED1]
after call lm3560_subdev_init(flash, LM3560_LED1, "lm3560-led1"),
but the container_of() in lm3560_remove() return the wrong pointer
to flash.(should be container_of(subdev, struct lm3560_flash,
subdev_led[LM3560_LED_MAX-1])
This patch fix to set i2c clientdata to flash so we can get flash
from clientdata directly.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/i2c/lm3560.c

index e728d9f..d98ca3a 100644 (file)
@@ -448,14 +448,14 @@ static int lm3560_probe(struct i2c_client *client,
        if (rval < 0)
                return rval;
 
+       i2c_set_clientdata(client, flash);
+
        return 0;
 }
 
 static int lm3560_remove(struct i2c_client *client)
 {
-       struct v4l2_subdev *subdev = i2c_get_clientdata(client);
-       struct lm3560_flash *flash = container_of(subdev, struct lm3560_flash,
-                                                 subdev_led[LM3560_LED_MAX]);
+       struct lm3560_flash *flash = i2c_get_clientdata(client);
        unsigned int i;
 
        for (i = LM3560_LED0; i < LM3560_LED_MAX; i++) {