From patchwork Fri Jan 16 14:24:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 43248 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 00F07240D8 for ; Fri, 16 Jan 2015 14:26:56 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id k14sf11245448wgh.2 for ; Fri, 16 Jan 2015 06:26:55 -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=KP15pJ8NVB1U4SgKpmBC4+mrdQQ4/BiqeG7FoJ9bJeM=; b=CbpPBBODaeqXsPoMqtdeF5gENlD4iL6czNexJ5zGTM6W1EbFShtpFcQMIPSZpsw/b0 BlVB4c9tyMM6Qv8nBZifYTeBzzBAmR1zlyQcgbJmE1QYW4cjIprEbKUTHkp9I4TaPkQb CjG6McVPmSTwnkEiqdJyCYgRo88s+bCm2O951syhT6uHUZq0VcKxS01EemnWHdfGl6eb Cpz/SIs1jYNBh1ZBwZdlOqtBT3wvpLKzrTM8gbyL5wGy0y9vQbw7hxTnBbm6OpWR3Tds y8im2PHV9MUmGYVZpZrQ0ijrktuuvlU1tjGl2m1Bryy0wwnriwinZz/6xowMAtzoxABZ HSBg== X-Gm-Message-State: ALoCoQktNKHxN9saIf86jKHLz5FT7/igRP3bMsKqLJnT4bXvAH/QetCNP0xcfOrzT1aK3q2YylSA X-Received: by 10.112.42.104 with SMTP id n8mr270099lbl.19.1421418415302; Fri, 16 Jan 2015 06:26:55 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.228 with SMTP id uh4ls364944lac.108.gmail; Fri, 16 Jan 2015 06:26:55 -0800 (PST) X-Received: by 10.112.125.202 with SMTP id ms10mr15916162lbb.33.1421418415160; Fri, 16 Jan 2015 06:26:55 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id lt6si4571684lac.47.2015.01.16.06.26.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 06:26:55 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so19176089lab.8 for ; Fri, 16 Jan 2015 06:26:55 -0800 (PST) X-Received: by 10.112.98.99 with SMTP id eh3mr15714799lbb.32.1421418414807; Fri, 16 Jan 2015 06:26:54 -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.9.200 with SMTP id c8csp325464lbb; Fri, 16 Jan 2015 06:26:53 -0800 (PST) X-Received: by 10.140.35.114 with SMTP id m105mr23756662qgm.79.1421418409594; Fri, 16 Jan 2015 06:26:49 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id c13si5976927qaw.34.2015.01.16.06.26.49 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 16 Jan 2015 06:26:49 -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 1YC7pl-0004NA-9E; Fri, 16 Jan 2015 14:25:09 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YC7pj-0004L6-3X for xen-devel@lists.xenproject.org; Fri, 16 Jan 2015 14:25:07 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 73/AA-17958-24F19B45; Fri, 16 Jan 2015 14:25:06 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-9.tower-31.messagelabs.com!1421418305!16408749!1 X-Originating-IP: [74.125.82.41] 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 11337 invoked from network); 16 Jan 2015 14:25:05 -0000 Received: from mail-wg0-f41.google.com (HELO mail-wg0-f41.google.com) (74.125.82.41) by server-9.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 16 Jan 2015 14:25:05 -0000 Received: by mail-wg0-f41.google.com with SMTP id l18so20846656wgh.0 for ; Fri, 16 Jan 2015 06:25:05 -0800 (PST) X-Received: by 10.180.101.35 with SMTP id fd3mr6012493wib.6.1421418304881; Fri, 16 Jan 2015 06:25:04 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id x6sm6270862wjf.24.2015.01.16.06.25.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jan 2015 06:25:04 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 16 Jan 2015 14:24:03 +0000 Message-Id: <1421418247-30068-9-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421418247-30068-1-git-send-email-julien.grall@linaro.org> References: <1421418247-30068-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 v2 08/12] 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.49 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 | 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 693b9af..e4f4603 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 f149e09..34d622f 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -764,16 +764,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 076aa62..35f80b3 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 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 2fe4280..e4666b4 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 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