linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container
@ 2020-10-29 16:42 Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 02/25] media: i2c: imx219: " Krzysztof Kozlowski
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: Krzysztof Kozlowski @ 2020-10-29 16:42 UTC (permalink / raw)
  To: Pavel Machek, Sakari Ailus, Mauro Carvalho Chehab,
	Lars-Peter Clausen, Tianshu Qiu, Dongchun Zhu, Shawn Tu,
	Ricardo Ribalda, Dave Stevenson, Manivannan Sadhasivam,
	Bingbu Cao, Rui Miguel Silva, Shunqian Zheng, Chiranjeevi Rapolu,
	Hyungwoo Yang, Wenyou Yang, Hans Verkuil, linux-media,
	linux-kernel
  Cc: Krzysztof Kozlowski

The pointer to 'struct v4l2_subdev' is stored in drvdata via
v4l2_i2c_subdev_init() so there is no point of a dance like:

    struct i2c_client *client = to_i2c_client(struct device *dev)
    struct v4l2_subdev *sd = i2c_get_clientdata(client);

This allows to remove local variable 'client' and few pointer
dereferences.  White at it, use 'dev' directly instead of 'imx214->dev'.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/media/i2c/imx214.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
index 1ef5af9a8c8b..dc27c3678f18 100644
--- a/drivers/media/i2c/imx214.c
+++ b/drivers/media/i2c/imx214.c
@@ -431,14 +431,13 @@ static inline struct imx214 *to_imx214(struct v4l2_subdev *sd)
 
 static int __maybe_unused imx214_power_on(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+	struct v4l2_subdev *sd = dev_get_drvdata(dev);
 	struct imx214 *imx214 = to_imx214(sd);
 	int ret;
 
 	ret = regulator_bulk_enable(IMX214_NUM_SUPPLIES, imx214->supplies);
 	if (ret < 0) {
-		dev_err(imx214->dev, "failed to enable regulators: %d\n", ret);
+		dev_err(dev, "failed to enable regulators: %d\n", ret);
 		return ret;
 	}
 
@@ -447,7 +446,7 @@ static int __maybe_unused imx214_power_on(struct device *dev)
 	ret = clk_prepare_enable(imx214->xclk);
 	if (ret < 0) {
 		regulator_bulk_disable(IMX214_NUM_SUPPLIES, imx214->supplies);
-		dev_err(imx214->dev, "clk prepare enable failed\n");
+		dev_err(dev, "clk prepare enable failed\n");
 		return ret;
 	}
 
@@ -459,8 +458,7 @@ static int __maybe_unused imx214_power_on(struct device *dev)
 
 static int __maybe_unused imx214_power_off(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+	struct v4l2_subdev *sd = dev_get_drvdata(dev);
 	struct imx214 *imx214 = to_imx214(sd);
 
 	gpiod_set_value_cansleep(imx214->enable_gpio, 0);
@@ -910,8 +908,7 @@ static int imx214_parse_fwnode(struct device *dev)
 
 static int __maybe_unused imx214_suspend(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+	struct v4l2_subdev *sd = dev_get_drvdata(dev);
 	struct imx214 *imx214 = to_imx214(sd);
 
 	if (imx214->streaming)
@@ -922,8 +919,7 @@ static int __maybe_unused imx214_suspend(struct device *dev)
 
 static int __maybe_unused imx214_resume(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+	struct v4l2_subdev *sd = dev_get_drvdata(dev);
 	struct imx214 *imx214 = to_imx214(sd);
 	int ret;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-10-30  9:17 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 02/25] media: i2c: imx219: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 03/25] media: i2c: imx290: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 04/25] media: i2c: imx319: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 05/25] media: i2c: imx319: silence unused acpi_device_id warning Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 06/25] media: i2c: imx355: simplify getting state container Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 07/25] media: i2c: imx355: silence unused acpi_device_id warning Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 08/25] media: i2c: ad5820: simplify getting state container Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 09/25] media: i2c: adp1653: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 10/25] media: i2c: adv7180: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 11/25] media: i2c: ak7375: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 12/25] media: i2c: dw9768: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 13/25] media: i2c: et8ek8: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 14/25] media: i2c: hi556: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 15/25] media: i2c: ov13858: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 16/25] media: i2c: ov2680: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 17/25] media: i2c: ov2685: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 18/25] media: i2c: ov2740: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 19/25] media: i2c: ov5670: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 20/25] media: i2c: ov5675: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 21/25] media: i2c: ov5695: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 22/25] media: i2c: ov7740: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 23/25] media: i2c: ov8856: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 24/25] media: i2c: smiapp: " Krzysztof Kozlowski
2020-10-29 16:42 ` [RESEND PATCH 25/25] media: i2c: tvp5150: " Krzysztof Kozlowski
2020-10-30  9:17 ` [RESEND PATCH 01/25] media: i2c: imx214: " Sakari Ailus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).