• Atsushi Nemoto's avatar
    rtc-stk17ta8: fix races around device registration · 3151520d
    Atsushi Nemoto authored
    - Call dev_set_drvdata before rtc device creation.
    
    - Use its own spinlock instead of rtc->irq_lock.  Because pdata->rtc
      must be initialized to use the irq_lock (pdata->rtc->irq_lock).  There
      is a small window which rtc methods can be called before pdata->rtc is
      initialized.
    
      And there is no need use the irq_lock to protect hardware registers.
      The driver's own spinlock shoule be enough.
    
    - Check pdata->rtc before calling rtc_update_irq.
    
    - Use alarm_irq_enable and remove ioctl routine.
    
    - Use devres APIs and simplify error/remove path.
    
    These fixes are ported from ds1553 driver and just compile-tested only.
    Signed-off-by: default avatarAtsushi Nemoto <anemo@mba.ocn.ne.jp>
    Cc: Alessandro Zummo <alessandro.zummo@towertech.it>
    Cc: Thomas Hommel <thomas.hommel@gefanuc.com>
    Cc: David Brownell <david-b@pacbell.net>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    3151520d
rtc-stk17ta8.c 11 KB