Re: [PATCH v2 1/6] powerpc/pseries/iommu: Create defines for operations in ibm,ddw-applicable

From: Alexey Kardashevskiy
Date: Wed Jul 01 2020 - 20:43:57 EST




On 02/07/2020 10:36, Leonardo Bras wrote:
> On Thu, 2020-07-02 at 10:21 +1000, Alexey Kardashevskiy wrote:
>>> enum {
>>> DDW_QUERY_PE_DMA_WIN,
>>> DDW_CREATE_PE_DMA_WIN,
>>> DDW_REMOVE_PE_DMA_WIN,
>>>
>>> DDW_APPLICABLE_SIZE
>>> }
>>> IMO, it looks better than all the defines before.
>>>
>>> What do you think?
>>
>> No, not really, these come from a binary interface so the reader of this
>> cares about absolute numbers and rather wants to see them explicitly.
>
> Makes sense to me.
> I am still getting experience on where to use enum vs define. Thanks
> for the tip!
>
> Using something like
> enum {
> DDW_QUERY_PE_DMA_WIN = 0,
> DDW_CREATE_PE_DMA_WIN = 1,
> DDW_REMOVE_PE_DMA_WIN = 2,
>
> DDW_APPLICABLE_SIZE
> };
>
> would be fine too?


This is fine too.


> Or should one stick to #define in this case?

imho a matter of taste but after some grepping it feels like #define is
mostly used which does not mean it is a good idea. Keep it enum and see
if it passed mpe's filter :)



--
Alexey