Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] marvell-cam: Allocate the i2c adapter in the platform driver

The upcoming mmp-camera driver will need an i2c_adapter structure allocated
externally, so change the core adapter to a pointer and require the
platform code to fill it in.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Jonathan Corbet and committed by
Mauro Carvalho Chehab
595a93a4 1c68f889

+9 -4
+7 -2
drivers/media/video/marvell-ccic/cafe-driver.c
··· 334 334 335 335 static int cafe_smbus_setup(struct cafe_camera *cam) 336 336 { 337 - struct i2c_adapter *adap = &cam->mcam.i2c_adapter; 337 + struct i2c_adapter *adap; 338 338 int ret; 339 339 340 + adap = kzalloc(sizeof(*adap), GFP_KERNEL); 341 + if (adap == NULL) 342 + return -ENOMEM; 343 + cam->mcam.i2c_adapter = adap; 340 344 cafe_smbus_enable_irq(cam); 341 345 adap->owner = THIS_MODULE; 342 346 adap->algo = &cafe_smbus_algo; ··· 355 351 356 352 static void cafe_smbus_shutdown(struct cafe_camera *cam) 357 353 { 358 - i2c_del_adapter(&cam->mcam.i2c_adapter); 354 + i2c_del_adapter(cam->mcam.i2c_adapter); 355 + kfree(cam->mcam.i2c_adapter); 359 356 } 360 357 361 358
+1 -1
drivers/media/video/marvell-ccic/mcam-core.c
··· 1581 1581 sensor_cfg.use_smbus = cam->use_smbus; 1582 1582 cam->sensor_addr = ov7670_info.addr; 1583 1583 cam->sensor = v4l2_i2c_new_subdev_board(&cam->v4l2_dev, 1584 - &cam->i2c_adapter, &ov7670_info, NULL); 1584 + cam->i2c_adapter, &ov7670_info, NULL); 1585 1585 if (cam->sensor == NULL) { 1586 1586 ret = -ENODEV; 1587 1587 goto out_unregister;
+1 -1
drivers/media/video/marvell-ccic/mcam-core.h
··· 37 37 * These fields should be set by the platform code prior to 38 38 * calling mcam_register(). 39 39 */ 40 - struct i2c_adapter i2c_adapter; 40 + struct i2c_adapter *i2c_adapter; 41 41 unsigned char __iomem *regs; 42 42 spinlock_t dev_lock; 43 43 struct device *dev; /* For messages, dma alloc */