From patchwork Wed Oct 9 14:16:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13828496 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 3215E18E045 for ; Wed, 9 Oct 2024 14:16:44 +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=1728483405; cv=none; b=u4HMcqWLn6Lq9MRY/Ya61h4Pvpyk/9iyHjq72UrIHWsTDXd8wbJwxAK6MbMt4Vd2mluWYTDHDr5WaDKCUTdW28gxV4u/eEQ8Kx/5uapDBR4l71mqYJPaA4KkANyyOQ41RDNSoq1ez1g/VFDLPYl+GfYBfV6MDoK6TWBZEGYSH5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728483405; c=relaxed/simple; bh=2Vfv6L5+I26r7iHjtmdUeRjoE9iZDONC1+j4Pb63fHw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KEJd5X6P807AiOh2LI11r6DbM1mHZ/aLiiRtBy4gLxsbDotpn4ywOfKMYF1H/uPwlW0lz5/cSHpOUywHif2LXASQaDWnkkaIxgITjefMLnFXRhuneBBxLobw9jiwIkP0yEYwZuW7XbsU5x+f3AOlE/YDpR4myQas+x/TeE/72OE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j+lyPDR/; 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="j+lyPDR/" Received: by smtp.kernel.org (Postfix) with ESMTPS id D24C0C4CECD; Wed, 9 Oct 2024 14:16:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728483404; bh=2Vfv6L5+I26r7iHjtmdUeRjoE9iZDONC1+j4Pb63fHw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=j+lyPDR//ou23usngJeWM1cXBfxXTK5afv3EPmVUkk728TqjuMLxYqOdAw8OmeKHL ELVvjl/fUcMjhWvRakQErJMm243vMu3gH6tE5wr4UQ+wcrx+ceYbI3pEsuEKHtAmWz p1hLwK2wC7wN9in5MwfF55LuOMOIDe6gq+lYvorERF4vYk8Lh+i491KhdITtQkREl9 ijaG2yZEOxd38xU692j9exYBFaawSvKQ8lipVsek6viX0tFFhv65K52zw1m9c9SNSu gShO1TyA9wwqUyk1pV1Npn/CUIZHd+CYYD2oL1yWU+kMsAeSnt7lATMdUtg+nFW8pO +Gv4xlmrG/Whg== 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 CCB92CEDD9C; Wed, 9 Oct 2024 14:16:44 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Wed, 09 Oct 2024 16:16:43 +0200 Subject: [PATCH 1/4] iio: frequency: adf4371: make use of spi_get_device_match_data() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241009-dev-adf4371-minor-improv-v1-1-97f4f22ed941@analog.com> References: <20241009-dev-adf4371-minor-improv-v1-0-97f4f22ed941@analog.com> In-Reply-To: <20241009-dev-adf4371-minor-improv-v1-0-97f4f22ed941@analog.com> To: linux-iio@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728483403; l=3000; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=RYoxMVKivVHRi4vEh9sR2ScD/T6oh+PpIdTQe1TqOU0=; b=uZ8BDgksHm9dKp4T6D8ZAu1W0jqMbGoekYy9MQNCFUXtxDDvPMBbjBE4caIs0efahl8gUh/Bz 2r2F5qqvlaRCO66K3ytrvzzHHsJLeEm1APGWUK3IexdLWbL7sy1+kgh 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 To use spi_get_device_match_data(), add the chip_info structure to the of_device_id table which is always a good thing to do. While at it, added dedicated variables for each chip (instead of the harder to maintain array) and added a new string variable for the part name. Signed-off-by: Nuno Sa --- drivers/iio/frequency/adf4371.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c index b270884648265..c8bf37f1679c3 100644 --- a/drivers/iio/frequency/adf4371.c +++ b/drivers/iio/frequency/adf4371.c @@ -150,6 +150,7 @@ static const struct regmap_config adf4371_regmap_config = { }; struct adf4371_chip_info { + const char *name; unsigned int num_channels; const struct iio_chan_spec *channels; }; @@ -444,15 +445,16 @@ static const struct iio_chan_spec adf4371_chan[] = { ADF4371_CHANNEL(ADF4371_CH_RF32), }; -static const struct adf4371_chip_info adf4371_chip_info[] = { - [ADF4371] = { - .channels = adf4371_chan, - .num_channels = 4, - }, - [ADF4372] = { - .channels = adf4371_chan, - .num_channels = 3, - } +static const struct adf4371_chip_info adf4371_chip_info = { + .name = "adf4371", + .channels = adf4371_chan, + .num_channels = 4, +}; + +static const struct adf4371_chip_info adf4372_chip_info = { + .name = "adf4372", + .channels = adf4371_chan, + .num_channels = 3, }; static int adf4371_reg_access(struct iio_dev *indio_dev, @@ -542,7 +544,6 @@ static int adf4371_setup(struct adf4371_state *st) static int adf4371_probe(struct spi_device *spi) { - const struct spi_device_id *id = spi_get_device_id(spi); struct iio_dev *indio_dev; struct adf4371_state *st; struct regmap *regmap; @@ -565,8 +566,11 @@ static int adf4371_probe(struct spi_device *spi) st->regmap = regmap; mutex_init(&st->lock); - st->chip_info = &adf4371_chip_info[id->driver_data]; - indio_dev->name = id->name; + st->chip_info = spi_get_device_match_data(spi); + if (!st->chip_info) + return -ENODEV; + + indio_dev->name = st->chip_info->name; indio_dev->info = &adf4371_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->chip_info->channels; @@ -588,15 +592,15 @@ static int adf4371_probe(struct spi_device *spi) } static const struct spi_device_id adf4371_id_table[] = { - { "adf4371", ADF4371 }, - { "adf4372", ADF4372 }, + { "adf4371", (kernel_ulong_t)&adf4371_chip_info }, + { "adf4372", (kernel_ulong_t)&adf4372_chip_info }, {} }; MODULE_DEVICE_TABLE(spi, adf4371_id_table); static const struct of_device_id adf4371_of_match[] = { - { .compatible = "adi,adf4371" }, - { .compatible = "adi,adf4372" }, + { .compatible = "adi,adf4371", .data = &adf4371_chip_info }, + { .compatible = "adi,adf4372", .data = &adf4372_chip_info}, { }, }; MODULE_DEVICE_TABLE(of, adf4371_of_match); From patchwork Wed Oct 9 14:16:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13828494 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 1635C224DC for ; Wed, 9 Oct 2024 14:16:45 +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=1728483405; cv=none; b=bvWtafiTLhuooz/F756X5rrUgoMwdff7xVvBdHLmwZ+YpQW8/J/pXGbXtEjspistcBdJhu5oRuM/kUcUYP84iCCGNbTC4GJgUH4Z+CPbBr0Cfxc+0KbdUfU6paDITC+oC2akvXEcXbrei/V/c8nNfnqx8H90QBSh8ZsUx4N4exI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728483405; c=relaxed/simple; bh=kaJf3xPAMqT20DAZ3PsVm0G2BLo82JR2Rih1UG8HKyw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DKOxWx+RDo7kPN7R/BZ7hHMpmA3EnQ8YPMCcV1wy2lb9HtVmGvGr3SN2r9cS0fBOD9DeRjf6F7Z8eaTYwx+CGCCX5CI+3E3QBN1W/U01iytKlnc60bL8bMYph2jZufX6aBANmeDzshw7RKYzJhfXSpuJmFipO+XPGfa56mi6eoA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fcU+7pEc; 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="fcU+7pEc" Received: by smtp.kernel.org (Postfix) with ESMTPS id E71B9C4CECF; Wed, 9 Oct 2024 14:16:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728483405; bh=kaJf3xPAMqT20DAZ3PsVm0G2BLo82JR2Rih1UG8HKyw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fcU+7pEcoMjHQpmTTMDWmQA0H0LB2wyyizal0vGYqna7VMymWrHCCNDtLOWuxa6fp kBwmt1+MKTxR0WKZu8HUtnNOYYCVIh3ojZKOJhGUX3KE5nSsVuoZhAM3QsXQGAskRo 6Qs34YOb8kQVDqBMaIg0uAnFm79nR60UD/t5EpCGg+RMdZWRVj9zUQJKxO4L7xIzLJ fsLpas+SDuahMROLt5Tx2Pl51k6tSpEgusHXN8e+OGrwg3oVF1pWdxrPLoqiwcmPKD NCwTBycoiWtdTHRldXf/U2SUPGhkCvtK/k4iA8zC1w6H0OYFywMoPHTKnSLDQxFOUj iKWQvaanUlicw== 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 DE576CEDD9E; Wed, 9 Oct 2024 14:16:44 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Wed, 09 Oct 2024 16:16:44 +0200 Subject: [PATCH 2/4] iio: frequency: adf4371: drop spi_set_drvdata() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241009-dev-adf4371-minor-improv-v1-2-97f4f22ed941@analog.com> References: <20241009-dev-adf4371-minor-improv-v1-0-97f4f22ed941@analog.com> In-Reply-To: <20241009-dev-adf4371-minor-improv-v1-0-97f4f22ed941@analog.com> To: linux-iio@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728483403; l=635; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=c8IXZHd6rce/m7P5wiE54syNc8oDjduP+uF8+b2rhUc=; b=IB87rW+qOzKKtO7GHOve2HEtyGEcN2xSuQwTVBrazpZXrWjpYl8y8HUt0pcU1laY29yvXfN21 2dPj1aEKxl9AAOZsOD0aBGpvUr5E0ddtZPtENsziPw7Y6B5wvPYSv6V 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 spi_set_drvdata() is not needed as there's no spi_get_drvdata() call in the code. Signed-off-by: Nuno Sa --- drivers/iio/frequency/adf4371.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c index c8bf37f1679c..eb31f442566c 100644 --- a/drivers/iio/frequency/adf4371.c +++ b/drivers/iio/frequency/adf4371.c @@ -561,7 +561,6 @@ static int adf4371_probe(struct spi_device *spi) } st = iio_priv(indio_dev); - spi_set_drvdata(spi, indio_dev); st->spi = spi; st->regmap = regmap; mutex_init(&st->lock); From patchwork Wed Oct 9 14:16:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13828495 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 2C4D218BBAE for ; Wed, 9 Oct 2024 14:16:45 +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=1728483405; cv=none; b=sKkonIF7EUiYmG6WgGDCzAaTt2LFBIHmD2GwYntWqihmKYT0V0yTQQS5d52IfVbQXiGlLSx56gZrJlaqLaOGNxGuf4G9AkNNWvwiCti/j4RvEH1PnjFq5ebD/3x8hUlEwihNH7RjO7hLFgEO8xI70NnlhJetoJulPq7daihc+as= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728483405; c=relaxed/simple; bh=5wNlux5z+GNogEq0WHV+rdvAu3R+H+JeZIEZHnIemd8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L9QGiJlmmh9mIfj75At8ctPa6CfSNsLkrVbLx06zz0pCEMrC4BH38qq3NH2Q4W2wuKeWVKL1tNyHV4C2gBPMsMq1c9hfYDgRfpuknLhygwPTW+Oo8Pajj8nWZoGz/3QyP9Yf13aqt9BCvTY9PeGV6D/pg8VMhWJHXBJTpVAYa+4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XojnCSEp; 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="XojnCSEp" Received: by smtp.kernel.org (Postfix) with ESMTPS id 06B3DC4CEC5; Wed, 9 Oct 2024 14:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728483405; bh=5wNlux5z+GNogEq0WHV+rdvAu3R+H+JeZIEZHnIemd8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=XojnCSEpOzEGGxjhVItQLYhKbCfVAAR2+M7r+pOOk+kpqH/0/E7ZkYkfQa4KnSnDf MYy+KCnXXRJlyBgPvI6oSmd18lKY4/aUAClgECo9VMhT4IMNEdbqeMHQdL6x+H9hPw v54rJ31+8GE33DXo46Wv6k3mjF47hcDW6mLWZlDvXJgIn72ul7JuU7iq/hWNBEi+7z MiQ5eKKJpVxSxBRstr2tPasbpzB4vy8le1BrpfoaQToez0fxhXshmqZMhVcI3eT+lc lJJCtXG83Obg9fOZbsFkiPWMyf6A4+2YhFvQGCHwpCWfHUDcUCAm1yniNC47ls11GZ zw71jx4wDrZFQ== 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 00FC7CEDD9B; Wed, 9 Oct 2024 14:16:45 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Wed, 09 Oct 2024 16:16:45 +0200 Subject: [PATCH 3/4] iio: frequency: adf4371: drop clkin from struct adf4371_state Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241009-dev-adf4371-minor-improv-v1-3-97f4f22ed941@analog.com> References: <20241009-dev-adf4371-minor-improv-v1-0-97f4f22ed941@analog.com> In-Reply-To: <20241009-dev-adf4371-minor-improv-v1-0-97f4f22ed941@analog.com> To: linux-iio@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728483403; l=1585; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=Ic4YOIeGuD72RBXK+dHg9LtJlzq6oNWChpWqVJAnaFo=; b=2YprnA4ytZoZwrfvBTYZRKMx95RMEyoGkdCylRl78UCBuU+49E2hYEX1lj6CnDG9JhT4Sdmou DlTD4ZFJ2xEC+TYXbQISqmXg+OlNF3zZ+3vKnWcacHhRdlyIALCyKwd 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 We already cache clkin rate during probe and then never use the clk object again. Hence, no point in saving in our global state struct. Signed-off-by: Nuno Sa --- drivers/iio/frequency/adf4371.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c index eb31f442566c..45c8398a45d0 100644 --- a/drivers/iio/frequency/adf4371.c +++ b/drivers/iio/frequency/adf4371.c @@ -158,7 +158,6 @@ struct adf4371_chip_info { struct adf4371_state { struct spi_device *spi; struct regmap *regmap; - struct clk *clkin; /* * Lock for accessing device registers. Some operations require * multiple consecutive R/W operations, during which the device @@ -547,6 +546,7 @@ static int adf4371_probe(struct spi_device *spi) struct iio_dev *indio_dev; struct adf4371_state *st; struct regmap *regmap; + struct clk *clkin; int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); @@ -575,11 +575,11 @@ static int adf4371_probe(struct spi_device *spi) indio_dev->channels = st->chip_info->channels; indio_dev->num_channels = st->chip_info->num_channels; - st->clkin = devm_clk_get_enabled(&spi->dev, "clkin"); - if (IS_ERR(st->clkin)) - return PTR_ERR(st->clkin); + clkin = devm_clk_get_enabled(&spi->dev, "clkin"); + if (IS_ERR(clkin)) + return PTR_ERR(clkin); - st->clkin_freq = clk_get_rate(st->clkin); + st->clkin_freq = clk_get_rate(clkin); ret = adf4371_setup(st); if (ret < 0) { From patchwork Wed Oct 9 14:16:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13828498 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 A0E7B18BBAE for ; Wed, 9 Oct 2024 14:16:45 +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=1728483405; cv=none; b=Khcq2d/6hWC2iH2aKr91czbaAyL7zqU16R++TM/m6HjegSTMLsmwYMpk8oLXmxJC434wqEqsrqczK47QKLHZLiKEISnoyrVxs16JWXUVUMbYKI9NL07JIx4EY0WUdJlZRQWHpa7L47CURJo4K0DXzNisJKnkaNb/3S+6hvsjcBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728483405; c=relaxed/simple; bh=+/dityUc5wn114IVF17+AyRQGPqD0EBKXypj6trz0nQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bxF6M+X9tdYcu6ONwg0z5m5dIkJFbNU+Mse/U5w5SoTxTLeXPXwniu0d3RXrH2TiR/5kLIYLn/hu8o+e2IQNT76fNLQJm84ubmrDa52F6MTGnHkJcf9Gm9lkTojCjqsRvxK2IXfgWMmagWzpi352902YQbl9Ui3HlQGQWVru1D4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Be4F2LIJ; 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="Be4F2LIJ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1FA26C4CED2; Wed, 9 Oct 2024 14:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728483405; bh=+/dityUc5wn114IVF17+AyRQGPqD0EBKXypj6trz0nQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Be4F2LIJE/Gv4KXZZp+COK/P3dsBOBVd84Cutt1T7h1QQWpsMsj3bY8RfdpFlb97W cJ6rJ69Yx5mEQdpcDUzg5odV99ZJ0AmKqc3Ap4V6GxNOWqQzR773TdaLe6mCLnHXp9 EogM4eHSOE687FEiQAtL25e/05B7/KG1AgzFCNf+7lnR8ZT8oC3j5ofvtB6E0GycxS 8mzvpv1PlH7959F/NZMThbWCUkv6sa1QaNs6ZD4+xuEmjXfkwDNNlxhT1e8NlgSUjc hn011rU+i7xJjMEZsUqKoqUvS2KoPBbWtDPYMw+WFL19CaINsiK9Qy6XqmSmt0h2Bv +mT9dqYYX1E1w== 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 1274BCEDD9E; Wed, 9 Oct 2024 14:16:45 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Wed, 09 Oct 2024 16:16:46 +0200 Subject: [PATCH 4/4] iio: frequency: adf4371: make use of dev_err_probe() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241009-dev-adf4371-minor-improv-v1-4-97f4f22ed941@analog.com> References: <20241009-dev-adf4371-minor-improv-v1-0-97f4f22ed941@analog.com> In-Reply-To: <20241009-dev-adf4371-minor-improv-v1-0-97f4f22ed941@analog.com> To: linux-iio@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728483403; l=1733; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=DGH4I8LERGUVBi449GUHzvNvBiAJHsHztF+43+7F+ac=; b=WUiHMjYXsVhamHZoKp5SXwyL2fY/16mdslO7qxD9UkUMiZOLD/6K8CR+s4T2Y5EpYdqKf3JQu il75xzcUJFnDGY0blvg5wYcCKofRDCiAia3HsHT3jh1gX7rWoGJVxOP 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 Use dev_err_probe() to simplify probe() error handling. While at it, add some error log in case we fail to get clkin. Signed-off-by: Nuno Sa --- drivers/iio/frequency/adf4371.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c index 45c8398a45d0..d752507e0c98 100644 --- a/drivers/iio/frequency/adf4371.c +++ b/drivers/iio/frequency/adf4371.c @@ -4,6 +4,7 @@ * * Copyright 2019 Analog Devices Inc. */ +#include "linux/dev_printk.h" #include #include #include @@ -554,11 +555,9 @@ static int adf4371_probe(struct spi_device *spi) return -ENOMEM; regmap = devm_regmap_init_spi(spi, &adf4371_regmap_config); - if (IS_ERR(regmap)) { - dev_err(&spi->dev, "Error initializing spi regmap: %ld\n", - PTR_ERR(regmap)); - return PTR_ERR(regmap); - } + if (IS_ERR(regmap)) + return dev_err_probe(&spi->dev, PTR_ERR(regmap), + "Error initializing spi regmap\n"); st = iio_priv(indio_dev); st->spi = spi; @@ -577,15 +576,14 @@ static int adf4371_probe(struct spi_device *spi) clkin = devm_clk_get_enabled(&spi->dev, "clkin"); if (IS_ERR(clkin)) - return PTR_ERR(clkin); + return dev_err_probe(&spi->dev, PTR_ERR(clkin), + "Failed to get clkin\n"); st->clkin_freq = clk_get_rate(clkin); ret = adf4371_setup(st); - if (ret < 0) { - dev_err(&spi->dev, "ADF4371 setup failed\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(&spi->dev, ret, "ADF4371 setup failed\n"); return devm_iio_device_register(&spi->dev, indio_dev); }