The current driver works with mcp9601, but emits a warning because it
does not recognize the chip id.
MCP9601 is a superset of MCP9600. The drivers works without changes
on this chipset.
However, the 9601 chip supports open/closed-circuit detection if wired
properly, so we'll need to be able to differentiate between them.
Signed-off-by: Ben Collins <bcollins@watter.com>
---
drivers/iio/temperature/Kconfig | 8 +++--
drivers/iio/temperature/mcp9600.c | 51 +++++++++++++++++++++++++------
2 files changed, 46 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/temperature/Kconfig b/drivers/iio/temperature/Kconfig
index 1244d8e17d504..e14ea6ebc7a24 100644
--- a/drivers/iio/temperature/Kconfig
+++ b/drivers/iio/temperature/Kconfig
@@ -173,11 +173,13 @@ config MAX31865
will be called max31865.
config MCP9600
- tristate "MCP9600 thermocouple EMF converter"
+ tristate "MCP9600 and similar thermocouple EMF converters"
depends on I2C
help
- If you say yes here you get support for MCP9600
- thermocouple EMF converter connected via I2C.
+ If you say yes here you get support for:
+ - MCP9600
+ - MCP9601
+ and similar thermocouple EMF converters connected via I2C.
This driver can also be built as a module. If so, the module
will be called mcp9600.
diff --git a/drivers/iio/temperature/mcp9600.c b/drivers/iio/temperature/mcp9600.c
index 40906bb200ec9..c18ae17b6d82f 100644
--- a/drivers/iio/temperature/mcp9600.c
+++ b/drivers/iio/temperature/mcp9600.c
@@ -42,6 +42,7 @@
/* MCP9600 device id value */
#define MCP9600_DEVICE_ID_MCP9600 0x40
+#define MCP9600_DEVICE_ID_MCP9601 0x41
#define MCP9600_ALERT_COUNT 4
@@ -123,6 +124,11 @@ static const struct iio_chan_spec mcp9600_channels[][2] = {
MCP9600_CHANNELS(2, 0, 2, 0), /* Alerts: 1 2 3 4 */
};
+struct mcp_chip_info {
+ u8 chip_id;
+ const char *chip_name;
+};
+
struct mcp9600_data {
struct i2c_client *client;
};
@@ -416,16 +422,29 @@ static int mcp9600_probe_alerts(struct iio_dev *indio_dev)
static int mcp9600_probe(struct i2c_client *client)
{
+ const struct mcp_chip_info *chip_info = i2c_get_match_data(client);
struct iio_dev *indio_dev;
struct mcp9600_data *data;
- int ret, ch_sel;
+ int ch_sel, dev_id, ret;
+
+ dev_id = i2c_smbus_read_byte_data(client, MCP9600_DEVICE_ID);
+ if (dev_id < 0)
+ return dev_err_probe(&client->dev, dev_id,
+ "Failed to read device ID\n");
+
+ switch (dev_id) {
+ case MCP9600_DEVICE_ID_MCP9600:
+ case MCP9600_DEVICE_ID_MCP9601:
+ if (dev_id != chip_info->chip_id)
+ dev_warn(&client->dev,
+ "Expected id %02x, but device responded with %02\n",
+ chip_info->chip_id, dev_id);
+ break;
- ret = i2c_smbus_read_byte_data(client, MCP9600_DEVICE_ID);
- if (ret < 0)
- return dev_err_probe(&client->dev, ret, "Failed to read device ID\n");
- if (ret != MCP9600_DEVICE_ID_MCP9600)
- dev_warn(&client->dev, "Expected ID %x, got %x\n",
- MCP9600_DEVICE_ID_MCP9600, ret);
+ default:
+ dev_warn(&client->dev, "Unknown id %x, using %x\n", dev_id,
+ chip_info->chip_id);
+ }
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
if (!indio_dev)
@@ -439,7 +458,7 @@ static int mcp9600_probe(struct i2c_client *client)
return ch_sel;
indio_dev->info = &mcp9600_info;
- indio_dev->name = "mcp9600";
+ indio_dev->name = chip_info->chip_name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = mcp9600_channels[ch_sel];
indio_dev->num_channels = ARRAY_SIZE(mcp9600_channels[ch_sel]);
@@ -447,14 +466,26 @@ static int mcp9600_probe(struct i2c_client *client)
return devm_iio_device_register(&client->dev, indio_dev);
}
+static const struct mcp_chip_info mcp9600_chip_info = {
+ .chip_id = MCP9600_DEVICE_ID_MCP9600,
+ .chip_name = "mcp9600",
+};
+
+static const struct mcp_chip_info mcp9601_chip_info = {
+ .chip_id = MCP9600_DEVICE_ID_MCP9601,
+ .chip_name = "mcp9601",
+};
+
static const struct i2c_device_id mcp9600_id[] = {
- { "mcp9600" },
+ { "mcp9600", .driver_data = (kernel_ulong_t)&mcp9600_chip_info },
+ { "mcp9601", .driver_data = (kernel_ulong_t)&mcp9601_chip_info },
{ }
};
MODULE_DEVICE_TABLE(i2c, mcp9600_id);
static const struct of_device_id mcp9600_of_match[] = {
- { .compatible = "microchip,mcp9600" },
+ { .compatible = "microchip,mcp9600", .data = &mcp9600_chip_info },
+ { .compatible = "microchip,mcp9601", .data = &mcp9601_chip_info },
{ }
};
MODULE_DEVICE_TABLE(of, mcp9600_of_match);
--
2.50.1
On Fri, 15 Aug 2025 16:46:05 +0000 Ben Collins <bcollins@watter.com> wrote: > The current driver works with mcp9601, but emits a warning because it > does not recognize the chip id. > > MCP9601 is a superset of MCP9600. The drivers works without changes > on this chipset. > > However, the 9601 chip supports open/closed-circuit detection if wired > properly, so we'll need to be able to differentiate between them. > > Signed-off-by: Ben Collins <bcollins@watter.com> > --- > drivers/iio/temperature/Kconfig | 8 +++-- > drivers/iio/temperature/mcp9600.c | 51 +++++++++++++++++++++++++------ > 2 files changed, 46 insertions(+), 13 deletions(-) > > diff --git a/drivers/iio/temperature/Kconfig b/drivers/iio/temperature/Kconfig > index 1244d8e17d504..e14ea6ebc7a24 100644 > --- a/drivers/iio/temperature/Kconfig > +++ b/drivers/iio/temperature/Kconfig > @@ -173,11 +173,13 @@ config MAX31865 > will be called max31865. > > config MCP9600 > - tristate "MCP9600 thermocouple EMF converter" > + tristate "MCP9600 and similar thermocouple EMF converters" > depends on I2C > help > - If you say yes here you get support for MCP9600 > - thermocouple EMF converter connected via I2C. > + If you say yes here you get support for: > + - MCP9600 > + - MCP9601 > + and similar thermocouple EMF converters connected via I2C. If we are updating this list every time, do we need to add the 'and similar' to the help text? It makes sense only in the short description above where we aren't listing them. > > This driver can also be built as a module. If so, the module > will be called mcp9600. >
Hi Ben, kernel test robot noticed the following build warnings: [auto build test WARNING on jic23-iio/togreg] [also build test WARNING on linus/master v6.17-rc1 next-20250815] [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/Ben-Collins/dt-bindings-iio-mcp9600-Add-compatible-for-microchip-mcp9601/20250816-005705 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20250815164627.22002-4-bcollins%40watter.com patch subject: [PATCH 3/5] iio: mcp9600: Recognize chip id for mcp9601 config: riscv-randconfig-001-20250816 (https://download.01.org/0day-ci/archive/20250816/202508161646.PDl6V4EU-lkp@intel.com/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef31524fa1d9f3f) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/202508161646.PDl6V4EU-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202508161646.PDl6V4EU-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from include/linux/regulator/consumer.h:35: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:27: In file included from include/linux/kernel_stat.h:8: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:12: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:820:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 820 | insl(addr, buffer, count); | ^~~~~~~~~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/io.h:106:53: note: expanded from macro 'insl' 106 | #define insl(addr, buffer, count) __insl(PCI_IOBASE + (addr), buffer, count) | ~~~~~~~~~~ ^ In file included from drivers/iio/temperature/mcp9600.c:13: In file included from include/linux/i2c.h:19: In file included from include/linux/regulator/consumer.h:35: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:27: In file included from include/linux/kernel_stat.h:8: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:12: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:829:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 829 | outsb(addr, buffer, count); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/io.h:118:55: note: expanded from macro 'outsb' 118 | #define outsb(addr, buffer, count) __outsb(PCI_IOBASE + (addr), buffer, count) | ~~~~~~~~~~ ^ In file included from drivers/iio/temperature/mcp9600.c:13: In file included from include/linux/i2c.h:19: In file included from include/linux/regulator/consumer.h:35: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:27: In file included from include/linux/kernel_stat.h:8: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:12: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:838:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 838 | outsw(addr, buffer, count); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/io.h:119:55: note: expanded from macro 'outsw' 119 | #define outsw(addr, buffer, count) __outsw(PCI_IOBASE + (addr), buffer, count) | ~~~~~~~~~~ ^ In file included from drivers/iio/temperature/mcp9600.c:13: In file included from include/linux/i2c.h:19: In file included from include/linux/regulator/consumer.h:35: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:27: In file included from include/linux/kernel_stat.h:8: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:12: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:847:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 847 | outsl(addr, buffer, count); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/io.h:120:55: note: expanded from macro 'outsl' 120 | #define outsl(addr, buffer, count) __outsl(PCI_IOBASE + (addr), buffer, count) | ~~~~~~~~~~ ^ In file included from drivers/iio/temperature/mcp9600.c:13: In file included from include/linux/i2c.h:19: In file included from include/linux/regulator/consumer.h:35: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:27: In file included from include/linux/kernel_stat.h:8: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:12: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:1175:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 1175 | return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port; | ~~~~~~~~~~ ^ >> drivers/iio/temperature/mcp9600.c:440:53: warning: invalid conversion specifier '\x0a' [-Wformat-invalid-specifier] 440 | "Expected id %02x, but device responded with %02\n", | ~~~^ include/linux/dev_printk.h:156:62: note: expanded from macro 'dev_warn' 156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__) | ^~~ include/linux/dev_printk.h:19:22: note: expanded from macro 'dev_fmt' 19 | #define dev_fmt(fmt) fmt | ^~~ include/linux/dev_printk.h:110:16: note: expanded from macro 'dev_printk_index_wrap' 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ | ^~~ >> drivers/iio/temperature/mcp9600.c:441:26: warning: data argument not used by format string [-Wformat-extra-args] 440 | "Expected id %02x, but device responded with %02\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 441 | chip_info->chip_id, dev_id); | ^ include/linux/dev_printk.h:156:70: note: expanded from macro 'dev_warn' 156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__) | ~~~ ^ include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap' 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ | ~~~ ^ drivers/iio/temperature/mcp9600.c:428:22: warning: unused variable 'ret' [-Wunused-variable] 428 | int ch_sel, dev_id, ret; | ^~~ 10 warnings generated. vim +/x0a +440 drivers/iio/temperature/mcp9600.c 422 423 static int mcp9600_probe(struct i2c_client *client) 424 { 425 const struct mcp_chip_info *chip_info = i2c_get_match_data(client); 426 struct iio_dev *indio_dev; 427 struct mcp9600_data *data; 428 int ch_sel, dev_id, ret; 429 430 dev_id = i2c_smbus_read_byte_data(client, MCP9600_DEVICE_ID); 431 if (dev_id < 0) 432 return dev_err_probe(&client->dev, dev_id, 433 "Failed to read device ID\n"); 434 435 switch (dev_id) { 436 case MCP9600_DEVICE_ID_MCP9600: 437 case MCP9600_DEVICE_ID_MCP9601: 438 if (dev_id != chip_info->chip_id) 439 dev_warn(&client->dev, > 440 "Expected id %02x, but device responded with %02\n", > 441 chip_info->chip_id, dev_id); 442 break; 443 444 default: 445 dev_warn(&client->dev, "Unknown id %x, using %x\n", dev_id, 446 chip_info->chip_id); 447 } 448 449 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); 450 if (!indio_dev) 451 return -ENOMEM; 452 453 data = iio_priv(indio_dev); 454 data->client = client; 455 456 ch_sel = mcp9600_probe_alerts(indio_dev); 457 if (ch_sel < 0) 458 return ch_sel; 459 460 indio_dev->info = &mcp9600_info; 461 indio_dev->name = chip_info->chip_name; 462 indio_dev->modes = INDIO_DIRECT_MODE; 463 indio_dev->channels = mcp9600_channels[ch_sel]; 464 indio_dev->num_channels = ARRAY_SIZE(mcp9600_channels[ch_sel]); 465 466 return devm_iio_device_register(&client->dev, indio_dev); 467 } 468 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
On Sat, 16 Aug 2025 16:46:12 +0800 kernel test robot <lkp@intel.com> wrote: > Hi Ben, > > kernel test robot noticed the following build warnings: > > [auto build test WARNING on jic23-iio/togreg] > [also build test WARNING on linus/master v6.17-rc1 next-20250815] > [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/Ben-Collins/dt-bindings-iio-mcp9600-Add-compatible-for-microchip-mcp9601/20250816-005705 > base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg > patch link: https://lore.kernel.org/r/20250815164627.22002-4-bcollins%40watter.com > patch subject: [PATCH 3/5] iio: mcp9600: Recognize chip id for mcp9601 > config: riscv-randconfig-001-20250816 (https://download.01.org/0day-ci/archive/20250816/202508161646.PDl6V4EU-lkp@intel.com/config) > compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef31524fa1d9f3f) > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/202508161646.PDl6V4EU-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202508161646.PDl6V4EU-lkp@intel.com/ > > All warnings (new ones prefixed by >>): > > In file included from include/linux/regulator/consumer.h:35: > In file included from include/linux/suspend.h:5: > In file included from include/linux/swap.h:9: > In file included from include/linux/memcontrol.h:13: > In file included from include/linux/cgroup.h:27: > In file included from include/linux/kernel_stat.h:8: > In file included from include/linux/interrupt.h:11: > In file included from include/linux/hardirq.h:11: > In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: > In file included from include/asm-generic/hardirq.h:17: > In file included from include/linux/irq.h:20: > In file included from include/linux/io.h:12: > In file included from arch/riscv/include/asm/io.h:136: > include/asm-generic/io.h:820:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > 820 | insl(addr, buffer, count); > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > arch/riscv/include/asm/io.h:106:53: note: expanded from macro 'insl' > 106 | #define insl(addr, buffer, count) __insl(PCI_IOBASE + (addr), buffer, count) > | ~~~~~~~~~~ ^ > In file included from drivers/iio/temperature/mcp9600.c:13: > In file included from include/linux/i2c.h:19: > In file included from include/linux/regulator/consumer.h:35: > In file included from include/linux/suspend.h:5: > In file included from include/linux/swap.h:9: > In file included from include/linux/memcontrol.h:13: > In file included from include/linux/cgroup.h:27: > In file included from include/linux/kernel_stat.h:8: > In file included from include/linux/interrupt.h:11: > In file included from include/linux/hardirq.h:11: > In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: > In file included from include/asm-generic/hardirq.h:17: > In file included from include/linux/irq.h:20: > In file included from include/linux/io.h:12: > In file included from arch/riscv/include/asm/io.h:136: > include/asm-generic/io.h:829:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > 829 | outsb(addr, buffer, count); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/riscv/include/asm/io.h:118:55: note: expanded from macro 'outsb' > 118 | #define outsb(addr, buffer, count) __outsb(PCI_IOBASE + (addr), buffer, count) > | ~~~~~~~~~~ ^ > In file included from drivers/iio/temperature/mcp9600.c:13: > In file included from include/linux/i2c.h:19: > In file included from include/linux/regulator/consumer.h:35: > In file included from include/linux/suspend.h:5: > In file included from include/linux/swap.h:9: > In file included from include/linux/memcontrol.h:13: > In file included from include/linux/cgroup.h:27: > In file included from include/linux/kernel_stat.h:8: > In file included from include/linux/interrupt.h:11: > In file included from include/linux/hardirq.h:11: > In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: > In file included from include/asm-generic/hardirq.h:17: > In file included from include/linux/irq.h:20: > In file included from include/linux/io.h:12: > In file included from arch/riscv/include/asm/io.h:136: > include/asm-generic/io.h:838:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > 838 | outsw(addr, buffer, count); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/riscv/include/asm/io.h:119:55: note: expanded from macro 'outsw' > 119 | #define outsw(addr, buffer, count) __outsw(PCI_IOBASE + (addr), buffer, count) > | ~~~~~~~~~~ ^ > In file included from drivers/iio/temperature/mcp9600.c:13: > In file included from include/linux/i2c.h:19: > In file included from include/linux/regulator/consumer.h:35: > In file included from include/linux/suspend.h:5: > In file included from include/linux/swap.h:9: > In file included from include/linux/memcontrol.h:13: > In file included from include/linux/cgroup.h:27: > In file included from include/linux/kernel_stat.h:8: > In file included from include/linux/interrupt.h:11: > In file included from include/linux/hardirq.h:11: > In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: > In file included from include/asm-generic/hardirq.h:17: > In file included from include/linux/irq.h:20: > In file included from include/linux/io.h:12: > In file included from arch/riscv/include/asm/io.h:136: > include/asm-generic/io.h:847:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > 847 | outsl(addr, buffer, count); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/riscv/include/asm/io.h:120:55: note: expanded from macro 'outsl' > 120 | #define outsl(addr, buffer, count) __outsl(PCI_IOBASE + (addr), buffer, count) > | ~~~~~~~~~~ ^ > In file included from drivers/iio/temperature/mcp9600.c:13: > In file included from include/linux/i2c.h:19: > In file included from include/linux/regulator/consumer.h:35: > In file included from include/linux/suspend.h:5: > In file included from include/linux/swap.h:9: > In file included from include/linux/memcontrol.h:13: > In file included from include/linux/cgroup.h:27: > In file included from include/linux/kernel_stat.h:8: > In file included from include/linux/interrupt.h:11: > In file included from include/linux/hardirq.h:11: > In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: > In file included from include/asm-generic/hardirq.h:17: > In file included from include/linux/irq.h:20: > In file included from include/linux/io.h:12: > In file included from arch/riscv/include/asm/io.h:136: > include/asm-generic/io.h:1175:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > 1175 | return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port; > | ~~~~~~~~~~ ^ > >> drivers/iio/temperature/mcp9600.c:440:53: warning: invalid conversion specifier '\x0a' [-Wformat-invalid-specifier] > 440 | "Expected id %02x, but device responded with %02\n", > | ~~~^ > include/linux/dev_printk.h:156:62: note: expanded from macro 'dev_warn' > 156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__) > | ^~~ > include/linux/dev_printk.h:19:22: note: expanded from macro 'dev_fmt' > 19 | #define dev_fmt(fmt) fmt > | ^~~ > include/linux/dev_printk.h:110:16: note: expanded from macro 'dev_printk_index_wrap' > 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ > | ^~~ > >> drivers/iio/temperature/mcp9600.c:441:26: warning: data argument not used by format string [-Wformat-extra-args] > 440 | "Expected id %02x, but device responded with %02\n", > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 441 | chip_info->chip_id, dev_id); > | ^ > include/linux/dev_printk.h:156:70: note: expanded from macro 'dev_warn' > 156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__) > | ~~~ ^ > include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap' > 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ > | ~~~ ^ > drivers/iio/temperature/mcp9600.c:428:22: warning: unused variable 'ret' [-Wunused-variable] > 428 | int ch_sel, dev_id, ret; > | ^~~ > 10 warnings generated. > > > vim +/x0a +440 drivers/iio/temperature/mcp9600.c > > 422 > 423 static int mcp9600_probe(struct i2c_client *client) > 424 { > 425 const struct mcp_chip_info *chip_info = i2c_get_match_data(client); Probably a false positive as I don't think we can probe without something matching and hence that not being NULL but an error check on that match is still a nice to have and should resolve this build warning. Note there is very little chance a compiler could ever figure out if this can be NULL or not so it's a reasonable warning! Jonathan > 426 struct iio_dev *indio_dev; > 427 struct mcp9600_data *data; > 428 int ch_sel, dev_id, ret; > 429 > 430 dev_id = i2c_smbus_read_byte_data(client, MCP9600_DEVICE_ID); > 431 if (dev_id < 0) > 432 return dev_err_probe(&client->dev, dev_id, > 433 "Failed to read device ID\n"); > 434 > 435 switch (dev_id) { > 436 case MCP9600_DEVICE_ID_MCP9600: > 437 case MCP9600_DEVICE_ID_MCP9601: > 438 if (dev_id != chip_info->chip_id) > 439 dev_warn(&client->dev, > > 440 "Expected id %02x, but device responded with %02\n", > > 441 chip_info->chip_id, dev_id); > 442 break; > 443 > 444 default: > 445 dev_warn(&client->dev, "Unknown id %x, using %x\n", dev_id, > 446 chip_info->chip_id); > 447 } > 448 > 449 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); > 450 if (!indio_dev) > 451 return -ENOMEM; > 452 > 453 data = iio_priv(indio_dev); > 454 data->client = client; > 455 > 456 ch_sel = mcp9600_probe_alerts(indio_dev); > 457 if (ch_sel < 0) > 458 return ch_sel; > 459 > 460 indio_dev->info = &mcp9600_info; > 461 indio_dev->name = chip_info->chip_name; > 462 indio_dev->modes = INDIO_DIRECT_MODE; > 463 indio_dev->channels = mcp9600_channels[ch_sel]; > 464 indio_dev->num_channels = ARRAY_SIZE(mcp9600_channels[ch_sel]); > 465 > 466 return devm_iio_device_register(&client->dev, indio_dev); > 467 } > 468 >
Hi Jonathan, On Sat, Aug 16, 2025 at 11:02:43AM +0100, Jonathan Cameron wrote: > On Sat, 16 Aug 2025 16:46:12 +0800 > kernel test robot <lkp@intel.com> wrote: > > > Hi Ben, > > > > kernel test robot noticed the following build warnings: > > > > [auto build test WARNING on jic23-iio/togreg] > > [also build test WARNING on linus/master v6.17-rc1 next-20250815] > > [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/Ben-Collins/dt-bindings-iio-mcp9600-Add-compatible-for-microchip-mcp9601/20250816-005705 > > base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg > > patch link: https://lore.kernel.org/r/20250815164627.22002-4-bcollins%40watter.com > > patch subject: [PATCH 3/5] iio: mcp9600: Recognize chip id for mcp9601 > > config: riscv-randconfig-001-20250816 (https://download.01.org/0day-ci/archive/20250816/202508161646.PDl6V4EU-lkp@intel.com/config) > > compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef31524fa1d9f3f) > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/202508161646.PDl6V4EU-lkp@intel.com/reproduce) > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > the same patch/commit), kindly add following tags > > | Reported-by: kernel test robot <lkp@intel.com> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202508161646.PDl6V4EU-lkp@intel.com/ > > > > All warnings (new ones prefixed by >>): <trim unrelated -Wnull-pointer-arithmetic> > > >> drivers/iio/temperature/mcp9600.c:440:53: warning: invalid conversion specifier '\x0a' [-Wformat-invalid-specifier] > > 440 | "Expected id %02x, but device responded with %02\n", > > | ~~~^ > > include/linux/dev_printk.h:156:62: note: expanded from macro 'dev_warn' > > 156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__) > > | ^~~ > > include/linux/dev_printk.h:19:22: note: expanded from macro 'dev_fmt' > > 19 | #define dev_fmt(fmt) fmt > > | ^~~ > > include/linux/dev_printk.h:110:16: note: expanded from macro 'dev_printk_index_wrap' > > 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ > > | ^~~ > > >> drivers/iio/temperature/mcp9600.c:441:26: warning: data argument not used by format string [-Wformat-extra-args] > > 440 | "Expected id %02x, but device responded with %02\n", > > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > 441 | chip_info->chip_id, dev_id); > > | ^ > > include/linux/dev_printk.h:156:70: note: expanded from macro 'dev_warn' > > 156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__) > > | ~~~ ^ > > include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap' > > 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ > > | ~~~ ^ > > drivers/iio/temperature/mcp9600.c:428:22: warning: unused variable 'ret' [-Wunused-variable] > > 428 | int ch_sel, dev_id, ret; > > | ^~~ > > 10 warnings generated. > > > > > > vim +/x0a +440 drivers/iio/temperature/mcp9600.c > > > > 422 > > 423 static int mcp9600_probe(struct i2c_client *client) > > 424 { > > 425 const struct mcp_chip_info *chip_info = i2c_get_match_data(client); > > Probably a false positive as I don't think we can probe without something matching and hence > that not being NULL but an error check on that match is still a nice to have and should > resolve this build warning. Note there is very little chance a compiler could ever figure > out if this can be NULL or not so it's a reasonable warning! I am not sure I follow if you are referring to the -Wformat warnings above. Isn't it pointing out that the second specifier is missing the actual type? Shouldn't it be '%02x' or something of the sort? Cheers, Nathan
On Mon, 18 Aug 2025 08:06:59 -0700 Nathan Chancellor <nathan@kernel.org> wrote: > Hi Jonathan, > > On Sat, Aug 16, 2025 at 11:02:43AM +0100, Jonathan Cameron wrote: > > On Sat, 16 Aug 2025 16:46:12 +0800 > > kernel test robot <lkp@intel.com> wrote: > > > > > Hi Ben, > > > > > > kernel test robot noticed the following build warnings: > > > > > > [auto build test WARNING on jic23-iio/togreg] > > > [also build test WARNING on linus/master v6.17-rc1 next-20250815] > > > [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/Ben-Collins/dt-bindings-iio-mcp9600-Add-compatible-for-microchip-mcp9601/20250816-005705 > > > base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg > > > patch link: https://lore.kernel.org/r/20250815164627.22002-4-bcollins%40watter.com > > > patch subject: [PATCH 3/5] iio: mcp9600: Recognize chip id for mcp9601 > > > config: riscv-randconfig-001-20250816 (https://download.01.org/0day-ci/archive/20250816/202508161646.PDl6V4EU-lkp@intel.com/config) > > > compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef31524fa1d9f3f) > > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/202508161646.PDl6V4EU-lkp@intel.com/reproduce) > > > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > > the same patch/commit), kindly add following tags > > > | Reported-by: kernel test robot <lkp@intel.com> > > > | Closes: https://lore.kernel.org/oe-kbuild-all/202508161646.PDl6V4EU-lkp@intel.com/ > > > > > > All warnings (new ones prefixed by >>): > > <trim unrelated -Wnull-pointer-arithmetic> > > > > >> drivers/iio/temperature/mcp9600.c:440:53: warning: invalid conversion specifier '\x0a' [-Wformat-invalid-specifier] > > > 440 | "Expected id %02x, but device responded with %02\n", > > > | ~~~^ > > > include/linux/dev_printk.h:156:62: note: expanded from macro 'dev_warn' > > > 156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__) > > > | ^~~ > > > include/linux/dev_printk.h:19:22: note: expanded from macro 'dev_fmt' > > > 19 | #define dev_fmt(fmt) fmt > > > | ^~~ > > > include/linux/dev_printk.h:110:16: note: expanded from macro 'dev_printk_index_wrap' > > > 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ > > > | ^~~ > > > >> drivers/iio/temperature/mcp9600.c:441:26: warning: data argument not used by format string [-Wformat-extra-args] > > > 440 | "Expected id %02x, but device responded with %02\n", > > > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > 441 | chip_info->chip_id, dev_id); > > > | ^ > > > include/linux/dev_printk.h:156:70: note: expanded from macro 'dev_warn' > > > 156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__) > > > | ~~~ ^ > > > include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap' > > > 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ > > > | ~~~ ^ > > > drivers/iio/temperature/mcp9600.c:428:22: warning: unused variable 'ret' [-Wunused-variable] > > > 428 | int ch_sel, dev_id, ret; > > > | ^~~ > > > 10 warnings generated. > > > > > > > > > vim +/x0a +440 drivers/iio/temperature/mcp9600.c > > > > > > 422 > > > 423 static int mcp9600_probe(struct i2c_client *client) > > > 424 { > > > 425 const struct mcp_chip_info *chip_info = i2c_get_match_data(client); > > > > Probably a false positive as I don't think we can probe without something matching and hence > > that not being NULL but an error check on that match is still a nice to have and should > > resolve this build warning. Note there is very little chance a compiler could ever figure > > out if this can be NULL or not so it's a reasonable warning! > > I am not sure I follow if you are referring to the -Wformat warnings > above. Isn't it pointing out that the second specifier is missing the > actual type? Shouldn't it be '%02x' or something of the sort? I think I completely misread the report! Sorry about that. Ignore my comment. Jonathan > > Cheers, > Nathan >
> On Aug 18, 2025, at 11:06 AM, Nathan Chancellor <nathan@kernel.org> wrote: > > Hi Jonathan, > > On Sat, Aug 16, 2025 at 11:02:43AM +0100, Jonathan Cameron wrote: >> On Sat, 16 Aug 2025 16:46:12 +0800 >> kernel test robot <lkp@intel.com> wrote: >> >>> Hi Ben, >>> >>> kernel test robot noticed the following build warnings: >>> >>> [auto build test WARNING on jic23-iio/togreg] >>> [also build test WARNING on linus/master v6.17-rc1 next-20250815] >>> [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/Ben-Collins/dt-bindings-iio-mcp9600-Add-compatible-for-microchip-mcp9601/20250816-005705 >>> base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg >>> patch link: https://lore.kernel.org/r/20250815164627.22002-4-bcollins%40watter.com >>> patch subject: [PATCH 3/5] iio: mcp9600: Recognize chip id for mcp9601 >>> config: riscv-randconfig-001-20250816 (https://download.01.org/0day-ci/archive/20250816/202508161646.PDl6V4EU-lkp@intel.com/config) >>> compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef31524fa1d9f3f) >>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/202508161646.PDl6V4EU-lkp@intel.com/reproduce) >>> >>> If you fix the issue in a separate patch/commit (i.e. not just a new version of >>> the same patch/commit), kindly add following tags >>> | Reported-by: kernel test robot <lkp@intel.com> >>> | Closes: https://lore.kernel.org/oe-kbuild-all/202508161646.PDl6V4EU-lkp@intel.com/ >>> >>> All warnings (new ones prefixed by >>): > > <trim unrelated -Wnull-pointer-arithmetic> > >>>>> drivers/iio/temperature/mcp9600.c:440:53: warning: invalid conversion specifier '\x0a' [-Wformat-invalid-specifier] >>> 440 | "Expected id %02x, but device responded with %02\n", >>> | ~~~^ >>> include/linux/dev_printk.h:156:62: note: expanded from macro 'dev_warn' >>> 156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__) >>> | ^~~ >>> include/linux/dev_printk.h:19:22: note: expanded from macro 'dev_fmt' >>> 19 | #define dev_fmt(fmt) fmt >>> | ^~~ >>> include/linux/dev_printk.h:110:16: note: expanded from macro 'dev_printk_index_wrap' >>> 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ >>> | ^~~ >>>>> drivers/iio/temperature/mcp9600.c:441:26: warning: data argument not used by format string [-Wformat-extra-args] >>> 440 | "Expected id %02x, but device responded with %02\n", >>> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> 441 | chip_info->chip_id, dev_id); >>> | ^ >>> include/linux/dev_printk.h:156:70: note: expanded from macro 'dev_warn' >>> 156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__) >>> | ~~~ ^ >>> include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap' >>> 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ >>> | ~~~ ^ >>> drivers/iio/temperature/mcp9600.c:428:22: warning: unused variable 'ret' [-Wunused-variable] >>> 428 | int ch_sel, dev_id, ret; >>> | ^~~ >>> 10 warnings generated. >>> >>> >>> vim +/x0a +440 drivers/iio/temperature/mcp9600.c >>> >>> 422 >>> 423 static int mcp9600_probe(struct i2c_client *client) >>> 424 { >>> 425 const struct mcp_chip_info *chip_info = i2c_get_match_data(client); >> >> Probably a false positive as I don't think we can probe without something matching and hence >> that not being NULL but an error check on that match is still a nice to have and should >> resolve this build warning. Note there is very little chance a compiler could ever figure >> out if this can be NULL or not so it's a reasonable warning! > > I am not sure I follow if you are referring to the -Wformat warnings > above. Isn't it pointing out that the second specifier is missing the > actual type? Shouldn't it be '%02x' or something of the sort? That actually was the issue and has already been fixed in follow up. Thanks
© 2016 - 2025 Red Hat, Inc.