Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp894165pxk; Mon, 31 Aug 2020 04:24:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw71y4glyGCJBS85vGifPFNbc2OS5aB1uSJhlA9D9eqHlEOTDuVDbEDGNzLhb5ev+BMIW4M X-Received: by 2002:a17:906:4c42:: with SMTP id d2mr663244ejw.506.1598873042472; Mon, 31 Aug 2020 04:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598873042; cv=none; d=google.com; s=arc-20160816; b=r6re19Z6YkV76hCu4VQ4xDiE9sirR7ea0wCSFSiIaM5M1swYmcmI+GRNHOflr67H6q 5pIO01+zpKXaqWM4PP2tf+d8mL3JEE+o154KB7iI31wzDFQkIRHeIfZ8RQPDBPLEwjpT kInXJcD241dQ/l7wxX4i0mjs8GNxoMZpNNT2KeelNuF2ocPBzaQzMd3AkEtroE9ozhHA BFufx4oL9h42s0GlvaXGmtMLQG57cIC2ynvtdxLMw4Rg4DEZm/P7hEpzqnLMZZkThRgs xHSKttrH0wn3+Uz4giQ/y89auo/KfqUdaQ1WbcgKeWrhv/bIQ+ZoPu0TJMzgj9XLqMjJ gOUw== 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:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bpGJm4IYslFuoSZ3o6novb/6qhN7y/aQ5q8x2EyNyWM=; b=i2dhddh3YqqNXM9Fvjnd6+qHDUo9YYmmxs3M1tGikOTy6DFFkqRQmzFYXM22411+0E s4Gt06f2/VVP51GUduR5a0p9x0KdwX447hVyyrseuoH2gxGbQJ3LGoSmKTdPLnfiv5/h NnFhaTSutSBLzrHhopa8yrsP6zQLqTa8hwRm92FLUyotvSQh4IERVL00XWC5zG8pdNIh sI9cIFnc6ZGSiV9P0uVTQ6WdxBA1tNA8w9t/IYkYLGmSQpDfPZccRgfRenptrxsCX58Z JoveZe9JK50C6Fkpl8d7VvqxjJa5XiAgLQXok7eybVW6BsE9x62aqgkAia29IEUfpS2u 5sKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q9i5JjFR; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r26si3850748eda.569.2020.08.31.04.23.39; Mon, 31 Aug 2020 04:24:02 -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=@kernel.org header.s=default header.b=q9i5JjFR; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727783AbgHaLVg (ORCPT + 99 others); Mon, 31 Aug 2020 07:21:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:34028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726726AbgHaLR6 (ORCPT ); Mon, 31 Aug 2020 07:17:58 -0400 Received: from localhost (unknown [122.171.38.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0162D206F0; Mon, 31 Aug 2020 11:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598872136; bh=luuKNVi+KwBr1ekM6udfXcrivJveuP/tHqNrnFBYWzo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=q9i5JjFRgd6CT0v9YoaM43xpHDTkyeMvqzq3Ssb0Bwy66dDENHm+T2c4kSr9F6e5F yEMdfTYkuFjp5dQur7ohdLp0G40YvgqkgngONSvuR2XT1YwwpxfCQsGF1eAe8OHKhd h9qDDRaJm9JIIW54F64ilO+Gwlnky3sIxbz/qE8Y= Date: Mon, 31 Aug 2020 16:38:52 +0530 From: Vinod Koul To: Liam Beguin Cc: geert@linux-m68k.org, kishon@ti.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/1] phy: tusb1210: use bitmasks to set VENDOR_SPECIFIC2 Message-ID: <20200831110852.GO2639@vkoul-mobl> References: <20200822205320.9746-1-liambeguin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200822205320.9746-1-liambeguin@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Liam, On 22-08-20, 16:53, Liam Beguin wrote: > From: Liam Beguin > > Start by reading the content of the VENDOR_SPECIFIC2 register and update > each bit field based on device properties when defined. > > 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. > > Signed-off-by: Liam Beguin > --- > Changes since v1: > - use set_mask_bits > > Changes since v2: > - fix missing bit shift dropped in v2 > - rebase on 5.9-rc1 > > Changes since v3: > - switch to u8p_replace_bits() since there's little reason to protect > against concurrent access > > drivers/phy/ti/phy-tusb1210.c | 27 ++++++++++++++------------- > 1 file changed, 14 insertions(+), 13 deletions(-) > > diff --git a/drivers/phy/ti/phy-tusb1210.c b/drivers/phy/ti/phy-tusb1210.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 > > #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) > > struct tusb1210 { > struct ulpi *ulpi; > @@ -118,22 +119,22 @@ static int tusb1210_probe(struct ulpi *ulpi) > * diagram optimization and DP/DM swap. > */ > > + reg = ulpi_read(ulpi, TUSB1210_VENDOR_SPECIFIC2); > + > /* High speed output drive strength configuration */ > - device_property_read_u8(&ulpi->dev, "ihstx", &val); > - reg = 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? Also please drop the u8 casts above, they seem unnecessary here > > /* High speed output impedance configuration */ > - device_property_read_u8(&ulpi->dev, "zhsdrv", &val); > - reg |= val << TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_SHIFT; > + if (!device_property_read_u8(&ulpi->dev, "zhsdrv", &val)) > + u8p_replace_bits(®, val, (u8)TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_MASK); > > /* DP/DM swap control */ > - device_property_read_u8(&ulpi->dev, "datapolarity", &val); > - reg |= 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); > > - if (reg) { > - ulpi_write(ulpi, TUSB1210_VENDOR_SPECIFIC2, reg); > - tusb->vendor_specific2 = reg; > - } > + ulpi_write(ulpi, TUSB1210_VENDOR_SPECIFIC2, reg); > + tusb->vendor_specific2 = reg; > > tusb->phy = ulpi_phy_create(ulpi, &phy_ops); > if (IS_ERR(tusb->phy)) > > base-commit: 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5 > -- > 2.27.0 -- ~Vinod