rtc: fix double lock on UIE emulation

With commit 5ad31a575157147b43fa84ef1e21471661653878 ("rtc: remove BKL
for ioctl()"), RTC_UIE_ON ioctl cause double lock on rtc->ops_lock.
The ops_lock must not be held while set_uie() calls rtc_read_time()
which takes the lock. Also clear_uie() does not need ops_lock. This
patch fixes return value of RTC_UIE_OFF ioctl too.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: David Brownell <david-b@pacbell.net>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Atsushi Nemoto and committed by Linus Torvalds 1d96469a ff9bc512

+4 -1
+4 -1
drivers/rtc/rtc-dev.c
··· 403 404 #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL 405 case RTC_UIE_OFF: 406 clear_uie(rtc); 407 - break; 408 409 case RTC_UIE_ON: 410 err = set_uie(rtc); 411 #endif 412 default: 413 err = -ENOTTY;
··· 403 404 #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL 405 case RTC_UIE_OFF: 406 + mutex_unlock(&rtc->ops_lock); 407 clear_uie(rtc); 408 + return 0; 409 410 case RTC_UIE_ON: 411 + mutex_unlock(&rtc->ops_lock); 412 err = set_uie(rtc); 413 + return err; 414 #endif 415 default: 416 err = -ENOTTY;