From patchwork Fri Jun 21 22:11:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 13708119 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8C03C2BBCA for ; Fri, 21 Jun 2024 22:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PD+YDF/bIrSJ5as8z+S1ghdz1Anzvn+XbfX57fqHPgE=; b=R+l1UeGtf9pGcdnSDsxluDWL8G n+v2wXVnaWYeG53WV+S7hwJLPEr5oyH4y/ndcEk+d29A/+z7YQ5k6HLoMiheb/ncMgvA7I7g5OgOs a803Walr3JxzC13zCMnnW04gSBX3pqIEzkMDzbvwKXrrVCI33PRF9kymalkOFJBD1Udj1es/5vdVY kyoJY6lFY01m4vJ1iPmX7AJmQdy9bh0LrxStwiBU7pZM8OReNLOewf9fRACAORwfbBRuLqLvGKxTN MGC6hajzNf7iiPQCMmySJg+mi9NgyHvMWHWyg68NKHYnvR3U6+fsrIMAv3huvudZci+ly19Ed4eDi WWI5gWOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKmUS-0000000Ai9b-1RLH; Fri, 21 Jun 2024 22:12:16 +0000 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKmUJ-0000000Ai3b-09f6 for linux-arm-kernel@lists.infradead.org; Fri, 21 Jun 2024 22:12:08 +0000 Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-5c1acd482e4so1366652eaf.3 for ; Fri, 21 Jun 2024 15:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1719007926; x=1719612726; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PD+YDF/bIrSJ5as8z+S1ghdz1Anzvn+XbfX57fqHPgE=; b=WXqUlZsV7n9toEWxzHc41iBhAXn4YCSUyMWOIBqybeCtJD2Uu/jVMBew8Es+Wt3be1 nH55OmJ+Ld9sKOtK3SajA9P/sjeY+yVG3rJEzCMAZn/wMDosarRQfn4/sFIKEjfJrumM AEqjgAPcaGN2GWNJHSHU3FWqHCSwOdZuzA9GcKKdJnPwaqCIuapt0YaaptPm4F8QfNeL Aqm68yhZb/zgEFT/YtwXbOvZNitdOWgWCl3kH66lrR2BXg3ZMGsU9WURRhwlODrQNCOR ueOc1k+2hbQW+b/WD5DC0V0xf8FHOPJnE0ls/oFyRYPvbDjKkNpgTVFad4KxnnKP5QPd PF8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719007926; x=1719612726; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PD+YDF/bIrSJ5as8z+S1ghdz1Anzvn+XbfX57fqHPgE=; b=o0uXTB59KLr2zR/5jX8Onw/PKiOQnREAw2Xexq5fEO6zgPQlOgm7EDKhq73a/ZpAto uEgW+nbRHx2tgYvYQgF031BmXf9VU0UAO4ROBavXvL4l77Kx83Jrn0djJsyQjs7dRSTE rPG0jjCAHBPT6MiwmXpWgD3Gqd/VkZf0HuXluEzsWNH4zJhhwtb5SZ3SYykQHPmZt5Mc Jl31SKlqUKe367tyfIDDxjkCmSvYIDUJB12iwLG14rRDFGezWzW+hEOTVKWwT0v5hFSi X9w9x9OM0cCzI5p7G42zxX6nmXoNY6Axs4bJUtQn+N3prkUw3lQ4wmdc4ZDiifSvpHGb ZqQQ== X-Forwarded-Encrypted: i=1; AJvYcCXJG4M0dF2kCBhthCuZmOTMLYbE9aQPqMpao5n9BX2bVfcS7iW+/BxwVwrgE/Z+0sQsSzN7YTSHS3bwNizewiAXJxC4HHyhjP76P1CV6fC4LIqGtks= X-Gm-Message-State: AOJu0Yyk6hy5FA98q7z0axUQM+o83D47LOfJX2UMGTnEHMWEnrE+2QJe ZE/Z8LjBQbgNcgZFYpwWz/c9dIKNw2In07IbA09eUHWyMdE5MQ0nNQc17lrLjgQ= X-Google-Smtp-Source: AGHT+IG8VExe3m+Cltyn4mwfelEWS/KdStFcap+oMybDTEkuUDcJh0MBpt38tdnWmKzNqDCnxsogbA== X-Received: by 2002:a4a:dcd7:0:b0:5ba:ffcb:c756 with SMTP id 006d021491bc7-5c1b8b70a91mr8440535eaf.1.1719007926083; Fri, 21 Jun 2024 15:12:06 -0700 (PDT) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5c1d94fb2a4sm329837eaf.10.2024.06.21.15.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 15:12:05 -0700 (PDT) From: David Lechner To: Jonathan Cameron Cc: David Lechner , Joel Stanley , Andrew Jeffery , Liam Girdwood , Mark Brown , Andreas Klinger , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/10] iio: adc: hx711: use dev_err_probe() Date: Fri, 21 Jun 2024 17:11:51 -0500 Message-ID: <20240621-iio-regulator-refactor-round-2-v1-4-49e50cd0b99a@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240621-iio-regulator-refactor-round-2-v1-0-49e50cd0b99a@baylibre.com> References: <20240621-iio-regulator-refactor-round-2-v1-0-49e50cd0b99a@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240621_151207_100626_882AF59E X-CRM114-Status: GOOD ( 14.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use dev_err_probe() to simplify error returns in the probe function. Signed-off-by: David Lechner Reviewed-by: Andreas Klinger --- drivers/iio/adc/hx711.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 8461b1fe6bad..b3372ccff7d5 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -464,10 +464,8 @@ static int hx711_probe(struct platform_device *pdev) int i; indio_dev = devm_iio_device_alloc(dev, sizeof(struct hx711_data)); - if (!indio_dev) { - dev_err(dev, "failed to allocate IIO device\n"); - return -ENOMEM; - } + if (!indio_dev) + return dev_err_probe(dev, -ENOMEM, "failed to allocate IIO device\n"); hx711_data = iio_priv(indio_dev); hx711_data->dev = dev; @@ -479,22 +477,18 @@ static int hx711_probe(struct platform_device *pdev) * in the driver it is an output */ hx711_data->gpiod_pd_sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW); - if (IS_ERR(hx711_data->gpiod_pd_sck)) { - dev_err(dev, "failed to get sck-gpiod: err=%ld\n", - PTR_ERR(hx711_data->gpiod_pd_sck)); - return PTR_ERR(hx711_data->gpiod_pd_sck); - } + if (IS_ERR(hx711_data->gpiod_pd_sck)) + return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_pd_sck), + "failed to get sck-gpiod\n"); /* * DOUT stands for serial data output of HX711 * for the driver it is an input */ hx711_data->gpiod_dout = devm_gpiod_get(dev, "dout", GPIOD_IN); - if (IS_ERR(hx711_data->gpiod_dout)) { - dev_err(dev, "failed to get dout-gpiod: err=%ld\n", - PTR_ERR(hx711_data->gpiod_dout)); - return PTR_ERR(hx711_data->gpiod_dout); - } + if (IS_ERR(hx711_data->gpiod_dout)) + return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_dout), + "failed to get dout-gpiod\n"); ret = devm_regulator_get_enable_read_voltage(dev, "avdd"); if (ret < 0) @@ -548,16 +542,13 @@ static int hx711_probe(struct platform_device *pdev) ret = devm_iio_triggered_buffer_setup(dev, indio_dev, iio_pollfunc_store_time, hx711_trigger, NULL); - if (ret < 0) { - dev_err(dev, "setup of iio triggered buffer failed\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, + "setup of iio triggered buffer failed\n"); ret = devm_iio_device_register(dev, indio_dev); - if (ret < 0) { - dev_err(dev, "Couldn't register the device\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Couldn't register the device\n"); return 0; }