Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1228285ybl; Wed, 4 Dec 2019 20:14:27 -0800 (PST) X-Google-Smtp-Source: APXvYqzFjkVXrlocZ2tlQ9OrnOWRDjf2Sf3EVLV3gSNVTpwg0wrQdhDVe0QOhhxkW7CHI+8LSsqt X-Received: by 2002:aca:ecd0:: with SMTP id k199mr5852098oih.158.1575519267401; Wed, 04 Dec 2019 20:14:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575519267; cv=none; d=google.com; s=arc-20160816; b=IBsUXB22Ib3rmU2nFvoceW29O+yCLG2igUksTKf83KO5eBDiLcB7Mcofziaf7HQKFd bTuajdE7Ogj0lTRfrlZpFzYJYia55ZWfLr8YREhjsQikwpThK/b7cwLMGY/e+AK3nLRE d0Ffh57oE4jkEzkWKw5LO2EdeGvmPpqkEHasnPf8QVvJoiLoEfQaqmI6nd6JXzz5qviw +dHgxzHPq2EvynwynQh9GZDoCbohh1MYjG0x2kcGqBSn7KfEMHFn9icZyopupCFvSj2V J2Z2JQ8mmpXo/AvLxEZzx3nOaPLJtOUEAI4EvApISMyInSKw6+awKHqbCe8QspNTqEhP N3cQ== 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=JxvM8PAlC3uvNhbaAB15+7WItiOZ6wH5Zn3knWGZWuw=; b=QyboWyCAyIHhIDt+4JNt+yQAnTUu3j4uhqAGCXBqWlm/pcVsltZEdi2FvxWeA7aB8d lRpXKCZ79SaFXaCPN3NS9HZxfZdGYc0ho7q6nw7fv5EFHsnqex8812vOiNXKLLkeLBnX KrooohC4H/urM8Sw+jH0WuKeVDb7DZohW93YWzu36PQrh101hL6kh7Ar1RsZ2FV4lD/h tN2M0/KS0P6VmlMcVIq5haW7iBb0OZ7sMIEg7o7Ddjr4vy+KPwNXYQCNI11DymkkINbE 8YNQA8m46PKJvulou4Q6j/7LZ/rf/47yxnexodIM+guSV515ZD7KQfryOsn5GNNASumF x3mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=kCXSBxmL; 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 17si4411719oix.71.2019.12.04.20.14.15; Wed, 04 Dec 2019 20:14:27 -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=kCXSBxmL; 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 S1728539AbfLEENt (ORCPT + 99 others); Wed, 4 Dec 2019 23:13:49 -0500 Received: from mail-ua1-f67.google.com ([209.85.222.67]:42598 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLEENs (ORCPT ); Wed, 4 Dec 2019 23:13:48 -0500 Received: by mail-ua1-f67.google.com with SMTP id 31so721565uas.9 for ; Wed, 04 Dec 2019 20:13:48 -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=JxvM8PAlC3uvNhbaAB15+7WItiOZ6wH5Zn3knWGZWuw=; b=kCXSBxmLW+TqYCxs2sT0nBzziphSgXA3YYH5gIvHSWYjFZSzA6I5Fdq1HyTqaMxMbF arIYwUzl/3ibdejY7UW4g9bRwp2MVIph3pzrL4XMMzfjea5E2jGEIpzuaus0EKmTOr5T am+tMyLWXrUfKXFoEDWTUq/2zcdLVp7gUAH8Z6B+haV4odWOEJfDdrK6IiBFd7rTxpAg 7zLfoo9mMbVjFltpgcjSUNKXJ5nMP4ivfo5Zym9f8kwKBFVpFhsiFvQL2msPJY6vVqZm 3HKX+3208wOLBBzS0LFE85jGtdh59F4FX4vkSpkVXOXMDSKkgSmSynMZbYOLrsAfutpv yMmg== 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=JxvM8PAlC3uvNhbaAB15+7WItiOZ6wH5Zn3knWGZWuw=; b=S1t5O9RAA5+gVZsYCwSjykPwkzvLqpZrESLhOAT1+ePc4L0sgjYZ7DMep13kFLrkPt jKklO1SEbRLN5aPFfAZ9w+F80mi1kAFSpOJA7gHSR1zYb1NHNbudgTe8p54Ju68cNRKh bxP6Iir0Bvwt8Ahu7IuZ+ywvtIF9J6AzbuYkKUJEI9zCfJCEQ2gv4ixsqhh4jajLKuf8 K3mTIxbqfRKusb3RCZCLPpIi38vXT8/JS78VafS6Ly+jlIiFwdScMF7Wv3yQyI6Voque Deu85LU+f+EMfPfYHVBek2Oq246V9LRiOWJzY5VVRS84rmLsbOhoYb3xJ8yY1HQr80AG BIFg== X-Gm-Message-State: APjAAAXrHElyfmCM9gpBqEKzi9R4xMqv4dnQZAZAjt1qBEJiR4FSr1BT 7xHfhvWSLJ4R4iYVghDoyDWFv2le1z38Nny6mLSy4g== X-Received: by 2002:ab0:30eb:: with SMTP id d11mr5654186uam.67.1575519227435; Wed, 04 Dec 2019 20:13:47 -0800 (PST) MIME-Version: 1.0 References: <20191204215618.125826-1-wvw@google.com> <20191204215618.125826-2-wvw@google.com> In-Reply-To: <20191204215618.125826-2-wvw@google.com> From: Amit Kucheria Date: Thu, 5 Dec 2019 09:43:36 +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 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. > 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" > + 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 >