hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/hwmon/ibmaem.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * A hwmon driver for the IBM System Director Active Energy Manager (AEM)
34 * temperature/power/energy sensors and capping functionality.
45 * Copyright (C) 2008 IBM
56 *
67 * Author: Darrick J. Wong <darrick.wong@oracle.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, write to the Free Software
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
218 */
229
2310 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -101,7 +88,7 @@
10188 struct aem_ipmi_data {
10289 struct completion read_complete;
10390 struct ipmi_addr address;
104
- ipmi_user_t user;
91
+ struct ipmi_user *user;
10592 int interface;
10693
10794 struct kernel_ipmi_msg tx_message;
....@@ -232,7 +219,7 @@
232219
233220 struct aem_read_sensor_resp {
234221 struct aem_iana_id id;
235
- u8 bytes[0];
222
+ u8 bytes[];
236223 } __packed;
237224
238225 /* Data structures to talk to the IPMI layer */
....@@ -563,7 +550,7 @@
563550
564551 res = platform_device_add(data->pdev);
565552 if (res)
566
- goto ipmi_err;
553
+ goto dev_add_err;
567554
568555 platform_set_drvdata(data->pdev, data);
569556
....@@ -611,7 +598,9 @@
611598 ipmi_destroy_user(data->ipmi.user);
612599 ipmi_err:
613600 platform_set_drvdata(data->pdev, NULL);
614
- platform_device_unregister(data->pdev);
601
+ platform_device_del(data->pdev);
602
+dev_add_err:
603
+ platform_device_put(data->pdev);
615604 dev_err:
616605 ida_simple_remove(&aem_ida, data->id);
617606 id_err:
....@@ -703,7 +692,7 @@
703692
704693 res = platform_device_add(data->pdev);
705694 if (res)
706
- goto ipmi_err;
695
+ goto dev_add_err;
707696
708697 platform_set_drvdata(data->pdev, data);
709698
....@@ -751,7 +740,9 @@
751740 ipmi_destroy_user(data->ipmi.user);
752741 ipmi_err:
753742 platform_set_drvdata(data->pdev, NULL);
754
- platform_device_unregister(data->pdev);
743
+ platform_device_del(data->pdev);
744
+dev_add_err:
745
+ platform_device_put(data->pdev);
755746 dev_err:
756747 ida_simple_remove(&aem_ida, data->id);
757748 id_err:
....@@ -813,25 +804,24 @@
813804 /* sysfs support functions */
814805
815806 /* AEM device name */
816
-static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
807
+static ssize_t name_show(struct device *dev, struct device_attribute *devattr,
817808 char *buf)
818809 {
819810 struct aem_data *data = dev_get_drvdata(dev);
820811
821812 return sprintf(buf, "%s%d\n", DRVNAME, data->ver_major);
822813 }
823
-static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0);
814
+static SENSOR_DEVICE_ATTR_RO(name, name, 0);
824815
825816 /* AEM device version */
826
-static ssize_t show_version(struct device *dev,
827
- struct device_attribute *devattr,
828
- char *buf)
817
+static ssize_t version_show(struct device *dev,
818
+ struct device_attribute *devattr, char *buf)
829819 {
830820 struct aem_data *data = dev_get_drvdata(dev);
831821
832822 return sprintf(buf, "%d.%d\n", data->ver_major, data->ver_minor);
833823 }
834
-static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, 0);
824
+static SENSOR_DEVICE_ATTR_RO(version, version, 0);
835825
836826 /* Display power use */
837827 static ssize_t aem_show_power(struct device *dev,
....@@ -931,7 +921,7 @@
931921 while (ro->label) {
932922 sysfs_attr_init(&sensors->dev_attr.attr);
933923 sensors->dev_attr.attr.name = ro->label;
934
- sensors->dev_attr.attr.mode = S_IRUGO;
924
+ sensors->dev_attr.attr.mode = 0444;
935925 sensors->dev_attr.show = ro->show;
936926 sensors->index = ro->index;
937927
....@@ -948,7 +938,7 @@
948938 while (rw->label) {
949939 sysfs_attr_init(&sensors->dev_attr.attr);
950940 sensors->dev_attr.attr.name = rw->label;
951
- sensors->dev_attr.attr.mode = S_IRUGO | S_IWUSR;
941
+ sensors->dev_attr.attr.mode = 0644;
952942 sensors->dev_attr.show = rw->show;
953943 sensors->dev_attr.store = rw->set;
954944 sensors->index = rw->index;