From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Tianshu Qiu <tian.shu.qiu@intel.com>,
Shawn Tu <shawnx.tu@intel.com>, Bingbu Cao <bingbu.cao@intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Subject: [PATCH v1 6/8] media: ov2740: Switch to use dev_err_probe()
Date: Tue, 26 Jul 2022 15:05:54 +0300 [thread overview]
Message-ID: <20220726120556.2881-6-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20220726120556.2881-1-andriy.shevchenko@linux.intel.com>
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 <andriy.shevchenko@linux.intel.com>
---
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;
}
--
2.35.1
next prev parent reply other threads:[~2022-07-26 12:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-26 12:05 [PATCH v1 1/8] media: ov2740: Remove duplicative pointer in struct nvm_data Andy Shevchenko
2022-07-26 12:05 ` [PATCH v1 2/8] media: ov2740: Replace voodoo coding with understandle flow Andy Shevchenko
2022-07-27 9:52 ` Cao, Bingbu
2022-11-11 15:02 ` Sakari Ailus
2022-11-11 15:30 ` Andy Shevchenko
2022-11-11 19:46 ` Sakari Ailus
2022-07-26 12:05 ` [PATCH v1 3/8] media: ov2740: Switch from __maybe_unused to pm_sleep_ptr() etc Andy Shevchenko
2022-07-26 12:05 ` [PATCH v1 4/8] media: ov2740: Remove duplicate check for NULL fwnode Andy Shevchenko
2022-07-27 9:41 ` Cao, Bingbu
2022-07-27 10:01 ` Cao, Bingbu
2022-07-26 12:05 ` [PATCH v1 5/8] media: ov2740: Drop redundant assignments of ret = 0 Andy Shevchenko
2022-07-26 12:05 ` Andy Shevchenko [this message]
2022-07-27 10:06 ` [PATCH v1 6/8] media: ov2740: Switch to use dev_err_probe() Cao, Bingbu
2022-07-26 12:05 ` [PATCH v1 7/8] media: ov2740: Add missed \n to the end of the messages Andy Shevchenko
2022-07-27 10:01 ` Cao, Bingbu
2022-07-26 12:05 ` [PATCH v1 8/8] media: ov2740: Use traditional pattern when checking error codes Andy Shevchenko
2022-08-23 14:10 ` [PATCH v1 1/8] media: ov2740: Remove duplicative pointer in struct nvm_data Andy Shevchenko
2022-11-11 12:05 ` Andy Shevchenko
2022-11-11 12:08 ` Andy Shevchenko
2022-11-11 14:58 ` Sakari Ailus
2022-11-11 15:29 ` Andy Shevchenko
2022-11-11 19:41 ` Sakari Ailus
2022-11-11 19:47 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220726120556.2881-6-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bingbu.cao@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=shawnx.tu@intel.com \
--cc=tian.shu.qiu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox