Linux IIO development
 help / color / mirror / Atom feed
From: Louis Adamian <adamianlouis@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>
Cc: Louis Adamian <adamianlouis@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 2/5] iio: pressure: ms5637: Move device data struct to header
Date: Thu, 20 Aug 2026 10:12:17 -0400	[thread overview]
Message-ID: <20260820141224.23730-3-adamianlouis@gmail.com> (raw)
In-Reply-To: <20260820141224.23730-1-adamianlouis@gmail.com>

ms_tp_dev duplicated the hw pointer already in ms_tp_data. This stores a
pointer to ms_tp_data instead which requires moving the struct
definition from ms5637.c to ms_sensors_i2c.h.

No functional change intended

Signed-off-by: Louis Adamian <adamianlouis@gmail.com>
---
 drivers/iio/common/ms_sensors/ms_sensors_i2c.c |  4 ++--
 drivers/iio/common/ms_sensors/ms_sensors_i2c.h | 13 ++++++++++++-
 drivers/iio/pressure/ms5637.c                  |  9 ++-------
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/common/ms_sensors/ms_sensors_i2c.c b/drivers/iio/common/ms_sensors/ms_sensors_i2c.c
index 1960a2ce82a8..f9dc7c7468c1 100644
--- a/drivers/iio/common/ms_sensors/ms_sensors_i2c.c
+++ b/drivers/iio/common/ms_sensors/ms_sensors_i2c.c
@@ -579,7 +579,7 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data)
 	int i, ret;
 	bool valid;
 
-	for (i = 0; i < dev_data->hw->prom_len; i++) {
+	for (i = 0; i < dev_data->data->hw->prom_len; i++) {
 		ret = ms_sensors_read_prom_word(
 			dev_data->client,
 			MS_SENSORS_TP_PROM_READ + (i << 1),
@@ -589,7 +589,7 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data)
 			return ret;
 	}
 
-	if (dev_data->hw->prom_len == 8)
+	if (dev_data->data->hw->prom_len == 8)
 		valid = ms_sensors_tp_crc_valid_128(dev_data->prom);
 	else
 		valid = ms_sensors_tp_crc_valid_112(dev_data->prom);
diff --git a/drivers/iio/common/ms_sensors/ms_sensors_i2c.h b/drivers/iio/common/ms_sensors/ms_sensors_i2c.h
index f15b973f27c6..d9898098c066 100644
--- a/drivers/iio/common/ms_sensors/ms_sensors_i2c.h
+++ b/drivers/iio/common/ms_sensors/ms_sensors_i2c.h
@@ -35,6 +35,16 @@ struct ms_tp_hw_data {
 	u8 max_res_index;
 };
 
+/**
+ * struct ms_tp_data - Temperature/Pressure sensor data
+ * @name: Device name
+ * @hw: Sensor hardware data
+ */
+struct ms_tp_data {
+	const char *name;
+	const struct ms_tp_hw_data *hw;
+};
+
 /**
  * struct ms_tp_dev - Temperature/Pressure sensor device structure
  * @client:	i2c client
@@ -42,11 +52,12 @@ struct ms_tp_hw_data {
  * @prom:	array of PROM coefficients used for conversion. Added element
  *              for CRC computation
  * @res_index:	index to selected sensor resolution
+ * @data:	Temperature/Pressure sensor data
  */
 struct ms_tp_dev {
 	struct i2c_client *client;
 	struct mutex lock;
-	const struct ms_tp_hw_data *hw;
+	const struct ms_tp_data *data;
 	u16 prom[MS_SENSORS_TP_PROM_WORDS_NB];
 	u8 res_index;
 };
diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c
index 4f9f556bd123..6009d87f3d4c 100644
--- a/drivers/iio/pressure/ms5637.c
+++ b/drivers/iio/pressure/ms5637.c
@@ -29,11 +29,6 @@
 
 #include "../common/ms_sensors/ms_sensors_i2c.h"
 
-struct ms_tp_data {
-	const char *name;
-	const struct ms_tp_hw_data *hw;
-};
-
 static const int ms5637_samp_freq[6] = { 960, 480, 240, 120, 60, 30 };
 
 static ssize_t ms5637_show_samp_freq(struct device *dev, struct device_attribute *attr, char *buf)
@@ -42,7 +37,7 @@ static ssize_t ms5637_show_samp_freq(struct device *dev, struct device_attribute
 	struct ms_tp_dev *dev_data = iio_priv(indio_dev);
 	int i, len = 0;
 
-	for (i = 0; i <= dev_data->hw->max_res_index; i++)
+	for (i = 0; i <= dev_data->data->hw->max_res_index; i++)
 		len += sysfs_emit_at(buf, len, "%u ", ms5637_samp_freq[i]);
 	sysfs_emit_at(buf, len - 1, "\n");
 
@@ -168,7 +163,7 @@ static int ms5637_probe(struct i2c_client *client)
 	dev_data = iio_priv(indio_dev);
 	dev_data->client = client;
 	dev_data->res_index = data->hw->max_res_index;
-	dev_data->hw = data->hw;
+	dev_data->data = data;
 	mutex_init(&dev_data->lock);
 
 	indio_dev->info = &ms5637_info;
-- 
2.55.0


  parent reply	other threads:[~2026-08-20 14:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260820141224.23730-1-adamianlouis@gmail.com>
2026-08-20 14:12 ` [PATCH v3 1/5] iio: pressure: ms5637: Add missing ms5803 I2C device ID Louis Adamian
2026-08-21  0:41   ` Jonathan Cameron
2026-08-20 14:12 ` Louis Adamian [this message]
2026-08-21  0:48   ` [PATCH v3 2/5] iio: pressure: ms5637: Move device data struct to header Jonathan Cameron
2026-08-20 14:12 ` [PATCH v3 3/5] dt-bindings: iio: pressure: Add MS5637 Louis Adamian
2026-08-20 18:13   ` Conor Dooley
2026-08-20 14:12 ` [PATCH v3 4/5] iio: pressure: ms5637: Parameterise second order temperature compensation Louis Adamian
2026-08-20 14:12 ` [PATCH v3 5/5] iio: pressure: ms5637: Add per-variant compensation Louis Adamian
2026-08-21  1:01   ` Jonathan Cameron

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=20260820141224.23730-3-adamianlouis@gmail.com \
    --to=adamianlouis@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --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