Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1787188pxk; Tue, 1 Sep 2020 07:49:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUcD1IAydSgehd7QyaFNdP+8xJ6CdmowLNxZEtIPTBc41Ipxtz7XC0x5ewAPknkZ39eaFJ X-Received: by 2002:a50:eb92:: with SMTP id y18mr1917738edr.373.1598971767245; Tue, 01 Sep 2020 07:49:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598971767; cv=none; d=google.com; s=arc-20160816; b=bZAeerGzlwNztyoow4l7kjmK4QDKzz8rKsWs4+UpwLnqt8WEYsYSyfxmciiTps4h+F SHumbnL7zYCuUhJcM0/+lrFaQrGNjfbrMKuMKy8f7h9KMVOMoY81ijK0ATZFqYtVLcus hORZ2GVjiFvdJtkBGxk3kREAUMR3w5vKJWNx2oMMBMyoWgwd3ol5gjKDlzjpgUuuVj/E eh3DACX3kYxnR/kRYN9P8xAfuQ2i0VS8+PCJAPaIuhZk5AvAJTBA3qNBvypKyTZtejjH 2BeFgJvjPU9rfkeY600gOjT2eJ8asILdvEdyGSzWYbovI+jVIOKe8DPPEQpCL/iU6WJM /ZHg== 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=BFo5n9HaRlQNxB7HLMjHORpQ6JwPJVs2FExjjB8oDWM=; b=yux9gkOpMxLUy2wISbNoBv964tRn3dcntn9rrc9m8qi7plX7Liy0JUEkjnA2I8khr0 E7YJOEDf4a8BJ30lkRXcx9g+MOV+Ym2bmuo9HSf7pTm8lGMAiCt8bJyiz/ZfB7tNqAIM 0pnniXdxX2WJxLi5Z/sgAwwrGVXdZRl71kbXe03aIa6XoUS+bC6RbkCqBGMuMtXSKyTR rwK95ond8SsiMxrfTqCJfEca1OiULyoEedMjoJ8Om1xQJBUBtjxIN8NsS7Np5njnASsH /rLL5cWzPPdb/I/qUfHhyxcbw2EbQKUgjq1/BDpuYFrNEzVtcl8CHeB8GCjeorJKpvt1 u6gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DEMQN9Kf; 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 l23si792880ejb.496.2020.09.01.07.49.03; Tue, 01 Sep 2020 07:49:27 -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=DEMQN9Kf; 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 S1727796AbgIAOsd (ORCPT + 99 others); Tue, 1 Sep 2020 10:48:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727937AbgIAOPL (ORCPT ); Tue, 1 Sep 2020 10:15:11 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CDFDC06125C for ; Tue, 1 Sep 2020 07:14:53 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id u3so1034528qkd.9 for ; Tue, 01 Sep 2020 07:14:53 -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=BFo5n9HaRlQNxB7HLMjHORpQ6JwPJVs2FExjjB8oDWM=; b=DEMQN9KfmUh5uM3zBJRl3lQDqYom89qxHOq2ebXdd3tjitjgsJQFOmhT7EPQoi1axi 49hDcvTNjGarxHI13WwKAdCOL6sFIO8AVEBBJh9u9ZhGS0kf/odIjTbVM0Y8dDyh/Gyw q8eArrgvvZi6g6EIaqWa3vFouR0+OHqLk/of70PXe23AdoXhMpDUgJdI2INrHjKEHHta lk2egh32w656MFJycIjuONVwMHhnKh1igySepYcRBy6W07+99N+CxwUZWeyd+IamiLTa /1fDAZ1zKCklS1rvpw0+bK613WV9YEKcOpIoWNyJ4YUu05NPBfKe6QEljJcS0Essp5Xx klrQ== 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=BFo5n9HaRlQNxB7HLMjHORpQ6JwPJVs2FExjjB8oDWM=; b=ULg5DRVEboQhFD3zNJloqPbhI2tKH9+gA8X3lNAllYrgmhteCgBL88MXAowrHq1/kV AJ02vx64r+NLgDng/JbhLgTl2w+4k6FPVCfNXONuqZVFDAH+mpKtKFotunrVyP1Kms+Y RpaYblYXQebLz6RbKtHTano7URFuH2XHp0OaYATgom8J8FFIaoqf06DJALFKe3p1uOzn IexPkqYXjozFGpnbrVl5XsbytErvTRty1b69kj8Wznt8YQ4/RyCfidu41ReLOf/KQC7Y QXbJe3nNtJ9bnxinI9nupL6XtBAiB5R9mwijpdx2F5l+jP+tTbRZyAaDHBSN+zoBLcxz IqIg== X-Gm-Message-State: AOAM532GHJI0+BNE/XQsQei2CHWee68af2n9tjE/TkqIErxNJeb9a1g3 dPcmfoeXblXrG86evmuZ0PY= X-Received: by 2002:ae9:e814:: with SMTP id a20mr2100888qkg.429.1598969692340; Tue, 01 Sep 2020 07:14:52 -0700 (PDT) Received: from localhost (198-48-202-89.cpe.pppoe.ca. [198.48.202.89]) by smtp.gmail.com with ESMTPSA id g15sm1461629qtx.57.2020.09.01.07.14.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Sep 2020 07:14:51 -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: Tue, 01 Sep 2020 10:11:38 -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 seemed like a more concise notation. > Also please drop the u8 casts above, they seem unnecessary here > I added the type 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