diff mbox series

[v5,4/5] iio: temperature: tmp117: add TI TMP116 support

Message ID 20230227211230.165073-5-m.felsch@pengutronix.de
State Superseded
Headers show
Series [v5,1/5] dt-bindings: iio: ti,tmp117: fix documentation link | expand

Commit Message

Marco Felsch Feb. 27, 2023, 9:12 p.m. UTC
The TMP116 is the predecessor of the TMP117. The TMP116 don't support
custom offset calibration data, instead this register is used as generic
EEPROM storage as well.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
v5:
- no changes
v4:
- split into two patches
  - 1st) handle fallback (Jonathan)
  - 2nd) this one, adding the support for tmp116
v3:
- use switch case within probe() as well
- don't hide smbus_read error within tmp117_identify()
- add dedicated compatible
v2:
- no changes

 drivers/iio/temperature/tmp117.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Marco Felsch Feb. 28, 2023, 9:06 a.m. UTC | #1
On 23-02-28, kernel test robot wrote:
> Hi Marco,
> 
> Thank you for the patch! Yet something to improve:

Argh.. I didn't noticed that since I repaired it within the last
commit... I have send a v6 which fixes this.

Regards,
  Marco


> 
> [auto build test ERROR on v6.2]
> [cannot apply to jic23-iio/togreg linus/master]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Marco-Felsch/dt-bindings-iio-ti-tmp117-fix-documentation-link/20230228-051305
> patch link:    https://lore.kernel.org/r/20230227211230.165073-5-m.felsch%40pengutronix.de
> patch subject: [PATCH v5 4/5] iio: temperature: tmp117: add TI TMP116 support
> config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20230228/202302280821.OXqGp2Tq-lkp@intel.com/config)
> compiler: powerpc-linux-gcc (GCC) 12.1.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/intel-lab-lkp/linux/commit/424113d7fdc257200d20da2991242a4050c04cb3
>         git remote add linux-review https://github.com/intel-lab-lkp/linux
>         git fetch --no-tags linux-review Marco-Felsch/dt-bindings-iio-ti-tmp117-fix-documentation-link/20230228-051305
>         git checkout 424113d7fdc257200d20da2991242a4050c04cb3
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc olddefconfig
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/iio/
> 
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> | Link: https://lore.kernel.org/oe-kbuild-all/202302280821.OXqGp2Tq-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
> >> drivers/iio/temperature/tmp117.c:111:2: error: expected '}' before ';' token
>      111 | };
>          |  ^
>    drivers/iio/temperature/tmp117.c:106:55: note: to match this '{'
>      106 | static const struct iio_chan_spec tmp117_channels[] = {
>          |                                                       ^
>    drivers/iio/temperature/tmp117.c:106:35: warning: 'tmp117_channels' defined but not used [-Wunused-const-variable=]
>      106 | static const struct iio_chan_spec tmp117_channels[] = {
>          |                                   ^~~~~~~~~~~~~~~
>    drivers/iio/temperature/tmp117.c:85:12: warning: 'tmp117_write_raw' defined but not used [-Wunused-function]
>       85 | static int tmp117_write_raw(struct iio_dev *indio_dev,
>          |            ^~~~~~~~~~~~~~~~
>    drivers/iio/temperature/tmp117.c:45:12: warning: 'tmp117_read_raw' defined but not used [-Wunused-function]
>       45 | static int tmp117_read_raw(struct iio_dev *indio_dev,
>          |            ^~~~~~~~~~~~~~~
> 
> 
> vim +111 drivers/iio/temperature/tmp117.c
> 
>    105	
>    106	static const struct iio_chan_spec tmp117_channels[] = {
>    107		{
>    108			.type = IIO_TEMP,
>    109			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>    110				BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_SCALE),
>  > 111	};
>    112	
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests
>
diff mbox series

Patch

diff --git a/drivers/iio/temperature/tmp117.c b/drivers/iio/temperature/tmp117.c
index 8a3992d9ee937..6994e3d3d06b1 100644
--- a/drivers/iio/temperature/tmp117.c
+++ b/drivers/iio/temperature/tmp117.c
@@ -32,9 +32,11 @@ 
 #define TMP117_REG_DEVICE_ID		0xF
 
 #define TMP117_RESOLUTION_10UC		78125
-#define TMP117_DEVICE_ID		0x0117
 #define MICRODEGREE_PER_10MILLIDEGREE	10000
 
+#define TMP116_DEVICE_ID		0x1116
+#define TMP117_DEVICE_ID		0x0117
+
 struct tmp117_data {
 	struct i2c_client *client;
 	s16 calibbias;
@@ -106,6 +108,13 @@  static const struct iio_chan_spec tmp117_channels[] = {
 		.type = IIO_TEMP,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
 			BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_SCALE),
+};
+
+static const struct iio_chan_spec tmp116_channels[] = {
+	{
+		.type = IIO_TEMP,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+				      BIT(IIO_CHAN_INFO_SCALE),
 	},
 };
 
@@ -125,6 +134,7 @@  static int tmp117_identify(struct i2c_client *client)
 		return dev_id;
 
 	switch (dev_id) {
+	case TMP116_DEVICE_ID:
 	case TMP117_DEVICE_ID:
 		return dev_id;
 	}
@@ -172,6 +182,11 @@  static int tmp117_probe(struct i2c_client *client)
 	indio_dev->info = &tmp117_info;
 
 	switch (dev_id) {
+	case TMP116_DEVICE_ID:
+		indio_dev->channels = tmp116_channels;
+		indio_dev->num_channels = ARRAY_SIZE(tmp116_channels);
+		indio_dev->name = "tmp116";
+		break;
 	case TMP117_DEVICE_ID:
 		indio_dev->channels = tmp117_channels;
 		indio_dev->num_channels = ARRAY_SIZE(tmp117_channels);
@@ -183,12 +198,14 @@  static int tmp117_probe(struct i2c_client *client)
 }
 
 static const struct of_device_id tmp117_of_match[] = {
+	{ .compatible = "ti,tmp116", .data = (void *)TMP116_DEVICE_ID },
 	{ .compatible = "ti,tmp117", .data = (void *)TMP117_DEVICE_ID },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, tmp117_of_match);
 
 static const struct i2c_device_id tmp117_id[] = {
+	{ "tmp116", TMP116_DEVICE_ID },
 	{ "tmp117", TMP117_DEVICE_ID },
 	{ }
 };