Skip to contentSkip to conversation

iio: adxl345: add spi-3wire and refac

PATCH Superseded Lothar Rubusch 4 participants 13 messages Mar 19, 2024 – Mar 24, 2024

Subsystems (4)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover iio: adxl345: add spi-3wire and refac

The patch adds the spi-3wire feature and some refactoring to the adxl345/375 accelerometer driver (iio). A separate patch updates the DT binding.

Lothar Rubusch (2):
iio: adxl345: add spi-3wire
iio: adxl345: update documentation for spi-3wire

 .../bindings/iio/accel/adi,adxl345.yaml       |   2 +
 drivers/iio/accel/adxl345.h                   |  44 ++++++-
 drivers/iio/accel/adxl345_core.c              | 116 ++++++++++--------
 drivers/iio/accel/adxl345_i2c.c               |  30 ++---
 drivers/iio/accel/adxl345_spi.c               |  50 +++++---
 5 files changed, 155 insertions(+), 87 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 iio: adxl345: add spi-3wire

Adds the spi-3wire feature and adds general refactoring to the iio driver.

The patch moves driver wide constants and fields into the 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.

---
 drivers/iio/accel/adxl345.h      |  44 +++++++++++-
 drivers/iio/accel/adxl345_core.c | 116 +++++++++++++++++--------------
 drivers/iio/accel/adxl345_i2c.c  |  30 ++++----
 drivers/iio/accel/adxl345_spi.c  |  50 ++++++++-----
 4 files changed, 153 insertions(+), 87 deletions(-)
drivers/iio/accel/adxl345.h +43 -1
index 284bd387c..01493c999 100644
@@ -8,6 +8,39 @@
 #ifndef _ADXL345_H_
 #define _ADXL345_H_
 
+#include <linux/iio/iio.h>
+
+/* ADXL345 register definitions */
+#define ADXL345_REG_DEVID		0x00
+#define ADXL345_REG_OFSX		0x1E
+#define ADXL345_REG_OFSY		0x1F
+#define ADXL345_REG_OFSZ		0x20
+#define ADXL345_REG_OFS_AXIS(index)	(ADXL345_REG_OFSX + (index))
+#define ADXL345_REG_BW_RATE		0x2C
+#define ADXL345_REG_POWER_CTL		0x2D
+#define ADXL345_REG_DATA_FORMAT		0x31
+#define ADXL345_REG_DATAX0		0x32
+#define ADXL345_REG_DATAY0		0x34
+#define ADXL345_REG_DATAZ0		0x36
+#define ADXL345_REG_DATA_AXIS(index)	\
+	(ADXL345_REG_DATAX0 + (index) * sizeof(__le16))
+
+#define ADXL345_BW_RATE			GENMASK(3, 0)
+#define ADXL345_BASE_RATE_NANO_HZ	97656250LL
+
+#define ADXL345_POWER_CTL_MEASURE	BIT(3)
+#define ADXL345_POWER_CTL_STANDBY	0x00
+
+#define ADXL345_DATA_FORMAT_FULL_RES	BIT(3) /* Up to 13-bits resolution */
+#define ADXL345_DATA_FORMAT_SPI         BIT(6) /* spi-3wire */
+#define ADXL345_DATA_FORMAT_2G		0
+#define ADXL345_DATA_FORMAT_4G		1
+#define ADXL345_DATA_FORMAT_8G		2
+#define ADXL345_DATA_FORMAT_16G		3
+#define ADXL345_DATA_FORMAT_MSK		~((u8) BIT(6)) /* ignore spi-3wire */
+
+#define ADXL345_DEVID			0xE5
+
 /*
  * In full-resolution mode, scale factor is maintained at ~4 mg/LSB
  * in all g ranges.
@@ -23,11 +56,20 @@
  */
 #define ADXL375_USCALE	480000
 
+enum adxl345_device_type {
+	ADXL345,
+	ADXL375,
+};
+
 struct adxl345_chip_info {
 	const char *name;
 	int uscale;
 };
 
-int adxl345_core_probe(struct device *dev, struct regmap *regmap);
+extern const struct adxl345_chip_info adxl3x5_chip_info[];
+
+int adxl345_core_probe(struct device *dev, struct regmap *regmap,
+		       const struct adxl345_chip_info *chip_info,
+		       int (*setup)(struct device*, struct regmap*));
 
 #endif /* _ADXL345_H_ */
