From patchwork Mon Apr 2 01:21:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 7566 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2B9C323E23 for ; Mon, 2 Apr 2012 01:21:54 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id E2255A1812D for ; Mon, 2 Apr 2012 01:21:53 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so4975195iag.11 for ; Sun, 01 Apr 2012 18:21:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=iPfbiHnGz6j296jNkraNkxD//4IrCLYR2I7o/EeglUE=; b=SCMiQgyJFd01hSuO1P7cuaUZBhfPwNPeclm6QdI0uaI/h/xI0QDTNl5aKHSfrTYO4H 9rMdXKIHGsiIOEsCbj2ywTpqQADlGj83vEnXR2F4PYEVj8NNVICPNZSU/q1P+P4J6aTI NS333SLqJg3UngCE9HWHgAThMOy+lIanFClVgsRaTYTLcvW1j4zUn3SiDGjCanVD886C n4Hkr3T5VtnVITVGWjoTaP7K1S2bfCvc45ovzSu3CLKkaAP9QONMkWO2ZwP7XUArjTUw 95JL9fMXoRrMbemBOgWu0XYydIh6jQNzpKkgmVU28/72rzZUzCwFw024IeWA0zoO9eqZ Uxtw== Received: by 10.50.207.5 with SMTP id ls5mr4036428igc.51.1333329713660; Sun, 01 Apr 2012 18:21:53 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.5.205 with SMTP id 13csp87693ibw; Sun, 1 Apr 2012 18:21:53 -0700 (PDT) Received: by 10.204.157.134 with SMTP id b6mr2884661bkx.88.1333329712471; Sun, 01 Apr 2012 18:21:52 -0700 (PDT) Received: from mail.df.lth.se (mail.df.lth.se. [194.47.250.12]) by mx.google.com with ESMTPS id k4si8963497bke.103.2012.04.01.18.21.51 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 Apr 2012 18:21:52 -0700 (PDT) Received-SPF: neutral (google.com: 194.47.250.12 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=194.47.250.12; Authentication-Results: mx.google.com; spf=neutral (google.com: 194.47.250.12 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) smtp.mail=linus.walleij@linaro.org Received: from fecusia (c83-249-217-152.bredband.comhem.se [83.249.217.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.df.lth.se (Postfix) with ESMTPSA id 6911B65D8D; Mon, 2 Apr 2012 03:21:50 +0200 (CEST) Received: by fecusia (sSMTP sendmail emulation); Mon, 2 Apr 2012 03:21:50 +0200 From: "Linus Walleij" To: linux-arm-kernel@lists.infradead.org Cc: Shawn Guo , Linus Walleij Subject: [PATCH 2/4] ARM: mxs: factor out dynamic amba device allocator Date: Mon, 2 Apr 2012 03:21:38 +0200 Message-Id: <1333329698-31666-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.7.7.6 X-Gm-Message-State: ALoCoQmsqRGkmmfBagf20p9lHHqNZaogL3msYy553mNrh85+MevfvozoOHJG6+VpYxP3xBNlnhqy Replace the local amba device allocator with the core code from the bus driver. Cc: Shawn Guo Signed-off-by: Linus Walleij --- arch/arm/mach-mxs/devices-mx23.h | 11 ++++-- 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, 17 insertions(+), 68 deletions(-) delete mode 100644 arch/arm/mach-mxs/devices/amba-duart.c diff --git a/arch/arm/mach-mxs/devices-mx23.h b/arch/arm/mach-mxs/devices-mx23.h index 4d1329d..1feea23 100644 --- a/arch/arm/mach-mxs/devices-mx23.h +++ b/arch/arm/mach-mxs/devices-mx23.h @@ -11,10 +11,15 @@ #include #include #include +#include -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() { + 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]) diff --git a/arch/arm/mach-mxs/devices-mx28.h b/arch/arm/mach-mxs/devices-mx28.h index 9dbeae1..b46c6d1 100644 --- a/arch/arm/mach-mxs/devices-mx28.h +++ b/arch/arm/mach-mxs/devices-mx28.h @@ -11,10 +11,16 @@ #include #include #include +#include + +static inline int mx28_add_duart() { + 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 amba_device mx28_duart_device __initconst; -#define mx28_add_duart() \ - mxs_add_duart(&mx28_duart_device) extern const struct mxs_auart_data mx28_auart_data[] __initconst; #define mx28_add_auart(id) mxs_add_auart(&mx28_auart_data[id]) diff --git a/arch/arm/mach-mxs/devices.c b/arch/arm/mach-mxs/devices.c index 01faffe..cf50b5a 100644 --- a/arch/arm/mach-mxs/devices.c +++ b/arch/arm/mach-mxs/devices.c @@ -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, diff --git a/arch/arm/mach-mxs/devices/Makefile b/arch/arm/mach-mxs/devices/Makefile index c8f5c95..5f72d97 100644 --- a/arch/arm/mach-mxs/devices/Makefile +++ b/arch/arm/mach-mxs/devices/Makefile @@ -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 diff --git a/arch/arm/mach-mxs/devices/amba-duart.c b/arch/arm/mach-mxs/devices/amba-duart.c deleted file mode 100644 index a5479f7..0000000 --- a/arch/arm/mach-mxs/devices/amba-duart.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2009-2010 Pengutronix - * Uwe Kleine-Koenig - * - * 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 -#include -#include -#include - -#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); -} diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h index f2e3839..21e45a7 100644 --- a/arch/arm/mach-mxs/include/mach/devices-common.h +++ b/arch/arm/mach-mxs/include/mach/devices-common.h @@ -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;