Skip to content

Commit 513a4ab

Browse files
committed
ARM: OMAP2+: Prepare class allocation for dynamically allocated modules
For dynamically allocated sysconfig data we only need to allocate a new class for the cases where the class is shared. For dynamically allocated struct omap_hwmod we will always allocate a new class. Let's add detection for when we need to allocate a new class by comparing the class name against the module name. If they match, there's no need to allocate a new calls as we don't have case of mixed platform data and dts data initialized modules for the same class. Let's also move the init of class data inside the spinlock. Cc: Paul Walmsley <[email protected]> Cc: Tero Kristo <[email protected]> Signed-off-by: Tony Lindgren <[email protected]>
1 parent 798bd17 commit 513a4ab

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

arch/arm/mach-omap2/omap_hwmod.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3443,7 +3443,7 @@ static int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh,
34433443
u32 idlemodes)
34443444
{
34453445
struct omap_hwmod_class_sysconfig *sysc;
3446-
struct omap_hwmod_class *class;
3446+
struct omap_hwmod_class *class = NULL;
34473447
void __iomem *regs = NULL;
34483448
unsigned long flags;
34493449

@@ -3467,19 +3467,21 @@ static int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh,
34673467
}
34683468

34693469
/*
3470-
* We need new oh->class as the other devices in the same class
3470+
* We may need a new oh->class as the other devices in the same class
34713471
* may not yet have ioremapped their registers.
34723472
*/
3473-
class = kmemdup(oh->class, sizeof(*oh->class), GFP_KERNEL);
3474-
if (!class)
3475-
return -ENOMEM;
3476-
3477-
class->sysc = sysc;
3473+
if (oh->class->name && strcmp(oh->class->name, data->name)) {
3474+
class = kmemdup(oh->class, sizeof(*oh->class), GFP_KERNEL);
3475+
if (!class)
3476+
return -ENOMEM;
3477+
}
34783478

34793479
spin_lock_irqsave(&oh->_lock, flags);
34803480
if (regs)
34813481
oh->_mpu_rt_va = regs;
3482-
oh->class = class;
3482+
if (class)
3483+
oh->class = class;
3484+
oh->class->sysc = sysc;
34833485
oh->_state = _HWMOD_STATE_INITIALIZED;
34843486
_setup(oh, NULL);
34853487
spin_unlock_irqrestore(&oh->_lock, flags);

0 commit comments

Comments
 (0)