2013-04-23 21:49:04

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCHv2 0/9] thermal: clean ups on thermal code base

Hello Rui,

This is v2 of this series. I have worked on the comments you sent
on these patches. For your reference, v1 has been reviewed at [1].

Summary of changelog:
- Added your acked-by on those patches you granted.
- Fixed the comments regarding functions that are not going
to be exported.
- Removed patches that are touching functions that are not
going to be exported.

Also available, as usual, here:
[email protected]:thermal-framework/thermal-framework.git thermal_work/thermal_core/coding_style
https://git.gitorious.org/thermal-framework/thermal-framework.git thermal_work/thermal_core/coding_style

The above branches are based on linux-next/master.

All best,

[1] - https://lkml.org/lkml/2013/4/8/471

Eduardo Valentin (9):
thermal: use strlcpy instead of strcpy
thermal: update driver license
thermal: rename notify_thermal_framework to thermal_notify_framework
thermal: use EXPORT_SYMBOL_GPL
thermal: update kernel-doc for thermal_zone_bind_cooling_device
thermal: update kernel-doc for thermal_zone_unbind_cooling_device
thermal: update kernel-doc for thermal_cooling_device_register
thermal: update kernel-doc for create_trip_attrs
thermal: update kernel-doc for thermal_zone_device_register

Documentation/thermal/sysfs-api.txt | 2 +-
drivers/thermal/thermal_core.c | 80 ++++++++++++++++++++++++++-----------
include/linux/thermal.h | 2 +-
3 files changed, 59 insertions(+), 25 deletions(-)

--
1.8.2.1.342.gfa7285d


2013-04-23 21:49:24

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCHv2 1/9] thermal: use strlcpy instead of strcpy

For memory boundaries safety, use strlcpy instead of strcpy.

Acked-by: Zhang Rui <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
---
drivers/thermal/thermal_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 4cdc3e3..bea3884 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1287,7 +1287,7 @@ thermal_cooling_device_register(char *type, void *devdata,
return ERR_PTR(result);
}

- strcpy(cdev->type, type ? : "");
+ strlcpy(cdev->type, type ? : "", sizeof(cdev->type));
mutex_init(&cdev->lock);
INIT_LIST_HEAD(&cdev->thermal_instances);
cdev->ops = ops;
@@ -1592,7 +1592,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
return ERR_PTR(result);
}

- strcpy(tz->type, type ? : "");
+ strlcpy(tz->type, type ? : "", sizeof(tz->type));
tz->ops = ops;
tz->tzp = tzp;
tz->device.class = &thermal_class;
--
1.8.2.1.342.gfa7285d

2013-04-23 21:49:44

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCHv2 2/9] thermal: update driver license

As per the comment at the top of this file, this is a GPLv2 driver.
This patch updates the driver license accordingly.

Acked-by: Zhang Rui <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
---
drivers/thermal/thermal_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index bea3884..a999b22 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -40,7 +40,7 @@

MODULE_AUTHOR("Zhang Rui");
MODULE_DESCRIPTION("Generic thermal management sysfs support");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");

static DEFINE_IDR(thermal_tz_idr);
static DEFINE_IDR(thermal_cdev_idr);
--
1.8.2.1.342.gfa7285d

2013-04-23 21:50:10

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCHv2 3/9] thermal: rename notify_thermal_framework to thermal_notify_framework

To follow the prefix names used by the thermal functions,
this patch renames notify_thermal_framework to thermal_notify_framework.

Acked-by: Zhang Rui <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
---
Documentation/thermal/sysfs-api.txt | 2 +-
drivers/thermal/thermal_core.c | 6 +++---
include/linux/thermal.h | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.txt
index b2ffe98..bb42266 100644
--- a/Documentation/thermal/sysfs-api.txt
+++ b/Documentation/thermal/sysfs-api.txt
@@ -367,7 +367,7 @@ This function returns the thermal_instance corresponding to a given
{thermal_zone, cooling_device, trip_point} combination. Returns NULL
if such an instance does not exist.

-5.3:notify_thermal_framework:
+5.3:thermal_notify_framework:
This function handles the trip events from sensor drivers. It starts
throttling the cooling devices according to the policy configured.
For CRITICAL and HOT trip points, this notifies the respective drivers,
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index a999b22..b54f916 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1418,7 +1418,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)
EXPORT_SYMBOL(thermal_cdev_update);

