Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1343627ybl; Wed, 4 Dec 2019 23:06:57 -0800 (PST) X-Google-Smtp-Source: APXvYqx8YQqfepXZ4zxYLLCdg5TOh9RirO1YidZd1hNCUtWWxtX27/Rx9D4Mti+HAPvOBqi7TDtS X-Received: by 2002:aca:f5cc:: with SMTP id t195mr6092873oih.163.1575529617853; Wed, 04 Dec 2019 23:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575529617; cv=none; d=google.com; s=arc-20160816; b=HV3jKtmAGAML+iKUmEuCxXzHMtAuQ0imbSyiGmfBmK+lw0RkoWzGTxkRIh/zmZkyGT AFfGMaN/TW4Mnkajv25UJe6rZw+c3UG+dX19V8cN4zH3LrdXzueZIM+Bc5PSuF3FpUni fdtSe+DnGsViNswyAY61ZZT+3tlUfETR9sHBE5B6k2WHSLLegzvngQvz9FFmWXUs8Uh2 hqtK5Ls+Xd0nO7NMgGbXTKngNCTdrP0Qt4Zwdvaz/17fnrXUsVVkxh1Vn8xseL159iEs +ii7Ckoo0HN81EflVbsCLzUz5zgqbna2M5M1T2+k9L4rOJp2EsDuwgi82uLu7BgtOcLs DFxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=48H2Q0jce9hn5rPUGQ82lc7wKpQZ76ct4p8NjtF+Ank=; b=N3hbdlIp7+TsprIhzO1GTiehQi0fHT9+TNUi7dkdDOQka1eafbpHdfO9L5f7Rn+Kyc cllSlrKe5Q8SuM1V2WTqss9otdSe+ZNmK/rjINarrwH7tCFQPAM5GW4f+foe5vJSDpKe xVcOEYFkrIGYhlWaebVCZ0/KQ5p++FG+lQRzIUYMOAqYvUR/r6QcKudlcd74mK6DsuPW YPTW5RQbf5uEHIUiW9D8TeIu7b0TzLEU2oVSz6fJYf4xgErJsrtl7FGkL/Bcu1MmZhPT yy+ivwwCLlYsWdzOnr3h9yl8ShJh/YPwfs3YbEOgHS1bUELgYfWpMm8qrkXuNyePzDJS S9QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=cSwCAmAh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z18si4367509otq.121.2019.12.04.23.06.44; Wed, 04 Dec 2019 23:06:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=cSwCAmAh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726032AbfLEHGO (ORCPT + 99 others); Thu, 5 Dec 2019 02:06:14 -0500 Received: from mail-ua1-f68.google.com ([209.85.222.68]:42541 "EHLO mail-ua1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbfLEHGN (ORCPT ); Thu, 5 Dec 2019 02:06:13 -0500 Received: by mail-ua1-f68.google.com with SMTP id 31so839264uas.9 for ; Wed, 04 Dec 2019 23:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verdurent-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=48H2Q0jce9hn5rPUGQ82lc7wKpQZ76ct4p8NjtF+Ank=; b=cSwCAmAhhA34fp0Z+ZFycH7GsX4J14HDAlz/cvLxWTGHVoYtg9rfokW3BLdHPH6dcv /jw2LyCRANBXWPJ/IvdnvPakkj33hzDx9xaEXaBNudPdCk6XcHUD1XY1VQ7KUlg01Nzf 2OmoQ6D9S3BDYtkknoVRwztIt1INWToD/eFSA8C0ccdsQBi0ndiyQsGD2WkS2xkehwzs r4M6YfmDGwmJ+zVmko9ucf74ySszsSALebJWqGaQNh3Nrfrhra6SSwmLGh5aCnEWiYyW JCByf0CyQ7mjw4F55PQxDSNEHSDaYtQhCTsJhMtAFKDeTiekrXiCyZd3r8J6TXwIeKMq q5mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=48H2Q0jce9hn5rPUGQ82lc7wKpQZ76ct4p8NjtF+Ank=; b=BTG832H/rHtvfpTqs8gdjejZSb8TF0dT2Vvw1dhVM88qQF2GOt+Ao1qwS5QAvJAa2F JhpObXj6auwkZTaXL50PzMB9EimzOxbBwA3fRV1ohiSgNY+gfwQyAslA74LWgR02hw65 I2exhEwSofCIp5Bw1p22UGR3/m2cdVdJq3nFlN+rSa4m3fmvZtS0Rb3Vm97McBLCukY+ fE/vWJYcwKuq53kMsLmDbVRCIGZRZK9C3aoYqvIAp+iBmW1rJNnodu/AvPI1XQ836yDb vlpYNE3EUe1qEXmgKEITOnZyGuaNHxn+M3jaTAyUK+ieNENFX7/Z+UWSa4T8J17s50Lk 3b8w== X-Gm-Message-State: APjAAAXOjSIlCeqjlcmrupR9wgdDF3B0EF85fflUAoT6WISUXtWjUhlP zrZjDJ58jlDb2YuG/T6QdHFsXQx75QEFgAGKUxjtaA== X-Received: by 2002:ab0:7352:: with SMTP id k18mr5729489uap.77.1575529572190; Wed, 04 Dec 2019 23:06:12 -0800 (PST) MIME-Version: 1.0 References: <20191204215618.125826-1-wvw@google.com> <20191204215618.125826-2-wvw@google.com> In-Reply-To: From: Amit Kucheria Date: Thu, 5 Dec 2019 12:36:01 +0530 Message-ID: Subject: Re: [PATCH v2 1/2] thermal: fix and clean up tz and cdev registration To: Wei Wang Cc: Wei Wang , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Linux PM list , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 5, 2019 at 11:56 AM Amit Kucheria wrote: > > On Thu, Dec 5, 2019 at 11:44 AM Wei Wang wrote: > > > > On Wed, Dec 4, 2019 at 8:13 PM Amit Kucheria > > wrote: > > > > > > Hi Wei, > > > > > > On Thu, Dec 5, 2019 at 3:26 AM Wei Wang wrote: > > > > > > > > Make cooling device registration behavior consistent with > > > > > > Consistent how? Please add details. > > > > > Consistent with > > https://lore.kernel.org/linux-pm/1478581767-7009-2-git-send-email-edubezval@gmail.com/ Studying this a bit more, git blame pointed to this SHA[1] that fixed it so that NULL value for 'type' is allowed, we just check for it. However, none of the users of thermal_cooling_device_register() seem to pass NULL. Rui, any insight into the history of why we would NOT want to create a sysfs attribute by passing NULL? Do we still need to allow for NULL values or should we cleanup the API to prevent NULL values? [1] 204dd1d39c32f39a95 > > > > will include aboce in next version. > > Thanks. > > > > > > > thermal zone. This patch also cleans up a unnecessary > > > > nullptr check. > > > > > > > > Signed-off-by: Wei Wang > > > > --- > > > > drivers/thermal/thermal_core.c | 16 ++++++++++++---- > > > > 1 file changed, 12 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > > > > index d4481cc8958f..64fbb59c2f44 100644 > > > > --- a/drivers/thermal/thermal_core.c > > > > +++ b/drivers/thermal/thermal_core.c > > > > @@ -954,8 +954,16 @@ __thermal_cooling_device_register(struct device_node *np, > > > > struct thermal_zone_device *pos = NULL; > > > > int result; > > > > > > > > - if (type && strlen(type) >= THERMAL_NAME_LENGTH) > > > > - return ERR_PTR(-EINVAL); > > > > + if (!type || !type[0]) { > > > > + pr_err("Error: No cooling device type defined\n"); > > > > + return ERR_PTR(-EINVAL); > > > > + } > > > > + > > > > + if (strlen(type) >= THERMAL_NAME_LENGTH) { > > > > + pr_err("Error: Cooling device name (%s) too long, " > > > > + "should be under %d chars\n", type, THERMAL_NAME_LENGTH); > > > > > > Consider fitting into a single greppable string as "Error: Cooling > > > device name over %d chars: %s\n" > > > > > Was intentionally keep it the same as this > > https://lore.kernel.org/linux-pm/31a29628894a14e716fff113fd9ce945fe649c05.1562876950.git.amit.kucheria@linaro.org/ > > Will make it shorter in both places next verion > > Yes please, make it a separate patch. We didn't catch it during review. > > > > > > > + return ERR_PTR(-EINVAL); > > > > + } > > > > > > > > if (!ops || !ops->get_max_state || !ops->get_cur_state || > > > > !ops->set_cur_state) > > > > @@ -972,7 +980,7 @@ __thermal_cooling_device_register(struct device_node *np, > > > > } > > > > > > > > cdev->id = result; > > > > - strlcpy(cdev->type, type ? : "", sizeof(cdev->type)); > > > > + strlcpy(cdev->type, type, sizeof(cdev->type)); > > > > mutex_init(&cdev->lock); > > > > INIT_LIST_HEAD(&cdev->thermal_instances); > > > > cdev->np = np; > > > > @@ -1250,7 +1258,7 @@ thermal_zone_device_register(const char *type, int trips, int mask, > > > > return ERR_PTR(-EINVAL); > > > > } > > > > > > > > - if (type && strlen(type) >= THERMAL_NAME_LENGTH) { > > > > + if (strlen(type) >= THERMAL_NAME_LENGTH) { > > > > pr_err("Error: Thermal zone name (%s) too long, should be under %d chars\n", > > > > type, THERMAL_NAME_LENGTH); > > > > return ERR_PTR(-EINVAL); > > > > -- > > > > 2.24.0.393.g34dc348eaf-goog > > > >