From patchwork Fri Jan 30 18:49:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 44059 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A13D220CA8 for ; Fri, 30 Jan 2015 18:52:42 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf3403530wiv.2 for ; Fri, 30 Jan 2015 10:52:41 -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=3yJRsZY0nen5uuMDSfdMs8nFiEHDbP5DE1ZEcmpN+Lo=; b=FO0lXZBB0tzuqdbDch378iy17Ahm5u3oHNXhoHf8Y9oAM5D0Bb6Jl6Y0XCM/hEO5Gf B0VqVHJZl4bByut7njrYnOQCISXPxsVJ/M3ZphoKD1+wrI24JYnzzcvUspMWH81DV7yj SWMKsGZvGeyAWfD7qR7LXi1B2teUaHI7aBy0flczceDvbgUPqwh3+1nW8dGCLfwJ6nZb 7rzXVN9B4mNB+nSnHMepHBeIHVqPJlD1m3aAhk9rekrlnMbQDqIVVGid0mAwximpx+YG PtvITNMFbrQrLn2AfxuaMO48SB3XDgYnsYn9tAhxwwtWdwrnzDOHeJVxrkoq+uRO04fF sk8w== X-Gm-Message-State: ALoCoQn7EB5yyIALXunng+vxq3lQE/+R6sZnjr+ls8ZxWel+Jzp2lkgZlU3Bh50a64z+HN/ZX7hp X-Received: by 10.194.221.65 with SMTP id qc1mr1035188wjc.7.1422643961897; Fri, 30 Jan 2015 10:52:41 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.42 with SMTP id x10ls300653lax.96.gmail; Fri, 30 Jan 2015 10:52:41 -0800 (PST) X-Received: by 10.112.234.164 with SMTP id uf4mr3311575lbc.83.1422643961598; Fri, 30 Jan 2015 10:52:41 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id my5si8342375lbb.93.2015.01.30.10.52.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Jan 2015 10:52:41 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id q1so25318878lam.2 for ; Fri, 30 Jan 2015 10:52:41 -0800 (PST) X-Received: by 10.152.182.235 with SMTP id eh11mr8139316lac.9.1422643961495; Fri, 30 Jan 2015 10:52:41 -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.35.133 with SMTP id h5csp377836lbj; Fri, 30 Jan 2015 10:52:40 -0800 (PST) X-Received: by 10.220.139.135 with SMTP id e7mr3981895vcu.75.1422643953484; Fri, 30 Jan 2015 10:52:33 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id b13si5533901vcv.95.2015.01.30.10.52.32 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 30 Jan 2015 10:52:33 -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 1YHGdy-0007Eg-6Z; Fri, 30 Jan 2015 18:50:14 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YHGdx-0007Dv-Bv for xen-devel@lists.xenproject.org; Fri, 30 Jan 2015 18:50:13 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id B7/E2-02885-462DBC45; Fri, 30 Jan 2015 18:50:12 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-2.tower-31.messagelabs.com!1422643811!10942811!1 X-Originating-IP: [74.125.82.172] 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 13826 invoked from network); 30 Jan 2015 18:50:11 -0000 Received: from mail-we0-f172.google.com (HELO mail-we0-f172.google.com) (74.125.82.172) by server-2.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 30 Jan 2015 18:50:11 -0000 Received: by mail-we0-f172.google.com with SMTP id q59so28721309wes.3 for ; Fri, 30 Jan 2015 10:50:11 -0800 (PST) X-Received: by 10.194.3.40 with SMTP id 8mr9268400wjz.98.1422643811283; Fri, 30 Jan 2015 10:50:11 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id n1sm169040wib.11.2015.01.30.10.50.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Jan 2015 10:50:10 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 30 Jan 2015 18:49:23 +0000 Message-Id: <1422643768-23614-9-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422643768-23614-1-git-send-email-julien.grall@linaro.org> References: <1422643768-23614-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v3 08/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.43 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 Acked-by: Stefano Stabellini --- Changes in v3: - Add Stefano's ack --- 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 | 4 ++-- xen/include/asm-arm/gic.h | 15 +++++---------- 9 files changed, 35 insertions(+), 59 deletions(-) diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index 1f9dbf7..675784c 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_class class, const void *data) { @@ -55,7 +38,7 @@ int __init device_init(struct dt_device_node *dev, enum device_class class, if ( desc->class != class ) 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_class device_get_class(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->class; } diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index ee400b6..01aa46d 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -762,16 +762,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 47452ca..4f1fd51 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1276,14 +1276,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 cba8729..bac1c2b 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 161b251..d443880 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 16d1454..d8f64ea 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 57274d9..67e6df5 100644 --- a/xen/drivers/char/pl011.c +++ b/xen/drivers/char/pl011.c @@ -285,14 +285,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 a3d45dd..2928a4f 100644 --- a/xen/include/asm-arm/device.h +++ b/xen/include/asm-arm/device.h @@ -44,8 +44,8 @@ struct device_desc { const char *name; /* Device class */ enum device_class class; - /* 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