/**
- * notify_thermal_framework - Sensor drivers use this API to notify framework
+ * thermal_notify_framework - Sensor drivers use this API to notify framework
* @tz: thermal zone device
* @trip: indicates which trip point has been crossed
*
@@ -1429,11 +1429,11 @@ EXPORT_SYMBOL(thermal_cdev_update);
* The throttling policy is based on the configured platform data; if no
* platform data is provided, this uses the step_wise throttling policy.
*/
-void notify_thermal_framework(struct thermal_zone_device *tz, int trip)
+void thermal_notify_framework(struct thermal_zone_device *tz, int trip)
{
handle_thermal_trip(tz, trip);
}
-EXPORT_SYMBOL(notify_thermal_framework);
+EXPORT_SYMBOL(thermal_notify_framework);

/**
* create_trip_attrs - create attributes for trip points
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 45c3917..8a1a5a4 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -244,7 +244,7 @@ int get_tz_trend(struct thermal_zone_device *, int);
struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
struct thermal_cooling_device *, int);
void thermal_cdev_update(struct thermal_cooling_device *);
-void notify_thermal_framework(struct thermal_zone_device *, int);
+void thermal_notify_framework(struct thermal_zone_device *, int);

#ifdef CONFIG_NET
extern int thermal_generate_netlink_event(struct thermal_zone_device *tz,
--
1.8.2.1.342.gfa7285d

2013-04-23 21:50:27

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCHv2 4/9] thermal: use EXPORT_SYMBOL_GPL

Restrict usage of GPL modules.

Acked-by: Zhang Rui <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
---
drivers/thermal/thermal_core.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index b54f916..3f39672 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -432,7 +432,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
for (count = 0; count < tz->trips; count++)
handle_thermal_trip(tz, count);
}
-EXPORT_SYMBOL(thermal_zone_device_update);
+EXPORT_SYMBOL_GPL(thermal_zone_device_update);

static void thermal_zone_device_check(struct work_struct *work)
{
@@ -1195,7 +1195,7 @@ free_mem:
kfree(dev);
return result;
}
-EXPORT_SYMBOL(thermal_zone_bind_cooling_device);
+EXPORT_SYMBOL_GPL(thermal_zone_bind_cooling_device);

/**
* thermal_zone_unbind_cooling_device - unbind a cooling device from a thermal zone
@@ -1235,7 +1235,7 @@ unbind:
kfree(pos);
return 0;
}
-EXPORT_SYMBOL(thermal_zone_unbind_cooling_device);
+EXPORT_SYMBOL_GPL(thermal_zone_unbind_cooling_device);

static void thermal_release(struct device *dev)
{
@@ -1332,7 +1332,7 @@ unregister:
device_unregister(&cdev->device);
return ERR_PTR(result);
}
-EXPORT_SYMBOL(thermal_cooling_device_register);
+EXPORT_SYMBOL_GPL(thermal_cooling_device_register);

/**
* thermal_cooling_device_unregister - removes the registered thermal cooling device
@@ -1392,7 +1392,7 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
device_unregister(&cdev->device);
return;
}
-EXPORT_SYMBOL(thermal_cooling_device_unregister);
+EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister);

void thermal_cdev_update(struct thermal_cooling_device *cdev)
{
@@ -1433,7 +1433,7 @@ void thermal_notify_framework(struct thermal_zone_device *tz, int trip)
{
handle_thermal_trip(tz, trip);
}
-EXPORT_SYMBOL(thermal_notify_framework);
+EXPORT_SYMBOL_GPL(thermal_notify_framework);

/**
* create_trip_attrs - create attributes for trip points
@@ -1685,7 +1685,7 @@ unregister:
device_unregister(&tz->device);
return ERR_PTR(result);
}
-EXPORT_SYMBOL(thermal_zone_device_register);
+EXPORT_SYMBOL_GPL(thermal_zone_device_register);

/**
* thermal_device_unregister - removes the registered thermal zone device
@@ -1752,7 +1752,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
device_unregister(&tz->device);
return;
}
-EXPORT_SYMBOL(thermal_zone_device_unregister);
+EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);

#ifdef CONFIG_NET
static struct genl_family thermal_event_genl_family = {
@@ -1830,7 +1830,7 @@ int thermal_generate_netlink_event(struct thermal_zone_device *tz,

return result;
}
-EXPORT_SYMBOL(thermal_generate_netlink_event);
+EXPORT_SYMBOL_GPL(thermal_generate_netlink_event);

static int genetlink_init(void)
{
--
1.8.2.1.342.gfa7285d

2013-04-23 21:50:53

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCHv2 5/9] thermal: update kernel-doc for thermal_zone_bind_cooling_device

This patch updates the documentation for thermal_zone_bind_cooling_device
and removes the warnings generated by scripts/kernel-doc -v.

Acked-by: Zhang Rui <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
---
drivers/thermal/thermal_core.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 3f39672..b417bc8 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1095,13 +1095,23 @@ thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
#endif

/**
- * thermal_zone_bind_cooling_device - bind a cooling device to a thermal zone
- * @tz: thermal zone device
+ * thermal_zone_bind_cooling_device() - bind a cooling device to a thermal zone
+ * @tz: pointer to struct thermal_zone_device
* @trip: indicates which trip point the cooling devices is
* associated with in this thermal zone.
- * @cdev: thermal cooling device
+ * @cdev: pointer to struct thermal_cooling_device
+ * @upper: the Maximum cooling state for this trip point.
+ * THERMAL_NO_LIMIT means no upper limit,
+ * and the cooling device can be in max_state.
+ * @lower: the Minimum cooling state can be used for this trip point.
+ * THERMAL_NO_LIMIT means no lower limit,
+ * and the cooling device can be in cooling state 0.
*
+ * This interface function bind a thermal cooling device to the certain trip
+ * point of a thermal zone device.
* This function is usually called in the thermal zone device .bind callback.
+ *
+ * Return: 0 on success, the proper error value otherwise.
*/
int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
int trip,
--
1.8.2.1.342.gfa7285d

