From patchwork Tue Dec 16 20:08:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 42360 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0AADF25E25 for ; Tue, 16 Dec 2014 20:12:08 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e53sf9383345eek.11 for ; Tue, 16 Dec 2014 12:12:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=4ADu7fApTLg5HIa7Kxw55+l0UkTgTEjz7ZpaSqIjKOs=; b=FNLeokkaScgL+SioLy5OXVo4JpLqAzxWyCiwe6e9seMnqeJ7vFv8cvsNFaOYP34a6y BiYCnQ0fxoZvCSF6wDBO5e6W8m1M8S2vd+Tq+vDwEtWv1piIptV3tX92GfuOOps7ZyfN eTUHh/r+WWW0DguedRgNUcXrGg+TGUOC8lgf+U/z6Gm631EYRtqDJn6y1UoblLzO6B37 o7BNcNGm4b0F5dTMPg+Nu+4yHxudmb6FGDDP4MmqD6zKRySn/eOfD1CXSUda6L0zZKCw eakW848poRuVhcxtHYZN61TO5ondzF0jINXG3F6Zw90hCsGiIqaUg4m4sWn4xxhDpcsz OTPw== X-Gm-Message-State: ALoCoQkwcpCZYARVvRSCD30I6FD/OAYxIkj7ENy0ib6Bkik6gAqmi5MG0Vpik6qSacVpAkt4Vet/ X-Received: by 10.180.19.42 with SMTP id b10mr742242wie.0.1418760727220; Tue, 16 Dec 2014 12:12:07 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.38 with SMTP id ld6ls974196lac.50.gmail; Tue, 16 Dec 2014 12:12:07 -0800 (PST) X-Received: by 10.152.120.42 with SMTP id kz10mr37635383lab.92.1418760727059; Tue, 16 Dec 2014 12:12:07 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id ny5si1789592lbb.77.2014.12.16.12.12.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Dec 2014 12:12:07 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so11619862lab.20 for ; Tue, 16 Dec 2014 12:12:07 -0800 (PST) X-Received: by 10.152.5.226 with SMTP id v2mr26438164lav.34.1418760726960; Tue, 16 Dec 2014 12:12:06 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp1149122lbb; Tue, 16 Dec 2014 12:12:05 -0800 (PST) X-Received: by 10.224.72.5 with SMTP id k5mr70078939qaj.2.1418760714549; Tue, 16 Dec 2014 12:11:54 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id j35si2082899qge.86.2014.12.16.12.11.53 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 16 Dec 2014 12:11:54 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Y0yR7-0004qL-AG; Tue, 16 Dec 2014 20:09:37 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Y0yR5-0004pj-W2 for xen-devel@lists.xenproject.org; Tue, 16 Dec 2014 20:09:36 +0000 Received: from [193.109.254.147] by server-11.bemta-14.messagelabs.com id 46/14-02696-F7190945; Tue, 16 Dec 2014 20:09:35 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-10.tower-27.messagelabs.com!1418760574!15504407!1 X-Originating-IP: [209.85.212.170] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31596 invoked from network); 16 Dec 2014 20:09:34 -0000 Received: from mail-wi0-f170.google.com (HELO mail-wi0-f170.google.com) (209.85.212.170) by server-10.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 16 Dec 2014 20:09:34 -0000 Received: by mail-wi0-f170.google.com with SMTP id bs8so14845137wib.1 for ; Tue, 16 Dec 2014 12:09:34 -0800 (PST) X-Received: by 10.194.241.194 with SMTP id wk2mr65135860wjc.132.1418760572673; Tue, 16 Dec 2014 12:09:32 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id b10sm3382705wiw.9.2014.12.16.12.09.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Dec 2014 12:09:31 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 16 Dec 2014 20:08:50 +0000 Message-Id: <1418760534-18163-10-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418760534-18163-1-git-send-email-julien.grall@linaro.org> References: <1418760534-18163-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, manish.jaggi@caviumnetworks.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH for 4.6 09/13] xen/arm: Describe device supported by a driver with dt_match_node X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Xen is currently using list a compatible string to know if the driver can use device node. This leads to have double definition in the GIC code. Futhermore Linux drivers is using dt_match_node (actually called of_device_id in Linux) to list device supported by the drivers. Signed-off-by: Julien Grall --- xen/arch/arm/device.c | 21 ++------------------- xen/arch/arm/gic-v2.c | 10 ++++------ xen/arch/arm/gic-v3.c | 8 ++++---- xen/drivers/char/exynos4210-uart.c | 8 ++++---- xen/drivers/char/ns16550.c | 12 ++++++------ xen/drivers/char/omap-uart.c | 8 ++++---- xen/drivers/char/pl011.c | 8 ++++---- xen/include/asm-arm/device.h | 8 ++++++-- xen/include/asm-arm/gic.h | 15 +++++---------- 9 files changed, 39 insertions(+), 59 deletions(-) diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index de702ff..1993929 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -23,23 +23,6 @@ extern const struct device_desc _sdevice[], _edevice[]; -static bool_t __init device_is_compatible(const struct device_desc *desc, - const struct dt_device_node *dev) -{ - const char *const *compat; - - if ( !desc->compatible ) - return 0; - - for ( compat = desc->compatible; *compat; compat++ ) - { - if ( dt_device_is_compatible(dev, *compat) ) - return 1; - } - - return 0; -} - int __init device_init(struct dt_device_node *dev, enum device_match type, const void *data) { @@ -55,7 +38,7 @@ int __init device_init(struct dt_device_node *dev, enum device_match type, if ( desc->type != type ) continue; - if ( device_is_compatible(desc, dev) ) + if ( dt_match_node(desc->dt_match, dev) ) { ASSERT(desc->init != NULL); @@ -75,7 +58,7 @@ enum device_match device_get_type(const struct dt_device_node *dev) for ( desc = _sdevice; desc != _edevice; desc++ ) { - if ( device_is_compatible(desc, dev) ) + if ( dt_match_node(desc->dt_match, dev) ) return desc->type; } diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index 048350b..db3795d 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -763,16 +763,14 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data) return 0; } -static const char * const gicv2_dt_compat[] __initconst = +static const struct dt_device_match gicv2_dt_match[] __initconst = { - DT_COMPAT_GIC_CORTEX_A15, - DT_COMPAT_GIC_CORTEX_A7, - DT_COMPAT_GIC_400, - NULL + DT_MATCH_GIC_V2, + { /* sentinel */ }, }; DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC) - .compatible = gicv2_dt_compat, + .dt_match = gicv2_dt_match, .init = gicv2_init, DT_DEVICE_END diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index c6d1876..1191cb7 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1278,14 +1278,14 @@ static int __init gicv3_init(struct dt_device_node *node, const void *data) return res; } -static const char * const gicv3_dt_compat[] __initconst = +static const struct dt_device_match gicv3_dt_match[] __initconst = { - DT_COMPAT_GIC_V3, - NULL + DT_MATCH_GIC_V3, + { /* sentinel */ }, }; DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC) - .compatible = gicv3_dt_compat, + .dt_match = gicv3_dt_match, .init = gicv3_init, DT_DEVICE_END diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c index 75246e1..b59e64a 100644 --- a/xen/drivers/char/exynos4210-uart.c +++ b/xen/drivers/char/exynos4210-uart.c @@ -352,14 +352,14 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev, return 0; } -static const char * const exynos4210_dt_compat[] __initconst = +static const struct dt_device_match exynos4210_dt_match[] __initconst = { - "samsung,exynos4210-uart", - NULL + DT_MATCH_COMPATIBLE("samsung,exynos4210-uart"), + { /* sentinel */ }, }; DT_DEVICE_START(exynos4210, "Exynos 4210 UART", DEVICE_SERIAL) - .compatible = exynos4210_dt_compat, + .dt_match = exynos4210_dt_match, .init = exynos4210_uart_init, DT_DEVICE_END diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index 6df3f95..a0373a9 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -1185,16 +1185,16 @@ static int __init ns16550_uart_dt_init(struct dt_device_node *dev, return 0; } -static const char * const ns16550_dt_compat[] __initconst = +static const struct dt_device_match ns16550_dt_match[] __initconst = { - "ns16550", - "ns16550a", - "snps,dw-apb-uart", - NULL + DT_MATCH_COMPATIBLE("ns16550"), + DT_MATCH_COMPATIBLE("ns16550a"), + DT_MATCH_COMPATIBLE("snps,dw-apb-uart"), + { /* sentinel */ }, }; DT_DEVICE_START(ns16550, "NS16550 UART", DEVICE_SERIAL) - .compatible = ns16550_dt_compat, + .dt_match = ns16550_dt_match, .init = ns16550_uart_dt_init, DT_DEVICE_END diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c index c4cd442..3df80cf 100644 --- a/xen/drivers/char/omap-uart.c +++ b/xen/drivers/char/omap-uart.c @@ -350,14 +350,14 @@ static int __init omap_uart_init(struct dt_device_node *dev, return 0; } -static const char * const omap_uart_dt_compat[] __initconst = +static const struct dt_device_match omap_uart_dt_match[] __initconst = { - "ti,omap4-uart", - NULL + DT_MATCH_COMPATIBLE("ti,omap4-uart"), + { /* sentinel */ }, }; DT_DEVICE_START(omap_uart, "OMAP UART", DEVICE_SERIAL) - .compatible = omap_uart_dt_compat, + .dt_match = omap_uart_dt_match, .init = omap_uart_init, DT_DEVICE_END diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c index cc91224..e6ecf0b 100644 --- a/xen/drivers/char/pl011.c +++ b/xen/drivers/char/pl011.c @@ -269,14 +269,14 @@ static int __init pl011_uart_init(struct dt_device_node *dev, return 0; } -static const char * const pl011_dt_compat[] __initconst = +static const struct dt_device_match pl011_dt_match[] __initconst = { - "arm,pl011", - NULL + DT_MATCH_COMPATIBLE("arm,pl011"), + { /* sentinel */ }, }; DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) - .compatible = pl011_dt_compat, + .dt_match = pl011_dt_match, .init = pl011_uart_init, DT_DEVICE_END diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h index fdcd097..a2711a3 100644 --- a/xen/include/asm-arm/device.h +++ b/xen/include/asm-arm/device.h @@ -3,6 +3,10 @@ #include +struct dev_archdata { + void *iommu; /* IOMMU private data */ +}; + struct dt_device_node; enum device_match @@ -19,8 +23,8 @@ struct device_desc { const char *name; /* Device type */ enum device_match type; - /* Array of device tree 'compatible' strings */ - const char *const *compatible; + /* List of devices supported by this driver */ + const struct dt_device_match *dt_match; /* Device initialization */ int (*init)(struct dt_device_node *dev, const void *data); }; diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 187dc46..73ca3cf 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -152,17 +152,12 @@ #include #include -#define DT_COMPAT_GIC_400 "arm,gic-400" -#define DT_COMPAT_GIC_CORTEX_A15 "arm,cortex-a15-gic" -#define DT_COMPAT_GIC_CORTEX_A7 "arm,cortex-a7-gic" +#define DT_MATCH_GIC_V2 \ + DT_MATCH_COMPATIBLE("arm,cortex-a15-gic"), \ + DT_MATCH_COMPATIBLE("arm,cortex-a7-gic"), \ + DT_MATCH_COMPATIBLE("arm,gic-400") -#define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \ - DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \ - DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400) - -#define DT_COMPAT_GIC_V3 "arm,gic-v3" - -#define DT_MATCH_GIC_V3 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_V3) +#define DT_MATCH_GIC_V3 DT_MATCH_COMPATIBLE("arm,gic-v3") /* * GICv3 registers that needs to be saved/restored