From patchwork Sun Oct 20 22:13:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Apitzsch_via_B4_Relay?= X-Patchwork-Id: 837428 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C63519882B; Sun, 20 Oct 2024 22:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729462452; cv=none; b=JvCFP4DHngdTcFoWueqJgJAGGPeBjgveua1vf+dF3VcwwPrP0wUANZLbITzfK/zA1f7e/NQHBKmxmgyUdaQyAKHAfpiLP8PHwVMvF1DhIqK/HV1xE1PQLLIsuBSDUGZlm6DU+gKrjR7LgHMiFOm/OdFG3mMKMCebGpAHvuv1llM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729462452; c=relaxed/simple; bh=fi+/W8VD8uiLbO3JFKJnunrXmJ0f6KvTtdEIT5PiEek=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ANBtdJ84Jxx3QXh8ASbcxD6jZ3LwieQd5ED3Z/CSgwJy0MWBobPy9rcJBYwXPItYyhd/1nB0F+xcTxn+XqhMJ5tPLUXaw+gPE16Ou5xCz/if+flwC/o4VahqeB/LZ7Pk/S9uvn98EUeISFrmLriUoYyQltJjskInyOaZj0jnlRM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YtuFmYEO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YtuFmYEO" Received: by smtp.kernel.org (Postfix) with ESMTPS id B831CC4CEE5; Sun, 20 Oct 2024 22:14:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729462451; bh=fi+/W8VD8uiLbO3JFKJnunrXmJ0f6KvTtdEIT5PiEek=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YtuFmYEOS+JgTZvLuZC6RiSnQegUi9RagAcQqzZAz2KOrnNFOToovzeTjV7PM/RVD EuBc0KHLxy/uX0WAyBUrPHuvowiqBA0gpkWv7D41BK84W0RH4QcfLU/jYVl+yJpJCH 9MPc6Vppcsu/p6JExg61xygsRfOMVqfmWwogT5q8h4T2gWbJbScj2+1p+hgRdwkK+Q ncKlPRo/P8iIzsyFk6Yn0LECyo0Zva29iwRgzMmkoVK7+hk4OO1mIFheLhihxP+W6c 2Uco8xK1zPZdOHrFi/wGlvorNkS2XkAi51TE/tcJGr3jAvKsAdDYtnYHlsrkUW3eFS 97RASYCvM7MvQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4917D3C938; Sun, 20 Oct 2024 22:14:11 +0000 (UTC) From: =?utf-8?q?Andr=C3=A9_Apitzsch_via_B4_Relay?= Date: Mon, 21 Oct 2024 00:13:23 +0200 Subject: [PATCH v2 03/13] media: i2c: imx214: Simplify with dev_err_probe() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241021-imx214-v2-3-fbd23e99541e@apitzsch.eu> References: <20241021-imx214-v2-0-fbd23e99541e@apitzsch.eu> In-Reply-To: <20241021-imx214-v2-0-fbd23e99541e@apitzsch.eu> To: Ricardo Ribalda , Mauro Carvalho Chehab , Sakari Ailus Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Dave Stevenson , =?utf-8?q?Andr=C3=A9_Apit?= =?utf-8?q?zsch?= , Ricardo Ribalda X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729462449; l=3934; i=git@apitzsch.eu; s=20240325; h=from:subject:message-id; bh=NPwSySA3gPKU4+Xr8HEmeYKsL8OgAT888MNkYNh/7tw=; b=deylbW2v+Eo3UW4C1DjzUs5xfgfRlVxu1OWqkoaD/z5T+x7ftQcfzT0GvhKvtloSdxgO+x+0w M8MtWWdI57xAQLXR2y8unW1RybKcKXfZlZKjWluOBkEZHuFZUwTRfEc X-Developer-Key: i=git@apitzsch.eu; a=ed25519; pk=wxovcZRfvNYBMcTw4QFFtNEP4qv39gnBfnfyImXZxiU= X-Endpoint-Received: by B4 Relay for git@apitzsch.eu/20240325 with auth_id=142 X-Original-From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Reply-To: git@apitzsch.eu From: André Apitzsch Error handling in probe() can be a bit simpler with dev_err_probe(). Acked-by: Ricardo Ribalda Signed-off-by: André Apitzsch --- drivers/media/i2c/imx214.c | 52 ++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 990fd0811904fc478c05d64054089fc2879cae94..fc734a162e655228d412ebe0646d64dc0c94f92a 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -933,14 +933,12 @@ static int imx214_parse_fwnode(struct device *dev) int ret; endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL); - if (!endpoint) { - dev_err(dev, "endpoint node not found\n"); - return -EINVAL; - } + if (!endpoint) + return dev_err_probe(dev, -EINVAL, "endpoint node not found\n"); ret = v4l2_fwnode_endpoint_alloc_parse(endpoint, &bus_cfg); if (ret) { - dev_err(dev, "parsing endpoint node failed\n"); + dev_err_probe(dev, ret, "parsing endpoint node failed\n"); goto done; } @@ -949,8 +947,9 @@ static int imx214_parse_fwnode(struct device *dev) break; if (i == bus_cfg.nr_of_link_frequencies) { - dev_err(dev, "link-frequencies %d not supported, Please review your DT\n", - IMX214_DEFAULT_LINK_FREQ); + dev_err_probe(dev, -EINVAL, + "link-frequencies %d not supported, Please review your DT\n", + IMX214_DEFAULT_LINK_FREQ); ret = -EINVAL; goto done; } @@ -978,34 +977,27 @@ static int imx214_probe(struct i2c_client *client) imx214->dev = dev; imx214->xclk = devm_clk_get(dev, NULL); - if (IS_ERR(imx214->xclk)) { - dev_err(dev, "could not get xclk"); - return PTR_ERR(imx214->xclk); - } + if (IS_ERR(imx214->xclk)) + return dev_err_probe(dev, PTR_ERR(imx214->xclk), + "failed to get xclk\n"); ret = clk_set_rate(imx214->xclk, IMX214_DEFAULT_CLK_FREQ); - if (ret) { - dev_err(dev, "could not set xclk frequency\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to set xclk frequency\n"); ret = imx214_get_regulators(dev, imx214); - if (ret < 0) { - dev_err(dev, "cannot get regulators\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "failed to get regulators\n"); imx214->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); - if (IS_ERR(imx214->enable_gpio)) { - dev_err(dev, "cannot get enable gpio\n"); - return PTR_ERR(imx214->enable_gpio); - } + if (IS_ERR(imx214->enable_gpio)) + return dev_err_probe(dev, PTR_ERR(imx214->enable_gpio), + "failed to get enable gpio\n"); imx214->regmap = devm_regmap_init_i2c(client, &sensor_regmap_config); - if (IS_ERR(imx214->regmap)) { - dev_err(dev, "regmap init failed\n"); - return PTR_ERR(imx214->regmap); - } + if (IS_ERR(imx214->regmap)) + return dev_err_probe(dev, PTR_ERR(imx214->regmap), + "regmap init failed\n"); v4l2_i2c_subdev_init(&imx214->sd, client, &imx214_subdev_ops); imx214->sd.internal_ops = &imx214_internal_ops; @@ -1034,20 +1026,20 @@ static int imx214_probe(struct i2c_client *client) ret = media_entity_pads_init(&imx214->sd.entity, 1, &imx214->pad); if (ret < 0) { - dev_err(dev, "could not register media entity\n"); + dev_err_probe(dev, ret, "failed to init entity pads\n"); goto free_ctrl; } imx214->sd.state_lock = imx214->ctrls.lock; ret = v4l2_subdev_init_finalize(&imx214->sd); if (ret < 0) { - dev_err(dev, "subdev init error: %d\n", ret); + dev_err_probe(dev, ret, "subdev init error\n"); goto free_entity; } ret = v4l2_async_register_subdev_sensor(&imx214->sd); if (ret < 0) { - dev_err(dev, "could not register v4l2 device\n"); + dev_err_probe(dev, ret, "failed to register sensor sub-device\n"); goto error_subdev_cleanup; }