public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: peter.ujfalusi@ti.com (Peter Ujfalusi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/9] dmaengine: edma: Use enum for eDMA binding type (legacy vs TPCC)
Date: Wed, 21 Sep 2016 14:07:22 +0300	[thread overview]
Message-ID: <bbd248d1-223c-00a9-3d2a-33df085c4f68@ti.com> (raw)
In-Reply-To: <7753810.Z3F41qkFaI@wuerfel>

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:

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);


same for the ti-dma-crossbar.

-- 
P?ter

  reply	other threads:[~2016-09-21 11:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-21 10:26 [PATCH v2 0/9] dmaengine: ti drivers: enable COMPILE_TESTing Peter Ujfalusi
2016-09-21 10:26 ` [PATCH v2 1/9] dmaengine: edma: Add missing MODULE_DEVICE_TABLE() for of_device_id structs Peter Ujfalusi
2016-09-21 10:26 ` [PATCH v2 2/9] dmaengine: edma: Use enum for eDMA binding type (legacy vs TPCC) Peter Ujfalusi
2016-09-21 10:31   ` Arnd Bergmann
2016-09-21 11:07     ` Peter Ujfalusi [this message]
2016-09-21 11:38       ` Arnd Bergmann
2016-09-21 10:26 ` [PATCH v2 3/9] dmaengine: edma: Use correct type for of_find_property() third parameter Peter Ujfalusi
2016-09-21 10:26 ` [PATCH v2 4/9] dmaengine/ARM: omap-dma: Fix the DMAengine compile test on non OMAP configs Peter Ujfalusi
2016-09-21 10:26 ` [PATCH v2 5/9] dmaengine: ti-dma-crossbar: Correct type for of_find_property() third parameter Peter Ujfalusi
2016-09-21 10:26 ` [PATCH v2 6/9] dmaengine: ti-dma-crossbar: Use enum for crossbar type Peter Ujfalusi
2016-09-21 10:26 ` [PATCH v2 7/9] dmaengine: edma: enable COMPILE_TEST Peter Ujfalusi
2016-09-21 10:26 ` [PATCH v2 8/9] dmaengine: omap-dma: " Peter Ujfalusi
2016-09-21 10:26 ` [PATCH v2 9/9] dmaengine: ti-dma-crossbar: " Peter Ujfalusi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bbd248d1-223c-00a9-3d2a-33df085c4f68@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox