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

* [RESEND PATCH 02/25] media: i2c: imx219: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 03/25] media: i2c: imx290: " Krzysztof Kozlowski
                   ` (23 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 1cee45e35355..d5349d1ca485 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -1114,22 +1114,21 @@ static int imx219_set_stream(struct v4l2_subdev *sd, int enable)
 /* Power/clock management functions */
 static int imx219_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 imx219 *imx219 = to_imx219(sd);
 	int ret;
 
 	ret = regulator_bulk_enable(IMX219_NUM_SUPPLIES,
 				    imx219->supplies);
 	if (ret) {
-		dev_err(&client->dev, "%s: failed to enable regulators\n",
+		dev_err(dev, "%s: failed to enable regulators\n",
 			__func__);
 		return ret;
 	}
 
 	ret = clk_prepare_enable(imx219->xclk);
 	if (ret) {
-		dev_err(&client->dev, "%s: failed to enable clock\n",
+		dev_err(dev, "%s: failed to enable clock\n",
 			__func__);
 		goto reg_off;
 	}
@@ -1148,8 +1147,7 @@ static int imx219_power_on(struct device *dev)
 
 static int imx219_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 imx219 *imx219 = to_imx219(sd);
 
 	gpiod_set_value_cansleep(imx219->reset_gpio, 0);
@@ -1161,8 +1159,7 @@ static int imx219_power_off(struct device *dev)
 
 static int __maybe_unused imx219_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 imx219 *imx219 = to_imx219(sd);
 
 	if (imx219->streaming)
@@ -1173,8 +1170,7 @@ static int __maybe_unused imx219_suspend(struct device *dev)
 
 static int __maybe_unused imx219_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 imx219 *imx219 = to_imx219(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 03/25] media: i2c: imx290: simplify getting state container
  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 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 04/25] media: i2c: imx319: " Krzysztof Kozlowski
                   ` (22 subsequent siblings)
  24 siblings, 0 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 'imx290->dev'.

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

diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index adcddf3204f7..6319a42057d2 100644
--- a/drivers/media/i2c/imx290.c
+++ b/drivers/media/i2c/imx290.c
@@ -842,20 +842,19 @@ static int imx290_set_data_lanes(struct imx290 *imx290)
 
 static int imx290_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 imx290 *imx290 = to_imx290(sd);
 	int ret;
 
 	ret = clk_prepare_enable(imx290->xclk);
 	if (ret) {
-		dev_err(imx290->dev, "Failed to enable clock\n");
+		dev_err(dev, "Failed to enable clock\n");
 		return ret;
 	}
 
 	ret = regulator_bulk_enable(IMX290_NUM_SUPPLIES, imx290->supplies);
 	if (ret) {
-		dev_err(imx290->dev, "Failed to enable regulators\n");
+		dev_err(dev, "Failed to enable regulators\n");
 		clk_disable_unprepare(imx290->xclk);
 		return ret;
 	}
@@ -872,8 +871,7 @@ static int imx290_power_on(struct device *dev)
 
 static int imx290_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 imx290 *imx290 = to_imx290(sd);
 
 	clk_disable_unprepare(imx290->xclk);
-- 
2.25.1


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

* [RESEND PATCH 04/25] media: i2c: imx319: simplify getting state container
  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 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 05/25] media: i2c: imx319: silence unused acpi_device_id warning Krzysztof Kozlowski
                   ` (21 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c
index 17c2e4b41221..8b86fc65364e 100644
--- a/drivers/media/i2c/imx319.c
+++ b/drivers/media/i2c/imx319.c
@@ -2179,8 +2179,7 @@ static int imx319_set_stream(struct v4l2_subdev *sd, int enable)
 
 static int __maybe_unused imx319_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 imx319 *imx319 = to_imx319(sd);
 
 	if (imx319->streaming)
@@ -2191,8 +2190,7 @@ static int __maybe_unused imx319_suspend(struct device *dev)
 
 static int __maybe_unused imx319_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 imx319 *imx319 = to_imx319(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 05/25] media: i2c: imx319: silence unused acpi_device_id warning
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 04/25] media: i2c: imx319: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 06/25] media: i2c: imx355: simplify getting state container Krzysztof Kozlowski
                   ` (20 subsequent siblings)
  24 siblings, 0 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

