Skip to content

Commit 370643f

Browse files
committed
power: supply: core: rename power_supply_get_by_phandle to power_supply_get_by_reference
(devm_)power_supply_get_by_phandle now internally uses fwnode and are no longer DT specific. Thus drop the ifdef check for CONFIG_OF and rename to (devm_)power_supply_get_by_reference to avoid the DT terminology. Reviewed-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/20250430-psy-core-convert-to-fwnode-v2-5-f9643b958677@collabora.com Signed-off-by: Sebastian Reichel <[email protected]>
1 parent f368f87 commit 370643f

File tree

4 files changed

+15
-26
lines changed

4 files changed

+15
-26
lines changed

drivers/phy/allwinner/phy-sun4i-usb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
754754
}
755755

756756
if (of_property_present(np, "usb0_vbus_power-supply")) {
757-
data->vbus_power_supply = devm_power_supply_get_by_phandle(dev,
757+
data->vbus_power_supply = devm_power_supply_get_by_reference(dev,
758758
"usb0_vbus_power-supply");
759759
if (IS_ERR(data->vbus_power_supply)) {
760760
dev_err(dev, "Couldn't get the VBUS power supply\n");

drivers/power/supply/bq2415x_charger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,7 @@ static int bq2415x_probe(struct i2c_client *client)
16741674
/* Query for initial reported_mode and set it */
16751675
if (bq->nb.notifier_call) {
16761676
if (np) {
1677-
notify_psy = power_supply_get_by_phandle(of_fwnode_handle(np),
1677+
notify_psy = power_supply_get_by_reference(of_fwnode_handle(np),
16781678
"ti,usb-charger-detection");
16791679
if (IS_ERR(notify_psy))
16801680
notify_psy = NULL;

drivers/power/supply/power_supply_core.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,13 @@ void power_supply_put(struct power_supply *psy)
496496
}
497497
EXPORT_SYMBOL_GPL(power_supply_put);
498498

499-
#ifdef CONFIG_OF
500499
static int power_supply_match_device_fwnode(struct device *dev, const void *data)
501500
{
502501
return dev->parent && dev_fwnode(dev->parent) == data;
503502
}
504503

505504
/**
506-
* power_supply_get_by_phandle() - Search for a power supply and returns its ref
505+
* power_supply_get_by_reference() - Search for a power supply and returns its ref
507506
* @fwnode: Pointer to fwnode holding phandle property
508507
* @property: Name of property holding a power supply name
509508
*
@@ -514,8 +513,8 @@ static int power_supply_match_device_fwnode(struct device *dev, const void *data
514513
* Return: On success returns a reference to a power supply with
515514
* matching name equals to value under @property, NULL or ERR_PTR otherwise.
516515
*/
517-
struct power_supply *power_supply_get_by_phandle(struct fwnode_handle *fwnode,
518-
const char *property)
516+
struct power_supply *power_supply_get_by_reference(struct fwnode_handle *fwnode,
517+
const char *property)
519518
{
520519
struct fwnode_handle *power_supply_fwnode;
521520
struct power_supply *psy = NULL;
@@ -537,7 +536,7 @@ struct power_supply *power_supply_get_by_phandle(struct fwnode_handle *fwnode,
537536

538537
return psy;
539538
}
540-
EXPORT_SYMBOL_GPL(power_supply_get_by_phandle);
539+
EXPORT_SYMBOL_GPL(power_supply_get_by_reference);
541540

542541
static void devm_power_supply_put(struct device *dev, void *res)
543542
{
@@ -547,16 +546,16 @@ static void devm_power_supply_put(struct device *dev, void *res)
547546
}
548547

549548
/**
550-
* devm_power_supply_get_by_phandle() - Resource managed version of
551-
* power_supply_get_by_phandle()
549+
* devm_power_supply_get_by_reference() - Resource managed version of
550+
* power_supply_get_by_reference()
552551
* @dev: Pointer to device holding phandle property
553552
* @property: Name of property holding a power supply phandle
554553
*
555554
* Return: On success returns a reference to a power supply with
556555
* matching name equals to value under @property, NULL or ERR_PTR otherwise.
557556
*/
558-
struct power_supply *devm_power_supply_get_by_phandle(struct device *dev,
559-
const char *property)
557+
struct power_supply *devm_power_supply_get_by_reference(struct device *dev,
558+
const char *property)
560559
{
561560
struct power_supply **ptr, *psy;
562561

@@ -567,7 +566,7 @@ struct power_supply *devm_power_supply_get_by_phandle(struct device *dev,
567566
if (!ptr)
568567
return ERR_PTR(-ENOMEM);
569568

570-
psy = power_supply_get_by_phandle(dev_fwnode(dev), property);
569+
psy = power_supply_get_by_reference(dev_fwnode(dev), property);
571570
if (IS_ERR_OR_NULL(psy)) {
572571
devres_free(ptr);
573572
} else {
@@ -576,8 +575,7 @@ struct power_supply *devm_power_supply_get_by_phandle(struct device *dev,
576575
}
577576
return psy;
578577
}
579-
EXPORT_SYMBOL_GPL(devm_power_supply_get_by_phandle);
580-
#endif /* CONFIG_OF */
578+
EXPORT_SYMBOL_GPL(devm_power_supply_get_by_reference);
581579

582580
int power_supply_get_battery_info(struct power_supply *psy,
583581
struct power_supply_battery_info **info_out)

include/linux/power_supply.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -807,19 +807,10 @@ static inline void power_supply_put(struct power_supply *psy) {}
807807
static inline struct power_supply *power_supply_get_by_name(const char *name)
808808
{ return NULL; }
809809
#endif
810-
#ifdef CONFIG_OF
811-
extern struct power_supply *power_supply_get_by_phandle(struct fwnode_handle *fwnode,
812-
const char *property);
813-
extern struct power_supply *devm_power_supply_get_by_phandle(
810+
extern struct power_supply *power_supply_get_by_reference(struct fwnode_handle *fwnode,
811+
const char *property);
812+
extern struct power_supply *devm_power_supply_get_by_reference(
814813
struct device *dev, const char *property);
815-
#else /* !CONFIG_OF */
816-
static inline struct power_supply *
817-
power_supply_get_by_phandle(struct device_node *np, const char *property)
818-
{ return NULL; }
819-
static inline struct power_supply *
820-
devm_power_supply_get_by_phandle(struct device *dev, const char *property)
821-
{ return NULL; }
822-
#endif /* CONFIG_OF */
823814

824815
extern const enum power_supply_property power_supply_battery_info_properties[];
825816
extern const size_t power_supply_battery_info_properties_size;

0 commit comments

Comments
 (0)