Message ID | 20230807001621.196776-1-hayashi.kunihiko@socionext.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1152439vqr; Sun, 6 Aug 2023 17:35:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGq7N43zYEBtBJsO96G0MT90LSOHRr8+8qbGHQit0RevA3K0ereT+cQDHuQgZbCB5j1T5Do X-Received: by 2002:a2e:9dca:0:b0:2b6:a3a0:5f7 with SMTP id x10-20020a2e9dca000000b002b6a3a005f7mr5586001ljj.9.1691368522897; Sun, 06 Aug 2023 17:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691368522; cv=none; d=google.com; s=arc-20160816; b=apfRZ/BwvJR6acbvK5ODaz4Fk/s1fcZal9cKd+OsbGPB8i4AdCbysth9niKNSy49nK k3xozSp/n48KWHBFvwBJw8yW/yPii7ib7No2G0iLaKZPWSPuLhEuGhdgBCeyZ/D1rxwy QJ2cNimwi2bnxI4v33z4v8PaoQpDMNk4cs2nzB+mlLJCwuq7bxGa7Jnbn1Uo603LEih+ olmzqMDU1ME+BlphE68uYDYUigcOxUkqfRY4ZukFaIvr4G4uDxRIC7PfQiMPEw9WXR/e vbVZR8gLTvAH8zNWuzRWDaVV5H7ZImFJYAY/MP8vjshVAcmr/3FipAXe90GjApfZX+vT mEMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=5a0YVBM1KXuf92XS0W2KrHhD2shTvu8rUr8/6aj9xak=; fh=mYfWdevyHAgX1fgmT9WsKOSK2gxRxRN24g1G821/dQk=; b=uPE3Di+bOD4h9FsNRTQ1iQHzEsi1UerlM7LSwA2O6KesCnHrII+EX81wliqc9FgKFp CmhFcaInwneRI+8zdb6MbKZp5m8pGJhZVR6G9AL/B7L0w2Qq0RiLkvzuZuscqhHW+94X 44xFC4WQJKJsbvrNzRqgrE4FWdKto4USJJhnnkT602GhB+VuL6AgMt5Esc/+J6pcO2B8 MhlMQQSslKcUFL2djd7qZ/buOvaFsNvfWYAQs1BllT+gBcVCcBScrD1WIr0S7+ED1BRY gsHjDx9X7oT9tuCf4aDf1STRfylFKCOGP/7Q+EfsGz0BB/9vTD6NAD8EGVi9xlBLufcX zYCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020a17090614c400b0099b49483268si4926503ejc.301.2023.08.06.17.35.00; Sun, 06 Aug 2023 17:35:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbjHGAQi (ORCPT <rfc822;aaronkmseo@gmail.com> + 99 others); Sun, 6 Aug 2023 20:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjHGAQh (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 6 Aug 2023 20:16:37 -0400 Received: from mx.socionext.com (mx.socionext.com [202.248.49.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0376DFA; Sun, 6 Aug 2023 17:16:34 -0700 (PDT) Received: from unknown (HELO iyokan2-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 07 Aug 2023 09:16:33 +0900 Received: from mail.mfilter.local (mail-arc02.css.socionext.com [10.213.46.40]) by iyokan2-ex.css.socionext.com (Postfix) with ESMTP id 6016D231A0F8; Mon, 7 Aug 2023 09:16:33 +0900 (JST) Received: from kinkan2.css.socionext.com ([172.31.9.51]) by m-FILTER with ESMTP; Mon, 7 Aug 2023 09:16:33 +0900 Received: from plum.e01.socionext.com (unknown [10.212.243.119]) by kinkan2.css.socionext.com (Postfix) with ESMTP id B6E81126DC0; Mon, 7 Aug 2023 09:16:32 +0900 (JST) From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> To: Serge Semin <fancer.lancer@gmail.com>, Mark Brown <broonie@kernel.org> Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Subject: [PATCH] spi: dw: Set default value if reg-io-width isn't specified Date: Mon, 7 Aug 2023 09:16:21 +0900 Message-Id: <20230807001621.196776-1-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773528440484237612 X-GMAIL-MSGID: 1773528440484237612 |
Series |
spi: dw: Set default value if reg-io-width isn't specified
|
|
Commit Message
Kunihiko Hayashi
Aug. 7, 2023, 12:16 a.m. UTC
According to the dt-bindings, the default value of reg-io-width is 4.
However, the value becomes zero when reg-io-width isn't specified.
Should set the actual value to dws->reg_io_width, considering it
referenced.
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
---
drivers/spi/spi-dw-mmio.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Mon, Aug 07, 2023 at 09:16:21AM +0900, Kunihiko Hayashi wrote: > According to the dt-bindings, the default value of reg-io-width is 4. > However, the value becomes zero when reg-io-width isn't specified. This semantic is implied by the dw_read_io_reg() and dw_write_io_reg() methods. It doesn't seem like that much necessary duplicating it in the property parse procedure, if not to say - redundant. -Serge(y) > > Should set the actual value to dws->reg_io_width, considering it > referenced. > > Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> > --- > drivers/spi/spi-dw-mmio.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c > index a963bc96c223..7eafc07ef7aa 100644 > --- a/drivers/spi/spi-dw-mmio.c > +++ b/drivers/spi/spi-dw-mmio.c > @@ -369,7 +369,9 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) > > dws->max_freq = clk_get_rate(dwsmmio->clk); > > - device_property_read_u32(&pdev->dev, "reg-io-width", &dws->reg_io_width); > + if (device_property_read_u32(&pdev->dev, "reg-io-width", > + &dws->reg_io_width)) > + dws->reg_io_width = 4; > > num_cs = 4; > > -- > 2.25.1 >
Hi Serge, On 2023/08/08 7:57, Serge Semin wrote: > On Mon, Aug 07, 2023 at 09:16:21AM +0900, Kunihiko Hayashi wrote: >> According to the dt-bindings, the default value of reg-io-width is 4. >> However, the value becomes zero when reg-io-width isn't specified. > > This semantic is implied by the dw_read_io_reg() and dw_write_io_reg() > methods. It doesn't seem like that much necessary duplicating it in the > property parse procedure, if not to say - redundant. I see. Currently since the variable reg_io_width has no other references other than dw_{read, write}_io_reg(), it means the default value is taken if this is zero. So, I think we should be careful when actually using the value of this variable. Thank you, > > -Serge(y) > >> >> Should set the actual value to dws->reg_io_width, considering it >> referenced. >> >> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> >> --- >> drivers/spi/spi-dw-mmio.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c >> index a963bc96c223..7eafc07ef7aa 100644 >> --- a/drivers/spi/spi-dw-mmio.c >> +++ b/drivers/spi/spi-dw-mmio.c >> @@ -369,7 +369,9 @@ static int dw_spi_mmio_probe(struct platform_device > *pdev) >> >> dws->max_freq = clk_get_rate(dwsmmio->clk); >> >> - device_property_read_u32(&pdev->dev, "reg-io-width", > &dws->reg_io_width); >> + if (device_property_read_u32(&pdev->dev, "reg-io-width", >> + &dws->reg_io_width)) >> + dws->reg_io_width = 4; >> >> num_cs = 4; >> >> -- >> 2.25.1 >> --- Best Regards Kunihiko Hayashi
On Tue, Aug 08, 2023 at 09:00:18AM +0900, Kunihiko Hayashi wrote: > On 2023/08/08 7:57, Serge Semin wrote: > > On Mon, Aug 07, 2023 at 09:16:21AM +0900, Kunihiko Hayashi wrote: > > > According to the dt-bindings, the default value of reg-io-width is 4. > > > However, the value becomes zero when reg-io-width isn't specified. > > This semantic is implied by the dw_read_io_reg() and dw_write_io_reg() > > methods. It doesn't seem like that much necessary duplicating it in the > > property parse procedure, if not to say - redundant. > I see. Currently since the variable reg_io_width has no other references > other than dw_{read, write}_io_reg(), it means the default value is taken > if this is zero. > So, I think we should be careful when actually using the value of > this variable. It does feel like a sensible robustness improvement, even if it's not fixing a specific issue now it might save us from future issues.
On Mon, 07 Aug 2023 09:16:21 +0900, Kunihiko Hayashi wrote: > According to the dt-bindings, the default value of reg-io-width is 4. > However, the value becomes zero when reg-io-width isn't specified. > > Should set the actual value to dws->reg_io_width, considering it > referenced. > > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next Thanks! [1/1] spi: dw: Set default value if reg-io-width isn't specified commit: 2ca03ecc9c8556e913aef6f381154721dec4e44b All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
On Tue, Aug 08, 2023 at 01:46:08PM +0100, Mark Brown wrote: > On Tue, Aug 08, 2023 at 09:00:18AM +0900, Kunihiko Hayashi wrote: > > On 2023/08/08 7:57, Serge Semin wrote: > > > On Mon, Aug 07, 2023 at 09:16:21AM +0900, Kunihiko Hayashi wrote: > > > > > According to the dt-bindings, the default value of reg-io-width is 4. > > > > However, the value becomes zero when reg-io-width isn't specified. > > > > This semantic is implied by the dw_read_io_reg() and dw_write_io_reg() > > > methods. It doesn't seem like that much necessary duplicating it in the > > > property parse procedure, if not to say - redundant. > > > I see. Currently since the variable reg_io_width has no other references > > other than dw_{read, write}_io_reg(), it means the default value is taken > > if this is zero. > > > So, I think we should be careful when actually using the value of > > this variable. > > It does feel like a sensible robustness improvement, I wouldn't call it "a sensible improvement" in this context, but merely something like "a data-field/property coherency fixup". > even if it's not > fixing a specific issue now it might save us from future issues. Such issues are very unlikely to happen unless somebody would try to use the dw_spi.reg_io_width field separately from the denoted methods. If one does, what he would have needed to make sure is that the field always takes a correct value which would have led to this patch anyway but at least it would have got a firm justification. So to speak I wouldn't have bothered with merging the patch now at least without changing the patch log which would have had to be reduced to just the first paragraph with additional message stating that the change just makes sure that the field is in a coherent state with the DT-property value in order to improve the code maintainability. -Serge(y)
diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index a963bc96c223..7eafc07ef7aa 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -369,7 +369,9 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) dws->max_freq = clk_get_rate(dwsmmio->clk); - device_property_read_u32(&pdev->dev, "reg-io-width", &dws->reg_io_width); + if (device_property_read_u32(&pdev->dev, "reg-io-width", + &dws->reg_io_width)) + dws->reg_io_width = 4; num_cs = 4;