Skip to content

Commit

Permalink
PM / devfreq: exynos-bus: Extract exynos_bus_profile_init()
Browse files Browse the repository at this point in the history
This patch adds a new exynos_bus_profile_init() extracted
from exynos_bus_probe() for devfreq device using simple_ondemand governor
like parent devfreq device.

Signed-off-by: Artur Świgoń <a.swigon@samsung.com>
[cw00.choi: Edit description to indicate that new function is
for parent devfreq device]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
  • Loading branch information
Artur Świgoń authored and chanwoochoi committed Dec 30, 2019
1 parent f9002b1 commit a47a97e
Showing 1 changed file with 58 additions and 44 deletions.
102 changes: 58 additions & 44 deletions drivers/devfreq/exynos-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,52 +287,12 @@ static int exynos_bus_parse_of(struct device_node *np,
return ret;
}

static int exynos_bus_probe(struct platform_device *pdev)
static int exynos_bus_profile_init(struct exynos_bus *bus,
struct devfreq_dev_profile *profile)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node, *node;
struct devfreq_dev_profile *profile;
struct device *dev = bus->dev;
struct devfreq_simple_ondemand_data *ondemand_data;
struct devfreq_passive_data *passive_data;
struct devfreq *parent_devfreq;
struct exynos_bus *bus;
int ret, max_state;
unsigned long min_freq, max_freq;
bool passive = false;

if (!np) {
dev_err(dev, "failed to find devicetree node\n");
return -EINVAL;
}

bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL);
if (!bus)
return -ENOMEM;
mutex_init(&bus->lock);
bus->dev = &pdev->dev;
platform_set_drvdata(pdev, bus);

profile = devm_kzalloc(dev, sizeof(*profile), GFP_KERNEL);
if (!profile)
return -ENOMEM;

node = of_parse_phandle(dev->of_node, "devfreq", 0);
if (node) {
of_node_put(node);
passive = true;
} else {
ret = exynos_bus_parent_parse_of(np, bus);
if (ret < 0)
return ret;
}

/* Parse the device-tree to get the resource information */
ret = exynos_bus_parse_of(np, bus);
if (ret < 0)
goto err_reg;

if (passive)
goto passive;
int ret;

/* Initialize the struct profile and governor data for parent device */
profile->polling_ms = 50;
Expand Down Expand Up @@ -381,6 +341,60 @@ static int exynos_bus_probe(struct platform_device *pdev)
goto err;
}

err:
return ret;
}

static int exynos_bus_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node, *node;
struct devfreq_dev_profile *profile;
struct devfreq_passive_data *passive_data;
struct devfreq *parent_devfreq;
struct exynos_bus *bus;
int ret, max_state;
unsigned long min_freq, max_freq;
bool passive = false;

if (!np) {
dev_err(dev, "failed to find devicetree node\n");
return -EINVAL;
}

bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL);
if (!bus)
return -ENOMEM;
mutex_init(&bus->lock);
bus->dev = &pdev->dev;
platform_set_drvdata(pdev, bus);

profile = devm_kzalloc(dev, sizeof(*profile), GFP_KERNEL);
if (!profile)
return -ENOMEM;

node = of_parse_phandle(dev->of_node, "devfreq", 0);
if (node) {
of_node_put(node);
passive = true;
} else {
ret = exynos_bus_parent_parse_of(np, bus);
if (ret < 0)
return ret;
}

/* Parse the device-tree to get the resource information */
ret = exynos_bus_parse_of(np, bus);
if (ret < 0)
goto err_reg;

if (passive)
goto passive;

ret = exynos_bus_profile_init(bus, profile);
if (ret < 0)
goto err;

goto out;
passive:
/* Initialize the struct profile and governor data for passive device */
Expand Down

0 comments on commit a47a97e

Please sign in to comment.