21 Aug, 2008

1 commit

  • 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
    Cc: David Brownell
    Cc: Russell King
    Cc: Alessandro Zummo
    Cc: "Rafael J. Wysocki"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Atsushi Nemoto
     

13 Aug, 2008

1 commit

  • Revert commit 51a776fa7a7997e726d4a478eda0854c6f9143bd ("rtc: cdev
    lock_kernel() pushdown"). The RTC framework does not need BKL
    protection.

    Signed-off-by: David Brownell
    Cc: Jonathan Corbet
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

31 Jul, 2008

2 commits

  • Solves http://bugzilla.kernel.org/show_bug.cgi?id=11127

    The old rtc.c driver did it and some drivers (like rtc-sh) do it in their
    release function, though they should not -- because they should provide
    the irq_set_state op and the rtc framework itself should care about it.
    This patch makes it do so.

    I am aware that some drivers, like rtc-sh, handle userspace PIE sets in
    their ioctl op (instead of having the framework call the op), exporting
    the irq_set_state op at the same time. The logic in rtc_irq_set_state
    should make sure it doesn't matter and the driver should not need to care
    stopping periodic interrupts in its release routine any more.

    The correct way, in my opinion, should be this:
    1) The driver provides the irq_set_state op and does not care closing the
    interrupts in its release op.
    2) If the driver does not provide the op and handles PIE in the ioctl op, it's
    reponsible for closing them in its release op.
    3) Something similar for other IRQs, like UIE -- if there's no in-kernel API
    like irq_set_state, handle it in ioctl and release ops. The framework will
    be responsible either for everything or for nothing. (This will probably
    change later.)

    Signed-off-by: Tomas Janousek
    Acked-by: David Brownell
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomas Janousek
     
  • It was pointed out that the RTC framework handles its mutex locks oddly
    ... returning -EBUSY when interrupted. This fixes that by returning the
    value of mutex_lock_interruptible() (i.e. -EINTR).

    Signed-off-by: David Brownell
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

25 Jul, 2008

1 commit

  • Remove implicit use of BKL in ioctl() from the RTC framework.

    Instead, the rtc->ops_lock is used. That's the same lock that already
    protects the RTC operations when they're issued through the exported
    rtc_*() calls in drivers/rtc/interface.c ... making this a bugfix, not
    just a cleanup, since both ioctl calls and set_alarm() need to update IRQ
    enable flags and that implies a common lock (which RTC drivers as a rule
    do not provide on their own).

    A new comment at the declaration of "struct rtc_class_ops" summarizes
    current locking rules. It's not clear to me that the exceptions listed
    there should exist ... if not, those are pre-existing problems which can
    be fixed in a patch that doesn't relate to BKL removal.

    Signed-off-by: David Brownell
    Cc: Alan Cox
    Cc: Jonathan Corbet
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

21 Jun, 2008

1 commit


07 Feb, 2008

1 commit

  • Start making the rtc-cmos alarm act more like a oneshot alarm by disabling
    that alarm after its IRQ fires. (ACPI hooks are also needed.)

    The Linux RTC framework has previously been a bit vague in this area, but
    any other behavior is problematic and not very portable. RTCs with full
    YYYY-MM-DD HH:MM[:SS] alarms won't have a problem here. Only ones with
    partial match criteria, with the most visible example being the PC RTC, get
    confused. (Because the criteria will match repeatedly.)

    Update comments relating to that oneshot behavior and timezone handling.
    (Timezones are another issue that's mostly visible with rtc-cmos. That's
    because PCs often dual-boot MS-Windows, which likes its RTC to match local
    wall-clock time instead of UTC.)

    Signed-off-by: David Brownell
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

06 Dec, 2007

