lkml.org 
[lkml]   [2008]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch][resend] provide rtc_cmos platform device, take 2
    Hello.

    akpm@linux-foundation.org wrote:
    > This patch was dropped because an updated version will be merged
    How is the attached one for an updated
    version?

    ----
    RTC doesn't work with pnpacpi=off.
    The attached patch fixes the problem by creating the platform device for
    the RTC when PNP is disabled. This may also help running the PNP-enabled
    kernel on an older PCs.

    Signed-off-by: Stas Sergeev <stsp@aknet.ru>
    Cc: David Brownell <david-b@pacbell.net>
    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
    Cc: Adam Belay <ambx1@neo.rr.com>
    CC: Russell King <rmk+lkml@arm.linux.org.uk>
    diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
    index 9615eee..01459d2 100644
    --- a/arch/x86/kernel/rtc.c
    +++ b/arch/x86/kernel/rtc.c
    @@ -4,9 +4,12 @@
    #include <linux/acpi.h>
    #include <linux/bcd.h>
    #include <linux/mc146818rtc.h>
    +#include <linux/platform_device.h>
    +#include <linux/pnp.h>

    #include <asm/time.h>
    #include <asm/vsyscall.h>
    +#include <asm/mc146818rtc.h>

    #ifdef CONFIG_X86_32
    /*
    @@ -197,3 +200,35 @@ unsigned long long native_read_tsc(void)
    }
    EXPORT_SYMBOL(native_read_tsc);

    +
    +static struct resource rtc_resources[] = {
    + [0] = {
    + .start = RTC_PORT(0),
    + .end = RTC_PORT(1),
    + .flags = IORESOURCE_IO,
    + },
    + [1] = {
    + .start = RTC_IRQ,
    + .end = RTC_IRQ,
    + .flags = IORESOURCE_IRQ,
    + }
    +};
    +
    +static struct platform_device rtc_device = {
    + .name = "rtc_cmos",
    + .id = -1,
    + .resource = rtc_resources,
    + .num_resources = ARRAY_SIZE(rtc_resources),
    +};
    +
    +static __init int add_rtc_cmos(void)
    +{
    +#ifdef CONFIG_PNP
    + if (!pnp_platform_devices)
    + platform_device_register(&rtc_device);
    +#else
    + platform_device_register(&rtc_device);
    +#endif /* CONFIG_PNP */
    + return 0;
    +}
    +device_initcall(add_rtc_cmos);
    diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
    index d060a06..d7bb9ba 100644
    --- a/drivers/rtc/rtc-cmos.c
    +++ b/drivers/rtc/rtc-cmos.c
    @@ -905,19 +905,7 @@ static struct pnp_driver cmos_pnp_driver = {
    .resume = cmos_pnp_resume,
    };

    -static int __init cmos_init(void)
    -{
    - return pnp_register_driver(&cmos_pnp_driver);
    -}
    -module_init(cmos_init);
    -
    -static void __exit cmos_exit(void)
    -{
    - pnp_unregister_driver(&cmos_pnp_driver);
    -}
    -module_exit(cmos_exit);
    -
    -#else /* no PNP */
    +#endif /* CONFIG_PNP */

    /*----------------------------------------------------------------*/

    @@ -958,20 +946,33 @@ static struct platform_driver cmos_platform_driver = {

    static int __init cmos_init(void)
    {
    +#ifdef CONFIG_PNP
    + if (pnp_platform_devices)
    + return pnp_register_driver(&cmos_pnp_driver);
    + else
    + return platform_driver_probe(&cmos_platform_driver,
    + cmos_platform_probe);
    +#else
    return platform_driver_probe(&cmos_platform_driver,
    cmos_platform_probe);
    +#endif /* CONFIG_PNP */
    }
    module_init(cmos_init);

    static void __exit cmos_exit(void)
    {
    +#ifdef CONFIG_PNP
    + if (pnp_platform_devices)
    + pnp_unregister_driver(&cmos_pnp_driver);
    + else
    + platform_driver_unregister(&cmos_platform_driver);
    +#else
    platform_driver_unregister(&cmos_platform_driver);
    +#endif /* CONFIG_PNP */
    }
    module_exit(cmos_exit);


    -#endif /* !PNP */
    -
    MODULE_AUTHOR("David Brownell");
    MODULE_DESCRIPTION("Driver for PC-style 'CMOS' RTCs");
    MODULE_LICENSE("GPL");
    \
     
     \ /
      Last update: 2008-05-27 13:35    [W:0.029 / U:29.704 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site