diff mbox series

[RESEND,01/25] media: i2c: imx214: simplify getting state container

Message ID 20201029164239.84240-1-krzk@kernel.org
State New
Headers show
Series [RESEND,01/25] media: i2c: imx214: simplify getting state container | expand

Commit Message

Krzysztof Kozlowski Oct. 29, 2020, 4:42 p.m. UTC
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(-)

Comments

Sakari Ailus Oct. 30, 2020, 9:17 a.m. UTC | #1
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
diff mbox series

Patch

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;