1 commit

  • We must make sure that the RTC_DEV_BUSY flag has proper lock semantics,
    i.e. that the RTC_DEV_BUSY stores clearing the flag don't get reordered
    before the preceeding stores and loads and vice versa.

    Spotted by Nick Piggin.

    Signed-off-by: Jiri Kosina
    Cc: Nick Piggin
    Cc: David Brownell
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jiri Kosina
     

30 Nov, 2007

1 commit

  • RTC code is using mutex to assure exclusive access to /dev/rtc. This is
    however wrong usage, as it leaves the mutex locked when returning into
    userspace, which is unacceptable.

    Convert rtc->char_lock into bit operation.

    Signed-off-by: Jiri Kosina
    Acked-by: Alessandro Zummo
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jiri Kosina
     

17 Oct, 2007

3 commits

  • drivers/char/rtc.c allowed RTC_PIE_ON ioctls for non-root users, as long as
    the current interval (set via RTC_IRQP_SET) is
    Acked-by: Alessandro Zummo
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Bryan Kadzban
     
  • In rtc-dev.c, when a rtc device is opened, file->private_data is already
    attached with the rtc device pointer, so there is no need to call
    to_rtc_device() to convert file->private_data to a rtc device pointer.

    Acked-by: Alessandro Zummo
    Signed-off-by: Mark Zhan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mark Zhan
     
  • Add kernel/kernel and kernel/user locking for the periodic irq feature of
    the rtc class.

    PIE ioctls are also supported.

    Signed-off-by: Alessandro Zummo
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alessandro Zummo
     

01 Aug, 2007

1 commit


18 Jul, 2007

1 commit


09 May, 2007

