Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp673435lqh; Thu, 28 Mar 2024 12:41:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXomZ//m03MFpsREdxjH2O8eOEXQKLSZ/j1kqvmVYEu85w/9JtIhj6oZRfeZRmkXSfJRDmNB+38mU+b6GOBAUbrV7vrbGnCaVPH+q1vIg== X-Google-Smtp-Source: AGHT+IE8BLFSp0f2ssehhgY3R7xYkosA2R03u/sF5wry06QtzFH7x/3Pz690g5tYd0SX70h/0qTq X-Received: by 2002:a05:6a00:181b:b0:6e7:6bc4:ef8c with SMTP id y27-20020a056a00181b00b006e76bc4ef8cmr5074950pfa.3.1711654867681; Thu, 28 Mar 2024 12:41:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711654867; cv=pass; d=google.com; s=arc-20160816; b=E6+w62yOATG/Vi1a1l+gRsC+4D3x0NTSaPzXJyMbjOF2f/FXenrSUCT6dTycRtpeuS sKWiKw3o1XAD95DERF+B4dQXmDlqeU2ZGChMGh75oj56d3r0be/ymMuWKar6/Zgxexbr dopz2WujYJJz8cdfh/GNXPA8+z958lOppOnBoEVv4tPbsebcPYxCKRX/vsIy3bCjunI5 Xc5SH9zrXNE6CxHcNBPqWTMRTl/6oK5de03QvSweTcjyfqVDcK+eahiRBRd1vr7q11nM LeqrKXDfud8yWmljGwPAUpSMej3sHwqFJRYEDUOrgb6GfPfdunGxdcwWxukbtTAs5yHL icXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=pGCaq9OrigqbkBbwFdgSJ7iz+P7VgNUODi7EL0TTbPM=; fh=hiC7Oe2TduFIBdKvMDeeJfMdo/FrOn6dS2qdfYnsRO8=; b=qvewLDlPzqyqD8BnJPrXVxTHh7a1wW1eCu8X4ZXVSNS/XbQhyTo9PLTnGKl6zSg4cM KESCTWZWYzkC5SchBEBuC5cMRmd6d4TGeWK1xyneMJ64DVlQ9gXRTbyN/DuAk9FOdx9w yOyN5gLuyOC4M7HQkRlwm7Pp0wVCnY1+DH8VIo/MNmHyPHXa6hF904cRBY9NJs1aCg2j YGyyI21Nos5UaWNvWs/vk3cseZhxsoUochV+INusvfZk01sPwvF8ei5Tg0N6e56KMIzX 40my+7CYyCr0ktZcmWInSVJ/Z5PWWaPMgDP5gJzzys+ebRgI7xHmVEPP2+oQ5KptNvkT PeCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kaA9Q3h4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-123492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s64-20020a637743000000b005e83f4901a7si2063595pgc.457.2024.03.28.12.41.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 12:41:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kaA9Q3h4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-123492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5BB05291B6D for ; Thu, 28 Mar 2024 19:41:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D65161384B3; Thu, 28 Mar 2024 19:41:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kaA9Q3h4" Received: from mail-vk1-f182.google.com (mail-vk1-f182.google.com [209.85.221.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 701641849; Thu, 28 Mar 2024 19:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711654860; cv=none; b=n+00L757N3vT1dZ82YdB3MOdwSfoospGHoxMUWUMLIaS0khyDCncM+yfoWz1HspulBqPej4M2WKiKCLMxmZH6UBePKjNdpJdxUCxtvxCgHV8way5NTenBFRIaxnT21aWPr/ZcG4k671BZ8FFW5nleeptDp0M6jlaqN2ud7AHCdI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711654860; c=relaxed/simple; bh=+3NWWwXtkzvrmA576fnyloztaGBywL+XKq+YksdA5gQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=qHDj/yQVgG6GaPJlEoUIAFSKe1lc8CGfwP9G+eSe9AJvOKUuRw4DfGmBVAOi1OYoc7i47o25Gymm6o/wheYEd04wsUMUmk4yXBN1J/Be/F+jQPajk4Yx6Hwi4tAYiusTWIKgb9Zn6OtGGRp+R5pKWLYqVyXLodOYUb8fQSCLNV0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kaA9Q3h4; arc=none smtp.client-ip=209.85.221.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-f182.google.com with SMTP id 71dfb90a1353d-4d438e141d5so714815e0c.0; Thu, 28 Mar 2024 12:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711654857; x=1712259657; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pGCaq9OrigqbkBbwFdgSJ7iz+P7VgNUODi7EL0TTbPM=; b=kaA9Q3h42sLRsltH3mK4bf+Kysp/vEkP2EoztKKfGf4F4xo6le+/mbcT4YLDaCYv6Z xyRCPRRVYeFeLtWk60JRQo/lhm0nVbAhWwQdEyuJnCQ5FDVND7S6fF/lESZh8AuAEglD U5rHDu9EO38SqP7eEn3ts72lj4BNehdOye1oINE4wx1KUm189/ee4LkA6rD0DGLNJmC+ SKi87e9FI4Wkw1Ts62f9Pta9G9aT1yB2xZRb8KwCWW2yUnbXQy4G33SLOJKEwEa4h5YX IpJgUApWG5cCCjpunC0CbLCFKtnk7uSvKiCvxuSjCLl37Y8abg1i/SJ6qikSxLAIA+eJ 3Gyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711654857; x=1712259657; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pGCaq9OrigqbkBbwFdgSJ7iz+P7VgNUODi7EL0TTbPM=; b=a3s489Fbi4hZfjyX/B0EKYrhCm1t3VuQs570uBZTQCl31R2SPSsrdiKvd8pudOzjBx wXI6pTPTISpwU3jOt/is6cC6Qm8WaJSl0+eVmiN9fccXoJGgPZN92iz7AywAKzrxi1oE 2h4TyqZN4soRrKPv0SqhnLShTQhWljzSh7Al5RhhPGFbT1aNurlrlvcN2Y7Qdi7i+XjH RbbF7/Grlq6HugKq181Wd3nSuo9fc3LIAhsXkPE3ZB89V5pAuszm3MfqmeQCzkovpD6T wuAMUp9jknOFj3z2Q58t4iTlFmGMca30Tu7OZLCXtJNiwsVyt48XfT08MetR0LTelxdP CrGg== X-Forwarded-Encrypted: i=1; AJvYcCU+nzXZJ9kY0ZKk29e1ABHDbAnsnGpfFLM1Q+wWuFcJkBW1QOsw2UH9oWE52rJlV3BjmQcKFxpMAUz32imU8kEFgVg9OK1p5oOzvXxfFd0KdOY2AQ5pP3NkkP8QB93HmgWoJhhE5Sa0PW5KToP9RJmDEd9pBxbXfuWUuN+xdkoMlTonsENPBIggZpE/YT9n86drMwA0phvXEsrTVRvzAVxfLZENcx94wg== X-Gm-Message-State: AOJu0YyEFheS7pG4zIkBH9fn3j9FjjOfXf2bgvMXLfTTC3ZXZQ2mKKZy GC20hOjHjnUGRcUW5UsNipqMfHhTX/u98H51iq2VifWd3MgEZr3flsUqtiH6l6IJhHZOtoG/Ohn scYD7hQ3XVt16n4chIV3glVm8xic= X-Received: by 2002:a05:6122:2806:b0:4c8:df97:139d with SMTP id en6-20020a056122280600b004c8df97139dmr2962055vkb.2.1711654857269; Thu, 28 Mar 2024 12:40:57 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240326222844.1422948-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20240326222844.1422948-8-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: From: "Lad, Prabhakar" Date: Thu, 28 Mar 2024 19:40:31 +0000 Message-ID: Subject: Re: [RFC PATCH 07/13] pinctrl: renesas: pinctrl-rzg2l: Validate power registers for SD and ETH To: claudiu beznea Cc: Geert Uytterhoeven , Linus Walleij , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm , linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Fabrizio Castro , Lad Prabhakar Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Claudiu, Thank you for the review. On Thu, Mar 28, 2024 at 8:01=E2=80=AFAM claudiu beznea wrote: > > Hi, Prabhakar, > > On 27.03.2024 00:28, Prabhakar wrote: > > From: Lad Prabhakar > > > > On RZ/V2H(P) SoC, the power registers for SD and ETH do not exist, > > resulting in invalid register offsets. Ensure that the register offsets > > are valid before any read/write operations are performed. If the power > > registers are not available, both SD and ETH will be set to -EINVAL. > > > > Signed-off-by: Lad Prabhakar > > --- > > drivers/pinctrl/renesas/pinctrl-rzg2l.c | 16 ++++++++++------ > > 1 file changed, 10 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/= renesas/pinctrl-rzg2l.c > > index 348fdccaff72..705372faaeff 100644 > > --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c > > +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c > > @@ -184,8 +184,8 @@ > > */ > > struct rzg2l_register_offsets { > > u16 pwpr; > > - u16 sd_ch; > > - u16 eth_poc; > > + int sd_ch; > > + int eth_poc; > > }; > > > > /** > > @@ -2567,8 +2567,10 @@ static int rzg2l_pinctrl_suspend_noirq(struct de= vice *dev) > > rzg2l_pinctrl_pm_setup_dedicated_regs(pctrl, true); > > > > for (u8 i =3D 0; i < 2; i++) { > > - cache->sd_ch[i] =3D readb(pctrl->base + SD_CH(regs->sd_ch= , i)); > > - cache->eth_poc[i] =3D readb(pctrl->base + ETH_POC(regs->e= th_poc, i)); > > + if (regs->sd_ch !=3D -EINVAL) > > As of my knowledge, the current users of this driver uses SD and ETH > offsets different from zero. To avoid populating these values for all the > SoCs and avoid increasing the size of these fields I think you can add > checks like these: > > if (regs->sd_ch) > // set sd_ch > Agreed. > > Same for the rest. > OK. Cheers, Prabhakar