From patchwork Wed Sep 21 11:07:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 9343331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2C62B601C2 for ; Wed, 21 Sep 2016 11:09:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D36C2A5EF for ; Wed, 21 Sep 2016 11:09:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 119CF2A5F1; Wed, 21 Sep 2016 11:09:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E2CC22A5EF for ; Wed, 21 Sep 2016 11:09:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bmfNs-0004fD-4H; Wed, 21 Sep 2016 11:08:12 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bmfNZ-0004Mb-Bi for linux-arm-kernel@lists.infradead.org; Wed, 21 Sep 2016 11:07:55 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id u8LB7PoP001989; Wed, 21 Sep 2016 06:07:25 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u8LB7Ol7006543; Wed, 21 Sep 2016 06:07:24 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Wed, 21 Sep 2016 06:07:23 -0500 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u8LB7L3f032451; Wed, 21 Sep 2016 06:07:22 -0500 Subject: Re: [PATCH v2 2/9] dmaengine: edma: Use enum for eDMA binding type (legacy vs TPCC) To: Arnd Bergmann References: <20160921102637.24845-1-peter.ujfalusi@ti.com> <20160921102637.24845-3-peter.ujfalusi@ti.com> <7753810.Z3F41qkFaI@wuerfel> From: Peter Ujfalusi Message-ID: Date: Wed, 21 Sep 2016 14:07:22 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <7753810.Z3F41qkFaI@wuerfel> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160921_040753_685001_103415E8 X-CRM114-Status: GOOD ( 11.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vinod.koul@intel.com, linux-kernel@vger.kernel.org, tony@atomide.com, dmaengine@vger.kernel.org, dan.j.williams@intel.com, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 09/21/16 13:31, Arnd Bergmann wrote: > On Wednesday, September 21, 2016 1:26:30 PM CEST Peter Ujfalusi wrote: >> diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c >> index c2098a4b4dcf..4c8818278fcc 100644 >> --- a/drivers/dma/edma.c >> +++ b/drivers/dma/edma.c >> @@ -261,8 +261,11 @@ static const struct edmacc_param dummy_paramset = { >> .ccnt = 1, >> }; >> >> -#define EDMA_BINDING_LEGACY 0 >> -#define EDMA_BINDING_TPCC 1 >> +enum edma_binding_type { >> + EDMA_BINDING_LEGACY = 0, >> + EDMA_BINDING_TPCC, >> +}; >> + >> static const struct of_device_id edma_of_ids[] = { >> { >> .compatible = "ti,edma3", >> @@ -2184,7 +2187,8 @@ static int edma_probe(struct platform_device *pdev) >> const struct of_device_id *match; >> >> match = of_match_node(edma_of_ids, node); >> - if (match && (u32)match->data == EDMA_BINDING_TPCC) >> + if (match && >> + (enum edma_binding_type)match->data == EDMA_BINDING_TPCC) >> legacy_mode = false; >> >> info = edma_setup_info_from_dt(dev, legacy_mode); >> -- >> 2.10.0 >> > > Are you sure this works on all architectures? IIRC the size of an enum > is implementation defined, so this could still fail sometimes. True, some arch have HW type for enum or something similar. > > I tend to use 'uintptr_t' for the cast instead. What about keeping the defines and: same for the ti-dma-crossbar. diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 3e9606b08340..493fdf30e8b8 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -263,14 +263,19 @@ static const struct edmacc_param dummy_paramset = { #define EDMA_BINDING_LEGACY 0 #define EDMA_BINDING_TPCC 1 +static const u32 edma_binding_type[] = { + [EDMA_BINDING_LEGACY] = EDMA_BINDING_LEGACY, + [EDMA_BINDING_TPCC] = EDMA_BINDING_TPCC, +}; + static const struct of_device_id edma_of_ids[] = { { .compatible = "ti,edma3", - .data = (void *)EDMA_BINDING_LEGACY, + .data = (void *)&edma_binding_type[EDMA_BINDING_LEGACY], }, { .compatible = "ti,edma3-tpcc", - .data = (void *)EDMA_BINDING_TPCC, + .data = (void *)&edma_binding_type[EDMA_BINDING_TPCC], }, {} }; @@ -2183,7 +2188,7 @@ static int edma_probe(struct platform_device *pdev) const struct of_device_id *match; match = of_match_node(edma_of_ids, node); - if (match && (u32)match->data == EDMA_BINDING_TPCC) + if (match && (*(u32*)match->data) == EDMA_BINDING_TPCC) legacy_mode = false; info = edma_setup_info_from_dt(dev, legacy_mode);