* Make sysfs entries documentation easier to maintain.
* Use multi-line enum.
* Correct "has_power_average" comment.
Create a new "has_update_interval" member for chips which support
averaging.
Signed-off-by: Ian Ray <ian.ray@gehealthcare.com>
---
Documentation/hwmon/ina2xx.rst | 12 ++++++++++--
drivers/hwmon/ina2xx.c | 21 +++++++++++++++++----
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/Documentation/hwmon/ina2xx.rst b/Documentation/hwmon/ina2xx.rst
index a3860aae444c..a4ddf4bd2b08 100644
--- a/Documentation/hwmon/ina2xx.rst
+++ b/Documentation/hwmon/ina2xx.rst
@@ -124,8 +124,16 @@ power1_input Power(uW) measurement channel
shunt_resistor Shunt resistance(uOhm) channel (not for ina260)
======================= ===============================================
-Additional sysfs entries for ina226, ina230, ina231, ina260, and sy24655
-------------------------------------------------------------------------
+Additional sysfs entries
+------------------------
+
+Additional entries are available for the following chips:
+
+ * ina226
+ * ina230
+ * ina231
+ * ina260
+ * sy24655
======================= ====================================================
curr1_lcrit Critical low current
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index 69ac0468dee4..4bf609e25f8a 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -46,9 +46,11 @@
#define INA2XX_CURRENT 0x04 /* readonly */
#define INA2XX_CALIBRATION 0x05
-/* INA226 register definitions */
+/* INA2xx register definitions */
#define INA226_MASK_ENABLE 0x06
#define INA226_ALERT_LIMIT 0x07
+
+/* INA226 register definitions */
#define INA226_DIE_ID 0xFF
/* SY24655 register definitions */
@@ -135,13 +137,19 @@ static const struct regmap_config ina2xx_regmap_config = {
.writeable_reg = ina2xx_writeable_reg,
};
-enum ina2xx_ids { ina219, ina226, ina260, sy24655 };
+enum ina2xx_ids {
+ ina219,
+ ina226,
+ ina260,
+ sy24655
+};
struct ina2xx_config {
u16 config_default;
bool has_alerts; /* chip supports alerts and limits */
bool has_ishunt; /* chip has internal shunt resistor */
- bool has_power_average; /* chip has internal shunt resistor */
+ bool has_power_average; /* chip supports average power */
+ bool has_update_interval;
int calibration_value;
int shunt_div;
int bus_voltage_shift;
@@ -171,6 +179,7 @@ static const struct ina2xx_config ina2xx_config[] = {
.has_alerts = false,
.has_ishunt = false,
.has_power_average = false,
+ .has_update_interval = false,
},
[ina226] = {
.config_default = INA226_CONFIG_DEFAULT,
@@ -182,6 +191,7 @@ static const struct ina2xx_config ina2xx_config[] = {
.has_alerts = true,
.has_ishunt = false,
.has_power_average = false,
+ .has_update_interval = true,
},
[ina260] = {
.config_default = INA260_CONFIG_DEFAULT,
@@ -192,6 +202,7 @@ static const struct ina2xx_config ina2xx_config[] = {
.has_alerts = true,
.has_ishunt = true,
.has_power_average = false,
+ .has_update_interval = true,
},
[sy24655] = {
.config_default = SY24655_CONFIG_DEFAULT,
@@ -203,6 +214,7 @@ static const struct ina2xx_config ina2xx_config[] = {
.has_alerts = true,
.has_ishunt = false,
.has_power_average = true,
+ .has_update_interval = false,
},
};
@@ -706,6 +718,7 @@ static umode_t ina2xx_is_visible(const void *_data, enum hwmon_sensor_types type
const struct ina2xx_data *data = _data;
bool has_alerts = data->config->has_alerts;
bool has_power_average = data->config->has_power_average;
+ bool has_update_interval = data->config->has_update_interval;
enum ina2xx_ids chip = data->chip;
switch (type) {
@@ -768,7 +781,7 @@ static umode_t ina2xx_is_visible(const void *_data, enum hwmon_sensor_types type
case hwmon_chip:
switch (attr) {
case hwmon_chip_update_interval:
- if (chip == ina226 || chip == ina260)
+ if (has_update_interval)
return 0644;
break;
default:
--
2.49.0
Hi Ian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on robh/for-next linus/master v6.19 next-20260219]
[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/Ian-Ray/dt-bindings-hwmon-ti-ina2xx-Add-INA234-device/20260219-210940
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link: https://lore.kernel.org/r/20260219130127.87901-3-ian.ray%40gehealthcare.com
patch subject: [PATCH V2 2/3] hwmon: (ina2xx) Make it easier to add more devices
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260220/202602200201.hafkm9wo-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260220/202602200201.hafkm9wo-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/202602200201.hafkm9wo-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/hwmon/ina2xx.c: In function 'ina2xx_is_visible':
>> drivers/hwmon/ina2xx.c:722:25: warning: unused variable 'chip' [-Wunused-variable]
722 | enum ina2xx_ids chip = data->chip;
| ^~~~
vim +/chip +722 drivers/hwmon/ina2xx.c
5a56a39be7ffb4 Alex Qiu 2020-05-04 714
814db9f1b8ec1c Guenter Roeck 2024-07-24 715 static umode_t ina2xx_is_visible(const void *_data, enum hwmon_sensor_types type,
814db9f1b8ec1c Guenter Roeck 2024-07-24 716 u32 attr, int channel)
814db9f1b8ec1c Guenter Roeck 2024-07-24 717 {
814db9f1b8ec1c Guenter Roeck 2024-07-24 718 const struct ina2xx_data *data = _data;
de0da6ae1908b4 Guenter Roeck 2024-08-27 719 bool has_alerts = data->config->has_alerts;
52172ad87a22ed Wenliang Yan 2024-11-06 720 bool has_power_average = data->config->has_power_average;
0337abb760db03 Ian Ray 2026-02-19 721 bool has_update_interval = data->config->has_update_interval;
814db9f1b8ec1c Guenter Roeck 2024-07-24 @722 enum ina2xx_ids chip = data->chip;
814db9f1b8ec1c Guenter Roeck 2024-07-24 723
814db9f1b8ec1c Guenter Roeck 2024-07-24 724 switch (type) {
814db9f1b8ec1c Guenter Roeck 2024-07-24 725 case hwmon_in:
814db9f1b8ec1c Guenter Roeck 2024-07-24 726 switch (attr) {
814db9f1b8ec1c Guenter Roeck 2024-07-24 727 case hwmon_in_input:
814db9f1b8ec1c Guenter Roeck 2024-07-24 728 return 0444;
814db9f1b8ec1c Guenter Roeck 2024-07-24 729 case hwmon_in_lcrit:
814db9f1b8ec1c Guenter Roeck 2024-07-24 730 case hwmon_in_crit:
de0da6ae1908b4 Guenter Roeck 2024-08-27 731 if (has_alerts)
814db9f1b8ec1c Guenter Roeck 2024-07-24 732 return 0644;
814db9f1b8ec1c Guenter Roeck 2024-07-24 733 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 734 case hwmon_in_lcrit_alarm:
814db9f1b8ec1c Guenter Roeck 2024-07-24 735 case hwmon_in_crit_alarm:
de0da6ae1908b4 Guenter Roeck 2024-08-27 736 if (has_alerts)
814db9f1b8ec1c Guenter Roeck 2024-07-24 737 return 0444;
814db9f1b8ec1c Guenter Roeck 2024-07-24 738 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 739 default:
814db9f1b8ec1c Guenter Roeck 2024-07-24 740 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 741 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 742 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 743 case hwmon_curr:
814db9f1b8ec1c Guenter Roeck 2024-07-24 744 switch (attr) {
814db9f1b8ec1c Guenter Roeck 2024-07-24 745 case hwmon_curr_input:
814db9f1b8ec1c Guenter Roeck 2024-07-24 746 return 0444;
4d5c2d986757e4 Guenter Roeck 2024-08-28 747 case hwmon_curr_lcrit:
4d5c2d986757e4 Guenter Roeck 2024-08-28 748 case hwmon_curr_crit:
de0da6ae1908b4 Guenter Roeck 2024-08-27 749 if (has_alerts)
4d5c2d986757e4 Guenter Roeck 2024-08-28 750 return 0644;
4d5c2d986757e4 Guenter Roeck 2024-08-28 751 break;
4d5c2d986757e4 Guenter Roeck 2024-08-28 752 case hwmon_curr_lcrit_alarm:
4d5c2d986757e4 Guenter Roeck 2024-08-28 753 case hwmon_curr_crit_alarm:
de0da6ae1908b4 Guenter Roeck 2024-08-27 754 if (has_alerts)
4d5c2d986757e4 Guenter Roeck 2024-08-28 755 return 0444;
4d5c2d986757e4 Guenter Roeck 2024-08-28 756 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 757 default:
814db9f1b8ec1c Guenter Roeck 2024-07-24 758 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 759 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 760 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 761 case hwmon_power:
814db9f1b8ec1c Guenter Roeck 2024-07-24 762 switch (attr) {
814db9f1b8ec1c Guenter Roeck 2024-07-24 763 case hwmon_power_input:
814db9f1b8ec1c Guenter Roeck 2024-07-24 764 return 0444;
814db9f1b8ec1c Guenter Roeck 2024-07-24 765 case hwmon_power_crit:
de0da6ae1908b4 Guenter Roeck 2024-08-27 766 if (has_alerts)
814db9f1b8ec1c Guenter Roeck 2024-07-24 767 return 0644;
814db9f1b8ec1c Guenter Roeck 2024-07-24 768 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 769 case hwmon_power_crit_alarm:
de0da6ae1908b4 Guenter Roeck 2024-08-27 770 if (has_alerts)
814db9f1b8ec1c Guenter Roeck 2024-07-24 771 return 0444;
814db9f1b8ec1c Guenter Roeck 2024-07-24 772 break;
52172ad87a22ed Wenliang Yan 2024-11-06 773 case hwmon_power_average:
52172ad87a22ed Wenliang Yan 2024-11-06 774 if (has_power_average)
52172ad87a22ed Wenliang Yan 2024-11-06 775 return 0444;
52172ad87a22ed Wenliang Yan 2024-11-06 776 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 777 default:
814db9f1b8ec1c Guenter Roeck 2024-07-24 778 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 779 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 780 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 781 case hwmon_chip:
814db9f1b8ec1c Guenter Roeck 2024-07-24 782 switch (attr) {
814db9f1b8ec1c Guenter Roeck 2024-07-24 783 case hwmon_chip_update_interval:
0337abb760db03 Ian Ray 2026-02-19 784 if (has_update_interval)
814db9f1b8ec1c Guenter Roeck 2024-07-24 785 return 0644;
814db9f1b8ec1c Guenter Roeck 2024-07-24 786 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 787 default:
814db9f1b8ec1c Guenter Roeck 2024-07-24 788 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 789 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 790 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 791 default:
814db9f1b8ec1c Guenter Roeck 2024-07-24 792 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 793 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 794 return 0;
814db9f1b8ec1c Guenter Roeck 2024-07-24 795 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 796
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Ian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on robh/for-next linus/master v6.19 next-20260219]
[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/Ian-Ray/dt-bindings-hwmon-ti-ina2xx-Add-INA234-device/20260219-210940
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link: https://lore.kernel.org/r/20260219130127.87901-3-ian.ray%40gehealthcare.com
patch subject: [PATCH V2 2/3] hwmon: (ina2xx) Make it easier to add more devices
config: x86_64-randconfig-014-20260219 (https://download.01.org/0day-ci/archive/20260220/202602200951.bP8YVa4Y-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260220/202602200951.bP8YVa4Y-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/202602200951.bP8YVa4Y-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/hwmon/ina2xx.c: In function 'ina2xx_is_visible':
>> drivers/hwmon/ina2xx.c:722:25: warning: unused variable 'chip' [-Wunused-variable]
722 | enum ina2xx_ids chip = data->chip;
| ^~~~
vim +/chip +722 drivers/hwmon/ina2xx.c
5a56a39be7ffb4 Alex Qiu 2020-05-04 714
814db9f1b8ec1c Guenter Roeck 2024-07-24 715 static umode_t ina2xx_is_visible(const void *_data, enum hwmon_sensor_types type,
814db9f1b8ec1c Guenter Roeck 2024-07-24 716 u32 attr, int channel)
814db9f1b8ec1c Guenter Roeck 2024-07-24 717 {
814db9f1b8ec1c Guenter Roeck 2024-07-24 718 const struct ina2xx_data *data = _data;
de0da6ae1908b4 Guenter Roeck 2024-08-27 719 bool has_alerts = data->config->has_alerts;
52172ad87a22ed Wenliang Yan 2024-11-06 720 bool has_power_average = data->config->has_power_average;
0337abb760db03 Ian Ray 2026-02-19 721 bool has_update_interval = data->config->has_update_interval;
814db9f1b8ec1c Guenter Roeck 2024-07-24 @722 enum ina2xx_ids chip = data->chip;
814db9f1b8ec1c Guenter Roeck 2024-07-24 723
814db9f1b8ec1c Guenter Roeck 2024-07-24 724 switch (type) {
814db9f1b8ec1c Guenter Roeck 2024-07-24 725 case hwmon_in:
814db9f1b8ec1c Guenter Roeck 2024-07-24 726 switch (attr) {
814db9f1b8ec1c Guenter Roeck 2024-07-24 727 case hwmon_in_input:
814db9f1b8ec1c Guenter Roeck 2024-07-24 728 return 0444;
814db9f1b8ec1c Guenter Roeck 2024-07-24 729 case hwmon_in_lcrit:
814db9f1b8ec1c Guenter Roeck 2024-07-24 730 case hwmon_in_crit:
de0da6ae1908b4 Guenter Roeck 2024-08-27 731 if (has_alerts)
814db9f1b8ec1c Guenter Roeck 2024-07-24 732 return 0644;
814db9f1b8ec1c Guenter Roeck 2024-07-24 733 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 734 case hwmon_in_lcrit_alarm:
814db9f1b8ec1c Guenter Roeck 2024-07-24 735 case hwmon_in_crit_alarm:
de0da6ae1908b4 Guenter Roeck 2024-08-27 736 if (has_alerts)
814db9f1b8ec1c Guenter Roeck 2024-07-24 737 return 0444;
814db9f1b8ec1c Guenter Roeck 2024-07-24 738 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 739 default:
814db9f1b8ec1c Guenter Roeck 2024-07-24 740 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 741 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 742 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 743 case hwmon_curr:
814db9f1b8ec1c Guenter Roeck 2024-07-24 744 switch (attr) {
814db9f1b8ec1c Guenter Roeck 2024-07-24 745 case hwmon_curr_input:
814db9f1b8ec1c Guenter Roeck 2024-07-24 746 return 0444;
4d5c2d986757e4 Guenter Roeck 2024-08-28 747 case hwmon_curr_lcrit:
4d5c2d986757e4 Guenter Roeck 2024-08-28 748 case hwmon_curr_crit:
de0da6ae1908b4 Guenter Roeck 2024-08-27 749 if (has_alerts)
4d5c2d986757e4 Guenter Roeck 2024-08-28 750 return 0644;
4d5c2d986757e4 Guenter Roeck 2024-08-28 751 break;
4d5c2d986757e4 Guenter Roeck 2024-08-28 752 case hwmon_curr_lcrit_alarm:
4d5c2d986757e4 Guenter Roeck 2024-08-28 753 case hwmon_curr_crit_alarm:
de0da6ae1908b4 Guenter Roeck 2024-08-27 754 if (has_alerts)
4d5c2d986757e4 Guenter Roeck 2024-08-28 755 return 0444;
4d5c2d986757e4 Guenter Roeck 2024-08-28 756 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 757 default:
814db9f1b8ec1c Guenter Roeck 2024-07-24 758 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 759 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 760 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 761 case hwmon_power:
814db9f1b8ec1c Guenter Roeck 2024-07-24 762 switch (attr) {
814db9f1b8ec1c Guenter Roeck 2024-07-24 763 case hwmon_power_input:
814db9f1b8ec1c Guenter Roeck 2024-07-24 764 return 0444;
814db9f1b8ec1c Guenter Roeck 2024-07-24 765 case hwmon_power_crit:
de0da6ae1908b4 Guenter Roeck 2024-08-27 766 if (has_alerts)
814db9f1b8ec1c Guenter Roeck 2024-07-24 767 return 0644;
814db9f1b8ec1c Guenter Roeck 2024-07-24 768 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 769 case hwmon_power_crit_alarm:
de0da6ae1908b4 Guenter Roeck 2024-08-27 770 if (has_alerts)
814db9f1b8ec1c Guenter Roeck 2024-07-24 771 return 0444;
814db9f1b8ec1c Guenter Roeck 2024-07-24 772 break;
52172ad87a22ed Wenliang Yan 2024-11-06 773 case hwmon_power_average:
52172ad87a22ed Wenliang Yan 2024-11-06 774 if (has_power_average)
52172ad87a22ed Wenliang Yan 2024-11-06 775 return 0444;
52172ad87a22ed Wenliang Yan 2024-11-06 776 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 777 default:
814db9f1b8ec1c Guenter Roeck 2024-07-24 778 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 779 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 780 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 781 case hwmon_chip:
814db9f1b8ec1c Guenter Roeck 2024-07-24 782 switch (attr) {
814db9f1b8ec1c Guenter Roeck 2024-07-24 783 case hwmon_chip_update_interval:
0337abb760db03 Ian Ray 2026-02-19 784 if (has_update_interval)
814db9f1b8ec1c Guenter Roeck 2024-07-24 785 return 0644;
814db9f1b8ec1c Guenter Roeck 2024-07-24 786 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 787 default:
814db9f1b8ec1c Guenter Roeck 2024-07-24 788 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 789 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 790 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 791 default:
814db9f1b8ec1c Guenter Roeck 2024-07-24 792 break;
814db9f1b8ec1c Guenter Roeck 2024-07-24 793 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 794 return 0;
814db9f1b8ec1c Guenter Roeck 2024-07-24 795 }
814db9f1b8ec1c Guenter Roeck 2024-07-24 796
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On 2/19/26 05:01, Ian Ray wrote:
> * Make sysfs entries documentation easier to maintain.
> * Use multi-line enum.
> * Correct "has_power_average" comment.
>
> Create a new "has_update_interval" member for chips which support
> averaging.
>
> Signed-off-by: Ian Ray <ian.ray@gehealthcare.com>
> ---
> Documentation/hwmon/ina2xx.rst | 12 ++++++++++--
> drivers/hwmon/ina2xx.c | 21 +++++++++++++++++----
> 2 files changed, 27 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/hwmon/ina2xx.rst b/Documentation/hwmon/ina2xx.rst
> index a3860aae444c..a4ddf4bd2b08 100644
> --- a/Documentation/hwmon/ina2xx.rst
> +++ b/Documentation/hwmon/ina2xx.rst
> @@ -124,8 +124,16 @@ power1_input Power(uW) measurement channel
> shunt_resistor Shunt resistance(uOhm) channel (not for ina260)
> ======================= ===============================================
>
> -Additional sysfs entries for ina226, ina230, ina231, ina260, and sy24655
> -------------------------------------------------------------------------
> +Additional sysfs entries
> +------------------------
> +
> +Additional entries are available for the following chips:
> +
> + * ina226
> + * ina230
> + * ina231
> + * ina260
> + * sy24655
>
> ======================= ====================================================
> curr1_lcrit Critical low current
> diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
> index 69ac0468dee4..4bf609e25f8a 100644
> --- a/drivers/hwmon/ina2xx.c
> +++ b/drivers/hwmon/ina2xx.c
> @@ -46,9 +46,11 @@
> #define INA2XX_CURRENT 0x04 /* readonly */
> #define INA2XX_CALIBRATION 0x05
>
> -/* INA226 register definitions */
> +/* INA2xx register definitions */
There was a reason for this. INA219 does not support those registers
or, more generically, they are only supported on chips supporting
alert limits.
> #define INA226_MASK_ENABLE 0x06
> #define INA226_ALERT_LIMIT 0x07
> +
> +/* INA226 register definitions */
> #define INA226_DIE_ID 0xFF
That isn't even used, and the comment is wrong (at least INA230 and INA260
also support it). Might as well drop it.
Either case, is that bike shedding really necessary ? The only really valuable
change in this patch is the introduction of has_update_interval. Please keep that
and drop the rest.
Thanks,
Guenter
>
> /* SY24655 register definitions */
> @@ -135,13 +137,19 @@ static const struct regmap_config ina2xx_regmap_config = {
> .writeable_reg = ina2xx_writeable_reg,
> };
>
> -enum ina2xx_ids { ina219, ina226, ina260, sy24655 };
> +enum ina2xx_ids {
> + ina219,
> + ina226,
> + ina260,
> + sy24655
> +};
>
> struct ina2xx_config {
> u16 config_default;
> bool has_alerts; /* chip supports alerts and limits */
> bool has_ishunt; /* chip has internal shunt resistor */
> - bool has_power_average; /* chip has internal shunt resistor */
> + bool has_power_average; /* chip supports average power */
> + bool has_update_interval;
> int calibration_value;
> int shunt_div;
> int bus_voltage_shift;
> @@ -171,6 +179,7 @@ static const struct ina2xx_config ina2xx_config[] = {
> .has_alerts = false,
> .has_ishunt = false,
> .has_power_average = false,
> + .has_update_interval = false,
> },
> [ina226] = {
> .config_default = INA226_CONFIG_DEFAULT,
> @@ -182,6 +191,7 @@ static const struct ina2xx_config ina2xx_config[] = {
> .has_alerts = true,
> .has_ishunt = false,
> .has_power_average = false,
> + .has_update_interval = true,
> },
> [ina260] = {
> .config_default = INA260_CONFIG_DEFAULT,
> @@ -192,6 +202,7 @@ static const struct ina2xx_config ina2xx_config[] = {
> .has_alerts = true,
> .has_ishunt = true,
> .has_power_average = false,
> + .has_update_interval = true,
> },
> [sy24655] = {
> .config_default = SY24655_CONFIG_DEFAULT,
> @@ -203,6 +214,7 @@ static const struct ina2xx_config ina2xx_config[] = {
> .has_alerts = true,
> .has_ishunt = false,
> .has_power_average = true,
> + .has_update_interval = false,
> },
> };
>
> @@ -706,6 +718,7 @@ static umode_t ina2xx_is_visible(const void *_data, enum hwmon_sensor_types type
> const struct ina2xx_data *data = _data;
> bool has_alerts = data->config->has_alerts;
> bool has_power_average = data->config->has_power_average;
> + bool has_update_interval = data->config->has_update_interval;
> enum ina2xx_ids chip = data->chip;
>
> switch (type) {
> @@ -768,7 +781,7 @@ static umode_t ina2xx_is_visible(const void *_data, enum hwmon_sensor_types type
> case hwmon_chip:
> switch (attr) {
> case hwmon_chip_update_interval:
> - if (chip == ina226 || chip == ina260)
> + if (has_update_interval)
> return 0644;
> break;
> default:
Hi, On 2/19/26 16:59, Guenter Roeck wrote: > On 2/19/26 05:01, Ian Ray wrote: >> diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c >> index 69ac0468dee4..4bf609e25f8a 100644 >> --- a/drivers/hwmon/ina2xx.c >> +++ b/drivers/hwmon/ina2xx.c >> @@ -46,9 +46,11 @@ >> #define INA2XX_CURRENT 0x04 /* readonly */ >> #define INA2XX_CALIBRATION 0x05 >> -/* INA226 register definitions */ >> +/* INA2xx register definitions */ > > There was a reason for this. INA219 does not support those registers > or, more generically, they are only supported on chips supporting > alert limits. > >> #define INA226_MASK_ENABLE 0x06 >> #define INA226_ALERT_LIMIT 0x07 >> + >> +/* INA226 register definitions */ >> #define INA226_DIE_ID 0xFF > > That isn't even used, and the comment is wrong (at least INA230 and INA260 > also support it). Might as well drop it. > > Either case, is that bike shedding really necessary ? The only really > valuable > change in this patch is the introduction of has_update_interval. Please > keep that > and drop the rest. > > Thanks, > Guenter I agree _this one_ hunk could be dropped. For the rest: Reviewed-by: Bence Csókás <bence98@sch.bme.hu> Bence
© 2016 - 2026 Red Hat, Inc.