* [PATCH 0/3] introduce macros for i2c_msg initialization
@ 2012-09-30 7:33 Julia Lawall
2012-09-30 7:33 ` [PATCH 3/3] drivers/media/tuners/fc0011.c: " Julia Lawall
2012-09-30 7:35 ` [PATCH 0/3] " Julia Lawall
0 siblings, 2 replies; 7+ messages in thread
From: Julia Lawall @ 2012-09-30 7:33 UTC (permalink / raw)
To: kernel-janitors
This patch introduces some macros for describing how an i2c_msg is being
initialized. There are three macros: I2C_MSG_READ, for a read message,
I2C_MSG_WRITE, for a write message, and I2C_MSG_OP, for some other kind of
message, which is expected to be very rarely used.
i2c_msg initializations are updated using the following semantic patch:
// <smpl>
@r@
field list[n] ds;
type T;
identifier i;
@@
struct i2c_msg {
ds
T i;
...
};
@@
initializer list[r.n] is;
expression a;
identifier nm;
identifier r.i;
@@
struct i2c_msg nm = {
is,
- a
+ .i = a
,...
};
@@
initializer list[r.n] is;
expression a;
identifier nm;
identifier r.i;
@@
struct i2c_msg nm[...] = { ..., {
is,
- a
+ .i = a
,...}, ...};
@@
initializer list[r.n] is;
expression a;
identifier nm;
identifier r.i;
@@
struct i2c_msg nm[] = { ..., {
is,
- a
+ .i = a
,...}, ...};
// --------------------------------------------------------------------
// ensure everyone has all fields, pointer case first
@rt@
type T;
identifier i;
@@
struct i2c_msg {
...
T *i;
...
};
@t1@
expression e;
identifier nm,rt.i;
position p;
@@
struct i2c_msg nm = {@p
.i = e,
};
@@
identifier nm,rt.i;
position p!= t1.p;
@@
struct i2c_msg nm = {@p
+ .i = NULL,
...
};
@t2@
expression e;
identifier nm,rt.i;
position p;
@@
struct i2c_msg nm[] = { ..., {@p
.i = e,
}, ...};
@@
identifier nm,rt.i;
position p!= t2.p;
@@
struct i2c_msg nm[] = { ..., {@p
+ .i = NULL,
...
}, ...};
@t3@
expression e;
identifier nm,rt.i;
position p;
@@
struct i2c_msg nm[...] = { ..., {@p
.i = e,
}, ...};
@@
identifier nm,rt.i;
position p!= t3.p;
@@
struct i2c_msg nm[...] = { ..., {@p
+ .i = NULL,
...
}, ...};
// ---------------------------------
@f1@
expression e;
identifier nm,r.i;
position p;
@@
struct i2c_msg nm = {@p
.i = e,
};
@@
identifier nm,r.i;
position p!= f1.p;
@@
struct i2c_msg nm = {@p
+ .i = 0,
...
};
@f2@
expression e;
identifier nm,r.i;
position p;
@@
struct i2c_msg nm[] = { ..., {@p
.i = e,
}, ...};
@@
identifier nm,r.i;
position p!= f2.p;
@@
struct i2c_msg nm[] = { ..., {@p
+ .i = 0,
...
}, ...};
@f3@
expression e;
identifier nm,r.i;
position p;
@@
struct i2c_msg nm[...] = { ..., {@p
.i = e,
}, ...};
@@
identifier nm,r.i;
position p!= f3.p;
@@
struct i2c_msg nm[...] = { ..., {@p
+ .i = 0,
...
}, ...};
// --------------------------------------------------------------------
@@
expression a,b,c;
identifier x;
@@
struct i2c_msg x - {.addr = a, .buf = b, .len = c, .flags = I2C_M_RD}
+ I2C_MSG_READ(a,b,c)
;
@@
expression a,b,c;
identifier x;
@@
struct i2c_msg x - {.addr = a, .buf = b, .len = c, .flags = 0}
+ I2C_MSG_WRITE(a,b,c)
;
// has to come before the next rule, which matcher fewer fields
@@
expression a,b,c,d;
identifier x;
@@
struct i2c_msg x =
- {.addr = a, .buf = b, .len = c, .flags = d}
+ I2C_MSG_OP(a,b,c,d)
;
// --------------------------------------------------------------------
@@
expression a,b,c;
identifier x;
@@
struct i2c_msg x[] = {...,
- {.addr = a, .buf = b, .len = c, .flags = I2C_M_RD}
+ I2C_MSG_READ(a,b,c)
,...};
@@
expression a,b,c;
identifier x;
@@
struct i2c_msg x[] = {...,
- {.addr = a, .buf = b, .len = c, .flags = 0}
+ I2C_MSG_WRITE(a,b,c)
,...};
@@
expression a,b,c,d;
identifier x;
@@
struct i2c_msg x[] = {...,
- {.addr = a, .buf = b, .len = c, .flags = d}
+ I2C_MSG_OP(a,b,c,d)
,...};
// --------------------------------------------------------------------
@@
expression a,b,c;
identifier x;
@@
struct i2c_msg x[...] = {...,
- {.addr = a, .buf = b, .len = c, .flags = I2C_M_RD}
+ I2C_MSG_READ(a,b,c)
,...};
@@
expression a,b,c;
identifier x;
@@
struct i2c_msg x[...] = {...,
- {.addr = a, .buf = b, .len = c, .flags = 0}
+ I2C_MSG_WRITE(a,b,c)
,...};
@@
expression a,b,c,d;
identifier x;
@@
struct i2c_msg x[...] = {...,
- {.addr = a, .buf = b, .len = c, .flags = d}
+ I2C_MSG_OP(a,b,c,d)
,...};
// --------------------------------------------------------------------
// got everything?
@check1@
identifier nm;
position p;
@@
struct i2c_msg nm@p = {...};
@script:python@
p << check1.p;
@@
cocci.print_main("",p)
@check2@
identifier nm;
position p;
@@
struct i2c_msg nm@p [] = {...,{...},...};
@script:python@
p << check2.p;
@@
cocci.print_main("",p)
@check3@
identifier nm;
position p;
@@
struct i2c_msg nm@p [...] = {...,{...},...};
@script:python@
p << check3.p;
@@
cocci.print_main("",p)
// </smpl>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 3/3] drivers/media/tuners/fc0011.c: introduce macros for i2c_msg initialization
@ 2012-09-30 7:33 ` Julia Lawall
2012-10-01 22:36 ` Ryan Mallon
2012-10-02 5:31 ` [PATCH 3/3] drivers/media/tuners/fc0011.c: introduce macros for i2c_msg initialization Julia Lawall
0 siblings, 2 replies; 7+ messages in thread
From: Julia Lawall @ 2012-09-30 7:33 UTC (permalink / raw)
To: kernel-janitors
From: Julia Lawall <Julia.Lawall@lip6.fr>
Introduce use of I2c_MSG_READ/WRITE/OP, for readability.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression a,b,c;
identifier x;
@@
struct i2c_msg x - {.addr = a, .buf = b, .len = c, .flags = I2C_M_RD}
+ I2C_MSG_READ(a,b,c)
;
@@
expression a,b,c;
identifier x;
@@
struct i2c_msg x - {.addr = a, .buf = b, .len = c, .flags = 0}
+ I2C_MSG_WRITE(a,b,c)
;
@@
expression a,b,c,d;
identifier x;
@@
struct i2c_msg x =
- {.addr = a, .buf = b, .len = c, .flags = d}
+ I2C_MSG_OP(a,b,c,d)
;
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/media/tuners/fc0011.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/media/tuners/fc0011.c b/drivers/media/tuners/fc0011.c
index e488254..b0036d6 100644
--- a/drivers/media/tuners/fc0011.c
+++ b/drivers/media/tuners/fc0011.c
@@ -80,8 +80,7 @@ struct fc0011_priv {
static int fc0011_writereg(struct fc0011_priv *priv, u8 reg, u8 val)
{
u8 buf[2] = { reg, val };
- struct i2c_msg msg = { .addr = priv->addr,
- .flags = 0, .buf = buf, .len = 2 };
+ struct i2c_msg msg = I2C_MSG_WRITE(priv->addr, buf, 2);
if (i2c_transfer(priv->i2c, &msg, 1) != 1) {
dev_err(&priv->i2c->dev,
@@ -97,10 +96,8 @@ static int fc0011_readreg(struct fc0011_priv *priv, u8 reg, u8 *val)
{
u8 dummy;
struct i2c_msg msg[2] = {
- { .addr = priv->addr,
- .flags = 0, .buf = ®, .len = 1 },
- { .addr = priv->addr,
- .flags = I2C_M_RD, .buf = val ? : &dummy, .len = 1 },
+ I2C_MSG_WRITE(priv->addr, ®, 1),
+ I2C_MSG_READ(priv->addr, val ? : &dummy, 1),
};
if (i2c_transfer(priv->i2c, msg, 2) != 2) {
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 3/3] drivers/media/tuners/fc0011.c: introduce macros for i2c_msg initialization
2012-09-30 7:33 ` [PATCH 3/3] drivers/media/tuners/fc0011.c: " Julia Lawall
@ 2012-10-01 22:36 ` Ryan Mallon
2012-10-06 13:20 ` question about drivers/gpu/drm/i915/dvo_ch7xxx.c Julia Lawall
2012-10-02 5:31 ` [PATCH 3/3] drivers/media/tuners/fc0011.c: introduce macros for i2c_msg initialization Julia Lawall
1 sibling, 1 reply; 7+ messages in thread
From: Ryan Mallon @ 2012-10-01 22:36 UTC (permalink / raw)
To: kernel-janitors
On 30/09/12 17:33, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Introduce use of I2c_MSG_READ/WRITE/OP, for readability.
>
> A simplified version of the semantic patch that makes this change is as
> follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression a,b,c;
> identifier x;
> @@
>
> struct i2c_msg x > - {.addr = a, .buf = b, .len = c, .flags = I2C_M_RD}
> + I2C_MSG_READ(a,b,c)
> ;
>
> @@
> expression a,b,c;
> identifier x;
> @@
>
> struct i2c_msg x > - {.addr = a, .buf = b, .len = c, .flags = 0}
> + I2C_MSG_WRITE(a,b,c)
> ;
>
> @@
> expression a,b,c,d;
> identifier x;
> @@
>
> struct i2c_msg x =
> - {.addr = a, .buf = b, .len = c, .flags = d}
> + I2C_MSG_OP(a,b,c,d)
> ;
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Looks okay. One minor comment, which could be done as a separate patch
to keep this one as just the straight conversion.
~Ryan
> ---
> drivers/media/tuners/fc0011.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/tuners/fc0011.c b/drivers/media/tuners/fc0011.c
> index e488254..b0036d6 100644
> --- a/drivers/media/tuners/fc0011.c
> +++ b/drivers/media/tuners/fc0011.c
> @@ -80,8 +80,7 @@ struct fc0011_priv {
> static int fc0011_writereg(struct fc0011_priv *priv, u8 reg, u8 val)
> {
> u8 buf[2] = { reg, val };
> - struct i2c_msg msg = { .addr = priv->addr,
> - .flags = 0, .buf = buf, .len = 2 };
> + struct i2c_msg msg = I2C_MSG_WRITE(priv->addr, buf, 2);
sizeof(buf)
>
> if (i2c_transfer(priv->i2c, &msg, 1) != 1) {
> dev_err(&priv->i2c->dev,
> @@ -97,10 +96,8 @@ static int fc0011_readreg(struct fc0011_priv *priv, u8 reg, u8 *val)
> {
> u8 dummy;
> struct i2c_msg msg[2] = {
> - { .addr = priv->addr,
> - .flags = 0, .buf = ®, .len = 1 },
> - { .addr = priv->addr,
> - .flags = I2C_M_RD, .buf = val ? : &dummy, .len = 1 },
> + I2C_MSG_WRITE(priv->addr, ®, 1),
> + I2C_MSG_READ(priv->addr, val ? : &dummy, 1),
> };
>
> if (i2c_transfer(priv->i2c, msg, 2) != 2) {
>
^ permalink raw reply [flat|nested] 7+ messages in thread* question about drivers/gpu/drm/i915/dvo_ch7xxx.c
2012-10-01 22:36 ` Ryan Mallon
@ 2012-10-06 13:20 ` Julia Lawall
2012-10-07 20:45 ` Daniel Vetter
0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2012-10-06 13:20 UTC (permalink / raw)
To: Ryan Mallon; +Cc: daniel.vetter, dri-devel
Hello,
I am looking at introducing some macros for i2c_msg initialization, and
Ryan Mallon suggested that sometimes it could be useful to at the same
time replace explicit lengths with the size of the associated buffer. But
in some cases the sizes are not the same. An example is as follows, in
drivers/gpu/drm/i915/dvo_ch7xxx.c:
static bool ch7xxx_readb(struct intel_dvo_device *dvo, int addr, uint8_t
*ch)
{
struct ch7xxx_priv *ch7xxx = dvo->dev_priv;
struct i2c_adapter *adapter = dvo->i2c_bus;
u8 out_buf[2];
u8 in_buf[2];
struct i2c_msg msgs[] = {
{
.addr = dvo->slave_addr,
.flags = 0,
.len = 1,
.buf = out_buf,
},
{
.addr = dvo->slave_addr,
.flags = I2C_M_RD,
.len = 1,
.buf = in_buf,
}
};
out_buf[0] = addr;
out_buf[1] = 0;
if (i2c_transfer(adapter, msgs, 2) == 2) {
*ch = in_buf[0];
return true;
};
if (!ch7xxx->quiet) {
DRM_DEBUG_KMS("Unable to read register 0x%02x from %s:%02x.\n",
addr, adapter->name, dvo->slave_addr);
}
return false;
}
The buffers both have size 2, but only one byte is asked to be read or
written. Is there any need for the buffers to have size 2 in this case?
Unrelatedly, is it correct that ch has type uint8_t and out_buf and in_buf
have type u8?
julia
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: question about drivers/gpu/drm/i915/dvo_ch7xxx.c
2012-10-06 13:20 ` question about drivers/gpu/drm/i915/dvo_ch7xxx.c Julia Lawall
@ 2012-10-07 20:45 ` Daniel Vetter
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2012-10-07 20:45 UTC (permalink / raw)
To: Julia Lawall; +Cc: daniel.vetter, Ryan Mallon, dri-devel
On Sat, Oct 06, 2012 at 03:20:19PM +0200, Julia Lawall wrote:
> Hello,
>
> I am looking at introducing some macros for i2c_msg initialization,
> and Ryan Mallon suggested that sometimes it could be useful to at
> the same time replace explicit lengths with the size of the
> associated buffer. But in some cases the sizes are not the same.
> An example is as follows, in drivers/gpu/drm/i915/dvo_ch7xxx.c:
>
> static bool ch7xxx_readb(struct intel_dvo_device *dvo, int addr,
> uint8_t *ch)
> {
> struct ch7xxx_priv *ch7xxx = dvo->dev_priv;
> struct i2c_adapter *adapter = dvo->i2c_bus;
> u8 out_buf[2];
> u8 in_buf[2];
>
> struct i2c_msg msgs[] = {
> {
> .addr = dvo->slave_addr,
> .flags = 0,
> .len = 1,
> .buf = out_buf,
> },
> {
> .addr = dvo->slave_addr,
> .flags = I2C_M_RD,
> .len = 1,
> .buf = in_buf,
> }
> };
>
> out_buf[0] = addr;
> out_buf[1] = 0;
>
> if (i2c_transfer(adapter, msgs, 2) == 2) {
> *ch = in_buf[0];
> return true;
> };
>
> if (!ch7xxx->quiet) {
> DRM_DEBUG_KMS("Unable to read register 0x%02x from %s:%02x.\n",
> addr, adapter->name, dvo->slave_addr);
> }
> return false;
> }
>
> The buffers both have size 2, but only one byte is asked to be read
> or written. Is there any need for the buffers to have size 2 in
> this case?
Looks like the 2 byte buffer size is just copy&pasta from writeb. And
didn't find any other reson for it not being just 1 byte.
> Unrelatedly, is it correct that ch has type uint8_t and out_buf and
> in_buf have type u8?
drm/i915 is totally confused about the (u)int*_t vs (s|t)* types
unfortunately. I think nowadays we mostly stick to _t typedefs, but not
consistenly.
Yours, Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] drivers/media/tuners/fc0011.c: introduce macros for i2c_msg initialization
2012-09-30 7:33 ` [PATCH 3/3] drivers/media/tuners/fc0011.c: " Julia Lawall
2012-10-01 22:36 ` Ryan Mallon
@ 2012-10-02 5:31 ` Julia Lawall
1 sibling, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2012-10-02 5:31 UTC (permalink / raw)
To: kernel-janitors
Thanks. I'll integrate the sizeof(buf) issue and resend everything in the
proper manner. The one case where the name of the buffer could change
seems like a separate patch.
julia
On Tue, 2 Oct 2012, Ryan Mallon wrote:
> On 30/09/12 17:33, Julia Lawall wrote:
>> From: Julia Lawall <Julia.Lawall@lip6.fr>
>>
>> Introduce use of I2c_MSG_READ/WRITE/OP, for readability.
>>
>> A simplified version of the semantic patch that makes this change is as
>> follows: (http://coccinelle.lip6.fr/)
>>
>> // <smpl>
>> @@
>> expression a,b,c;
>> identifier x;
>> @@
>>
>> struct i2c_msg x >> - {.addr = a, .buf = b, .len = c, .flags = I2C_M_RD}
>> + I2C_MSG_READ(a,b,c)
>> ;
>>
>> @@
>> expression a,b,c;
>> identifier x;
>> @@
>>
>> struct i2c_msg x >> - {.addr = a, .buf = b, .len = c, .flags = 0}
>> + I2C_MSG_WRITE(a,b,c)
>> ;
>>
>> @@
>> expression a,b,c,d;
>> identifier x;
>> @@
>>
>> struct i2c_msg x >> - {.addr = a, .buf = b, .len = c, .flags = d}
>> + I2C_MSG_OP(a,b,c,d)
>> ;
>> // </smpl>
>>
>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Looks okay. One minor comment, which could be done as a separate patch
> to keep this one as just the straight conversion.
>
> ~Ryan
>
>> ---
>> drivers/media/tuners/fc0011.c | 9 +++------
>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/media/tuners/fc0011.c b/drivers/media/tuners/fc0011.c
>> index e488254..b0036d6 100644
>> --- a/drivers/media/tuners/fc0011.c
>> +++ b/drivers/media/tuners/fc0011.c
>> @@ -80,8 +80,7 @@ struct fc0011_priv {
>> static int fc0011_writereg(struct fc0011_priv *priv, u8 reg, u8 val)
>> {
>> u8 buf[2] = { reg, val };
>> - struct i2c_msg msg = { .addr = priv->addr,
>> - .flags = 0, .buf = buf, .len = 2 };
>> + struct i2c_msg msg = I2C_MSG_WRITE(priv->addr, buf, 2);
>
> sizeof(buf)
>
>>
>> if (i2c_transfer(priv->i2c, &msg, 1) != 1) {
>> dev_err(&priv->i2c->dev,
>> @@ -97,10 +96,8 @@ static int fc0011_readreg(struct fc0011_priv *priv, u8 reg, u8 *val)
>> {
>> u8 dummy;
>> struct i2c_msg msg[2] = {
>> - { .addr = priv->addr,
>> - .flags = 0, .buf = ®, .len = 1 },
>> - { .addr = priv->addr,
>> - .flags = I2C_M_RD, .buf = val ? : &dummy, .len = 1 },
>> + I2C_MSG_WRITE(priv->addr, ®, 1),
>> + I2C_MSG_READ(priv->addr, val ? : &dummy, 1),
>> };
>>
>> if (i2c_transfer(priv->i2c, msg, 2) != 2) {
>>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] introduce macros for i2c_msg initialization
2012-09-30 7:33 [PATCH 0/3] introduce macros for i2c_msg initialization Julia Lawall
2012-09-30 7:33 ` [PATCH 3/3] drivers/media/tuners/fc0011.c: " Julia Lawall
@ 2012-09-30 7:35 ` Julia Lawall
1 sibling, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2012-09-30 7:35 UTC (permalink / raw)
To: kernel-janitors
Oops, I didn't mean to send this to kernel janitors yet. Comments are
nevertheless welcome...
julia
On Sun, 30 Sep 2012, Julia Lawall wrote:
> This patch introduces some macros for describing how an i2c_msg is being
> initialized. There are three macros: I2C_MSG_READ, for a read message,
> I2C_MSG_WRITE, for a write message, and I2C_MSG_OP, for some other kind of
> message, which is expected to be very rarely used.
>
> i2c_msg initializations are updated using the following semantic patch:
>
> // <smpl>
> @r@
> field list[n] ds;
> type T;
> identifier i;
> @@
>
> struct i2c_msg {
> ds
> T i;
> ...
> };
>
> @@
> initializer list[r.n] is;
> expression a;
> identifier nm;
> identifier r.i;
> @@
>
> struct i2c_msg nm = {
> is,
> - a
> + .i = a
> ,...
> };
>
> @@
> initializer list[r.n] is;
> expression a;
> identifier nm;
> identifier r.i;
> @@
>
> struct i2c_msg nm[...] = { ..., {
> is,
> - a
> + .i = a
> ,...}, ...};
>
> @@
> initializer list[r.n] is;
> expression a;
> identifier nm;
> identifier r.i;
> @@
>
> struct i2c_msg nm[] = { ..., {
> is,
> - a
> + .i = a
> ,...}, ...};
>
> // --------------------------------------------------------------------
> // ensure everyone has all fields, pointer case first
>
> @rt@
> type T;
> identifier i;
> @@
>
> struct i2c_msg {
> ...
> T *i;
> ...
> };
>
> @t1@
> expression e;
> identifier nm,rt.i;
> position p;
> @@
>
> struct i2c_msg nm = {@p
> .i = e,
> };
>
> @@
> identifier nm,rt.i;
> position p!= t1.p;
> @@
>
> struct i2c_msg nm = {@p
> + .i = NULL,
> ...
> };
>
> @t2@
> expression e;
> identifier nm,rt.i;
> position p;
> @@
>
> struct i2c_msg nm[] = { ..., {@p
> .i = e,
> }, ...};
>
> @@
> identifier nm,rt.i;
> position p!= t2.p;
> @@
>
> struct i2c_msg nm[] = { ..., {@p
> + .i = NULL,
> ...
> }, ...};
>
> @t3@
> expression e;
> identifier nm,rt.i;
> position p;
> @@
>
> struct i2c_msg nm[...] = { ..., {@p
> .i = e,
> }, ...};
>
> @@
> identifier nm,rt.i;
> position p!= t3.p;
> @@
>
> struct i2c_msg nm[...] = { ..., {@p
> + .i = NULL,
> ...
> }, ...};
>
> // ---------------------------------
>
> @f1@
> expression e;
> identifier nm,r.i;
> position p;
> @@
>
> struct i2c_msg nm = {@p
> .i = e,
> };
>
> @@
> identifier nm,r.i;
> position p!= f1.p;
> @@
>
> struct i2c_msg nm = {@p
> + .i = 0,
> ...
> };
>
> @f2@
> expression e;
> identifier nm,r.i;
> position p;
> @@
>
> struct i2c_msg nm[] = { ..., {@p
> .i = e,
> }, ...};
>
> @@
> identifier nm,r.i;
> position p!= f2.p;
> @@
>
> struct i2c_msg nm[] = { ..., {@p
> + .i = 0,
> ...
> }, ...};
>
> @f3@
> expression e;
> identifier nm,r.i;
> position p;
> @@
>
> struct i2c_msg nm[...] = { ..., {@p
> .i = e,
> }, ...};
>
> @@
> identifier nm,r.i;
> position p!= f3.p;
> @@
>
> struct i2c_msg nm[...] = { ..., {@p
> + .i = 0,
> ...
> }, ...};
>
> // --------------------------------------------------------------------
>
> @@
> expression a,b,c;
> identifier x;
> @@
>
> struct i2c_msg x > - {.addr = a, .buf = b, .len = c, .flags = I2C_M_RD}
> + I2C_MSG_READ(a,b,c)
> ;
>
> @@
> expression a,b,c;
> identifier x;
> @@
>
> struct i2c_msg x > - {.addr = a, .buf = b, .len = c, .flags = 0}
> + I2C_MSG_WRITE(a,b,c)
> ;
>
> // has to come before the next rule, which matcher fewer fields
> @@
> expression a,b,c,d;
> identifier x;
> @@
>
> struct i2c_msg x > - {.addr = a, .buf = b, .len = c, .flags = d}
> + I2C_MSG_OP(a,b,c,d)
> ;
>
> // --------------------------------------------------------------------
>
> @@
> expression a,b,c;
> identifier x;
> @@
>
> struct i2c_msg x[] = {...,
> - {.addr = a, .buf = b, .len = c, .flags = I2C_M_RD}
> + I2C_MSG_READ(a,b,c)
> ,...};
>
> @@
> expression a,b,c;
> identifier x;
> @@
>
> struct i2c_msg x[] = {...,
> - {.addr = a, .buf = b, .len = c, .flags = 0}
> + I2C_MSG_WRITE(a,b,c)
> ,...};
>
> @@
> expression a,b,c,d;
> identifier x;
> @@
>
> struct i2c_msg x[] = {...,
> - {.addr = a, .buf = b, .len = c, .flags = d}
> + I2C_MSG_OP(a,b,c,d)
> ,...};
>
> // --------------------------------------------------------------------
>
> @@
> expression a,b,c;
> identifier x;
> @@
>
> struct i2c_msg x[...] = {...,
> - {.addr = a, .buf = b, .len = c, .flags = I2C_M_RD}
> + I2C_MSG_READ(a,b,c)
> ,...};
>
> @@
> expression a,b,c;
> identifier x;
> @@
>
> struct i2c_msg x[...] = {...,
> - {.addr = a, .buf = b, .len = c, .flags = 0}
> + I2C_MSG_WRITE(a,b,c)
> ,...};
>
> @@
> expression a,b,c,d;
> identifier x;
> @@
>
> struct i2c_msg x[...] = {...,
> - {.addr = a, .buf = b, .len = c, .flags = d}
> + I2C_MSG_OP(a,b,c,d)
> ,...};
>
> // --------------------------------------------------------------------
> // got everything?
>
> @check1@
> identifier nm;
> position p;
> @@
>
> struct i2c_msg nm@p = {...};
>
> @script:python@
> p << check1.p;
> @@
>
> cocci.print_main("",p)
>
> @check2@
> identifier nm;
> position p;
> @@
>
> struct i2c_msg nm@p [] = {...,{...},...};
>
> @script:python@
> p << check2.p;
> @@
>
> cocci.print_main("",p)
>
> @check3@
> identifier nm;
> position p;
> @@
>
> struct i2c_msg nm@p [...] = {...,{...},...};
>
> @script:python@
> p << check3.p;
> @@
>
> cocci.print_main("",p)
> // </smpl>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-10-07 20:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-30 7:33 [PATCH 0/3] introduce macros for i2c_msg initialization Julia Lawall
2012-09-30 7:33 ` [PATCH 3/3] drivers/media/tuners/fc0011.c: " Julia Lawall
2012-10-01 22:36 ` Ryan Mallon
2012-10-06 13:20 ` question about drivers/gpu/drm/i915/dvo_ch7xxx.c Julia Lawall
2012-10-07 20:45 ` Daniel Vetter
2012-10-02 5:31 ` [PATCH 3/3] drivers/media/tuners/fc0011.c: introduce macros for i2c_msg initialization Julia Lawall
2012-09-30 7:35 ` [PATCH 0/3] " Julia Lawall
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.