If driver is built without ACPI, the struct acpi_device_id won't be
used:

  drivers/media/i2c/imx319.c:2536:36: warning:
    'imx319_acpi_ids' defined but not used [-Wunused-const-variable=]

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/media/i2c/imx319.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c
index 8b86fc65364e..8473c0bbb35d 100644
--- a/drivers/media/i2c/imx319.c
+++ b/drivers/media/i2c/imx319.c
@@ -2533,7 +2533,7 @@ static const struct dev_pm_ops imx319_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(imx319_suspend, imx319_resume)
 };
 
-static const struct acpi_device_id imx319_acpi_ids[] = {
+static const struct acpi_device_id imx319_acpi_ids[] __maybe_unused = {
 	{ "SONY319A" },
 	{ /* sentinel */ }
 };
-- 
2.25.1


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

* [RESEND PATCH 06/25] media: i2c: imx355: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  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 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 07/25] media: i2c: imx355: silence unused acpi_device_id warning Krzysztof Kozlowski
                   ` (19 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c
index bed293b60e50..51245e71b411 100644
--- a/drivers/media/i2c/imx355.c
+++ b/drivers/media/i2c/imx355.c
@@ -1480,8 +1480,7 @@ static int imx355_set_stream(struct v4l2_subdev *sd, int enable)
 
 static int __maybe_unused imx355_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 imx355 *imx355 = to_imx355(sd);
 
 	if (imx355->streaming)
@@ -1492,8 +1491,7 @@ static int __maybe_unused imx355_suspend(struct device *dev)
 
 static int __maybe_unused imx355_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 imx355 *imx355 = to_imx355(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 07/25] media: i2c: imx355: silence unused acpi_device_id warning
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (4 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 06/25] media: i2c: imx355: simplify getting state container Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 08/25] media: i2c: ad5820: simplify getting state container Krzysztof Kozlowski
                   ` (18 subsequent siblings)
  24 siblings, 0 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

If driver is built without ACPI, the struct acpi_device_id won't be
used:

  drivers/media/i2c/imx355.c:1836:36: warning:
    'imx355_acpi_ids' defined but not used [-Wunused-const-variable=]

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/media/i2c/imx355.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c
index 51245e71b411..700f7467fb31 100644
--- a/drivers/media/i2c/imx355.c
+++ b/drivers/media/i2c/imx355.c
@@ -1833,7 +1833,7 @@ static const struct dev_pm_ops imx355_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(imx355_suspend, imx355_resume)
 };
 
