* [PATCH] iommu: replace single-char identifiers in macros
@ 2019-06-03 12:59 ` Qian Cai
0 siblings, 0 replies; 8+ messages in thread
From: Qian Cai @ 2019-06-03 12:59 UTC (permalink / raw)
To: jroedel; +Cc: akpm, iommu, linux-kernel, Qian Cai
There are a few macros in IOMMU have single-char identifiers make the
code hard to read and debug. Replace them with meaningful names.
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Qian Cai <cai@lca.pw>
---
include/linux/dmar.h | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index f8af1d770520..eb634912f475 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -104,12 +104,14 @@ static inline bool dmar_rcu_check(void)
#define dmar_rcu_dereference(p) rcu_dereference_check((p), dmar_rcu_check())
-#define for_each_dev_scope(a, c, p, d) \
- for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev) : \
- NULL, (p) < (c)); (p)++)
-
-#define for_each_active_dev_scope(a, c, p, d) \
- for_each_dev_scope((a), (c), (p), (d)) if (!(d)) { continue; } else
+#define for_each_dev_scope(devs, cnt, i, tmp) \
+ for ((i) = 0; ((tmp) = (i) < (cnt) ? \
+ dmar_rcu_dereference((devs)[(i)].dev) : NULL, (i) < (cnt)); \
+ (i)++)
+
+#define for_each_active_dev_scope(devs, cnt, i, tmp) \
+ for_each_dev_scope((devs), (cnt), (i), (tmp)) \
+ if (!(tmp)) { continue; } else
extern int dmar_table_init(void);
extern int dmar_dev_scope_init(void);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] iommu: replace single-char identifiers in macros
@ 2019-06-03 12:59 ` Qian Cai
0 siblings, 0 replies; 8+ messages in thread
From: Qian Cai @ 2019-06-03 12:59 UTC (permalink / raw)
To: jroedel; +Cc: akpm, Qian Cai, iommu, linux-kernel
There are a few macros in IOMMU have single-char identifiers make the
code hard to read and debug. Replace them with meaningful names.
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Qian Cai <cai@lca.pw>
---
include/linux/dmar.h | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index f8af1d770520..eb634912f475 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -104,12 +104,14 @@ static inline bool dmar_rcu_check(void)
#define dmar_rcu_dereference(p) rcu_dereference_check((p), dmar_rcu_check())
-#define for_each_dev_scope(a, c, p, d) \
- for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev) : \
- NULL, (p) < (c)); (p)++)
-
-#define for_each_active_dev_scope(a, c, p, d) \
- for_each_dev_scope((a), (c), (p), (d)) if (!(d)) { continue; } else
+#define for_each_dev_scope(devs, cnt, i, tmp) \
+ for ((i) = 0; ((tmp) = (i) < (cnt) ? \
+ dmar_rcu_dereference((devs)[(i)].dev) : NULL, (i) < (cnt)); \
+ (i)++)
+
+#define for_each_active_dev_scope(devs, cnt, i, tmp) \
+ for_each_dev_scope((devs), (cnt), (i), (tmp)) \
+ if (!(tmp)) { continue; } else
extern int dmar_table_init(void);
extern int dmar_dev_scope_init(void);
--
1.8.3.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu: replace single-char identifiers in macros
2019-06-03 12:59 ` Qian Cai
@ 2019-06-03 13:07 ` Robin Murphy
-1 siblings, 0 replies; 8+ messages in thread
From: Robin Murphy @ 2019-06-03 13:07 UTC (permalink / raw)
To: Qian Cai, jroedel; +Cc: akpm, iommu, linux-kernel
On 03/06/2019 13:59, Qian Cai wrote:
> There are a few macros in IOMMU have single-char identifiers make the
> code hard to read and debug. Replace them with meaningful names.
>
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
> include/linux/dmar.h | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/dmar.h b/include/linux/dmar.h
> index f8af1d770520..eb634912f475 100644
> --- a/include/linux/dmar.h
> +++ b/include/linux/dmar.h
> @@ -104,12 +104,14 @@ static inline bool dmar_rcu_check(void)
>
> #define dmar_rcu_dereference(p) rcu_dereference_check((p), dmar_rcu_check())
>
> -#define for_each_dev_scope(a, c, p, d) \
> - for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev) : \
> - NULL, (p) < (c)); (p)++)
> -
> -#define for_each_active_dev_scope(a, c, p, d) \
> - for_each_dev_scope((a), (c), (p), (d)) if (!(d)) { continue; } else
> +#define for_each_dev_scope(devs, cnt, i, tmp) \
> + for ((i) = 0; ((tmp) = (i) < (cnt) ? \
Given that "tmp" actually appears to be some sort of device cursor, I'm
not sure that that naming really achieves the stated goal of clarity :/
Robin.
> + dmar_rcu_dereference((devs)[(i)].dev) : NULL, (i) < (cnt)); \
> + (i)++)
> +
> +#define for_each_active_dev_scope(devs, cnt, i, tmp) \
> + for_each_dev_scope((devs), (cnt), (i), (tmp)) \
> + if (!(tmp)) { continue; } else
>
> extern int dmar_table_init(void);
> extern int dmar_dev_scope_init(void);
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu: replace single-char identifiers in macros
@ 2019-06-03 13:07 ` Robin Murphy
0 siblings, 0 replies; 8+ messages in thread
From: Robin Murphy @ 2019-06-03 13:07 UTC (permalink / raw)
To: Qian Cai, jroedel; +Cc: akpm, iommu, linux-kernel
On 03/06/2019 13:59, Qian Cai wrote:
> There are a few macros in IOMMU have single-char identifiers make the
> code hard to read and debug. Replace them with meaningful names.
>
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
> include/linux/dmar.h | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/dmar.h b/include/linux/dmar.h
> index f8af1d770520..eb634912f475 100644
> --- a/include/linux/dmar.h
> +++ b/include/linux/dmar.h
> @@ -104,12 +104,14 @@ static inline bool dmar_rcu_check(void)
>
> #define dmar_rcu_dereference(p) rcu_dereference_check((p), dmar_rcu_check())
>
> -#define for_each_dev_scope(a, c, p, d) \
> - for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev) : \
> - NULL, (p) < (c)); (p)++)
> -
> -#define for_each_active_dev_scope(a, c, p, d) \
> - for_each_dev_scope((a), (c), (p), (d)) if (!(d)) { continue; } else
> +#define for_each_dev_scope(devs, cnt, i, tmp) \
> + for ((i) = 0; ((tmp) = (i) < (cnt) ? \
Given that "tmp" actually appears to be some sort of device cursor, I'm
not sure that that naming really achieves the stated goal of clarity :/
Robin.
> + dmar_rcu_dereference((devs)[(i)].dev) : NULL, (i) < (cnt)); \
> + (i)++)
> +
> +#define for_each_active_dev_scope(devs, cnt, i, tmp) \
> + for_each_dev_scope((devs), (cnt), (i), (tmp)) \
> + if (!(tmp)) { continue; } else
>
> extern int dmar_table_init(void);
> extern int dmar_dev_scope_init(void);
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu: replace single-char identifiers in macros
2019-06-03 13:07 ` Robin Murphy
@ 2019-06-03 13:29 ` Qian Cai
-1 siblings, 0 replies; 8+ messages in thread
From: Qian Cai @ 2019-06-03 13:29 UTC (permalink / raw)
To: Robin Murphy, jroedel; +Cc: akpm, iommu, linux-kernel
On Mon, 2019-06-03 at 14:07 +0100, Robin Murphy wrote:
> On 03/06/2019 13:59, Qian Cai wrote:
> > There are a few macros in IOMMU have single-char identifiers make the
> > code hard to read and debug. Replace them with meaningful names.
> >
> > Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Qian Cai <cai@lca.pw>
> > ---
> > include/linux/dmar.h | 14 ++++++++------
> > 1 file changed, 8 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/linux/dmar.h b/include/linux/dmar.h
> > index f8af1d770520..eb634912f475 100644
> > --- a/include/linux/dmar.h
> > +++ b/include/linux/dmar.h
> > @@ -104,12 +104,14 @@ static inline bool dmar_rcu_check(void)
> >
> > #define dmar_rcu_dereference(p) rcu_dereference_check((p),
> > dmar_rcu_check())
> >
> > -#define for_each_dev_scope(a, c, p, d) \
> > - for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev)
> > : \
> > - NULL, (p) < (c)); (p)++)
> > -
> > -#define for_each_active_dev_scope(a, c, p, d) \
> > - for_each_dev_scope((a), (c), (p), (d)) if (!(d)) { continue;
> > } else
> > +#define for_each_dev_scope(devs, cnt, i, tmp)
> > \
> > + for ((i) = 0; ((tmp) = (i) < (cnt) ?
> > \
>
> Given that "tmp" actually appears to be some sort of device cursor, I'm
> not sure that that naming really achieves the stated goal of clarity :/
"tmp" is used in the callers everywhere though, although I suppose something
like "tmp_dev" can be used if you prefer.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu: replace single-char identifiers in macros
@ 2019-06-03 13:29 ` Qian Cai
0 siblings, 0 replies; 8+ messages in thread
From: Qian Cai @ 2019-06-03 13:29 UTC (permalink / raw)
To: Robin Murphy, jroedel; +Cc: akpm, iommu, linux-kernel
On Mon, 2019-06-03 at 14:07 +0100, Robin Murphy wrote:
> On 03/06/2019 13:59, Qian Cai wrote:
> > There are a few macros in IOMMU have single-char identifiers make the
> > code hard to read and debug. Replace them with meaningful names.
> >
> > Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Qian Cai <cai@lca.pw>
> > ---
> > include/linux/dmar.h | 14 ++++++++------
> > 1 file changed, 8 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/linux/dmar.h b/include/linux/dmar.h
> > index f8af1d770520..eb634912f475 100644
> > --- a/include/linux/dmar.h
> > +++ b/include/linux/dmar.h
> > @@ -104,12 +104,14 @@ static inline bool dmar_rcu_check(void)
> >
> > #define dmar_rcu_dereference(p) rcu_dereference_check((p),
> > dmar_rcu_check())
> >
> > -#define for_each_dev_scope(a, c, p, d) \
> > - for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev)
> > : \
> > - NULL, (p) < (c)); (p)++)
> > -
> > -#define for_each_active_dev_scope(a, c, p, d) \
> > - for_each_dev_scope((a), (c), (p), (d)) if (!(d)) { continue;
> > } else
> > +#define for_each_dev_scope(devs, cnt, i, tmp)
> > \
> > + for ((i) = 0; ((tmp) = (i) < (cnt) ?
> > \
>
> Given that "tmp" actually appears to be some sort of device cursor, I'm
> not sure that that naming really achieves the stated goal of clarity :/
"tmp" is used in the callers everywhere though, although I suppose something
like "tmp_dev" can be used if you prefer.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu: replace single-char identifiers in macros
2019-06-03 13:29 ` Qian Cai
@ 2019-06-03 13:48 ` Robin Murphy
-1 siblings, 0 replies; 8+ messages in thread
From: Robin Murphy @ 2019-06-03 13:48 UTC (permalink / raw)
To: Qian Cai, jroedel; +Cc: akpm, iommu, linux-kernel
On 03/06/2019 14:29, Qian Cai wrote:
> On Mon, 2019-06-03 at 14:07 +0100, Robin Murphy wrote:
>> On 03/06/2019 13:59, Qian Cai wrote:
>>> There are a few macros in IOMMU have single-char identifiers make the
>>> code hard to read and debug. Replace them with meaningful names.
>>>
>>> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
>>> Signed-off-by: Qian Cai <cai@lca.pw>
>>> ---
>>> include/linux/dmar.h | 14 ++++++++------
>>> 1 file changed, 8 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/include/linux/dmar.h b/include/linux/dmar.h
>>> index f8af1d770520..eb634912f475 100644
>>> --- a/include/linux/dmar.h
>>> +++ b/include/linux/dmar.h
>>> @@ -104,12 +104,14 @@ static inline bool dmar_rcu_check(void)
>>>
>>> #define dmar_rcu_dereference(p) rcu_dereference_check((p),
>>> dmar_rcu_check())
>>>
>>> -#define for_each_dev_scope(a, c, p, d) \
>>> - for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev)
>>> : \
>>> - NULL, (p) < (c)); (p)++)
>>> -
>>> -#define for_each_active_dev_scope(a, c, p, d) \
>>> - for_each_dev_scope((a), (c), (p), (d)) if (!(d)) { continue;
>>> } else
>>> +#define for_each_dev_scope(devs, cnt, i, tmp)
>>> \
>>> + for ((i) = 0; ((tmp) = (i) < (cnt) ?
>>> \
>>
>> Given that "tmp" actually appears to be some sort of device cursor, I'm
>> not sure that that naming really achieves the stated goal of clarity :/
>
> "tmp" is used in the callers everywhere though, although I suppose something
> like "tmp_dev" can be used if you prefer.
I don't have any preference, I'm just questioning the assertion in the
commit message - as a reader not intimately familiar with this code,
"tmp" is honestly no more meaningful than "d" was.
Robin.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu: replace single-char identifiers in macros
@ 2019-06-03 13:48 ` Robin Murphy
0 siblings, 0 replies; 8+ messages in thread
From: Robin Murphy @ 2019-06-03 13:48 UTC (permalink / raw)
To: Qian Cai, jroedel; +Cc: akpm, iommu, linux-kernel
On 03/06/2019 14:29, Qian Cai wrote:
> On Mon, 2019-06-03 at 14:07 +0100, Robin Murphy wrote:
>> On 03/06/2019 13:59, Qian Cai wrote:
>>> There are a few macros in IOMMU have single-char identifiers make the
>>> code hard to read and debug. Replace them with meaningful names.
>>>
>>> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
>>> Signed-off-by: Qian Cai <cai@lca.pw>
>>> ---
>>> include/linux/dmar.h | 14 ++++++++------
>>> 1 file changed, 8 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/include/linux/dmar.h b/include/linux/dmar.h
>>> index f8af1d770520..eb634912f475 100644
>>> --- a/include/linux/dmar.h
>>> +++ b/include/linux/dmar.h
>>> @@ -104,12 +104,14 @@ static inline bool dmar_rcu_check(void)
>>>
>>> #define dmar_rcu_dereference(p) rcu_dereference_check((p),
>>> dmar_rcu_check())
>>>
>>> -#define for_each_dev_scope(a, c, p, d) \
>>> - for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev)
>>> : \
>>> - NULL, (p) < (c)); (p)++)
>>> -
>>> -#define for_each_active_dev_scope(a, c, p, d) \
>>> - for_each_dev_scope((a), (c), (p), (d)) if (!(d)) { continue;
>>> } else
>>> +#define for_each_dev_scope(devs, cnt, i, tmp)
>>> \
>>> + for ((i) = 0; ((tmp) = (i) < (cnt) ?
>>> \
>>
>> Given that "tmp" actually appears to be some sort of device cursor, I'm
>> not sure that that naming really achieves the stated goal of clarity :/
>
> "tmp" is used in the callers everywhere though, although I suppose something
> like "tmp_dev" can be used if you prefer.
I don't have any preference, I'm just questioning the assertion in the
commit message - as a reader not intimately familiar with this code,
"tmp" is honestly no more meaningful than "d" was.
Robin.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-06-03 13:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-03 12:59 [PATCH] iommu: replace single-char identifiers in macros Qian Cai
2019-06-03 12:59 ` Qian Cai
2019-06-03 13:07 ` Robin Murphy
2019-06-03 13:07 ` Robin Murphy
2019-06-03 13:29 ` Qian Cai
2019-06-03 13:29 ` Qian Cai
2019-06-03 13:48 ` Robin Murphy
2019-06-03 13:48 ` Robin Murphy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.