Message ID | BD79186B4FD85F4B8E60E381CAEE1909012E2C18@mi8nycmail19.Mi8.com |
---|---|
State | Superseded, archived |
Headers | show |
On Thursday, February 19, 2009 5:10 PM, hartleys wrote: > This patch updates the rtc-ep93xx.c driver to use ioremap'ed addresses. > > This removes the dependency on <mach/hardware.h> and properly reports > the memory addresses used by the driver in /proc/iomem. > > In addition, ep93xx_rtc_init() is updated to use platform_driver_probe() > instead of platform_driver_register(). > > Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> > > --- > [SNIP] > -static struct platform_driver ep93xx_rtc_platform_driver = { > +static struct platform_driver ep93xx_rtcdrv = { > .driver = { > .name = "ep93xx-rtc", > .owner = THIS_MODULE, > }, > - .probe = ep93xx_rtc_probe, > .remove = __devexit_p(ep93xx_rtc_remove), > }; > > static int __init ep93xx_rtc_init(void) > { > - return platform_driver_register(&ep93xx_rtc_platform_driver); > + return platform_driver_probe(&ep93xx_rtcdrv, ep93xx_rtc_probe); > } > > static void __exit ep93xx_rtc_exit(void) > { > - platform_driver_unregister(&ep93xx_rtc_platform_driver); > + platform_driver_unregister(&ep93xx_rtcdrv); > } When I created this patch I had to remove the __devexit_p() to get rid of a compile warning about a Section mismatch. I started messing with it to try and figure out the problem and now I'm really confused. I had shortened the ep93xx_rtc_platform_driver variable name to ep93xx_rtcdrv in order to keep the platform_driver_probe() line length short. If I change the variable name back, or just change it to ep93xx_rtc_driver, the Section mismatch warning then doesn't show up when the __devexit_p() is used. Could someone please explain this to me? The actual warning messages were as follows with make CONFIG_DEBUG_SECTION_MISMATCH=y: CC drivers/rtc/rtc-ep93xx.o LD drivers/rtc/built-in.o WARNING: drivers/rtc/built-in.o(.data+0x9c): Section mismatch in reference from the variable ep93xx_rtcdrv to the (unknown reference) .devexit.text:(unknown) The variable ep93xx_rtcdrv references the (unknown reference) __devexit (unknown) If the reference is valid then annotate the variable with __exit* (see linux/init.h) or name the variable: *driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console, LD drivers/built-in.o WARNING: drivers/built-in.o(.data+0x88d8): Section mismatch in reference from the variable ep93xx_rtcdrv to the (unknown reference) .devexit.text:(unknown) The variable ep93xx_rtcdrv references the (unknown reference) __devexit (unknown) If the reference is valid then annotate the variable with __exit* (see linux/init.h) or name the variable: *driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console, LD vmlinux.o MODPOST vmlinux.o WARNING: vmlinux.o(.data+0x19c20): Section mismatch in reference from the variable ep93xx_rtcdrv to the (unknown reference) .devexit.text:(unknown) The variable ep93xx_rtcdrv references the (unknown reference) __devexit (unknown) If the reference is valid then annotate the variable with __exit* (see linux/init.h) or name the variable: *driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console, Thanks, Hartley --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. -~----------~----~----~----~------~----~------~--~---
On Thu, 19 Feb 2009 21:05:48 -0500 "hartleys" <hartleys@visionengravers.com> wrote: > I had shortened the ep93xx_rtc_platform_driver variable name to > ep93xx_rtcdrv in order to keep the platform_driver_probe() line length > short. If I change the variable name back, or just change it to > ep93xx_rtc_driver, the Section mismatch warning then doesn't show up > when the __devexit_p() is used. there's some magic on the structure name . anyway if you use platform_driver_probe you shuld be using __init/__exit/__exit_p
On Thu, 19 Feb 2009 21:05:48 -0500 "hartleys" <hartleys@visionengravers.com> wrote: > On Thursday, February 19, 2009 5:10 PM, hartleys wrote: > > This patch updates the rtc-ep93xx.c driver to use ioremap'ed > addresses. hi, did you sent this thru arm?
On Thu, 19 Feb 2009 19:09:49 -0500 "hartleys" <hartleys@visionengravers.com> wrote: > This patch updates the rtc-ep93xx.c driver to use ioremap'ed addresses. > > This removes the dependency on <mach/hardware.h> and properly reports > the memory addresses used by the driver in /proc/iomem. > > In addition, ep93xx_rtc_init() is updated to use platform_driver_probe() > instead of platform_driver_register(). > > Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Please send this in via arm along with the other patches you told me about, so we can stay safe from conflicts. You can bump the version numbers too.
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c index 6d9152d..90254d8 100644 --- a/arch/arm/mach-ep93xx/core.c +++ b/arch/arm/mach-ep93xx/core.c @@ -449,11 +449,19 @@ static struct amba_device uart3_device = { .periphid = 0x00041010, }; +static struct resource ep93xx_rtc_resource[] = { + { + .start = EP93XX_RTC_PHYS_BASE, + .end = EP93XX_RTC_PHYS_BASE + 0x10c - 1, + .flags = IORESOURCE_MEM, + }, +}; static struct platform_device ep93xx_rtc_device = { - .name = "ep93xx-rtc", - .id = -1, - .num_resources = 0, + .name = "ep93xx-rtc", + .id = -1, + .num_resources = ARRAY_SIZE(ep93xx_rtc_resource), + .resource = ep93xx_rtc_resource, }; diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h index 22d6c9a..68e6b23 100644 --- a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h +++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h @@ -146,6 +146,7 @@ #define EP93XX_PWM_BASE (EP93XX_APB_VIRT_BASE + 0x00110000) #define EP93XX_RTC_BASE (EP93XX_APB_VIRT_BASE + 0x00120000) +#define EP93XX_RTC_PHYS_BASE (EP93XX_APB_PHYS_BASE + 0x00120000) #define EP93XX_SYSCON_BASE (EP93XX_APB_VIRT_BASE + 0x00130000) #define EP93XX_SYSCON_REG(x) (EP93XX_SYSCON_BASE + (x)) diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index f7a3283..5eec3f5 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c @@ -11,20 +11,24 @@ #include <linux/module.h> #include <linux/rtc.h> +#include <linux/init.h> #include <linux/platform_device.h> -#include <mach/hardware.h> +#include <linux/io.h> -#define EP93XX_RTC_REG(x) (EP93XX_RTC_BASE + (x)) -#define EP93XX_RTC_DATA EP93XX_RTC_REG(0x0000) -#define EP93XX_RTC_LOAD EP93XX_RTC_REG(0x000C) -#define EP93XX_RTC_SWCOMP EP93XX_RTC_REG(0x0108) +#define EP93XX_RTC_DATA 0x000 +#define EP93XX_RTC_MATCH 0x004 +#define EP93XX_RTC_STATUS 0x008 +#define EP93XX_RTC_LOAD 0x00C +#define EP93XX_RTC_CONTROL 0x010 +#define EP93XX_RTC_SWCOMP 0x108 #define DRV_VERSION "0.2" static int ep93xx_get_swcomp(struct device *dev, unsigned short *preload, unsigned short *delete) { - unsigned short comp = __raw_readl(EP93XX_RTC_SWCOMP); + void __iomem *mmio_base = dev->platform_data; + unsigned long comp = __raw_readl(mmio_base + EP93XX_RTC_SWCOMP); if (preload)
This patch updates the rtc-ep93xx.c driver to use ioremap'ed addresses. This removes the dependency on <mach/hardware.h> and properly reports the memory addresses used by the driver in /proc/iomem. In addition, ep93xx_rtc_init() is updated to use platform_driver_probe() instead of platform_driver_register(). Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> --- *preload = comp & 0xffff; @@ -37,7 +41,8 @@ static int ep93xx_get_swcomp(struct device *dev, unsigned short *preload, static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm) { - unsigned long time = __raw_readl(EP93XX_RTC_DATA); + void __iomem *mmio_base = dev->platform_data; + unsigned long time = __raw_readl(mmio_base + EP93XX_RTC_DATA); rtc_time_to_tm(time, tm); return 0; @@ -45,7 +50,9 @@ static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm) static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs) { - __raw_writel(secs + 1, EP93XX_RTC_LOAD); + void __iomem *mmio_base = dev->platform_data; + + __raw_writel(secs + 1, mmio_base + EP93XX_RTC_LOAD); return 0; } @@ -92,11 +99,32 @@ static DEVICE_ATTR(comp_delete, S_IRUGO, ep93xx_sysfs_show_comp_delete, NULL); static int __devinit ep93xx_rtc_probe(struct platform_device *dev) { - struct rtc_device *rtc = rtc_device_register("ep93xx", - &dev->dev, &ep93xx_rtc_ops, THIS_MODULE); + struct resource *res; + void __iomem *mmio_base; + struct rtc_device *rtc; + int err; + + res = platform_get_resource(dev, IORESOURCE_MEM, 0); + if (res == NULL) + return -ENXIO; + + res = request_mem_region(res->start, resource_size(res), dev->name); + if (res == NULL) + return -EBUSY; + + mmio_base = ioremap(res->start, resource_size(res)); + if (mmio_base == NULL) { + err = -ENXIO; + goto fail; + } + dev->dev.platform_data = mmio_base; + + rtc = rtc_device_register(dev->name, + &dev->dev, &ep93xx_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) { - return PTR_ERR(rtc); + err = PTR_ERR(rtc); + goto fail; } platform_set_drvdata(dev, rtc); @@ -105,14 +133,29 @@ static int __devinit ep93xx_rtc_probe(struct platform_device *dev) device_create_file(&dev->dev, &dev_attr_comp_delete); return 0; + +fail: + if (mmio_base) { + iounmap(mmio_base); + dev->dev.platform_data = NULL; + } + release_mem_region(res->start, resource_size(res)); + return err; } static int __devexit ep93xx_rtc_remove(struct platform_device *dev) { struct rtc_device *rtc = platform_get_drvdata(dev); + void __iomem *mmio_base = dev->dev.platform_data; + struct resource *res; + + rtc_device_unregister(rtc); + + iounmap(mmio_base); + dev->dev.platform_data = NULL; - if (rtc) - rtc_device_unregister(rtc); + res = platform_get_resource(dev, IORESOURCE_MEM, 0); + release_mem_region(res->start, resource_size(res)); platform_set_drvdata(dev, NULL); @@ -122,23 +165,22 @@ static int __devexit ep93xx_rtc_remove(struct platform_device *dev) /* work with hotplug and coldplug */ MODULE_ALIAS("platform:ep93xx-rtc"); -static struct platform_driver ep93xx_rtc_platform_driver = { +static struct platform_driver ep93xx_rtcdrv = { .driver = { .name = "ep93xx-rtc", .owner = THIS_MODULE, }, - .probe = ep93xx_rtc_probe, .remove = __devexit_p(ep93xx_rtc_remove), }; static int __init ep93xx_rtc_init(void) { - return platform_driver_register(&ep93xx_rtc_platform_driver); + return platform_driver_probe(&ep93xx_rtcdrv, ep93xx_rtc_probe); } static void __exit ep93xx_rtc_exit(void) { - platform_driver_unregister(&ep93xx_rtc_platform_driver); + platform_driver_unregister(&ep93xx_rtcdrv); } MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. -~----------~----~----~----~------~----~------~--~---