Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751474AbdI1GLv (ORCPT ); Thu, 28 Sep 2017 02:11:51 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:4456 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750914AbdI1GLt (ORCPT ); Thu, 28 Sep 2017 02:11:49 -0400 X-IronPort-AV: E=Sophos;i="5.42,448,1500966000"; d="scan'208";a="5085897" Subject: Re: [PATCH v2 1/5] media: atmel_isc: Add spin lock for clock enable ops To: Sakari Ailus CC: Mauro Carvalho Chehab , , Nicolas Ferre , Jonathan Corbet , Hans Verkuil , , Linux Media Mailing List References: <20170918063925.6372-1-wenyou.yang@microchip.com> <20170918063925.6372-2-wenyou.yang@microchip.com> <20170927071626.mok5h3ckisyipy53@valkosipuli.retiisi.org.uk> From: "Yang, Wenyou" Message-ID: Date: Thu, 28 Sep 2017 14:11:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170927071626.mok5h3ckisyipy53@valkosipuli.retiisi.org.uk> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2368 Lines: 83 Hi Sakari, On 2017/9/27 15:16, Sakari Ailus wrote: > Hi Wenyou, > > On subject: > > s/_/-/ > > On Mon, Sep 18, 2017 at 02:39:21PM +0800, Wenyou Yang wrote: >> Add the spin lock for the clock enable and disable operations. >> >> Signed-off-by: Wenyou Yang >> --- >> >> Changes in v2: None >> >> drivers/media/platform/atmel/atmel-isc.c | 14 +++++++++++++- >> 1 file changed, 13 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c >> index 2f8e345d297e..78114193af4c 100644 >> --- a/drivers/media/platform/atmel/atmel-isc.c >> +++ b/drivers/media/platform/atmel/atmel-isc.c >> @@ -65,6 +65,7 @@ struct isc_clk { >> struct clk_hw hw; >> struct clk *clk; >> struct regmap *regmap; >> + spinlock_t *lock; > Can this work? I don't see lock being assigned anywhere. Did you mean > > spinlock_t lock; > > ? Ooh. I made a mistake. Thank you very much. > >> u8 id; >> u8 parent_id; >> u32 div; >> @@ -312,26 +313,37 @@ static int isc_clk_enable(struct clk_hw *hw) >> struct isc_clk *isc_clk = to_isc_clk(hw); >> u32 id = isc_clk->id; >> struct regmap *regmap = isc_clk->regmap; >> + unsigned long flags; >> + unsigned int status; >> >> dev_dbg(isc_clk->dev, "ISC CLK: %s, div = %d, parent id = %d\n", >> __func__, isc_clk->div, isc_clk->parent_id); >> >> + spin_lock_irqsave(isc_clk->lock, flags); >> regmap_update_bits(regmap, ISC_CLKCFG, >> ISC_CLKCFG_DIV_MASK(id) | ISC_CLKCFG_SEL_MASK(id), >> (isc_clk->div << ISC_CLKCFG_DIV_SHIFT(id)) | >> (isc_clk->parent_id << ISC_CLKCFG_SEL_SHIFT(id))); >> >> regmap_write(regmap, ISC_CLKEN, ISC_CLK(id)); >> + spin_unlock_irqrestore(isc_clk->lock, flags); >> >> - return 0; >> + regmap_read(regmap, ISC_CLKSR, &status); >> + if (status & ISC_CLK(id)) >> + return 0; >> + else >> + return -EINVAL; >> } >> >> static void isc_clk_disable(struct clk_hw *hw) >> { >> struct isc_clk *isc_clk = to_isc_clk(hw); >> u32 id = isc_clk->id; >> + unsigned long flags; >> >> + spin_lock_irqsave(isc_clk->lock, flags); >> regmap_write(isc_clk->regmap, ISC_CLKDIS, ISC_CLK(id)); >> + spin_unlock_irqrestore(isc_clk->lock, flags); >> } >> >> static int isc_clk_is_enabled(struct clk_hw *hw) Best Regards, Wenyou Yang