hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/firmware/arm_scpi.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * System Control and Power Interface (SCPI) Message Protocol driver
34 *
....@@ -11,18 +12,6 @@
1112 * clocks configuration, thermal sensors and many others.
1213 *
1314 * Copyright (C) 2015 ARM Ltd.
14
- *
15
- * This program is free software; you can redistribute it and/or modify it
16
- * under the terms and conditions of the GNU General Public License,
17
- * version 2, as published by the Free Software Foundation.
18
- *
19
- * This program is distributed in the hope it will be useful, but WITHOUT
20
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
22
- * more details.
23
- *
24
- * You should have received a copy of the GNU General Public License along
25
- * with this program. If not, see <http://www.gnu.org/licenses/>.
2615 */
2716
2817 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -273,12 +262,12 @@
273262 struct scpi_shared_mem {
274263 __le32 command;
275264 __le32 status;
276
- u8 payload[0];
265
+ u8 payload[];
277266 } __packed;
278267
279268 struct legacy_scpi_shared_mem {
280269 __le32 status;
281
- u8 payload[0];
270
+ u8 payload[];
282271 } __packed;
283272
284273 struct scp_capabilities {
....@@ -826,7 +815,7 @@
826815 info->firmware_version = le32_to_cpu(caps.platform_version);
827816 }
828817 /* Ignore error if not implemented */
829
- if (scpi_info->is_legacy && ret == -EOPNOTSUPP)
818
+ if (info->is_legacy && ret == -EOPNOTSUPP)
830819 return 0;
831820
832821 return ret;
....@@ -916,13 +905,14 @@
916905 struct resource res;
917906 struct device *dev = &pdev->dev;
918907 struct device_node *np = dev->of_node;
908
+ struct scpi_drvinfo *scpi_drvinfo;
919909
920
- scpi_info = devm_kzalloc(dev, sizeof(*scpi_info), GFP_KERNEL);
921
- if (!scpi_info)
910
+ scpi_drvinfo = devm_kzalloc(dev, sizeof(*scpi_drvinfo), GFP_KERNEL);
911
+ if (!scpi_drvinfo)
922912 return -ENOMEM;
923913
924914 if (of_match_device(legacy_scpi_of_match, &pdev->dev))
925
- scpi_info->is_legacy = true;
915
+ scpi_drvinfo->is_legacy = true;
926916
927917 count = of_count_phandle_with_args(np, "mboxes", "#mbox-cells");
928918 if (count < 0) {
....@@ -930,19 +920,19 @@
930920 return -ENODEV;
931921 }
932922
933
- scpi_info->channels = devm_kcalloc(dev, count, sizeof(struct scpi_chan),
934
- GFP_KERNEL);
935
- if (!scpi_info->channels)
923
+ scpi_drvinfo->channels =
924
+ devm_kcalloc(dev, count, sizeof(struct scpi_chan), GFP_KERNEL);
925
+ if (!scpi_drvinfo->channels)
936926 return -ENOMEM;
937927
938
- ret = devm_add_action(dev, scpi_free_channels, scpi_info);
928
+ ret = devm_add_action(dev, scpi_free_channels, scpi_drvinfo);
939929 if (ret)
940930 return ret;
941931
942
- for (; scpi_info->num_chans < count; scpi_info->num_chans++) {
932
+ for (; scpi_drvinfo->num_chans < count; scpi_drvinfo->num_chans++) {
943933 resource_size_t size;
944
- int idx = scpi_info->num_chans;
945
- struct scpi_chan *pchan = scpi_info->channels + idx;
934
+ int idx = scpi_drvinfo->num_chans;
935
+ struct scpi_chan *pchan = scpi_drvinfo->channels + idx;
946936 struct mbox_client *cl = &pchan->cl;
947937 struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
948938
....@@ -986,49 +976,53 @@
986976 return ret;
987977 }
988978
989
- scpi_info->commands = scpi_std_commands;
979
+ scpi_drvinfo->commands = scpi_std_commands;
990980
991
- platform_set_drvdata(pdev, scpi_info);
981
+ platform_set_drvdata(pdev, scpi_drvinfo);
992982
993
- if (scpi_info->is_legacy) {
983
+ if (scpi_drvinfo->is_legacy) {
994984 /* Replace with legacy variants */
995985 scpi_ops.clk_set_val = legacy_scpi_clk_set_val;
996
- scpi_info->commands = scpi_legacy_commands;
986
+ scpi_drvinfo->commands = scpi_legacy_commands;
997987
998988 /* Fill priority bitmap */
999989 for (idx = 0; idx < ARRAY_SIZE(legacy_hpriority_cmds); idx++)
1000990 set_bit(legacy_hpriority_cmds[idx],
1001
- scpi_info->cmd_priority);
991
+ scpi_drvinfo->cmd_priority);
1002992 }
1003993
1004
- ret = scpi_init_versions(scpi_info);
994
+ scpi_info = scpi_drvinfo;
995
+
996
+ ret = scpi_init_versions(scpi_drvinfo);
1005997 if (ret) {
1006998 dev_err(dev, "incorrect or no SCP firmware found\n");
999
+ scpi_info = NULL;
10071000 return ret;
10081001 }
10091002
1010
- if (scpi_info->is_legacy && !scpi_info->protocol_version &&
1011
- !scpi_info->firmware_version)
1003
+ if (scpi_drvinfo->is_legacy && !scpi_drvinfo->protocol_version &&
1004
+ !scpi_drvinfo->firmware_version)
10121005 dev_info(dev, "SCP Protocol legacy pre-1.0 firmware\n");
10131006 else
10141007 dev_info(dev, "SCP Protocol %lu.%lu Firmware %lu.%lu.%lu version\n",
10151008 FIELD_GET(PROTO_REV_MAJOR_MASK,
1016
- scpi_info->protocol_version),
1009
+ scpi_drvinfo->protocol_version),
10171010 FIELD_GET(PROTO_REV_MINOR_MASK,
1018
- scpi_info->protocol_version),
1011
+ scpi_drvinfo->protocol_version),
10191012 FIELD_GET(FW_REV_MAJOR_MASK,
1020
- scpi_info->firmware_version),
1013
+ scpi_drvinfo->firmware_version),
10211014 FIELD_GET(FW_REV_MINOR_MASK,
1022
- scpi_info->firmware_version),
1015
+ scpi_drvinfo->firmware_version),
10231016 FIELD_GET(FW_REV_PATCH_MASK,
1024
- scpi_info->firmware_version));
1025
- scpi_info->scpi_ops = &scpi_ops;
1017
+ scpi_drvinfo->firmware_version));
10261018
1027
- ret = devm_device_add_groups(dev, versions_groups);
1019
+ scpi_drvinfo->scpi_ops = &scpi_ops;
1020
+
1021
+ ret = devm_of_platform_populate(dev);
10281022 if (ret)
1029
- dev_err(dev, "unable to create sysfs version group\n");
1023
+ scpi_info = NULL;
10301024
1031
- return devm_of_platform_populate(dev);
1025
+ return ret;
10321026 }
10331027
10341028 static const struct of_device_id scpi_of_match[] = {
....@@ -1043,6 +1037,7 @@
10431037 .driver = {
10441038 .name = "scpi_protocol",
10451039 .of_match_table = scpi_of_match,
1040
+ .dev_groups = versions_groups,
10461041 },
10471042 .probe = scpi_probe,
10481043 .remove = scpi_remove,