-static const struct acpi_device_id imx355_acpi_ids[] = {
+static const struct acpi_device_id imx355_acpi_ids[] __maybe_unused = {
 	{ "SONY355A" },
 	{ /* sentinel */ }
 };
-- 
2.25.1


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

* [RESEND PATCH 08/25] media: i2c: ad5820: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (5 preceding siblings ...)
  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 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 09/25] media: i2c: adp1653: " Krzysztof Kozlowski
                   ` (17 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c
index 19c74db0649f..2958a4694461 100644
--- a/drivers/media/i2c/ad5820.c
+++ b/drivers/media/i2c/ad5820.c
@@ -270,8 +270,7 @@ static const struct v4l2_subdev_internal_ops ad5820_internal_ops = {
  */
 static int __maybe_unused ad5820_suspend(struct device *dev)
 {
-	struct i2c_client *client = container_of(dev, struct i2c_client, dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
+	struct v4l2_subdev *subdev = dev_get_drvdata(dev);
 	struct ad5820_device *coil = to_ad5820_device(subdev);
 
 	if (!coil->power_count)
@@ -282,8 +281,7 @@ static int __maybe_unused ad5820_suspend(struct device *dev)
 
 static int __maybe_unused ad5820_resume(struct device *dev)
 {
-	struct i2c_client *client = container_of(dev, struct i2c_client, dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
+	struct v4l2_subdev *subdev = dev_get_drvdata(dev);
 	struct ad5820_device *coil = to_ad5820_device(subdev);
 
 	if (!coil->power_count)
-- 
2.25.1


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

* [RESEND PATCH 09/25] media: i2c: adp1653: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (6 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 08/25] media: i2c: ad5820: simplify getting state container Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 10/25] media: i2c: adv7180: " Krzysztof Kozlowski
                   ` (16 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 694125a59f64..522a0b10e415 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -379,8 +379,7 @@ static const struct v4l2_subdev_internal_ops adp1653_internal_ops = {
 
 static int adp1653_suspend(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
+	struct v4l2_subdev *subdev = dev_get_drvdata(dev);
 	struct adp1653_flash *flash = to_adp1653_flash(subdev);
 
 	if (!flash->power_count)
@@ -391,8 +390,7 @@ static int adp1653_suspend(struct device *dev)
 
 static int adp1653_resume(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
+	struct v4l2_subdev *subdev = dev_get_drvdata(dev);
 	struct adp1653_flash *flash = to_adp1653_flash(subdev);
 
 	if (!flash->power_count)
-- 
2.25.1


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

* [RESEND PATCH 10/25] media: i2c: adv7180: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (7 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 09/25] media: i2c: adp1653: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 11/25] media: i2c: ak7375: " Krzysztof Kozlowski
                   ` (15 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 4498d14d3429..44bb6fe85644 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1454,8 +1454,7 @@ MODULE_DEVICE_TABLE(i2c, adv7180_id);
 #ifdef CONFIG_PM_SLEEP
 static int adv7180_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 adv7180_state *state = to_state(sd);
 
 	return adv7180_set_power(state, false);
@@ -1463,8 +1462,7 @@ static int adv7180_suspend(struct device *dev)
 
 static int adv7180_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 adv7180_state *state = to_state(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 11/25] media: i2c: ak7375: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (8 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 10/25] media: i2c: adv7180: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 12/25] media: i2c: dw9768: " Krzysztof Kozlowski
                   ` (14 subsequent siblings)
  24 siblings, 0 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.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/media/i2c/ak7375.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/ak7375.c b/drivers/media/i2c/ak7375.c
index 7b14b11605ca..e1f94ee0f48f 100644
--- a/drivers/media/i2c/ak7375.c
+++ b/drivers/media/i2c/ak7375.c
@@ -196,9 +196,7 @@ static int ak7375_remove(struct i2c_client *client)
  */
 static int __maybe_unused ak7375_vcm_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 ak7375_device *ak7375_dev = sd_to_ak7375_vcm(sd);
 	int ret, val;
 
@@ -233,8 +231,7 @@ static int __maybe_unused ak7375_vcm_suspend(struct device *dev)
  */
 static int __maybe_unused ak7375_vcm_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 ak7375_device *ak7375_dev = sd_to_ak7375_vcm(sd);
 	int ret, val;
 
-- 
2.25.1


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

* [RESEND PATCH 12/25] media: i2c: dw9768: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (9 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 11/25] media: i2c: ak7375: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 13/25] media: i2c: et8ek8: " Krzysztof Kozlowski
                   ` (13 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/dw9768.c b/drivers/media/i2c/dw9768.c
index 45cdd924b565..8b8cb4b077b5 100644
--- a/drivers/media/i2c/dw9768.c
+++ b/drivers/media/i2c/dw9768.c
@@ -315,8 +315,7 @@ static int dw9768_release(struct dw9768 *dw9768)
 
 static int dw9768_runtime_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 dw9768 *dw9768 = sd_to_dw9768(sd);
 
 	dw9768_release(dw9768);
@@ -328,8 +327,7 @@ static int dw9768_runtime_suspend(struct device *dev)
 
 static int dw9768_runtime_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 dw9768 *dw9768 = sd_to_dw9768(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 13/25] media: i2c: et8ek8: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (10 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 12/25] media: i2c: dw9768: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 14/25] media: i2c: hi556: " Krzysztof Kozlowski
                   ` (12 subsequent siblings)
  24 siblings, 0 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.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/media/i2c/et8ek8/et8ek8_driver.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/et8ek8/et8ek8_driver.c b/drivers/media/i2c/et8ek8/et8ek8_driver.c
index 256acf73d5ea..122af761c8e3 100644
--- a/drivers/media/i2c/et8ek8/et8ek8_driver.c
+++ b/drivers/media/i2c/et8ek8/et8ek8_driver.c
@@ -1237,7 +1237,7 @@ static ssize_t
 et8ek8_priv_mem_read(struct device *dev, struct device_attribute *attr,
 		     char *buf)
 {
-	struct v4l2_subdev *subdev = i2c_get_clientdata(to_i2c_client(dev));
+	struct v4l2_subdev *subdev = dev_get_drvdata(dev);
 	struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
 
 #if PAGE_SIZE < ET8EK8_PRIV_MEM_SIZE
@@ -1374,8 +1374,7 @@ static const struct v4l2_subdev_internal_ops et8ek8_internal_ops = {
  */
 static int __maybe_unused et8ek8_suspend(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
+	struct v4l2_subdev *subdev = dev_get_drvdata(dev);
 	struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
 
 	if (!sensor->power_count)
@@ -1386,8 +1385,7 @@ static int __maybe_unused et8ek8_suspend(struct device *dev)
 
 static int __maybe_unused et8ek8_resume(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
+	struct v4l2_subdev *subdev = dev_get_drvdata(dev);
 	struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
 
 	if (!sensor->power_count)
-- 
2.25.1


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

* [RESEND PATCH 14/25] media: i2c: hi556: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (11 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 13/25] media: i2c: et8ek8: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 15/25] media: i2c: ov13858: " Krzysztof Kozlowski
                   ` (11 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/hi556.c b/drivers/media/i2c/hi556.c
index c66cd1446c0f..c74736845d7a 100644
--- a/drivers/media/i2c/hi556.c
+++ b/drivers/media/i2c/hi556.c
@@ -839,8 +839,7 @@ static int hi556_set_stream(struct v4l2_subdev *sd, int enable)
 
 static int __maybe_unused hi556_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 hi556 *hi556 = to_hi556(sd);
 
 	mutex_lock(&hi556->mutex);
@@ -854,8 +853,7 @@ static int __maybe_unused hi556_suspend(struct device *dev)
 
 static int __maybe_unused hi556_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 hi556 *hi556 = to_hi556(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 15/25] media: i2c: ov13858: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (12 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 14/25] media: i2c: hi556: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 16/25] media: i2c: ov2680: " Krzysztof Kozlowski
                   ` (10 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c
index 236ad2c816b7..2f3be7a80cef 100644
--- a/drivers/media/i2c/ov13858.c
+++ b/drivers/media/i2c/ov13858.c
@@ -1505,8 +1505,7 @@ static int ov13858_set_stream(struct v4l2_subdev *sd, int enable)
 
 static int __maybe_unused ov13858_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 ov13858 *ov13858 = to_ov13858(sd);
 
 	if (ov13858->streaming)
@@ -1517,8 +1516,7 @@ static int __maybe_unused ov13858_suspend(struct device *dev)
 
 static int __maybe_unused ov13858_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 ov13858 *ov13858 = to_ov13858(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 16/25] media: i2c: ov2680: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (13 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 15/25] media: i2c: ov13858: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 17/25] media: i2c: ov2685: " Krzysztof Kozlowski
                   ` (9 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index 59cdbc33658c..178dfe985a25 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -1111,8 +1111,7 @@ static int ov2680_remove(struct i2c_client *client)
 
 static int __maybe_unused ov2680_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 ov2680_dev *sensor = to_ov2680_dev(sd);
 
 	if (sensor->is_streaming)
@@ -1123,8 +1122,7 @@ static int __maybe_unused ov2680_suspend(struct device *dev)
 
 static int __maybe_unused ov2680_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 ov2680_dev *sensor = to_ov2680_dev(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 17/25] media: i2c: ov2685: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (14 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 16/25] media: i2c: ov2680: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 18/25] media: i2c: ov2740: " Krzysztof Kozlowski
                   ` (8 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
index 6814583d9606..49a2dcedb347 100644
--- a/drivers/media/i2c/ov2685.c
+++ b/drivers/media/i2c/ov2685.c
@@ -506,8 +506,7 @@ static int ov2685_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 
 static int __maybe_unused ov2685_runtime_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 ov2685 *ov2685 = to_ov2685(sd);
 
 	return __ov2685_power_on(ov2685);
@@ -515,8 +514,7 @@ static int __maybe_unused ov2685_runtime_resume(struct device *dev)
 
 static int __maybe_unused ov2685_runtime_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 ov2685 *ov2685 = to_ov2685(sd);
 
 	__ov2685_power_off(ov2685);
-- 
2.25.1


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

* [RESEND PATCH 18/25] media: i2c: ov2740: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (15 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 17/25] media: i2c: ov2685: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 19/25] media: i2c: ov5670: " Krzysztof Kozlowski
                   ` (7 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index bd0d45b0d43f..0d32b0c0ca11 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -674,8 +674,7 @@ static int ov2740_set_stream(struct v4l2_subdev *sd, int enable)
 
 static int __maybe_unused ov2740_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 ov2740 *ov2740 = to_ov2740(sd);
 
 	mutex_lock(&ov2740->mutex);
@@ -689,8 +688,7 @@ static int __maybe_unused ov2740_suspend(struct device *dev)
 
 static int __maybe_unused ov2740_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 ov2740 *ov2740 = to_ov2740(sd);
 	int ret = 0;
 
-- 
2.25.1


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

* [RESEND PATCH 19/25] media: i2c: ov5670: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (16 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 18/25] media: i2c: ov2740: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 20/25] media: i2c: ov5675: " Krzysztof Kozlowski
                   ` (6 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
index f26252e35e08..148fd4e05029 100644
--- a/drivers/media/i2c/ov5670.c
+++ b/drivers/media/i2c/ov5670.c
@@ -2373,8 +2373,7 @@ static int ov5670_set_stream(struct v4l2_subdev *sd, int enable)
 
 static int __maybe_unused ov5670_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 ov5670 *ov5670 = to_ov5670(sd);
 
 	if (ov5670->streaming)
@@ -2385,8 +2384,7 @@ static int __maybe_unused ov5670_suspend(struct device *dev)
 
 static int __maybe_unused ov5670_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 ov5670 *ov5670 = to_ov5670(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 20/25] media: i2c: ov5675: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (17 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 19/25] media: i2c: ov5670: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 21/25] media: i2c: ov5695: " Krzysztof Kozlowski
                   ` (5 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/ov5675.c b/drivers/media/i2c/ov5675.c
index 9540ce8918f0..5e35808037ad 100644
--- a/drivers/media/i2c/ov5675.c
+++ b/drivers/media/i2c/ov5675.c
@@ -889,8 +889,7 @@ static int ov5675_set_stream(struct v4l2_subdev *sd, int enable)
 
 static int __maybe_unused ov5675_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 ov5675 *ov5675 = to_ov5675(sd);
 
 	mutex_lock(&ov5675->mutex);
@@ -904,8 +903,7 @@ static int __maybe_unused ov5675_suspend(struct device *dev)
 
 static int __maybe_unused ov5675_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 ov5675 *ov5675 = to_ov5675(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 21/25] media: i2c: ov5695: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (18 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 20/25] media: i2c: ov5675: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 22/25] media: i2c: ov7740: " Krzysztof Kozlowski
                   ` (4 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
index cc678d9d2e0d..bbccb6f9582f 100644
--- a/drivers/media/i2c/ov5695.c
+++ b/drivers/media/i2c/ov5695.c
@@ -1033,8 +1033,7 @@ static void __ov5695_power_off(struct ov5695 *ov5695)
 
 static int __maybe_unused ov5695_runtime_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 ov5695 *ov5695 = to_ov5695(sd);
 
 	return __ov5695_power_on(ov5695);
@@ -1042,8 +1041,7 @@ static int __maybe_unused ov5695_runtime_resume(struct device *dev)
 
 static int __maybe_unused ov5695_runtime_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 ov5695 *ov5695 = to_ov5695(sd);
 
 	__ov5695_power_off(ov5695);
-- 
2.25.1


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

* [RESEND PATCH 22/25] media: i2c: ov7740: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (19 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 21/25] media: i2c: ov5695: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 23/25] media: i2c: ov8856: " Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c
index 5832461c032d..47a9003d29d6 100644
--- a/drivers/media/i2c/ov7740.c
+++ b/drivers/media/i2c/ov7740.c
@@ -1176,8 +1176,7 @@ static int ov7740_remove(struct i2c_client *client)
 
 static int __maybe_unused ov7740_runtime_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 ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
 
 	ov7740_set_power(ov7740, 0);
@@ -1187,8 +1186,7 @@ static int __maybe_unused ov7740_runtime_suspend(struct device *dev)
 
 static int __maybe_unused ov7740_runtime_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 ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
 
 	return ov7740_set_power(ov7740, 1);
-- 
2.25.1


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

* [RESEND PATCH 23/25] media: i2c: ov8856: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (20 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 22/25] media: i2c: ov7740: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-29 16:42 ` [RESEND PATCH 24/25] media: i2c: smiapp: " Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c
index 2f4ceaa80593..d8cefd3d4045 100644
--- a/drivers/media/i2c/ov8856.c
+++ b/drivers/media/i2c/ov8856.c
@@ -1417,8 +1417,7 @@ static void __ov8856_power_off(struct ov8856 *ov8856)
 
 static int __maybe_unused ov8856_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 ov8856 *ov8856 = to_ov8856(sd);
 
 	mutex_lock(&ov8856->mutex);
@@ -1433,8 +1432,7 @@ static int __maybe_unused ov8856_suspend(struct device *dev)
 
 static int __maybe_unused ov8856_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 ov8856 *ov8856 = to_ov8856(sd);
 	int ret;
 
-- 
2.25.1


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

* [RESEND PATCH 24/25] media: i2c: smiapp: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (21 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 23/25] media: i2c: ov8856: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` 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
  24 siblings, 0 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.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/media/i2c/smiapp/smiapp-core.c | 28 ++++++++++++--------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 6fc0680a93d0..105ef29152e8 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -1185,8 +1185,7 @@ static int smiapp_setup_flash_strobe(struct smiapp_sensor *sensor)
 
 static int smiapp_power_on(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
+	struct v4l2_subdev *subdev = dev_get_drvdata(dev);
 	struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
 	/*
 	 * The sub-device related to the I2C device is always the
@@ -1199,14 +1198,14 @@ static int smiapp_power_on(struct device *dev)
 
 	rval = regulator_enable(sensor->vana);
 	if (rval) {
-		dev_err(&client->dev, "failed to enable vana regulator\n");
+		dev_err(dev, "failed to enable vana regulator\n");
 		return rval;
 	}
 	usleep_range(1000, 1000);
 
 	rval = clk_prepare_enable(sensor->ext_clk);
 	if (rval < 0) {
-		dev_dbg(&client->dev, "failed to enable xclk\n");
+		dev_dbg(dev, "failed to enable xclk\n");
 		goto out_xclk_fail;
 	}
 	usleep_range(1000, 1000);
@@ -1230,7 +1229,7 @@ static int smiapp_power_on(struct device *dev)
 	if (sensor->hwcfg->i2c_addr_alt) {
 		rval = smiapp_change_cci_addr(sensor);
 		if (rval) {
-			dev_err(&client->dev, "cci address change error\n");
+			dev_err(dev, "cci address change error\n");
 			goto out_cci_addr_fail;
 		}
 	}
@@ -1238,14 +1237,14 @@ static int smiapp_power_on(struct device *dev)
 	rval = smiapp_write(sensor, SMIAPP_REG_U8_SOFTWARE_RESET,
 			    SMIAPP_SOFTWARE_RESET);
 	if (rval < 0) {
-		dev_err(&client->dev, "software reset failed\n");
+		dev_err(dev, "software reset failed\n");
 		goto out_cci_addr_fail;
 	}
 
 	if (sensor->hwcfg->i2c_addr_alt) {
 		rval = smiapp_change_cci_addr(sensor);
 		if (rval) {
-			dev_err(&client->dev, "cci address change error\n");
+			dev_err(dev, "cci address change error\n");
 			goto out_cci_addr_fail;
 		}
 	}
@@ -1253,7 +1252,7 @@ static int smiapp_power_on(struct device *dev)
 	rval = smiapp_write(sensor, SMIAPP_REG_U16_COMPRESSION_MODE,
 			    SMIAPP_COMPRESSION_MODE_SIMPLE_PREDICTOR);
 	if (rval) {
-		dev_err(&client->dev, "compression mode set failed\n");
+		dev_err(dev, "compression mode set failed\n");
 		goto out_cci_addr_fail;
 	}
 
@@ -1261,28 +1260,28 @@ static int smiapp_power_on(struct device *dev)
 		sensor, SMIAPP_REG_U16_EXTCLK_FREQUENCY_MHZ,
 		sensor->hwcfg->ext_clk / (1000000 / (1 << 8)));
 	if (rval) {
-		dev_err(&client->dev, "extclk frequency set failed\n");
+		dev_err(dev, "extclk frequency set failed\n");
 		goto out_cci_addr_fail;
 	}
 
 	rval = smiapp_write(sensor, SMIAPP_REG_U8_CSI_LANE_MODE,
 			    sensor->hwcfg->lanes - 1);
 	if (rval) {
-		dev_err(&client->dev, "csi lane mode set failed\n");
+		dev_err(dev, "csi lane mode set failed\n");
 		goto out_cci_addr_fail;
 	}
 
 	rval = smiapp_write(sensor, SMIAPP_REG_U8_FAST_STANDBY_CTRL,
 			    SMIAPP_FAST_STANDBY_CTRL_IMMEDIATE);
 	if (rval) {
-		dev_err(&client->dev, "fast standby set failed\n");
+		dev_err(dev, "fast standby set failed\n");
 		goto out_cci_addr_fail;
 	}
 
 	rval = smiapp_write(sensor, SMIAPP_REG_U8_CSI_SIGNALLING_MODE,
 			    sensor->hwcfg->csi_signalling_mode);
 	if (rval) {
-		dev_err(&client->dev, "csi signalling mode set failed\n");
+		dev_err(dev, "csi signalling mode set failed\n");
 		goto out_cci_addr_fail;
 	}
 
@@ -1294,7 +1293,7 @@ static int smiapp_power_on(struct device *dev)
 
 	rval = smiapp_call_quirk(sensor, post_poweron);
 	if (rval) {
-		dev_err(&client->dev, "post_poweron quirks failed\n");
+		dev_err(dev, "post_poweron quirks failed\n");
 		goto out_cci_addr_fail;
 	}
 
@@ -1312,8 +1311,7 @@ static int smiapp_power_on(struct device *dev)
 
 static int smiapp_power_off(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
+	struct v4l2_subdev *subdev = dev_get_drvdata(dev);
 	struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
 	struct smiapp_sensor *sensor =
 		container_of(ssd, struct smiapp_sensor, ssds[0]);
-- 
2.25.1


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

* [RESEND PATCH 25/25] media: i2c: tvp5150: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (22 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 24/25] media: i2c: smiapp: " Krzysztof Kozlowski
@ 2020-10-29 16:42 ` Krzysztof Kozlowski
  2020-10-30  9:17 ` [RESEND PATCH 01/25] media: i2c: imx214: " Sakari Ailus
  24 siblings, 0 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.

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

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 7d9401219a3a..29f65bb6103d 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1413,8 +1413,7 @@ static const struct media_entity_operations tvp5150_sd_media_ops = {
  ****************************************************************************/
 static int __maybe_unused tvp5150_runtime_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 tvp5150 *decoder = to_tvp5150(sd);
 
 	if (decoder->irq)
@@ -1427,8 +1426,7 @@ static int __maybe_unused tvp5150_runtime_suspend(struct device *dev)
 
 static int __maybe_unused tvp5150_runtime_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 tvp5150 *decoder = to_tvp5150(sd);
 
 	if (decoder->irq)
-- 
2.25.1


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

* Re: [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container
  2020-10-29 16:42 [RESEND PATCH 01/25] media: i2c: imx214: simplify getting state container Krzysztof Kozlowski
                   ` (23 preceding siblings ...)
  2020-10-29 16:42 ` [RESEND PATCH 25/25] media: i2c: tvp5150: " Krzysztof Kozlowski
@ 2020-10-30  9:17 ` Sakari Ailus
  24 siblings, 0 replies; 26+ messages in thread
From: Sakari Ailus @ 2020-10-30  9:17 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Pavel Machek, 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

Hi Krzysztof,

On Thu, Oct 29, 2020 at 05:42:15PM +0100, Krzysztof Kozlowski wrote:
> 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>

I've applied the original set to my tree here:

<URL:https://git.linuxtv.org/sailus/media_tree.git/log/>

The status of the patches is generally indicated in Patchwork:

<URL:https://patchwork.linuxtv.org/project/linux-media/list/>

"Under review" effectively, but perhaps confusingly, is also used to tell
that the patch is in someone else's tree and on its way to Mauro's. IOW, it
is not necessary to resend them.

-- 
Regards,

Sakari Ailus

^ permalink raw reply	[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).