Merge tag 'hwmon-for-v5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 13 May 2021 16:58:53 +0000 (09:58 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 13 May 2021 16:58:53 +0000 (09:58 -0700)
Pull hwmon fixes from Guenter Roeck:
 "Fix bugs/regressions in adm9240, ltc2992, pmbus/fsp-3y, and occ
  drivers, plus a minor cleanup in the corsair-psu driver"

* tag 'hwmon-for-v5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (adm9240) Fix writes into inX_max attributes
  hwmon: (ltc2992) Put fwnode in error case during ->probe()
  hwmon: (pmbus/fsp-3y) Fix FSP-3Y YH-5151E non-compliant vout encoding
  hwmon: (occ) Fix poll rate limiting
  hwmon: (corsair-psu) Remove unneeded semicolons

drivers/hwmon/adm9240.c
drivers/hwmon/corsair-psu.c
drivers/hwmon/ltc2992.c
drivers/hwmon/occ/common.c
drivers/hwmon/occ/common.h
drivers/hwmon/pmbus/fsp-3y.c

index 5677263..483cd75 100644 (file)
@@ -485,7 +485,7 @@ static int adm9240_in_write(struct device *dev, u32 attr, int channel, long val)
                reg = ADM9240_REG_IN_MIN(channel);
                break;
        case hwmon_in_max:
-               reg = ADM9240_REG_IN(channel);
+               reg = ADM9240_REG_IN_MAX(channel);
                break;
        default:
                return -EOPNOTSUPP;
index 3a5807e..02298b8 100644 (file)
@@ -355,7 +355,7 @@ static umode_t corsairpsu_hwmon_power_is_visible(const struct corsairpsu_data *p
                return 0444;
        default:
                return 0;
-       };
+       }
 }
 
 static umode_t corsairpsu_hwmon_in_is_visible(const struct corsairpsu_data *priv, u32 attr,
@@ -376,7 +376,7 @@ static umode_t corsairpsu_hwmon_in_is_visible(const struct corsairpsu_data *priv
                break;
        default:
                break;
-       };
+       }
 
        return res;
 }
index 4382105..2a4bed0 100644 (file)
@@ -900,11 +900,15 @@ static int ltc2992_parse_dt(struct ltc2992_state *st)
 
        fwnode_for_each_available_child_node(fwnode, child) {
                ret = fwnode_property_read_u32(child, "reg", &addr);
-               if (ret < 0)
+               if (ret < 0) {
+                       fwnode_handle_put(child);
                        return ret;
+               }
 
-               if (addr > 1)
+               if (addr > 1) {
+                       fwnode_handle_put(child);
                        return -EINVAL;
+               }
 
                ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val);
                if (!ret)
index f1ac153..967532a 100644 (file)
@@ -217,9 +217,9 @@ int occ_update_response(struct occ *occ)
                return rc;
 
        /* limit the maximum rate of polling the OCC */
-       if (time_after(jiffies, occ->last_update + OCC_UPDATE_FREQUENCY)) {
+       if (time_after(jiffies, occ->next_update)) {
                rc = occ_poll(occ);
-               occ->last_update = jiffies;
+               occ->next_update = jiffies + OCC_UPDATE_FREQUENCY;
        } else {
                rc = occ->last_error;
        }
@@ -1165,6 +1165,7 @@ int occ_setup(struct occ *occ, const char *name)
                return rc;
        }
 
+       occ->next_update = jiffies + OCC_UPDATE_FREQUENCY;
        occ_parse_poll_response(occ);
 
        rc = occ_setup_sensor_attrs(occ);
index 67e6968..e6df719 100644 (file)
@@ -99,7 +99,7 @@ struct occ {
        u8 poll_cmd_data;               /* to perform OCC poll command */
        int (*send_cmd)(struct occ *occ, u8 *cmd);
 
-       unsigned long last_update;
+       unsigned long next_update;
        struct mutex lock;              /* lock OCC access */
 
        struct device *hwmon;
index b177987..e248424 100644 (file)
@@ -57,7 +57,7 @@ static int page_log_to_page_real(int page_log, enum chips chip)
                case YH5151E_PAGE_12V_LOG:
                        return YH5151E_PAGE_12V_REAL;
                case YH5151E_PAGE_5V_LOG:
-                       return YH5151E_PAGE_5V_LOG;
+                       return YH5151E_PAGE_5V_REAL;
                case YH5151E_PAGE_3V3_LOG:
                        return YH5151E_PAGE_3V3_REAL;
                }
@@ -103,8 +103,18 @@ static int set_page(struct i2c_client *client, int page_log)
 
 static int fsp3y_read_byte_data(struct i2c_client *client, int page, int reg)
 {
+       const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
+       struct fsp3y_data *data = to_fsp3y_data(info);
        int rv;
 
+       /*
+        * YH5151-E outputs vout in linear11. The conversion is done when
+        * reading. Here, we have to inject pmbus_core with the correct
+        * exponent (it is -6).
+        */
+       if (data->chip == yh5151e && reg == PMBUS_VOUT_MODE)
+               return 0x1A;
+
        rv = set_page(client, page);
        if (rv < 0)
                return rv;
@@ -114,6 +124,8 @@ static int fsp3y_read_byte_data(struct i2c_client *client, int page, int reg)
 
 static int fsp3y_read_word_data(struct i2c_client *client, int page, int phase, int reg)
 {
+       const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
+       struct fsp3y_data *data = to_fsp3y_data(info);
        int rv;
 
        /*
@@ -144,7 +156,18 @@ static int fsp3y_read_word_data(struct i2c_client *client, int page, int phase,
        if (rv < 0)
                return rv;
 
-       return i2c_smbus_read_word_data(client, reg);
+       rv = i2c_smbus_read_word_data(client, reg);
+       if (rv < 0)
+               return rv;
+
+       /*
+        * YH-5151E is non-compliant and outputs output voltages in linear11
+        * instead of linear16.
+        */
+       if (data->chip == yh5151e && reg == PMBUS_READ_VOUT)
+               rv = sign_extend32(rv, 10) & 0xffff;
+
+       return rv;
 }
 
 static struct pmbus_driver_info fsp3y_info[] = {