From patchwork Thu Oct 29 16:42:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 315137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A764BC4363A for ; Thu, 29 Oct 2020 16:43:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E91920FC3 for ; Thu, 29 Oct 2020 16:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603989781; bh=62tbWUZhtwhdx/5WGWfElJ9O7gQqjsCzRSN58mpUCJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=fUWcHvgxfVmq+PEAYH/19+1neTJ50q7txQ3Z92ZJZF6Q0C2HT3JKGCV+HwpsSESgU 9CXOdI/nV9oWu1u2BMV1tv6TeF9+zOkSP8TLrJqlf/N4w4AX3h1yKveKoRJJKBCMeW WSj1VYHK+2AwT2jobaRzoLR8hwNofZRlIYDi63Is= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726211AbgJ2Qm5 (ORCPT ); Thu, 29 Oct 2020 12:42:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:51308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726051AbgJ2Qmz (ORCPT ); Thu, 29 Oct 2020 12:42:55 -0400 Received: from localhost.localdomain (adsl-84-226-167-205.adslplus.ch [84.226.167.205]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6917D20EDD; Thu, 29 Oct 2020 16:42:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603989775; bh=62tbWUZhtwhdx/5WGWfElJ9O7gQqjsCzRSN58mpUCJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zjhAhCudL6oHOXDXyTrQ7CrZlAAYuHsMUUyo8E1s1AqBt2OoIIKsy0M+HGM0Xj/YR bgkWMGEWdoheuTvEIq7hcDHrs08j0WO1mmKepLaWDTLZBXjmGGABEUXYO5VMMNe896 nZAXbZPQYyQiGUsyBgBcaIvXUl3gAT6GiWwOHdqc= From: Krzysztof Kozlowski 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@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [RESEND PATCH 02/25] media: i2c: imx219: simplify getting state container Date: Thu, 29 Oct 2020 17:42:16 +0100 Message-Id: <20201029164239.84240-2-krzk@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201029164239.84240-1-krzk@kernel.org> References: <20201029164239.84240-1-krzk@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 --- 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;