Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp720753ybh; Sun, 12 Jul 2020 22:09:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDFU8rcANXgKQqkUbJfjbDwpQpz2PzsLKG1XhBBxOCEXI678KHFcdXALhh4Tg5fVnBLGqo X-Received: by 2002:aa7:ce91:: with SMTP id y17mr68359995edv.105.1594616985904; Sun, 12 Jul 2020 22:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594616985; cv=none; d=google.com; s=arc-20160816; b=l7Ne2RT1NQpW5n3pSKbaYtNbNFvjCt4BqpkB7G0YYU0+lVVylWhqrRpzv/ukIDKK7R Sa+qQweGtqVBacKOG8PThsdkhruAGjAnDznSJ3h+XFaXvG715i888BGQeTKTpVt2PBse 2F2zGPktfft8MzyVEB3MR8l/B7uImLQC2QkmD2GW6r8/3CMH5HF6jPIWzjjjZJd/omVK 0k6/itrjs8AQ2of/0XUbDnkiZymBKnuMmpvHyTCClVttt8gC6x+cDrD6/kIq47fa1H7l 0IiD7demb+eSKmKjgWnrykMslmOOqZBWfNABYYwiH3CMn0578hTf4uuFcFQx2GXrnyd4 PZWg== 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=aD4EFIsPmnZjcKm1NU7Xo2ody48GwPzFmXTA/Lgl3r4=; b=EveQJ7esuS5g7uegF3JVY8mZkHCi5h1H7Il/VNI3KHxYv+D2e6wDNfl5OE9AG5oMQr pm/G4Uhpo7DH8b5YKlIqZ9so9bVyjoqTtXCxW7B8ZWuDeH/Y8hU8i3r1e9uYjXJz468I /SmFGfZEXGH74W89ig55lk4Wy2NgCAPXMegzMAcfMFKFW8SeAyUXOynDR9xvoOuARDpw 9IZ4roZ5aqBMgZJIKRWYqF14zneeIfw61taiAmviE8qavCCbwqucEH8AzEvqthOoTprT MbLP85RW6O0lGczGGCjf1sRGxJPMVHpr4dpcxeQYMzk9SzY0835HlDWz7S6RfudtecFz hjTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GYiltRdQ; 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 bf28si9288467edb.312.2020.07.12.22.09.23; Sun, 12 Jul 2020 22:09:45 -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=GYiltRdQ; 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 S1728488AbgGMFIo (ORCPT + 99 others); Mon, 13 Jul 2020 01:08:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:49584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725830AbgGMFIo (ORCPT ); Mon, 13 Jul 2020 01:08:44 -0400 Received: from localhost (unknown [122.182.251.219]) (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 D6E4420724; Mon, 13 Jul 2020 05:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594616923; bh=l9woS6qlWWRbrNRtwz0odix51LNFvdItegOJQMN4QOg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GYiltRdQJZKiHRMk4Fr6TeJWi9EeeW1TfU3hOq0LI+1tD7pe/w6hlEfUE8I7aLrL7 ETUVNB57QxqlVMatJrqRM6R/BKEk7vf0IyOH7xpS4j/7lr73Hsa7gd054VyIVkzTRt o77PmUklaw7BbAcaxgwTjWpL4vSTeqS6ZW5G2ZvY= Date: Mon, 13 Jul 2020 10:38:39 +0530 From: Vinod Koul To: Liam Beguin Cc: kishon@ti.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/1] phy: tusb1210: use bitmasks to set VENDOR_SPECIFIC2 Message-ID: <20200713050839.GS34333@vkoul-mobl> References: <20200702010649.16323-1-liambeguin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200702010649.16323-1-liambeguin@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01-07-20, 21:06, 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 > --- > drivers/phy/ti/phy-tusb1210.c | 29 ++++++++++++++++------------- > 1 file changed, 16 insertions(+), 13 deletions(-) > > diff --git a/drivers/phy/ti/phy-tusb1210.c b/drivers/phy/ti/phy-tusb1210.c > index d8d0cc11d187..a957655ebd36 100644 > --- a/drivers/phy/ti/phy-tusb1210.c > +++ b/drivers/phy/ti/phy-tusb1210.c > @@ -13,9 +13,9 @@ > #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 0x0f > +#define TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_MASK 0x30 Why not be better and use GENMASK(3, 0) and GENMASK(5, 4) for these > +#define TUSB1210_VENDOR_SPECIFIC2_DP_MASK BIT(6) > > struct tusb1210 { > struct ulpi *ulpi; > @@ -118,22 +118,25 @@ 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)) > + reg = (reg & ~TUSB1210_VENDOR_SPECIFIC2_IHSTX_MASK) | > + (val & TUSB1210_VENDOR_SPECIFIC2_IHSTX_MASK); It would be better to use a helper to do this > > /* 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)) > + reg = (reg & ~TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_MASK) | > + (val & 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)) > + reg = (reg & ~TUSB1210_VENDOR_SPECIFIC2_DP_MASK) | > + (val & 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: cd77006e01b3198c75fb7819b3d0ff89709539bb fatal: bad object cd77006e01b3198c75fb7819b3d0ff89709539bb in linux-phy.git -- ~Vinod