Skip to content

Commit 14178aa

Browse files
lyakhMauro Carvalho Chehab
authored andcommitted
[media] V4L: soc-camera: start removing struct soc_camera_device from client drivers
Remove most trivial uses of struct soc_camera_device from most client drivers, abstracting some of them inside inline functions. Next steps will eliminate remaining uses and modify inline functions to not use struct soc_camera_device. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1 parent 09362ec commit 14178aa

15 files changed

Lines changed: 126 additions & 286 deletions

File tree

‎drivers/media/video/imx074.c‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ static struct v4l2_subdev_ops imx074_subdev_ops = {
298298
.video = &imx074_subdev_video_ops,
299299
};
300300

301-
static int imx074_video_probe(struct soc_camera_device *icd,
302-
struct i2c_client *client)
301+
static int imx074_video_probe(struct i2c_client *client)
303302
{
304303
int ret;
305304
u16 id;
@@ -409,17 +408,10 @@ static int imx074_probe(struct i2c_client *client,
409408
const struct i2c_device_id *did)
410409
{
411410
struct imx074 *priv;
412-
struct soc_camera_device *icd = client->dev.platform_data;
413411
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
414-
struct soc_camera_link *icl;
412+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
415413
int ret;
416414

417-
if (!icd) {
418-
dev_err(&client->dev, "IMX074: missing soc-camera data!\n");
419-
return -EINVAL;
420-
}
421-
422-
icl = to_soc_camera_link(icd);
423415
if (!icl) {
424416
dev_err(&client->dev, "IMX074: missing platform data!\n");
425417
return -EINVAL;
@@ -439,7 +431,7 @@ static int imx074_probe(struct i2c_client *client,
439431

440432
priv->fmt = &imx074_colour_fmts[0];
441433

442-
ret = imx074_video_probe(icd, client);
434+
ret = imx074_video_probe(client);
443435
if (ret < 0) {
444436
kfree(priv);
445437
return ret;
@@ -451,8 +443,7 @@ static int imx074_probe(struct i2c_client *client,
451443
static int imx074_remove(struct i2c_client *client)
452444
{
453445
struct imx074 *priv = to_imx074(client);
454-
struct soc_camera_device *icd = client->dev.platform_data;
455-
struct soc_camera_link *icl = to_soc_camera_link(icd);
446+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
456447

457448
if (icl->free_bus)
458449
icl->free_bus(icl);

‎drivers/media/video/mt9m001.c‎

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
205205

206206
/*
207207
* The caller provides a supported format, as verified per
208-
* call to icd->try_fmt()
208+
* call to .try_mbus_fmt()
209209
*/
210210
if (!ret)
211211
ret = reg_write(client, MT9M001_COLUMN_START, rect.left);
@@ -474,19 +474,14 @@ static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl)
474474
* Interface active, can use i2c. If it fails, it can indeed mean, that
475475
* this wasn't our capture interface, so, we wait for the right one
476476
*/
477-
static int mt9m001_video_probe(struct soc_camera_device *icd,
477+
static int mt9m001_video_probe(struct soc_camera_link *icl,
478478
struct i2c_client *client)
479479
{
480480
struct mt9m001 *mt9m001 = to_mt9m001(client);
481-
struct soc_camera_link *icl = to_soc_camera_link(icd);
482481
s32 data;
483482
unsigned long flags;
484483
int ret;
485484

486-
/* We must have a parent by now. And it cannot be a wrong one. */
487-
BUG_ON(!icd->parent ||
488-
to_soc_camera_host(icd->parent)->nr != icd->iface);
489-
490485
/* Enable the chip */
491486
data = reg_write(client, MT9M001_CHIP_ENABLE, 1);
492487
dev_dbg(&client->dev, "write: %d\n", data);
@@ -544,12 +539,8 @@ static int mt9m001_video_probe(struct soc_camera_device *icd,
544539
return v4l2_ctrl_handler_setup(&mt9m001->hdl);
545540
}
546541

547-
static void mt9m001_video_remove(struct soc_camera_device *icd)
542+
static void mt9m001_video_remove(struct soc_camera_link *icl)
548543
{
549-
struct soc_camera_link *icl = to_soc_camera_link(icd);
550-
551-
dev_dbg(icd->pdev, "Video removed: %p, %p\n",
552-
icd->parent, icd->vdev);
553544
if (icl->free_bus)
554545
icl->free_bus(icl);
555546
}
@@ -594,8 +585,7 @@ static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,
594585
struct v4l2_mbus_config *cfg)
595586
{
596587
struct i2c_client *client = v4l2_get_subdevdata(sd);
597-
struct soc_camera_device *icd = client->dev.platform_data;
598-
struct soc_camera_link *icl = to_soc_camera_link(icd);
588+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
599589

600590
/* MT9M001 has all capture_format parameters fixed */
601591
cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
@@ -610,9 +600,9 @@ static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,
610600
static int mt9m001_s_mbus_config(struct v4l2_subdev *sd,
611601
const struct v4l2_mbus_config *cfg)
612602
{
613-
struct i2c_client *client = v4l2_get_subdevdata(sd);
614-
struct soc_camera_device *icd = client->dev.platform_data;
615-
struct soc_camera_link *icl = to_soc_camera_link(icd);
603+
const struct i2c_client *client = v4l2_get_subdevdata(sd);
604+
struct soc_camera_device *icd = soc_camera_from_i2c(client);
605+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
616606
/*
617607
* Cannot use icd->current_fmt->host_fmt->bits_per_sample, because that
618608
* is the number of bits, that the host has to sample, not the number of
@@ -658,17 +648,10 @@ static int mt9m001_probe(struct i2c_client *client,
658648
const struct i2c_device_id *did)
659649
{
660650
struct mt9m001 *mt9m001;
661-
struct soc_camera_device *icd = client->dev.platform_data;
662651
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
663-
struct soc_camera_link *icl;
652+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
664653
int ret;
665654

666-
if (!icd) {
667-
dev_err(&client->dev, "MT9M001: missing soc-camera data!\n");
668-
return -EINVAL;
669-
}
670-
671-
icl = to_soc_camera_link(icd);
672655
if (!icl) {
673656
dev_err(&client->dev, "MT9M001 driver needs platform data\n");
674657
return -EINVAL;
@@ -716,7 +699,7 @@ static int mt9m001_probe(struct i2c_client *client,
716699
mt9m001->rect.width = MT9M001_MAX_WIDTH;
717700
mt9m001->rect.height = MT9M001_MAX_HEIGHT;
718701

719-
ret = mt9m001_video_probe(icd, client);
702+
ret = mt9m001_video_probe(icl, client);
720703
if (ret) {
721704
v4l2_ctrl_handler_free(&mt9m001->hdl);
722705
kfree(mt9m001);
@@ -728,11 +711,11 @@ static int mt9m001_probe(struct i2c_client *client,
728711
static int mt9m001_remove(struct i2c_client *client)
729712
{
730713
struct mt9m001 *mt9m001 = to_mt9m001(client);
731-
struct soc_camera_device *icd = client->dev.platform_data;
714+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
732715

733716
v4l2_device_unregister_subdev(&mt9m001->subdev);
734717
v4l2_ctrl_handler_free(&mt9m001->hdl);
735-
mt9m001_video_remove(icd);
718+
mt9m001_video_remove(icl);
736719
kfree(mt9m001);
737720

738721
return 0;

‎drivers/media/video/mt9m111.c‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -784,19 +784,12 @@ static int mt9m111_init(struct mt9m111 *mt9m111)
784784
* Interface active, can use i2c. If it fails, it can indeed mean, that
785785
* this wasn't our capture interface, so, we wait for the right one
786786
*/
787-
static int mt9m111_video_probe(struct soc_camera_device *icd,
788-
struct i2c_client *client)
787+
static int mt9m111_video_probe(struct i2c_client *client)
789788
{
790789
struct mt9m111 *mt9m111 = to_mt9m111(client);
791790
s32 data;
792791
int ret;
793792

794-
/* We must have a parent by now. And it cannot be a wrong one. */
795-
BUG_ON(!icd->parent ||
796-
to_soc_camera_host(icd->parent)->nr != icd->iface);
797-
798-
mt9m111->lastpage = -1;
799-
800793
data = reg_read(CHIP_VERSION);
801794

802795
switch (data) {
@@ -883,8 +876,7 @@ static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
883876
struct v4l2_mbus_config *cfg)
884877
{
885878
struct i2c_client *client = v4l2_get_subdevdata(sd);
886-
struct soc_camera_device *icd = client->dev.platform_data;
887-
struct soc_camera_link *icl = to_soc_camera_link(icd);
879+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
888880

889881
cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
890882
V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
@@ -915,17 +907,10 @@ static int mt9m111_probe(struct i2c_client *client,
915907
const struct i2c_device_id *did)
916908
{
917909
struct mt9m111 *mt9m111;
918-
struct soc_camera_device *icd = client->dev.platform_data;
919910
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
920-
struct soc_camera_link *icl;
911+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
921912
int ret;
922913

923-
if (!icd) {
924-
dev_err(&client->dev, "mt9m111: soc-camera data missing!\n");
925-
return -EINVAL;
926-
}
927-
928-
icl = to_soc_camera_link(icd);
929914
if (!icl) {
930915
dev_err(&client->dev, "mt9m111: driver needs platform data\n");
931916
return -EINVAL;
@@ -968,8 +953,9 @@ static int mt9m111_probe(struct i2c_client *client,
968953
mt9m111->rect.width = MT9M111_MAX_WIDTH;
969954
mt9m111->rect.height = MT9M111_MAX_HEIGHT;
970955
mt9m111->fmt = &mt9m111_colour_fmts[0];
956+
mt9m111->lastpage = -1;
971957

972-
ret = mt9m111_video_probe(icd, client);
958+
ret = mt9m111_video_probe(client);
973959
if (ret) {
974960
v4l2_ctrl_handler_free(&mt9m111->hdl);
975961
kfree(mt9m111);

‎drivers/media/video/mt9t031.c‎

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static int mt9t031_set_params(struct i2c_client *client,
265265

266266
/*
267267
* The caller provides a supported format, as guaranteed by
268-
* icd->try_fmt_cap(), soc_camera_s_crop() and soc_camera_cropcap()
268+
* .try_mbus_fmt(), soc_camera_s_crop() and soc_camera_cropcap()
269269
*/
270270
if (ret >= 0)
271271
ret = reg_write(client, MT9T031_COLUMN_START, rect->left);
@@ -573,8 +573,7 @@ static int mt9t031_runtime_suspend(struct device *dev)
573573
static int mt9t031_runtime_resume(struct device *dev)
574574
{
575575
struct video_device *vdev = to_video_device(dev);
576-
struct soc_camera_device *icd = dev_get_drvdata(vdev->parent);
577-
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
576+
struct v4l2_subdev *sd = soc_camera_vdev_to_subdev(vdev);
578577
struct i2c_client *client = v4l2_get_subdevdata(sd);
579578
struct mt9t031 *mt9t031 = to_mt9t031(client);
580579

@@ -684,8 +683,7 @@ static int mt9t031_g_mbus_config(struct v4l2_subdev *sd,
684683
struct v4l2_mbus_config *cfg)
685684
{
686685
struct i2c_client *client = v4l2_get_subdevdata(sd);
687-
struct soc_camera_device *icd = client->dev.platform_data;
688-
struct soc_camera_link *icl = to_soc_camera_link(icd);
686+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
689687

690688
cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
691689
V4L2_MBUS_PCLK_SAMPLE_FALLING | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
@@ -700,8 +698,7 @@ static int mt9t031_s_mbus_config(struct v4l2_subdev *sd,
700698
const struct v4l2_mbus_config *cfg)
701699
{
702700
struct i2c_client *client = v4l2_get_subdevdata(sd);
703-
struct soc_camera_device *icd = client->dev.platform_data;
704-
struct soc_camera_link *icl = to_soc_camera_link(icd);
701+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
705702

706703
if (soc_camera_apply_board_flags(icl, cfg) &
707704
V4L2_MBUS_PCLK_SAMPLE_FALLING)
@@ -737,16 +734,13 @@ static int mt9t031_probe(struct i2c_client *client,
737734
const struct i2c_device_id *did)
738735
{
739736
struct mt9t031 *mt9t031;
740-
struct soc_camera_device *icd = client->dev.platform_data;
737+
struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
741738
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
742739
int ret;
743740

744-
if (icd) {
745-
struct soc_camera_link *icl = to_soc_camera_link(icd);
746-
if (!icl) {
747-
dev_err(&client->dev, "MT9T031 driver needs platform data\n");
748-
return -EINVAL;
749-
}
741+
if (!icl) {
742+
dev_err(&client->dev, "MT9T031 driver needs platform data\n");
743+
return -EINVAL;
750744
}
751745

752746
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) {

0 commit comments

Comments
 (0)