diff options
Diffstat (limited to 'drivers/hwmon/ibmpex.c')
| -rw-r--r-- | drivers/hwmon/ibmpex.c | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c index bb17a29af64c..228c5f6c6f38 100644 --- a/drivers/hwmon/ibmpex.c +++ b/drivers/hwmon/ibmpex.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * A hwmon driver for the IBM PowerExecutive temperature/power sensors * Copyright (C) 2007 IBM * * Author: Darrick J. Wong <darrick.wong@oracle.com> - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/ipmi.h> @@ -79,7 +66,7 @@ struct ibmpex_bmc_data { struct device *hwmon_dev; struct device *bmc_device; struct mutex lock; - char valid; + bool valid; unsigned long last_updated; /* In jiffies */ struct ipmi_addr address; @@ -252,7 +239,7 @@ static void ibmpex_update_device(struct ibmpex_bmc_data *data) } data->last_updated = jiffies; - data->valid = 1; + data->valid = true; out: mutex_unlock(&data->lock); @@ -269,12 +256,7 @@ static struct ibmpex_bmc_data *get_bmc_data(int iface) return NULL; } -static ssize_t show_name(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - return sprintf(buf, "%s\n", DRVNAME); -} -static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0); +static DEVICE_STRING_ATTR_RO(name, 0444, DRVNAME); static ssize_t ibmpex_show_sensor(struct device *dev, struct device_attribute *devattr, @@ -289,10 +271,9 @@ static ssize_t ibmpex_show_sensor(struct device *dev, data->sensors[attr->index].values[attr->nr] * mult); } -static ssize_t ibmpex_reset_high_low(struct device *dev, +static ssize_t ibmpex_high_low_store(struct device *dev, struct device_attribute *devattr, - const char *buf, - size_t count) + const char *buf, size_t count) { struct ibmpex_bmc_data *data = dev_get_drvdata(dev); @@ -301,8 +282,7 @@ static ssize_t ibmpex_reset_high_low(struct device *dev, return count; } -static SENSOR_DEVICE_ATTR(reset_high_low, S_IWUSR, NULL, - ibmpex_reset_high_low, 0); +static SENSOR_DEVICE_ATTR_WO(reset_high_low, ibmpex_high_low, 0); static int is_power_sensor(const char *sensor_id, int len) { @@ -358,7 +338,7 @@ static int create_sensor(struct ibmpex_bmc_data *data, int type, sysfs_attr_init(&data->sensors[sensor].attr[func].dev_attr.attr); data->sensors[sensor].attr[func].dev_attr.attr.name = n; - data->sensors[sensor].attr[func].dev_attr.attr.mode = S_IRUGO; + data->sensors[sensor].attr[func].dev_attr.attr.mode = 0444; data->sensors[sensor].attr[func].dev_attr.show = ibmpex_show_sensor; data->sensors[sensor].attr[func].index = sensor; data->sensors[sensor].attr[func].nr = func; @@ -430,8 +410,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data) if (err) goto exit_remove; - err = device_create_file(data->bmc_device, - &sensor_dev_attr_name.dev_attr); + err = device_create_file(data->bmc_device, &dev_attr_name.attr); if (err) goto exit_remove; @@ -440,7 +419,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data) exit_remove: device_remove_file(data->bmc_device, &sensor_dev_attr_reset_high_low.dev_attr); - device_remove_file(data->bmc_device, &sensor_dev_attr_name.dev_attr); + device_remove_file(data->bmc_device, &dev_attr_name.attr); for (i = 0; i < data->num_sensors; i++) for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { if (!data->sensors[i].attr[j].dev_attr.attr.name) @@ -517,6 +496,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev) return; out_register: + list_del(&data->list); hwmon_device_unregister(data->hwmon_dev); out_user: ipmi_destroy_user(data->user); @@ -530,7 +510,7 @@ static void ibmpex_bmc_delete(struct ibmpex_bmc_data *data) device_remove_file(data->bmc_device, &sensor_dev_attr_reset_high_low.dev_attr); - device_remove_file(data->bmc_device, &sensor_dev_attr_name.dev_attr); + device_remove_file(data->bmc_device, &dev_attr_name.attr); for (i = 0; i < data->num_sensors; i++) for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { if (!data->sensors[i].attr[j].dev_attr.attr.name) @@ -560,7 +540,7 @@ static void ibmpex_bmc_gone(int iface) static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) { - struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data; + struct ibmpex_bmc_data *data = user_msg_data; if (msg->msgid != data->tx_msgid) { dev_err(data->bmc_device, |