5 commits

  • This fixes a common glitch in how RTC drivers handle two "set alarm" modes,
    by getting rid of the surprising/hidden one that was rarely implemented
    correctly (and which could expose nonportable hardware-specific behavior).

    The glitch comes from the /dev/rtcX logic implementing the legacy
    RTC_ALM_SET (limited to 24 hours, needing RTC_AIE_ON) ioctl on top of the
    RTC driver call providing access to the newer RTC_WKALM_SET (without those
    limitations) by initializing the day/month/year fields to be invalid ...
    that second mode.

    Now, since few RTC drivers check those fields, and most hardware misbehaves
    when faced with invalid date fields, many RTC drivers will set bogus alarm
    times on those RTC_ALM_SET code paths. (Several in-tree drivers have that
    issue, and I also noticed it with code reviews on several new RTC drivers.)

    This patch ensures that RTC drivers never see such invalid alarm fields, by
    moving some logic out of rtc-omap into the RTC_ALM_SET code and adding an
    explicit check (which will prevent the issue on other code paths).

    Signed-off-by: David Brownell
    Cc: Scott Wood
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • Fix a goof in the revised classdev support for RTCs: make sure the /dev
    node info is ready before the device is registered, not after. Otherwise
    the /sys/class/rtc/rtcN/dev attribute won't be created and then udev won't
    have the information it needs to create the /dev/rtcN node.

    Signed-off-by: David Brownell
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • Finish converting the RTC framework so it no longer uses class_device.

    Signed-off-by: David Brownell
    Acked-by: Greg Kroah-Hartman
    Acked-By: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • This patch removes class_device from the programming interface that the RTC
    framework exposes to the rest of the kernel. Now an rtc_device is passed,
    which is more type-safe and streamlines all the relevant code.

    Signed-off-by: David Brownell
    Acked-by: Greg Kroah-Hartman
    Acked-By: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • This simplifies the /dev support by removing a superfluous class_device (the
    /sys/class/rtc-dev stuff) and the class_interface that hooks it into the rtc
    core. Accordingly, if it's configured then /dev support is now part of the
    RTC core, and is never a separate module.

    It's another step towards being able to remove "struct class_device".

    [bunk@stusta.de: drivers/rtc/rtc-dev.c should #include "rtc-core.h"]
    Signed-off-by: David Brownell
    Acked-by: Greg Kroah-Hartman
    Acked-By: Alessandro Zummo
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

13 Feb, 2007

1 commit

  • Many struct file_operations in the kernel can be "const". Marking them const
    moves these to the .rodata section, which avoids false sharing with potential
    dirty data. In addition it'll catch accidental writes at compile time to
    these shared resources.

    Signed-off-by: Arjan van de Ven
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     

10 Feb, 2007

1 commit


14 Dec, 2006

1 commit


05 Dec, 2006

1 commit


26 Nov, 2006

2 commits

  • I got a lockdep warning when running "rtctest" so I though it'd be good
    to see what was up.

    - The warning was for rtc->irq_task_lock, gotten from rtc_update_irq()
    by irq handlerss ... but in a handful of other cases, grabbed without
    blocking IRQs.

    - Some callers to rtc_update_irq() were not ensuring IRQs were blocked,
    yet the routine expects that; make sure all callers block IRQs.

    It would appear that RTC API tests haven't been part of anyone's kernel
    regression test suite recently, at least not with lockdep running.

    Signed-off-by: David Brownell
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • The RTC framework has an irq_set_freq() method that should be used to manage
    the periodic IRQ frequency, but the current ioctl logic doesn't know how to do
    that. This patch teaches it how.

    This means that drivers implementing irq_set_freq() will automatically support
    RTC_IRQP_{READ,SET} ioctls; that logic doesn't need duplication within the
    driver.

    [akpm@osdl.org: export rtc_irq_set_freq]
    Signed-off-by: David Brownell
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

22 Nov, 2006

1 commit


01 Oct, 2006

3 commits

  • Update RTC framework so that drivers can constify their method tables, moving
    them from ".data" to ".rodata". Then update the drivers.

    Signed-off-by: David Brownell
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • This makes RTC core components use "subsys_init" instead of "module_init", as
    appropriate for subsystem infrastructure. This is mostly useful for
    statically linking drivers in other parts of the tree that may provide an RTC
    interface as a secondary functionality (e.g. part of a multifunction chip);
    they won't need to worry so much about drivers/Makefile link order.

    Signed-off-by: David Brownell
    Cc: Alessandro Zummo
    Acked-by: Oleg Verych
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • If cdev_add() fails there is no good reason to call cdev_del().

    Signed-off-by: Rolf Eike Beer
    Cc: Alessandro Zummo
    Cc: Dmitry Torokhov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rolf Eike Beer
     

26 Jun, 2006

2 commits

  • Centralize CAP_SYS_XXX checks to avoid duplicate code and missing checks in
    the drivers.

    Signed-off-by: Alessandro Zummo
    Cc: Richard Purdie
    Cc: Yoichi Yuasa
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alessandro Zummo
     
  • Import genrtc's RTC UIE emulation (CONFIG_GEN_RTC_X) to rtc-dev driver with
    slight adjustments/refinements. This makes UIE-less rtc drivers work
    better with programs doing read/poll on /dev/rtc, such as hwclock. This
    emulation should not harm rtc drivers with UIE support, since
    rtc_dev_ioctl() calls underlaying rtc driver's ioctl() first.

    Signed-off-by: Atsushi Nemoto
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Atsushi Nemoto
     

22 May, 2006

1 commit


02 May, 2006

1 commit

  • Make rtc-dev work well on 64-bit platforms with 32-bit userland. On those
    platforms, users might try to read 32-bit integer value. This patch make
    rtc-dev's read() work well for both "int" and "long" size. This tweak is came
    from genrtc driver.

    Signed-off-by: Atsushi Nemoto
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Atsushi Nemoto
     

28 Mar, 2006

1 commit

  • Add the dev interface to the RTC subsystem.

    Each RTC will be available under /dev/rtcX . A symlink from /dev/rtc0 to
    /dev/rtc cab be obtained with the following udev rule:

    KERNEL=="rtc0", SYMLINK+="rtc"

    Signed-off-by: Alessandro Zummo
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alessandro Zummo