lkml.org 
[lkml]   [2019]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 2/3] thermal: improve error message in thermal zone registration
On Thu, Dec 5, 2019 at 12:50 PM Wei Wang <wvw@google.com> wrote:
>
> Follow up with commit 67eed44b8a8a ("thermal: Add some error messages")
> to clean up checkpatch warning on line length and also add more message
> for developers.
>
> Signed-off-by: Wei Wang <wvw@google.com>

Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>

> ---
> drivers/thermal/thermal_core.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 974e2d91c30b..9db7f72e70f8 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1255,29 +1255,33 @@ thermal_zone_device_register(const char *type, int trips, int mask,
> int count;
> struct thermal_governor *governor;
>
> - if (!type || strlen(type) == 0) {
> + if (!type || !type[0]) {
> pr_err("Error: No thermal zone type defined\n");
> return ERR_PTR(-EINVAL);
> }
>
> - if (type && strlen(type) >= THERMAL_NAME_LENGTH) {
> - pr_err("Error: Thermal zone name (%s) too long, should be under %d chars\n",
> - type, THERMAL_NAME_LENGTH);
> + if (strlen(type) >= THERMAL_NAME_LENGTH) {
> + pr_err("Error: Thermal zone name over %d chars: %s\n",
> + THERMAL_NAME_LENGTH, type);
> return ERR_PTR(-EINVAL);
> }
>
> if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) {
> - pr_err("Error: Incorrect number of thermal trips\n");
> + pr_err("Error: Incorrect number of thermal trips: %s\n", type);
> return ERR_PTR(-EINVAL);
> }
>
> if (!ops) {
> - pr_err("Error: Thermal zone device ops not defined\n");
> + pr_err("Error: Thermal zone device ops not defined: %s\n",
> + type);
> return ERR_PTR(-EINVAL);
> }
>
> - if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp))
> + if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) {
> + pr_err("Error: Thermal zone device missing callback: %s\n",
> + type);
> return ERR_PTR(-EINVAL);
> + }
>
> tz = kzalloc(sizeof(*tz), GFP_KERNEL);
> if (!tz)
> --
> 2.24.0.393.g34dc348eaf-goog
>

\
 
 \ /
  Last update: 2019-12-09 08:42    [W:0.110 / U:2.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site