| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * A hwmon driver for the IBM System Director Active Energy Manager (AEM) |
|---|
| 3 | 4 | * temperature/power/energy sensors and capping functionality. |
|---|
| 4 | 5 | * Copyright (C) 2008 IBM |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * 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 |
|---|
| 21 | 8 | */ |
|---|
| 22 | 9 | |
|---|
| 23 | 10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 101 | 88 | struct aem_ipmi_data { |
|---|
| 102 | 89 | struct completion read_complete; |
|---|
| 103 | 90 | struct ipmi_addr address; |
|---|
| 104 | | - ipmi_user_t user; |
|---|
| 91 | + struct ipmi_user *user; |
|---|
| 105 | 92 | int interface; |
|---|
| 106 | 93 | |
|---|
| 107 | 94 | struct kernel_ipmi_msg tx_message; |
|---|
| .. | .. |
|---|
| 232 | 219 | |
|---|
| 233 | 220 | struct aem_read_sensor_resp { |
|---|
| 234 | 221 | struct aem_iana_id id; |
|---|
| 235 | | - u8 bytes[0]; |
|---|
| 222 | + u8 bytes[]; |
|---|
| 236 | 223 | } __packed; |
|---|
| 237 | 224 | |
|---|
| 238 | 225 | /* Data structures to talk to the IPMI layer */ |
|---|
| .. | .. |
|---|
| 563 | 550 | |
|---|
| 564 | 551 | res = platform_device_add(data->pdev); |
|---|
| 565 | 552 | if (res) |
|---|
| 566 | | - goto ipmi_err; |
|---|
| 553 | + goto dev_add_err; |
|---|
| 567 | 554 | |
|---|
| 568 | 555 | platform_set_drvdata(data->pdev, data); |
|---|
| 569 | 556 | |
|---|
| .. | .. |
|---|
| 611 | 598 | ipmi_destroy_user(data->ipmi.user); |
|---|
| 612 | 599 | ipmi_err: |
|---|
| 613 | 600 | 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); |
|---|
| 615 | 604 | dev_err: |
|---|
| 616 | 605 | ida_simple_remove(&aem_ida, data->id); |
|---|
| 617 | 606 | id_err: |
|---|
| .. | .. |
|---|
| 703 | 692 | |
|---|
| 704 | 693 | res = platform_device_add(data->pdev); |
|---|
| 705 | 694 | if (res) |
|---|
| 706 | | - goto ipmi_err; |
|---|
| 695 | + goto dev_add_err; |
|---|
| 707 | 696 | |
|---|
| 708 | 697 | platform_set_drvdata(data->pdev, data); |
|---|
| 709 | 698 | |
|---|
| .. | .. |
|---|
| 751 | 740 | ipmi_destroy_user(data->ipmi.user); |
|---|
| 752 | 741 | ipmi_err: |
|---|
| 753 | 742 | 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); |
|---|
| 755 | 746 | dev_err: |
|---|
| 756 | 747 | ida_simple_remove(&aem_ida, data->id); |
|---|
| 757 | 748 | id_err: |
|---|
| .. | .. |
|---|
| 813 | 804 | /* sysfs support functions */ |
|---|
| 814 | 805 | |
|---|
| 815 | 806 | /* 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, |
|---|
| 817 | 808 | char *buf) |
|---|
| 818 | 809 | { |
|---|
| 819 | 810 | struct aem_data *data = dev_get_drvdata(dev); |
|---|
| 820 | 811 | |
|---|
| 821 | 812 | return sprintf(buf, "%s%d\n", DRVNAME, data->ver_major); |
|---|
| 822 | 813 | } |
|---|
| 823 | | -static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0); |
|---|
| 814 | +static SENSOR_DEVICE_ATTR_RO(name, name, 0); |
|---|
| 824 | 815 | |
|---|
| 825 | 816 | /* 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) |
|---|
| 829 | 819 | { |
|---|
| 830 | 820 | struct aem_data *data = dev_get_drvdata(dev); |
|---|
| 831 | 821 | |
|---|
| 832 | 822 | return sprintf(buf, "%d.%d\n", data->ver_major, data->ver_minor); |
|---|
| 833 | 823 | } |
|---|
| 834 | | -static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, 0); |
|---|
| 824 | +static SENSOR_DEVICE_ATTR_RO(version, version, 0); |
|---|
| 835 | 825 | |
|---|
| 836 | 826 | /* Display power use */ |
|---|
| 837 | 827 | static ssize_t aem_show_power(struct device *dev, |
|---|
| .. | .. |
|---|
| 931 | 921 | while (ro->label) { |
|---|
| 932 | 922 | sysfs_attr_init(&sensors->dev_attr.attr); |
|---|
| 933 | 923 | sensors->dev_attr.attr.name = ro->label; |
|---|
| 934 | | - sensors->dev_attr.attr.mode = S_IRUGO; |
|---|
| 924 | + sensors->dev_attr.attr.mode = 0444; |
|---|
| 935 | 925 | sensors->dev_attr.show = ro->show; |
|---|
| 936 | 926 | sensors->index = ro->index; |
|---|
| 937 | 927 | |
|---|
| .. | .. |
|---|
| 948 | 938 | while (rw->label) { |
|---|
| 949 | 939 | sysfs_attr_init(&sensors->dev_attr.attr); |
|---|
| 950 | 940 | sensors->dev_attr.attr.name = rw->label; |
|---|
| 951 | | - sensors->dev_attr.attr.mode = S_IRUGO | S_IWUSR; |
|---|
| 941 | + sensors->dev_attr.attr.mode = 0644; |
|---|
| 952 | 942 | sensors->dev_attr.show = rw->show; |
|---|
| 953 | 943 | sensors->dev_attr.store = rw->set; |
|---|
| 954 | 944 | sensors->index = rw->index; |
|---|