From patchwork Tue Jul 26 12:05:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 593671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 477FEC433EF for ; Tue, 26 Jul 2022 12:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239047AbiGZMF7 (ORCPT ); Tue, 26 Jul 2022 08:05:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233080AbiGZMFz (ORCPT ); Tue, 26 Jul 2022 08:05:55 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 246E62AC6D; Tue, 26 Jul 2022 05:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658837155; x=1690373155; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=MJcfMMw6vibpVnMNINqRvTa/7DV3eje+x+g9lq2jXNg=; b=ROT+jCB82bXvDUhA5uKEDlSQ+ltpq6HMJi1W7H8l3XOVzDgVtMkGb5O0 qsl0X33d04vGVqGcrSL6z0gKIjCp0syHo3G7eIkBkRQQKF6d3py0n4Twf 6IFzViIZNm0tOImXPkEzywthCsA6efDowYhVdEzvXWXA5Bb8W4arwxCCy tl1B1vrvhmG+GVVfEGiOJ9xBvbZrP9gUJauFJ6QpWQB1WJ7qnbhILCJZu hjIY6eze1PUvAoa1J6sGvt/GAAHKEbD9yN+GiY3/sLeS4e4afabp59uII 5ytDGr1q8btk+0idDjYkSvOUEwzY0eaJbW0btbcGBgRVB7GBH/acTPGJ/ g==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="270971287" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="270971287" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2022 05:05:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="702871731" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 26 Jul 2022 05:05:52 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 501E8F1; Tue, 26 Jul 2022 15:06:02 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianshu Qiu , Shawn Tu , Bingbu Cao , Mauro Carvalho Chehab Subject: [PATCH v1 1/8] media: ov2740: Remove duplicative pointer in struct nvm_data Date: Tue, 26 Jul 2022 15:05:49 +0300 Message-Id: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The struct i2c_client pointer is used only to get driver data, associated with a struct device or print messages on behalf. Moreover, the very same pointer to a struct device is already assigned by a regmap and can be retrieved from there. No need to keep a duplicative pointer. Signed-off-by: Andy Shevchenko Reviewed-by: Bingbu Cao Reviewed-by: Bingbu Cao --- drivers/media/i2c/ov2740.c | 39 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index d5f0eabf20c6..c975db1bbe8c 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -77,7 +77,6 @@ #define OV2740_REG_OTP_CUSTOMER 0x7010 struct nvm_data { - struct i2c_client *client; struct nvmem_device *nvmem; struct regmap *regmap; char *nvm_buffer; @@ -649,34 +648,28 @@ static void ov2740_update_pad_format(const struct ov2740_mode *mode, static int ov2740_load_otp_data(struct nvm_data *nvm) { - struct i2c_client *client; - struct ov2740 *ov2740; + struct device *dev = regmap_get_device(nvm->regmap); + struct ov2740 *ov2740 = to_ov2740(dev_get_drvdata(dev)); u32 isp_ctrl00 = 0; u32 isp_ctrl01 = 0; int ret; - if (!nvm) - return -EINVAL; - if (nvm->nvm_buffer) return 0; - client = nvm->client; - ov2740 = to_ov2740(i2c_get_clientdata(client)); - nvm->nvm_buffer = kzalloc(CUSTOMER_USE_OTP_SIZE, GFP_KERNEL); if (!nvm->nvm_buffer) return -ENOMEM; ret = ov2740_read_reg(ov2740, OV2740_REG_ISP_CTRL00, 1, &isp_ctrl00); if (ret) { - dev_err(&client->dev, "failed to read ISP CTRL00\n"); + dev_err(dev, "failed to read ISP CTRL00\n"); goto err; } ret = ov2740_read_reg(ov2740, OV2740_REG_ISP_CTRL01, 1, &isp_ctrl01); if (ret) { - dev_err(&client->dev, "failed to read ISP CTRL01\n"); + dev_err(dev, "failed to read ISP CTRL01\n"); goto err; } @@ -684,7 +677,7 @@ static int ov2740_load_otp_data(struct nvm_data *nvm) ret = ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL00, 1, isp_ctrl00 & ~BIT(5)); if (ret) { - dev_err(&client->dev, "failed to set ISP CTRL00\n"); + dev_err(dev, "failed to set ISP CTRL00\n"); goto err; } @@ -692,14 +685,14 @@ static int ov2740_load_otp_data(struct nvm_data *nvm) ret = ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL01, 1, isp_ctrl01 & ~BIT(7)); if (ret) { - dev_err(&client->dev, "failed to set ISP CTRL01\n"); + dev_err(dev, "failed to set ISP CTRL01\n"); goto err; } ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1, OV2740_MODE_STREAMING); if (ret) { - dev_err(&client->dev, "failed to set streaming mode\n"); + dev_err(dev, "failed to set streaming mode\n"); goto err; } @@ -712,26 +705,26 @@ static int ov2740_load_otp_data(struct nvm_data *nvm) ret = regmap_bulk_read(nvm->regmap, OV2740_REG_OTP_CUSTOMER, nvm->nvm_buffer, CUSTOMER_USE_OTP_SIZE); if (ret) { - dev_err(&client->dev, "failed to read OTP data, ret %d\n", ret); + dev_err(dev, "failed to read OTP data, ret %d\n", ret); goto err; } ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1, OV2740_MODE_STANDBY); if (ret) { - dev_err(&client->dev, "failed to set streaming mode\n"); + dev_err(dev, "failed to set streaming mode\n"); goto err; } ret = ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL01, 1, isp_ctrl01); if (ret) { - dev_err(&client->dev, "failed to set ISP CTRL01\n"); + dev_err(dev, "failed to set ISP CTRL01\n"); goto err; } ret = ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL00, 1, isp_ctrl00); if (ret) { - dev_err(&client->dev, "failed to set ISP CTRL00\n"); + dev_err(dev, "failed to set ISP CTRL00\n"); goto err; } @@ -746,7 +739,6 @@ static int ov2740_load_otp_data(struct nvm_data *nvm) static int ov2740_start_streaming(struct ov2740 *ov2740) { struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd); - struct nvm_data *nvm = ov2740->nvm; const struct ov2740_reg_list *reg_list; int link_freq_index; int ret = 0; @@ -755,7 +747,8 @@ static int ov2740_start_streaming(struct ov2740 *ov2740) if (ret) return ret; - ov2740_load_otp_data(nvm); + if (ov2740->nvm) + ov2740_load_otp_data(ov2740->nvm); link_freq_index = ov2740->cur_mode->link_freq_index; reg_list = &link_freq_configs[link_freq_index].reg_list; @@ -1071,9 +1064,8 @@ static int ov2740_nvmem_read(void *priv, unsigned int off, void *val, size_t count) { struct nvm_data *nvm = priv; - struct v4l2_subdev *sd = i2c_get_clientdata(nvm->client); - struct device *dev = &nvm->client->dev; - struct ov2740 *ov2740 = to_ov2740(sd); + struct device *dev = regmap_get_device(nvm->regmap); + struct ov2740 *ov2740 = to_ov2740(dev_get_drvdata(dev)); int ret = 0; mutex_lock(&ov2740->mutex); @@ -1120,7 +1112,6 @@ static int ov2740_register_nvmem(struct i2c_client *client, return PTR_ERR(regmap); nvm->regmap = regmap; - nvm->client = client; nvmem_config.name = dev_name(dev); nvmem_config.dev = dev; From patchwork Tue Jul 26 12:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 593672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A75DCCA47E for ; Tue, 26 Jul 2022 12:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239024AbiGZMF4 (ORCPT ); Tue, 26 Jul 2022 08:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232678AbiGZMFz (ORCPT ); Tue, 26 Jul 2022 08:05:55 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D7F714008; Tue, 26 Jul 2022 05:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658837154; x=1690373154; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jMC2wNGyqJFQfBamjOwEaaiV4YpyT3KOmIURe2y6h6U=; b=X8AmgrsL3mix3YyCOk3YocMksYLpgJ05+peM1yymXF8ccswIHE3cTIGe L95njfrNpIgTbPdWC2rA6akUYT1wQqihKGwVwfFnUeIuZEtpWG98u70yp Al3/soEYF48RYPEvpR9jJS4bS64lOJ1bfDhQ7TxaiLUTlo2tQ4N5I4Sqb W8gLIf04Fbwf9Dkr2pcRkD5v7du85ZIiJM3dPDEAdR4lRaIbKp05zJWrd RknMDML3J9zAa/rm7Qz9WiPHmggC5NtBL4FECQyfGOdbrq/TSro5TruVE PZkEfiZih7v9ksvJtUneRQ/z08Y8Jw4cOLGnsCkCvcGmXLUeM3RT6oqca g==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="267703529" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="267703529" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2022 05:05:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="845854992" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 26 Jul 2022 05:05:52 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5DBAB86; Tue, 26 Jul 2022 15:06:02 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianshu Qiu , Shawn Tu , Bingbu Cao , Mauro Carvalho Chehab Subject: [PATCH v1 2/8] media: ov2740: Replace voodoo coding with understandle flow Date: Tue, 26 Jul 2022 15:05:50 +0300 Message-Id: <20220726120556.2881-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> References: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Besides not being understandable at the first glance, the code might provoke a compiler or a static analyser tool to warn about out-of-bound access (when len == 0). Replace it with clear flow an understandable intention. Signed-off-by: Andy Shevchenko Reviewed-by: Bingbu Cao --- drivers/media/i2c/ov2740.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index c975db1bbe8c..81c0ab220339 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -377,10 +377,10 @@ static int ov2740_read_reg(struct ov2740 *ov2740, u16 reg, u16 len, u32 *val) struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd); struct i2c_msg msgs[2]; u8 addr_buf[2]; - u8 data_buf[4] = {0}; + u8 data_buf[4]; int ret = 0; - if (len > sizeof(data_buf)) + if (len > 4) return -EINVAL; put_unaligned_be16(reg, addr_buf); @@ -391,13 +391,22 @@ static int ov2740_read_reg(struct ov2740 *ov2740, u16 reg, u16 len, u32 *val) msgs[1].addr = client->addr; msgs[1].flags = I2C_M_RD; msgs[1].len = len; - msgs[1].buf = &data_buf[sizeof(data_buf) - len]; + msgs[1].buf = data_buf; ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); if (ret != ARRAY_SIZE(msgs)) return ret < 0 ? ret : -EIO; - *val = get_unaligned_be32(data_buf); + if (len == 4) + *val = get_unaligned_be32(data_buf); + else if (len == 3) + *val = get_unaligned_be24(data_buf); + else if (len == 2) + *val = get_unaligned_be16(data_buf); + else if (len == 1) + *val = data_buf[0]; + else + return -EINVAL; return 0; } @@ -412,7 +421,16 @@ static int ov2740_write_reg(struct ov2740 *ov2740, u16 reg, u16 len, u32 val) return -EINVAL; put_unaligned_be16(reg, buf); - put_unaligned_be32(val << 8 * (4 - len), buf + 2); + if (len == 4) + put_unaligned_be32(val, buf + 2); + else if (len == 3) + put_unaligned_be24(val, buf + 2); + else if (len == 2) + put_unaligned_be16(val, buf + 2); + else if (len == 1) + buf[2] = val; + else + return -EINVAL; ret = i2c_master_send(client, buf, len + 2); if (ret != len + 2) From patchwork Tue Jul 26 12:05:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 593946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A3D1C43334 for ; Tue, 26 Jul 2022 12:06:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239057AbiGZMGA (ORCPT ); Tue, 26 Jul 2022 08:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238994AbiGZMF4 (ORCPT ); Tue, 26 Jul 2022 08:05:56 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E82F814008; Tue, 26 Jul 2022 05:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658837155; x=1690373155; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IUSEatphJXrxHtFATG8DqV4oMhLluYvQE60yRglB11c=; b=Ylpe4xrJ2Y1aRdS1iHvguK5GOO8nhco7acZOMn8/AQ01jolQ2EbHDs2Y a0Jtp2BQ8iV4KeyZHWJZRj+TGZUk2KX7a9HC4FFrp8PbjU4a31kZWxsfY VdwqfJpJL+zcBnD+mbFshdCHmICUpOFZRFsvE/TOWvxnCDyYNQxIN7XKz WfJHMTuRmACvkeicv8/2CBqfOiYmlqZvT3m9quyB3c/8uxjc4n4Ku+gPE Z0+TMupC/Px+e4+9tW2gUQ24u4/uGukYxl+3MLMSuH5TBYpiULa6b4q3y S4O4mh1lWzRSGsvZjQBKm4OfnJVS24c6PXFkLZdOK3ABDZsz7Ow2wLIWE A==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="270971289" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="270971289" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2022 05:05:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="702871733" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 26 Jul 2022 05:05:52 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 64AC511C; Tue, 26 Jul 2022 15:06:02 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianshu Qiu , Shawn Tu , Bingbu Cao , Mauro Carvalho Chehab Subject: [PATCH v1 3/8] media: ov2740: Switch from __maybe_unused to pm_sleep_ptr() etc Date: Tue, 26 Jul 2022 15:05:51 +0300 Message-Id: <20220726120556.2881-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> References: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less heavier for builds than the use of __maybe_unused attributes. Signed-off-by: Andy Shevchenko --- drivers/media/i2c/ov2740.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index 81c0ab220339..9420258c6073 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -838,7 +838,7 @@ static int ov2740_set_stream(struct v4l2_subdev *sd, int enable) return ret; } -static int __maybe_unused ov2740_suspend(struct device *dev) +static int ov2740_suspend(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct ov2740 *ov2740 = to_ov2740(sd); @@ -852,7 +852,7 @@ static int __maybe_unused ov2740_suspend(struct device *dev) return 0; } -static int __maybe_unused ov2740_resume(struct device *dev) +static int ov2740_resume(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct ov2740 *ov2740 = to_ov2740(sd); @@ -1229,9 +1229,7 @@ static int ov2740_probe(struct i2c_client *client) return ret; } -static const struct dev_pm_ops ov2740_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(ov2740_suspend, ov2740_resume) -}; +static DEFINE_SIMPLE_DEV_PM_OPS(ov2740_pm_ops, ov2740_suspend, ov2740_resume); static const struct acpi_device_id ov2740_acpi_ids[] = { {"INT3474"}, @@ -1243,7 +1241,7 @@ MODULE_DEVICE_TABLE(acpi, ov2740_acpi_ids); static struct i2c_driver ov2740_i2c_driver = { .driver = { .name = "ov2740", - .pm = &ov2740_pm_ops, + .pm = pm_sleep_ptr(&ov2740_pm_ops), .acpi_match_table = ov2740_acpi_ids, }, .probe_new = ov2740_probe, From patchwork Tue Jul 26 12:05:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 593947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42AB3C43334 for ; Tue, 26 Jul 2022 12:05:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbiGZMF6 (ORCPT ); Tue, 26 Jul 2022 08:05:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232953AbiGZMFz (ORCPT ); Tue, 26 Jul 2022 08:05:55 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 542F72AE08; Tue, 26 Jul 2022 05:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658837155; x=1690373155; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dErGB4TIKDepZJW1i+iaXrBp16cjYh5ghvqazNtEIuM=; b=ThAJQc1V671PPDzSSd7RTI/Yn1RpvpD8KhFii4/YurGBOegskw9rOsn2 3ISK3nWueUqkBnu5GZ8NwfH3QumyB0FBay9voa0O0iwIxW4TKnLjVtiT/ 3XvhDhboH0OSsUaO5egpJ0f/AdNTMaoD0X99Cb50a3zgzop2Xja/+CdMI LV+wHdemf4qwZRK/4tACeESPwSB2R/YoDUgDv5b7dzdS3WFnhyv5p6SWL uV1urYE88HmyvBVHhu/L903Esh0wznT98YJCV8xm9B7XlUFu8nXUzZsn+ Qlcj4heICAXyloCTOgSlUYt5I4hRsQXf7OgHwatizSaRxmilfI1b+Z8n0 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="274804291" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="274804291" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2022 05:05:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="667879823" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 26 Jul 2022 05:05:52 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6BCAC1D0; Tue, 26 Jul 2022 15:06:02 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianshu Qiu , Shawn Tu , Bingbu Cao , Mauro Carvalho Chehab Subject: [PATCH v1 4/8] media: ov2740: Remove duplicate check for NULL fwnode Date: Tue, 26 Jul 2022 15:05:52 +0300 Message-Id: <20220726120556.2881-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> References: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org fwnode API does proper checks and returns correct codes, no need to repeat it in the caller. Signed-off-by: Andy Shevchenko --- drivers/media/i2c/ov2740.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index 9420258c6073..07fe8fda274e 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -1009,9 +1009,6 @@ static int ov2740_check_hwcfg(struct device *dev) int ret; unsigned int i, j; - if (!fwnode) - return -ENXIO; - ret = fwnode_property_read_u32(fwnode, "clock-frequency", &mclk); if (ret) return ret; From patchwork Tue Jul 26 12:05:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 593948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AD0DC43334 for ; Tue, 26 Jul 2022 12:05:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238983AbiGZMF4 (ORCPT ); Tue, 26 Jul 2022 08:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229945AbiGZMFz (ORCPT ); Tue, 26 Jul 2022 08:05:55 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B20F623BC7; Tue, 26 Jul 2022 05:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658837154; x=1690373154; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c8qJbgX+bkOR5QAtm73Za+GslKiRmJrk9Ct5rxSUFyw=; b=Vk9XlZoQPGo5w3KEfJSkEpxQJl96A8y0AHLUNS2yLO5fv9jdwqcnKLDW F/y/Qodfq4Dgx+7vxdWeeAHu8iXjkdZ8J+UmOrErJz076XY7wOklUk6NR M/qK6OGmXx8HB0YcCS3BJDd/+7EarQUGKL/6pimKg6VnQyHG/T4JQyHBC V9lyDQNZW/JVhn2QKZMDGWhyT5NJ1of79N2h1EPtIhdUqmH6JIhoy70Na dcZmHf7NhLQGGDtHxff0Igg935egX4NYju8VCTNZdmo92ePB0GqTGa59a 5pvD29tN4vy1OphfzRo+8wGK6JL14XkM58z9iWVsqpQltD1i19vGVxjCG A==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="287948612" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="287948612" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2022 05:05:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="689417853" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 26 Jul 2022 05:05:52 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 70C6DF7; Tue, 26 Jul 2022 15:06:02 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianshu Qiu , Shawn Tu , Bingbu Cao , Mauro Carvalho Chehab Subject: [PATCH v1 5/8] media: ov2740: Drop redundant assignments of ret = 0 Date: Tue, 26 Jul 2022 15:05:53 +0300 Message-Id: <20220726120556.2881-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> References: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org In some cases it might hide real bugs, in most cases here it's just redundant as it's being reassigned immediately after initial assignment. Signed-off-by: Andy Shevchenko --- drivers/media/i2c/ov2740.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index 07fe8fda274e..212190cb14e4 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -378,7 +378,7 @@ static int ov2740_read_reg(struct ov2740 *ov2740, u16 reg, u16 len, u32 *val) struct i2c_msg msgs[2]; u8 addr_buf[2]; u8 data_buf[4]; - int ret = 0; + int ret; if (len > 4) return -EINVAL; @@ -415,7 +415,7 @@ static int ov2740_write_reg(struct ov2740 *ov2740, u16 reg, u16 len, u32 val) { struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd); u8 buf[6]; - int ret = 0; + int ret; if (len > 4) return -EINVAL; @@ -444,7 +444,7 @@ static int ov2740_write_reg_list(struct ov2740 *ov2740, { struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd); unsigned int i; - int ret = 0; + int ret; for (i = 0; i < r_list->num_of_regs; i++) { ret = ov2740_write_reg(ov2740, r_list->regs[i].address, 1, @@ -486,7 +486,7 @@ static int ov2740_identify_module(struct ov2740 *ov2740) static int ov2740_update_digital_gain(struct ov2740 *ov2740, u32 d_gain) { - int ret = 0; + int ret; ret = ov2740_write_reg(ov2740, OV2740_REG_GROUP_ACCESS, 1, OV2740_GROUP_HOLD_START); @@ -530,7 +530,7 @@ static int ov2740_set_ctrl(struct v4l2_ctrl *ctrl) struct ov2740, ctrl_handler); struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd); s64 exposure_max; - int ret = 0; + int ret; /* Propagate change of current control to all related controls */ if (ctrl->id == V4L2_CID_VBLANK) { @@ -593,7 +593,7 @@ static int ov2740_init_controls(struct ov2740 *ov2740) s64 exposure_max, h_blank, pixel_rate; u32 vblank_min, vblank_max, vblank_default; int size; - int ret = 0; + int ret; ctrl_hdlr = &ov2740->ctrl_handler; ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); @@ -759,7 +759,7 @@ static int ov2740_start_streaming(struct ov2740 *ov2740) struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd); const struct ov2740_reg_list *reg_list; int link_freq_index; - int ret = 0; + int ret; ret = ov2740_identify_module(ov2740); if (ret) @@ -1154,8 +1154,8 @@ static int ov2740_register_nvmem(struct i2c_client *client, static int ov2740_probe(struct i2c_client *client) { struct ov2740 *ov2740; - int ret = 0; bool full_power; + int ret; ret = ov2740_check_hwcfg(&client->dev); if (ret) { From patchwork Tue Jul 26 12:05:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 593670 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D042CCCA47E for ; Tue, 26 Jul 2022 12:06:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239063AbiGZMGB (ORCPT ); Tue, 26 Jul 2022 08:06:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239039AbiGZMF6 (ORCPT ); Tue, 26 Jul 2022 08:05:58 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F7182B187; Tue, 26 Jul 2022 05:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658837157; x=1690373157; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=y/yDmo7qbXEh70Kz4ZNEYtLjd9Z7AKLADZUFGnXR7fs=; b=Pmjaw6aXbeWGQn0ZW+ZVBkzAVJQmpYwdrVP/dksc7Kv7YuFW0KxMbnb3 7eQj8aae1Pir6CwHS8KlnalHBXRwx+AeUJmppjP/vd/rWYoh5lMpuTpzA oqPno4W1zKKOxfeg11lvZdV/2p9DUgV62kXC7Ex3SCPcgJNHLkPMi5LSw Ex992IyDnlF8RTM1s4UCp8v4JEgoiyo7uffNzG4gOVjd/Owwj7btFyCEe LWyf6SUNOnSxxTkr963dtwY7hyDvwunijp51wt34hitBwPh+X83I1HqB8 u1qQP25wqO64lk9Ael/wJgLVTa4OAzAO4fRRsTkHzPqmH4jjBdb0uDcEG g==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="285485867" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="285485867" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2022 05:05:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="658656518" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 26 Jul 2022 05:05:55 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7F270303; Tue, 26 Jul 2022 15:06:02 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianshu Qiu , Shawn Tu , Bingbu Cao , Mauro Carvalho Chehab Subject: [PATCH v1 6/8] media: ov2740: Switch to use dev_err_probe() Date: Tue, 26 Jul 2022 15:05:54 +0300 Message-Id: <20220726120556.2881-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> References: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Switch to use dev_err_probe() to simpify error path and unify message template. While at it, add missed \n to the end of the messages. Signed-off-by: Andy Shevchenko Reviewed-by: Bingbu Cao --- drivers/media/i2c/ov2740.c | 44 ++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index 212190cb14e4..7271e3d011c9 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -1013,10 +1013,10 @@ static int ov2740_check_hwcfg(struct device *dev) if (ret) return ret; - if (mclk != OV2740_MCLK) { - dev_err(dev, "external clock %d is not supported", mclk); - return -EINVAL; - } + if (mclk != OV2740_MCLK) + return dev_err_probe(dev, -EINVAL, + "external clock %d is not supported\n", + mclk); ep = fwnode_graph_get_next_endpoint(fwnode, NULL); if (!ep) @@ -1028,15 +1028,14 @@ static int ov2740_check_hwcfg(struct device *dev) return ret; if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV2740_DATA_LANES) { - dev_err(dev, "number of CSI2 data lanes %d is not supported", - bus_cfg.bus.mipi_csi2.num_data_lanes); - ret = -EINVAL; + ret = dev_err_probe(dev, -EINVAL, + "number of CSI2 data lanes %d is not supported\n", + bus_cfg.bus.mipi_csi2.num_data_lanes); goto check_hwcfg_error; } if (!bus_cfg.nr_of_link_frequencies) { - dev_err(dev, "no link frequencies defined"); - ret = -EINVAL; + ret = dev_err_probe(dev, -EINVAL, "no link frequencies defined\n"); goto check_hwcfg_error; } @@ -1048,9 +1047,9 @@ static int ov2740_check_hwcfg(struct device *dev) } if (j == bus_cfg.nr_of_link_frequencies) { - dev_err(dev, "no link frequency %lld supported", - link_freq_menu_items[i]); - ret = -EINVAL; + ret = dev_err_probe(dev, -EINVAL, + "no link frequency %lld supported\n", + link_freq_menu_items[i]); goto check_hwcfg_error; } } @@ -1153,16 +1152,14 @@ static int ov2740_register_nvmem(struct i2c_client *client, static int ov2740_probe(struct i2c_client *client) { + struct device *dev = &client->dev; struct ov2740 *ov2740; bool full_power; int ret; ret = ov2740_check_hwcfg(&client->dev); - if (ret) { - dev_err(&client->dev, "failed to check HW configuration: %d", - ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to check HW configuration\n"); ov2740 = devm_kzalloc(&client->dev, sizeof(*ov2740), GFP_KERNEL); if (!ov2740) @@ -1172,17 +1169,15 @@ static int ov2740_probe(struct i2c_client *client) full_power = acpi_dev_state_d0(&client->dev); if (full_power) { ret = ov2740_identify_module(ov2740); - if (ret) { - dev_err(&client->dev, "failed to find sensor: %d", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to find sensor\n"); } mutex_init(&ov2740->mutex); ov2740->cur_mode = &supported_modes[0]; ret = ov2740_init_controls(ov2740); if (ret) { - dev_err(&client->dev, "failed to init controls: %d", ret); + dev_err_probe(dev, ret, "failed to init controls\n"); goto probe_error_v4l2_ctrl_handler_free; } @@ -1193,14 +1188,13 @@ static int ov2740_probe(struct i2c_client *client) ov2740->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_pads_init(&ov2740->sd.entity, 1, &ov2740->pad); if (ret) { - dev_err(&client->dev, "failed to init entity pads: %d", ret); + dev_err_probe(dev, ret, "failed to init entity pads\n"); goto probe_error_v4l2_ctrl_handler_free; } ret = v4l2_async_register_subdev_sensor(&ov2740->sd); if (ret < 0) { - dev_err(&client->dev, "failed to register V4L2 subdev: %d", - ret); + dev_err_probe(dev, ret, "failed to register V4L2 subdev\n"); goto probe_error_media_entity_cleanup; } From patchwork Tue Jul 26 12:05:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 593669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31FB0C43334 for ; Tue, 26 Jul 2022 12:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239074AbiGZMGD (ORCPT ); Tue, 26 Jul 2022 08:06:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239042AbiGZMF6 (ORCPT ); Tue, 26 Jul 2022 08:05:58 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA7B22B194; Tue, 26 Jul 2022 05:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658837157; x=1690373157; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V/y17cHBQ5iVwv3J6QidD4ZeKYLL1WEzsEMjhIU10dI=; b=JLe7BCjsLJ4nmxe9Tu9sMJAj2TtEsZIOgHRmyu5S3I+dOLBohxiSCUSC lOUn3pDy4E5vLfmynYOmhWZARdePZYuo6WstxODesBzyJWjNCPWM4I00M i7IesY6lH4/tZaoNOx1NTgf5J7Lt3Z9Rn4JAkBX//IgViVEZmfmvSy+bw TX/NdA0E0nXzbVQCSflusJyWAc3INtvi/tUQ33X3YUTfW/5NBTbsqu3vt 4gtI2co6KZ9OQ2joS+r95/YSqGZC2J06p50ss0ACXxCyy5ZQagPPl+q0n bUNDtyrB4uD5dKq8v+Aun7cD4xErtrqSg+HhfuFXOTBzsakZxWFpg5hif g==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="289125412" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="289125412" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2022 05:05:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="726514858" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 26 Jul 2022 05:05:55 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8414C1DF; Tue, 26 Jul 2022 15:06:02 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianshu Qiu , Shawn Tu , Bingbu Cao , Mauro Carvalho Chehab Subject: [PATCH v1 7/8] media: ov2740: Add missed \n to the end of the messages Date: Tue, 26 Jul 2022 15:05:55 +0300 Message-Id: <20220726120556.2881-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> References: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add missed \n to the end of the messages. Signed-off-by: Andy Shevchenko Reviewed-by: Bingbu Cao --- drivers/media/i2c/ov2740.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index 7271e3d011c9..c4c511f90257 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -451,7 +451,7 @@ static int ov2740_write_reg_list(struct ov2740 *ov2740, r_list->regs[i].val); if (ret) { dev_err_ratelimited(&client->dev, - "write reg 0x%4.4x return err = %d", + "write reg 0x%4.4x return err = %d\n", r_list->regs[i].address, ret); return ret; } @@ -474,7 +474,7 @@ static int ov2740_identify_module(struct ov2740 *ov2740) return ret; if (val != OV2740_CHIP_ID) { - dev_err(&client->dev, "chip id mismatch: %x!=%x", + dev_err(&client->dev, "chip id mismatch: %x != %x\n", OV2740_CHIP_ID, val); return -ENXIO; } @@ -772,14 +772,14 @@ static int ov2740_start_streaming(struct ov2740 *ov2740) reg_list = &link_freq_configs[link_freq_index].reg_list; ret = ov2740_write_reg_list(ov2740, reg_list); if (ret) { - dev_err(&client->dev, "failed to set plls"); + dev_err(&client->dev, "failed to set plls\n"); return ret; } reg_list = &ov2740->cur_mode->reg_list; ret = ov2740_write_reg_list(ov2740, reg_list); if (ret) { - dev_err(&client->dev, "failed to set mode"); + dev_err(&client->dev, "failed to set mode\n"); return ret; } @@ -790,7 +790,7 @@ static int ov2740_start_streaming(struct ov2740 *ov2740) ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1, OV2740_MODE_STREAMING); if (ret) - dev_err(&client->dev, "failed to start streaming"); + dev_err(&client->dev, "failed to start streaming\n"); return ret; } @@ -801,7 +801,7 @@ static void ov2740_stop_streaming(struct ov2740 *ov2740) if (ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1, OV2740_MODE_STANDBY)) - dev_err(&client->dev, "failed to stop streaming"); + dev_err(&client->dev, "failed to stop streaming\n"); } static int ov2740_set_stream(struct v4l2_subdev *sd, int enable) From patchwork Tue Jul 26 12:05:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 593945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0097CCA489 for ; Tue, 26 Jul 2022 12:06:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239070AbiGZMGC (ORCPT ); Tue, 26 Jul 2022 08:06:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239045AbiGZMF6 (ORCPT ); Tue, 26 Jul 2022 08:05:58 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF7072B19D; Tue, 26 Jul 2022 05:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658837157; x=1690373157; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/pMpcO4DRoaktxrLUp1GwMzfi5O0xvdqzoWKuaXXOB0=; b=DI+Q+3/+VmtzEnzEKjZCs5X4M91ZH26cM27g3mxVopmj73suNRWRxdLP A6SblMEiiREHXdQR55DLwmVVHGuvleHqw6ibkucKuw6efqLnfhsTEJ3NO xXL3Ck6tvhqW9+RBG+sgYJr7PmPMoCNa39dTZuTpit2AD4NaPpf8BKYtP qNbzzI/Ba/PAsDOOLDb4glM3IG5onrm2QRAtbPMfaRsSQV2d2W9NhpFmY fya1NuXJjz6049/btPYKEUuQV+o2F+E+z9QIn87Teu1iTBEBouiSoozRP dkLGRfwRM/2jaHNPJaFmrXUnHzYcelOmL0JED+unteLxRw4WNgfj1p78y g==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="270971295" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="270971295" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2022 05:05:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="702871738" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 26 Jul 2022 05:05:55 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8CD68347; Tue, 26 Jul 2022 15:06:02 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianshu Qiu , Shawn Tu , Bingbu Cao , Mauro Carvalho Chehab Subject: [PATCH v1 8/8] media: ov2740: Use traditional pattern when checking error codes Date: Tue, 26 Jul 2022 15:05:56 +0300 Message-Id: <20220726120556.2881-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> References: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Instead of 'if (!ret)' switch to "check for the error first" rule. Signed-off-by: Andy Shevchenko --- drivers/media/i2c/ov2740.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index c4c511f90257..afd591be6526 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -1112,7 +1112,6 @@ static int ov2740_register_nvmem(struct i2c_client *client, struct nvmem_config nvmem_config = { }; struct regmap *regmap; struct device *dev = &client->dev; - int ret; nvm = devm_kzalloc(dev, sizeof(*nvm), GFP_KERNEL); if (!nvm) @@ -1142,12 +1141,11 @@ static int ov2740_register_nvmem(struct i2c_client *client, nvmem_config.size = CUSTOMER_USE_OTP_SIZE; nvm->nvmem = devm_nvmem_register(dev, &nvmem_config); + if (IS_ERR(nvm->nvmem)) + return PTR_ERR(nvm->nvmem); - ret = PTR_ERR_OR_ZERO(nvm->nvmem); - if (!ret) - ov2740->nvm = nvm; - - return ret; + ov2740->nvm = nvm; + return 0; } static int ov2740_probe(struct i2c_client *client)