Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'scmi-updates-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into soc/drivers

Arm SCMI updates for v7.0

A set of cleanups, refactoring, and fixes to the Arm SCMI stack:

1. Rework protocol version negotiation by moving version discovery and
downgrade handling into the SCMI core and performing negotiation early,
before protocol initialization. Remove legacy per-protocol versioning
logic now made redundant by centralized SCMI handling.

2. Increase the internal MAX_OPPS limit in the SCMI performance protocol
to 64, allowing platforms with larger OPP tables to be fully supported.

3. Reduce duplicated boilerplate in pinctrl and related protocols by
consolidating validation and lookup logic in protocol get info helpers.

4. Refactor reset protocol domain handling by introducing a shared lookup
helper, ensuring consistent validation and error reporting.

5. Fix potential undefined behaviour by properly initializing pointers
annotated with the __free attribute.

* tag 'scmi-updates-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
firmware: arm_scmi: Remove legacy protocol versioning logic
firmware: arm_scmi: Rework protocol version negotiation logic
firmware: arm_scmi: Increase performance MAX_OPPS limit to 64
firmware: arm_scmi: Move boiler plate code into the get info functions
firmware: arm_scmi: Refactor reset domain handling
firmware: arm_scmi: Fix uninitialized pointers with __free attr

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+238 -282
+3 -8
drivers/firmware/arm_scmi/base.c
··· 375 375 { 376 376 int id, ret; 377 377 u8 *prot_imp; 378 - u32 version; 379 378 char name[SCMI_SHORT_NAME_MAX_SIZE]; 380 379 struct device *dev = ph->dev; 381 380 struct scmi_revision_info *rev = scmi_revision_area_get(ph); 382 381 383 - ret = ph->xops->version_get(ph, &version); 384 - if (ret) 385 - return ret; 386 - 387 - rev->major_ver = PROTOCOL_REV_MAJOR(version); 388 - rev->minor_ver = PROTOCOL_REV_MINOR(version); 389 - ph->set_priv(ph, rev, version); 382 + rev->major_ver = PROTOCOL_REV_MAJOR(ph->version); 383 + rev->minor_ver = PROTOCOL_REV_MINOR(ph->version); 384 + ph->set_priv(ph, rev); 390 385 391 386 ret = scmi_base_attributes_get(ph); 392 387 if (ret)
+8 -16
drivers/firmware/arm_scmi/clock.c
··· 157 157 }; 158 158 159 159 struct clock_info { 160 - u32 version; 161 160 int num_clocks; 162 161 int max_async_req; 163 162 bool notify_rate_changed_cmd; ··· 345 346 } 346 347 347 348 static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, 348 - u32 clk_id, struct clock_info *cinfo, 349 - u32 version) 349 + u32 clk_id, struct clock_info *cinfo) 350 350 { 351 351 int ret; 352 352 u32 attributes; ··· 368 370 attributes = le32_to_cpu(attr->attributes); 369 371 strscpy(clk->name, attr->name, SCMI_SHORT_NAME_MAX_SIZE); 370 372 /* clock_enable_latency field is present only since SCMI v3.1 */ 371 - if (PROTOCOL_REV_MAJOR(version) >= 0x2) 373 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2) 372 374 latency = le32_to_cpu(attr->clock_enable_latency); 373 375 clk->enable_latency = latency ? : U32_MAX; 374 376 } ··· 379 381 * If supported overwrite short name with the extended one; 380 382 * on error just carry on and use already provided short name. 381 383 */ 382 - if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x2) { 384 + if (!ret && PROTOCOL_REV_MAJOR(ph->version) >= 0x2) { 383 385 if (SUPPORTS_EXTENDED_NAMES(attributes)) 384 386 ph->hops->extended_name_get(ph, CLOCK_NAME_GET, clk_id, 385 387 NULL, clk->name, ··· 391 393 if (cinfo->notify_rate_change_requested_cmd && 392 394 SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(attributes)) 393 395 clk->rate_change_requested_notifications = true; 394 - if (PROTOCOL_REV_MAJOR(version) >= 0x3) { 396 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3) { 395 397 if (SUPPORTS_PARENT_CLOCK(attributes)) 396 398 scmi_clock_possible_parents(ph, clk_id, clk); 397 399 if (SUPPORTS_GET_PERMISSIONS(attributes)) ··· 1066 1068 1067 1069 static int scmi_clock_protocol_init(const struct scmi_protocol_handle *ph) 1068 1070 { 1069 - u32 version; 1070 1071 int clkid, ret; 1071 1072 struct clock_info *cinfo; 1072 1073 1073 - ret = ph->xops->version_get(ph, &version); 1074 - if (ret) 1075 - return ret; 1076 - 1077 1074 dev_dbg(ph->dev, "Clock Version %d.%d\n", 1078 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 1075 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 1079 1076 1080 1077 cinfo = devm_kzalloc(ph->dev, sizeof(*cinfo), GFP_KERNEL); 1081 1078 if (!cinfo) ··· 1088 1095 for (clkid = 0; clkid < cinfo->num_clocks; clkid++) { 1089 1096 struct scmi_clock_info *clk = cinfo->clk + clkid; 1090 1097 1091 - ret = scmi_clock_attributes_get(ph, clkid, cinfo, version); 1098 + ret = scmi_clock_attributes_get(ph, clkid, cinfo); 1092 1099 if (!ret) 1093 1100 scmi_clock_describe_rates_get(ph, clkid, clk); 1094 1101 } 1095 1102 1096 - if (PROTOCOL_REV_MAJOR(version) >= 0x3) { 1103 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3) { 1097 1104 cinfo->clock_config_set = scmi_clock_config_set_v2; 1098 1105 cinfo->clock_config_get = scmi_clock_config_get_v2; 1099 1106 } else { ··· 1101 1108 cinfo->clock_config_get = scmi_clock_config_get; 1102 1109 } 1103 1110 1104 - cinfo->version = version; 1105 - return ph->set_priv(ph, cinfo, version); 1111 + return ph->set_priv(ph, cinfo); 1106 1112 } 1107 1113 1108 1114 static const struct scmi_protocol scmi_clock = {
+78 -20
drivers/firmware/arm_scmi/driver.c
··· 1627 1627 * 1628 1628 * @ph: A reference to the protocol handle. 1629 1629 * @priv: The private data to set. 1630 - * @version: The detected protocol version for the core to register. 1631 1630 * 1632 1631 * Return: 0 on Success 1633 1632 */ 1634 1633 static int scmi_set_protocol_priv(const struct scmi_protocol_handle *ph, 1635 - void *priv, u32 version) 1634 + void *priv) 1636 1635 { 1637 1636 struct scmi_protocol_instance *pi = ph_to_pi(ph); 1638 1637 1639 1638 pi->priv = priv; 1640 - pi->version = version; 1641 1639 1642 1640 return 0; 1643 1641 } ··· 1655 1657 } 1656 1658 1657 1659 static const struct scmi_xfer_ops xfer_ops = { 1658 - .version_get = version_get, 1659 1660 .xfer_get_init = xfer_get_init, 1660 1661 .reset_rx_to_maxsz = reset_rx_to_maxsz, 1661 1662 .do_xfer = do_xfer, ··· 2110 2113 } 2111 2114 2112 2115 /** 2116 + * scmi_protocol_version_initialize - Initialize protocol version 2117 + * @dev: A device reference. 2118 + * @pi: A reference to the protocol instance being initialized 2119 + * 2120 + * At first retrieve the newest protocol version supported by the platform for 2121 + * this specific protoocol. 2122 + * 2123 + * Negotiation is attempted only when the platform advertised a protocol 2124 + * version newer than the most recent version known to this agent, since 2125 + * backward compatibility is NOT assured in general between versions. 2126 + * 2127 + * Failing to negotiate a fallback version or to query supported version at 2128 + * all will result in an attempt to use the newest version known to this agent 2129 + * even though compatibility is NOT assured. 2130 + * 2131 + * Versions are defined as: 2132 + * 2133 + * pi->version: the version supported by the platform as returned by the query. 2134 + * pi->proto->supported_version: the newest version supported by this agent 2135 + * for this protocol. 2136 + * pi->negotiated_version: The version successfully negotiated with the platform. 2137 + * ph->version: The final version effectively chosen for this session. 2138 + */ 2139 + static void scmi_protocol_version_initialize(struct device *dev, 2140 + struct scmi_protocol_instance *pi) 2141 + { 2142 + struct scmi_protocol_handle *ph = &pi->ph; 2143 + int ret; 2144 + 2145 + /* 2146 + * Query and store platform supported protocol version: this is usually 2147 + * the newest version the platfom can support. 2148 + */ 2149 + ret = version_get(ph, &pi->version); 2150 + if (ret) { 2151 + dev_warn(dev, 2152 + "Failed to query supported version for protocol 0x%X.\n", 2153 + pi->proto->id); 2154 + goto best_effort; 2155 + } 2156 + 2157 + /* Need to negotiate at all ? */ 2158 + if (pi->version <= pi->proto->supported_version) { 2159 + ph->version = pi->version; 2160 + return; 2161 + } 2162 + 2163 + /* Attempt negotiation */ 2164 + ret = scmi_protocol_version_negotiate(ph); 2165 + if (!ret) { 2166 + ph->version = pi->negotiated_version; 2167 + dev_info(dev, 2168 + "Protocol 0x%X successfully negotiated version 0x%X\n", 2169 + pi->proto->id, ph->version); 2170 + return; 2171 + } 2172 + 2173 + dev_warn(dev, 2174 + "Detected UNSUPPORTED higher version 0x%X for protocol 0x%X.\n", 2175 + pi->version, pi->proto->id); 2176 + 2177 + best_effort: 2178 + /* Fallback to use newest version known to this agent */ 2179 + ph->version = pi->proto->supported_version; 2180 + dev_warn(dev, 2181 + "Trying version 0x%X. Backward compatibility is NOT assured.\n", 2182 + ph->version); 2183 + } 2184 + 2185 + /** 2113 2186 * scmi_alloc_init_protocol_instance - Allocate and initialize a protocol 2114 2187 * instance descriptor. 2115 2188 * @info: The reference to the related SCMI instance. ··· 2224 2157 pi->ph.set_priv = scmi_set_protocol_priv; 2225 2158 pi->ph.get_priv = scmi_get_protocol_priv; 2226 2159 refcount_set(&pi->users, 1); 2160 + 2161 + /* 2162 + * Initialize effectively used protocol version performing any 2163 + * possibly needed negotiations. 2164 + */ 2165 + scmi_protocol_version_initialize(handle->dev, pi); 2166 + 2227 2167 /* proto->init is assured NON NULL by scmi_protocol_register */ 2228 2168 ret = pi->proto->instance_init(&pi->ph); 2229 2169 if (ret) ··· 2257 2183 2258 2184 devres_close_group(handle->dev, pi->gid); 2259 2185 dev_dbg(handle->dev, "Initialized protocol: 0x%X\n", pi->proto->id); 2260 - 2261 - if (pi->version > proto->supported_version) { 2262 - ret = scmi_protocol_version_negotiate(&pi->ph); 2263 - if (!ret) { 2264 - dev_info(handle->dev, 2265 - "Protocol 0x%X successfully negotiated version 0x%X\n", 2266 - proto->id, pi->negotiated_version); 2267 - } else { 2268 - dev_warn(handle->dev, 2269 - "Detected UNSUPPORTED higher version 0x%X for protocol 0x%X.\n", 2270 - pi->version, pi->proto->id); 2271 - dev_warn(handle->dev, 2272 - "Trying version 0x%X. Backward compatibility is NOT assured.\n", 2273 - pi->proto->supported_version); 2274 - } 2275 - } 2276 2186 2277 2187 return pi; 2278 2188
+20 -39
drivers/firmware/arm_scmi/perf.c
··· 27 27 /* Updated only after ALL the mandatory features for that version are merged */ 28 28 #define SCMI_PROTOCOL_SUPPORTED_VERSION 0x40000 29 29 30 - #define MAX_OPPS 32 30 + #define MAX_OPPS 64 31 31 32 32 enum scmi_performance_protocol_cmd { 33 33 PERF_DOMAIN_ATTRIBUTES = 0x3, ··· 178 178 }) 179 179 180 180 struct scmi_perf_info { 181 - u32 version; 182 181 u16 num_domains; 183 182 enum scmi_power_scale power_scale; 184 183 u64 stats_addr; ··· 214 215 215 216 if (POWER_SCALE_IN_MILLIWATT(flags)) 216 217 pi->power_scale = SCMI_POWER_MILLIWATTS; 217 - if (PROTOCOL_REV_MAJOR(pi->version) >= 0x3) 218 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3) 218 219 if (POWER_SCALE_IN_MICROWATT(flags)) 219 220 pi->power_scale = SCMI_POWER_MICROWATTS; 220 221 ··· 250 251 static int 251 252 scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, 252 253 struct perf_dom_info *dom_info, 253 - bool notify_lim_cmd, bool notify_lvl_cmd, 254 - u32 version) 254 + bool notify_lim_cmd, bool notify_lvl_cmd) 255 255 { 256 256 int ret; 257 257 u32 flags; ··· 278 280 dom_info->perf_level_notify = 279 281 SUPPORTS_PERF_LEVEL_NOTIFY(flags); 280 282 dom_info->perf_fastchannels = SUPPORTS_PERF_FASTCHANNELS(flags); 281 - if (PROTOCOL_REV_MAJOR(version) >= 0x4) 283 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x4) 282 284 dom_info->level_indexing_mode = 283 285 SUPPORTS_LEVEL_INDEXING(flags); 284 286 dom_info->rate_limit_us = le32_to_cpu(attr->rate_limit_us) & ··· 321 323 * If supported overwrite short name with the extended one; 322 324 * on error just carry on and use already provided short name. 323 325 */ 324 - if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 && 326 + if (!ret && PROTOCOL_REV_MAJOR(ph->version) >= 0x3 && 325 327 SUPPORTS_EXTENDED_NAMES(flags)) 326 328 ph->hops->extended_name_get(ph, PERF_DOMAIN_NAME_GET, 327 329 dom_info->id, NULL, dom_info->info.name, ··· 343 345 return t1->perf - t2->perf; 344 346 } 345 347 346 - struct scmi_perf_ipriv { 347 - u32 version; 348 - struct perf_dom_info *perf_dom; 349 - }; 350 - 351 348 static void iter_perf_levels_prepare_message(void *message, 352 349 unsigned int desc_index, 353 350 const void *priv) 354 351 { 355 352 struct scmi_msg_perf_describe_levels *msg = message; 356 - const struct scmi_perf_ipriv *p = priv; 353 + const struct perf_dom_info *perf_dom = priv; 357 354 358 - msg->domain = cpu_to_le32(p->perf_dom->id); 355 + msg->domain = cpu_to_le32(perf_dom->id); 359 356 /* Set the number of OPPs to be skipped/already read */ 360 357 msg->level_index = cpu_to_le32(desc_index); 361 358 } ··· 438 445 { 439 446 int ret; 440 447 struct scmi_opp *opp; 441 - struct scmi_perf_ipriv *p = priv; 448 + struct perf_dom_info *perf_dom = priv; 442 449 443 - opp = &p->perf_dom->opp[p->perf_dom->opp_count]; 444 - if (PROTOCOL_REV_MAJOR(p->version) <= 0x3) 445 - ret = process_response_opp(ph->dev, p->perf_dom, opp, 450 + opp = &perf_dom->opp[perf_dom->opp_count]; 451 + if (PROTOCOL_REV_MAJOR(ph->version) <= 0x3) 452 + ret = process_response_opp(ph->dev, perf_dom, opp, 446 453 st->loop_idx, response); 447 454 else 448 - ret = process_response_opp_v4(ph->dev, p->perf_dom, opp, 455 + ret = process_response_opp_v4(ph->dev, perf_dom, opp, 449 456 st->loop_idx, response); 450 457 451 458 /* Skip BAD duplicates received from firmware */ 452 459 if (ret) 453 460 return ret == -EBUSY ? 0 : ret; 454 461 455 - p->perf_dom->opp_count++; 462 + perf_dom->opp_count++; 456 463 457 464 dev_dbg(ph->dev, "Level %d Power %d Latency %dus Ifreq %d Index %d\n", 458 465 opp->perf, opp->power, opp->trans_latency_us, ··· 463 470 464 471 static int 465 472 scmi_perf_describe_levels_get(const struct scmi_protocol_handle *ph, 466 - struct perf_dom_info *perf_dom, u32 version) 473 + struct perf_dom_info *perf_dom) 467 474 { 468 475 int ret; 469 476 void *iter; ··· 472 479 .update_state = iter_perf_levels_update_state, 473 480 .process_response = iter_perf_levels_process_response, 474 481 }; 475 - struct scmi_perf_ipriv ppriv = { 476 - .version = version, 477 - .perf_dom = perf_dom, 478 - }; 479 482 480 483 iter = ph->hops->iter_response_init(ph, &ops, MAX_OPPS, 481 484 PERF_DESCRIBE_LEVELS, 482 485 sizeof(struct scmi_msg_perf_describe_levels), 483 - &ppriv); 486 + perf_dom); 484 487 if (IS_ERR(iter)) 485 488 return PTR_ERR(iter); 486 489 ··· 565 576 static int scmi_perf_limits_set(const struct scmi_protocol_handle *ph, 566 577 u32 domain, u32 max_perf, u32 min_perf) 567 578 { 568 - struct scmi_perf_info *pi = ph->get_priv(ph); 569 579 struct perf_dom_info *dom; 570 580 571 581 dom = scmi_perf_domain_lookup(ph, domain); ··· 574 586 if (!dom->set_limits) 575 587 return -EOPNOTSUPP; 576 588 577 - if (PROTOCOL_REV_MAJOR(pi->version) >= 0x3 && !max_perf && !min_perf) 589 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3 && !max_perf && !min_perf) 578 590 return -EINVAL; 579 591 580 592 if (dom->level_indexing_mode) { ··· 1269 1281 static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph) 1270 1282 { 1271 1283 int domain, ret; 1272 - u32 version; 1273 1284 struct scmi_perf_info *pinfo; 1274 1285 1275 - ret = ph->xops->version_get(ph, &version); 1276 - if (ret) 1277 - return ret; 1278 - 1279 1286 dev_dbg(ph->dev, "Performance Version %d.%d\n", 1280 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 1287 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 1281 1288 1282 1289 pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL); 1283 1290 if (!pinfo) 1284 1291 return -ENOMEM; 1285 - 1286 - pinfo->version = version; 1287 1292 1288 1293 ret = scmi_perf_attributes_get(ph, pinfo); 1289 1294 if (ret) ··· 1292 1311 1293 1312 dom->id = domain; 1294 1313 scmi_perf_domain_attributes_get(ph, dom, pinfo->notify_lim_cmd, 1295 - pinfo->notify_lvl_cmd, version); 1296 - scmi_perf_describe_levels_get(ph, dom, version); 1314 + pinfo->notify_lvl_cmd); 1315 + scmi_perf_describe_levels_get(ph, dom); 1297 1316 1298 1317 if (dom->perf_fastchannels) 1299 1318 scmi_perf_domain_init_fc(ph, dom); ··· 1303 1322 if (ret) 1304 1323 return ret; 1305 1324 1306 - return ph->set_priv(ph, pinfo, version); 1325 + return ph->set_priv(ph, pinfo); 1307 1326 } 1308 1327 1309 1328 static const struct scmi_protocol scmi_perf = {
+50 -70
drivers/firmware/arm_scmi/pinctrl.c
··· 117 117 }; 118 118 119 119 struct scmi_pinctrl_info { 120 - u32 version; 121 120 int nr_groups; 122 121 int nr_functions; 123 122 int nr_pins; ··· 595 596 } 596 597 597 598 static int scmi_pinctrl_get_group_info(const struct scmi_protocol_handle *ph, 598 - u32 selector, 599 - struct scmi_group_info *group) 599 + u32 selector) 600 600 { 601 + struct scmi_pinctrl_info *pi = ph->get_priv(ph); 602 + struct scmi_group_info *group; 601 603 int ret; 604 + 605 + if (selector >= pi->nr_groups) 606 + return -EINVAL; 607 + 608 + group = &pi->groups[selector]; 609 + if (group->present) 610 + return 0; 602 611 603 612 ret = scmi_pinctrl_attributes(ph, GROUP_TYPE, selector, group->name, 604 613 &group->nr_pins); ··· 639 632 u32 selector, const char **name) 640 633 { 641 634 struct scmi_pinctrl_info *pi = ph->get_priv(ph); 635 + int ret; 642 636 643 637 if (!name) 644 638 return -EINVAL; 645 639 646 - if (selector >= pi->nr_groups || pi->nr_groups == 0) 647 - return -EINVAL; 648 - 649 - if (!pi->groups[selector].present) { 650 - int ret; 651 - 652 - ret = scmi_pinctrl_get_group_info(ph, selector, 653 - &pi->groups[selector]); 654 - if (ret) 655 - return ret; 656 - } 640 + ret = scmi_pinctrl_get_group_info(ph, selector); 641 + if (ret) 642 + return ret; 657 643 658 644 *name = pi->groups[selector].name; 659 645 ··· 658 658 u32 *nr_pins) 659 659 { 660 660 struct scmi_pinctrl_info *pi = ph->get_priv(ph); 661 + int ret; 661 662 662 663 if (!pins || !nr_pins) 663 664 return -EINVAL; 664 665 665 - if (selector >= pi->nr_groups || pi->nr_groups == 0) 666 - return -EINVAL; 667 - 668 - if (!pi->groups[selector].present) { 669 - int ret; 670 - 671 - ret = scmi_pinctrl_get_group_info(ph, selector, 672 - &pi->groups[selector]); 673 - if (ret) 674 - return ret; 675 - } 666 + ret = scmi_pinctrl_get_group_info(ph, selector); 667 + if (ret) 668 + return ret; 676 669 677 670 *pins = pi->groups[selector].group_pins; 678 671 *nr_pins = pi->groups[selector].nr_pins; ··· 674 681 } 675 682 676 683 static int scmi_pinctrl_get_function_info(const struct scmi_protocol_handle *ph, 677 - u32 selector, 678 - struct scmi_function_info *func) 684 + u32 selector) 679 685 { 686 + struct scmi_pinctrl_info *pi = ph->get_priv(ph); 687 + struct scmi_function_info *func; 680 688 int ret; 689 + 690 + if (selector >= pi->nr_functions) 691 + return -EINVAL; 692 + 693 + func = &pi->functions[selector]; 694 + if (func->present) 695 + return 0; 681 696 682 697 ret = scmi_pinctrl_attributes(ph, FUNCTION_TYPE, selector, func->name, 683 698 &func->nr_groups); ··· 717 716 u32 selector, const char **name) 718 717 { 719 718 struct scmi_pinctrl_info *pi = ph->get_priv(ph); 719 + int ret; 720 720 721 721 if (!name) 722 722 return -EINVAL; 723 723 724 - if (selector >= pi->nr_functions || pi->nr_functions == 0) 725 - return -EINVAL; 726 - 727 - if (!pi->functions[selector].present) { 728 - int ret; 729 - 730 - ret = scmi_pinctrl_get_function_info(ph, selector, 731 - &pi->functions[selector]); 732 - if (ret) 733 - return ret; 734 - } 724 + ret = scmi_pinctrl_get_function_info(ph, selector); 725 + if (ret) 726 + return ret; 735 727 736 728 *name = pi->functions[selector].name; 737 729 return 0; ··· 736 742 const u32 **groups) 737 743 { 738 744 struct scmi_pinctrl_info *pi = ph->get_priv(ph); 745 + int ret; 739 746 740 747 if (!groups || !nr_groups) 741 748 return -EINVAL; 742 749 743 - if (selector >= pi->nr_functions || pi->nr_functions == 0) 744 - return -EINVAL; 745 - 746 - if (!pi->functions[selector].present) { 747 - int ret; 748 - 749 - ret = scmi_pinctrl_get_function_info(ph, selector, 750 - &pi->functions[selector]); 751 - if (ret) 752 - return ret; 753 - } 750 + ret = scmi_pinctrl_get_function_info(ph, selector); 751 + if (ret) 752 + return ret; 754 753 755 754 *groups = pi->functions[selector].groups; 756 755 *nr_groups = pi->functions[selector].nr_groups; ··· 758 771 } 759 772 760 773 static int scmi_pinctrl_get_pin_info(const struct scmi_protocol_handle *ph, 761 - u32 selector, struct scmi_pin_info *pin) 774 + u32 selector) 762 775 { 776 + struct scmi_pinctrl_info *pi = ph->get_priv(ph); 777 + struct scmi_pin_info *pin; 763 778 int ret; 764 779 765 - if (!pin) 780 + if (selector >= pi->nr_pins) 766 781 return -EINVAL; 782 + 783 + pin = &pi->pins[selector]; 784 + if (pin->present) 785 + return 0; 767 786 768 787 ret = scmi_pinctrl_attributes(ph, PIN_TYPE, selector, pin->name, NULL); 769 788 if (ret) ··· 783 790 u32 selector, const char **name) 784 791 { 785 792 struct scmi_pinctrl_info *pi = ph->get_priv(ph); 793 + int ret; 786 794 787 795 if (!name) 788 796 return -EINVAL; 789 797 790 - if (selector >= pi->nr_pins) 791 - return -EINVAL; 792 - 793 - if (!pi->pins[selector].present) { 794 - int ret; 795 - 796 - ret = scmi_pinctrl_get_pin_info(ph, selector, &pi->pins[selector]); 797 - if (ret) 798 - return ret; 799 - } 798 + ret = scmi_pinctrl_get_pin_info(ph, selector); 799 + if (ret) 800 + return ret; 800 801 801 802 *name = pi->pins[selector].name; 802 803 ··· 830 843 static int scmi_pinctrl_protocol_init(const struct scmi_protocol_handle *ph) 831 844 { 832 845 int ret; 833 - u32 version; 834 846 struct scmi_pinctrl_info *pinfo; 835 847 836 - ret = ph->xops->version_get(ph, &version); 837 - if (ret) 838 - return ret; 839 - 840 848 dev_dbg(ph->dev, "Pinctrl Version %d.%d\n", 841 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 849 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 842 850 843 851 pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL); 844 852 if (!pinfo) ··· 858 876 if (!pinfo->functions) 859 877 return -ENOMEM; 860 878 861 - pinfo->version = version; 862 - 863 - return ph->set_priv(ph, pinfo, version); 879 + return ph->set_priv(ph, pinfo); 864 880 } 865 881 866 882 static int scmi_pinctrl_protocol_deinit(const struct scmi_protocol_handle *ph)
+5 -13
drivers/firmware/arm_scmi/power.c
··· 67 67 }; 68 68 69 69 struct scmi_power_info { 70 - u32 version; 71 70 bool notify_state_change_cmd; 72 71 int num_domains; 73 72 u64 stats_addr; ··· 108 109 static int 109 110 scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph, 110 111 u32 domain, struct power_dom_info *dom_info, 111 - u32 version, bool notify_state_change_cmd) 112 + bool notify_state_change_cmd) 112 113 { 113 114 int ret; 114 115 u32 flags; ··· 140 141 * If supported overwrite short name with the extended one; 141 142 * on error just carry on and use already provided short name. 142 143 */ 143 - if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 && 144 + if (!ret && PROTOCOL_REV_MAJOR(ph->version) >= 0x3 && 144 145 SUPPORTS_EXTENDED_NAMES(flags)) { 145 146 ph->hops->extended_name_get(ph, POWER_DOMAIN_NAME_GET, 146 147 domain, NULL, dom_info->name, ··· 322 323 static int scmi_power_protocol_init(const struct scmi_protocol_handle *ph) 323 324 { 324 325 int domain, ret; 325 - u32 version; 326 326 struct scmi_power_info *pinfo; 327 327 328 - ret = ph->xops->version_get(ph, &version); 329 - if (ret) 330 - return ret; 331 - 332 328 dev_dbg(ph->dev, "Power Version %d.%d\n", 333 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 329 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 334 330 335 331 pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL); 336 332 if (!pinfo) ··· 343 349 for (domain = 0; domain < pinfo->num_domains; domain++) { 344 350 struct power_dom_info *dom = pinfo->dom_info + domain; 345 351 346 - scmi_power_domain_attributes_get(ph, domain, dom, version, 352 + scmi_power_domain_attributes_get(ph, domain, dom, 347 353 pinfo->notify_state_change_cmd); 348 354 } 349 355 350 - pinfo->version = version; 351 - 352 - return ph->set_priv(ph, pinfo, version); 356 + return ph->set_priv(ph, pinfo); 353 357 } 354 358 355 359 static const struct scmi_protocol scmi_power = {
+7 -14
drivers/firmware/arm_scmi/powercap.c
··· 122 122 }; 123 123 124 124 struct powercap_info { 125 - u32 version; 126 125 int num_domains; 127 126 bool notify_cap_cmd; 128 127 bool notify_measurements_cmd; ··· 433 434 } 434 435 435 436 /* Save the last explicitly set non-zero powercap value */ 436 - if (PROTOCOL_REV_MAJOR(pi->version) >= 0x2 && !ret && power_cap) 437 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2 && !ret && power_cap) 437 438 pi->states[domain_id].last_pcap = power_cap; 438 439 439 440 return ret; ··· 453 454 return -EINVAL; 454 455 455 456 /* Just log the last set request if acting on a disabled domain */ 456 - if (PROTOCOL_REV_MAJOR(pi->version) >= 0x2 && 457 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2 && 457 458 !pi->states[domain_id].enabled) { 458 459 pi->states[domain_id].last_pcap = power_cap; 459 460 return 0; ··· 634 635 u32 power_cap; 635 636 struct powercap_info *pi = ph->get_priv(ph); 636 637 637 - if (PROTOCOL_REV_MAJOR(pi->version) < 0x2) 638 + if (PROTOCOL_REV_MAJOR(ph->version) < 0x2) 638 639 return -EINVAL; 639 640 640 641 if (enable == pi->states[domain_id].enabled) ··· 675 676 struct powercap_info *pi = ph->get_priv(ph); 676 677 677 678 *enable = true; 678 - if (PROTOCOL_REV_MAJOR(pi->version) < 0x2) 679 + if (PROTOCOL_REV_MAJOR(ph->version) < 0x2) 679 680 return 0; 680 681 681 682 /* ··· 960 961 scmi_powercap_protocol_init(const struct scmi_protocol_handle *ph) 961 962 { 962 963 int domain, ret; 963 - u32 version; 964 964 struct powercap_info *pinfo; 965 965 966 - ret = ph->xops->version_get(ph, &version); 967 - if (ret) 968 - return ret; 969 - 970 966 dev_dbg(ph->dev, "Powercap Version %d.%d\n", 971 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 967 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 972 968 973 969 pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL); 974 970 if (!pinfo) ··· 1000 1006 &pinfo->powercaps[domain].fc_info); 1001 1007 1002 1008 /* Grab initial state when disable is supported. */ 1003 - if (PROTOCOL_REV_MAJOR(version) >= 0x2) { 1009 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2) { 1004 1010 ret = __scmi_powercap_cap_get(ph, 1005 1011 &pinfo->powercaps[domain], 1006 1012 &pinfo->states[domain].last_pcap); ··· 1012 1018 } 1013 1019 } 1014 1020 1015 - pinfo->version = version; 1016 - return ph->set_priv(ph, pinfo, version); 1021 + return ph->set_priv(ph, pinfo); 1017 1022 } 1018 1023 1019 1024 static const struct scmi_protocol scmi_powercap = {
+5 -4
drivers/firmware/arm_scmi/protocols.h
··· 159 159 * struct scmi_protocol_handle - Reference to an initialized protocol instance 160 160 * 161 161 * @dev: A reference to the associated SCMI instance device (handle->dev). 162 + * @version: The protocol version currently effectively in use by this 163 + * initialized instance of the protocol as determined at the end of 164 + * any possibly needed negotiations performed by the core. 162 165 * @xops: A reference to a struct holding refs to the core xfer operations that 163 166 * can be used by the protocol implementation to generate SCMI messages. 164 167 * @set_priv: A method to set protocol private data for this instance. ··· 180 177 */ 181 178 struct scmi_protocol_handle { 182 179 struct device *dev; 180 + unsigned int version; 183 181 const struct scmi_xfer_ops *xops; 184 182 const struct scmi_proto_helpers_ops *hops; 185 - int (*set_priv)(const struct scmi_protocol_handle *ph, void *priv, 186 - u32 version); 183 + int (*set_priv)(const struct scmi_protocol_handle *ph, void *priv); 187 184 void *(*get_priv)(const struct scmi_protocol_handle *ph); 188 185 }; 189 186 ··· 290 287 291 288 /** 292 289 * struct scmi_xfer_ops - References to the core SCMI xfer operations. 293 - * @version_get: Get this version protocol. 294 290 * @xfer_get_init: Initialize one struct xfer if any xfer slot is free. 295 291 * @reset_rx_to_maxsz: Reset rx size to max transport size. 296 292 * @do_xfer: Do the SCMI transfer. ··· 302 300 * another protocol. 303 301 */ 304 302 struct scmi_xfer_ops { 305 - int (*version_get)(const struct scmi_protocol_handle *ph, u32 *version); 306 303 int (*xfer_get_init)(const struct scmi_protocol_handle *ph, u8 msg_id, 307 304 size_t tx_size, size_t rx_size, 308 305 struct scmi_xfer **p);
+38 -30
drivers/firmware/arm_scmi/reset.c
··· 65 65 }; 66 66 67 67 struct scmi_reset_info { 68 - u32 version; 69 68 int num_domains; 70 69 bool notify_reset_cmd; 71 70 struct reset_dom_info *dom_info; ··· 97 98 return ret; 98 99 } 99 100 101 + static struct reset_dom_info * 102 + scmi_reset_domain_lookup(const struct scmi_protocol_handle *ph, u32 domain) 103 + { 104 + struct scmi_reset_info *pi = ph->get_priv(ph); 105 + 106 + if (domain >= pi->num_domains) 107 + return ERR_PTR(-EINVAL); 108 + 109 + return pi->dom_info + domain; 110 + } 111 + 100 112 static int 101 113 scmi_reset_domain_attributes_get(const struct scmi_protocol_handle *ph, 102 - struct scmi_reset_info *pinfo, 103 - u32 domain, u32 version) 114 + struct scmi_reset_info *pinfo, u32 domain) 104 115 { 105 116 int ret; 106 117 u32 attributes; ··· 146 137 * If supported overwrite short name with the extended one; 147 138 * on error just carry on and use already provided short name. 148 139 */ 149 - if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 && 140 + if (!ret && PROTOCOL_REV_MAJOR(ph->version) >= 0x3 && 150 141 SUPPORTS_EXTENDED_NAMES(attributes)) 151 142 ph->hops->extended_name_get(ph, RESET_DOMAIN_NAME_GET, domain, 152 143 NULL, dom_info->name, ··· 165 156 static const char * 166 157 scmi_reset_name_get(const struct scmi_protocol_handle *ph, u32 domain) 167 158 { 168 - struct scmi_reset_info *pi = ph->get_priv(ph); 159 + struct reset_dom_info *dom_info; 169 160 170 - struct reset_dom_info *dom = pi->dom_info + domain; 161 + dom_info = scmi_reset_domain_lookup(ph, domain); 162 + if (IS_ERR(dom_info)) 163 + return "unknown"; 171 164 172 - return dom->name; 165 + return dom_info->name; 173 166 } 174 167 175 168 static int scmi_reset_latency_get(const struct scmi_protocol_handle *ph, 176 169 u32 domain) 177 170 { 178 - struct scmi_reset_info *pi = ph->get_priv(ph); 179 - struct reset_dom_info *dom = pi->dom_info + domain; 171 + struct reset_dom_info *dom_info; 180 172 181 - return dom->latency_us; 173 + dom_info = scmi_reset_domain_lookup(ph, domain); 174 + if (IS_ERR(dom_info)) 175 + return PTR_ERR(dom_info); 176 + 177 + return dom_info->latency_us; 182 178 } 183 179 184 180 static int scmi_domain_reset(const struct scmi_protocol_handle *ph, u32 domain, ··· 192 178 int ret; 193 179 struct scmi_xfer *t; 194 180 struct scmi_msg_reset_domain_reset *dom; 195 - struct scmi_reset_info *pi = ph->get_priv(ph); 196 - struct reset_dom_info *rdom; 181 + struct reset_dom_info *dom_info; 197 182 198 - if (domain >= pi->num_domains) 199 - return -EINVAL; 183 + dom_info = scmi_reset_domain_lookup(ph, domain); 184 + if (IS_ERR(dom_info)) 185 + return PTR_ERR(dom_info); 200 186 201 - rdom = pi->dom_info + domain; 202 - if (rdom->async_reset && flags & AUTONOMOUS_RESET) 187 + if (dom_info->async_reset && flags & AUTONOMOUS_RESET) 203 188 flags |= ASYNCHRONOUS_RESET; 204 189 205 190 ret = ph->xops->xfer_get_init(ph, RESET, sizeof(*dom), 0, &t); ··· 251 238 static bool scmi_reset_notify_supported(const struct scmi_protocol_handle *ph, 252 239 u8 evt_id, u32 src_id) 253 240 { 254 - struct reset_dom_info *dom; 255 - struct scmi_reset_info *pi = ph->get_priv(ph); 241 + struct reset_dom_info *dom_info; 256 242 257 - if (evt_id != SCMI_EVENT_RESET_ISSUED || src_id >= pi->num_domains) 243 + if (evt_id != SCMI_EVENT_RESET_ISSUED) 258 244 return false; 259 245 260 - dom = pi->dom_info + src_id; 246 + dom_info = scmi_reset_domain_lookup(ph, src_id); 247 + if (IS_ERR(dom_info)) 248 + return false; 261 249 262 - return dom->reset_notify; 250 + return dom_info->reset_notify; 263 251 } 264 252 265 253 static int scmi_reset_notify(const struct scmi_protocol_handle *ph, ··· 354 340 static int scmi_reset_protocol_init(const struct scmi_protocol_handle *ph) 355 341 { 356 342 int domain, ret; 357 - u32 version; 358 343 struct scmi_reset_info *pinfo; 359 344 360 - ret = ph->xops->version_get(ph, &version); 361 - if (ret) 362 - return ret; 363 - 364 345 dev_dbg(ph->dev, "Reset Version %d.%d\n", 365 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 346 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 366 347 367 348 pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL); 368 349 if (!pinfo) ··· 373 364 return -ENOMEM; 374 365 375 366 for (domain = 0; domain < pinfo->num_domains; domain++) 376 - scmi_reset_domain_attributes_get(ph, pinfo, domain, version); 367 + scmi_reset_domain_attributes_get(ph, pinfo, domain); 377 368 378 - pinfo->version = version; 379 - return ph->set_priv(ph, pinfo, version); 369 + return ph->set_priv(ph, pinfo); 380 370 } 381 371 382 372 static const struct scmi_protocol scmi_reset = {
+7 -15
drivers/firmware/arm_scmi/sensors.c
··· 214 214 }; 215 215 216 216 struct sensors_info { 217 - u32 version; 218 217 bool notify_trip_point_cmd; 219 218 bool notify_continuos_update_cmd; 220 219 int num_sensors; ··· 523 524 } 524 525 525 526 static int scmi_sensor_axis_description(const struct scmi_protocol_handle *ph, 526 - struct scmi_sensor_info *s, 527 - u32 version) 527 + struct scmi_sensor_info *s) 528 528 { 529 529 int ret; 530 530 void *iter; ··· 553 555 if (ret) 554 556 return ret; 555 557 556 - if (PROTOCOL_REV_MAJOR(version) >= 0x3 && 558 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3 && 557 559 apriv.any_axes_support_extended_names) 558 560 ret = scmi_sensor_axis_extended_names_get(ph, s); 559 561 ··· 619 621 s->type = SENSOR_TYPE(attrh); 620 622 /* Use pre-allocated pool wherever possible */ 621 623 s->intervals.desc = s->intervals.prealloc_pool; 622 - if (si->version == SCMIv2_SENSOR_PROTOCOL) { 624 + if (ph->version == SCMIv2_SENSOR_PROTOCOL) { 623 625 s->intervals.segmented = false; 624 626 s->intervals.count = 1; 625 627 /* ··· 657 659 * one; on error just carry on and use already provided 658 660 * short name. 659 661 */ 660 - if (PROTOCOL_REV_MAJOR(si->version) >= 0x3 && 662 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3 && 661 663 SUPPORTS_EXTENDED_NAMES(attrl)) 662 664 ph->hops->extended_name_get(ph, SENSOR_NAME_GET, s->id, 663 665 NULL, s->name, SCMI_MAX_STR_SIZE); ··· 681 683 } 682 684 683 685 if (s->num_axis > 0) 684 - ret = scmi_sensor_axis_description(ph, s, si->version); 686 + ret = scmi_sensor_axis_description(ph, s); 685 687 686 688 st->priv = ((u8 *)sdesc + dsize); 687 689 ··· 1146 1148 1147 1149 static int scmi_sensors_protocol_init(const struct scmi_protocol_handle *ph) 1148 1150 { 1149 - u32 version; 1150 1151 int ret; 1151 1152 struct sensors_info *sinfo; 1152 1153 1153 - ret = ph->xops->version_get(ph, &version); 1154 - if (ret) 1155 - return ret; 1156 - 1157 1154 dev_dbg(ph->dev, "Sensor Version %d.%d\n", 1158 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 1155 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 1159 1156 1160 1157 sinfo = devm_kzalloc(ph->dev, sizeof(*sinfo), GFP_KERNEL); 1161 1158 if (!sinfo) 1162 1159 return -ENOMEM; 1163 - sinfo->version = version; 1164 1160 1165 1161 ret = scmi_sensor_attributes_get(ph, sinfo); 1166 1162 if (ret) ··· 1168 1176 if (ret) 1169 1177 return ret; 1170 1178 1171 - return ph->set_priv(ph, sinfo, version); 1179 + return ph->set_priv(ph, sinfo); 1172 1180 } 1173 1181 1174 1182 static const struct scmi_protocol scmi_sensors = {
+3 -2
drivers/firmware/arm_scmi/shmem.c
··· 196 196 struct resource *res, 197 197 struct scmi_shmem_io_ops **ops) 198 198 { 199 - struct device_node *shmem __free(device_node); 200 199 const char *desc = tx ? "Tx" : "Rx"; 201 200 int ret, idx = tx ? 0 : 1; 202 201 struct device *cdev = cinfo->dev; ··· 204 205 void __iomem *addr; 205 206 u32 reg_io_width; 206 207 207 - shmem = of_parse_phandle(cdev->of_node, "shmem", idx); 208 + struct device_node *shmem __free(device_node) = of_parse_phandle(cdev->of_node, 209 + "shmem", idx); 210 + 208 211 if (!shmem) 209 212 return IOMEM_ERR_PTR(-ENODEV); 210 213
+3 -11
drivers/firmware/arm_scmi/system.c
··· 34 34 }; 35 35 36 36 struct scmi_system_info { 37 - u32 version; 38 37 bool graceful_timeout_supported; 39 38 bool power_state_notify_cmd; 40 39 }; ··· 140 141 141 142 static int scmi_system_protocol_init(const struct scmi_protocol_handle *ph) 142 143 { 143 - int ret; 144 - u32 version; 145 144 struct scmi_system_info *pinfo; 146 145 147 - ret = ph->xops->version_get(ph, &version); 148 - if (ret) 149 - return ret; 150 - 151 146 dev_dbg(ph->dev, "System Power Version %d.%d\n", 152 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 147 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 153 148 154 149 pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL); 155 150 if (!pinfo) 156 151 return -ENOMEM; 157 152 158 - pinfo->version = version; 159 - if (PROTOCOL_REV_MAJOR(pinfo->version) >= 0x2) 153 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2) 160 154 pinfo->graceful_timeout_supported = true; 161 155 162 156 if (!ph->hops->protocol_msg_check(ph, SYSTEM_POWER_STATE_NOTIFY, NULL)) 163 157 pinfo->power_state_notify_cmd = true; 164 158 165 - return ph->set_priv(ph, pinfo, version); 159 + return ph->set_priv(ph, pinfo); 166 160 } 167 161 168 162 static const struct scmi_protocol scmi_system = {
+2 -8
drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c
··· 48 48 #define SCMI_IMX_BBM_EVENT_RTC_MASK GENMASK(31, 24) 49 49 50 50 struct scmi_imx_bbm_info { 51 - u32 version; 52 51 int nr_rtc; 53 52 int nr_gpr; 54 53 }; ··· 344 345 345 346 static int scmi_imx_bbm_protocol_init(const struct scmi_protocol_handle *ph) 346 347 { 347 - u32 version; 348 348 int ret; 349 349 struct scmi_imx_bbm_info *binfo; 350 350 351 - ret = ph->xops->version_get(ph, &version); 352 - if (ret) 353 - return ret; 354 - 355 351 dev_info(ph->dev, "NXP SM BBM Version %d.%d\n", 356 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 352 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 357 353 358 354 binfo = devm_kzalloc(ph->dev, sizeof(*binfo), GFP_KERNEL); 359 355 if (!binfo) ··· 358 364 if (ret) 359 365 return ret; 360 366 361 - return ph->set_priv(ph, binfo, version); 367 + return ph->set_priv(ph, binfo); 362 368 } 363 369 364 370 static const struct scmi_protocol scmi_imx_bbm = {
+2 -7
drivers/firmware/arm_scmi/vendors/imx/imx-sm-cpu.c
··· 233 233 static int scmi_imx_cpu_protocol_init(const struct scmi_protocol_handle *ph) 234 234 { 235 235 struct scmi_imx_cpu_info *info; 236 - u32 version; 237 236 int ret, i; 238 237 239 - ret = ph->xops->version_get(ph, &version); 240 - if (ret) 241 - return ret; 242 - 243 238 dev_info(ph->dev, "NXP SM CPU Protocol Version %d.%d\n", 244 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 239 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 245 240 246 241 info = devm_kzalloc(ph->dev, sizeof(*info), GFP_KERNEL); 247 242 if (!info) ··· 252 257 return ret; 253 258 } 254 259 255 - return ph->set_priv(ph, info, version); 260 + return ph->set_priv(ph, info); 256 261 } 257 262 258 263 static const struct scmi_protocol scmi_imx_cpu = {
+2 -7
drivers/firmware/arm_scmi/vendors/imx/imx-sm-lmm.c
··· 226 226 static int scmi_imx_lmm_protocol_init(const struct scmi_protocol_handle *ph) 227 227 { 228 228 struct scmi_imx_lmm_priv *info; 229 - u32 version; 230 229 int ret; 231 230 232 - ret = ph->xops->version_get(ph, &version); 233 - if (ret) 234 - return ret; 235 - 236 231 dev_info(ph->dev, "NXP SM LMM Version %d.%d\n", 237 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 232 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 238 233 239 234 info = devm_kzalloc(ph->dev, sizeof(*info), GFP_KERNEL); 240 235 if (!info) ··· 239 244 if (ret) 240 245 return ret; 241 246 242 - return ph->set_priv(ph, info, version); 247 + return ph->set_priv(ph, info); 243 248 } 244 249 245 250 static const struct scmi_protocol scmi_imx_lmm = {
+2 -8
drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
··· 32 32 }; 33 33 34 34 struct scmi_imx_misc_info { 35 - u32 version; 36 35 u32 nr_dev_ctrl; 37 36 u32 nr_brd_ctrl; 38 37 u32 nr_reason; ··· 379 380 static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph) 380 381 { 381 382 struct scmi_imx_misc_info *minfo; 382 - u32 version; 383 383 int ret; 384 384 385 - ret = ph->xops->version_get(ph, &version); 386 - if (ret) 387 - return ret; 388 - 389 385 dev_info(ph->dev, "NXP SM MISC Version %d.%d\n", 390 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 386 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 391 387 392 388 minfo = devm_kzalloc(ph->dev, sizeof(*minfo), GFP_KERNEL); 393 389 if (!minfo) ··· 404 410 if (ret && ret != -EOPNOTSUPP) 405 411 return ret; 406 412 407 - return ph->set_priv(ph, minfo, version); 413 + return ph->set_priv(ph, minfo); 408 414 } 409 415 410 416 static const struct scmi_protocol scmi_imx_misc = {
+3 -10
drivers/firmware/arm_scmi/voltage.c
··· 66 66 }; 67 67 68 68 struct voltage_info { 69 - unsigned int version; 70 69 unsigned int num_domains; 71 70 struct scmi_voltage_info *domains; 72 71 }; ··· 242 243 * If supported overwrite short name with the extended one; 243 244 * on error just carry on and use already provided short name. 244 245 */ 245 - if (PROTOCOL_REV_MAJOR(vinfo->version) >= 0x2) { 246 + if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2) { 246 247 if (SUPPORTS_EXTENDED_NAMES(attributes)) 247 248 ph->hops->extended_name_get(ph, 248 249 VOLTAGE_DOMAIN_NAME_GET, ··· 404 405 static int scmi_voltage_protocol_init(const struct scmi_protocol_handle *ph) 405 406 { 406 407 int ret; 407 - u32 version; 408 408 struct voltage_info *vinfo; 409 409 410 - ret = ph->xops->version_get(ph, &version); 411 - if (ret) 412 - return ret; 413 - 414 410 dev_dbg(ph->dev, "Voltage Version %d.%d\n", 415 - PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); 411 + PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version)); 416 412 417 413 vinfo = devm_kzalloc(ph->dev, sizeof(*vinfo), GFP_KERNEL); 418 414 if (!vinfo) 419 415 return -ENOMEM; 420 - vinfo->version = version; 421 416 422 417 ret = scmi_protocol_attributes_get(ph, vinfo); 423 418 if (ret) ··· 430 437 dev_warn(ph->dev, "No Voltage domains found.\n"); 431 438 } 432 439 433 - return ph->set_priv(ph, vinfo, version); 440 + return ph->set_priv(ph, vinfo); 434 441 } 435 442 436 443 static const struct scmi_protocol scmi_voltage = {