ARM: mxs: factor out dynamic amba device allocator
Subsystems (3)
PATCH v2 2/4 ARM: mxs: factor out dynamic amba device allocator
Replace the local amba device allocator with the core code from the bus driver.
Acked-by Shawn Guo <[email protected]>
Signed-off-by Linus Walleij <[email protected]>
---
ChangeLog v1->v2: fixed up the compile warnings spotted by Shawn.
--- arch/arm/mach-mxs/devices-mx23.h | 12 +++++-- arch/arm/mach-mxs/devices-mx28.h | 12 +++++-- arch/arm/mach-mxs/devices.c | 16 --------- arch/arm/mach-mxs/devices/Makefile | 1 - arch/arm/mach-mxs/devices/amba-duart.c | 40 ----------------------- arch/arm/mach-mxs/include/mach/devices-common.h | 5 --- 6 files changed, 18 insertions(+), 68 deletions(-) delete mode 100644 arch/arm/mach-mxs/devices/amba-duart.c
arch/arm/mach-mxs/devices-mx23.h +9 -3
@@ -11,10 +11,16 @@#include <mach/mx23.h> #include <mach/devices-common.h> #include <mach/mxsfb.h> +#include <linux/amba/bus.h> -extern const struct amba_device mx23_duart_device__initconst ; -#define mx23_add_duart () \ - mxs_add_duart(&mx23_duart_device) +static inline int mx23_add_duart (void ) +{ +struct amba_device *d; + + d =amba_ahb_device_add (NULL ,"duart" ,MX23_DUART_BASE_ADDR ,SZ_8K , +MX23_INT_DUART ,0 ,0 ,0 ); +return IS_ERR (d) ?PTR_ERR (d) :0 ; +}extern const struct mxs_auart_data mx23_auart_data[]__initconst ;#define mx23_add_auart (id) mxs_add_auart(&mx23_auart_data[id])
arch/arm/mach-mxs/devices-mx28.h +9 -3
@@ -11,10 +11,16 @@#include <mach/mx28.h> #include <mach/devices-common.h> #include <mach/mxsfb.h> +#include <linux/amba/bus.h> -extern const struct amba_device mx28_duart_device__initconst ; -#define mx28_add_duart () \ - mxs_add_duart(&mx28_duart_device) +static inline int mx28_add_duart (void ) +{ +struct amba_device *d; + + d =amba_ahb_device_add (NULL ,"duart" ,MX28_DUART_BASE_ADDR ,SZ_8K , +MX28_INT_DUART ,0 ,0 ,0 ); +return IS_ERR (d) ?PTR_ERR (d) :0 ; +}extern const struct mxs_auart_data mx28_auart_data[]__initconst ;#define mx28_add_auart (id) mxs_add_auart(&mx28_auart_data[id])
arch/arm/mach-mxs/devices.c +0 -16
@@ -75,22 +75,6 @@ err:return pdev; } -int __init mxs_add_amba_device (const struct amba_device *dev) -{ -struct amba_device *adev =amba_device_alloc (dev->dev.init_name, - dev->res.start,resource_size (&dev->res)); - -if (!adev) { -pr_err ("%s: failed to allocate memory" , __func__); -return -ENOMEM ; - } - - adev->irq[0 ] = dev->irq[0 ]; - adev->irq[1 ] = dev->irq[1 ]; - -return amba_device_add (adev, &iomem_resource); -} -struct device mxs_apbh_bus = { .init_name ="mxs_apbh" , .parent = &platform_bus,
arch/arm/mach-mxs/devices/Makefile +0 -1
@@ -1,4 +1,3 @@ -obj-$(CONFIG_MXS_HAVE_AMBA_DUART) += amba-duart.o obj-$(CONFIG_MXS_HAVE_PLATFORM_AUART) += platform-auart.o obj-y += platform-dma.o obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o
arch/arm/mach-mxs/devices/amba-duart.c deleted +0 -40
@@ -1,40 +0,0 @@ -/* -* Copyright (C) 2009-2010 Pengutronix -* Uwe Kleine-Koenig <[email protected]> -* -* Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved. -* -* This program is free software; you can redistribute it and/or modify it under -* the terms of the GNU General Public License version 2 as published by the -* Free Software Foundation. -*/ -#include <asm/irq.h> -#include <mach/mx23.h> -#include <mach/mx28.h> -#include <mach/devices-common.h> - -#define MXS_AMBA_DUART_DEVICE (name, soc) \ -const struct amba_device name##_device __initconst = { \ - .dev = { \ - .init_name = "duart", \ - }, \ - .res = { \ - .start = soc ## _DUART_BASE_ADDR, \ - .end = (soc ## _DUART_BASE_ADDR) + SZ_8K - 1, \ - .flags = IORESOURCE_MEM, \ - }, \ - .irq = {soc ## _INT_DUART}, \ -} - -#ifdef CONFIG_SOC_IMX23 -MXS_AMBA_DUART_DEVICE (mx23_duart,MX23 ); -#endif - -#ifdef CONFIG_SOC_IMX28 -MXS_AMBA_DUART_DEVICE (mx28_duart,MX28 ); -#endif - -int __init mxs_add_duart (const struct amba_device *dev) -{ -return mxs_add_amba_device (dev); -}
arch/arm/mach-mxs/include/mach/devices-common.h +0 -5
@@ -27,11 +27,6 @@ static inline struct platform_device *mxs_add_platform_device( name, id, res, num_resources, data, size_data, 0); } -int __init mxs_add_amba_device (const struct amba_device *dev); - -/* duart */ -int __init mxs_add_duart (const struct amba_device *dev); -/* auart */ struct mxs_auart_data {int id;
Signature · 1 line
1.7.7.6
PATCH v2 2/4 ARM: mxs: factor out dynamic amba device allocator
Quoted 5 lines · Linus Walleij
Replace the local amba device allocator with the core code from the bus driver.
Acked-by Shawn Guo <[email protected]>Signed-off-by Linus Walleij <[email protected]>
Just nitpicking: You can make use of PTR_RET() instead of open-coding it (see inline).
regards, Marc
Quoted 23 lines
---
ChangeLogv1->v2: fixed up the compile warnings spotted by Shawn.--- arch/arm/mach-mxs/devices-mx23.h | 12 +++++-- arch/arm/mach-mxs/devices-mx28.h | 12 +++++-- arch/arm/mach-mxs/devices.c | 16 --------- arch/arm/mach-mxs/devices/Makefile | 1 - arch/arm/mach-mxs/devices/amba-duart.c | 40 ----------------------- arch/arm/mach-mxs/include/mach/devices-common.h | 5 --- 6 files changed, 18 insertions(+), 68 deletions(-) delete mode 100644 arch/arm/mach-mxs/devices/amba-duart.carch/arm/mach-mxs/devices-mx23.h +1
-0@@ -11,10 +11,16 @@#include <mach/mx23.h> #include <mach/devices-common.h> #include <mach/mxsfb.h> +#include <linux/amba/bus.h>
arch/arm/mach-mxs/devices-mx23.h line 22
Quoted 10 lines
arch/arm/mach-mxs/devices-mx23.h +7
-3-extern const struct amba_device mx23_duart_device__initconst ; -#define mx23_add_duart () \ - mxs_add_duart(&mx23_duart_device) +static inline int mx23_add_duart (void ) +{ +struct amba_device *d; + + d =amba_ahb_device_add (NULL ,"duart" ,MX23_DUART_BASE_ADDR ,SZ_8K , +MX23_INT_DUART ,0 ,0 ,0 ); +return IS_ERR (d) ?PTR_ERR (d) :0 ;
there's a helper for that PTR_RET.
Quoted 14 lines
arch/arm/mach-mxs/devices-mx23.h +1
-0+}extern const struct mxs_auart_data mx23_auart_data[]__initconst ;#define mx23_add_auart (id) mxs_add_auart(&mx23_auart_data[id])arch/arm/mach-mxs/devices-mx28.h +1
-0@@ -11,10 +11,16 @@#include <mach/mx28.h> #include <mach/devices-common.h> #include <mach/mxsfb.h> +#include <linux/amba/bus.h>
arch/arm/mach-mxs/devices-mx28.h line 22
Quoted 10 lines
arch/arm/mach-mxs/devices-mx28.h +7
-3-extern const struct amba_device mx28_duart_device__initconst ; -#define mx28_add_duart () \ - mxs_add_duart(&mx28_duart_device) +static inline int mx28_add_duart (void ) +{ +struct amba_device *d; + + d =amba_ahb_device_add (NULL ,"duart" ,MX28_DUART_BASE_ADDR ,SZ_8K , +MX28_INT_DUART ,0 ,0 ,0 ); +return IS_ERR (d) ?PTR_ERR (d) :0 ;
dito
Quoted 102 lines
arch/arm/mach-mxs/devices-mx28.h +1
-0+}extern const struct mxs_auart_data mx28_auart_data[]__initconst ;#define mx28_add_auart (id) mxs_add_auart(&mx28_auart_data[id])arch/arm/mach-mxs/devices.c +0
-16@@ -75,22 +75,6 @@ err:return pdev; } -int __init mxs_add_amba_device (const struct amba_device *dev) -{ -struct amba_device *adev =amba_device_alloc (dev->dev.init_name, - dev->res.start,resource_size (&dev->res)); - -if (!adev) { -pr_err ("%s: failed to allocate memory" , __func__); -return -ENOMEM ; - } - - adev->irq[0 ] = dev->irq[0 ]; - adev->irq[1 ] = dev->irq[1 ]; - -return amba_device_add (adev, &iomem_resource); -} -struct device mxs_apbh_bus = { .init_name ="mxs_apbh" , .parent = &platform_bus,arch/arm/mach-mxs/devices/Makefile +0
-1@@ -1,4 +1,3 @@ -obj-$(CONFIG_MXS_HAVE_AMBA_DUART) += amba-duart.o obj-$(CONFIG_MXS_HAVE_PLATFORM_AUART) += platform-auart.o obj-y += platform-dma.o obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.oarch/arm/mach-mxs/devices/amba-duart.c deleted +0
-40@@ -1,40 +0,0 @@ -/* -* Copyright (C) 2009-2010 Pengutronix -* Uwe Kleine-Koenig <[email protected]> -* -* Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved. -* -* This program is free software; you can redistribute it and/or modify it under -* the terms of the GNU General Public License version 2 as published by the -* Free Software Foundation. -*/ -#include <asm/irq.h> -#include <mach/mx23.h> -#include <mach/mx28.h> -#include <mach/devices-common.h> - -#define MXS_AMBA_DUART_DEVICE (name, soc) \ -const struct amba_device name##_device __initconst = { \ - .dev = { \ - .init_name = "duart", \ - }, \ - .res = { \ - .start = soc ## _DUART_BASE_ADDR, \ - .end = (soc ## _DUART_BASE_ADDR) + SZ_8K - 1, \ - .flags = IORESOURCE_MEM, \ - }, \ - .irq = {soc ## _INT_DUART}, \ -} - -#ifdef CONFIG_SOC_IMX23 -MXS_AMBA_DUART_DEVICE (mx23_duart,MX23 ); -#endif - -#ifdef CONFIG_SOC_IMX28 -MXS_AMBA_DUART_DEVICE (mx28_duart,MX28 ); -#endif - -int __init mxs_add_duart (const struct amba_device *dev) -{ -return mxs_add_amba_device (dev); -}arch/arm/mach-mxs/include/mach/devices-common.h +0
-5@@ -27,11 +27,6 @@ static inline struct platform_device *mxs_add_platform_device( name, id, res, num_resources, data, size_data, 0); } -int __init mxs_add_amba_device (const struct amba_device *dev); - -/* duart */ -int __init mxs_add_duart (const struct amba_device *dev); -/* auart */ struct mxs_auart_data {int id;
Signature · 12 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120403/aa9c8790/attachment-0001.sig>