drivers/iio/accel/adxl345_core.c +65 -51

160 lines not on this page · raw message

drivers/iio/accel/adxl345_i2c.c +13 -17
index a3084b0a8..3f882e2e0 100644
@@ -9,6 +9,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
 
@@ -21,41 +22,36 @@ static const struct regmap_config adxl345_i2c_regmap_config = {
 
 static int adxl345_i2c_probe(struct i2c_client *client)
 {
+	const struct adxl345_chip_info *chip_data;
 	struct regmap *regmap;
 
+	/* Retrieve device data, i.e. the name, to pass it to the core */
+	chip_data = i2c_get_match_data(client);
+
 	regmap = devm_regmap_init_i2c(client, &adxl345_i2c_regmap_config);
 	if (IS_ERR(regmap))
-		return dev_err_probe(&client->dev, PTR_ERR(regmap), "Error initializing regmap\n");
+		return dev_err_probe(&client->dev, PTR_ERR(regmap),
+				     "Error initializing regmap\n");
 
-	return adxl345_core_probe(&client->dev, regmap);
+	return adxl345_core_probe(&client->dev, regmap, chip_data, NULL);
 }
 
-static const struct adxl345_chip_info adxl345_i2c_info = {
-	.name = "adxl345",
-	.uscale = ADXL345_USCALE,
-};
-
-static const struct adxl345_chip_info adxl375_i2c_info = {
-	.name = "adxl375",
-	.uscale = ADXL375_USCALE,
-};
-
 static const struct i2c_device_id adxl345_i2c_id[] = {
-	{ "adxl345", (kernel_ulong_t)&adxl345_i2c_info },
-	{ "adxl375", (kernel_ulong_t)&adxl375_i2c_info },
+	{ "adxl345", (kernel_ulong_t)&adxl3x5_chip_info[ADXL345] },
+	{ "adxl375", (kernel_ulong_t)&adxl3x5_chip_info[ADXL375] },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, adxl345_i2c_id);
 
 static const struct of_device_id adxl345_of_match[] = {
-	{ .compatible = "adi,adxl345", .data = &adxl345_i2c_info },
-	{ .compatible = "adi,adxl375", .data = &adxl375_i2c_info },
+	{ .compatible = "adi,adxl345", .data = &adxl3x5_chip_info[ADXL345] },
+	{ .compatible = "adi,adxl375", .data = &adxl3x5_chip_info[ADXL375] },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, adxl345_of_match);
 
 static const struct acpi_device_id adxl345_acpi_match[] = {
-	{ "ADS0345", (kernel_ulong_t)&adxl345_i2c_info },
+	{ "ADS0345", (kernel_ulong_t)&adxl3x5_chip_info[ADXL345] },
 	{ }
 };
 MODULE_DEVICE_TABLE(acpi, adxl345_acpi_match);
drivers/iio/accel/adxl345_spi.c +32 -18

80 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/2] iio: adxl345: add spi-3wire

Quoted 1 line · Lothar Rubusch

Adds the spi-3wire feature and adds general refactoring to the

Add

Quoted 3 lines

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

Quoted 12 lines

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.

---

