Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1307792ybl; Wed, 4 Dec 2019 22:16:25 -0800 (PST) X-Google-Smtp-Source: APXvYqw/6+naIEwhFSI3PYCQEUljRhNJ58rhJcjGdBUK/090lOClCqkOkgiSpV+wlI5VGHnLXL0q X-Received: by 2002:aca:a902:: with SMTP id s2mr6104538oie.5.1575526585002; Wed, 04 Dec 2019 22:16:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575526584; cv=none; d=google.com; s=arc-20160816; b=LG31Y6cj6BMLNGQ25eRwv5yPKURXa/YZal/Szz/r/kK7KS/TV9k4X4/Vbp8sd6o3+Y QiHxiSKQXnPAJ/W0cnZ6M0Z0bHjdRYtkJ7RtcZj6NceQNcurKnpsfmusUWZpXGQ40oPe DY29qxq9Yg7KkIUHdU5Acyd+T39hk0vfUeSiiIZWvv8qCW0Jo5n6k32t1Tlr57jnZ5RD s9M9H4ncvTCX+BQYUp1k2/Ijrs2ZHJe0UKHmBf36/kWcePKiFpj43bdvvSNFR45WQVGu JgE0n+R2tkO2jJroL+CAxY8wwBJX7MqRFkG/R2Sb8AmYmoGxBK3ArHx/wInTNMF9xIOn awCw== 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=pW0Hn3aQ9V6GllI+q5V9oU8MXeLBI73uZ2g1iNoE2vg=; b=gOc88nLTeM5voUdZzNc3Uc9BpWW6Wx3Rl3NggzjlSBP/V7JB7a2bwh9jxb8JrQ1AC6 f1G64pGx9PEBDb8ayWobvX82dmyRCPPLxjnyPedf4dA7gssOwbcXwXbMrO1FOp5jj5QK w2wgO40cd0cA+IpYzmkGT8gwQkaWjBZAVLeuqanVBC3QjDbTIfEqAAeD8t6/Lk9EIesg mJO7Ukb7JiLcA1HWpOxKPUxfHVHj1zw99oe038GUY2QPihDU5lzo7deLgboNZR/HvYCD QEJwTA/FRP6LuM6Awn5pXYmjJ5soNczjGPfrpHroRYX3hHV68P8B9KIFVKhLrrqu+9E8 60mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=buIieAhF; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9si2031587otq.68.2019.12.04.22.16.12; Wed, 04 Dec 2019 22:16:24 -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=@google.com header.s=20161025 header.b=buIieAhF; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725867AbfLEGO2 (ORCPT + 99 others); Thu, 5 Dec 2019 01:14:28 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:38616 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725905AbfLEGO2 (ORCPT ); Thu, 5 Dec 2019 01:14:28 -0500 Received: by mail-ed1-f68.google.com with SMTP id i6so490759edr.5 for ; Wed, 04 Dec 2019 22:14:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pW0Hn3aQ9V6GllI+q5V9oU8MXeLBI73uZ2g1iNoE2vg=; b=buIieAhFdrFpxCNwtChiUsQhKQY9qRW1+zBlZUCnjwiZXOQRmaaixxYsBaCsYma2rl gkr9OLiC304ks0YXwxGL0tnCpWZFFrHBzLRFkOPXBEOIPeKERjnRdzC1VNSsjOkrnbIZ Yuykw0lMDgAaStLRoXRnSqLmVKuCzwve88JsjLjfBxzBq4x3950MfxG7GfCFJ9R38sTu +qewiulWTRBFToNmG4t/jHEN2iYOVqhz9V9kKdgDHrqFMvEZBEfYPNnERMon3IeBz4V9 dFNjaRqsomnlWE8N0HZP1hZUE0g7ZsgxutYf6XNhq5K4bAfAdkf4dQ303nz2L1XaWNuj 9B1w== 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=pW0Hn3aQ9V6GllI+q5V9oU8MXeLBI73uZ2g1iNoE2vg=; b=glclIF93iPMV9DC4Aej1M0IKyYJRT0GEJLIaw6CYDL84WBkJ7eDuGlJOGse5ICymR+ dq7/70iMN24u6agLqCLFs+cK7audMv0Yfp/F05EBMxOb9Avqxn4v7k3RR+X0rMHSr3zm mEh4mWksSDECaGRuLTwuaFxmItIOliJWFiPi1NarXOIotSTHpNSZNbF/it3/8aMGBsw0 Qndm/43oHeAA2dDqx41BnH9g6ZWiJU00vpY86WyQnFMWbn1iezJbKMjM2aKS80uLvn+6 sbrDq7N+7i5ShBppGsV1PycV0owu4OjEhvKvDVcooTymlroyRr2i6fCLcwY9U+qCBNzG Py9Q== X-Gm-Message-State: APjAAAU4z4UcqeMLtUYBDC8OlYuPfTTrhx73U0HS5eKKEXcELe6r43tv 66iylj3xtrE9B2/NAG/VOEjyT2476BjMgeYGZxAxeg== X-Received: by 2002:a17:906:3290:: with SMTP id 16mr7504457ejw.329.1575526465741; Wed, 04 Dec 2019 22:14:25 -0800 (PST) MIME-Version: 1.0 References: <20191204215618.125826-1-wvw@google.com> <20191204215618.125826-2-wvw@google.com> In-Reply-To: From: Wei Wang Date: Wed, 4 Dec 2019 22:14:14 -0800 Message-ID: Subject: Re: [PATCH v2 1/2] thermal: fix and clean up tz and cdev registration To: Amit Kucheria 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 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/ will include aboce in next version. > > 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 > > + 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 > >