2013-04-23 21:51:08

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCHv2 6/9] thermal: update kernel-doc for thermal_zone_unbind_cooling_device

This patch updates the documentation for thermal_zone_unbind_cooling_device
and removes the warnings generated by scripts/kernel-doc -v.

Acked-by: Zhang Rui <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
---
drivers/thermal/thermal_core.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index b417bc8..4171170 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1208,13 +1208,18 @@ free_mem:
EXPORT_SYMBOL_GPL(thermal_zone_bind_cooling_device);

/**
- * thermal_zone_unbind_cooling_device - unbind a cooling device from a thermal zone
- * @tz: thermal zone device
+ * thermal_zone_unbind_cooling_device() - unbind a cooling device from a
+ * thermal zone.
+ * @tz: pointer to a struct thermal_zone_device.
* @trip: indicates which trip point the cooling devices is
* associated with in this thermal zone.
- * @cdev: thermal cooling device
+ * @cdev: pointer to a struct thermal_cooling_device.
*
+ * This interface function unbind a thermal cooling device from the certain
+ * trip point of a thermal zone device.
* This function is usually called in the thermal zone device .unbind callback.
+ *
+ * Return: 0 on success, the proper error value otherwise.
*/
int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
int trip,
--
1.8.2.1.342.gfa7285d

2013-04-23 21:51:30

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCHv2 7/9] thermal: update kernel-doc for thermal_cooling_device_register

This patch updates the documentation for thermal_cooling_device_register
and removes the warnings generated by scripts/kernel-doc -v.

Acked-by: Zhang Rui <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
---
drivers/thermal/thermal_core.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 4171170..1f9b9f9 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1273,10 +1273,17 @@ static struct class thermal_class = {
};

/**
- * thermal_cooling_device_register - register a new thermal cooling device
+ * thermal_cooling_device_register() - register a new thermal cooling device
* @type: the thermal cooling device type.
* @devdata: device private data.
* @ops: standard thermal cooling devices callbacks.
+ *
+ * This interface function adds a new thermal cooling device (fan/processor/...)
+ * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
+ * to all the thermal zone devices registered at the same time.
+ *
+ * Return: a pointer to the created struct thermal_cooling_device or an
+ * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
*/
struct thermal_cooling_device *
thermal_cooling_device_register(char *type, void *devdata,
--
1.8.2.1.342.gfa7285d

2013-04-23 21:51:50

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCHv2 8/9] thermal: update kernel-doc for create_trip_attrs

This patch updates the documentation for create_trip_attrs
and removes the warnings generated by scripts/kernel-doc -v.

Acked-by: Zhang Rui <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
---
drivers/thermal/thermal_core.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 1f9b9f9..be07261 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1458,9 +1458,14 @@ void thermal_notify_framework(struct thermal_zone_device *tz, int trip)
EXPORT_SYMBOL_GPL(thermal_notify_framework);

