Re: [PATCH v3 2/3] thermal: improve error message in thermal zone registration

From: Amit Kucheria
Date: Mon Dec 09 2019 - 02:41:59 EST


On Thu, Dec 5, 2019 at 12:50 PM Wei Wang <wvw@xxxxxxxxxx> 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@xxxxxxxxxx>

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

> ---
> 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
>