From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756036AbeARNGt (ORCPT ); Thu, 18 Jan 2018 08:06:49 -0500 Received: from lelnx194.ext.ti.com ([198.47.27.80]:28120 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754815AbeARNGq (ORCPT ); Thu, 18 Jan 2018 08:06:46 -0500 Subject: Re: [PATCH v5 21/44] clk: davinci: New driver for TI DA8XX USB PHY clocks To: David Lechner , , , CC: Michael Turquette , Stephen Boyd , Rob Herring , Mark Rutland , Kevin Hilman , Adam Ford , References: <1515377863-20358-1-git-send-email-david@lechnology.com> <1515377863-20358-22-git-send-email-david@lechnology.com> From: Sekhar Nori Message-ID: <493e4809-6b77-7772-70c7-ad0fa04e9033@ti.com> Date: Thu, 18 Jan 2018 18:35:39 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1515377863-20358-22-git-send-email-david@lechnology.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 08 January 2018 07:47 AM, David Lechner wrote: > +static int da8xx_usb1_phy_clk_set_parent(struct clk_hw *hw, u8 index) > +{ > + struct da8xx_usb1_phy_clk *clk = to_da8xx_usb1_phy_clk(hw); > + unsigned int mask, val; > + > + /* Set the USB 1.1 PHY clock mux based on the parent clock. */ > + mask = CFGCHIP2_USB1PHYCLKMUX; > + switch (index) { > + case DA8XX_USB1_PHY_CLK_PARENT_USB_REFCLKIN: > + val = CFGCHIP2_USB1PHYCLKMUX; > + break; > + case DA8XX_USB1_PHY_CLK_PARENT_USB0_PHY_PLL: > + val = 0; > + break; > + default: > + return -EINVAL; > + } > + > + regmap_write_bits(clk->regmap, CFGCHIP(2), mask, val); This function can be simplified quite a bit if you use a shift. #define CFGCHIP2_USB1PHYCLKMUX_SHIFT 12 static int da8xx_usb1_phy_clk_set_parent(struct clk_hw *hw, u8 index) { struct da8xx_usb1_phy_clk *clk = to_da8xx_usb1_phy_clk(hw); regmap_write_bits(clk->regmap, CFGCHIP(2), CFGCHIP2_USB1PHYCLKMUX, index << CFGCHIP2_USB1PHYCLKMUX_SHIFT); } Same thing for da8xx_usb0_phy_clk_set_parent() as well. Thanks, Sekhar