public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] hwmon: add support for sensors exported via ARM SCMI
@ 2018-03-12 14:17 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2018-03-12 14:17 UTC (permalink / raw)
  To: sudeep.holla; +Cc: linux-hwmon

Hello Sudeep Holla,

The patch b23688aefb8b: "hwmon: add support for sensors exported via
ARM SCMI" from Jun 15, 2017, leads to the following static checker
warning:

	drivers/hwmon/scmi-hwmon.c:141 scmi_hwmon_probe()
	warn: passing zero to 'PTR_ERR'

drivers/hwmon/scmi-hwmon.c
   111  static int scmi_hwmon_probe(struct scmi_device *sdev)
   112  {
   113          int i, idx;
   114          u16 nr_sensors;
   115          enum hwmon_sensor_types type;
   116          struct scmi_sensors *scmi_sensors;
   117          const struct scmi_sensor_info *sensor;
   118          int nr_count[hwmon_max] = {0}, nr_types = 0;
   119          const struct hwmon_chip_info *chip_info;
   120          struct device *hwdev, *dev = &sdev->dev;
   121          struct hwmon_channel_info *scmi_hwmon_chan;
   122          const struct hwmon_channel_info **ptr_scmi_ci;
   123          const struct scmi_handle *handle = sdev->handle;
   124  
   125          if (!handle || !handle->sensor_ops)
   126                  return -ENODEV;
   127  
   128          nr_sensors = handle->sensor_ops->count_get(handle);
   129          if (!nr_sensors)
   130                  return -EIO;
   131  
   132          scmi_sensors = devm_kzalloc(dev, sizeof(*scmi_sensors), GFP_KERNEL);
   133          if (!scmi_sensors)
   134                  return -ENOMEM;
   135  
   136          scmi_sensors->handle = handle;
   137  
   138          for (i = 0; i < nr_sensors; i++) {
   139                  sensor = handle->sensor_ops->info_get(handle, i);
   140                  if (!sensor)
   141                          return PTR_ERR(sensor);
                                               ^^^^^^
This means "return 0;" which obviously isn't right, but I don't know the
currect error code to return.

   142  
   143                  switch (sensor->type) {
   144                  case TEMPERATURE_C:
   145                  case VOLTAGE:
   146                  case CURRENT:
   147                  case POWER:
   148                  case ENERGY:
   149                          type = scmi_types[sensor->type];
   150                          if (!nr_count[type])
   151                                  nr_types++;
   152                          nr_count[type]++;
   153                          break;
   154                  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-03-12 14:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-12 14:17 [bug report] hwmon: add support for sensors exported via ARM SCMI Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox