mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Antoniu Miclaus <antoniu.miclaus@analog.com>
To: "Antoniu Miclaus" <antoniu.miclaus@analog.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 03/12] iio: frequency: admv1014: introduce struct device variable
Date: Mon, 23 Feb 2026 15:13:54 +0200	[thread overview]
Message-ID: <20260223131418.55414-4-antoniu.miclaus@analog.com> (raw)
In-Reply-To: <20260223131418.55414-1-antoniu.miclaus@analog.com>

Add struct device *dev local variable to simplify repeated &spi->dev
dereferences. Where spi is no longer needed beyond &spi->dev, replace
struct spi_device *spi with struct device *dev = &st->spi->dev.

No functional change.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 drivers/iio/frequency/admv1014.c | 49 ++++++++++++++++----------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/drivers/iio/frequency/admv1014.c b/drivers/iio/frequency/admv1014.c
index 7a8f92ec80a2..ce1b40336e15 100644
--- a/drivers/iio/frequency/admv1014.c
+++ b/drivers/iio/frequency/admv1014.c
@@ -609,16 +609,16 @@ static void admv1014_powerdown(void *data)
 static int admv1014_init(struct admv1014_state *st)
 {
 	unsigned int chip_id, enable_reg, enable_reg_msk;
-	struct spi_device *spi = st->spi;
+	struct device *dev = &st->spi->dev;
 	int ret;
 
 	ret = regulator_bulk_enable(ADMV1014_NUM_REGULATORS, st->regulators);
 	if (ret) {
-		dev_err(&spi->dev, "Failed to enable regulators");
+		dev_err(dev, "Failed to enable regulators");
 		return ret;
 	}
 
-	ret = devm_add_action_or_reset(&spi->dev, admv1014_reg_disable, st->regulators);
+	ret = devm_add_action_or_reset(dev, admv1014_reg_disable, st->regulators);
 	if (ret)
 		return ret;
 
@@ -626,16 +626,16 @@ static int admv1014_init(struct admv1014_state *st)
 	if (ret)
 		return ret;
 
-	ret = devm_add_action_or_reset(&spi->dev, admv1014_clk_disable, st->clkin);
+	ret = devm_add_action_or_reset(dev, admv1014_clk_disable, st->clkin);
 	if (ret)
 		return ret;
 
 	st->nb.notifier_call = admv1014_freq_change;
-	ret = devm_clk_notifier_register(&spi->dev, st->clkin, &st->nb);
+	ret = devm_clk_notifier_register(dev, st->clkin, &st->nb);
 	if (ret)
 		return ret;
 
-	ret = devm_add_action_or_reset(&spi->dev, admv1014_powerdown, st);
+	ret = devm_add_action_or_reset(dev, admv1014_powerdown, st);
 	if (ret)
 		return ret;
 
@@ -644,7 +644,7 @@ static int admv1014_init(struct admv1014_state *st)
 					 ADMV1014_SPI_SOFT_RESET_MSK,
 					 FIELD_PREP(ADMV1014_SPI_SOFT_RESET_MSK, 1));
 	if (ret) {
-		dev_err(&spi->dev, "ADMV1014 SPI software reset failed.\n");
+		dev_err(dev, "ADMV1014 SPI software reset failed.\n");
 		return ret;
 	}
 
@@ -652,13 +652,13 @@ static int admv1014_init(struct admv1014_state *st)
 					 ADMV1014_SPI_SOFT_RESET_MSK,
 					 FIELD_PREP(ADMV1014_SPI_SOFT_RESET_MSK, 0));
 	if (ret) {
-		dev_err(&spi->dev, "ADMV1014 SPI software reset disable failed.\n");
+		dev_err(dev, "ADMV1014 SPI software reset disable failed.\n");
 		return ret;
 	}
 
 	ret = __admv1014_spi_write(st, ADMV1014_REG_VVA_TEMP_COMP, 0x727C);
 	if (ret) {
-		dev_err(&spi->dev, "Writing default Temperature Compensation value failed.\n");
+		dev_err(dev, "Writing default Temperature Compensation value failed.\n");
 		return ret;
 	}
 
@@ -668,7 +668,7 @@ static int admv1014_init(struct admv1014_state *st)
 
 	chip_id = FIELD_GET(ADMV1014_CHIP_ID_MSK, chip_id);
 	if (chip_id != ADMV1014_CHIP_ID) {
-		dev_err(&spi->dev, "Invalid Chip ID.\n");
+		dev_err(dev, "Invalid Chip ID.\n");
 		return -EINVAL;
 	}
 
@@ -677,19 +677,19 @@ static int admv1014_init(struct admv1014_state *st)
 					 FIELD_PREP(ADMV1014_QUAD_SE_MODE_MSK,
 						    st->quad_se_mode));
 	if (ret) {
-		dev_err(&spi->dev, "Writing Quad SE Mode failed.\n");
+		dev_err(dev, "Writing Quad SE Mode failed.\n");
 		return ret;
 	}
 
 	ret = admv1014_update_quad_filters(st);
 	if (ret) {
-		dev_err(&spi->dev, "Update Quad Filters failed.\n");
+		dev_err(dev, "Update Quad Filters failed.\n");
 		return ret;
 	}
 
 	ret = admv1014_update_vcm_settings(st);
 	if (ret) {
-		dev_err(&spi->dev, "Update VCM Settings failed.\n");
+		dev_err(dev, "Update VCM Settings failed.\n");
 		return ret;
 	}
 