/**
- * create_trip_attrs - create attributes for trip points
+ * create_trip_attrs() - create attributes for trip points
* @tz: the thermal zone device
* @mask: Writeable trip point bitmap.
+ *
+ * helper function to instantiate sysfs entries for every trip
+ * point and its properties of a struct thermal_zone_device.
+ *
+ * Return: 0 on success, the proper error value otherwise.
*/
static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
{
--
1.8.2.1.342.gfa7285d

2013-04-23 21:52:12

by Eduardo Valentin

[permalink] [raw]
Subject: [PATCHv2 9/9] thermal: update kernel-doc for thermal_zone_device_register

This patch updates the documentation for thermal_zone_device_register
and removes the warnings generated by scripts/kernel-doc -v.

Acked-by: Zhang Rui <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
---
drivers/thermal/thermal_core.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index be07261..654e983 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1566,7 +1566,7 @@ static void remove_trip_attrs(struct thermal_zone_device *tz)
}

/**
- * thermal_zone_device_register - register a new thermal zone device
+ * thermal_zone_device_register() - register a new thermal zone device
* @type: the thermal zone device type
* @trips: the number of trip points the thermal zone support
* @mask: a bit string indicating the writeablility of trip points
@@ -1579,8 +1579,15 @@ static void remove_trip_attrs(struct thermal_zone_device *tz)
* whether trip points have been crossed (0 for interrupt
* driven systems)
*
+ * This interface function adds a new thermal zone device (sensor) to
+ * /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the
+ * thermal cooling devices registered at the same time.
* thermal_zone_device_unregister() must be called when the device is no
* longer needed. The passive cooling depends on the .get_trend() return value.
+ *
+ * Return: a pointer to the created struct thermal_zone_device or an
+ * in case of error, an ERR_PTR. Caller must check return value with
+ * IS_ERR*() helpers.
*/
struct thermal_zone_device *thermal_zone_device_register(const char *type,
int trips, int mask, void *devdata,
--
1.8.2.1.342.gfa7285d

2013-04-24 16:54:48

by Zhang Rui

[permalink] [raw]
Subject: RE: [PATCHv2 0/9] thermal: clean ups on thermal code base

Hi, Eduardo,

> -----Original Message-----
> From: [email protected] [mailto:linux-pm-
> [email protected]] On Behalf Of Eduardo Valentin
> Sent: Wednesday, April 24, 2013 5:48 AM
> To: Zhang, Rui
> Cc: [email protected]; [email protected]; Eduardo
> Valentin
> Subject: [PATCHv2 0/9] thermal: clean ups on thermal code base
> Importance: High
>
> Hello Rui,
>
> This is v2 of this series. I have worked on the comments you sent on
> these patches. For your reference, v1 has been reviewed at [1].
>
All the patches in this series has been applied.

Thanks,
rui

> Summary of changelog:
> - Added your acked-by on those patches you granted.
> - Fixed the comments regarding functions that are not going to be
> exported.
> - Removed patches that are touching functions that are not going to be
> exported.
>
> Also available, as usual, here:
> [email protected]:thermal-framework/thermal-framework.git
> thermal_work/thermal_core/coding_style
> https://git.gitorious.org/thermal-framework/thermal-framework.git
> thermal_work/thermal_core/coding_style
>
> The above branches are based on linux-next/master.
>
> All best,
>
> [1] - https://lkml.org/lkml/2013/4/8/471
>
> Eduardo Valentin (9):
> thermal: use strlcpy instead of strcpy
> thermal: update driver license
> thermal: rename notify_thermal_framework to thermal_notify_framework
> thermal: use EXPORT_SYMBOL_GPL
> thermal: update kernel-doc for thermal_zone_bind_cooling_device
> thermal: update kernel-doc for thermal_zone_unbind_cooling_device
> thermal: update kernel-doc for thermal_cooling_device_register
> thermal: update kernel-doc for create_trip_attrs
> thermal: update kernel-doc for thermal_zone_device_register
>
> Documentation/thermal/sysfs-api.txt | 2 +-
> drivers/thermal/thermal_core.c | 80 ++++++++++++++++++++++++++---
> --------
> include/linux/thermal.h | 2 +-
> 3 files changed, 59 insertions(+), 25 deletions(-)
>
> --
> 1.8.2.1.342.gfa7285d
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to [email protected] More majordomo info
> at http://vger.kernel.org/majordomo-info.html