summaryrefslogtreecommitdiff
path: root/drivers/hwmon/emc2103.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/emc2103.c')
-rw-r--r--drivers/hwmon/emc2103.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
index 4b7748a0a833..9b8e925af030 100644
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* emc2103.c - Support for SMSC EMC2103
* Copyright (c) 2010 SMSC
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/module.h>
@@ -290,8 +277,10 @@ fan1_input_show(struct device *dev, struct device_attribute *da, char *buf)
{
struct emc2103_data *data = emc2103_update_device(dev);
int rpm = 0;
+ mutex_lock(&data->update_lock);
if (data->fan_tach != 0)
rpm = (FAN_RPM_FACTOR * data->fan_multiplier) / data->fan_tach;
+ mutex_unlock(&data->update_lock);
return sprintf(buf, "%d\n", rpm);
}
@@ -376,10 +365,12 @@ fan1_target_show(struct device *dev, struct device_attribute *da, char *buf)
struct emc2103_data *data = emc2103_update_device(dev);
int rpm = 0;
+ mutex_lock(&data->update_lock);
/* high byte of 0xff indicates disabled so return 0 */
if ((data->fan_target != 0) && ((data->fan_target & 0x1fe0) != 0x1fe0))
rpm = (FAN_RPM_FACTOR * data->fan_multiplier)
/ data->fan_target;
+ mutex_unlock(&data->update_lock);
return sprintf(buf, "%d\n", rpm);
}
@@ -456,7 +447,7 @@ static ssize_t pwm1_enable_store(struct device *dev,
}
result = read_u8_from_i2c(client, REG_FAN_CONF1, &conf_reg);
- if (result) {
+ if (result < 0) {
count = result;
goto err;
}
@@ -564,7 +555,7 @@ static const struct attribute_group emc2103_temp4_group = {
};
static int
-emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id)
+emc2103_probe(struct i2c_client *client)
{
struct emc2103_data *data;
struct device *hwmon_dev;
@@ -633,7 +624,7 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id)
}
static const struct i2c_device_id emc2103_ids[] = {
- { "emc2103", 0, },
+ { "emc2103" },
{ /* LIST END */ }
};
MODULE_DEVICE_TABLE(i2c, emc2103_ids);
@@ -656,7 +647,7 @@ emc2103_detect(struct i2c_client *new_client, struct i2c_board_info *info)
if ((product != 0x24) && (product != 0x26))
return -ENODEV;
- strlcpy(info->type, "emc2103", I2C_NAME_SIZE);
+ strscpy(info->type, "emc2103", I2C_NAME_SIZE);
return 0;
}