[v3,2/3] thermal: improve error message in thermal zone registration
diff mbox series

Message ID 20191205071953.121511-3-wvw@google.com
State Accepted, archived
Delegated to: Zhang Rui
Headers show
Series
  • thermal: introduce by-name softlink
Related show

Commit Message

Wei Wang Dec. 5, 2019, 7:19 a.m. UTC
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>
---
 drivers/thermal/thermal_core.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Amit Kucheria Dec. 9, 2019, 7:41 a.m. UTC | #1
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
>

Patch
diff mbox series

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)