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

media: i2c: ov02a10: Replace client->dev usage

The driver needs to access the struct device in many places, and
retrieves it from the i2c_client itself retrieved with
v4l2_get_subdevdata(). Store it as a pointer in struct ov02a10 and
access it from there instead, to simplify the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
f8f4914e 44fec2c0

+16 -15
+16 -15
drivers/media/i2c/ov02a10.c
··· 100 100 }; 101 101 102 102 struct ov02a10 { 103 + struct device *dev; 104 + 103 105 u32 eclk_freq; 104 106 /* Indication of MIPI transmission speed select */ 105 107 u32 mipi_clock_voltage; ··· 394 392 chip_id = le16_to_cpu((__force __le16)ret); 395 393 396 394 if ((chip_id & OV02A10_ID_MASK) != OV02A10_ID) { 397 - dev_err(&client->dev, "unexpected sensor id(0x%04x)\n", chip_id); 395 + dev_err(ov02a10->dev, "unexpected sensor id(0x%04x)\n", chip_id); 398 396 return -EINVAL; 399 397 } 400 398 ··· 483 481 ret = i2c_smbus_write_byte_data(client, REG_MIRROR_FLIP_CONTROL, 484 482 REG_MIRROR_FLIP_ENABLE); 485 483 if (ret < 0) { 486 - dev_err(&client->dev, "failed to set orientation\n"); 484 + dev_err(ov02a10->dev, "failed to set orientation\n"); 487 485 return ret; 488 486 } 489 487 ret = i2c_smbus_write_byte_data(client, REG_GLOBAL_EFFECTIVE, ··· 532 530 static int ov02a10_s_stream(struct v4l2_subdev *sd, int on) 533 531 { 534 532 struct ov02a10 *ov02a10 = to_ov02a10(sd); 535 - struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); 536 533 int ret; 537 534 538 535 mutex_lock(&ov02a10->mutex); ··· 542 541 } 543 542 544 543 if (on) { 545 - ret = pm_runtime_resume_and_get(&client->dev); 544 + ret = pm_runtime_resume_and_get(ov02a10->dev); 546 545 if (ret < 0) 547 546 goto unlock_and_return; 548 547 ··· 554 553 } 555 554 } else { 556 555 __ov02a10_stop_stream(ov02a10); 557 - pm_runtime_put(&client->dev); 556 + pm_runtime_put(ov02a10->dev); 558 557 } 559 558 560 559 ov02a10->streaming = on; ··· 563 562 return 0; 564 563 565 564 err_rpm_put: 566 - pm_runtime_put(&client->dev); 565 + pm_runtime_put(ov02a10->dev); 567 566 unlock_and_return: 568 567 mutex_unlock(&ov02a10->mutex); 569 568 ··· 663 662 { 664 663 struct ov02a10 *ov02a10 = container_of(ctrl->handler, 665 664 struct ov02a10, ctrl_handler); 666 - struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); 667 665 s64 max_expo; 668 666 int ret; 669 667 ··· 678 678 } 679 679 680 680 /* V4L2 controls values will be applied only when power is already up */ 681 - if (!pm_runtime_get_if_in_use(&client->dev)) 681 + if (!pm_runtime_get_if_in_use(ov02a10->dev)) 682 682 return 0; 683 683 684 684 switch (ctrl->id) { ··· 699 699 break; 700 700 } 701 701 702 - pm_runtime_put(&client->dev); 702 + pm_runtime_put(ov02a10->dev); 703 703 704 704 return ret; 705 705 } ··· 734 734 735 735 static int ov02a10_initialize_controls(struct ov02a10 *ov02a10) 736 736 { 737 - struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); 738 737 const struct ov02a10_mode *mode; 739 738 struct v4l2_ctrl_handler *handler; 740 739 struct v4l2_ctrl *ctrl; ··· 789 790 790 791 if (handler->error) { 791 792 ret = handler->error; 792 - dev_err(&client->dev, "failed to init controls(%d)\n", ret); 793 + dev_err(ov02a10->dev, "failed to init controls(%d)\n", ret); 793 794 goto err_free_handler; 794 795 } 795 796 ··· 864 865 ov02a10 = devm_kzalloc(dev, sizeof(*ov02a10), GFP_KERNEL); 865 866 if (!ov02a10) 866 867 return -ENOMEM; 868 + 869 + ov02a10->dev = dev; 867 870 868 871 ret = ov02a10_check_hwcfg(dev, ov02a10); 869 872 if (ret) ··· 986 985 v4l2_async_unregister_subdev(sd); 987 986 media_entity_cleanup(&sd->entity); 988 987 v4l2_ctrl_handler_free(sd->ctrl_handler); 989 - pm_runtime_disable(&client->dev); 990 - if (!pm_runtime_status_suspended(&client->dev)) 991 - ov02a10_power_off(&client->dev); 992 - pm_runtime_set_suspended(&client->dev); 988 + pm_runtime_disable(ov02a10->dev); 989 + if (!pm_runtime_status_suspended(ov02a10->dev)) 990 + ov02a10_power_off(ov02a10->dev); 991 + pm_runtime_set_suspended(ov02a10->dev); 993 992 mutex_destroy(&ov02a10->mutex); 994 993 } 995 994