Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1784230pxk; Tue, 1 Sep 2020 07:45:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxvGomVyfbKSJqSW7gNQXVsOhVxmGDpjujh6fVRe/FCD8cjKRWA7PvCSfbt+epur3CaOc5 X-Received: by 2002:aa7:de8f:: with SMTP id j15mr1913757edv.135.1598971501258; Tue, 01 Sep 2020 07:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598971501; cv=none; d=google.com; s=arc-20160816; b=U+BbJ9ZFokH9HtWYLrNMCm7tqTmNsC+9RujqLhSq6+jS9jqTosnAI7fwyFSwA/eHsB wacVE/W/h3i/9E24iZ0rDYWODPADEf78RKHGq4FPU/9UktYk+26jbgrtmqcJwm84Khew LxJ219q6q5rUag0xHRcLiRiczSQnD+dARkZugQIR11kOuHkcqdpuc9E8wGEKVNq9wUFq vbD3rUp/i5qo/7DS7yqsaheCC7tjoEHt1vgG1POu/1s1GxRajrqUpc0TTw3nV1sGwrnY RWzXTXHkoj4n9AZEh2YBXrVDw62GR5722P3bO9xc4KjaxNVkrv/Ik1Lje+dsQwZZw+2C hrbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:message-id:date:to:from :subject:cc:content-transfer-encoding:mime-version:dkim-signature; bh=+c7gUM4M1NG54PZN7hYz3O1VCdsfHKYvNA1RcLxjRT4=; b=phYVeYp3pmyCbXs3R9/KNa5KgxlxogLU+ujh1beUnOh5VFC/F/d/QjVIb+vXqoZ9yK SbDNER+rtNHMn1al9IXYOjClaY6HZ1VgfEC+JedSfixbjbjF2JRKgNhoXvn+0lx61JbM Y13vlRB6QFnJq7yJM7DDjmLJCycbarNPAwvu7/lX8ZDRvZ91BNl+FxtwQtv+lsfFeQIN WJDvhV2FrUUPfW4D0HNHEUwZhMr38I0KmPA8+9OlckJ71yQlgDInCYXE2mMi0tRmt0hH jHZu1nzmIdJkgSaKjlupZk2rmAhWMsV7U/o3ZY9WwhQVzjlDAZrQsA5seb6zXx/TypZg ljwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DtGglfrV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i15si740567ejy.710.2020.09.01.07.44.37; Tue, 01 Sep 2020 07:45:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DtGglfrV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728374AbgIAOly (ORCPT + 99 others); Tue, 1 Sep 2020 10:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728305AbgIAOQq (ORCPT ); Tue, 1 Sep 2020 10:16:46 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F31CEC061251 for ; Tue, 1 Sep 2020 07:07:39 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id d20so1019187qka.5 for ; Tue, 01 Sep 2020 07:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:content-transfer-encoding:cc:subject:from:to:date :message-id:in-reply-to; bh=+c7gUM4M1NG54PZN7hYz3O1VCdsfHKYvNA1RcLxjRT4=; b=DtGglfrVkajnixQQs92D4Z0K2684L1xRNQx6ROkO6nL5ByavpK+z7lGv2Cj6qIVlli tivZ9xsZnEX7sLIbciNgwJSu4trMy6XhwZXTI14WxS2mR6KrA6clkgacrsmnIBGHRvHp Vdy+oFh2uQbBRobIDRo81RCTxaMMIE0B6EhjSeNt00LGQ95FAzJGP1Aa4IaR8HaTW1XS /tq9s4WiENbGx7GoGSaRe1DX8WDy8jo8dOniiKviBzPhQVxo2pTpIDWQ34Huy8qRElfy LQwPyJOTok+HG4mw0V6qHwOtJFfJVobOzD2X6sKH7Ia7ydvgiME1lIT/t2Bhahr2ioJ3 ZD1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:cc :subject:from:to:date:message-id:in-reply-to; bh=+c7gUM4M1NG54PZN7hYz3O1VCdsfHKYvNA1RcLxjRT4=; b=O+OddR6EataWoUEi0L5K2ZwhxMT8/82Cv+3ONCy9+6BPU838dVFHhu/9dWfXs4LhuS 5ZS2gKG7LwUIuh4FMVtu9erD+i+9HxpQjkD3eRSo8j8UpFCYI7QaPjb7DTFbSTwH+g0h pnQZKXEmIBNTzSv9IWfJTvTy2VJz38BxmSSfv8N3GRYubB6l5lqsxeRk89RtwkUJFdUo 8TbmDKOl4T5d4OLo+pUT+CRr5n5Y70B1SVXM7uXvYp2ubGuRhqRtJwmqlUzj+aFf/pQn SIZTjdhty8wM+cLPkyp0TcGNwX2K3jmiw6Eova/Vakacpg5Q+lore6v6A91Ew+f3EaIJ 3Ktw== X-Gm-Message-State: AOAM5321H3GYpa3i4aYZqKWdFV2I2cbSaWkefGWPRRdomX/QX/hHZPj4 qoTpyH2M2kbuqUUFNOQUEnsfdm3zReQ= X-Received: by 2002:a37:8f04:: with SMTP id r4mr2015273qkd.495.1598969259038; Tue, 01 Sep 2020 07:07:39 -0700 (PDT) Received: from localhost (198-48-202-89.cpe.pppoe.ca. [198.48.202.89]) by smtp.gmail.com with ESMTPSA id 192sm1429688qkm.110.2020.09.01.07.07.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Sep 2020 07:07:37 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Cc: , , Subject: Re: [PATCH v4 1/1] phy: tusb1210: use bitmasks to set VENDOR_SPECIFIC2 From: "Liam Beguin" To: "Vinod Koul" Date: Mon, 31 Aug 2020 12:10:18 -0400 Message-Id: In-Reply-To: <20200831110852.GO2639@vkoul-mobl> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vinod, On Mon Aug 31, 2020 at 7:08 AM EDT, Vinod Koul wrote: > Hi Liam, > > On 22-08-20, 16:53, Liam Beguin wrote: > > From: Liam Beguin > >=20 > > Start by reading the content of the VENDOR_SPECIFIC2 register and updat= e > > each bit field based on device properties when defined. > >=20 > > The use of bit masks prevents fields from overriding each other and > > enables users to clear bits which are set by default, like datapolarity > > in this instance. > >=20 > > Signed-off-by: Liam Beguin > > --- > > Changes since v1: > > - use set_mask_bits > >=20 > > Changes since v2: > > - fix missing bit shift dropped in v2 > > - rebase on 5.9-rc1 > >=20 > > Changes since v3: > > - switch to u8p_replace_bits() since there's little reason to protect > > against concurrent access > >=20 > > drivers/phy/ti/phy-tusb1210.c | 27 ++++++++++++++------------- > > 1 file changed, 14 insertions(+), 13 deletions(-) > >=20 > > diff --git a/drivers/phy/ti/phy-tusb1210.c b/drivers/phy/ti/phy-tusb121= 0.c > > index d8d0cc11d187..a63213f5972a 100644 > > --- a/drivers/phy/ti/phy-tusb1210.c > > +++ b/drivers/phy/ti/phy-tusb1210.c > > @@ -7,15 +7,16 @@ > > * Author: Heikki Krogerus > > */ > > #include > > +#include > > #include > > #include > > #include > > #include > > =20 > > #define TUSB1210_VENDOR_SPECIFIC2 0x80 > > -#define TUSB1210_VENDOR_SPECIFIC2_IHSTX_SHIFT 0 > > -#define TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_SHIFT 4 > > -#define TUSB1210_VENDOR_SPECIFIC2_DP_SHIFT 6 > > +#define TUSB1210_VENDOR_SPECIFIC2_IHSTX_MASK GENMASK(3, 0) > > +#define TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_MASK GENMASK(5, 4) > > +#define TUSB1210_VENDOR_SPECIFIC2_DP_MASK BIT(6) > > =20 > > struct tusb1210 { > > struct ulpi *ulpi; > > @@ -118,22 +119,22 @@ static int tusb1210_probe(struct ulpi *ulpi) > > * diagram optimization and DP/DM swap. > > */ > > =20 > > + reg =3D ulpi_read(ulpi, TUSB1210_VENDOR_SPECIFIC2); > > + > > /* High speed output drive strength configuration */ > > - device_property_read_u8(&ulpi->dev, "ihstx", &val); > > - reg =3D val << TUSB1210_VENDOR_SPECIFIC2_IHSTX_SHIFT; > > + if (!device_property_read_u8(&ulpi->dev, "ihstx", &val)) > > + u8p_replace_bits(®, val, (u8)TUSB1210_VENDOR_SPECIFIC2_IHSTX_MASK= ); > > Any reason for using u8p_replace_bits and not u8_replace_bits? > u8p_replace_bits seems like a more concise notation. > Also please drop the u8 casts above, they seem unnecessary here > I added the casts to get rid of compilation warnings. > > =20 > > /* High speed output impedance configuration */ > > - device_property_read_u8(&ulpi->dev, "zhsdrv", &val); > > - reg |=3D val << TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_SHIFT; > > + if (!device_property_read_u8(&ulpi->dev, "zhsdrv", &val)) > > + u8p_replace_bits(®, val, (u8)TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_MAS= K); > > =20 > > /* DP/DM swap control */ > > - device_property_read_u8(&ulpi->dev, "datapolarity", &val); > > - reg |=3D val << TUSB1210_VENDOR_SPECIFIC2_DP_SHIFT; > > + if (!device_property_read_u8(&ulpi->dev, "datapolarity", &val)) > > + u8p_replace_bits(®, val, (u8)TUSB1210_VENDOR_SPECIFIC2_DP_MASK); > > =20 > > - if (reg) { > > - ulpi_write(ulpi, TUSB1210_VENDOR_SPECIFIC2, reg); > > - tusb->vendor_specific2 =3D reg; > > - } > > + ulpi_write(ulpi, TUSB1210_VENDOR_SPECIFIC2, reg); > > + tusb->vendor_specific2 =3D reg; > > =20 > > tusb->phy =3D ulpi_phy_create(ulpi, &phy_ops); > > if (IS_ERR(tusb->phy)) > >=20 > > base-commit: 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5 > > --=20 > > 2.27.0 > > -- > ~Vinod Thanks, Liam