From patchwork Wed Feb 25 18:52:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 45098 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7934B20502 for ; Wed, 25 Feb 2015 18:55:04 +0000 (UTC) Received: by lbdu10 with SMTP id u10sf4402111lbd.3 for ; Wed, 25 Feb 2015 10:55:03 -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=Mi/mUcBHU9CFu67ue+IKWfxxgcYdyRkics6mbejZN18=; b=VmsPP9JyXxnY1kH+57+hglazWvV0/DyJf5nZo9YZXvUS6reX/29FxY8PHWPdcUD5/L QnZT3Tr6n6KDPjgJF5s/ukAFgVklUDYEEnfvFZ/kV34QVeMy3Bf2G9kX+EeyBOUlORTH 8WK3oIgrK4SsYbfikPtT6m6c6taTAvit8oL//WmzZRxgo+Af6LNlzW0x0CceweD1kPm9 mjGS4/pOXXcu/CwoBTpXHxlSwGJ5YJkYEpfIZGbLYUGy73k+W07MBHGOZi0CTlGLn7qz 85mHNw2U0iuwak6kEWxzVSJv69X736l0dlk9y8UP3NeK6KJHNiY/Ft9NjkDnqwytlrvS Drvg== X-Gm-Message-State: ALoCoQkACK36AuJXVVFd0j3jUdQecWC+KBc+p7CXTovOGZ1FGjNcd5A0L33AJThoYK18+K5RIGDA X-Received: by 10.112.131.106 with SMTP id ol10mr736391lbb.20.1424890503407; Wed, 25 Feb 2015 10:55:03 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.9 with SMTP id bc9ls921804lab.101.gmail; Wed, 25 Feb 2015 10:55:03 -0800 (PST) X-Received: by 10.112.25.104 with SMTP id b8mr4093041lbg.69.1424890503247; Wed, 25 Feb 2015 10:55:03 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id d9si8137277lah.152.2015.02.25.10.55.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 10:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lamq1 with SMTP id q1so6004474lam.5 for ; Wed, 25 Feb 2015 10:55:03 -0800 (PST) X-Received: by 10.112.135.196 with SMTP id pu4mr4089437lbb.41.1424890502935; Wed, 25 Feb 2015 10:55:02 -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 h5csp2819612lbj; Wed, 25 Feb 2015 10:55:01 -0800 (PST) X-Received: by 10.52.81.229 with SMTP id d5mr5365751vdy.54.1424890500590; Wed, 25 Feb 2015 10:55:00 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id dh4si20699650vcb.94.2015.02.25.10.54.59 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 25 Feb 2015 10:55:00 -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 1YQh5Z-0005r9-2a; Wed, 25 Feb 2015 18:53:41 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQh5X-0005qJ-QB for xen-devel@lists.xenproject.org; Wed, 25 Feb 2015 18:53:40 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 14/6D-02801-23A1EE45; Wed, 25 Feb 2015 18:53:38 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1424890418!11377162!1 X-Originating-IP: [74.125.82.46] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1077 invoked from network); 25 Feb 2015 18:53:38 -0000 Received: from mail-wg0-f46.google.com (HELO mail-wg0-f46.google.com) (74.125.82.46) by server-13.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 25 Feb 2015 18:53:38 -0000 Received: by wggy19 with SMTP id y19so5549068wgg.10 for ; Wed, 25 Feb 2015 10:53:38 -0800 (PST) X-Received: by 10.194.89.163 with SMTP id bp3mr8673411wjb.145.1424890418010; Wed, 25 Feb 2015 10:53:38 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id kr5sm61071839wjc.1.2015.02.25.10.53.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 10:53:37 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 25 Feb 2015 18:52:57 +0000 Message-Id: <1424890381-4225-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424890381-4225-1-git-send-email-julien.grall@linaro.org> References: <1424890381-4225-1-git-send-email-julien.grall@linaro.org> Cc: ian.campbell@citrix.com, Stefano Stabellini , manish.jaggi@caviumnetworks.com, Julien Grall , tim@xen.org, stefano.stabellini@citrix.com Subject: [Xen-devel] [PATCH v4 4/8] xen/arm: Describe devices supported by a driver with dt_device_match 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.48 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 a list of compatible strings to match drivers again device nodes. This leads to having double definitions in the GIC code. Furthermore Linux drivers are using dt_device_match (actually called of_device_id in Linux) to list device supported by the drivers. Remove the exisiting compatible field and replace with a dt_match field Signed-off-by: Julien Grall Acked-by: Stefano Stabellini Acked-by: Ian Campbell --- Changes in v4: - s/dt_match_node/dt_device_match/ in the commit message - Make the SCIF UART driver use the new API (was merged recently) - Typoes and clarify the commit message - Add Ian's ack 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/drivers/char/scif-uart.c | 8 ++++---- xen/include/asm-arm/device.h | 4 ++-- xen/include/asm-arm/gic.h | 15 +++++---------- 10 files changed, 39 insertions(+), 63 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 c05b64a..e551549 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -776,16 +776,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 1558e17..66cc2a2 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1320,14 +1320,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/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c index 1a1c496..51a2233 100644 --- a/xen/drivers/char/scif-uart.c +++ b/xen/drivers/char/scif-uart.c @@ -346,14 +346,14 @@ static int __init scif_uart_init(struct dt_device_node *dev, return 0; } -static const char * const scif_uart_dt_compat[] __initconst = +static const struct dt_device_match scif_uart_dt_match[] __initconst = { - "renesas,scif", - NULL + DT_MATCH_COMPATIBLE("renesas,scif"), + { /* sentinel */ }, }; DT_DEVICE_START(scif_uart, "SCIF UART", DEVICE_SERIAL) - .compatible = scif_uart_dt_compat, + .dt_match = scif_uart_dt_match, .init = scif_uart_init, DT_DEVICE_END diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h index 1cedd49..a72f7c9 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 0396a8e..6f5767f 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -153,17 +153,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