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.

reset: convert the core API to using firmware nodes

In order to simplify the commit converting the internals of reset core
to using firmware nodes, first convert the user-facing API. Modify the
signature of the core consumer functions but leave the specialized
wrappers as is to avoid modifying users for now.

No functional change intended.

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Bartosz Golaszewski and committed by
Philipp Zabel
ba8dbbb1 9d52054a

+46 -31
-1
Documentation/driver-api/reset.rst
··· 198 198 reset_control_rearm 199 199 reset_control_put 200 200 of_reset_control_get_count 201 - of_reset_control_array_get 202 201 devm_reset_control_array_get 203 202 reset_control_get_count 204 203
+18 -15
drivers/reset/core.c
··· 1061 1061 rgpio_dev->of_args = *args; 1062 1062 /* 1063 1063 * We keep the device_node reference, but of_args.np is put at the end 1064 - * of __of_reset_control_get(), so get it one more time. 1064 + * of __fwnode_reset_control_get(), so get it one more time. 1065 1065 * Hold reference as long as rgpio_dev memory is valid. 1066 1066 */ 1067 1067 of_node_get(rgpio_dev->of_args.np); ··· 1115 1115 } 1116 1116 1117 1117 struct reset_control * 1118 - __of_reset_control_get(struct device_node *node, const char *id, int index, 1119 - enum reset_control_flags flags) 1118 + __fwnode_reset_control_get(struct fwnode_handle *fwnode, const char *id, int index, 1119 + enum reset_control_flags flags) 1120 1120 { 1121 1121 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL; 1122 1122 bool gpio_fallback = false; 1123 + struct device_node *node = to_of_node(fwnode); 1123 1124 struct reset_control *rstc = ERR_PTR(-EINVAL); 1124 1125 struct reset_controller_dev *rcdev; 1125 1126 struct of_phandle_args args; 1126 1127 int rstc_id; 1127 1128 int ret; 1128 1129 1129 - if (!node) 1130 + if (!fwnode) 1130 1131 return ERR_PTR(-EINVAL); 1131 1132 1132 1133 if (id) { ··· 1194 1193 1195 1194 return rstc; 1196 1195 } 1197 - EXPORT_SYMBOL_GPL(__of_reset_control_get); 1196 + EXPORT_SYMBOL_GPL(__fwnode_reset_control_get); 1198 1197 1199 1198 struct reset_control *__reset_control_get(struct device *dev, const char *id, 1200 1199 int index, enum reset_control_flags flags) ··· 1202 1201 bool shared = flags & RESET_CONTROL_FLAGS_BIT_SHARED; 1203 1202 bool acquired = flags & RESET_CONTROL_FLAGS_BIT_ACQUIRED; 1204 1203 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL; 1204 + struct fwnode_handle *fwnode = dev_fwnode(dev); 1205 1205 1206 1206 if (WARN_ON(shared && acquired)) 1207 1207 return ERR_PTR(-EINVAL); 1208 1208 1209 - if (dev->of_node) 1210 - return __of_reset_control_get(dev->of_node, id, index, flags); 1209 + if (fwnode) 1210 + return __fwnode_reset_control_get(fwnode, id, index, flags); 1211 1211 1212 1212 return optional ? NULL : ERR_PTR(-ENOENT); 1213 1213 } ··· 1470 1468 } 1471 1469 1472 1470 /** 1473 - * of_reset_control_array_get - Get a list of reset controls using 1474 - * device node. 1471 + * fwnode_reset_control_array_get - Get a list of reset controls using 1472 + * a firmware node. 1475 1473 * 1476 - * @np: device node for the device that requests the reset controls array 1474 + * @fwnode: firmware node for the device that requests the reset controls array 1477 1475 * @flags: whether reset controls are shared, optional, acquired 1478 1476 * 1479 1477 * Returns pointer to allocated reset_control on success or error on failure 1480 1478 */ 1481 1479 struct reset_control * 1482 - of_reset_control_array_get(struct device_node *np, enum reset_control_flags flags) 1480 + fwnode_reset_control_array_get(struct fwnode_handle *fwnode, 1481 + enum reset_control_flags flags) 1483 1482 { 1484 1483 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL; 1485 1484 struct reset_control_array *resets; 1486 1485 struct reset_control *rstc; 1487 1486 int num, i; 1488 1487 1489 - num = fwnode_reset_control_get_count(of_fwnode_handle(np)); 1488 + num = fwnode_reset_control_get_count(fwnode); 1490 1489 if (num < 0) 1491 1490 return optional ? NULL : ERR_PTR(num); 1492 1491 ··· 1497 1494 resets->num_rstcs = num; 1498 1495 1499 1496 for (i = 0; i < num; i++) { 1500 - rstc = __of_reset_control_get(np, NULL, i, flags); 1497 + rstc = __fwnode_reset_control_get(fwnode, NULL, i, flags); 1501 1498 if (IS_ERR(rstc)) 1502 1499 goto err_rst; 1503 1500 resets->rstc[i] = rstc; ··· 1514 1511 1515 1512 return rstc; 1516 1513 } 1517 - EXPORT_SYMBOL_GPL(of_reset_control_array_get); 1514 + EXPORT_SYMBOL_GPL(fwnode_reset_control_array_get); 1518 1515 1519 1516 /** 1520 1517 * devm_reset_control_array_get - Resource managed reset control array get ··· 1538 1535 if (!ptr) 1539 1536 return ERR_PTR(-ENOMEM); 1540 1537 1541 - rstc = of_reset_control_array_get(dev->of_node, flags); 1538 + rstc = fwnode_reset_control_array_get(dev_fwnode(dev), flags); 1542 1539 if (IS_ERR_OR_NULL(rstc)) { 1543 1540 devres_free(ptr); 1544 1541 return rstc;
+28 -15
include/linux/reset.h
··· 5 5 #include <linux/bits.h> 6 6 #include <linux/err.h> 7 7 #include <linux/errno.h> 8 + #include <linux/of.h> 8 9 #include <linux/types.h> 9 10 10 11 struct device; 11 12 struct device_node; 13 + struct fwnode_handle; 12 14 struct reset_control; 13 15 14 16 /** ··· 86 84 int reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs); 87 85 void reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs); 88 86 89 - struct reset_control *__of_reset_control_get(struct device_node *node, 87 + struct reset_control *__fwnode_reset_control_get(struct fwnode_handle *fwnode, 90 88 const char *id, int index, enum reset_control_flags flags); 91 89 struct reset_control *__reset_control_get(struct device *dev, const char *id, 92 90 int index, enum reset_control_flags flags); ··· 105 103 106 104 struct reset_control *devm_reset_control_array_get(struct device *dev, 107 105 enum reset_control_flags flags); 108 - struct reset_control *of_reset_control_array_get(struct device_node *np, enum reset_control_flags); 106 + struct reset_control *fwnode_reset_control_array_get(struct fwnode_handle *fwnode, 107 + enum reset_control_flags); 109 108 110 109 int reset_control_get_count(struct device *dev); 111 110 ··· 155 152 return optional ? 0 : -ENOTSUPP; 156 153 } 157 154 158 - static inline struct reset_control *__of_reset_control_get( 159 - struct device_node *node, 155 + static inline struct reset_control *__fwnode_reset_control_get( 156 + struct fwnode_handle *fwnode, 160 157 const char *id, int index, enum reset_control_flags flags) 161 158 { 162 159 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL; ··· 245 242 } 246 243 247 244 static inline struct reset_control * 248 - of_reset_control_array_get(struct device_node *np, enum reset_control_flags flags) 245 + fwnode_reset_control_array_get(struct fwnode_handle *fwnode, enum reset_control_flags flags) 249 246 { 250 247 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL; 251 248 ··· 503 500 static inline struct reset_control *of_reset_control_get_exclusive( 504 501 struct device_node *node, const char *id) 505 502 { 506 - return __of_reset_control_get(node, id, 0, RESET_CONTROL_EXCLUSIVE); 503 + return __fwnode_reset_control_get(of_fwnode_handle(node), id, 0, 504 + RESET_CONTROL_EXCLUSIVE); 507 505 } 508 506 509 507 /** ··· 524 520 static inline struct reset_control *of_reset_control_get_optional_exclusive( 525 521 struct device_node *node, const char *id) 526 522 { 527 - return __of_reset_control_get(node, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE); 523 + return __fwnode_reset_control_get(of_fwnode_handle(node), id, 0, 524 + RESET_CONTROL_OPTIONAL_EXCLUSIVE); 528 525 } 529 526 530 527 /** ··· 550 545 static inline struct reset_control *of_reset_control_get_shared( 551 546 struct device_node *node, const char *id) 552 547 { 553 - return __of_reset_control_get(node, id, 0, RESET_CONTROL_SHARED); 548 + return __fwnode_reset_control_get(of_fwnode_handle(node), id, 0, 549 + RESET_CONTROL_SHARED); 554 550 } 555 551 556 552 /** ··· 568 562 static inline struct reset_control *of_reset_control_get_exclusive_by_index( 569 563 struct device_node *node, int index) 570 564 { 571 - return __of_reset_control_get(node, NULL, index, RESET_CONTROL_EXCLUSIVE); 565 + return __fwnode_reset_control_get(of_fwnode_handle(node), NULL, index, 566 + RESET_CONTROL_EXCLUSIVE); 572 567 } 573 568 574 569 /** ··· 597 590 static inline struct reset_control *of_reset_control_get_shared_by_index( 598 591 struct device_node *node, int index) 599 592 { 600 - return __of_reset_control_get(node, NULL, index, RESET_CONTROL_SHARED); 593 + return __fwnode_reset_control_get(of_fwnode_handle(node), NULL, index, 594 + RESET_CONTROL_SHARED); 601 595 } 602 596 603 597 /** ··· 1040 1032 static inline struct reset_control * 1041 1033 of_reset_control_array_get_exclusive(struct device_node *node) 1042 1034 { 1043 - return of_reset_control_array_get(node, RESET_CONTROL_EXCLUSIVE); 1035 + return fwnode_reset_control_array_get(of_fwnode_handle(node), 1036 + RESET_CONTROL_EXCLUSIVE); 1044 1037 } 1045 1038 1046 1039 static inline struct reset_control * 1047 1040 of_reset_control_array_get_exclusive_released(struct device_node *node) 1048 1041 { 1049 - return of_reset_control_array_get(node, RESET_CONTROL_EXCLUSIVE_RELEASED); 1042 + return fwnode_reset_control_array_get(of_fwnode_handle(node), 1043 + RESET_CONTROL_EXCLUSIVE_RELEASED); 1050 1044 } 1051 1045 1052 1046 static inline struct reset_control * 1053 1047 of_reset_control_array_get_shared(struct device_node *node) 1054 1048 { 1055 - return of_reset_control_array_get(node, RESET_CONTROL_SHARED); 1049 + return fwnode_reset_control_array_get(of_fwnode_handle(node), 1050 + RESET_CONTROL_SHARED); 1056 1051 } 1057 1052 1058 1053 static inline struct reset_control * 1059 1054 of_reset_control_array_get_optional_exclusive(struct device_node *node) 1060 1055 { 1061 - return of_reset_control_array_get(node, RESET_CONTROL_OPTIONAL_EXCLUSIVE); 1056 + return fwnode_reset_control_array_get(of_fwnode_handle(node), 1057 + RESET_CONTROL_OPTIONAL_EXCLUSIVE); 1062 1058 } 1063 1059 1064 1060 static inline struct reset_control * 1065 1061 of_reset_control_array_get_optional_shared(struct device_node *node) 1066 1062 { 1067 - return of_reset_control_array_get(node, RESET_CONTROL_OPTIONAL_SHARED); 1063 + return fwnode_reset_control_array_get(of_fwnode_handle(node), 1064 + RESET_CONTROL_OPTIONAL_SHARED); 1068 1065 } 1069 1066 #endif