1. 30 Aug, 2024 9 commits
    • Guenter Roeck's avatar
      hwmon: (ina2xx) Set alert latch · aa7d1763
      Guenter Roeck authored
      Alerts should only be cleared after reported, not immediately after the
      alert condition has been cleared. Set the latch enable bit to keep alerts
      latched until the alert register has been read from the chip.
      Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      aa7d1763
    • Guenter Roeck's avatar
      hwmon: (ina2xx) Consolidate chip initialization code · 51c6fa32
      Guenter Roeck authored
      Move all chip initialization code into a single function.
      
      No functional change.
      Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      51c6fa32
    • Guenter Roeck's avatar
      hwmon: (ina2xx) Fix various overflow issues · ab7fbee4
      Guenter Roeck authored
      Module tests show various overflow problems when writing limits
      and other attributes.
      
      in0_crit: Suspected overflow: [max=82, read 0, written 2147483648]
      in0_lcrit: Suspected overflow: [max=82, read 0, written 2147483648]
      in1_crit: Suspected overflow: [max=40959, read 0, written 2147483647]
      in1_lcrit: Suspected overflow: [max=40959, read 0, written 2147483647]
      power1_crit: Suspected overflow: [max=134218750, read 0, written 2147483648]
      update_interval: Suspected overflow: [max=2253, read 2, written 2147483647]
      
      Implement missing clamping on attribute write operations to avoid those
      problems.
      
      While at it, check in the probe function if the shunt resistor value
      passed from devicetree is valid, and bail out if it isn't. Also limit
      mutex use to the code calling ina2xx_set_shunt() since it isn't needed
      when called from the probe function.
      Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      ab7fbee4
    • Guenter Roeck's avatar
      hwmon: (ina2xx) Re-initialize chip using regmap functions · bb25cdc2
      Guenter Roeck authored
      If it is necessary to re-initialize the chip, for example because
      it has been power cycled, use regmap functions to update register
      contents. This ensures that all registers, including the configuration
      register and alert registers, are updated to previously configured
      values without having to locally cache everything.
      
      For this to work, volatile registers have to be marked as volatile.
      Also, the cache needs to be bypassed when reading the calibration
      and mask_enable registers. While the calibration register is not
      volatile, it will be reset to 0 if the chip has been power cycled.
      Most of the bits in the mask_enable register are configuration bits,
      except for bit 4 which reports if an alert has been observed.
      Both registers need to be marked as non-volatile to be updated
      after a power cycle, but it is necessary to bypass the cache when
      reading them to detect if the chip has been power cycled and to
      read the alert status.
      
      The chip does not support register auto-increments. It is therefore
      necessary to configure regmap to use single register read/write
      operations. Otherwise regmap tries to write all registers in a single
      operation when synchronizing register contents with the hardware,
      and the synchronization fails.
      
      Another necessary change is to declare ina226_alert_to_reg() as u16.
      So far it returned an s16 which is sign extended to a large negative
      value which is then sent to regmap as unsigned int, causing an -EINVAL
      error return.
      Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      bb25cdc2
    • Guenter Roeck's avatar
      hwmon: (ina2xx) Use local regmap pointer if used more than once · d491e781
      Guenter Roeck authored
      If regmap is accessed more than once in a function, declare and used
      local regmap variable.
      
      While at it, drop low value debug messages.
      Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      d491e781
    • Guenter Roeck's avatar
      hwmon: (ina2xx) Mark regmap_config as const · 2bb47652
      Guenter Roeck authored
      Recent versions of checkpatch complain that struct regmap_config
      should be declared as const.
      
      WARNING: struct regmap_config should normally be const
      
      Doing so reveals a potential problem in the driver: If both supported
      chips are present in a single system, the maximum number of registers
      may race when devices are instantiated since max_registers is updated
      in the probe function. Solve the problem by setting .max_registers to the
      maximum register address of all supported chips. This does not make a
      practical difference while fixing the potential race condition and reducing
      code complexity.
      Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      2bb47652
    • Guenter Roeck's avatar
      hwmon: (ina2xx) Use bit operations · 232177a3
      Guenter Roeck authored
      Use bit operations where possible to make the code more generic and to
      align it with other drivers. Also use compile time conversion from bit
      to mask to reduce runtime overhead.
      Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      232177a3
    • Guenter Roeck's avatar
      hwmon: (ina2xx) Replace platform data with device properties · 61a4a841
      Guenter Roeck authored
      There are no in-tree users of ina2xx platform data. Drop it and support
      device properties instead as alternative if it should ever be needed.
      Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      61a4a841
    • Guenter Roeck's avatar
      hwmon: (ina2xx) Reorder include files to alphabetic order · 9e60bb81
      Guenter Roeck authored
      Simplify driver maintenance by reordering include files to alphabetic
      order.
      
      Whule at it, drop unnecessary / unused jiffies.h.
      
      No functional change.
      Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      9e60bb81
  2. 29 Aug, 2024 1 commit
  3. 28 Aug, 2024 1 commit
    • Nathan Chancellor's avatar
      hwmon: (oxp-sensors) Add missing breaks to fix -Wimplicit-fallthrough with clang · 98845e77
      Nathan Chancellor authored
      clang warns (or errors due to CONFIG_WERROR):
      
        drivers/hwmon/oxp-sensors.c:481:3: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
        drivers/hwmon/oxp-sensors.c:553:3: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
        drivers/hwmon/oxp-sensors.c:556:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
        drivers/hwmon/oxp-sensors.c:607:3: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
      
      Clang is a little more pedantic than GCC, which does not warn when
      falling through to a case that is just break or return. Clang's version
      is more in line with the kernel's own stance in deprecated.rst, which
      states that all switch/case blocks must end in either break,
      fallthrough, continue, goto, or return. Add the missing breaks to
      silence the warnings.
      
      Fixes: b82b38a4 ("hwmon: (oxp-sensors) Add support for multiple new devices.")
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Message-ID: <20240828-hwmon-oxp-sensors-fix-clang-implicit-fallthrough-v1-1-dc48496ac67a@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      98845e77
  4. 27 Aug, 2024 29 commits