From: Viresh Kumar <viresh.kumar@linaro.org>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: rui.zhang@intel.com, rjw@rjwysocki.net, edubezval@gmail.com,
linux-pm@vger.kernel.org, amit.kucheria@linaro.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2 3/4] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver
Date: Tue, 3 Dec 2019 13:44:31 +0530 [thread overview]
Message-ID: <20191203081431.zddvzuaw2hx5e4u5@vireshk-i7> (raw)
In-Reply-To: <20191202202815.22731-3-daniel.lezcano@linaro.org>
On 02-12-19, 21:28, Daniel Lezcano wrote:
> +/**
> + * cpuidle_of_cooling_register - Idle cooling device initialization function
> + * @drv: a cpuidle driver structure pointer
@np missing here.
> + *
> + * This function is in charge of creating a cooling device per cpuidle
> + * driver and register it to thermal framework.
> + *
> + * Returns a valid pointer to a thermal cooling device, a PTR_ERR
s/, a/, or a/ ?
> + * corresponding to the error detected in the underlying subsystems.
> + */
> +struct thermal_cooling_device *
> +__init cpuidle_of_cooling_register(struct device_node *np,
> + struct cpuidle_driver *drv)
> +{
> + struct idle_inject_device *ii_dev;
> + struct cpuidle_cooling_device *idle_cdev;
> + struct thermal_cooling_device *cdev;
> + char dev_name[THERMAL_NAME_LENGTH];
> + int id, ret;
> +
> + idle_cdev = kzalloc(sizeof(*idle_cdev), GFP_KERNEL);
> + if (!idle_cdev) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + id = ida_simple_get(&cpuidle_ida, 0, 0, GFP_KERNEL);
> + if (id < 0) {
> + ret = id;
> + goto out_kfree;
> + }
> +
> + ii_dev = idle_inject_register(drv->cpumask);
> + if (IS_ERR(ii_dev)) {
> + ret = PTR_ERR(ii_dev);
> + goto out_id;
> + }
> +
> + idle_inject_set_duration(ii_dev, 0, TICK_USEC);
> +
> + idle_cdev->ii_dev = ii_dev;
> +
> + snprintf(dev_name, sizeof(dev_name), "thermal-idle-%d", id);
> +
> + cdev = thermal_of_cooling_device_register(np, dev_name, idle_cdev,
> + &cpuidle_cooling_ops);
> + if (IS_ERR(cdev)) {
> + ret = PTR_ERR(cdev);
> + goto out_unregister;
> + }
> +
> + return cdev;
> +
> +out_unregister:
> + idle_inject_unregister(ii_dev);
> +out_id:
> + ida_simple_remove(&cpuidle_ida, id);
> +out_kfree:
> + kfree(idle_cdev);
> +out:
> + return ERR_PTR(ret);
> +}
> +
> +/**
> + * cpuidle_cooling_register - Idle cooling device initialization function
> + * @drv: a cpuidle driver structure pointer
> + *
> + * This function is in charge of creating a cooling device per cpuidle
> + * driver and register it to thermal framework.
> + *
> + * Returns a valid pointer to a thermal cooling device, a PTR_ERR
> + * corresponding to the error detected in the underlying subsystems.
> + */
> +struct thermal_cooling_device *
> +__init cpuidle_cooling_register(struct cpuidle_driver *drv)
> +{
> + return cpuidle_of_cooling_register(NULL, drv);
> +}
> diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h
> index 3cdd85f987d7..da0970183d1f 100644
> --- a/include/linux/cpu_cooling.h
> +++ b/include/linux/cpu_cooling.h
> @@ -60,4 +60,26 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy)
> }
> #endif /* CONFIG_CPU_FREQ_THERMAL */
>
> +struct cpuidle_driver;
> +
> +#ifdef CONFIG_CPU_IDLE_THERMAL
> +extern struct thermal_cooling_device *
> +__init cpuidle_cooling_register(struct cpuidle_driver *drv);
> +extern struct thermal_cooling_device *
> +__init cpuidle_of_cooling_register(struct device_node *np,
> + struct cpuidle_driver *drv);
Maybe just drop the "extern" thing here as it is redundant really.
> +#else /* CONFIG_CPU_IDLE_THERMAL */
> +static inline struct thermal_cooling_device *
> +__init cpuidle_cooling_register(struct cpuidle_driver *drv)
> +{
> + return ERR_PTR(-EINVAL);
> +}
> +static inline struct thermal_cooling_device *
> +__init cpuidle_of_cooling_register(struct device_node *np,
> + struct cpuidle_driver *drv)
> +{
> + return ERR_PTR(-EINVAL);
> +}
> +#endif /* CONFIG_CPU_IDLE_THERMAL */
> +
> #endif /* __CPU_COOLING_H__ */
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
next prev parent reply other threads:[~2019-12-03 8:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-02 20:28 [PATCH V2 1/4] thermal/drivers/Kconfig: Convert the CPU cooling device to a choice Daniel Lezcano
2019-12-02 20:28 ` [PATCH V2 2/4] thermal/drivers/cpu_cooling: Add idle cooling device documentation Daniel Lezcano
2019-12-03 6:44 ` Viresh Kumar
2019-12-02 20:28 ` [PATCH V2 3/4] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver Daniel Lezcano
2019-12-03 8:14 ` Viresh Kumar [this message]
2019-12-03 8:24 ` Viresh Kumar
2019-12-02 20:28 ` [PATCH V2 4/4] thermal/drivers/cpu_cooling: Rename to cpufreq_cooling Daniel Lezcano
2019-12-03 8:20 ` Viresh Kumar
2019-12-03 6:43 ` [PATCH V2 1/4] thermal/drivers/Kconfig: Convert the CPU cooling device to a choice Viresh Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191203081431.zddvzuaw2hx5e4u5@vireshk-i7 \
--to=viresh.kumar@linaro.org \
--cc=amit.kucheria@linaro.org \
--cc=daniel.lezcano@linaro.org \
--cc=edubezval@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).