From: Max Staudt <max@enpas.org>
To: linux-i2c@vger.kernel.org, linux-hwmon@vger.kernel.org,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>
Cc: linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org,
glaubitz@physik.fu-berlin.de, Max Staudt <max@enpas.org>
Subject: [PATCH v2 3/4] hwmon/ltc2990: Add platform_data support
Date: Tue, 13 Aug 2019 01:52:36 +0200 [thread overview]
Message-ID: <20190812235237.21797-3-max@enpas.org> (raw)
In-Reply-To: <20190812235237.21797-1-max@enpas.org>
This allows code using i2c_new_device() to specify a measurement mode.
Signed-off-by: Max Staudt <max@enpas.org>
---
drivers/hwmon/ltc2990.c | 9 +++++++++
include/linux/platform_data/ltc2990.h | 11 +++++++++++
2 files changed, 20 insertions(+)
create mode 100644 include/linux/platform_data/ltc2990.h
diff --git a/drivers/hwmon/ltc2990.c b/drivers/hwmon/ltc2990.c
index f9431ad43..f19b9c50c 100644
--- a/drivers/hwmon/ltc2990.c
+++ b/drivers/hwmon/ltc2990.c
@@ -14,6 +14,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/platform_data/ltc2990.h>
#define LTC2990_STATUS 0x00
#define LTC2990_CONTROL 0x01
@@ -206,6 +207,7 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c,
int ret;
struct device *hwmon_dev;
struct ltc2990_data *data;
+ struct ltc2990_platform_data *pdata = dev_get_platdata(&i2c->dev);
struct device_node *of_node = i2c->dev.of_node;
if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA |
@@ -227,6 +229,13 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c,
if (data->mode[0] & ~LTC2990_MODE0_MASK ||
data->mode[1] & ~LTC2990_MODE1_MASK)
return -EINVAL;
+ } else if (pdata) {
+ data->mode[0] = pdata->meas_mode[0];
+ data->mode[1] = pdata->meas_mode[1];
+
+ if (data->mode[0] & ~LTC2990_MODE0_MASK ||
+ data->mode[1] & ~LTC2990_MODE1_MASK)
+ return -EINVAL;
} else {
ret = i2c_smbus_read_byte_data(i2c, LTC2990_CONTROL);
if (ret < 0)
diff --git a/include/linux/platform_data/ltc2990.h b/include/linux/platform_data/ltc2990.h
new file mode 100644
index 000000000..7ec89e784
--- /dev/null
+++ b/include/linux/platform_data/ltc2990.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef LTC2990_PDATA_H
+#define LTC2990_PDATA_H
+
+#include <linux/types.h>
+
+struct ltc2990_platform_data {
+ u8 meas_mode[2];
+};
+
+#endif /* LTC2990_PDATA_H */
--
2.11.0
next prev parent reply other threads:[~2019-08-12 23:53 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-12 23:52 [PATCH v2 1/4] i2c/busses: Add i2c-icy for I2C on m68k/Amiga Max Staudt
2019-08-12 23:52 ` [PATCH v2 2/4] i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision Max Staudt
2019-08-13 7:03 ` Geert Uytterhoeven
2019-08-13 9:49 ` Max Staudt
2019-08-14 19:52 ` Wolfram Sang
2019-08-12 23:52 ` Max Staudt [this message]
2019-08-13 6:59 ` [PATCH v2 3/4] hwmon/ltc2990: Add platform_data support Geert Uytterhoeven
2019-08-13 8:02 ` Guenter Roeck
2019-08-13 8:27 ` Geert Uytterhoeven
2019-08-13 13:27 ` Guenter Roeck
2019-08-13 13:32 ` Geert Uytterhoeven
2019-08-13 10:10 ` Max Staudt
2019-08-13 13:24 ` Guenter Roeck
2019-08-13 13:31 ` Max
2019-08-14 18:11 ` Max Staudt
2019-08-12 23:52 ` [PATCH v2 4/4] i2c/busses/i2c-icy: Add platform_data for LTC2990 Max Staudt
2019-08-13 7:04 ` Geert Uytterhoeven
2019-08-13 7:08 ` [PATCH v2 1/4] i2c/busses: Add i2c-icy for I2C on m68k/Amiga Geert Uytterhoeven
2019-08-13 9:50 ` Max Staudt
2019-08-14 19:47 ` Wolfram Sang
2019-08-14 22:33 ` Max Staudt
2019-08-15 7:12 ` Wolfram Sang
2019-08-15 10:00 ` Max Staudt
2019-08-15 11:48 ` Wolfram Sang
2019-08-15 11:52 ` Max
2019-08-15 12:04 ` Wolfram Sang
2019-08-15 12:10 ` Max Staudt
2019-08-15 12:52 ` Wolfram Sang
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=20190812235237.21797-3-max@enpas.org \
--to=max@enpas.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=wsa+renesas@sang-engineering.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.