From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C65D1DA5F for ; Tue, 8 Jul 2025 02:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.29.241.158 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751940840; cv=none; b=m89MpUQWRKN4Dnzj3uUf97GXSlvz4pWvNs1mLJ9WVUaDuSJGuu5pMvAPpqA3hATrLJDE3k3gNBwk7lSUiYdFdp5iOCFAOouCqGYOoq7oOdi9i0UclIzMTxqlANeQQrMS4iNWRSpBgBVS70XCrQP0IkHFmw46T1+pf8d2fLam/K4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751940840; c=relaxed/simple; bh=J55cKjqJdB/s54ySt3a9A6aU/rgkpjBjIATa2spYydU=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=eXY/UWz27y2PovJaTR8gc44u/VHdTJ2sRoSFBp9Rjs4CQJwtAgOJdHeNQkrGoAEXHwt3VnuE68STn0kUkCjb3QGFU3EN/fTRI+qDSimk9JLdmQ0vhkzjOkVhdVeywPJ47Ri5/PnW6hORJmlKBbPrSRLFqZZPF2cmHUTG1N6X/yg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeconstruct.com.au; spf=pass smtp.mailfrom=codeconstruct.com.au; dkim=pass (2048-bit key) header.d=codeconstruct.com.au header.i=@codeconstruct.com.au header.b=IJYoMmte; arc=none smtp.client-ip=203.29.241.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeconstruct.com.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeconstruct.com.au Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeconstruct.com.au header.i=@codeconstruct.com.au header.b="IJYoMmte" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1751940402; bh=J55cKjqJdB/s54ySt3a9A6aU/rgkpjBjIATa2spYydU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=IJYoMmteYdZnYL0OquHwmK0NgiaYNAHFy7ZXSITie3Aff57LFZ10+VjFGYJo5pgh6 +2wZlmQU026XtnxYbNM7ivS4pQN6FE6/BEw12mwgCSeyAtxs8F+w2dEQCp85J1J+Gs Kzfn64K3crWXikXXqxFvqxbS1gjLzh+W5ujytZ4weU3fiuJQQE0EXxWVkNK7qfqxj0 ijvNj5Vw1L2hDpWPRT7kPn/lt258fmy8dHx/YfWrn7KHZLGg2njfsM9G4S6e0kfMoO DvEu1YrP2ovT4C+zLLvrR+2vEjQwJRzC9WNMNQfPbBmQqd5Nez6vEvaYXMRHJoNOoe zph9f7ARVn9OQ== Received: from [192.168.68.112] (unknown [180.150.112.153]) by mail.codeconstruct.com.au (Postfix) with ESMTPSA id 25621640B5; Tue, 8 Jul 2025 10:06:40 +0800 (AWST) Message-ID: Subject: Re: [PATCH v2 04/10] soc: aspeed: lpc-snoop: Constrain parameters in channel paths From: Andrew Jeffery To: Jean Delvare Cc: linux-aspeed@lists.ozlabs.org, Joel Stanley , Henry Martin , Patrick Rudolph , Andrew Geissler , Ninad Palsule , Patrick Venture , Robert Lippert , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Tue, 08 Jul 2025 11:36:39 +0930 In-Reply-To: <20250704184408.32227305@endymion> References: <20250616-aspeed-lpc-snoop-fixes-v2-0-3cdd59c934d3@codeconstruct.com.au> <20250616-aspeed-lpc-snoop-fixes-v2-4-3cdd59c934d3@codeconstruct.com.au> <20250704184408.32227305@endymion> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi Jean, On Fri, 2025-07-04 at 18:44 +0200, Jean Delvare wrote: > On Mon, 16 Jun 2025 22:43:41 +0930, Andrew Jeffery wrote: > > Ensure pointers and the channel index are valid before use. > >=20 > > Signed-off-by: Andrew Jeffery > > --- > > =C2=A0drivers/soc/aspeed/aspeed-lpc-snoop.c | 25 ++++++++++++++++------= --- > > =C2=A01 file changed, 16 insertions(+), 9 deletions(-) > >=20 > > diff --git a/drivers/soc/aspeed/aspeed-lpc-snoop.c b/drivers/soc/aspeed= /aspeed-lpc-snoop.c > > index ca7536213e0986f737606a52996ffea620df2a7a..804c6ed9c4c671da73a6c66= c1de41c59922c82dc 100644 > > --- a/drivers/soc/aspeed/aspeed-lpc-snoop.c > > +++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c > > @@ -25,7 +25,6 @@ > > =C2=A0 > > =C2=A0#define DEVICE_NAME=C2=A0=C2=A0=C2=A0=C2=A0"aspeed-lpc-snoop" > > =C2=A0 > > -#define NUM_SNOOP_CHANNELS 2 > > =C2=A0#define SNOOP_FIFO_SIZE 2048 > > =C2=A0 > > =C2=A0#define HICR5=C2=A0=C2=A00x80 > > @@ -57,6 +56,12 @@ struct aspeed_lpc_snoop_model_data { > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0unsigned int has_hicrb_= ensnp; > > =C2=A0}; > > =C2=A0 > > +enum aspeed_lpc_snoop_index { > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0ASPEED_LPC_SNOOP_INDEX_0 =3D= 0, > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0ASPEED_LPC_SNOOP_INDEX_1 =3D= 1, > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0ASPEED_LPC_SNOOP_INDEX_MAX = =3D ASPEED_LPC_SNOOP_INDEX_1, > > +}; >=20 > I don't have a strong opinion on this (again, I'm neither the driver > maintainer nor the subsystem maintainer so my opinion has little > value), but IMHO the main value of introducing an enum here was to make > it possible to get rid of the default statement in the switch > constructs. With switch constructs being gone in patch 10/10 (soc: > aspeed: lpc-snoop: Lift channel config to const structs), the value of > this enum seems pretty low now. You could use NUM_SNOOP_CHANNELS > instead of ASPEED_LPC_SNOOP_INDEX_MAX + 1 and 0 and 1 instead of > ASPEED_LPC_SNOOP_INDEX_0 and ASPEED_LPC_SNOOP_INDEX_1, respectively, > and the code would work just the same, while being more simple, with no > downside that I can see. >=20 Yeah, I agonised over it a bit before posting. However, I'm on leave, and I'd like to draw a line under this series. This patch is in the middle of it, and I'd rather not disrupt it too much and go around again with a v3. I'm going to keep the enum for now, but if I need to tidy up the driver down again the track I'll reconsider its worth. Andrew