Skip to content

Commit

Permalink
media: cafe-driver: use drvdata instead of back-casting from v4l2_device
Browse files Browse the repository at this point in the history
Since commit 95db3a6 ("[media] v4l: Add a media_device pointer
to the v4l2_device structure") the v4l core doesn't insist on using drvdata
itself.  Therefore we can use it ourselves, making things somewhat simpler.

Signed-off-by: Lubomir Rintel <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
lkundrak authored and mchehab committed Aug 29, 2020
1 parent 1762175 commit 953e411
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions drivers/media/platform/marvell-ccic/cafe-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
cam = kzalloc(sizeof(struct cafe_camera), GFP_KERNEL);
if (cam == NULL)
goto out;
pci_set_drvdata(pdev, cam);
cam->pdev = pdev;
mcam = &cam->mcam;
mcam->chip_id = MCAM_CAFE;
Expand Down Expand Up @@ -592,8 +593,7 @@ static void cafe_shutdown(struct cafe_camera *cam)

static void cafe_pci_remove(struct pci_dev *pdev)
{
struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
struct cafe_camera *cam = to_cam(v4l2_dev);
struct cafe_camera *cam = pci_get_drvdata(pdev);

if (cam == NULL) {
printk(KERN_WARNING "pci_remove on unknown pdev %p\n", pdev);
Expand All @@ -609,8 +609,7 @@ static void cafe_pci_remove(struct pci_dev *pdev)
*/
static int __maybe_unused cafe_pci_suspend(struct device *dev)
{
struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
struct cafe_camera *cam = to_cam(v4l2_dev);
struct cafe_camera *cam = dev_get_drvdata(dev);

mccic_suspend(&cam->mcam);
return 0;
Expand All @@ -619,8 +618,7 @@ static int __maybe_unused cafe_pci_suspend(struct device *dev)

static int __maybe_unused cafe_pci_resume(struct device *dev)
{
struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
struct cafe_camera *cam = to_cam(v4l2_dev);
struct cafe_camera *cam = dev_get_drvdata(dev);

cafe_ctlr_init(&cam->mcam);
return mccic_resume(&cam->mcam);
Expand Down

0 comments on commit 953e411

Please sign in to comment.