@@ -711,14 +711,14 @@ static int admv1014_init(struct admv1014_state *st)
 static int admv1014_properties_parse(struct admv1014_state *st)
 {
 	unsigned int i;
-	struct spi_device *spi = st->spi;
+	struct device *dev = &st->spi->dev;
 	int ret;
 
-	st->det_en = device_property_read_bool(&spi->dev, "adi,detector-enable");
+	st->det_en = device_property_read_bool(dev, "adi,detector-enable");
 
-	st->p1db_comp = device_property_read_bool(&spi->dev, "adi,p1db-compensation-enable");
+	st->p1db_comp = device_property_read_bool(dev, "adi,p1db-compensation-enable");
 
-	ret = device_property_match_property_string(&spi->dev, "adi,input-mode",
+	ret = device_property_match_property_string(dev, "adi,input-mode",
 						    input_mode_names,
 						    ARRAY_SIZE(input_mode_names));
 	if (ret >= 0)
@@ -726,7 +726,7 @@ static int admv1014_properties_parse(struct admv1014_state *st)
 	else
 		st->input_mode = ADMV1014_IQ_MODE;
 
-	ret = device_property_match_property_string(&spi->dev, "adi,quad-se-mode",
+	ret = device_property_match_property_string(dev, "adi,quad-se-mode",
 						    quad_se_mode_names,
 						    ARRAY_SIZE(quad_se_mode_names));
 	if (ret >= 0)
@@ -737,16 +737,16 @@ static int admv1014_properties_parse(struct admv1014_state *st)
 	for (i = 0; i < ADMV1014_NUM_REGULATORS; ++i)
 		st->regulators[i].supply = admv1014_reg_name[i];
 
-	ret = devm_regulator_bulk_get(&st->spi->dev, ADMV1014_NUM_REGULATORS,
+	ret = devm_regulator_bulk_get(dev, ADMV1014_NUM_REGULATORS,
 				      st->regulators);
 	if (ret) {
-		dev_err(&spi->dev, "Failed to request regulators");
+		dev_err(dev, "Failed to request regulators");
 		return ret;
 	}
 
-	st->clkin = devm_clk_get(&spi->dev, "lo_in");
+	st->clkin = devm_clk_get(dev, "lo_in");
 	if (IS_ERR(st->clkin))
-		return dev_err_probe(&spi->dev, PTR_ERR(st->clkin),
+		return dev_err_probe(dev, PTR_ERR(st->clkin),
 				     "failed to get the LO input clock\n");
 
 	return 0;
@@ -756,9 +756,10 @@ static int admv1014_probe(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev;
 	struct admv1014_state *st;
+	struct device *dev = &spi->dev;
 	int ret;
 
-	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
 	if (!indio_dev)
 		return -ENOMEM;
 
@@ -787,7 +788,7 @@ static int admv1014_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	return devm_iio_device_register(&spi->dev, indio_dev);
+	return devm_iio_device_register(dev, indio_dev);
 }
 
 static const struct spi_device_id admv1014_id[] = {
-- 
2.43.0


  parent reply	other threads:[~2026-02-23 13:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 13:13 [PATCH v2 00/12] iio: use dev_err_probe in probe path for ADI drivers Antoniu Miclaus
2026-02-23 13:13 ` [PATCH v2 01/12] iio: frequency: adrf6780: introduce struct device variable Antoniu Miclaus
2026-02-23 13:13 ` [PATCH v2 02/12] iio: frequency: adrf6780: use dev_err_probe in probe path Antoniu Miclaus
2026-02-23 13:13 ` Antoniu Miclaus [this message]
2026-02-23 13:55   ` [PATCH v2 03/12] iio: frequency: admv1014: introduce struct device variable Andy Shevchenko
2026-02-23 13:13 ` [PATCH v2 04/12] iio: frequency: admv1014: use dev_err_probe in probe path Antoniu Miclaus
2026-02-23 13:57   ` Andy Shevchenko
2026-02-23 13:13 ` [PATCH v2 05/12] iio: frequency: admv1013: introduce struct device variable Antoniu Miclaus
2026-02-23 13:13 ` [PATCH v2 06/12] iio: frequency: admv1013: use dev_err_probe in probe path Antoniu Miclaus
2026-02-23 13:13 ` [PATCH v2 07/12] iio: frequency: adf4377: introduce struct device variable Antoniu Miclaus
2026-02-23 13:13 ` [PATCH v2 08/12] iio: frequency: adf4377: use dev_err_probe in probe path Antoniu Miclaus
2026-02-23 13:14 ` [PATCH v2 09/12] iio: dac: ad7293: introduce struct device variable Antoniu Miclaus
2026-02-23 13:14 ` [PATCH v2 10/12] iio: dac: ad7293: use dev_err_probe in probe path Antoniu Miclaus
2026-02-23 13:14 ` [PATCH v2 11/12] iio: filter: admv8818: introduce struct device variable Antoniu Miclaus
2026-02-23 13:14 ` [PATCH v2 12/12] iio: filter: admv8818: use dev_err_probe in probe path Antoniu Miclaus
2026-02-23 14:03 ` [PATCH v2 00/12] iio: use dev_err_probe in probe path for ADI drivers 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=20260223131418.55414-4-antoniu.miclaus@analog.com \
    --to=antoniu.miclaus@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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

all inboxes | Powered by JetHome®