Linux IIO development
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Lothar Rubusch <l.rubusch@gmail.com>,
	lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org
Cc: linux-iio@vger.kernel.org, eraretuya@gmail.com
Subject: Re: [PATCH 1/2] iio: adxl345: add spi-3wire
Date: Wed, 20 Mar 2024 10:37:42 +0100	[thread overview]
Message-ID: <7f349041-bf2f-434d-a9cd-a82ac902f613@kernel.org> (raw)
In-Reply-To: <20240319212713.257600-2-l.rubusch@gmail.com>

On 19/03/2024 22:27, Lothar Rubusch wrote:
> Adds the spi-3wire feature and adds general refactoring to the

Add

> iio driver.
> 
> The patch moves driver wide constants and fields into the

Please do not use "This commit/patch/change", but imperative mood. See
longer explanation here:
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95

> header. Thereby reduces redundant info struct definitions.
> Allows to pass a function pointer from SPI/I2C specific probe,
> and smaller refactorings. A regmap_update_bits() in the core
> file replaces the regmap_write() to format_data.
> 
> Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
> ---



>  static int adxl345_spi_probe(struct spi_device *spi)
>  {
> +	const struct adxl345_chip_info *chip_data;
>  	struct regmap *regmap;
>  
> +	/* Retrieve device name to pass it as driver specific data */
> +	chip_data = device_get_match_data(&spi->dev);
> +	if (!chip_data)
> +		chip_data = (const struct adxl345_chip_info *) spi_get_device_id(spi)->driver_data;

Are you sure you need the cast?

And why aren't you using spi_get_device_match_data()?

> +
>  	/* Bail out if max_speed_hz exceeds 5 MHz */
>  	if (spi->max_speed_hz > ADXL345_MAX_SPI_FREQ_HZ)
>  		return dev_err_probe(&spi->dev, -EINVAL, "SPI CLK, %d Hz exceeds 5 MHz\n",
>  				     spi->max_speed_hz);
>  
>  	regmap = devm_regmap_init_spi(spi, &adxl345_spi_regmap_config);
> -	if (IS_ERR(regmap))
> -		return dev_err_probe(&spi->dev, PTR_ERR(regmap), "Error initializing regmap\n");
> +	if (IS_ERR(regmap)) {
> +		dev_err_probe(&spi->dev, PTR_ERR(regmap), "Error initializing spi regmap: %ld\n",
> +			      PTR_ERR(regmap));
> +		return PTR_ERR(regmap);

Why are you changing correct code into incorrect?

> +	}
>  
> -	return adxl345_core_probe(&spi->dev, regmap);
> +	return adxl345_core_probe(&spi->dev, regmap, chip_data, &adxl345_spi_setup);
>  }


Best regards,
Krzysztof


  reply	other threads:[~2024-03-20  9:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19 21:27 [PATCH 0/2] iio: adxl345: add spi-3wire and refac Lothar Rubusch
2024-03-19 21:27 ` [PATCH 1/2] iio: adxl345: add spi-3wire Lothar Rubusch
2024-03-20  9:37   ` Krzysztof Kozlowski [this message]
2024-03-22  0:32     ` Lothar Rubusch
2024-03-22  5:37       ` Krzysztof Kozlowski
2024-03-22  6:58         ` Nuno Sá
2024-03-24 13:14       ` Jonathan Cameron
2024-03-20 10:34   ` Nuno Sá
2024-03-22  0:33     ` Lothar Rubusch
2024-03-19 21:27 ` [PATCH 2/2] iio: adxl345: update documentation for spi-3wire Lothar Rubusch
2024-03-20  9:34   ` Krzysztof Kozlowski
2024-03-22  0:27     ` Lothar Rubusch
2024-03-22  5:36       ` Krzysztof Kozlowski

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=7f349041-bf2f-434d-a9cd-a82ac902f613@kernel.org \
    --to=krzk@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=eraretuya@gmail.com \
    --cc=jic23@kernel.org \
    --cc=l.rubusch@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    /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