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

[media] V4L: soc-camera: call soc_camera_power_on() after adding the client to the host

soc_camera_power_on() calls client's .s_power(1) method, which can try to
access the client hardware. This, however, is typically only possible,
after calling host's .add() method, because that's where the host driver
usually turns the master clock on.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Guennadi Liakhovetski and committed by
Mauro Carvalho Chehab
7705b6d8 5da6e984

+16 -16
+16 -16
drivers/media/video/soc_camera.c
··· 526 526 }, 527 527 }; 528 528 529 - ret = soc_camera_power_on(icd, icl); 530 - if (ret < 0) 531 - goto epower; 532 - 533 529 /* The camera could have been already on, try to reset */ 534 530 if (icl->reset) 535 531 icl->reset(icd->pdev); ··· 535 539 dev_err(icd->pdev, "Couldn't activate the camera: %d\n", ret); 536 540 goto eiciadd; 537 541 } 542 + 543 + ret = soc_camera_power_on(icd, icl); 544 + if (ret < 0) 545 + goto epower; 538 546 539 547 pm_runtime_enable(&icd->vdev->dev); 540 548 ret = pm_runtime_resume(&icd->vdev->dev); ··· 578 578 esfmt: 579 579 pm_runtime_disable(&icd->vdev->dev); 580 580 eresume: 581 - ici->ops->remove(icd); 582 - eiciadd: 583 581 soc_camera_power_off(icd, icl); 584 582 epower: 583 + ici->ops->remove(icd); 584 + eiciadd: 585 585 icd->use_count--; 586 586 module_put(ici->ops->owner); 587 587 ··· 1050 1050 if (ret < 0) 1051 1051 goto ereg; 1052 1052 1053 + /* The camera could have been already on, try to reset */ 1054 + if (icl->reset) 1055 + icl->reset(icd->pdev); 1056 + 1057 + ret = ici->ops->add(icd); 1058 + if (ret < 0) 1059 + goto eadd; 1060 + 1053 1061 /* 1054 1062 * This will not yet call v4l2_subdev_core_ops::s_power(1), because the 1055 1063 * subdevice has not been initialised yet. We'll have to call it once ··· 1067 1059 ret = soc_camera_power_on(icd, icl); 1068 1060 if (ret < 0) 1069 1061 goto epower; 1070 - 1071 - /* The camera could have been already on, try to reset */ 1072 - if (icl->reset) 1073 - icl->reset(icd->pdev); 1074 - 1075 - ret = ici->ops->add(icd); 1076 - if (ret < 0) 1077 - goto eadd; 1078 1062 1079 1063 /* Must have icd->vdev before registering the device */ 1080 1064 ret = video_dev_create(icd); ··· 1165 1165 video_device_release(icd->vdev); 1166 1166 icd->vdev = NULL; 1167 1167 evdc: 1168 - ici->ops->remove(icd); 1169 - eadd: 1170 1168 soc_camera_power_off(icd, icl); 1171 1169 epower: 1170 + ici->ops->remove(icd); 1171 + eadd: 1172 1172 regulator_bulk_free(icl->num_regulators, icl->regulators); 1173 1173 ereg: 1174 1174 v4l2_ctrl_handler_free(&icd->ctrl_handler);