Skip to content

Commit f21d326

Browse files
Wenyou Yangehristev
authored andcommitted
media: atmel-isc: Add spin lock for clock enable ops
Add the spin lock for the clock enable and disable operations. Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
1 parent 8fd5926 commit f21d326

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

drivers/media/platform/atmel/atmel-isc.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct isc_clk {
6565
struct clk_hw hw;
6666
struct clk *clk;
6767
struct regmap *regmap;
68+
spinlock_t lock;
6869
u8 id;
6970
u8 parent_id;
7071
u32 div;
@@ -312,26 +313,37 @@ static int isc_clk_enable(struct clk_hw *hw)
312313
struct isc_clk *isc_clk = to_isc_clk(hw);
313314
u32 id = isc_clk->id;
314315
struct regmap *regmap = isc_clk->regmap;
316+
unsigned long flags;
317+
unsigned int status;
315318

316319
dev_dbg(isc_clk->dev, "ISC CLK: %s, div = %d, parent id = %d\n",
317320
__func__, isc_clk->div, isc_clk->parent_id);
318321

322+
spin_lock_irqsave(&isc_clk->lock, flags);
319323
regmap_update_bits(regmap, ISC_CLKCFG,
320324
ISC_CLKCFG_DIV_MASK(id) | ISC_CLKCFG_SEL_MASK(id),
321325
(isc_clk->div << ISC_CLKCFG_DIV_SHIFT(id)) |
322326
(isc_clk->parent_id << ISC_CLKCFG_SEL_SHIFT(id)));
323327

324328
regmap_write(regmap, ISC_CLKEN, ISC_CLK(id));
329+
spin_unlock_irqrestore(&isc_clk->lock, flags);
325330

326-
return 0;
331+
regmap_read(regmap, ISC_CLKSR, &status);
332+
if (status & ISC_CLK(id))
333+
return 0;
334+
else
335+
return -EINVAL;
327336
}
328337

329338
static void isc_clk_disable(struct clk_hw *hw)
330339
{
331340
struct isc_clk *isc_clk = to_isc_clk(hw);
332341
u32 id = isc_clk->id;
342+
unsigned long flags;
333343

344+
spin_lock_irqsave(&isc_clk->lock, flags);
334345
regmap_write(isc_clk->regmap, ISC_CLKDIS, ISC_CLK(id));
346+
spin_unlock_irqrestore(&isc_clk->lock, flags);
335347
}
336348

337349
static int isc_clk_is_enabled(struct clk_hw *hw)
@@ -492,6 +504,7 @@ static int isc_clk_register(struct isc_device *isc, unsigned int id)
492504
isc_clk->regmap = regmap;
493505
isc_clk->id = id;
494506
isc_clk->dev = isc->dev;
507+
spin_lock_init(&isc_clk->lock);
495508

496509
isc_clk->clk = clk_register(isc->dev, &isc_clk->hw);
497510
if (IS_ERR(isc_clk->clk)) {

0 commit comments

Comments
 (0)