Skip to content

Commit

Permalink
PM / devfreq: Change prototype of devfreq_get_devfreq_by_phandle func…
Browse files Browse the repository at this point in the history
…tion

Previously, devfreq core support 'devfreq' property in order to get
the devfreq device by phandle. But, 'devfreq' property name is not proper
on devicetree binding because this name doesn't mean the any h/w attribute.

The devfreq core hand over the right to decide the property name
for getting the devfreq device on devicetree. Each devfreq driver
will decide the property name on devicetree binding and pass
the their own property name to devfreq_get_devfreq_by_phandle function.

Acked-by: Krzysztof Kozlowski <[email protected]>
Signed-off-by: Chanwoo Choi <[email protected]>
  • Loading branch information
chanwoochoi committed Sep 29, 2020
1 parent 7b38b7b commit 86d90fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
11 changes: 7 additions & 4 deletions drivers/devfreq/devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,22 +1012,24 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
/*
* devfreq_get_devfreq_by_phandle - Get the devfreq device from devicetree
* @dev - instance to the given device
* @phandle_name - name of property holding a phandle value
* @index - index into list of devfreq
*
* return the instance of devfreq device
*/
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index)
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
const char *phandle_name, int index)
{
struct device_node *node;
struct devfreq *devfreq;

if (!dev)
if (!dev || !phandle_name)
return ERR_PTR(-EINVAL);

if (!dev->of_node)
return ERR_PTR(-EINVAL);

node = of_parse_phandle(dev->of_node, "devfreq", index);
node = of_parse_phandle(dev->of_node, phandle_name, index);
if (!node)
return ERR_PTR(-ENODEV);

Expand All @@ -1043,7 +1045,8 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
return ERR_PTR(-ENODEV);
}

struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index)
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
const char *phandle_name, int index)
{
return ERR_PTR(-ENODEV);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/devfreq/exynos-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
profile->exit = exynos_bus_passive_exit;

/* Get the instance of parent devfreq device */
parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
parent_devfreq = devfreq_get_devfreq_by_phandle(dev, "devfreq", 0);
if (IS_ERR(parent_devfreq))
return -EPROBE_DEFER;

Expand Down
5 changes: 3 additions & 2 deletions include/linux/devfreq.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ void devm_devfreq_unregister_notifier(struct device *dev,
struct notifier_block *nb,
unsigned int list);
struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node);
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index);
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
const char *phandle_name, int index);

#if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
/**
Expand Down Expand Up @@ -421,7 +422,7 @@ static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *no
}

static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
int index)
const char *phandle_name, int index)
{
return ERR_PTR(-ENODEV);
}
Expand Down

0 comments on commit 86d90fd

Please sign in to comment.