Re: [PATCH v2 1/5] hwmon: (max31790) Rework to use regmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dan,

thanks, I will fix this in v3 of this patch series.

Vaclav

st 17. 3. 2021 v 6:14 odesílatel Dan Carpenter
<dan.carpenter@xxxxxxxxxx> napsal:
>
> Hi "Václav,
>
> url:    https://github.com/0day-ci/linux/commits/V-clav-Kubern-t/hwmon-max31790-Rework-to-use-regmap/20210317-015931
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
> config: x86_64-randconfig-m001-20210316 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
>
> smatch warnings:
> drivers/hwmon/max31790.c:263 max31790_fan_is_visible() warn: impossible condition '(fan_config < 0) => (0-255 < 0)'
> drivers/hwmon/max31790.c:337 max31790_write_pwm() warn: impossible condition '(fan_config < 0) => (0-255 < 0)'
> drivers/hwmon/max31790.c:372 max31790_pwm_is_visible() warn: impossible condition '(fan_config < 0) => (0-255 < 0)'
>
> vim +263 drivers/hwmon/max31790.c
>
> 54187ff9d766b2 Guenter Roeck   2016-07-01  257  static umode_t max31790_fan_is_visible(const void *_data, u32 attr, int channel)
> 195a4b4298a795 Il Han          2015-08-30  258  {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  259          const struct max31790_data *data = _data;
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  260          struct regmap *regmap = data->regmap;
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  261          u8 fan_config = read_reg_byte(regmap, MAX31790_REG_FAN_CONFIG(channel % NR_CHANNEL));
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  262
> 2c8602cfaeab63 Václav Kubernát 2021-03-16 @263          if (fan_config < 0)
>                                                             ^^^^^^^^^^^^^^
> A u8 can't be negative.
>
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  264                  return 0;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  265
> 54187ff9d766b2 Guenter Roeck   2016-07-01  266          switch (attr) {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  267          case hwmon_fan_input:
> 54187ff9d766b2 Guenter Roeck   2016-07-01  268          case hwmon_fan_fault:
> 54187ff9d766b2 Guenter Roeck   2016-07-01  269                  if (channel < NR_CHANNEL ||
> 54187ff9d766b2 Guenter Roeck   2016-07-01  270                      (fan_config & MAX31790_FAN_CFG_TACH_INPUT))
> dc8dbb4d7672b7 Guenter Roeck   2018-12-10  271                          return 0444;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  272                  return 0;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  273          case hwmon_fan_target:
> 54187ff9d766b2 Guenter Roeck   2016-07-01  274                  if (channel < NR_CHANNEL &&
> 54187ff9d766b2 Guenter Roeck   2016-07-01  275                      !(fan_config & MAX31790_FAN_CFG_TACH_INPUT))
> dc8dbb4d7672b7 Guenter Roeck   2018-12-10  276                          return 0644;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  277                  return 0;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  278          default:
> 54187ff9d766b2 Guenter Roeck   2016-07-01  279                  return 0;
> 195a4b4298a795 Il Han          2015-08-30  280          }
> 195a4b4298a795 Il Han          2015-08-30  281  }
> 195a4b4298a795 Il Han          2015-08-30  282
> 54187ff9d766b2 Guenter Roeck   2016-07-01  283  static int max31790_read_pwm(struct device *dev, u32 attr, int channel,
> 54187ff9d766b2 Guenter Roeck   2016-07-01  284                               long *val)
> 195a4b4298a795 Il Han          2015-08-30  285  {
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  286          struct max31790_data *data = dev_get_drvdata(dev);
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  287          struct regmap *regmap = data->regmap;
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  288          int read;
> 195a4b4298a795 Il Han          2015-08-30  289
> 195a4b4298a795 Il Han          2015-08-30  290          if (IS_ERR(data))
> 195a4b4298a795 Il Han          2015-08-30  291                  return PTR_ERR(data);
> 195a4b4298a795 Il Han          2015-08-30  292
> 54187ff9d766b2 Guenter Roeck   2016-07-01  293          switch (attr) {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  294          case hwmon_pwm_input:
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  295                  read = read_reg_word(regmap, MAX31790_REG_PWMOUT(channel));
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  296                  if (read < 0)
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  297                          return read;
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  298
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  299                  *val = read >> 8;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  300                  return 0;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  301          case hwmon_pwm_enable:
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  302                  read = read_reg_byte(regmap, MAX31790_REG_FAN_CONFIG(channel));
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  303                  if (read < 0)
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  304                          return read;
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  305
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  306                  if (read & MAX31790_FAN_CFG_RPM_MODE)
> 54187ff9d766b2 Guenter Roeck   2016-07-01  307                          *val = 2;
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  308                  else if (read & MAX31790_FAN_CFG_TACH_INPUT_EN)
> 54187ff9d766b2 Guenter Roeck   2016-07-01  309                          *val = 1;
> 195a4b4298a795 Il Han          2015-08-30  310                  else
> 54187ff9d766b2 Guenter Roeck   2016-07-01  311                          *val = 0;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  312                  return 0;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  313          default:
> 54187ff9d766b2 Guenter Roeck   2016-07-01  314                  return -EOPNOTSUPP;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  315          }
> 195a4b4298a795 Il Han          2015-08-30  316  }
> 195a4b4298a795 Il Han          2015-08-30  317
> 54187ff9d766b2 Guenter Roeck   2016-07-01  318  static int max31790_write_pwm(struct device *dev, u32 attr, int channel,
> 54187ff9d766b2 Guenter Roeck   2016-07-01  319                                long val)
> 195a4b4298a795 Il Han          2015-08-30  320  {
> 195a4b4298a795 Il Han          2015-08-30  321          struct max31790_data *data = dev_get_drvdata(dev);
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  322          struct regmap *regmap = data->regmap;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  323          u8 fan_config;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  324          int err = 0;
> 195a4b4298a795 Il Han          2015-08-30  325
> 54187ff9d766b2 Guenter Roeck   2016-07-01  326          switch (attr) {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  327          case hwmon_pwm_input:
> 54187ff9d766b2 Guenter Roeck   2016-07-01  328                  if (val < 0 || val > 255) {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  329                          err = -EINVAL;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  330                          break;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  331                  }
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  332                  err = write_reg_word(regmap, MAX31790_REG_PWMOUT(channel), val << 8);
> 195a4b4298a795 Il Han          2015-08-30  333                  break;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  334          case hwmon_pwm_enable:
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  335                  fan_config = read_reg_byte(regmap, MAX31790_REG_FAN_CONFIG(channel % NR_CHANNEL));
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  336
> 2c8602cfaeab63 Václav Kubernát 2021-03-16 @337                  if (fan_config < 0)
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  338                          return fan_config;
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  339
> 54187ff9d766b2 Guenter Roeck   2016-07-01  340                  if (val == 0) {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  341                          fan_config &= ~(MAX31790_FAN_CFG_TACH_INPUT_EN |
> 54187ff9d766b2 Guenter Roeck   2016-07-01  342                                          MAX31790_FAN_CFG_RPM_MODE);
> 54187ff9d766b2 Guenter Roeck   2016-07-01  343                  } else if (val == 1) {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  344                          fan_config = (fan_config |
> 54187ff9d766b2 Guenter Roeck   2016-07-01  345                                        MAX31790_FAN_CFG_TACH_INPUT_EN) &
> 54187ff9d766b2 Guenter Roeck   2016-07-01  346                                       ~MAX31790_FAN_CFG_RPM_MODE;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  347                  } else if (val == 2) {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  348                          fan_config |= MAX31790_FAN_CFG_TACH_INPUT_EN |
> 54187ff9d766b2 Guenter Roeck   2016-07-01  349                                        MAX31790_FAN_CFG_RPM_MODE;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  350                  } else {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  351                          err = -EINVAL;
> 195a4b4298a795 Il Han          2015-08-30  352                          break;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  353                  }
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  354                  err = regmap_write(regmap,
> 54187ff9d766b2 Guenter Roeck   2016-07-01  355                                     MAX31790_REG_FAN_CONFIG(channel),
> 54187ff9d766b2 Guenter Roeck   2016-07-01  356                                     fan_config);
> 195a4b4298a795 Il Han          2015-08-30  357                  break;
> 195a4b4298a795 Il Han          2015-08-30  358          default:
> 54187ff9d766b2 Guenter Roeck   2016-07-01  359                  err = -EOPNOTSUPP;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  360                  break;
> 195a4b4298a795 Il Han          2015-08-30  361          }
> 195a4b4298a795 Il Han          2015-08-30  362
> 195a4b4298a795 Il Han          2015-08-30  363          return err;
> 195a4b4298a795 Il Han          2015-08-30  364  }
> 195a4b4298a795 Il Han          2015-08-30  365
> 54187ff9d766b2 Guenter Roeck   2016-07-01  366  static umode_t max31790_pwm_is_visible(const void *_data, u32 attr, int channel)
> 195a4b4298a795 Il Han          2015-08-30  367  {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  368          const struct max31790_data *data = _data;
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  369          struct regmap *regmap = data->regmap;
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  370          u8 fan_config = read_reg_byte(regmap, MAX31790_REG_FAN_CONFIG(channel % NR_CHANNEL));
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  371
> 2c8602cfaeab63 Václav Kubernát 2021-03-16 @372          if (fan_config < 0)
> 2c8602cfaeab63 Václav Kubernát 2021-03-16  373                  return 0;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  374
> 54187ff9d766b2 Guenter Roeck   2016-07-01  375          switch (attr) {
> 54187ff9d766b2 Guenter Roeck   2016-07-01  376          case hwmon_pwm_input:
> 54187ff9d766b2 Guenter Roeck   2016-07-01  377          case hwmon_pwm_enable:
> 54187ff9d766b2 Guenter Roeck   2016-07-01  378                  if (!(fan_config & MAX31790_FAN_CFG_TACH_INPUT))
> dc8dbb4d7672b7 Guenter Roeck   2018-12-10  379                          return 0644;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  380                  return 0;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  381          default:
> 54187ff9d766b2 Guenter Roeck   2016-07-01  382                  return 0;
> 54187ff9d766b2 Guenter Roeck   2016-07-01  383          }
> 54187ff9d766b2 Guenter Roeck   2016-07-01  384  }
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux