···1616#include <linux/hwmon.h>1717#include <linux/hwmon-sysfs.h>1818#include <linux/err.h>1919-#include <linux/mutex.h>2019#include <linux/delay.h>21202221#define ADC_STEP_MV 2···74757576struct powr1220_data {7677 struct i2c_client *client;7777- struct mutex update_lock;7878 u8 max_channels;7979 bool adc_valid[MAX_POWR1220_ADC_VALUES];8080 /* the next value is in jiffies */···109111 int result;110112 int adc_range = 0;111113112112- mutex_lock(&data->update_lock);113113-114114 if (time_after(jiffies, data->adc_last_updated[ch_num] + HZ) ||115115 !data->adc_valid[ch_num]) {116116 /*···124128 /* set the attenuator and mux */125129 result = i2c_smbus_write_byte_data(data->client, ADC_MUX,126130 adc_range | ch_num);127127- if (result)128128- goto exit;131131+ if (result < 0)132132+ return result;129133130134 /*131135 * wait at least Tconvert time (200 us) for the···136140 /* get the ADC reading */137141 result = i2c_smbus_read_byte_data(data->client, ADC_VALUE_LOW);138142 if (result < 0)139139- goto exit;143143+ return result;140144141145 reading = result >> 4;142146143147 /* get the upper half of the reading */144148 result = i2c_smbus_read_byte_data(data->client, ADC_VALUE_HIGH);145149 if (result < 0)146146- goto exit;150150+ return result;147151148152 reading |= result << 4;149153···159163 } else {160164 result = data->adc_values[ch_num];161165 }162162-163163-exit:164164- mutex_unlock(&data->update_lock);165165-166166 return result;167167}168168···294302 break;295303 }296304297297- mutex_init(&data->update_lock);298305 data->client = client;299306300307 hwmon_dev = devm_hwmon_device_register_with_info(&client->dev,