static int adxl345_spi_probe(struct spi_device *spi) {

drivers/iio/accel/adxl345_spi.c static const struct regmap_config adxl345_spi_regmap_config = { · line 46

Quoted 7 lines
drivers/iio/accel/adxl345_spi.c +5 -0
+	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()?

drivers/iio/accel/adxl345_spi.c static const struct regmap_config adxl345_spi_regmap_config = { · line 57

Quoted 13 lines
drivers/iio/accel/adxl345_spi.c +5 -2
+
 	/* 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?

drivers/iio/accel/adxl345_spi.c static const struct regmap_config adxl345_spi_regmap_config = { · line 61

Quoted 5 lines
drivers/iio/accel/adxl345_spi.c +2 -1
+	}
 
-	return adxl345_core_probe(&spi->dev, regmap);
+	return adxl345_core_probe(&spi->dev, regmap, chip_data, &adxl345_spi_setup);
 }

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH 1/2] iio: adxl345: add spi-3wire

Quoted 6 lines · Krzysztof Kozlowski
Quoted 1 line · Lothar Rubusch

Adds the spi-3wire feature and adds general refactoring to the

Add

Quoted 15 lines
Quoted 3 lines

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

Quoted 7 lines

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.

---

Agree

Quoted 5 lines
Quoted 5 lines

static int adxl345_spi_probe(struct spi_device *spi) {

+     const struct adxl345_chip_info *chip_data;
      struct regmap *regmap;
Quoted 8 lines

drivers/iio/accel/adxl345_spi.c static const struct regmap_config adxl345_spi_regmap_config = { · line 46

Quoted 4 lines
drivers/iio/accel/adxl345_spi.c +4 -0
+     /* 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()?

Agree

Quoted 14 lines

drivers/iio/accel/adxl345_spi.c static const struct regmap_config adxl345_spi_regmap_config = { · line 57

Quoted 13 lines
drivers/iio/accel/adxl345_spi.c +5 -2
+
      /* 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);
Quoted 1 line

Why are you changing correct code into incorrect?

I'll adjust that. It looks odd, I agree, but is this incorrect code? I found similar code in the neighbor adxl313 accel driver. I may change/update
that then, too. Thank you for the hints.

adxl313_i2c.c
72 if (IS_ERR(regmap)) {
73 dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
74 PTR_ERR(regmap));
75 return PTR_ERR(regmap);
76 }

Quoted 10 lines

drivers/iio/accel/adxl345_spi.c static const struct regmap_config adxl345_spi_regmap_config = { · line 61

Quoted 5 lines
drivers/iio/accel/adxl345_spi.c +2 -1
+     }
 
-     return adxl345_core_probe(&spi->dev, regmap);
+     return adxl345_core_probe(&spi->dev, regmap, chip_data, &adxl345_spi_setup);
 }

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH 1/2] iio: adxl345: add spi-3wire

Quoted 15 lines · Lothar Rubusch
Quoted 15 lines
Quoted 14 lines
drivers/iio/accel/adxl345_spi.c +5 -2
+
      /* 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);
Quoted 5 lines
Quoted 1 line

Why are you changing correct code into incorrect?

I'll adjust that. It looks odd, I agree, but is this incorrect code? I found similar code in the neighbor adxl313 accel driver. I may change/update
that then, too. Thank you for the hints.

Please explain why you are doing this. How is this related to adding SPI 3-wire mode?

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH 1/2] iio: adxl345: add spi-3wire

Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Lothar Rubusch
Quoted 18 lines
Quoted 17 lines

+
      /* 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);

Quoted 10 lines
Quoted 5 lines
Quoted 1 line

Why are you changing correct code into incorrect?

I'll adjust that. It looks odd, I agree, but is this incorrect code? I found similar code in the neighbor adxl313 accel driver. I may change/update that then, too. Thank   you for the hints.

Please explain why you are doing this. How is this related to adding SPI 3-wire mode?

Yeah... Already asked to separate the refactor from the feature in two different patches.

- Nuno Sá

maintainer
#6 lore raw

Re: [PATCH 1/2] iio: adxl345: add spi-3wire

In reply to Lothar Rubusch
Quoted 61 lines · On Fri, 22 Mar 2024 01:32:11 +0100 Lothar Rubusch <[email protected]> wrote:
Quoted 6 lines · Krzysztof Kozlowski
Quoted 1 line · Lothar Rubusch

Adds the spi-3wire feature and adds general refactoring to the

Add

Quoted 15 lines
Quoted 3 lines

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

Quoted 7 lines

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.

---

Agree

Quoted 5 lines
Quoted 5 lines

static int adxl345_spi_probe(struct spi_device *spi) {

+     const struct adxl345_chip_info *chip_data;
      struct regmap *regmap;
Quoted 8 lines

drivers/iio/accel/adxl345_spi.c static const struct regmap_config adxl345_spi_regmap_config = { · line 46

Quoted 4 lines
drivers/iio/accel/adxl345_spi.c +4 -0
+     /* 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()?

Agree

Quoted 14 lines

drivers/iio/accel/adxl345_spi.c static const struct regmap_config adxl345_spi_regmap_config = { · line 57

Quoted 13 lines
drivers/iio/accel/adxl345_spi.c +5 -2
+
      /* 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);  
Quoted 1 line

Why are you changing correct code into incorrect?

I'll adjust that. It looks odd, I agree, but is this incorrect code? I found similar code in the neighbor adxl313 accel driver. I may change/update
that then, too. Thank you for the hints.

Quoted 6 lines

adxl313_i2c.c
72 if (IS_ERR(regmap)) {
73 dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
74 PTR_ERR(regmap));
75 return PTR_ERR(regmap);
76 }

dev_err_probe() already pretty prints the error so no point in repeating it. It also returns the error value so you can do it on one line. dev_err() does neither of these things.

Likely that axl313_i2c.c could be converted to use dev_err_probe() for all calls in the probe() function and anything only called as part of that.

Patches welcome.

Jonathan

Quoted 11 lines
Quoted 11 lines

drivers/iio/accel/adxl345_spi.c static const struct regmap_config adxl345_spi_regmap_config = { · line 61

Quoted 6 lines
drivers/iio/accel/adxl345_spi.c +2 -1
+     }
 
-     return adxl345_core_probe(&spi->dev, regmap);
+     return adxl345_core_probe(&spi->dev, regmap, chip_data, &adxl345_spi_setup);
 }  

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH 1/2] iio: adxl345: add spi-3wire

In reply to Lothar Rubusch
Quoted 11 lines · Lothar Rubusch

Adds the spi-3wire feature and adds general refactoring to the iio driver.

The patch moves driver wide constants and fields into the 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.

---

On top of what Krzysztof already said I would also like for you to split the spi-3wire (which is adding a new feature) from the refactor in two different patches. One more comment inline...

Quoted 6 lines

 drivers/iio/accel/adxl345.h      |  44 +++++++++++- drivers/iio/accel/adxl345_core.c | 116 +++++++++++++++++-------------- drivers/iio/accel/adxl345_i2c.c  |  30 ++++---- drivers/iio/accel/adxl345_spi.c  |  50 ++++++++-----

 4 files changed, 153 insertions(+), 87 deletions(-)

...

Quoted 12 lines
drivers/iio/accel/adxl345_spi.c +0 -0
index 93ca349f1..e456b61c6 100644
@@ -20,48 +20,62 @@ static const struct regmap_config
 adxl345_spi_regmap_config = {
  	.read_flag_mask = BIT(7) | BIT(6),
  };

drivers/iio/accel/adxl345_spi.c +3 -0
+static int adxl345_spi_setup(struct device *dev, struct regmap *regmap)
+{
+	struct spi_device *spi = container_of(dev, struct spi_device, dev);

drivers/iio/accel/adxl345_spi.c static const struct regmap_config adxl345_spi_regmap_config = { · line 35

Quoted 10 lines
drivers/iio/accel/adxl345_spi.c +10 -0
+	int ret;
+
+	if (spi->mode & SPI_3WIRE) {
+		ret = regmap_write(regmap, ADXL345_REG_DATA_FORMAT,
+				   ADXL345_DATA_FORMAT_SPI);
+		if (ret)
+			return ret;
+	}
+
+	return 0;

I think this would be neater:

if (!(spi->mode & SPI_3WIRE))

	return 0;

return regmap_write(regmap, ADXL345_REG_DATA_FORMAT,

		    ADXL345_DATA_FORMAT_SPI);

- Nuno Sá

#8 lore raw

Re: [PATCH 1/2] iio: adxl345: add spi-3wire

Quoted 11 lines · Nuno Sá
Quoted 9 lines · Lothar Rubusch

Adds the spi-3wire feature and adds general refactoring to the iio driver.

The patch moves driver wide constants and fields into the 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.

Quoted 6 lines
Quoted 2 lines

---

On top of what Krzysztof already said I would also like for you to split the spi-3wire (which is adding a new feature) from the refactor in two different patches. One more comment inline...

Agree

Quoted 34 lines
Quoted 6 lines
 drivers/iio/accel/adxl345.h      |  44 +++++++++++-
 drivers/iio/accel/adxl345_core.c | 116 +++++++++++++++++--------------
 drivers/iio/accel/adxl345_i2c.c  |  30 ++++----
 drivers/iio/accel/adxl345_spi.c  |  50 ++++++++-----
 4 files changed, 153 insertions(+), 87 deletions(-)

...

Quoted 12 lines
drivers/iio/accel/adxl345_spi.c +3 -0
index 93ca349f1..e456b61c6 100644
@@ -20,48 +20,62 @@ static const struct regmap_config
 adxl345_spi_regmap_config = {
      .read_flag_mask = BIT(7) | BIT(6),
 };
 
+static int adxl345_spi_setup(struct device *dev, struct regmap *regmap)
+{
+     struct spi_device *spi = container_of(dev, struct spi_device, dev);

drivers/iio/accel/adxl345_spi.c static const struct regmap_config · line 36

Quoted 10 lines
drivers/iio/accel/adxl345_spi.c +10 -0
+     int ret;
+
+     if (spi->mode & SPI_3WIRE) {
+             ret = regmap_write(regmap, ADXL345_REG_DATA_FORMAT,
+                                ADXL345_DATA_FORMAT_SPI);
+             if (ret)
+                     return ret;
+     }
+
+     return 0;

I think this would be neater:

Quoted 5 lines

if (!(spi->mode & SPI_3WIRE))

        return 0;

return regmap_write(regmap, ADXL345_REG_DATA_FORMAT,

                    ADXL345_DATA_FORMAT_SPI);

Definitely. Thank you.

Best,
L

#9 lore raw

PATCH 2/2 iio: adxl345: update documentation for spi-3wire

In reply to Lothar Rubusch

Provide the optional spi-3wire option for the DT binding.

---
 Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml +2 -0
index 07cacc3f6..280ed479e 100644
@@ -32,6 +32,8 @@ properties:
 
   spi-cpol: true
 
+  spi-3wire: true
+
   interrupts:
     maxItems: 1
 
Signature · 1 line
2.25.1
#10 lore raw

Re: [PATCH 2/2] iio: adxl345: update documentation for spi-3wire

Quoted 3 lines · Lothar Rubusch

Provide the optional spi-3wire option for the DT binding.

A nit, subject: drop second/last, redundant "documentation". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Also, everything is an update. Be descriptive.

Please use subject prefixes matching the subsystem. You can get them for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching.

Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.

Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline), work on fork of kernel (don't, instead use mainline) or you ignore some maintainers (really don't). Just use b4 and everything should be fine, although remember about b4 prep --auto-to-cc if you added new patches to the patchset.

You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time, thus I will skip this patch entirely till you follow the process allowing the patch to be tested.

Please kindly resend and include all necessary To/Cc entries.

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH 2/2] iio: adxl345: update documentation for spi-3wire

Quoted 4 lines · Krzysztof Kozlowski
Quoted 2 lines · Lothar Rubusch

Provide the optional spi-3wire option for the DT binding.

Quoted 8 lines
Quoted 1 line

A nit, subject: drop second/last, redundant "documentation". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Also, everything is an update. Be descriptive.

Ok

Quoted 3 lines

Please use subject prefixes matching the subsystem. You can get them for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching.

Yes. Next time I'll chose better prefixes. For now I keep the subject to the mail to not break the mailing thread and update the patches in a follow up. I hope this is ok?

Quoted 17 lines

Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.

Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline), work on fork of kernel (don't, instead use mainline) or you ignore some maintainers (really don't). Just use b4 and everything should be fine, although remember about b4 prep --auto-to-cc if you added new patches to the patchset.

You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time, thus I will skip this patch entirely till you follow the process allowing the patch to be tested.

Quoted 4 lines

Please kindly resend and include all necessary To/Cc entries.

Best regards,
Krzysztof

I understand. I took linux-next. I fetched it this week from mainline kernel.org. I took "get_maintainers.pl" as a mere recommendation rather than mandatory and skipped most of the emails. Sry for that. Thank you for all the information.

#12 lore raw

Re: [PATCH 2/2] iio: adxl345: update documentation for spi-3wire

Quoted 8 lines · Lothar Rubusch
Quoted 4 lines

Please use subject prefixes matching the subsystem. You can get them for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching.

Yes. Next time I'll chose better prefixes. For now I keep the subject to the mail to not break the mailing thread and update the patches in a follow up. I hope this is ok?

No. Email threading depends on reply-to headers, not subject. It's irrelevant.

Best regards,
Krzysztof