Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10037037rwr; Fri, 12 May 2023 02:57:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wzpY/4wbbL1u67g0zsdRtYKb0jAIiHG8Vh9NA4rktYLbvhkd1DwGiNFIH6xD0qP3KCwrG X-Received: by 2002:a17:902:7597:b0:1ad:e639:e673 with SMTP id j23-20020a170902759700b001ade639e673mr1200744pll.53.1683885440916; Fri, 12 May 2023 02:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683885440; cv=none; d=google.com; s=arc-20160816; b=iIY6WNJoZZqR3wJLqIqhaTafGPF/YSFHny+9kxfiJmf7Kfzezzvj52dE2F4dK3Zrjg 1rDRwiOi0cXBXrd6G/QVN3RZ1wQosdgaAQo1gSUGyJGwTSgvJ55Q5QdHaUdo4Rcxi2UN nbvXyt0b6wHTTnK2db1W4MtuvtUWGNU/t1bvuj01LRvoyiEgmkvsgio87KHrjIa+GAE8 BJZzTOoTJVwsiGmWze48FVY1mUVd1THOPx2n5XpupofUMPq+fyGGkoCIUlvA3XfILEz/ bep12A2Mg0VHy8he6Ccldk40bRYvxeRSONJZGq2dV47LnYex/sC/M86RyrDi9PD4KEbf kjHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=WgvI1wBQwWPAHGVgPMl1t4Eh+AyHOlrQwlKzTs1KGuU=; b=Kzn3WhsTW13DPB9x22sNHobpmK2PL/ECnZ4ULt8635b4no3PrgfTUPtHAbcVl0vzag F6+CSJzETBh4l4hhuuDK57+234jHwZ8EchjZqsqHh1JvUiE5Wo+AV8olyTCh2nG0vNwx 0iTnaePlp0Mi8OYHuJG/kZgHuWcOEQsMg1NwBIjPOuy+vvvI0qj+yEJUWTIlFpfiyVhN v4Urcna4/+UJcOpumHOcYxS3dTiEttHhkItfeAW07NKpYic2KF+bmuUvbqFBjBnfbcvq cLnH769GQWab6NcPWuvQMkm11cVjayrKV0+pScZ3uOH93NiHbq+/9OETL7m5K39ElYkT 4GHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=lqoAOFDF; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a1709028c8b00b001ac3f3cc15fsi8463964plo.275.2023.05.12.02.57.05; Fri, 12 May 2023 02:57:20 -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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=lqoAOFDF; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240564AbjELJl7 (ORCPT + 99 others); Fri, 12 May 2023 05:41:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240537AbjELJl1 (ORCPT ); Fri, 12 May 2023 05:41:27 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4214C106D3; Fri, 12 May 2023 02:41:06 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-7576deacbd6so379275185a.3; Fri, 12 May 2023 02:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683884464; x=1686476464; 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=WgvI1wBQwWPAHGVgPMl1t4Eh+AyHOlrQwlKzTs1KGuU=; b=lqoAOFDFj2u5/n0ai2w3ScJeW4r/DBqFUliw7qxLsjG0PFIFzNU1BwY0io0X0OF3q0 bo9Z4hx2DFNuUG4n691BU+R8M1cClttiFXnPIJMM2Ruh5qx1Yjx8BDSPhFoUlnMEIds5 pZCETnymGjt4NQT499rNSrwqoIp9pqjbC9CHcjIzbjE9an+jA2KM1DHyRVhmzwN8th0m ipgH4SKJwNLaPYgke4IgbekzxC6zxyweeOwc1Ignd7xlw8QDPC+sYQwyzWhPlgZ3884I rFCJl312cuhfpRYIltuJoAmxAZV7CDL+lFUKvZ0yHh091cegtOdPCPGZoT0a1FG4NeSa MP+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683884464; x=1686476464; 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=WgvI1wBQwWPAHGVgPMl1t4Eh+AyHOlrQwlKzTs1KGuU=; b=RnEjOCqNbVuTrAmpeuw/8g5d8615ewIFLmv1/wxOiFu7kwbrSPnkeOztDwU3dLPCZZ PMtJpuC2Penz9OfWEhnp2cejKHoiS/ZI1QaYz3NlOtRrA2fBT3rBVe4bd8XSeKsT1he/ gvThYa1W2ZsKX9CImm95McsP+Ti7l0ZnRHBzqd37hZiZL1bcD6WVqQDcLfgXKYfJCBuE gtzJXfSZm1vNHI9kavG5BVppfXrvqMaHFuiRqmXBhwfPOV0Frwmd4cR/edqYiWd7AQWF Tfb5T21BZNFhG+xZVnYIboL0xWxioZyCfScSgpcSbt6gJNobEu9QiSPFJhcHk8cNS9ur SVnA== X-Gm-Message-State: AC+VfDyy3KAlNBB+9yYCxovXcuVvVCn47z5tm3qsqyVYBEnJ5IHSoBTk bqAtdWB0Bd5hXDW76gybUqPKJJ6jubCIhw7L0HGpRepCu5QHeA== X-Received: by 2002:a05:6214:628:b0:621:42c8:9bdd with SMTP id a8-20020a056214062800b0062142c89bddmr17598245qvx.29.1683884464669; Fri, 12 May 2023 02:41:04 -0700 (PDT) MIME-Version: 1.0 References: <20230426071045.20753-1-zhuyinbo@loongson.cn> <20230426071045.20753-3-zhuyinbo@loongson.cn> In-Reply-To: From: Andy Shevchenko Date: Fri, 12 May 2023 12:40:28 +0300 Message-ID: Subject: Re: [PATCH v9 2/2] spi: loongson: add bus driver for the loongson spi controller To: zhuyinbo Cc: Mark Brown , Rob Herring , Krzysztof Kozlowski , linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jianmin Lv , wanghongliang@loongson.cn, Liu Peibao , loongson-kernel@lists.loongnix.cn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 12, 2023 at 11:12=E2=80=AFAM zhuyinbo wr= ote: > =E5=9C=A8 2023/5/10 =E4=B8=8B=E5=8D=883:03, Andy Shevchenko =E5=86=99=E9= =81=93: ... > so, I think it is better > to confiure clk and mode separately. Agree, but at the same time you can split the conditional bodies to the separate functions. In this case the indentation of each of them can be decreased. ... > > Also the check can be modified to have less indented code: > > > > if (hz && loongson_spi->hz =3D=3D hz) > > return 0; > > > > if (!((spi->mode ^ loongson_spi->mode) & SPI_MODE_X_MASK)) > > return 0; > > The setting register about clk and mode was the same SPCR register, so > only the clk and mode don't need to be updated in the same, then return > 0, so the code seems to be as follows. But setting clk and mode > separately doesn't require follows judgement. > > if ((hz && loongson_spi->hz =3D=3D hz) && > !((spi->mode ^ loongson_spi->mode) & SPI_MODE_X_MASK)) > return 0; Correct, sorry for the mistake I made. --=20 With Best Regards, Andy Shevchenko