Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp557767lqh; Thu, 28 Mar 2024 09:24:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUsUKHf4BAWmXcczvyNKYdBUz/Mce+mDumV5Uhut5mX0oe0y5agG9RcJ6VlONpq1JIYZSY5x3aBDg4qC3qH+vIOyoEqiirRSfG/i7gclg== X-Google-Smtp-Source: AGHT+IFSm6pIF3G0zZs/qB7LMWb6wtbAtpBZat5UzIGouvG8g1PTjLVrcRCrEvpOQ+4eKYO1L/UG X-Received: by 2002:a17:902:d2d2:b0:1dc:6152:7c24 with SMTP id n18-20020a170902d2d200b001dc61527c24mr3771139plc.43.1711643048841; Thu, 28 Mar 2024 09:24:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711643048; cv=pass; d=google.com; s=arc-20160816; b=xIyXCPwlFWMDt0Qu+XSV5SVGheqL3TDKscwldTlagve6L1V9b0UQqYaY3NABZEtZ+j xMEvWDdEbhYcNdR9vXKfFl2KDsOeMJZ40MkHpeCVMhdOIVA9yNKGn+RvupznzAc6rA5e w+DiQPSDvpxAjbQVIWv38Qz/xItGduuMqipVZGYqy6Q3zRzTY5z3Nt2VHgW7HQvE5jlC AvP2Jb55KnS/09ywmJOzoPy9kl665g+HueJ4pZcL6v21x0pCk2Iw6NFhjizl609a4AyH OqSHONnufqxmoF9kseyLAELbbbW94L/Y8yuKIs0J5Lbha5hCkxWRl7sdda7Ep45hqO+6 wDsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=x8gGU0UHOF0LCh8SaWfg5xoQ26maUMu2aTlQaUFPQ44=; fh=eLJ0ZkbGfa/aqy/dGSdsvXDgUwptbVw94nQm6NI/Hjg=; b=mHXdf/tnMAnQWdRPkKADOe6esnFHYtmS/nYUjkyrghQLRYagipGAOEdHkm2xlNQelb np+cN6YJch+w1qCdFsY17n2NuiPI7Hm8SWsfYnI/PM0g3Uy+qyc4VkA+cpNFVuAYS8GV D5wIn9NB4pDhnrMxowy2nJyEKq5Zw909ApcmEbI8qEugbgMdi5R8nz8miREqLJ4qWCio AY9ADwcDttFRpOGHGBjg8cyxicZY6mJLjcBZDCpC8XuQ811erK8+mp92eiKqNgIwTcLm 5kQmeNBsORO/RYKKtEkbX5qfB710s+G5CCYh3FdWozdnU8arBuSVlShlpyVIoWIoUHs6 1YEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eZo6pxXF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-123244-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123244-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n7-20020a170902f60700b001d4ca2fcc4asi1816176plg.291.2024.03.28.09.24.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 09:24:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123244-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eZo6pxXF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-123244-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123244-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id F1B84293F46 for ; Thu, 28 Mar 2024 16:23:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87F61137C3A; Thu, 28 Mar 2024 16:22:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eZo6pxXF" 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 F337D54673; Thu, 28 Mar 2024 16:22:07 +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=1711642928; cv=none; b=E92fa8iIbswjTY0XauocDIvf1h48IQZu5L6sdaB4rqmzH+ChPjg/HqVk9CABoQcgkcnBVv/bNU1cxGPgD0Cj+0S5dSTchCXkNOAQ192GW3Z8AJ1Gm9lKIlZLF9oMw6j183cc/G7fnlEiYV5xCgYgoFK2ptXJrMHB7YOh98se+Yc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711642928; c=relaxed/simple; bh=dCZc/jEii72+NzqEeuXpC+RCbEkLGzC80WA8NGGJ0n8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SyJr7m1cY8+uOfKk/+gRa3bbdz9L1xP9Cdijn+KAEXfdrbtfMqPMtQpIu4ebhkkLBCaCd5hVX2vxmwp67rgoemANLB6KNb7fE2CfS8trqN5XCrhHTHGVGhVdy/uvciF9tgQOByJz6j34CJwlmzNmrtjKS25c94iNG5wfpnDerx4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eZo6pxXF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 97711C43601; Thu, 28 Mar 2024 16:22:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711642927; bh=dCZc/jEii72+NzqEeuXpC+RCbEkLGzC80WA8NGGJ0n8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=eZo6pxXFWdeEvNe+/3FvroGHofYT2IqX+PmZ1bpVf4kEYgWmxooZbfrNlJrKizVdM repBQc0LZ78TwmCM2Qz/Y0EPeZtls1FHTDdrMUDVZ6F3YpebPTNKFkQo27+V3q9DlJ Rjys4HLlZvwe2GfvnwAys5TGl23/ezE19pknCDkWa04o6fr6LZFh/ymvdbUWz43vN7 eC77O0RTltNXurumC/bE31VRq1loPXmOPNZZLgrb94M+maujS9lhvgI4V1ASrce/YM X8cJyP5R6STqjLdDW3sFJVpaQNBwUZFNjUfGJT4ohYdTkYsUDE6KJTy1Lizc0pqH61 jx6zWlCAT20PQ== 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 7FE8BCD1283; Thu, 28 Mar 2024 16:22:07 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Thu, 28 Mar 2024 17:22:06 +0100 Subject: [PATCH v4 6/6] iio: common: scmi_iio: convert to dev_err_probe() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240328-ltc2983-misc-improv-v4-6-0cc428c07cd5@analog.com> References: <20240328-ltc2983-misc-improv-v4-0-0cc428c07cd5@analog.com> In-Reply-To: <20240328-ltc2983-misc-improv-v4-0-0cc428c07cd5@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Olivier Moysan , Jyoti Bhayana X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1711642925; l=3435; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=fNPiCbBBcgPGtymUHxCG0IpXbjRneBGghOMvhTO+DqU=; b=RUz+deQwQ5JZU8wRdkeVarQwg8rjLLVxLCJCg0hTcLAhRamfi700AZoSgPDMfGYQFvWCM1rnq nPuBHXir35YCu87W2kuAFwWJ/HfDmaQFfV6M3yN/AQYSpxPSC5QDA63 X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: nuno.sa@analog.com From: Nuno Sa Make use of dev_err_probe() and dev_errp_probe() to simplify error paths during probe. Signed-off-by: Nuno Sa --- drivers/iio/common/scmi_sensors/scmi_iio.c | 45 +++++++++++++----------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c index 0c2caf3570db..30d58af02b4c 100644 --- a/drivers/iio/common/scmi_sensors/scmi_iio.c +++ b/drivers/iio/common/scmi_sensors/scmi_iio.c @@ -626,12 +626,10 @@ scmi_alloc_iiodev(struct scmi_device *sdev, SCMI_PROTOCOL_SENSOR, SCMI_EVENT_SENSOR_UPDATE, &sensor->sensor_info->id, &sensor->sensor_update_nb); - if (ret) { - dev_err(&iiodev->dev, - "Error in registering sensor update notifier for sensor %s err %d", - sensor->sensor_info->name, ret); - return ERR_PTR(ret); - } + if (ret) + return dev_errp_probe(&iiodev->dev, ret, + "Error in registering sensor update notifier for sensor %s err %d", + sensor->sensor_info->name, ret); scmi_iio_set_timestamp_channel(&iio_channels[i], i); iiodev->channels = iio_channels; @@ -653,10 +651,9 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev) return -ENODEV; sensor_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_SENSOR, &ph); - if (IS_ERR(sensor_ops)) { - dev_err(dev, "SCMI device has no sensor interface\n"); - return PTR_ERR(sensor_ops); - } + if (IS_ERR(sensor_ops)) + return dev_err_probe(dev, PTR_ERR(sensor_ops), + "SCMI device has no sensor interface\n"); nr_sensors = sensor_ops->count_get(ph); if (!nr_sensors) { @@ -667,8 +664,8 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev) for (i = 0; i < nr_sensors; i++) { sensor_info = sensor_ops->info_get(ph, i); if (!sensor_info) { - dev_err(dev, "SCMI sensor %d has missing info\n", i); - return -EINVAL; + return dev_err_probe(dev, -EINVAL, + "SCMI sensor %d has missing info\n", i); } /* This driver only supports 3-axis accel and gyro, skipping other sensors */ @@ -683,29 +680,25 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev) scmi_iio_dev = scmi_alloc_iiodev(sdev, sensor_ops, ph, sensor_info); if (IS_ERR(scmi_iio_dev)) { - dev_err(dev, - "failed to allocate IIO device for sensor %s: %ld\n", - sensor_info->name, PTR_ERR(scmi_iio_dev)); - return PTR_ERR(scmi_iio_dev); + return dev_err_probe(dev, PTR_ERR(scmi_iio_dev), + "failed to allocate IIO device for sensor %s: %ld\n", + sensor_info->name, PTR_ERR(scmi_iio_dev)); } err = devm_iio_kfifo_buffer_setup(&scmi_iio_dev->dev, scmi_iio_dev, &scmi_iio_buffer_ops); if (err < 0) { - dev_err(dev, - "IIO buffer setup error at sensor %s: %d\n", - sensor_info->name, err); - return err; + return dev_err_probe(dev, err, + "IIO buffer setup error at sensor %s: %d\n", + sensor_info->name, err); } err = devm_iio_device_register(dev, scmi_iio_dev); - if (err) { - dev_err(dev, - "IIO device registration failed at sensor %s: %d\n", - sensor_info->name, err); - return err; - } + if (err) + return dev_err_probe(dev, err, + "IIO device registration failed at sensor %s: %d\n", + sensor_info->name, err); } return err; } -- 2.44.0