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 of_reset_control_get_count() to using firmware nodes

Start the conversion of reset core to using firmware nodes by reworking
of_reset_control_get_count(). Unfortunately there is no fwnode-based
alternative to of_count_phandle_with_args() so we have to hand-code it.

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
9d52054a 8c91302a

+27 -9
+27 -9
drivers/reset/core.c
··· 12 12 #include <linux/device.h> 13 13 #include <linux/err.h> 14 14 #include <linux/export.h> 15 + #include <linux/fwnode.h> 15 16 #include <linux/gpio/driver.h> 16 17 #include <linux/gpio/machine.h> 17 18 #include <linux/gpio/property.h> ··· 21 20 #include <linux/kref.h> 22 21 #include <linux/module.h> 23 22 #include <linux/of.h> 23 + #include <linux/property.h> 24 24 #include <linux/reset.h> 25 25 #include <linux/reset-controller.h> 26 26 #include <linux/slab.h> ··· 1432 1430 */ 1433 1431 1434 1432 /** 1435 - * of_reset_control_get_count - Count number of resets available with a device 1433 + * fwnode_reset_control_get_count - Count number of resets available with a device 1436 1434 * 1437 - * @node: device node that contains 'resets'. 1435 + * @fwnode: firmware node that contains 'resets'. 1438 1436 * 1439 1437 * Returns positive reset count on success, or error number on failure and 1440 1438 * on count being zero. 1441 1439 */ 1442 - static int of_reset_control_get_count(struct device_node *node) 1440 + static int fwnode_reset_control_get_count(struct fwnode_handle *fwnode) 1443 1441 { 1444 - int count; 1442 + struct fwnode_reference_args args; 1443 + int count = 0, ret; 1445 1444 1446 - if (!node) 1445 + if (!fwnode) 1447 1446 return -EINVAL; 1448 1447 1449 - count = of_count_phandle_with_args(node, "resets", "#reset-cells"); 1448 + for (;;) { 1449 + ret = fwnode_property_get_reference_args(fwnode, "resets", "#reset-cells", 1450 + 0, count, &args); 1451 + if (ret) { 1452 + if (ret == -ENOENT) 1453 + break; 1454 + 1455 + return ret; 1456 + } 1457 + 1458 + fwnode_handle_put(args.fwnode); 1459 + count++; 1460 + } 1461 + 1450 1462 if (count == 0) 1451 1463 count = -ENOENT; 1452 1464 ··· 1484 1468 struct reset_control *rstc; 1485 1469 int num, i; 1486 1470 1487 - num = of_reset_control_get_count(np); 1471 + num = fwnode_reset_control_get_count(of_fwnode_handle(np)); 1488 1472 if (num < 0) 1489 1473 return optional ? NULL : ERR_PTR(num); 1490 1474 ··· 1558 1542 */ 1559 1543 int reset_control_get_count(struct device *dev) 1560 1544 { 1561 - if (dev->of_node) 1562 - return of_reset_control_get_count(dev->of_node); 1545 + struct fwnode_handle *fwnode = dev_fwnode(dev); 1546 + 1547 + if (fwnode) 1548 + return fwnode_reset_control_get_count(fwnode); 1563 1549 1564 1550 return -ENOENT; 1565 1551 }