Skip to content

Commit a8dc26a

Browse files
andredkrzk
authored andcommitted
firmware: exynos-acpm: introduce devm_acpm_get_by_node()
To allow ACPM clients to simply be children of the ACPM node in DT, they need to be able to get the ACPM handle based on that ACPM node directly. Add an API to allow them to do so, devm_acpm_get_by_node(). At the same time, the previous approach of acquiring the ACPM handle via a DT phandle is now obsolete and we can remove devm_acpm_get_by_phandle(), which was there to facilitate that. There are no existing or anticipated upcoming users of that API, because all clients should be children of the ACPM node going forward. Note that no DTs have been merged that use the old approach, so doing this API change in this driver now will not affect any existing DTs or client drivers. Signed-off-by: André Draszik <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Kozlowski <[email protected]>
1 parent 636baba commit a8dc26a

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

drivers/firmware/samsung/exynos-acpm.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -667,20 +667,14 @@ static void devm_acpm_release(struct device *dev, void *res)
667667
*
668668
* Return: pointer to handle on success, ERR_PTR(-errno) otherwise.
669669
*/
670-
static const struct acpm_handle *acpm_get_by_phandle(struct device *dev,
671-
const char *property)
670+
static const struct acpm_handle *acpm_get_by_node(struct device *dev,
671+
struct device_node *acpm_np)
672672
{
673673
struct platform_device *pdev;
674-
struct device_node *acpm_np;
675674
struct device_link *link;
676675
struct acpm_info *acpm;
677676

678-
acpm_np = of_parse_phandle(dev->of_node, property, 0);
679-
if (!acpm_np)
680-
return ERR_PTR(-ENODEV);
681-
682677
pdev = of_find_device_by_node(acpm_np);
683-
of_node_put(acpm_np);
684678
if (!pdev)
685679
return ERR_PTR(-EPROBE_DEFER);
686680

@@ -709,22 +703,22 @@ static const struct acpm_handle *acpm_get_by_phandle(struct device *dev,
709703
}
710704

711705
/**
712-
* devm_acpm_get_by_phandle() - managed get handle using phandle.
713-
* @dev: device pointer requesting ACPM handle.
714-
* @property: property name containing phandle on ACPM node.
706+
* devm_acpm_get_by_node() - managed get handle using node pointer.
707+
* @dev: device pointer requesting ACPM handle.
708+
* @np: ACPM device tree node.
715709
*
716710
* Return: pointer to handle on success, ERR_PTR(-errno) otherwise.
717711
*/
718-
const struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev,
719-
const char *property)
712+
const struct acpm_handle *devm_acpm_get_by_node(struct device *dev,
713+
struct device_node *np)
720714
{
721715
const struct acpm_handle **ptr, *handle;
722716

723717
ptr = devres_alloc(devm_acpm_release, sizeof(*ptr), GFP_KERNEL);
724718
if (!ptr)
725719
return ERR_PTR(-ENOMEM);
726720

727-
handle = acpm_get_by_phandle(dev, property);
721+
handle = acpm_get_by_node(dev, np);
728722
if (!IS_ERR(handle)) {
729723
*ptr = handle;
730724
devres_add(dev, ptr);
@@ -734,6 +728,7 @@ const struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev,
734728

735729
return handle;
736730
}
731+
EXPORT_SYMBOL_GPL(devm_acpm_get_by_node);
737732

738733
static const struct acpm_match_data acpm_gs101 = {
739734
.initdata_base = ACPM_GS101_INITDATA_BASE,

include/linux/firmware/samsung/exynos-acpm-protocol.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/types.h>
1212

1313
struct acpm_handle;
14+
struct device_node;
1415

1516
struct acpm_pmic_ops {
1617
int (*read_reg)(const struct acpm_handle *handle,
@@ -44,6 +45,7 @@ struct acpm_handle {
4445

4546
struct device;
4647

47-
const struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev,
48-
const char *property);
48+
const struct acpm_handle *devm_acpm_get_by_node(struct device *dev,
49+
struct device_node *np);
50+
4951
#endif /* __EXYNOS_ACPM_PROTOCOL_H */

0 commit comments

Comments
 (0)