aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-10-20 16:29:09 -0400
committerArnd Bergmann <arnd@arndb.de>2017-10-20 16:29:09 -0400
commit6710acf2596a29f7351e8165d981645f403e0025 (patch)
treebf7e56e91ef6a2c3ee590e721751f2381a8974ab
parent4b367f2e8854da34d14bd154ff4432fb49f69b36 (diff)
parent430594c1c7f5051f0d99ed9d08d086d20587cdd1 (diff)
Merge tag 'scpi-updates-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into next/drivers
Pull "ARM SCPI updates/cleanups for v4.15" from Sudeep Holla: 1. Fixes to get rid of sparse warnings 2. Use of FIELD_GET and GENMASK for better subfields handling 3. Make mbox_free_channels device-managed helping in removing unnecessary code 4. Various other cleanups to simplify and improve code readability * tag 'scpi-updates-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux: firmware: arm_scpi: silence sparse warnings firmware: arm_scpi: remove all single element structures firmware: arm_scpi: drop unnecessary type cast to scpi_shared_mem firmware: arm_scpi: improve struct sensor_value firmware: arm_scpi: improve handling of protocol and firmware version subfields firmware: arm_scpi: improve struct dvfs_info to make code better readable firmware: arm_scpi: remove scpi_remove firmware: arm_scpi: make freeing mbox channels device-managed firmware: arm_scpi: pre-populate dvfs info in scpi_probe firmware: arm_scpi: remove two unneeded devm_kfree's in scpi_remove firmware: arm_scpi: remove usage of drvdata and don't reset scpi_info to null
-rw-r--r--drivers/firmware/arm_scpi.c216
1 files changed, 87 insertions, 129 deletions
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 7da9f1b83ebe..dfb373c8ba2a 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -28,6 +28,7 @@
28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29 29
30#include <linux/bitmap.h> 30#include <linux/bitmap.h>
31#include <linux/bitfield.h>
31#include <linux/device.h> 32#include <linux/device.h>
32#include <linux/err.h> 33#include <linux/err.h>
33#include <linux/export.h> 34#include <linux/export.h>
@@ -72,21 +73,13 @@
72 73
73#define MAX_DVFS_DOMAINS 8 74#define MAX_DVFS_DOMAINS 8
74#define MAX_DVFS_OPPS 16 75#define MAX_DVFS_OPPS 16
75#define DVFS_LATENCY(hdr) (le32_to_cpu(hdr) >> 16) 76
76#define DVFS_OPP_COUNT(hdr) ((le32_to_cpu(hdr) >> 8) & 0xff) 77#define PROTO_REV_MAJOR_MASK GENMASK(31, 16)
77 78#define PROTO_REV_MINOR_MASK GENMASK(15, 0)
78#define PROTOCOL_REV_MINOR_BITS 16 79
79#define PROTOCOL_REV_MINOR_MASK ((1U << PROTOCOL_REV_MINOR_BITS) - 1) 80#define FW_REV_MAJOR_MASK GENMASK(31, 24)
80#define PROTOCOL_REV_MAJOR(x) ((x) >> PROTOCOL_REV_MINOR_BITS) 81#define FW_REV_MINOR_MASK GENMASK(23, 16)
81#define PROTOCOL_REV_MINOR(x) ((x) & PROTOCOL_REV_MINOR_MASK) 82#define FW_REV_PATCH_MASK GENMASK(15, 0)
82
83#define FW_REV_MAJOR_BITS 24
84#define FW_REV_MINOR_BITS 16
85#define FW_REV_PATCH_MASK ((1U << FW_REV_MINOR_BITS) - 1)
86#define FW_REV_MINOR_MASK ((1U << FW_REV_MAJOR_BITS) - 1)
87#define FW_REV_MAJOR(x) ((x) >> FW_REV_MAJOR_BITS)
88#define FW_REV_MINOR(x) (((x) & FW_REV_MINOR_MASK) >> FW_REV_MINOR_BITS)
89#define FW_REV_PATCH(x) ((x) & FW_REV_PATCH_MASK)
90 83
91#define MAX_RX_TIMEOUT (msecs_to_jiffies(30)) 84#define MAX_RX_TIMEOUT (msecs_to_jiffies(30))
92 85
@@ -311,10 +304,6 @@ struct clk_get_info {
311 u8 name[20]; 304 u8 name[20];
312} __packed; 305} __packed;
313 306
314struct clk_get_value {
315 __le32 rate;
316} __packed;
317
318struct clk_set_value { 307struct clk_set_value {
319 __le16 id; 308 __le16 id;
320 __le16 reserved; 309 __le16 reserved;
@@ -328,7 +317,9 @@ struct legacy_clk_set_value {
328} __packed; 317} __packed;
329 318
330struct dvfs_info { 319struct dvfs_info {
331 __le32 header; 320 u8 domain;
321 u8 opp_count;
322 __le16 latency;
332 struct { 323 struct {
333 __le32 freq; 324 __le32 freq;
334 __le32 m_volt; 325 __le32 m_volt;
@@ -351,11 +342,6 @@ struct _scpi_sensor_info {
351 char name[20]; 342 char name[20];
352}; 343};
353 344
354struct sensor_value {
355 __le32 lo_val;
356 __le32 hi_val;
357} __packed;
358
359struct dev_pstate_set { 345struct dev_pstate_set {
360 __le16 dev_id; 346 __le16 dev_id;
361 u8 pstate; 347 u8 pstate;
@@ -419,19 +405,20 @@ static void scpi_process_cmd(struct scpi_chan *ch, u32 cmd)
419 unsigned int len; 405 unsigned int len;
420 406
421 if (scpi_info->is_legacy) { 407 if (scpi_info->is_legacy) {
422 struct legacy_scpi_shared_mem *mem = ch->rx_payload; 408 struct legacy_scpi_shared_mem __iomem *mem =
409 ch->rx_payload;
423 410
424 /* RX Length is not replied by the legacy Firmware */ 411 /* RX Length is not replied by the legacy Firmware */
425 len = match->rx_len; 412 len = match->rx_len;
426 413
427 match->status = le32_to_cpu(mem->status); 414 match->status = ioread32(&mem->status);
428 memcpy_fromio(match->rx_buf, mem->payload, len); 415 memcpy_fromio(match->rx_buf, mem->payload, len);
429 } else { 416 } else {
430 struct scpi_shared_mem *mem = ch->rx_payload; 417 struct scpi_shared_mem __iomem *mem = ch->rx_payload;
431 418
432 len = min(match->rx_len, CMD_SIZE(cmd)); 419 len = min(match->rx_len, CMD_SIZE(cmd));
433 420
434 match->status = le32_to_cpu(mem->status); 421 match->status = ioread32(&mem->status);
435 memcpy_fromio(match->rx_buf, mem->payload, len); 422 memcpy_fromio(match->rx_buf, mem->payload, len);
436 } 423 }
437 424
@@ -445,11 +432,11 @@ static void scpi_process_cmd(struct scpi_chan *ch, u32 cmd)
445static void scpi_handle_remote_msg(struct mbox_client *c, void *msg) 432static void scpi_handle_remote_msg(struct mbox_client *c, void *msg)
446{ 433{
447 struct scpi_chan *ch = container_of(c, struct scpi_chan, cl); 434 struct scpi_chan *ch = container_of(c, struct scpi_chan, cl);
448 struct scpi_shared_mem *mem = ch->rx_payload; 435 struct scpi_shared_mem __iomem *mem = ch->rx_payload;
449 u32 cmd = 0; 436 u32 cmd = 0;
450 437
451 if (!scpi_info->is_legacy) 438 if (!scpi_info->is_legacy)
452 cmd = le32_to_cpu(mem->command); 439 cmd = ioread32(&mem->command);
453 440
454 scpi_process_cmd(ch, cmd); 441 scpi_process_cmd(ch, cmd);
455} 442}
@@ -459,7 +446,7 @@ static void scpi_tx_prepare(struct mbox_client *c, void *msg)
459 unsigned long flags; 446 unsigned long flags;
460 struct scpi_xfer *t = msg; 447 struct scpi_xfer *t = msg;
461 struct scpi_chan *ch = container_of(c, struct scpi_chan, cl); 448 struct scpi_chan *ch = container_of(c, struct scpi_chan, cl);
462 struct scpi_shared_mem *mem = (struct scpi_shared_mem *)ch->tx_payload; 449 struct scpi_shared_mem __iomem *mem = ch->tx_payload;
463 450
464 if (t->tx_buf) { 451 if (t->tx_buf) {
465 if (scpi_info->is_legacy) 452 if (scpi_info->is_legacy)
@@ -478,7 +465,7 @@ static void scpi_tx_prepare(struct mbox_client *c, void *msg)
478 } 465 }
479 466
480 if (!scpi_info->is_legacy) 467 if (!scpi_info->is_legacy)
481 mem->command = cpu_to_le32(t->cmd); 468 iowrite32(t->cmd, &mem->command);
482} 469}
483 470
484static struct scpi_xfer *get_scpi_xfer(struct scpi_chan *ch) 471static struct scpi_xfer *get_scpi_xfer(struct scpi_chan *ch)
@@ -583,13 +570,13 @@ scpi_clk_get_range(u16 clk_id, unsigned long *min, unsigned long *max)
583static unsigned long scpi_clk_get_val(u16 clk_id) 570static unsigned long scpi_clk_get_val(u16 clk_id)
584{ 571{
585 int ret; 572 int ret;
586 struct clk_get_value clk; 573 __le32 rate;
587 __le16 le_clk_id = cpu_to_le16(clk_id); 574 __le16 le_clk_id = cpu_to_le16(clk_id);
588 575
589 ret = scpi_send_message(CMD_GET_CLOCK_VALUE, &le_clk_id, 576 ret = scpi_send_message(CMD_GET_CLOCK_VALUE, &le_clk_id,
590 sizeof(le_clk_id), &clk, sizeof(clk)); 577 sizeof(le_clk_id), &rate, sizeof(rate));
591 578
592 return ret ? ret : le32_to_cpu(clk.rate); 579 return ret ? ret : le32_to_cpu(rate);
593} 580}
594 581
595static int scpi_clk_set_val(u16 clk_id, unsigned long rate) 582static int scpi_clk_set_val(u16 clk_id, unsigned long rate)
@@ -645,34 +632,34 @@ static int opp_cmp_func(const void *opp1, const void *opp2)
645 632
646static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain) 633static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain)
647{ 634{
635 if (domain >= MAX_DVFS_DOMAINS)
636 return ERR_PTR(-EINVAL);
637
638 return scpi_info->dvfs[domain] ?: ERR_PTR(-EINVAL);
639}
640
641static int scpi_dvfs_populate_info(struct device *dev, u8 domain)
642{
648 struct scpi_dvfs_info *info; 643 struct scpi_dvfs_info *info;
649 struct scpi_opp *opp; 644 struct scpi_opp *opp;
650 struct dvfs_info buf; 645 struct dvfs_info buf;
651 int ret, i; 646 int ret, i;
652 647
653 if (domain >= MAX_DVFS_DOMAINS)
654 return ERR_PTR(-EINVAL);
655
656 if (scpi_info->dvfs[domain]) /* data already populated */
657 return scpi_info->dvfs[domain];
658
659 ret = scpi_send_message(CMD_GET_DVFS_INFO, &domain, sizeof(domain), 648 ret = scpi_send_message(CMD_GET_DVFS_INFO, &domain, sizeof(domain),
660 &buf, sizeof(buf)); 649 &buf, sizeof(buf));
661 if (ret) 650 if (ret)
662 return ERR_PTR(ret); 651 return ret;
663 652
664 info = kmalloc(sizeof(*info), GFP_KERNEL); 653 info = devm_kmalloc(dev, sizeof(*info), GFP_KERNEL);
665 if (!info) 654 if (!info)
666 return ERR_PTR(-ENOMEM); 655 return -ENOMEM;
667 656
668 info->count = DVFS_OPP_COUNT(buf.header); 657 info->count = buf.opp_count;
669 info->latency = DVFS_LATENCY(buf.header) * 1000; /* uS to nS */ 658 info->latency = le16_to_cpu(buf.latency) * 1000; /* uS to nS */
670 659
671 info->opps = kcalloc(info->count, sizeof(*opp), GFP_KERNEL); 660 info->opps = devm_kcalloc(dev, info->count, sizeof(*opp), GFP_KERNEL);
672 if (!info->opps) { 661 if (!info->opps)
673 kfree(info); 662 return -ENOMEM;
674 return ERR_PTR(-ENOMEM);
675 }
676 663
677 for (i = 0, opp = info->opps; i < info->count; i++, opp++) { 664 for (i = 0, opp = info->opps; i < info->count; i++, opp++) {
678 opp->freq = le32_to_cpu(buf.opps[i].freq); 665 opp->freq = le32_to_cpu(buf.opps[i].freq);
@@ -682,7 +669,15 @@ static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain)
682 sort(info->opps, info->count, sizeof(*opp), opp_cmp_func, NULL); 669 sort(info->opps, info->count, sizeof(*opp), opp_cmp_func, NULL);
683 670
684 scpi_info->dvfs[domain] = info; 671 scpi_info->dvfs[domain] = info;
685 return info; 672 return 0;
673}
674
675static void scpi_dvfs_populate(struct device *dev)
676{
677 int domain;
678
679 for (domain = 0; domain < MAX_DVFS_DOMAINS; domain++)
680 scpi_dvfs_populate_info(dev, domain);
686} 681}
687 682
688static int scpi_dev_domain_id(struct device *dev) 683static int scpi_dev_domain_id(struct device *dev)
@@ -713,9 +708,6 @@ static int scpi_dvfs_get_transition_latency(struct device *dev)
713 if (IS_ERR(info)) 708 if (IS_ERR(info))
714 return PTR_ERR(info); 709 return PTR_ERR(info);
715 710
716 if (!info->latency)
717 return 0;
718
719 return info->latency; 711 return info->latency;
720} 712}
721 713
@@ -776,20 +768,19 @@ static int scpi_sensor_get_info(u16 sensor_id, struct scpi_sensor_info *info)
776static int scpi_sensor_get_value(u16 sensor, u64 *val) 768static int scpi_sensor_get_value(u16 sensor, u64 *val)
777{ 769{
778 __le16 id = cpu_to_le16(sensor); 770 __le16 id = cpu_to_le16(sensor);
779 struct sensor_value buf; 771 __le64 value;
780 int ret; 772 int ret;
781 773
782 ret = scpi_send_message(CMD_SENSOR_VALUE, &id, sizeof(id), 774 ret = scpi_send_message(CMD_SENSOR_VALUE, &id, sizeof(id),
783 &buf, sizeof(buf)); 775 &value, sizeof(value));
784 if (ret) 776 if (ret)
785 return ret; 777 return ret;
786 778
787 if (scpi_info->is_legacy) 779 if (scpi_info->is_legacy)
788 /* only 32-bits supported, hi_val can be junk */ 780 /* only 32-bits supported, upper 32 bits can be junk */
789 *val = le32_to_cpu(buf.lo_val); 781 *val = le32_to_cpup((__le32 *)&value);
790 else 782 else
791 *val = (u64)le32_to_cpu(buf.hi_val) << 32 | 783 *val = le64_to_cpu(value);
792 le32_to_cpu(buf.lo_val);
793 784
794 return 0; 785 return 0;
795} 786}
@@ -862,23 +853,19 @@ static int scpi_init_versions(struct scpi_drvinfo *info)
862static ssize_t protocol_version_show(struct device *dev, 853static ssize_t protocol_version_show(struct device *dev,
863 struct device_attribute *attr, char *buf) 854 struct device_attribute *attr, char *buf)
864{ 855{
865 struct scpi_drvinfo *scpi_info = dev_get_drvdata(dev); 856 return sprintf(buf, "%lu.%lu\n",
866 857 FIELD_GET(PROTO_REV_MAJOR_MASK, scpi_info->protocol_version),
867 return sprintf(buf, "%d.%d\n", 858 FIELD_GET(PROTO_REV_MINOR_MASK, scpi_info->protocol_version));
868 PROTOCOL_REV_MAJOR(scpi_info->protocol_version),
869 PROTOCOL_REV_MINOR(scpi_info->protocol_version));
870} 859}
871static DEVICE_ATTR_RO(protocol_version); 860static DEVICE_ATTR_RO(protocol_version);
872 861
873static ssize_t firmware_version_show(struct device *dev, 862static ssize_t firmware_version_show(struct device *dev,
874 struct device_attribute *attr, char *buf) 863 struct device_attribute *attr, char *buf)
875{ 864{
876 struct scpi_drvinfo *scpi_info = dev_get_drvdata(dev); 865 return sprintf(buf, "%lu.%lu.%lu\n",
877 866 FIELD_GET(FW_REV_MAJOR_MASK, scpi_info->firmware_version),
878 return sprintf(buf, "%d.%d.%d\n", 867 FIELD_GET(FW_REV_MINOR_MASK, scpi_info->firmware_version),
879 FW_REV_MAJOR(scpi_info->firmware_version), 868 FIELD_GET(FW_REV_PATCH_MASK, scpi_info->firmware_version));
880 FW_REV_MINOR(scpi_info->firmware_version),
881 FW_REV_PATCH(scpi_info->firmware_version));
882} 869}
883static DEVICE_ATTR_RO(firmware_version); 870static DEVICE_ATTR_RO(firmware_version);
884 871
@@ -889,39 +876,13 @@ static struct attribute *versions_attrs[] = {
889}; 876};
890ATTRIBUTE_GROUPS(versions); 877ATTRIBUTE_GROUPS(versions);
891 878
892static void 879static void scpi_free_channels(void *data)
893scpi_free_channels(struct device *dev, struct scpi_chan *pchan, int count)
894{ 880{
881 struct scpi_drvinfo *info = data;
895 int i; 882 int i;
896 883
897 for (i = 0; i < count && pchan->chan; i++, pchan++) { 884 for (i = 0; i < info->num_chans; i++)
898 mbox_free_channel(pchan->chan); 885 mbox_free_channel(info->channels[i].chan);
899 devm_kfree(dev, pchan->xfers);
900 devm_iounmap(dev, pchan->rx_payload);
901 }
902}
903
904static int scpi_remove(struct platform_device *pdev)
905{
906 int i;
907 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
912 of_platform_depopulate(dev);
913 sysfs_remove_groups(&dev->kobj, versions_groups);
914 scpi_free_channels(dev, info->channels, info->num_chans);
915 platform_set_drvdata(pdev, NULL);
916
917 for (i = 0; i < MAX_DVFS_DOMAINS && info->dvfs[i]; i++) {
918 kfree(info->dvfs[i]->opps);
919 kfree(info->dvfs[i]);
920 }
921 devm_kfree(dev, info->channels);
922 devm_kfree(dev, info);
923
924 return 0;
925} 886}
926 887
927#define MAX_SCPI_XFERS 10 888#define MAX_SCPI_XFERS 10
@@ -952,7 +913,6 @@ static int scpi_probe(struct platform_device *pdev)
952{ 913{
953 int count, idx, ret; 914 int count, idx, ret;
954 struct resource res; 915 struct resource res;
955 struct scpi_chan *scpi_chan;
956 struct device *dev = &pdev->dev; 916 struct device *dev = &pdev->dev;
957 struct device_node *np = dev->of_node; 917 struct device_node *np = dev->of_node;
958 918
@@ -969,13 +929,19 @@ static int scpi_probe(struct platform_device *pdev)
969 return -ENODEV; 929 return -ENODEV;
970 } 930 }
971 931
972 scpi_chan = devm_kcalloc(dev, count, sizeof(*scpi_chan), GFP_KERNEL); 932 scpi_info->channels = devm_kcalloc(dev, count, sizeof(struct scpi_chan),
973 if (!scpi_chan) 933 GFP_KERNEL);
934 if (!scpi_info->channels)
974 return -ENOMEM; 935 return -ENOMEM;
975 936
976 for (idx = 0; idx < count; idx++) { 937 ret = devm_add_action(dev, scpi_free_channels, scpi_info);
938 if (ret)
939 return ret;
940
941 for (; scpi_info->num_chans < count; scpi_info->num_chans++) {
977 resource_size_t size; 942 resource_size_t size;
978 struct scpi_chan *pchan = scpi_chan + idx; 943 int idx = scpi_info->num_chans;
944 struct scpi_chan *pchan = scpi_info->channels + idx;
979 struct mbox_client *cl = &pchan->cl; 945 struct mbox_client *cl = &pchan->cl;
980 struct device_node *shmem = of_parse_phandle(np, "shmem", idx); 946 struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
981 947
@@ -983,15 +949,14 @@ static int scpi_probe(struct platform_device *pdev)
983 of_node_put(shmem); 949 of_node_put(shmem);
984 if (ret) { 950 if (ret) {
985 dev_err(dev, "failed to get SCPI payload mem resource\n"); 951 dev_err(dev, "failed to get SCPI payload mem resource\n");
986 goto err; 952 return ret;
987 } 953 }
988 954
989 size = resource_size(&res); 955 size = resource_size(&res);
990 pchan->rx_payload = devm_ioremap(dev, res.start, size); 956 pchan->rx_payload = devm_ioremap(dev, res.start, size);
991 if (!pchan->rx_payload) { 957 if (!pchan->rx_payload) {
992 dev_err(dev, "failed to ioremap SCPI payload\n"); 958 dev_err(dev, "failed to ioremap SCPI payload\n");
993 ret = -EADDRNOTAVAIL; 959 return -EADDRNOTAVAIL;
994 goto err;
995 } 960 }
996 pchan->tx_payload = pchan->rx_payload + (size >> 1); 961 pchan->tx_payload = pchan->rx_payload + (size >> 1);
997 962
@@ -1017,17 +982,11 @@ static int scpi_probe(struct platform_device *pdev)
1017 dev_err(dev, "failed to get channel%d err %d\n", 982 dev_err(dev, "failed to get channel%d err %d\n",
1018 idx, ret); 983 idx, ret);
1019 } 984 }
1020err:
1021 scpi_free_channels(dev, scpi_chan, idx);
1022 scpi_info = NULL;
1023 return ret; 985 return ret;
1024 } 986 }
1025 987
1026 scpi_info->channels = scpi_chan;
1027 scpi_info->num_chans = count;
1028 scpi_info->commands = scpi_std_commands; 988 scpi_info->commands = scpi_std_commands;
1029 989 scpi_info->scpi_ops = &scpi_ops;
1030 platform_set_drvdata(pdev, scpi_info);
1031 990
1032 if (scpi_info->is_legacy) { 991 if (scpi_info->is_legacy) {
1033 /* Replace with legacy variants */ 992 /* Replace with legacy variants */
@@ -1043,23 +1002,23 @@ err:
1043 ret = scpi_init_versions(scpi_info); 1002 ret = scpi_init_versions(scpi_info);
1044 if (ret) { 1003 if (ret) {
1045 dev_err(dev, "incorrect or no SCP firmware found\n"); 1004 dev_err(dev, "incorrect or no SCP firmware found\n");
1046 scpi_remove(pdev);
1047 return ret; 1005 return ret;
1048 } 1006 }
1049 1007
1050 _dev_info(dev, "SCP Protocol %d.%d Firmware %d.%d.%d version\n", 1008 scpi_dvfs_populate(dev);
1051 PROTOCOL_REV_MAJOR(scpi_info->protocol_version), 1009
1052 PROTOCOL_REV_MINOR(scpi_info->protocol_version), 1010 _dev_info(dev, "SCP Protocol %lu.%lu Firmware %lu.%lu.%lu version\n",
1053 FW_REV_MAJOR(scpi_info->firmware_version), 1011 FIELD_GET(PROTO_REV_MAJOR_MASK, scpi_info->protocol_version),
1054 FW_REV_MINOR(scpi_info->firmware_version), 1012 FIELD_GET(PROTO_REV_MINOR_MASK, scpi_info->protocol_version),
1055 FW_REV_PATCH(scpi_info->firmware_version)); 1013 FIELD_GET(FW_REV_MAJOR_MASK, scpi_info->firmware_version),
1056 scpi_info->scpi_ops = &scpi_ops; 1014 FIELD_GET(FW_REV_MINOR_MASK, scpi_info->firmware_version),
1015 FIELD_GET(FW_REV_PATCH_MASK, scpi_info->firmware_version));
1057 1016
1058 ret = sysfs_create_groups(&dev->kobj, versions_groups); 1017 ret = devm_device_add_groups(dev, versions_groups);
1059 if (ret) 1018 if (ret)
1060 dev_err(dev, "unable to create sysfs version group\n"); 1019 dev_err(dev, "unable to create sysfs version group\n");
1061 1020
1062 return of_platform_populate(dev->of_node, NULL, NULL, dev); 1021 return devm_of_platform_populate(dev);
1063} 1022}
1064 1023
1065static const struct of_device_id scpi_of_match[] = { 1024static const struct of_device_id scpi_of_match[] = {
@@ -1076,7 +1035,6 @@ static struct platform_driver scpi_driver = {
1076 .of_match_table = scpi_of_match, 1035 .of_match_table = scpi_of_match,
1077 }, 1036 },
1078 .probe = scpi_probe, 1037 .probe = scpi_probe,
1079 .remove = scpi_remove,
1080}; 1038};
1081module_platform_driver(scpi_driver); 1039module_platform_driver(scpi_driver);
1082 1040