diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2017-09-29 17:43:54 -0400 |
---|---|---|
committer | Sudeep Holla <sudeep.holla@arm.com> | 2017-10-04 06:09:05 -0400 |
commit | 00126945902d2335c3b1f1c12db4ae2afeb4da0f (patch) | |
tree | 87178e20e2d0c290b343bc8d767bcd8c392e0876 | |
parent | 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e (diff) |
firmware: arm_scpi: remove usage of drvdata and don't reset scpi_info to null
There's no benefit using drvdata as variable scpi_info is global.
Setting scpi_info to NULL in scpi_remove isn't needed too. If arm_scpi
is built-in, then this code is never used. And if arm_scpi is built as
a module and some other module calls get_scpi_ops() then due to this
dependency scpi_remove is called only after the other module has been
removed.
Last but not least, users usually store the result of get_scpi_ops(),
therefore setting scpi_info to NULL wouldn't really help.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
[sudeep.holla: reworded the commit log a bit]
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
-rw-r--r-- | drivers/firmware/arm_scpi.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c index 7da9f1b83ebe..a7f686e9dc1c 100644 --- a/drivers/firmware/arm_scpi.c +++ b/drivers/firmware/arm_scpi.c | |||
@@ -862,8 +862,6 @@ static int scpi_init_versions(struct scpi_drvinfo *info) | |||
862 | static ssize_t protocol_version_show(struct device *dev, | 862 | static ssize_t protocol_version_show(struct device *dev, |
863 | struct device_attribute *attr, char *buf) | 863 | struct device_attribute *attr, char *buf) |
864 | { | 864 | { |
865 | struct scpi_drvinfo *scpi_info = dev_get_drvdata(dev); | ||
866 | |||
867 | return sprintf(buf, "%d.%d\n", | 865 | return sprintf(buf, "%d.%d\n", |
868 | PROTOCOL_REV_MAJOR(scpi_info->protocol_version), | 866 | PROTOCOL_REV_MAJOR(scpi_info->protocol_version), |
869 | PROTOCOL_REV_MINOR(scpi_info->protocol_version)); | 867 | PROTOCOL_REV_MINOR(scpi_info->protocol_version)); |
@@ -873,8 +871,6 @@ static DEVICE_ATTR_RO(protocol_version); | |||
873 | static ssize_t firmware_version_show(struct device *dev, | 871 | static ssize_t firmware_version_show(struct device *dev, |
874 | struct device_attribute *attr, char *buf) | 872 | struct device_attribute *attr, char *buf) |
875 | { | 873 | { |
876 | struct scpi_drvinfo *scpi_info = dev_get_drvdata(dev); | ||
877 | |||
878 | return sprintf(buf, "%d.%d.%d\n", | 874 | return sprintf(buf, "%d.%d.%d\n", |
879 | FW_REV_MAJOR(scpi_info->firmware_version), | 875 | FW_REV_MAJOR(scpi_info->firmware_version), |
880 | FW_REV_MINOR(scpi_info->firmware_version), | 876 | FW_REV_MINOR(scpi_info->firmware_version), |
@@ -905,21 +901,17 @@ static int scpi_remove(struct platform_device *pdev) | |||
905 | { | 901 | { |
906 | int i; | 902 | int i; |
907 | struct device *dev = &pdev->dev; | 903 | struct device *dev = &pdev->dev; |
908 | struct scpi_drvinfo *info = platform_get_drvdata(pdev); | ||
909 | |||
910 | scpi_info = NULL; /* stop exporting SCPI ops through get_scpi_ops */ | ||
911 | 904 | ||
912 | of_platform_depopulate(dev); | 905 | of_platform_depopulate(dev); |
913 | sysfs_remove_groups(&dev->kobj, versions_groups); | 906 | sysfs_remove_groups(&dev->kobj, versions_groups); |
914 | scpi_free_channels(dev, info->channels, info->num_chans); | 907 | scpi_free_channels(dev, scpi_info->channels, scpi_info->num_chans); |
915 | platform_set_drvdata(pdev, NULL); | ||
916 | 908 | ||
917 | for (i = 0; i < MAX_DVFS_DOMAINS && info->dvfs[i]; i++) { | 909 | for (i = 0; i < MAX_DVFS_DOMAINS && scpi_info->dvfs[i]; i++) { |
918 | kfree(info->dvfs[i]->opps); | 910 | kfree(scpi_info->dvfs[i]->opps); |
919 | kfree(info->dvfs[i]); | 911 | kfree(scpi_info->dvfs[i]); |
920 | } | 912 | } |
921 | devm_kfree(dev, info->channels); | 913 | devm_kfree(dev, scpi_info->channels); |
922 | devm_kfree(dev, info); | 914 | devm_kfree(dev, scpi_info); |
923 | 915 | ||
924 | return 0; | 916 | return 0; |
925 | } | 917 | } |
@@ -1027,8 +1019,6 @@ err: | |||
1027 | scpi_info->num_chans = count; | 1019 | scpi_info->num_chans = count; |
1028 | scpi_info->commands = scpi_std_commands; | 1020 | scpi_info->commands = scpi_std_commands; |
1029 | 1021 | ||
1030 | platform_set_drvdata(pdev, scpi_info); | ||
1031 | |||
1032 | if (scpi_info->is_legacy) { | 1022 | if (scpi_info->is_legacy) { |
1033 | /* Replace with legacy variants */ | 1023 | /* Replace with legacy variants */ |
1034 | scpi_ops.clk_set_val = legacy_scpi_clk_set_val; | 1024 | scpi_ops.clk_set_val = legacy_scpi_clk_set_val; |