From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35F3EC67861 for ; Tue, 9 Apr 2024 06:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UeONmI4E6cFJhTv7kPcZVfQ2jOAy0nR5XoZZ+hM0uFw=; b=Lrkwrs0C3fvX6O jx36MEyDHbp4UdHsTc+OgcLYxnbhhlpx+lLG/Kw3An7bAq4zmVZ/dCZ4FKSNKdXe3+AFoT3Yq0cqM UYE7wZYGkBissOKvs6eqTG1gKBdMTSKsnkSnFptR3zHXQBjqHJ0Zuvej316ubWaYMZn77rw5oqUAp +vByMeM35gPofvyaZ/QSIIPcHv7CmncBBarGw+nPNupDiKaqJj814gchLgHTYajHbQ6L55dPkvEi9 J5phi0RqhkXhWJf9Jg16v1tRVuY6Z7wfBUdNtlBal/3Pl1JaB60CcQfTs8AIPvahEoFcR763dkfyK CCs5zBXLecbXc09ZZiHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ru4sa-00000000ZM0-0QuU; Tue, 09 Apr 2024 06:22:48 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ru4sX-00000000ZDL-0CyK for linux-arm-kernel@lists.infradead.org; Tue, 09 Apr 2024 06:22:46 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a46ea03c2a5so872403866b.1 for ; Mon, 08 Apr 2024 23:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712643739; x=1713248539; darn=lists.infradead.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=UMDYO2c6oxyg4uLYpkx2s2QjYRlbgcgKpJOA25y7Xcg=; b=ovsjfSpJy/5HOA0l1zZ5TNhQO24kZLuvGQkopOHbZ0fgIs/Ckzt8Vx7phdDTBrS6Mv oUSDL0aqwdq4vd80KVtqyzvp5GddpHYN4oCBHgFG6iB6jsoYRTCUN2G6x7/LXLltBAcw gQRwJGNnfL99la1jAkVLJ9pcHFrX7dIJtHA2AZoJSgbINAHTqYtW2sbBol5YsgyhySEJ +360de62F6javL1u+ELlaMz+zK5lCRfXrC8B/Z4crCKlns7kakw88w4PWX/Vr4MW2WVS E5EZ38f658me91ODTRGEIhkcvLq2a3mltlGbUL03AMMYigyU7E8i+HQ9vWc40twv7VxT +ypw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712643739; x=1713248539; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UMDYO2c6oxyg4uLYpkx2s2QjYRlbgcgKpJOA25y7Xcg=; b=LuTeDcgPx4KVXEBFmdZa5UNpq4jrH41ZZtekJE84IojQBLqGC9OV/JAt1TDH735Weu wEJzTnTW3ProFMLYWxaNawNaQjoG9OAvj8xOI7cw1Hac0Cnb4KMFmnTEsjCXmwcH6VxT MRzjag2S+2hTcLQQ8c9mwg6jNwdL/8PZPXJNmEdF4VA/gtjbS52wAMtdN7vfu2wJA1aV nWR74+l8Oy0R9q+neMIDSCj2Qr2J2VGM10cB8yhPF6ldqplq7iZdmGpymQcqnHlw7rS8 uHYfki6vyG86YyZjSnwCn6g26k+fFwvY2saNPSb7cyKQ5kq4GDHnHKvOvCvgi7Q/dHvE Te5Q== X-Forwarded-Encrypted: i=1; AJvYcCVVMTYbVWpOrou7ahjqAeZ7BxlCCV3Ox62JDC6wNmfCerXnfb3c6lbVPLE9nWWmKSSdktlPEpNxxEfo8vDL17vCXChpIm3mg4fgZTNbUdHjuE92UAc= X-Gm-Message-State: AOJu0YxuSw/MYyRZhqciIfBbsqP9ceG7uqmpSSTdUDdfavhsBLhIMNNO 6lgj+jQmwJKKKcyhb3qxl34VZAVNB1P9xadn3BEUTn+ObqfAaqKpn8NdmvwQeE0= X-Google-Smtp-Source: AGHT+IFezcxylFThCkZ5dq6o+jnfozGQsIp94NHvIm6eTu25O92P3DhT+nJlYrPygKuAeOBrFXddww== X-Received: by 2002:a17:907:7203:b0:a51:d48e:52a0 with SMTP id dr3-20020a170907720300b00a51d48e52a0mr1969227ejc.27.1712643739522; Mon, 08 Apr 2024 23:22:19 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id qx25-20020a170907b59900b00a46caa13e67sm5252758ejc.105.2024.04.08.23.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 23:22:18 -0700 (PDT) Date: Tue, 9 Apr 2024 09:22:14 +0300 From: Dan Carpenter To: Christophe JAILLET Cc: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Matthias Brugger , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH 2/2] thermal/drivers/mediatek/lvts_thermal: Improve some memory allocation Message-ID: <483b8e9a-26db-45c8-ada6-e39575760c51@moroto.mountain> References: <42a87fb9837f1760d1ad4eb7162a7536785dc6f5.1712520052.git.christophe.jaillet@wanadoo.fr> <8cb69f245311a348164b0b5ca3dbc59386746035.1712520052.git.christophe.jaillet@wanadoo.fr> <4ebbe227-38b1-4a1c-af34-9ba7bdfecad5@wanadoo.fr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4ebbe227-38b1-4a1c-af34-9ba7bdfecad5@wanadoo.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240408_232245_109033_39DD7349 X-CRM114-Status: GOOD ( 29.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 08, 2024 at 08:41:26PM +0200, Christophe JAILLET wrote: > Le 08/04/2024 =E0 10:09, Dan Carpenter a =E9crit=A0: > > On Sun, Apr 07, 2024 at 10:01:49PM +0200, Christophe JAILLET wrote: > > > diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/therma= l/mediatek/lvts_thermal.c > > > index 3003dc350766..b133f731c5ba 100644 > > > --- a/drivers/thermal/mediatek/lvts_thermal.c > > > +++ b/drivers/thermal/mediatek/lvts_thermal.c > > > @@ -204,7 +204,7 @@ static const struct debugfs_reg32 lvts_regs[] =3D= { > > > static int lvts_debugfs_init(struct device *dev, struct lvts_domain= *lvts_td) > > > { > > > - struct debugfs_regset32 *regset; > > > + struct debugfs_regset32 *regsets; > > > struct lvts_ctrl *lvts_ctrl; > > > struct dentry *dentry; > > > char name[64]; > > > @@ -214,8 +214,14 @@ static int lvts_debugfs_init(struct device *dev,= struct lvts_domain *lvts_td) > > > if (IS_ERR(lvts_td->dom_dentry)) > > > return 0; > > > + regsets =3D devm_kcalloc(dev, lvts_td->num_lvts_ctrl, > > > + sizeof(*regsets), GFP_KERNEL); > > > + if (!regsets) > > > + return 0; > > = > > I understand that this preserved the behavior from the original code, > > but the original code was wrong. This should return -ENOMEM. > = > Hi Dan, > I don't agree. > = > For me, this memory allocation is of the same type as all debugfs functio= ns > that we ignore the error code. > = > If it fails, it is not a reason good enough to have the probe fail. (anyw= ay, > if we are short on memory at this point other errors will likely occur) > = Huh. It's an interesting point. Fair enough. > > = > > > + > > > for (i =3D 0; i < lvts_td->num_lvts_ctrl; i++) { > > > + struct debugfs_regset32 *regset =3D ®sets[i]; > > > lvts_ctrl =3D &lvts_td->lvts_ctrl[i]; > > = > > The blank line should come after the declaration. > = > The blank line was already there, and in this file, it looks like the > preferred style (even if not completely consistent) > = > Let see if there is some comment about 0 or -ENOMEM in case of memory > allocation error, and if needed, I'll repost without the blank line. > = There is supposed to be a blank line after declarations though so I think if you re-run checkpatch.pl -f on the file there is a checkpatch warning now. regards, dan carpenter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel