[PATCH 2/13] drivers/media/tuners/mxl5007t.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Introduce use of I2c_MSG_READ/WRITE/OP, for readability.

In each case, a length expressed as an explicit constant is also
re-expressed as the size of the buffer, when this is possible.

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.law...@lip6.fr

---
 drivers/media/tuners/mxl5007t.c |   16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/media/tuners/mxl5007t.c b/drivers/media/tuners/mxl5007t.c
index 69e453e..c0c28be 100644
--- a/drivers/media/tuners/mxl5007t.c
+++ b/drivers/media/tuners/mxl5007t.c
@@ -464,8 +464,8 @@ reg_pair_t *mxl5007t_calc_rf_tune_regs(struct 
mxl5007t_state *state,
 static int mxl5007t_write_reg(struct mxl5007t_state *state, u8 reg, u8 val)
 {
u8 buf[] = { reg, val };
-   struct i2c_msg msg = { .addr = state-i2c_props.addr, .flags = 0,
-  .buf = buf, .len = 2 };
+   struct i2c_msg msg = I2C_MSG_WRITE(state-i2c_props.addr, buf,
+  sizeof(buf));
int ret;
 
ret = i2c_transfer(state-i2c_props.adap, msg, 1);
@@ -494,10 +494,8 @@ static int mxl5007t_read_reg(struct mxl5007t_state *state, 
u8 reg, u8 *val)
 {
u8 buf[2] = { 0xfb, reg };
struct i2c_msg msg[] = {
-   { .addr = state-i2c_props.addr, .flags = 0,
- .buf = buf, .len = 2 },
-   { .addr = state-i2c_props.addr, .flags = I2C_M_RD,
- .buf = val, .len = 1 },
+   I2C_MSG_WRITE(state-i2c_props.addr, buf, sizeof(buf)),
+   I2C_MSG_READ(state-i2c_props.addr, val, 1),
};
int ret;
 
@@ -512,10 +510,8 @@ static int mxl5007t_read_reg(struct mxl5007t_state *state, 
u8 reg, u8 *val)
 static int mxl5007t_soft_reset(struct mxl5007t_state *state)
 {
u8 d = 0xff;
-   struct i2c_msg msg = {
-   .addr = state-i2c_props.addr, .flags = 0,
-   .buf = d, .len = 1
-   };
+   struct i2c_msg msg = I2C_MSG_WRITE(state-i2c_props.addr, d,
+  sizeof(d));
int ret = i2c_transfer(state-i2c_props.adap, msg, 1);
 
if (ret != 1) {

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/13] drivers/media/tuners/e4000.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Introduce use of I2c_MSG_READ/WRITE/OP, for readability.

In the second i2c_msg structure, a length expressed as an explicit constant
is also re-expressed as the size of the buffer, reg.

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.law...@lip6.fr

---
 drivers/media/tuners/e4000.c |   20 +++-
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 1b33ed3..8f182fc 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -26,12 +26,7 @@ static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 
*val, int len)
int ret;
u8 buf[1 + len];
struct i2c_msg msg[1] = {
-   {
-   .addr = priv-cfg-i2c_addr,
-   .flags = 0,
-   .len = sizeof(buf),
-   .buf = buf,
-   }
+   I2C_MSG_WRITE(priv-cfg-i2c_addr, buf, sizeof(buf))
};
 
buf[0] = reg;
@@ -54,17 +49,8 @@ static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 
*val, int len)
int ret;
u8 buf[len];
struct i2c_msg msg[2] = {
-   {
-   .addr = priv-cfg-i2c_addr,
-   .flags = 0,
-   .len = 1,
-   .buf = reg,
-   }, {
-   .addr = priv-cfg-i2c_addr,
-   .flags = I2C_M_RD,
-   .len = sizeof(buf),
-   .buf = buf,
-   }
+   I2C_MSG_WRITE(priv-cfg-i2c_addr, reg, sizeof(reg)),
+   I2C_MSG_READ(priv-cfg-i2c_addr, buf, sizeof(buf))
};
 
ret = i2c_transfer(priv-i2c, msg, 2);

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/13] drivers/media/tuners/e4000.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall

On Sun, 7 Oct 2012, walter harms wrote:




Am 07.10.2012 17:38, schrieb Julia Lawall:

From: Julia Lawall julia.law...@lip6.fr

Introduce use of I2c_MSG_READ/WRITE/OP, for readability.

In the second i2c_msg structure, a length expressed as an explicit constant
is also re-expressed as the size of the buffer, reg.

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.law...@lip6.fr

---
 drivers/media/tuners/e4000.c |   20 +++-
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 1b33ed3..8f182fc 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -26,12 +26,7 @@ static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 
*val, int len)
int ret;
u8 buf[1 + len];
struct i2c_msg msg[1] = {
-   {
-   .addr = priv-cfg-i2c_addr,
-   .flags = 0,
-   .len = sizeof(buf),
-   .buf = buf,
-   }
+   I2C_MSG_WRITE(priv-cfg-i2c_addr, buf, sizeof(buf))
};



Any reason why struct i2c_msg is an array ?


I assumed that it looked more harmonious with the other uses of 
i2c_transfer, which takes as arguments an array and the number of 
elements.


But there are some files that instead use i2c_transfer(priv-i2c, msg, 1).
I can change them all to do that if that is preferred.  But maybe I 
will wait a little bit to see if there are other issues to address at 
the same time.


thanks,
julia



re,
wh


buf[0] = reg;
@@ -54,17 +49,8 @@ static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 
*val, int len)
int ret;
u8 buf[len];
struct i2c_msg msg[2] = {
-   {
-   .addr = priv-cfg-i2c_addr,
-   .flags = 0,
-   .len = 1,
-   .buf = reg,
-   }, {
-   .addr = priv-cfg-i2c_addr,
-   .flags = I2C_M_RD,
-   .len = sizeof(buf),
-   .buf = buf,
-   }
+   I2C_MSG_WRITE(priv-cfg-i2c_addr, reg, sizeof(reg)),
+   I2C_MSG_READ(priv-cfg-i2c_addr, buf, sizeof(buf))
};

ret = i2c_transfer(priv-i2c, msg, 2);

--
To unsubscribe from this list: send the line unsubscribe kernel-janitors in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
To unsubscribe from this list: send the line unsubscribe kernel-janitors in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 9/13] drivers/media/tuners/fc0011.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall

On Sun, 7 Oct 2012, walter harms wrote:




Am 07.10.2012 17:38, schrieb Julia Lawall:

From: Julia Lawall julia.law...@lip6.fr

Introduce use of I2c_MSG_READ/WRITE/OP, for readability.

A length expressed as an explicit constant is also re-expressed as the size
of the buffer in each case.

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.law...@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..5dbba98 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, 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 = reg, .len = 1 },
-   { .addr = priv-addr,
- .flags = I2C_M_RD, .buf = val ? : dummy, .len = 1 },
+   I2C_MSG_WRITE(priv-addr, reg, sizeof(reg)),
+   I2C_MSG_READ(priv-addr, val ? : dummy, sizeof(dummy)),
};



This dummy looks strange, can it be that this is used uninitialised ?


I'm not sure to understand the question.  The read, when it happens in 
i2c_transfer will initialize dummy.  On the other hand, I don't know what 
i2c_transfer does when the buffer is NULL and the size is 1.  It does not 
look very elegant at least.


julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/13] drivers/media/tuners/e4000.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall

On Sun, 7 Oct 2012, walter harms wrote:




Am 07.10.2012 18:44, schrieb Julia Lawall:

On Sun, 7 Oct 2012, walter harms wrote:




Am 07.10.2012 17:38, schrieb Julia Lawall:

From: Julia Lawall julia.law...@lip6.fr

Introduce use of I2c_MSG_READ/WRITE/OP, for readability.

In the second i2c_msg structure, a length expressed as an explicit
constant
is also re-expressed as the size of the buffer, reg.

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.law...@lip6.fr

---
 drivers/media/tuners/e4000.c |   20 +++-
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 1b33ed3..8f182fc 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -26,12 +26,7 @@ static int e4000_wr_regs(struct e4000_priv *priv,
u8 reg, u8 *val, int len)
 int ret;
 u8 buf[1 + len];
 struct i2c_msg msg[1] = {
-{
-.addr = priv-cfg-i2c_addr,
-.flags = 0,
-.len = sizeof(buf),
-.buf = buf,
-}
+I2C_MSG_WRITE(priv-cfg-i2c_addr, buf, sizeof(buf))
 };



Any reason why struct i2c_msg is an array ?


I assumed that it looked more harmonious with the other uses of
i2c_transfer, which takes as arguments an array and the number of elements.

But there are some files that instead use i2c_transfer(priv-i2c, msg, 1).
I can change them all to do that if that is preferred.  But maybe I will
wait a little bit to see if there are other issues to address at the
same time.

thanks,
julia



Hi Julia,
please be aware i am not the maintainer only a distant watcher :)

do you really thing that a macro is appropriate here ? I feel uneasy about it
but i can not offer an other solution.


Some people thought that it would be nice to have the macros rather than 
the inlined field initializations, especially since there is no flag for 
write.  A separate question is whether an array of one element is useful, 
or whether one should systematically use  on a simple variable of the 
structure type.  I'm open to suggestions about either point.


julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/13] drivers/media/tuners/e4000.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall

Some people thought that it would be nice to have the macros rather than
the inlined field initializations, especially since there is no flag for
write.  A separate question is whether an array of one element is useful,
or whether one should systematically use  on a simple variable of the
structure type.  I'm open to suggestions about either point.


I think the macro naming is not great.

Maybe add DEFINE_/DECLARE_/_INIT or something other than an action
name type to the macro names.


DEFINE and DECLARE usually have a declared variable as an argument, which 
is not the case here.


These macros are like the macros PCI_DEVICE and PCI_DEVICE_CLASS.

Are READ and WRITE the action names?  They are really the important 
information in this case.



I think the consistency is better if all the references are done
as arrays, even for single entry arrays.


Is it worth creating arrays where msg is used?  Or would it be better to 
leave that aspect as it is?


julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/13] drivers/media/tuners/e4000.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall

On Sun, 7 Oct 2012, Joe Perches wrote:


On Sun, 2012-10-07 at 20:56 +0200, Julia Lawall wrote:

Some people thought that it would be nice to have the macros rather than
the inlined field initializations, especially since there is no flag for
write.  A separate question is whether an array of one element is useful,
or whether one should systematically use  on a simple variable of the
structure type.  I'm open to suggestions about either point.


I think the macro naming is not great.

Maybe add DEFINE_/DECLARE_/_INIT or something other than an action
name type to the macro names.


DEFINE and DECLARE usually have a declared variable as an argument, which
is not the case here.

These macros are like the macros PCI_DEVICE and PCI_DEVICE_CLASS.


I understand that.


Are READ and WRITE the action names?  They are really the important
information in this case.


Yes, most (all?) uses of _READ and _WRITE macros actually
perform some I/O.


I2C_MSG_READ_DATA?
I2C_MSG_READ_INFO?
I2C_MSG_READ_INIT?
I2C_MSG_PREPARE_READ?

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/13] drivers/media/tuners/e4000.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall

On Sun, 7 Oct 2012, Joe Perches wrote:


On Sun, 2012-10-07 at 23:43 +0200, Julia Lawall wrote:

On Sun, 7 Oct 2012, Joe Perches wrote:

Are READ and WRITE the action names?  They are really the important
information in this case.


Yes, most (all?) uses of _READ and _WRITE macros actually
perform some I/O.


I2C_MSG_READ_DATA?
I2C_MSG_READ_INFO?
I2C_MSG_READ_INIT?
I2C_MSG_PREPARE_READ?


Dunno, naming is hard.  Maybe:

I2C_INPUT_MSG
I2C_OUTPUT_MSG
I2C_OP_MSG


The current terminology, however, is READ, not INPUT (.flags = I2C_M_RD).

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/13] drivers/media/tuners/qt1010.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall

On Mon, 8 Oct 2012, Ryan Mallon wrote:


On 08/10/12 02:38, Julia Lawall wrote:

From: Julia Lawall julia.law...@lip6.fr

Introduce use of I2c_MSG_READ/WRITE/OP, for readability.

A length expressed as an explicit constant is also re-expressed as the size
of the buffer, when this is possible.

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.law...@lip6.fr

---
 drivers/media/tuners/qt1010.c |   10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/media/tuners/qt1010.c b/drivers/media/tuners/qt1010.c
index bc419f8..37ff254 100644
--- a/drivers/media/tuners/qt1010.c
+++ b/drivers/media/tuners/qt1010.c
@@ -25,10 +25,8 @@
 static int qt1010_readreg(struct qt1010_priv *priv, u8 reg, u8 *val)
 {
struct i2c_msg msg[2] = {
-   { .addr = priv-cfg-i2c_address,
- .flags = 0, .buf = reg, .len = 1 },
-   { .addr = priv-cfg-i2c_address,
- .flags = I2C_M_RD, .buf = val, .len = 1 },
+   I2C_MSG_WRITE(priv-cfg-i2c_address, reg, sizeof(reg)),
+   I2C_MSG_READ(priv-cfg-i2c_address, val, 1),


This is a bit inconsistent. For single length values we should either
consistently use sizeof(val) or 1. This has both.


val is a pointer.  It does not have size 1.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/13] drivers/media/tuners: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall

As far as I can see, the comments on this are:

b[0] should be just b
There should be a newline before the elements of a multi-element array
Some one-element array buffers should just be variables
sizeof(val) should be used

I will redo the patches to include the first two, but not the others.

I will send another set of patches for the third one.  It seems like the 
conclusion is that the buffer should always be a variable if it can, but 
the message should always be an array for uniformity in the call to 
i2c_transfer.


I believe that the fourth one is not correct.  The variable in question is 
a pointer, so sizeof would give the wrong result.  If it is preferred, I 
could not use sizeof for the other structure in the same code, but it 
seems just a little safer to use it.


thanks,
julia


On Mon, 8 Oct 2012, Ryan Mallon wrote:


On 08/10/12 02:38, Julia Lawall wrote:

From: Julia Lawall julia.law...@lip6.fr

Introduce use of I2c_MSG_READ/WRITE/OP, for readability.

A length expressed as an explicit constant is also re-expressed as the size
of the buffer, when this is possible.

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.law...@lip6.fr

---
 drivers/media/tuners/fc0012.c   |8 +++-
 drivers/media/tuners/fc0013.c   |8 +++-
 drivers/media/tuners/mc44s803.c |8 +++-
 drivers/media/tuners/mt2060.c   |   13 +
 drivers/media/tuners/mt2063.c   |   23 ++-
 drivers/media/tuners/mt2131.c   |   13 +
 drivers/media/tuners/mt2266.c   |   13 +
 drivers/media/tuners/mxl5005s.c |8 
 drivers/media/tuners/tda827x.c  |   29 +++--
 drivers/media/tuners/tuner-i2c.h|   12 
 drivers/media/tuners/tuner-simple.c |5 +
 drivers/media/tuners/xc4000.c   |9 +++--
 drivers/media/tuners/xc5000.c   |9 +++--
 13 files changed, 56 insertions(+), 102 deletions(-)

diff --git a/drivers/media/tuners/fc0012.c b/drivers/media/tuners/fc0012.c
index 308135a..01dac7e 100644
--- a/drivers/media/tuners/fc0012.c
+++ b/drivers/media/tuners/fc0012.c
@@ -24,9 +24,7 @@
 static int fc0012_writereg(struct fc0012_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, sizeof(buf));

if (i2c_transfer(priv-i2c, msg, 1) != 1) {
err(I2C write reg failed, reg: %02x, val: %02x, reg, val);
@@ -38,8 +36,8 @@ static int fc0012_writereg(struct fc0012_priv *priv, u8 reg, 
u8 val)
 static int fc0012_readreg(struct fc0012_priv *priv, u8 reg, u8 *val)
 {
struct i2c_msg msg[2] = {
-   { .addr = priv-addr, .flags = 0, .buf = reg, .len = 1 },
-   { .addr = priv-addr, .flags = I2C_M_RD, .buf = val, .len = 1 },
+   I2C_MSG_WRITE(priv-addr, reg, sizeof(reg)),
+   I2C_MSG_READ(priv-addr, val, 1),
};

if (i2c_transfer(priv-i2c, msg, 2) != 2) {
diff --git a/drivers/media/tuners/fc0013.c b/drivers/media/tuners/fc0013.c
index bd8f0f1..174f0b0 100644
--- a/drivers/media/tuners/fc0013.c
+++ b/drivers/media/tuners/fc0013.c
@@ -27,9 +27,7 @@
 static int fc0013_writereg(struct fc0013_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, sizeof(buf));

if (i2c_transfer(priv-i2c, msg, 1) != 1) {
err(I2C write reg failed, reg: %02x, val: %02x, reg, val);
@@ -41,8 +39,8 @@ static int fc0013_writereg(struct fc0013_priv *priv, u8 reg, 
u8 val)
 static int fc0013_readreg(struct fc0013_priv *priv, u8 reg, u8 *val)
 {
struct i2c_msg msg[2] = {
-   { .addr = priv-addr, .flags = 0, .buf = reg, .len = 1 },
-   { .addr = priv-addr, .flags = I2C_M_RD, .buf = val, .len = 1 },
+   I2C_MSG_WRITE(priv-addr, reg, sizeof(reg)),
+   I2C_MSG_READ(priv-addr, val, 1),
};

if (i2c_transfer(priv-i2c, msg, 2) != 2) {
diff --git a/drivers/media/tuners/mc44s803.c b/drivers/media/tuners/mc44s803.c
index f1b7640..df47e03 100644
--- a/drivers/media/tuners/mc44s803.c
+++ b/drivers/media/tuners/mc44s803.c
@@ -37,9 +37,8 @@
 static int mc44s803_writereg(struct mc44s803_priv

Re: [PATCH 12/13] drivers/media/tuners/max2165.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall

On Mon, 8 Oct 2012, Ryan Mallon wrote:


On 08/10/12 02:38, Julia Lawall wrote:

From: Julia Lawall julia.law...@lip6.fr

Introduce use of I2c_MSG_READ/WRITE/OP, for readability.

A length expressed as an explicit constant is also re-expressed as the size
of the buffer, when this is possible.

The second case is simplified to use simple variables rather than arrays.
The variable b0 is dropped completely, and the variable reg that it
contains is used instead.  The variable b1 is replaced by a u8-typed
variable named buf (the name used earlier in the file).  The uses of b1 are
then adjusted accordingly.

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.law...@lip6.fr

---

 drivers/media/tuners/max2165.c |   13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/media/tuners/max2165.c b/drivers/media/tuners/max2165.c
index ba84936..6638617 100644
--- a/drivers/media/tuners/max2165.c
+++ b/drivers/media/tuners/max2165.c
@@ -47,7 +47,7 @@ static int max2165_write_reg(struct max2165_priv *priv, u8 
reg, u8 data)
 {
int ret;
u8 buf[] = { reg, data };
-   struct i2c_msg msg = { .flags = 0, .buf = buf, .len = 2 };
+   struct i2c_msg msg = I2C_MSG_WRITE(0, buf, sizeof(buf));

msg.addr = priv-config-i2c_address;

@@ -68,11 +68,10 @@ static int max2165_read_reg(struct max2165_priv *priv, u8 
reg, u8 *p_data)
int ret;
u8 dev_addr = priv-config-i2c_address;

-   u8 b0[] = { reg };
-   u8 b1[] = { 0 };
+   u8 buf;
struct i2c_msg msg[] = {
-   { .addr = dev_addr, .flags = 0, .buf = b0, .len = 1 },
-   { .addr = dev_addr, .flags = I2C_M_RD, .buf = b1, .len = 1 },
+   I2C_MSG_WRITE(dev_addr, reg, sizeof(reg)),
+   I2C_MSG_READ(dev_addr, buf, sizeof(buf)),
};


Not sure if the array changes should be done here or as a separate
patch. Some of the other patches also have cases where single index
arrays (both buffers and messages) could be converted. Should either
convert all or none of them. I think its probably best to do as a
separate series on top of this though.


OK, I will do it that way.

thanks,
julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/13] drivers/media/tuners/qt1010.c: use macros for i2c_msg initialization

2012-10-07 Thread Julia Lawall

Sorry, I mean either:

I2C_MSG_WRITE(priv-cfg-i2c_address, reg, sizeof(reg)),
I2C_MSG_READ(priv-cfg-i2c_address, val, sizeof(*val)),


Of course.  Sorry for not having seen that.  I can do that.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/13] drivers/media/tuners/e4000.c: use macros for i2c_msg initialization

2012-10-08 Thread Julia Lawall
I found only 15 uses of I2C_MSG_OP, out of 653 uses of one of the three
macros.  Since I2C_MSG_OP has the complete set of flags, I think it should
be OK?

One of the uses, in drivers/media/i2c/adv7604.c, is as follows:

   struct i2c_msg msg[2] = { { client-addr, 0, 1, msgbuf0 },
 { client-addr, 0 | I2C_M_RD, len, msgbuf1 }

I'm not sure what was intended, but I guess the second structure is
supposed to only do a read?

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/13] drivers/media/tuners/mxl5007t.c: use macros for i2c_msg initialization

2012-10-09 Thread Julia Lawall
On Tue, 9 Oct 2012, Jean Delvare wrote:

 Hi Julia,

 On Sun,  7 Oct 2012 17:38:33 +0200, Julia Lawall wrote:
  From: Julia Lawall julia.law...@lip6.fr
 
  Introduce use of I2c_MSG_READ/WRITE/OP, for readability.

 Next time you send this patch set, please Cc me on every post so that I
 don't have to hunt for them on lkml.org.

OK.

  In each case, a length expressed as an explicit constant is also
  re-expressed as the size of the buffer, when this is possible.

 This is conceptually wrong, please don't do that. It is perfectly valid
 to use a buffer which is larger than the message being written or read.
 When exchanging multiple messages, it is actually quite common to
 declare only 2 buffers and reuse them:

   char reg;
   char val[2];

   struct i2c_msg msg[2] = {
   { .addr = addr, .flags = 0, .buf = reg, .len = 1 },
   { .addr = addr, .flags = I2C_M_RD, .buf = val, .len = 1 },
   };

   reg = 0x04;
   i2c_transfer(i2c_adap, msg, 2);
   /* Do stuff with val */

   reg = 0x06;
   msg[1].len = 2;
   i2c_transfer(i2c_adap, msg, 2);
   /* Do stuff with val */

 Your conversion would read 2 bytes from register 0x04 instead of 1 in
 the example above.

 I am not opposed to the idea of i2c_msg initialization helper macros,
 but please don't mix that with actual code changes which could have bad
 side effects.

I at least tried to check in every case that the result of sizeof is the
same as the value that is present.  But I can leave the constants as is,
if that seems better.

Thanks for the feedback.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/13] drivers/media/tuners/qt1010.c: use macros for i2c_msg initialization

2012-10-09 Thread Julia Lawall
On Tue, 9 Oct 2012, Jean Delvare wrote:

 Hi Julia,

 On Mon, 8 Oct 2012 07:24:11 +0200 (CEST), Julia Lawall wrote:
   Sorry, I mean either:
  
 I2C_MSG_WRITE(priv-cfg-i2c_address, reg, sizeof(reg)),
 I2C_MSG_READ(priv-cfg-i2c_address, val, sizeof(*val)),
 
  Of course.  Sorry for not having seen that.  I can do that.

 Eek, no, you can't, not in the general case at least. sizeof(*val) will
 return the size of the _first_ element of the destination buffer, which
 has nothing to do with the length of that buffer (which in turn might
 be rightfully longer than the read length for this specific message.)

I was actually only going to do it when the size was 1 and the type was
u8 *.  But your other email suggests that converting to sizeof is just not
a good idea at all.  So I will drop that part of the rule.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/11] introduce macros for i2c_msg initialization

2012-10-09 Thread Julia Lawall
On Tue, 9 Oct 2012, Jean Delvare wrote:

 Hi Julia,

 On Sun,  7 Oct 2012 17:38:30 +0200, Julia Lawall wrote:
  This patch set 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.

 Some other kind of message is actually messages which need extra
 flags. They are still read or write messages.

I agree.  We could also have a read with extra options macro and a write
with extra options macro.  That would give four macros, which is not too
much more than three.

 OK, I've read the whole series now and grepped the kernel tree so I
 have a better overview. There are a lot more occurrences than what you
 converted. I presume the conversions were just an example and you leave
 the rest up to the relevant maintainers (e.g. me) if they are
 interested?

I would be happy to do the rest, or at least to do more.  I just didn't
want to do 600+ cases before knowing how others felt about the various
changes.  Actually, now that we seem to have decided to make fewer changes
at once, I could probably work more quickly.  So far, I have been
comparing the results after running cpp, as well as checking that the
sizeof transformation is correct, which is a bit slow.

 Given the huge number of affected drivers (a quick grep suggests 230
 drivers and more than 300 occurrences), we'd better think twice before
 going on as it will be intrusive and hard to change afterward.

 So my first question will be: what is your goal with this change? Are
 you only trying to save a few lines of source code? Or do you expect to
 actually fix/prevent bugs by introducing these macros? Or something
 else?

The main goal just seems to be to provide something that is more readable.

 I admit I am not completely convinced by the benefit at the moment. A
 number of these drivers should be using i2c_smbus_*() functions instead
 of i2c_transfer() for improved compatibility, or i2c_master_send/recv()
 for single message transfers (383 occurrences!), so making
 i2c_transfer() easier to use isn't at the top of my priority list. And
 I see the extra work for the pre-processor, so we need a good reason
 for doing that.

OK, if it doesn't seem like a good idea, it is no problem to drop the idea
completely.  It does seem a bit nicer to have writing indicated as WRITE
rather than as 0, but that might not be a big enough benefit to justify
making changes.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/13] drivers/media/tuners/e4000.c: use macros for i2c_msg initialization

2012-10-11 Thread Julia Lawall
I found 6 cases where there are more than 2 messages in the array.  I
didn't check how many cases where there are two messages but there is
something other than one read and one write.

Perhaps a reasonable option would be to use

I2C_MSG_READ
I2C_MSG_WRITE
I2C_MSG_READ_OP
I2C_MSG_WRITE_OP

The last two are for the few cases where more flags are specified.  As
compared to the original proposal of I2C_MSG_OP, these keep the READ or
WRITE idea in the macro name.  The additional argument to the OP macros
would be or'd with the read or write (nothing to do in this case) flags as
appropriate.

Mauro proposed INIT_I2C_READ_SUBADDR for the very common case where a
message array has one read and one write.  I think that putting one
I2C_MSG_READ and one I2C_MSG_WRITE in this case is readable enough, and
avoids the need to do something special for the cases that don't match the
expectations of INIT_I2C_READ_SUBADDR.

I propose not to do anything for the moment either for sizes or for
message or buffer arrays that contain only one element.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/11] introduce macros for i2c_msg initialization

2012-10-22 Thread Julia Lawall
I have been looking at this again, with the macros

#define I2C_MSG_OP(_addr, _buf, _len, _flags) \
{ .addr = _addr, .buf = _buf, .len = _len, .flags = _flags }

#define I2C_MSG_WRITE(addr, buf, len) \
I2C_MSG_OP(addr, buf, len, 0)
#define I2C_MSG_READ(addr, buf, len) \
I2C_MSG_OP(addr, buf, len, I2C_M_RD)
#define I2C_MSG_WRITE_OP(addr, buf, len, op) \
I2C_MSG_OP(addr, buf, len, 0 | op)
#define I2C_MSG_READ_OP(addr, buf, len, op) \
I2C_MSG_OP(addr, buf, len, I2C_M_RD | op)

and the tuners files as a random first example.  This time I haven't made
any adjustments for arrays of size 1.

The following file is a bit unfortunate, because a single structure is
mostly used for writing, but sometimes used for reading, in the function
tda827xa_set_params.  That is, there are explicit assignments to
msg.flags.

drivers/media/tuners/tda827x.c

Currently, this is done in 8 files across the entire kernel.  Would it be
a problem to use a READ or WRITE macro to initialize such a structure,
give that the type is going to change?  Maybe the I2C_MSG_OP macro could
be used, with an explicit flag argument?

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] trivial: adjust code alignment

2013-08-05 Thread Julia Lawall

On Mon, 5 Aug 2013, walter harms wrote:


Hello Julia,

IMHO keep the patch as it is.
It does not change any code that is good.
Suspicious code that comes up here can be addressed
in a separate patch.


OK, thanks!

julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] trivial: adjust code alignment

2013-08-05 Thread Julia Lawall

On Mon, 5 Aug 2013, Dan Carpenter wrote:


On Mon, Aug 05, 2013 at 04:47:39PM +0200, Julia Lawall wrote:

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index e8a1ce2..4a5a5dc 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -1369,8 +1369,8 @@ static int ov7670_s_exp(struct v4l2_subdev *sd, int value)
unsigned char com1, com8, aech, aechh;

ret = ov7670_read(sd, REG_COM1, com1) +
-   ov7670_read(sd, REG_COM8, com8);
-   ov7670_read(sd, REG_AECHH, aechh);
+   ov7670_read(sd, REG_COM8, com8);
+   ov7670_read(sd, REG_AECHH, aechh);
if (ret)
return ret;



The new indenting isn't correct here and anyway the intent was to
combine all the error codes together and return them as an error
code jumble.  I'm not a fan of error code jumbles, probably the
right thing is to check each function call or, barring that, to
return -EIO.


Oops, thanks for spotting that.  I'm not sure whether it is safe to abort 
these calls as soon as the first one fails, but perhaps I could introduce 
some more variables, and test them all afterwards.


What should I do with the big patch?  Resend it with this cut out?  Or, 
considering that I might have overlooked something else, send 90 some 
little ones?


thanks,
julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 26/29] drivers/media/platform/coda.c: simplify use of devm_ioremap_resource

2013-08-14 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Remove unneeded error handling on the result of a call to
platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  e = devm_ioremap_resource(e1, res);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/platform/coda.c |5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 66db0df..1a2192f 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -3122,11 +3122,6 @@ static int coda_probe(struct platform_device *pdev)
 
/* Get  memory for physical registers */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (res == NULL) {
-   dev_err(pdev-dev, failed to get memory region resource\n);
-   return -ENOENT;
-   }
-
dev-regs_base = devm_ioremap_resource(pdev-dev, res);
if (IS_ERR(dev-regs_base))
return PTR_ERR(dev-regs_base);

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/29] marvell-ccic/mmp-driver.c: simplify use of devm_ioremap_resource

2013-08-14 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Remove unneeded error handling on the result of a call to
platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  e = devm_ioremap_resource(e1, res);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/platform/marvell-ccic/mmp-driver.c |8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c 
b/drivers/media/platform/marvell-ccic/mmp-driver.c
index f06daa4..b5a19af 100644
--- a/drivers/media/platform/marvell-ccic/mmp-driver.c
+++ b/drivers/media/platform/marvell-ccic/mmp-driver.c
@@ -396,10 +396,6 @@ static int mmpcam_probe(struct platform_device *pdev)
 * Get our I/O memory.
 */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (res == NULL) {
-   dev_err(pdev-dev, no iomem resource!\n);
-   return -ENODEV;
-   }
mcam-regs = devm_ioremap_resource(pdev-dev, res);
if (IS_ERR(mcam-regs))
return PTR_ERR(mcam-regs);
@@ -409,10 +405,6 @@ static int mmpcam_probe(struct platform_device *pdev)
 * should really be managed outside of this driver?
 */
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-   if (res == NULL) {
-   dev_err(pdev-dev, no power resource!\n);
-   return -ENODEV;
-   }
cam-power_regs = devm_ioremap_resource(pdev-dev, res);
if (IS_ERR(cam-power_regs))
return PTR_ERR(cam-power_regs);

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/29] simplify use of devm_ioremap_resource

2013-08-14 Thread Julia Lawall
devm_ioremap_resource often uses the result of a call to
platform_get_resource as its last argument.  devm_ioremap_resource does
appropriate error handling on this argument, so error handling can be
removed from the call site.  To make the connection between the call to
platform_get_resource and the call to devm_ioremap_resource more clear, the
former is also moved down to be adjacent to the latter.

In many cases, this patch changes the specific error value that is
returned on failure of platform_get_resource.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

(
  res = platform_get_resource(pdev, IORESOURCE_MEM, n);
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  e = devm_ioremap_resource(e1, res);
|
- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  e = devm_ioremap_resource(e1, res);
)
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


question about drivers/media/usb/gspca/kinect.c

2013-12-25 Thread Julia Lawall
The following code, in the function send_cmd, looks too concise:

do {
actual_len = kinect_read(udev, ibuf, 0x200);
} while (actual_len == 0);
PDEBUG(D_USBO, Control reply: %d, res);
if (actual_len  sizeof(*rhdr)) {
pr_err(send_cmd: Input control transfer failed (%d)\n, res);
return res;
}

It seems that actual_len might be less than sizeof(*rhdr) either because 
an error code is returned by the call to kinect_read or because a shorter 
length is returned than the desired one.  In the error code case, I would 
guess that one would want to return the error code, but I don't know what 
on would want to return in the other case.  In any case, res is not 
defined by this code, so what is returned is whatever the result of the 
previous call to kinect_write happened to be.

How should the code be changed?

thanks,
julia
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/25] fix error return code

2013-12-29 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Set the return variable to an error code as done elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
(
if@p1 (\(ret  0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != ret
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}

// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
Not tested.

 drivers/media/tuners/e4000.c |   16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 72971a8..40c1da7 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -243,8 +243,10 @@ static int e4000_set_params(struct dvb_frontend *fe)
break;
}
 
-   if (i == ARRAY_SIZE(e4000_pll_lut))
+   if (i == ARRAY_SIZE(e4000_pll_lut)) {
+   ret = -EINVAL;
goto err;
+   }
 
/*
 * Note: Currently f_vco overflows when c-frequency is 1 073 741 824 Hz
@@ -271,8 +273,10 @@ static int e4000_set_params(struct dvb_frontend *fe)
break;
}
 
-   if (i == ARRAY_SIZE(e400_lna_filter_lut))
+   if (i == ARRAY_SIZE(e400_lna_filter_lut)) {
+   ret = -EINVAL;
goto err;
+   }
 
ret = e4000_wr_reg(priv, 0x10, e400_lna_filter_lut[i].val);
if (ret  0)
@@ -284,8 +288,10 @@ static int e4000_set_params(struct dvb_frontend *fe)
break;
}
 
-   if (i == ARRAY_SIZE(e4000_if_filter_lut))
+   if (i == ARRAY_SIZE(e4000_if_filter_lut)) {
+   ret = -EINVAL;
goto err;
+   }
 
buf[0] = e4000_if_filter_lut[i].reg11_val;
buf[1] = e4000_if_filter_lut[i].reg12_val;
@@ -300,8 +306,10 @@ static int e4000_set_params(struct dvb_frontend *fe)
break;
}
 
-   if (i == ARRAY_SIZE(e4000_band_lut))
+   if (i == ARRAY_SIZE(e4000_band_lut)) {
+   ret = -EINVAL;
goto err;
+   }
 
ret = e4000_wr_reg(priv, 0x07, e4000_band_lut[i].reg07_val);
if (ret  0)

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/25] fix error return code

2013-12-29 Thread Julia Lawall
These patches fix cases where the return variable is not set to an error
code in an error case.

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/25] fix error return code

2013-12-29 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

The rest of the function uses ret to store the return value, even setting
ret to i a few lines before this, so return ret instead of i.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
(
if@p1 (\(ret  0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != ret
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}

// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
Not tested.

 drivers/media/usb/dvb-usb-v2/ec168.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/ec168.c 
b/drivers/media/usb/dvb-usb-v2/ec168.c
index 5c68f39..0c2b377 100644
--- a/drivers/media/usb/dvb-usb-v2/ec168.c
+++ b/drivers/media/usb/dvb-usb-v2/ec168.c
@@ -170,7 +170,7 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
 
 error:
mutex_unlock(d-i2c_mutex);
-   return i;
+   return ret;
 }
 
 static u32 ec168_i2c_func(struct i2c_adapter *adapter)

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c: use correct structure type name in sizeof

2014-07-29 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Correct typo in the name of the type given to sizeof.  Because it is the
size of a pointer that is wanted, the typo has no impact on compilation or
execution.

This problem was found using Coccinelle (http://coccinelle.lip6.fr/).  The
semantic patch used can be found in message 0 of this patch series.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c 
b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
index cda8388..255590f 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
@@ -227,7 +227,7 @@ static int vpfe_enable_clock(struct vpfe_device *vpfe_dev)
return 0;
 
vpfe_dev-clks = kzalloc(vpfe_cfg-num_clocks *
-  sizeof(struct clock *), GFP_KERNEL);
+  sizeof(struct clk *), GFP_KERNEL);
if (vpfe_dev-clks == NULL) {
v4l2_err(vpfe_dev-pdev-driver, Memory allocation failed\n);
return -ENOMEM;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/9] use correct structure type name in sizeof

2014-07-29 Thread Julia Lawall
These patches fix typos in the name of a type referenced in a sizeof
command.  These problems are not caught by the compiler, because they have
no impact on execution - the size of a pointer is independent of the size
of the pointed value.

The semantic patch that finds these problems is shown below
(http://coccinelle.lip6.fr/).  This semantic patch distinguishes between
structures that are defined in C files, and thus are expected to be visible
in only that file, and structures that are defined in header files, which
could potential be visible everywhere.  This distinction seems to be
unnecessary in practice, though.

smpl
virtual after_start

@initialize:ocaml@
@@

type fl = C of string | H

let structures = Hashtbl.create 101
let restarted = ref false

let add_if_not_present _ =
  if not !restarted
  then
begin
  restarted := true;
  let it = new iteration() in
  it#add_virtual_rule After_start;
  it#register()
end

let hashadd str file =
  let cell =
try Hashtbl.find structures str
with Not_found -
  let cell = ref [] in
  Hashtbl.add structures str cell;
  cell in
  if not (List.mem file !cell) then cell := file :: !cell

let get_file fl =
  if Filename.check_suffix fl .c
  then C fl
  else H

@script:ocaml depends on !after_start@
@@
add_if_not_present()

@r depends on !after_start@
identifier nm;
position p;
@@

struct nm@p { ... };

@script:ocaml@
nm  r.nm;
p  r.p;
@@

hashadd nm (get_file (List.hd p).file)

// -

@sz depends on after_start@
identifier nm;
position p;
@@

sizeof(struct nm@p *)

@script:ocaml@
nm  sz.nm;
p  sz.p;
@@

try
  let allowed = !(Hashtbl.find structures nm) in
  if List.mem H allowed or List.mem (get_file (List.hd p).file) allowed
  then ()
  else print_main nm p
with Not_found - print_main nm p
/smpl

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/9] use c99 initializers in structures

2014-08-23 Thread Julia Lawall
These patches add labels in the initializations of structure fields (c99
initializers).  The complete semantic patch thta makes this change is shown
below.  This rule ignores cases where the initialization is just 0 or NULL,
where some of the fields already use labels, and where there are nested
structures.

// smpl
@ok1@
identifier i1,i2;
position p;
@@

struct i1 i2@p = { \(0\|NULL\) };

@ok2@
identifier i1,i2,i3;
position p;
expression e;
@@

struct i1 i2@p = { ..., .i3 = e, ... };

@ok3@
identifier i1,i2;
position p;
@@

struct i1 i2@p = { ..., { ... }, ... };

@decl@
identifier i1,fld;
type T;
field list[n] fs;
@@

struct i1 {
 fs
 T fld;
 ...};

@bad@
identifier decl.i1,i2;
expression e;
position p != {ok1.p,ok2.p,ok3.p};
constant nm;
initializer list[decl.n] is;
position fix;
@@

struct i1 i2@p = { is,
(
 nm(...)
|
 e@fix
)
 ,...};

@@
identifier decl.i1,i2,decl.fld;
expression e;
position bad.p, bad.fix;
@@

struct i1 i2@p = { ...,
+ .fld = e
- e@fix
 ,...};
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] [media] v4l: ti-vpe: use c99 initializers in structures

2014-08-23 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Use c99 initializers for structures.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@decl@
identifier i1,fld;
type T;
field list[n] fs;
@@

struct i1 {
 fs
 T fld;
 ...};

@bad@
identifier decl.i1,i2;
expression e;
initializer list[decl.n] is;
@@

struct i1 i2 = { is,
+ .fld = e
- e
 ,...};
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
The patches in this series do not depend on each other.

Not compiled.

 drivers/media/platform/ti-vpe/vpe.c |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/ti-vpe/vpe.c 
b/drivers/media/platform/ti-vpe/vpe.c
index 972f43f..20dd7ea 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -138,12 +138,12 @@ struct vpe_dei_regs {
  * default expert DEI register values, unlikely to be modified.
  */
 static const struct vpe_dei_regs dei_regs = {
-   0x020C0804u,
-   0x0118100Fu,
-   0x08040200u,
-   0x1010100Cu,
-   0x10101010u,
-   0x10101010u,
+   .mdt_spacial_freq_thr_reg = 0x020C0804u,
+   .edi_config_reg = 0x0118100Fu,
+   .edi_lut_reg0 = 0x08040200u,
+   .edi_lut_reg1 = 0x1010100Cu,
+   .edi_lut_reg2 = 0x10101010u,
+   .edi_lut_reg3 = 0x10101010u,
 };
 
 /*

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [linuxtv-media:devel 497/499] drivers/media/platform/s5p-mfc/s5p_mfc.c:454:2-5: WARNING: Use BUG_ON

2014-08-27 Thread Julia Lawall
The bug_on one doesn't look like a good idea, but the returnvar one would
make the code a little simpler.

julia

On Thu, 28 Aug 2014, kbuild test robot wrote:

 TO: Mauro Carvalho Chehab m.che...@samsung.com
 CC: linux-media@vger.kernel.org

 Hi Mauro,

 First bad commit (maybe != root cause):

 tree:   git://linuxtv.org/media_tree.git devel
 head:   38a0731165250a0a77eff7b90ea3156d44cc7d66
 commit: 7155043c2d027c9c848c3d09badb5af2894ed652 [497/499] [media] enable 
 COMPILE_TEST for media drivers
 :: branch date: 19 hours ago
 :: commit date: 19 hours ago

  drivers/media/platform/s5p-mfc/s5p_mfc.c:454:2-5: WARNING: Use BUG_ON
  drivers/media/platform/s5p-mfc/s5p_mfc.c:333:3-6: WARNING: Use BUG_ON
  drivers/media/platform/s5p-mfc/s5p_mfc.c:406:2-5: WARNING: Use BUG_ON
  drivers/media/platform/s5p-mfc/s5p_mfc.c:548:3-6: WARNING: Use BUG_ON
  drivers/media/platform/s5p-mfc/s5p_mfc.c:556:3-6: WARNING: Use BUG_ON
  drivers/media/platform/s5p-mfc/s5p_mfc.c:509:2-5: WARNING: Use BUG_ON
  drivers/media/platform/s5p-mfc/s5p_mfc.c:634:4-7: WARNING: Use BUG_ON
 --
  drivers/media/platform/davinci/vpfe_capture.c:946:5-8: Unneeded variable: 
  ret. Return 0 on line 951

 Please consider folding the attached diff :-)

 ---
 0-DAY kernel build testing backend  Open Source Technology Center
 http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
From: Fengguang Wu fengguang...@intel.com
Subject: [PATCH] fix coccinelle warnings
TO: Mauro Carvalho Chehab m.che...@samsung.com
CC: Mauro Carvalho Chehab m.che...@samsung.com
CC: linux-arm-ker...@lists.infradead.org 
CC: linux-media@vger.kernel.org 
CC: linux-ker...@vger.kernel.org 
CC: devicet...@vger.kernel.org 

drivers/media/platform/s5p-mfc/s5p_mfc.c:454:2-5: WARNING: Use BUG_ON
drivers/media/platform/s5p-mfc/s5p_mfc.c:333:3-6: WARNING: Use BUG_ON
drivers/media/platform/s5p-mfc/s5p_mfc.c:406:2-5: WARNING: Use BUG_ON
drivers/media/platform/s5p-mfc/s5p_mfc.c:548:3-6: WARNING: Use BUG_ON
drivers/media/platform/s5p-mfc/s5p_mfc.c:556:3-6: WARNING: Use BUG_ON
drivers/media/platform/s5p-mfc/s5p_mfc.c:509:2-5: WARNING: Use BUG_ON
drivers/media/platform/s5p-mfc/s5p_mfc.c:634:4-7: WARNING: Use BUG_ON

 Use BUG_ON instead of a if condition followed by BUG.

Semantic patch information:
 This makes an effort to find cases where BUG() follows an if
 condition on an expression and replaces the if condition and BUG()
 with a BUG_ON having the conditional expression of the if statement
 as argument.

Generated by: scripts/coccinelle/misc/bugon.cocci

CC: Mauro Carvalho Chehab m.che...@samsung.com
Signed-off-by: Fengguang Wu fengguang...@intel.com
---

Please take the patch only if it's a positive warning. Thanks!

 s5p_mfc.c |   21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -329,8 +329,7 @@ static void s5p_mfc_handle_frame(struct
 		ctx-state = MFCINST_RES_CHANGE_INIT;
 		s5p_mfc_hw_call(dev-mfc_ops, clear_int_flags, dev);
 		wake_up_ctx(ctx, reason, err);
-		if (test_and_clear_bit(0, dev-hw_lock) == 0)
-			BUG();
+		BUG_ON(test_and_clear_bit(0, dev-hw_lock) == 0);
 		s5p_mfc_clock_off();
 		s5p_mfc_hw_call(dev-mfc_ops, try_run, dev);
 		return;
@@ -402,8 +401,7 @@ leave_handle_frame:
 		clear_work_bit(ctx);
 	s5p_mfc_hw_call(dev-mfc_ops, clear_int_flags, dev);
 	wake_up_ctx(ctx, reason, err);
-	if (test_and_clear_bit(0, dev-hw_lock) == 0)
-		BUG();
+	BUG_ON(test_and_clear_bit(0, dev-hw_lock) == 0);
 	s5p_mfc_clock_off();
 	/* if suspending, wake up device and do not try_run again*/
 	if (test_bit(0, dev-enter_suspend))
@@ -450,8 +448,7 @@ static void s5p_mfc_handle_error(struct
 			break;
 		}
 	}
-	if (test_and_clear_bit(0, dev-hw_lock) == 0)
-		BUG();
+	BUG_ON(test_and_clear_bit(0, dev-hw_lock) == 0);
 	s5p_mfc_hw_call(dev-mfc_ops, clear_int_flags, dev);
 	s5p_mfc_clock_off();
 	wake_up_dev(dev, reason, err);
@@ -505,8 +502,7 @@ static void s5p_mfc_handle_seq_done(stru
 	}
 	s5p_mfc_hw_call(dev-mfc_ops, clear_int_flags, dev);
 	clear_work_bit(ctx);
-	if (test_and_clear_bit(0, dev-hw_lock) == 0)
-		BUG();
+	BUG_ON(test_and_clear_bit(0, dev-hw_lock) == 0);
 	s5p_mfc_clock_off();
 	s5p_mfc_hw_call(dev-mfc_ops, try_run, dev);
 	wake_up_ctx(ctx, reason, err);
@@ -544,16 +540,14 @@ static void s5p_mfc_handle_init_buffers(
 		} else {
 			ctx-dpb_flush_flag = 0;
 		}
-		if (test_and_clear_bit(0, dev-hw_lock) == 0)
-			BUG();
+		BUG_ON(test_and_clear_bit(0, dev-hw_lock) == 0);
 
 		s5p_mfc_clock_off();
 
 		wake_up(ctx-queue);
 		s5p_mfc_hw_call(dev-mfc_ops, try_run, dev);
 	} else {
-		if (test_and_clear_bit(0, dev-hw_lock) == 0)
-			BUG();
+		BUG_ON(test_and_clear_bit(0, dev-hw_lock) == 0);
 
 		s5p_mfc_clock_off();
 
@@ -630,8 +624,7 @@ static irqreturn_t s5p_mfc_irq(int irq,
 mfc_err(post_frame_start() failed\n);
 			s5p_mfc_hw_call(dev-mfc_ops, clear_int_flags, dev);
 			wake_up_ctx(ctx, reason, err);
-			if 

Re: [patch] [media] em28xx-input: NULL dereference on error

2014-09-25 Thread Julia Lawall
On Thu, 25 Sep 2014, Frank Schäfer wrote:

 Hi Dan,

 Am 25.09.2014 um 13:39 schrieb Dan Carpenter:
  We call kfree(ir-i2c_client); in the error handling and that doesn't
  work if ir is NULL.
 
  Fixes: 78e719a5f30b ('[media] em28xx-input: i2c IR decoders: improve 
  i2c_client handling')
  Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
 
  diff --git a/drivers/media/usb/em28xx/em28xx-input.c 
  b/drivers/media/usb/em28xx/em28xx-input.c
  index 581f6da..23f8f6a 100644
  --- a/drivers/media/usb/em28xx/em28xx-input.c
  +++ b/drivers/media/usb/em28xx/em28xx-input.c
  @@ -712,8 +712,10 @@ static int em28xx_ir_init(struct em28xx *dev)
  em28xx_info(Registering input extension\n);
 
  ir = kzalloc(sizeof(*ir), GFP_KERNEL);
  +   if (!ir)
  +   return -ENOMEM;
  rc = rc_allocate_device();
  -   if (!ir || !rc)
  +   if (!rc)
  goto error;

I have never understood this kind of code.  If the kmalloc fails, why not
give up immediately (as in Dan's patch)?

julia


  /* record handles to ourself */
 I would prefer to fix it where the actual problem is located.
 Can you send an updated version that changes the code to do

 ...
 error:
 if (ir)
   kfree(ir-i2c_client);
 ...

 This makes the code less prone to future error handling changes.

 Thanks !

 Regards,
 Frank

 --
 To unsubscribe from this list: send the line unsubscribe kernel-janitors in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [linuxtv-media:master 489/499] drivers/media/usb/cx231xx/cx231xx-audio.c:445:16-20: ERROR: dev is NULL but dereferenced.

2014-11-03 Thread Julia Lawall
Clearly a bug.

On Tue, 4 Nov 2014, kbuild test robot wrote:

 TO: Mauro Carvalho Chehab m.che...@samsung.com
 CC: linux-media@vger.kernel.org
 
 tree:   git://linuxtv.org/media_tree.git master
 head:   ed3da2bf2e1800e7c6e31e7d31917dacce599458
 commit: b7085c08647598aafbf8f6223ebcdd413745449c [489/499] [media] cx231xx: 
 convert from pr_foo to dev_foo
 :: branch date: 81 minutes ago
 :: commit date: 2 hours ago
 
  drivers/media/usb/cx231xx/cx231xx-audio.c:445:16-20: ERROR: dev is NULL 
  but dereferenced.
 
 git remote add linuxtv-media git://linuxtv.org/media_tree.git
 git remote update linuxtv-media
 git checkout b7085c08647598aafbf8f6223ebcdd413745449c
 vim +445 drivers/media/usb/cx231xx/cx231xx-audio.c
 
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  429.buffer_bytes_max = 62720 * 8,  /* just about the value in 
 usbaudio.c */
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  430.period_bytes_min = 64, /* 12544/2, */
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  431.period_bytes_max = 12544,
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  432.periods_min = 2,
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  433.periods_max = 98,  /* 12544, */
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  434  };
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  435  
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  436  static int snd_cx231xx_capture_open(struct snd_pcm_substream 
 *substream)
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  437  {
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  438struct cx231xx *dev = snd_pcm_substream_chip(substream);
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  439struct snd_pcm_runtime *runtime = substream-runtime;
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  440int ret = 0;
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  441  
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  442dprintk(opening device and trying to acquire exclusive 
 lock\n);
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  443  
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  444if (!dev) {
 b7085c08 drivers/media/usb/cx231xx/cx231xx-audio.c   Mauro Carvalho Chehab 
 2014-11-02 @445dev_err(dev-udev-dev,
 b7085c08 drivers/media/usb/cx231xx/cx231xx-audio.c   Mauro Carvalho Chehab 
 2014-11-02  446BUG: cx231xx can't find device struct. 
 Can't proceed with open\n);
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  447return -ENODEV;
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  448}
 e0d3bafd drivers/media/video/cx231xx/cx231xx-audio.c Sri Deevi 
 2009-03-03  449  
 990862a2 drivers/media/video/cx231xx/cx231xx-audio.c Mauro Carvalho Chehab 
 2012-01-10  450if (dev-state  DEV_DISCONNECTED) {
 b7085c08 drivers/media/usb/cx231xx/cx231xx-audio.c   Mauro Carvalho Chehab 
 2014-11-02  451dev_err(dev-udev-dev,
 b7085c08 drivers/media/usb/cx231xx/cx231xx-audio.c   Mauro Carvalho Chehab 
 2014-11-02  452Can't open. the device was removed.\n);
 990862a2 drivers/media/video/cx231xx/cx231xx-audio.c Mauro Carvalho Chehab 
 2012-01-10  453return -ENODEV;
 
 ---
 0-DAY kernel test infrastructureOpen Source Technology Center
 http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/27] [media] usbvision: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.data = d;
-t.function = f;
// /smpl

The semantic patch also changes the cast to long to a cast to unsigned
long in the data initializer, as unsigned long is the type of the data field.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/usb/usbvision/usbvision-core.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/usbvision/usbvision-core.c 
b/drivers/media/usb/usbvision/usbvision-core.c
index 302aa07..64c63d3 100644
--- a/drivers/media/usb/usbvision/usbvision-core.c
+++ b/drivers/media/usb/usbvision/usbvision-core.c
@@ -2194,9 +2194,8 @@ static void usbvision_power_off_timer(unsigned long data)
 
 void usbvision_init_power_off_timer(struct usb_usbvision *usbvision)
 {
-   init_timer(usbvision-power_off_timer);
-   usbvision-power_off_timer.data = (long)usbvision;
-   usbvision-power_off_timer.function = usbvision_power_off_timer;
+   setup_timer(usbvision-power_off_timer, usbvision_power_off_timer,
+   (unsigned long)usbvision);
 }
 
 void usbvision_set_power_off_timer(struct usb_usbvision *usbvision)

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/27] Use setup_timer

2014-12-26 Thread Julia Lawall
These patches group a call to init_timer and initialization of the function
and data fields into a call to setup_timer.  Is there is no initialization
of the data field before add_timer is called, the the data value is set to
0UL.  If the data value has a cast to something other than unsigned long,
it is changes to a cast to unsigned long, which is the type of the data
field.

The semantic patch that performs this change is shown below
(http://coccinelle.lip6.fr/).  This semantic patch is fairly restrictive on
what appears between the init_timer call and the two field initializations,
to ensure that the there is no code that the initializations depend on.

// smpl
@@
expression t,d,f,e1,e2;
identifier x1,x2;
statement S1,S2;
@@

(
-t.data = d;
|
-t.function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
... when != S1
t.x1 = e1;
...
(
-t.data = d;
|
-t.function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
... when != S2
t.x2 = e2;
...
(
-t.data = d;
|
-t.function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)

// --

@@
expression t,d,f,e1,e2;
identifier x1,x2;
statement S1,S2;
@@

(
-t-data = d;
|
-t-function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
... when != S1
t-x1 = e1;
...
(
-t-data = d;
|
-t-function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
... when != S2
t-x2 = e2;
...
(
-t-data = d;
|
-t-function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)

// -
// no initialization of data field

@@
expression t,d1,d2,f;
@@

(
-init_timer(t);
+setup_timer(t,f,0UL);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,0UL);
)
... when != t.data = d1;
-t.function = f;
... when != t.data = d2;
add_timer(t);

@@
expression t,d,f,fn;
type T;
@@

-t.function = f;
... when != t.data
when != fn(...,(T)t,...)
(
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,0UL);
)
... when != t.data = d;
add_timer(t);

// --

@@
expression t,d1,d2,f;
@@

(
-init_timer(t);
+setup_timer(t,f,0UL);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,0UL);
)
... when != t-data = d1;
-t-function = f;
... when != t-data = d2;
add_timer(t);

@@
expression t,d,f,fn;
type T;
@@

-t-function = f;
... when != t.data
when != fn(...,(T)t,...)
(
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,0UL);
)
... when != t-data = d;
add_timer(t);

// -
// change data field type

@@
expression d;
type T;
@@

(
setup_timer
|
setup_timer_on_stack
)
 (...,
(
  (unsigned long)d
|
- (T)
+ (unsigned long)
  d
)
 )
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/27] [media] pvrusb2: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.data = d;
-t.function = f;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c |   26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 2fd9b5e..08f2f5a 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -2425,22 +2425,18 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface 
*intf,
}
if (!hdw) goto fail;
 
-   init_timer(hdw-quiescent_timer);
-   hdw-quiescent_timer.data = (unsigned long)hdw;
-   hdw-quiescent_timer.function = pvr2_hdw_quiescent_timeout;
+   setup_timer(hdw-quiescent_timer, pvr2_hdw_quiescent_timeout,
+   (unsigned long)hdw);
 
-   init_timer(hdw-decoder_stabilization_timer);
-   hdw-decoder_stabilization_timer.data = (unsigned long)hdw;
-   hdw-decoder_stabilization_timer.function =
-   pvr2_hdw_decoder_stabilization_timeout;
+   setup_timer(hdw-decoder_stabilization_timer,
+   pvr2_hdw_decoder_stabilization_timeout,
+   (unsigned long)hdw);
 
-   init_timer(hdw-encoder_wait_timer);
-   hdw-encoder_wait_timer.data = (unsigned long)hdw;
-   hdw-encoder_wait_timer.function = pvr2_hdw_encoder_wait_timeout;
+   setup_timer(hdw-encoder_wait_timer, pvr2_hdw_encoder_wait_timeout,
+   (unsigned long)hdw);
 
-   init_timer(hdw-encoder_run_timer);
-   hdw-encoder_run_timer.data = (unsigned long)hdw;
-   hdw-encoder_run_timer.function = pvr2_hdw_encoder_run_timeout;
+   setup_timer(hdw-encoder_run_timer, pvr2_hdw_encoder_run_timeout,
+   (unsigned long)hdw);
 
hdw-master_state = PVR2_STATE_DEAD;
 
@@ -3680,10 +3676,8 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
hdw-ctl_timeout_flag = 0;
hdw-ctl_write_pend_flag = 0;
hdw-ctl_read_pend_flag = 0;
-   init_timer(timer);
+   setup_timer(timer, pvr2_ctl_timeout, (unsigned long)hdw);
timer.expires = jiffies + timeout;
-   timer.data = (unsigned long)hdw;
-   timer.function = pvr2_ctl_timeout;
 
if (write_len) {
hdw-cmd_debug_state = 2;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/27] [media] s2255drv: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.function = f;
-t.data = d;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/usb/s2255/s2255drv.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index de55e96..0f3c34d 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -2274,9 +2274,7 @@ static int s2255_probe(struct usb_interface *interface,
dev_err(interface-dev, Could not find bulk-in endpoint\n);
goto errorEP;
}
-   init_timer(dev-timer);
-   dev-timer.function = s2255_timer;
-   dev-timer.data = (unsigned long)dev-fw_data;
+   setup_timer(dev-timer, s2255_timer, (unsigned long)dev-fw_data);
init_waitqueue_head(dev-fw_data-wait_fw);
for (i = 0; i  MAX_CHANNELS; i++) {
struct s2255_vc *vc = dev-vc[i];

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/27] [media] au0828: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-t.function = f;
-t.data = d;
-init_timer(t);
+setup_timer(t,f,d);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/usb/au0828/au0828-video.c |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 5f337b1..0b24791 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -2043,13 +2043,10 @@ int au0828_analog_register(struct au0828_dev *dev,
INIT_LIST_HEAD(dev-vbiq.active);
INIT_LIST_HEAD(dev-vbiq.queued);
 
-   dev-vid_timeout.function = au0828_vid_buffer_timeout;
-   dev-vid_timeout.data = (unsigned long) dev;
-   init_timer(dev-vid_timeout);
-
-   dev-vbi_timeout.function = au0828_vbi_buffer_timeout;
-   dev-vbi_timeout.data = (unsigned long) dev;
-   init_timer(dev-vbi_timeout);
+   setup_timer(dev-vid_timeout, au0828_vid_buffer_timeout,
+   (unsigned long)dev);
+   setup_timer(dev-vbi_timeout, au0828_vbi_buffer_timeout,
+   (unsigned long)dev);
 
dev-width = NTSC_STD_W;
dev-height = NTSC_STD_H;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/15] media: pci: cx23885: don't export static symbol

2015-03-11 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@r@
type T;
identifier f;
@@

static T f (...) { ... }

@@
identifier r.f;
declarer name EXPORT_SYMBOL;
@@

-EXPORT_SYMBOL(f);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/pci/cx23885/altera-ci.c |3 ---
 1 file changed, 3 deletions(-)

diff -u -p a/drivers/media/pci/cx23885/altera-ci.c 
b/drivers/media/pci/cx23885/altera-ci.c
--- a/drivers/media/pci/cx23885/altera-ci.c
+++ b/drivers/media/pci/cx23885/altera-ci.c
@@ -483,7 +483,6 @@ static void altera_hw_filt_release(void
}
 
 }
-EXPORT_SYMBOL(altera_hw_filt_release);
 
 void altera_ci_release(void *dev, int ci_nr)
 {
@@ -598,7 +597,6 @@ static int altera_pid_feed_control(void
 
return 0;
 }
-EXPORT_SYMBOL(altera_pid_feed_control);
 
 static int altera_ci_start_feed(struct dvb_demux_feed *feed, int num)
 {
@@ -699,7 +697,6 @@ err:
 
return ret;
 }
-EXPORT_SYMBOL(altera_hw_filt_init);
 
 int altera_ci_init(struct altera_ci_config *config, int ci_nr)
 {

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/15] don't export static symbol

2015-03-11 Thread Julia Lawall
These patches remove EXPORT_SYMBOL or EXPORT_SYMBOL_GPL declarations on
static functions.

This was done using the following semantic patch:
(http://coccinelle.lip6.fr/)

// smpl
@r@
type T;
identifier f;
@@

static T f (...) { ... }

@@
identifier r.f;
declarer name EXPORT_SYMBOL;
@@

-EXPORT_SYMBOL(f);

@@
identifier r.f;
declarer name EXPORT_SYMBOL_GPL;
@@

-EXPORT_SYMBOL_GPL(f);
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: drivers/media/usb/au0828/au0828-video.c:1741:1-3: WARNING: end returns can be simpified if negative or 0 value

2015-03-25 Thread Julia Lawall
The function does only return 0 or a negative constant, but it seems like
a matter of personal prefernce - shorter vs more explicit.

julia

On Wed, 25 Mar 2015, kbuild test robot wrote:

 TO: Shuah Khan shua...@osg.samsung.com
 CC: Mauro Carvalho Chehab m.che...@samsung.com
 CC: linux-media@vger.kernel.org
 CC: Hans Verkuil hans.verk...@cisco.com

 tree:   git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
 master
 head:   c875f421097a55d9126159957a2d812b91c9ce8c
 commit: 05439b1a36935992785c4f28f6693e73820321cb [media] media: au0828 - 
 convert to use videobuf2
 date:   7 weeks ago
 :: branch date: 9 hours ago
 :: commit date: 7 weeks ago

  drivers/media/usb/au0828/au0828-video.c:1741:1-3: WARNING: end returns can 
  be simpified if negative or 0 value

 git remote add linus 
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
 git remote update linus
 git checkout 05439b1a36935992785c4f28f6693e73820321cb
 vim +1741 drivers/media/usb/au0828/au0828-video.c

 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1725 q-mem_ops = vb2_vmalloc_memops;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1726
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1727 rc = vb2_queue_init(q);
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1728 if (rc  0)
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1729 return rc;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1730
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1731 /* Setup Videobuf2 for VBI capture */
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1732 q = dev-vb_vbiq;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1733 q-type = V4L2_BUF_TYPE_VBI_CAPTURE;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1734 q-io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR | 
 VB2_DMABUF;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1735 q-timestamp_flags = 
 V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1736 q-drv_priv = dev;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1737 q-buf_struct_size = sizeof(struct au0828_buffer);
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1738 q-ops = au0828_vbi_qops;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1739 q-mem_ops = vb2_vmalloc_memops;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1740
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29 @1741 rc = vb2_queue_init(q);
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1742 if (rc  0)
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1743 return rc;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1744
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1745 return 0;
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1746  }
 05439b1a drivers/media/usb/au0828/au0828-video.c   Shuah Khan
 2015-01-29  1747
 8b2f0795 drivers/media/video/au0828/au0828-video.c Devin Heitmueller 
 2009-03-11  1748  
 /**/
 8b2f0795 drivers/media/video/au0828/au0828-video.c Devin Heitmueller 
 2009-03-11  1749

 ---
 0-DAY kernel test infrastructureOpen Source Technology Center
 http://lists.01.org/mailman/listinfo/kbuild Intel Corporation

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/16] [media] as102: fix error return code

2015-04-05 Thread Julia Lawall
Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret  0\|ret != 0\))
 { ... return ret; }
|
ret = 0
)
... when != ret = e1
when != ret
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/usb/as102/as102_drv.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/as102/as102_drv.c 
b/drivers/media/usb/as102/as102_drv.c
index 8be1474..9dd7c7c 100644
--- a/drivers/media/usb/as102/as102_drv.c
+++ b/drivers/media/usb/as102/as102_drv.c
@@ -337,6 +337,7 @@ int as102_dvb_register(struct as102_dev_t *as102_dev)
   as102_dev-bus_adap,
   as102_dev-elna_cfg);
if (!as102_dev-dvb_fe) {
+   ret = -ENODEV;
dev_err(dev, %s: as102_attach() failed: %d,
__func__, ret);
goto efereg;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/16] [media] si4713: fix error return code

2015-04-05 Thread Julia Lawall
Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret  0\|ret != 0\))
 { ... return ret; }
|
ret = 0
)
... when != ret = e1
when != ret
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/radio/si4713/si4713.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/radio/si4713/si4713.c 
b/drivers/media/radio/si4713/si4713.c
index c90004d..c4e1d6c 100644
--- a/drivers/media/radio/si4713/si4713.c
+++ b/drivers/media/radio/si4713/si4713.c
@@ -1615,8 +1615,10 @@ static int si4713_probe(struct i2c_client *client,
return 0;
 
si4713_pdev = platform_device_alloc(radio-si4713, -1);
-   if (!si4713_pdev)
+   if (!si4713_pdev) {
+   rval = -ENOMEM;
goto put_main_pdev;
+   }
 
si4713_pdev_pdata.subdev = client;
rval = platform_device_add_data(si4713_pdev, si4713_pdev_pdata,

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/16] fix error return code

2015-04-05 Thread Julia Lawall
The complate semantic patch that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@ok exists@
identifier f,ret,i;
expression e;
constant c;
@@

// identify a function that returns a negative return value at least once.
f(...) {
... when any
(
return -c@i;
|
ret = -c@i;
... when != ret = e
return ret;
|
if (ret  0) { ... return ret; }
)
... when any
}

@r exists@
identifier ret,ok.f,fn;
expression e1,e2,e3,e4,e5,e6,x;
statement S,S1;
position p1,p2,p3;
@@

// identify a case where the return variable is set to a non-negative value
// and then returned in error-handling code
f(...) {
... when any
(
if@p1 (\(ret  0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\)
when != ret
when any
(
 if (+... ret = e5 ...+) S1
|
 if (+... ret ...+) S1
|
if@p2(+...x = fn(...)...+)
 {
  ... when != ret = e6
  when forall
 return@p3 ret;
}
|
break;
|
x = fn(...)
... when != \(ret = e4\|ret++\|ret--\|ret+=e4\|ret-=e4\)
when != ret
(
 if (+... ret = e3 ...+) S
|
 if (+... ret ...+) S
|
if@p2(+...\(x != 0\|x  0\|x == NULL\|IS_ERR(x)\)...+)
 {
  ... when != ret = e2
  when forall
 return@p3 ret;
}
)
)
... when any
}

@printer depends on r@
position p;
identifier ok.f,pr;
constant char [] c;
@@

f(...) { ...pr@p(...,c,...)... }

@bad0 exists@
identifier r.ret,ok.f,g != {ERR_PTR,IS_ERR};
position p != printer.p;
@@

f(...) { ... when any
g@p(...,ret,...)
... when any
 }

@bad depends on !bad0 exists@
position r.p1,r.p2;
statement S1,S2;
identifier r.ret;
expression e1;
@@

// ignore the above if there is some path where the variable is set to
// something else
(
if@p1 (\(ret  0\|ret != 0\)) S1
|
ret@p1 = 0
)
... when any
 \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\|ret\)
... when any
if@p2(...) S2

@bad1 depends on !bad0  !bad exists@
position r.p2;
statement S2;
identifier r.ret;
expression e1;
constant c;
@@

ret = -c
... when != \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\)
when != ret
when any
if@p2(...) S2

@bad2 depends on !bad0  !bad  !bad1 exists@
position r.p1,r.p2;
identifier r.ret;
expression e1;
statement S2;
constant c;
@@

// likewise ignore it if there has been an intervening return
ret@p1 = 0
... when != if (...) { ... ret = e1 ... return ret; }
when != if (...) { ... return -c; }
when any
if@p2(...) S2

@script:python depends on !bad0  !bad  !bad1  !bad2@
p1  r.p1;
p2  r.p2;
p3  r.p3;
@@

cocci.print_main(,p1)
cocci.print_secs(,p2)
cocci.print_secs(,p3)
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/16] [media] radio: fix error return code

2015-04-05 Thread Julia Lawall
Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret  0\|ret != 0\))
 { ... return ret; }
|
ret = 0
)
... when != ret = e1
when != ret
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/radio/radio-timb.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c
index e6b55ed..04baafe 100644
--- a/drivers/media/radio/radio-timb.c
+++ b/drivers/media/radio/radio-timb.c
@@ -138,8 +138,10 @@ static int timbradio_probe(struct platform_device *pdev)
i2c_get_adapter(pdata-i2c_adapter), pdata-tuner, NULL);
tr-sd_dsp = v4l2_i2c_new_subdev_board(tr-v4l2_dev,
i2c_get_adapter(pdata-i2c_adapter), pdata-dsp, NULL);
-   if (tr-sd_tuner == NULL || tr-sd_dsp == NULL)
+   if (tr-sd_tuner == NULL || tr-sd_dsp == NULL) {
+   err = -ENODEV;
goto err_video_req;
+   }
 
tr-v4l2_dev.ctrl_handler = tr-sd_dsp-ctrl_handler;
 

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/9] drop unneeded goto

2015-05-28 Thread Julia Lawall
These patches drop gotos that jump to a label that is at the next
instruction, in the case that the label is not used elsewhere in the
function.  The complete semantic patch that performs this transformation is
as follows:

// smpl
@r@
position p;
identifier l;
@@

if (...) goto l@p;
l:

@script:ocaml s@
p  r.p;
nm;
@@

nm := (List.hd p).current_element

@ok exists@
identifier s.nm,l;
position p != r.p;
@@

nm(...) {
+... goto l@p; ...+
}

@depends on !ok@
identifier s.nm;
position r.p;
identifier l;
@@

nm(...) {
...
- if(...) goto l@p; l:
...
}
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] drivers/media/usb/airspy/airspy.c: drop unneeded goto

2015-05-28 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Delete jump to a label on the next line, when that label is not
used elsewhere.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@r@
identifier l;
@@

-if (...) goto l;
-l:
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/usb/airspy/airspy.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/media/usb/airspy/airspy.c 
b/drivers/media/usb/airspy/airspy.c
index 4069234..8f2e1c2 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -937,9 +937,6 @@ static int airspy_set_if_gain(struct airspy *s)
ret = airspy_ctrl_msg(s, CMD_SET_VGA_GAIN, 0, s-if_gain-val,
u8tmp, 1);
if (ret)
-   goto err;
-err:
-   if (ret)
dev_dbg(s-dev, failed=%d\n, ret);
 
return ret;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/9] drivers/media/tuners/e4000.c: drop unneeded goto

2015-05-28 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Delete jump to a label on the next line, when that label is not
used elsewhere.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@r@
identifier l;
@@

-if (...) goto l;
-l:
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/media/tuners/e4000.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 510239f..50c0f0d 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -103,9 +103,6 @@ static int e4000_sleep(struct dvb_frontend *fe)
 
ret = regmap_write(s-regmap, 0x00, 0x00);
if (ret)
-   goto err;
-err:
-   if (ret)
dev_dbg(s-client-dev, failed=%d\n, ret);
 
return ret;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/8] [media] v4l: xilinx-vipp: add missing of_node_put

2015-10-25 Thread Julia Lawall
for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// 
@@
expression root,e;
local idexpression child;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
   when != e = child
(
   return child;
|
+  of_node_put(child);
?  return ...;
)
   ...
 }
// 

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/platform/xilinx/xilinx-vipp.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c 
b/drivers/media/platform/xilinx/xilinx-vipp.c
index 7b7cb9c..b9bf24f 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -476,8 +476,10 @@ static int xvip_graph_dma_init(struct 
xvip_composite_device *xdev)
 
for_each_child_of_node(ports, port) {
ret = xvip_graph_dma_init_one(xdev, port);
-   if (ret < 0)
+   if (ret < 0) {
+   of_node_put(port);
return ret;
+   }
}
 
return 0;

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/8] add missing of_node_put

2015-10-25 Thread Julia Lawall
The various for_each device_node iterators performs an of_node_get on each
iteration, so a break out of the loop requires an of_node_put.

The complete semantic patch that fixes this problem is
(http://coccinelle.lip6.fr):

// 
@r@
local idexpression n;
expression e1,e2;
iterator name for_each_node_by_name, for_each_node_by_type,
for_each_compatible_node, for_each_matching_node,
for_each_matching_node_and_match, for_each_child_of_node,
for_each_available_child_of_node, for_each_node_with_property;
iterator i;
statement S;
expression list [n1] es;
@@

(
(
for_each_node_by_name(n,e1) S
|
for_each_node_by_type(n,e1) S
|
for_each_compatible_node(n,e1,e2) S
|
for_each_matching_node(n,e1) S
|
for_each_matching_node_and_match(n,e1,e2) S
|
for_each_child_of_node(e1,n) S
|
for_each_available_child_of_node(e1,n) S
|
for_each_node_with_property(n,e1) S
)
&
i(es,n,...) S
)

@@
local idexpression r.n;
iterator r.i;
expression e;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
   return n;
|
+  of_node_put(n);
?  return ...;
)
   ...
 }

@@
local idexpression r.n;
iterator r.i;
expression e;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  break;
)
   ...
 }
... when != n

@@
local idexpression r.n;
iterator r.i;
expression e;
identifier l;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  goto l;
)
   ...
 }
...
l: ... when != n// 

---

 drivers/media/platform/xilinx/xilinx-tpg.c|2 ++
 drivers/media/platform/xilinx/xilinx-vipp.c   |4 +++-
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c |4 +++-
 drivers/net/ethernet/marvell/mv643xx_eth.c|4 +++-
 drivers/net/ethernet/ti/netcp_ethss.c |8 ++--
 drivers/net/phy/mdio-mux-mmioreg.c|2 ++
 drivers/net/phy/mdio-mux.c|1 +
 drivers/net/wireless/ath/ath6kl/init.c|1 +
 8 files changed, 21 insertions(+), 5 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/8] [media] v4l: xilinx-tpg: add missing of_node_put

2015-10-25 Thread Julia Lawall
for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// 
@@
expression root,e;
local idexpression child;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
   when != e = child
(
   return child;
|
+  of_node_put(child);
?  return ...;
)
   ...
 }
// 

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/platform/xilinx/xilinx-tpg.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c 
b/drivers/media/platform/xilinx/xilinx-tpg.c
index b5f7d5e..8bd7e37 100644
--- a/drivers/media/platform/xilinx/xilinx-tpg.c
+++ b/drivers/media/platform/xilinx/xilinx-tpg.c
@@ -731,6 +731,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)
format = xvip_of_get_format(port);
if (IS_ERR(format)) {
dev_err(dev, "invalid format in DT");
+   of_node_put(port);
return PTR_ERR(format);
}
 
@@ -739,6 +740,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)
xtpg->vip_format = format;
} else if (xtpg->vip_format != format) {
dev_err(dev, "in/out format mismatch in DT");
+   of_node_put(port);
return -EINVAL;
}
 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] radio-shark2: constify radio_tea5777_ops structures

2015-11-13 Thread Julia Lawall
The radio_tea5777_ops structure is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/radio/radio-shark2.c  |2 +-
 drivers/media/radio/radio-tea5777.h |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/radio/radio-tea5777.h 
b/drivers/media/radio/radio-tea5777.h
index 4ea43a9..4bd9425 100644
--- a/drivers/media/radio/radio-tea5777.h
+++ b/drivers/media/radio/radio-tea5777.h
@@ -76,7 +76,7 @@ struct radio_tea5777 {
u32 read_reg;
u64 write_reg;
struct mutex mutex;
-   struct radio_tea5777_ops *ops;
+   const struct radio_tea5777_ops *ops;
void *private_data;
u8 card[32];
u8 bus_info[32];
diff --git a/drivers/media/radio/radio-shark2.c 
b/drivers/media/radio/radio-shark2.c
index 8654e0d..0e65a85 100644
--- a/drivers/media/radio/radio-shark2.c
+++ b/drivers/media/radio/radio-shark2.c
@@ -137,7 +137,7 @@ static int shark_read_reg(struct radio_tea5777 *tea, u32 
*reg_ret)
return 0;
 }
 
-static struct radio_tea5777_ops shark_tea_ops = {
+static const struct radio_tea5777_ops shark_tea_ops = {
.write_reg = shark_write_reg,
.read_reg  = shark_read_reg,
 };

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] ttusb-dec: constify ttusbdecfe_config structure

2015-11-13 Thread Julia Lawall
The ttusbdecfe_config structure is never modified, so declare it
as const.

Other references to this structure type were already declared as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/usb/ttusb-dec/ttusb_dec.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c 
b/drivers/media/usb/ttusb-dec/ttusb_dec.c
index a5de46f..4e36e24 100644
--- a/drivers/media/usb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c
@@ -1606,7 +1606,7 @@ static int fe_send_command(struct dvb_frontend* fe, const 
u8 command,
return ttusb_dec_send_command(dec, command, param_length, params, 
result_length, cmd_result);
 }
 
-static struct ttusbdecfe_config fe_config = {
+static const struct ttusbdecfe_config fe_config = {
.send_command = fe_send_command
 };
 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] i2c: constify v4l2_ctrl_ops structures

2015-11-13 Thread Julia Lawall
These v4l2_ctrl_ops structures are never modified, like all the other
v4l2_ctrl_ops structures, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/i2c/mt9m032.c |2 +-
 drivers/media/i2c/mt9p031.c |2 +-
 drivers/media/i2c/mt9t001.c |2 +-
 drivers/media/i2c/mt9v011.c |2 +-
 drivers/media/i2c/mt9v032.c |2 +-
 drivers/media/i2c/ov2659.c  |2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index 8ae99f7..3486bc8 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -626,7 +626,7 @@ static int mt9t001_s_ctrl(struct v4l2_ctrl *ctrl)
return 0;
 }
 
-static struct v4l2_ctrl_ops mt9t001_ctrl_ops = {
+static const struct v4l2_ctrl_ops mt9t001_ctrl_ops = {
.s_ctrl = mt9t001_s_ctrl,
 };
 
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index a68ce94..b8e80c0 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -703,7 +703,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
return 0;
 }
 
-static struct v4l2_ctrl_ops mt9v032_ctrl_ops = {
+static const struct v4l2_ctrl_ops mt9v032_ctrl_ops = {
.s_ctrl = mt9v032_s_ctrl,
 };
 
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 0db15f5..1e78aa2 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -817,7 +817,7 @@ static int mt9p031_s_ctrl(struct v4l2_ctrl *ctrl)
return 0;
 }
 
-static struct v4l2_ctrl_ops mt9p031_ctrl_ops = {
+static const struct v4l2_ctrl_ops mt9p031_ctrl_ops = {
.s_ctrl = mt9p031_s_ctrl,
 };
 
diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c
index a4a5c39..c681b3b 100644
--- a/drivers/media/i2c/mt9v011.c
+++ b/drivers/media/i2c/mt9v011.c
@@ -454,7 +454,7 @@ static int mt9v011_s_ctrl(struct v4l2_ctrl *ctrl)
return 0;
 }
 
-static struct v4l2_ctrl_ops mt9v011_ctrl_ops = {
+static const struct v4l2_ctrl_ops mt9v011_ctrl_ops = {
.s_ctrl = mt9v011_s_ctrl,
 };
 
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 49109f4..b952e7d 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1249,7 +1249,7 @@ static int ov2659_s_ctrl(struct v4l2_ctrl *ctrl)
return 0;
 }
 
-static struct v4l2_ctrl_ops ov2659_ctrl_ops = {
+static const struct v4l2_ctrl_ops ov2659_ctrl_ops = {
.s_ctrl = ov2659_s_ctrl,
 };
 
diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
index c7747bd..eec064e 100644
--- a/drivers/media/i2c/mt9m032.c
+++ b/drivers/media/i2c/mt9m032.c
@@ -671,7 +671,7 @@ static int mt9m032_set_ctrl(struct v4l2_ctrl *ctrl)
return 0;
 }
 
-static struct v4l2_ctrl_ops mt9m032_ctrl_ops = {
+static const struct v4l2_ctrl_ops mt9m032_ctrl_ops = {
.s_ctrl = mt9m032_set_ctrl,
.try_ctrl = mt9m032_try_ctrl,
 };

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] drivers/media/platform/s5p-tv: constify mxr_layer_ops structures

2015-11-15 Thread Julia Lawall
The mxr_layer_ops structures are never modified, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/platform/s5p-tv/mixer.h   |2 +-
 drivers/media/platform/s5p-tv/mixer_grp_layer.c |2 +-
 drivers/media/platform/s5p-tv/mixer_video.c |2 +-
 drivers/media/platform/s5p-tv/mixer_vp_layer.c  |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/s5p-tv/mixer.h 
b/drivers/media/platform/s5p-tv/mixer.h
index 42cd270..4dd62a9 100644
--- a/drivers/media/platform/s5p-tv/mixer.h
+++ b/drivers/media/platform/s5p-tv/mixer.h
@@ -300,7 +300,7 @@ void mxr_release_video(struct mxr_device *mdev);
 struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx);
 struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx);
 struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
-   int idx, char *name, struct mxr_layer_ops *ops);
+   int idx, char *name, const struct mxr_layer_ops *ops);
 
 void mxr_base_layer_release(struct mxr_layer *layer);
 void mxr_layer_release(struct mxr_layer *layer);
diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c 
b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
index db3163b..d4d2564 100644
--- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
+++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
@@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device 
*mdev, int idx)
 {
struct mxr_layer *layer;
int ret;
-   struct mxr_layer_ops ops = {
+   const struct mxr_layer_ops ops = {
.release = mxr_graph_layer_release,
.buffer_set = mxr_graph_buffer_set,
.stream_set = mxr_graph_stream_set,
diff --git a/drivers/media/platform/s5p-tv/mixer_video.c 
b/drivers/media/platform/s5p-tv/mixer_video.c
index dc1c679..abcc36a 100644
--- a/drivers/media/platform/s5p-tv/mixer_video.c
+++ b/drivers/media/platform/s5p-tv/mixer_video.c
@@ -1070,7 +1070,7 @@ static void mxr_vfd_release(struct video_device *vdev)
 }
 
 struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
-   int idx, char *name, struct mxr_layer_ops *ops)
+   int idx, char *name, const struct mxr_layer_ops *ops)
 {
struct mxr_layer *layer;
 
diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c 
b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
index dd002a4..6fa6f67 100644
--- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
+++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
@@ -207,7 +207,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device 
*mdev, int idx)
 {
struct mxr_layer *layer;
int ret;
-   struct mxr_layer_ops ops = {
+   const struct mxr_layer_ops ops = {
.release = mxr_vp_layer_release,
.buffer_set = mxr_vp_buffer_set,
.stream_set = mxr_vp_stream_set,

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] netup_unidvb: delete null dereference

2015-10-17 Thread Julia Lawall
The calls to dev_dbg will not work properly when spi is NULL.  Just use
pr_debug instead.

Problem found using scripts/coccinelle/null/deref_null.cocci

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/pci/netup_unidvb/netup_unidvb_spi.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c 
b/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c
index f55b327..026895f 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c
@@ -81,8 +81,7 @@ irqreturn_t netup_spi_interrupt(struct netup_spi *spi)
unsigned long flags;
 
if (!spi) {
-   dev_dbg(>master->dev,
-   "%s(): SPI not initialized\n", __func__);
+   pr_debug("%s(): SPI not initialized\n", __func__);
return IRQ_NONE;
}
spin_lock_irqsave(>lock, flags);
@@ -235,8 +234,7 @@ void netup_spi_release(struct netup_unidvb_dev *ndev)
struct netup_spi *spi = ndev->spi;
 
if (!spi) {
-   dev_dbg(>master->dev,
-   "%s(): SPI not initialized\n", __func__);
+   pr_debug("%s(): SPI not initialized\n", __func__);
return;
}
spin_lock_irqsave(>lock, flags);

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] delete null dereference

2015-10-17 Thread Julia Lawall
These patches delete NULL dereferences, as detected by
scripts/coccinelle/null/deref_null.cocci.

---

 drivers/media/pci/netup_unidvb/netup_unidvb_spi.c |6 ++
 net/nfc/netlink.c |6 ++
 2 files changed, 4 insertions(+), 8 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] mt9t001: constify v4l2_subdev_internal_ops structure

2015-10-11 Thread Julia Lawall
This v4l2_subdev_internal_ops structure is never modified.  All other
v4l2_subdev_internal_ops structures are declared as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/i2c/mt9t001.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index 8ae99f7..4383a5d 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -834,7 +834,7 @@ static struct v4l2_subdev_ops mt9t001_subdev_ops = {
.pad = _subdev_pad_ops,
 };
 
-static struct v4l2_subdev_internal_ops mt9t001_subdev_internal_ops = {
+static const struct v4l2_subdev_internal_ops mt9t001_subdev_internal_ops = {
.registered = mt9t001_registered,
.open = mt9t001_open,
.close = mt9t001_close,

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] media: videobuf2: fix compare_const_fl.cocci warnings

2015-11-13 Thread Julia Lawall
 Move constants to the right of binary operators.

Generated by: scripts/coccinelle/misc/compare_const_fl.cocci

CC: Junghak Sung <jh1009.s...@samsung.com>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
---

!b->m.planes could also be possible.  Up to you.

 videobuf2-v4l2.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -52,7 +52,7 @@ static int __verify_planes_array(struct
return 0;

/* Is memory for copying plane information present? */
-   if (NULL == b->m.planes) {
+   if (b->m.planes == NULL) {
dprintk(1, "multi-planar buffer passed but "
   "planes array not provided\n");
return -EINVAL;
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] drivers/media/usb/dvb-usb-v2: constify mxl111sf_demod_config structure

2015-11-13 Thread Julia Lawall
The mxl111sf_demod_config structure is never modified, so declare it
as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c |4 ++--
 drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h |4 ++--
 drivers/media/usb/dvb-usb-v2/mxl111sf.c   |2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c 
b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
index ea37536..84f6de6 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
@@ -35,7 +35,7 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info 
(or-able)).");
 struct mxl111sf_demod_state {
struct mxl111sf_state *mxl_state;
 
-   struct mxl111sf_demod_config *cfg;
+   const struct mxl111sf_demod_config *cfg;
 
struct dvb_frontend fe;
 };
@@ -579,7 +579,7 @@ static struct dvb_frontend_ops mxl111sf_demod_ops = {
 };
 
 struct dvb_frontend *mxl111sf_demod_attach(struct mxl111sf_state *mxl_state,
-  struct mxl111sf_demod_config *cfg)
+  const struct mxl111sf_demod_config *cfg)
 {
struct mxl111sf_demod_state *state = NULL;
 
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h 
b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
index 0bd83e5..7065aca 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
@@ -35,11 +35,11 @@ struct mxl111sf_demod_config {
 #if IS_ENABLED(CONFIG_DVB_USB_MXL111SF)
 extern
 struct dvb_frontend *mxl111sf_demod_attach(struct mxl111sf_state *mxl_state,
-  struct mxl111sf_demod_config *cfg);
+  const struct mxl111sf_demod_config *cfg);
 #else
 static inline
 struct dvb_frontend *mxl111sf_demod_attach(struct mxl111sf_state *mxl_state,
-  struct mxl111sf_demod_config *cfg)
+  const struct mxl111sf_demod_config *cfg)
 {
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
return NULL;
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c 
b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index bec12b0..c4a4a99 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -731,7 +731,7 @@ fail:
return ret;
 }
 
-static struct mxl111sf_demod_config mxl_demod_config = {
+static const struct mxl111sf_demod_config mxl_demod_config = {
.read_reg= mxl111sf_read_reg,
.write_reg   = mxl111sf_write_reg,
.program_regs= mxl111sf_ctrl_program_regs,

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] drivers/media/usb/as102: constify as102_priv_ops_t structure

2015-12-06 Thread Julia Lawall
The as102_priv_ops_t structure is never modified, so declare it as
const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/usb/as102/as102_drv.h |2 +-
 drivers/media/usb/as102/as102_usb_drv.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/as102/as102_drv.h 
b/drivers/media/usb/as102/as102_drv.h
index aee2d76..8def19d 100644
--- a/drivers/media/usb/as102/as102_drv.h
+++ b/drivers/media/usb/as102/as102_drv.h
@@ -52,7 +52,7 @@ struct as10x_bus_adapter_t {
struct as10x_cmd_t *cmd, *rsp;
 
/* bus adapter private ops callback */
-   struct as102_priv_ops_t *ops;
+   const struct as102_priv_ops_t *ops;
 };
 
 struct as102_dev_t {
diff --git a/drivers/media/usb/as102/as102_usb_drv.c 
b/drivers/media/usb/as102/as102_usb_drv.c
index 3f66906..0e8030c 100644
--- a/drivers/media/usb/as102/as102_usb_drv.c
+++ b/drivers/media/usb/as102/as102_usb_drv.c
@@ -189,7 +189,7 @@ static int as102_read_ep2(struct as10x_bus_adapter_t 
*bus_adap,
return actual_len;
 }
 
-static struct as102_priv_ops_t as102_priv_ops = {
+static const struct as102_priv_ops_t as102_priv_ops = {
.upload_fw_pkt  = as102_send_ep1,
.xfer_cmd   = as102_usb_xfer_cmd,
.as102_read_ep2 = as102_read_ep2,

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] constify stv6110x_devctl structure

2015-12-06 Thread Julia Lawall
The stv6110x_devctl structure is never modified, so declare is as
const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/dvb-frontends/stv6110x.c   |4 ++--
 drivers/media/dvb-frontends/stv6110x.h   |4 ++--
 drivers/media/dvb-frontends/stv6110x_priv.h  |2 +-
 drivers/media/pci/ddbridge/ddbridge-core.c   |2 +-
 drivers/media/pci/ngene/ngene-cards.c|2 +-
 drivers/media/pci/ttpci/budget.c |4 ++--
 drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c |2 +-
 drivers/media/usb/dvb-usb/technisat-usb2.c   |2 +-
 8 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv6110x.c 
b/drivers/media/dvb-frontends/stv6110x.c
index e66154e..a62c01e 100644
--- a/drivers/media/dvb-frontends/stv6110x.c
+++ b/drivers/media/dvb-frontends/stv6110x.c
@@ -355,7 +355,7 @@ static struct dvb_tuner_ops stv6110x_ops = {
.release= stv6110x_release
 };
 
-static struct stv6110x_devctl stv6110x_ctl = {
+static const struct stv6110x_devctl stv6110x_ctl = {
.tuner_init = stv6110x_init,
.tuner_sleep= stv6110x_sleep,
.tuner_set_mode = stv6110x_set_mode,
@@ -369,7 +369,7 @@ static struct stv6110x_devctl stv6110x_ctl = {
.tuner_get_status   = stv6110x_get_status,
 };
 
-struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
+const struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
const struct stv6110x_config *config,
struct i2c_adapter *i2c)
 {
diff --git a/drivers/media/dvb-frontends/stv6110x.h 
b/drivers/media/dvb-frontends/stv6110x.h
index 9f7eb25..696b6e5 100644
--- a/drivers/media/dvb-frontends/stv6110x.h
+++ b/drivers/media/dvb-frontends/stv6110x.h
@@ -55,12 +55,12 @@ struct stv6110x_devctl {
 
 #if IS_REACHABLE(CONFIG_DVB_STV6110x)
 
-extern struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
+extern const struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
   const struct stv6110x_config 
*config,
   struct i2c_adapter *i2c);
 
 #else
-static inline struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
+static inline const struct stv6110x_devctl *stv6110x_attach(struct 
dvb_frontend *fe,
  const struct 
stv6110x_config *config,
  struct i2c_adapter *i2c)
 {
diff --git a/drivers/media/dvb-frontends/stv6110x_priv.h 
b/drivers/media/dvb-frontends/stv6110x_priv.h
index 0ec936a..a993aba 100644
--- a/drivers/media/dvb-frontends/stv6110x_priv.h
+++ b/drivers/media/dvb-frontends/stv6110x_priv.h
@@ -70,7 +70,7 @@ struct stv6110x_state {
const struct stv6110x_config*config;
u8  regs[8];
 
-   struct stv6110x_devctl  *devctl;
+   const struct stv6110x_devctl*devctl;
 };
 
 #endif /* __STV6110x_PRIV_H */
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index fba5b40..17f56a8 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -690,7 +690,7 @@ static int tuner_attach_stv6110(struct ddb_input *input, 
int type)
struct stv090x_config *feconf = type ? _aa : 
struct stv6110x_config *tunerconf = (input->nr & 1) ?
 : 
-   struct stv6110x_devctl *ctl;
+   const struct stv6110x_devctl *ctl;
 
ctl = dvb_attach(stv6110x_attach, input->fe, tunerconf, i2c);
if (!ctl) {
diff --git a/drivers/media/pci/ngene/ngene-cards.c 
b/drivers/media/pci/ngene/ngene-cards.c
index 039bed3..4e783a6 100644
--- a/drivers/media/pci/ngene/ngene-cards.c
+++ b/drivers/media/pci/ngene/ngene-cards.c
@@ -57,7 +57,7 @@ static int tuner_attach_stv6110(struct ngene_channel *chan)
chan->dev->card_info->fe_config[chan->number];
struct stv6110x_config *tunerconf = (struct stv6110x_config *)
chan->dev->card_info->tuner_config[chan->number];
-   struct stv6110x_devctl *ctl;
+   const struct stv6110x_devctl *ctl;
 
/* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
if (chan->number < 2)
diff --git a/drivers/media/pci/ttpci/budget.c b/drivers/media/pci/ttpci/budget.c
index 99972be..b44639c 100644
--- a/drivers/media/pci/ttpci/budget.c
+++ b/drivers/media/pci/ttpci/budget.c
@@ -644,7 +644,7 @@ static void frontend_init(struct budget *budget)
}
 
case 0x101c: { /* TT S2-1600 */
-   struct stv6110x_devctl *ctl;
+   const struct stv6110x_devctl *ctl;

[PATCH] [media] go7007: constify go7007_hpi_ops structures

2015-12-11 Thread Julia Lawall
The go7007_hpi_ops structures are never modified, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/pci/saa7134/saa7134-go7007.c |2 +-
 drivers/media/usb/go7007/go7007-priv.h |2 +-
 drivers/media/usb/go7007/go7007-usb.c  |4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/go7007/go7007-priv.h 
b/drivers/media/usb/go7007/go7007-priv.h
index 745185e..bebee8c 100644
--- a/drivers/media/usb/go7007/go7007-priv.h
+++ b/drivers/media/usb/go7007/go7007-priv.h
@@ -250,7 +250,7 @@ struct go7007 {
struct i2c_adapter i2c_adapter;
 
/* HPI driver */
-   struct go7007_hpi_ops *hpi_ops;
+   const struct go7007_hpi_ops *hpi_ops;
void *hpi_context;
int interrupt_available;
wait_queue_head_t interrupt_waitq;
diff --git a/drivers/media/usb/go7007/go7007-usb.c 
b/drivers/media/usb/go7007/go7007-usb.c
index 3dbf14c..14d3f8c 100644
--- a/drivers/media/usb/go7007/go7007-usb.c
+++ b/drivers/media/usb/go7007/go7007-usb.c
@@ -932,7 +932,7 @@ static void go7007_usb_release(struct go7007 *go)
kfree(go->hpi_context);
 }
 
-static struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
+static const struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
.interface_reset= go7007_usb_interface_reset,
.write_interrupt= go7007_usb_ezusb_write_interrupt,
.read_interrupt = go7007_usb_read_interrupt,
@@ -942,7 +942,7 @@ static struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
.release= go7007_usb_release,
 };
 
-static struct go7007_hpi_ops go7007_usb_onboard_hpi_ops = {
+static const struct go7007_hpi_ops go7007_usb_onboard_hpi_ops = {
.interface_reset= go7007_usb_interface_reset,
.write_interrupt= go7007_usb_onboard_write_interrupt,
.read_interrupt = go7007_usb_read_interrupt,
diff --git a/drivers/media/pci/saa7134/saa7134-go7007.c 
b/drivers/media/pci/saa7134/saa7134-go7007.c
index 8a2abb3..2799538 100644
--- a/drivers/media/pci/saa7134/saa7134-go7007.c
+++ b/drivers/media/pci/saa7134/saa7134-go7007.c
@@ -378,7 +378,7 @@ static int saa7134_go7007_send_firmware(struct go7007 *go, 
u8 *data, int len)
return 0;
 }
 
-static struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
+static const struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
.interface_reset= saa7134_go7007_interface_reset,
.write_interrupt= saa7134_go7007_write_interrupt,
.read_interrupt = saa7134_go7007_read_interrupt,

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] av7110: constify sp8870_config structure

2016-01-03 Thread Julia Lawall
This sp8870_config structure is never modified, so declare it as
const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/pci/ttpci/av7110.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
index a69dc6a..18d229f 100644
--- a/drivers/media/pci/ttpci/av7110.c
+++ b/drivers/media/pci/ttpci/av7110.c
@@ -1739,7 +1739,7 @@ static int alps_tdlb7_request_firmware(struct 
dvb_frontend* fe, const struct fir
 #endif
 }
 
-static struct sp8870_config alps_tdlb7_config = {
+static const struct sp8870_config alps_tdlb7_config = {
 
.demod_address = 0x71,
.request_firmware = alps_tdlb7_request_firmware,

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media: bt8xx: constify sp887x_config structure

2016-01-03 Thread Julia Lawall
This sp887x_config structure is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
This patch and the previous one on the same file can be applied in any order.

 drivers/media/pci/bt8xx/dvb-bt8xx.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c 
b/drivers/media/pci/bt8xx/dvb-bt8xx.c
index d407244..a3aa0cd 100644
--- a/drivers/media/pci/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c
@@ -318,7 +318,7 @@ static int microtune_mt7202dtf_request_firmware(struct 
dvb_frontend* fe, const s
return request_firmware(fw, name, >bt->dev->dev);
 }
 
-static struct sp887x_config microtune_mt7202dtf_config = {
+static const struct sp887x_config microtune_mt7202dtf_config = {
.demod_address = 0x70,
.request_firmware = microtune_mt7202dtf_request_firmware,
 };

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media: bt8xx: constify or51211_config structure

2016-01-03 Thread Julia Lawall
The or51211_config structure is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/pci/bt8xx/dvb-bt8xx.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c 
b/drivers/media/pci/bt8xx/dvb-bt8xx.c
index d407244..8aeb14c 100644
--- a/drivers/media/pci/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c
@@ -458,7 +458,7 @@ static void or51211_sleep(struct dvb_frontend * fe)
bttv_write_gpio(bt->bttv_nr, 0x0001, 0x);
 }
 
-static struct or51211_config or51211_config = {
+static const struct or51211_config or51211_config = {
.demod_address = 0x15,
.request_firmware = or51211_request_firmware,
.setmode = or51211_setmode,

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] drivers/media/usb/dvb-usb-v2: constify mxl111sf_tuner_config structure

2016-01-03 Thread Julia Lawall
This mxl111sf_tuner_config structure is never modified, so declare it as
const.

There are some indentation changes to remain within 80 columns.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c |6 +++---
 drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h |8 
 drivers/media/usb/dvb-usb-v2/mxl111sf.c   |2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c 
b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
index 444579b..7d16252 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
@@ -36,7 +36,7 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info 
(or-able)).");
 struct mxl111sf_tuner_state {
struct mxl111sf_state *mxl_state;
 
-   struct mxl111sf_tuner_config *cfg;
+   const struct mxl111sf_tuner_config *cfg;
 
enum mxl_if_freq if_freq;
 
@@ -489,8 +489,8 @@ static struct dvb_tuner_ops mxl111sf_tuner_tuner_ops = {
 };
 
 struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe,
-  struct mxl111sf_state *mxl_state,
-  struct mxl111sf_tuner_config *cfg)
+   struct mxl111sf_state *mxl_state,
+   const struct mxl111sf_tuner_config *cfg)
 {
struct mxl111sf_tuner_state *state = NULL;
 
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h 
b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
index e6caab2..509b550 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
@@ -63,13 +63,13 @@ struct mxl111sf_tuner_config {
 #if IS_ENABLED(CONFIG_DVB_USB_MXL111SF)
 extern
 struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe,
-  struct mxl111sf_state *mxl_state,
-  struct mxl111sf_tuner_config *cfg);
+   struct mxl111sf_state *mxl_state,
+   const struct mxl111sf_tuner_config *cfg);
 #else
 static inline
 struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe,
-  struct mxl111sf_state *mxl_state,
-  struct mxl111sf_tuner_config *cfg)
+   struct mxl111sf_state *mxl_state,
+   const struct mxl111sf_tuner_config *cfg)
 {
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
return NULL;
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c 
b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index b669dec..b586e17 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -856,7 +856,7 @@ static int mxl111sf_ant_hunt(struct dvb_frontend *fe)
return 0;
 }
 
-static struct mxl111sf_tuner_config mxl_tuner_config = {
+static const struct mxl111sf_tuner_config mxl_tuner_config = {
.if_freq = MXL_IF_6_0, /* applies to external IF output, only */
.invert_spectrum = 0,
.read_reg= mxl111sf_read_reg,

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq

2015-12-26 Thread Julia Lawall
The error return value of platform_get_irq seems to often get dropped.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---

v2: Check for the direct return case also.  Added some mailing lists of
common offenders.

diff --git a/scripts/coccinelle/api/platform_get_irq_return.cocci 
b/scripts/coccinelle/api/platform_get_irq_return.cocci
new file mode 100644
index 000..44680d0
--- /dev/null
+++ b/scripts/coccinelle/api/platform_get_irq_return.cocci
@@ -0,0 +1,58 @@
+/// Propagate the return value of platform_get_irq.
+//# Sometimes the return value of platform_get_irq is tested using <= 0, but 0
+//# might not be an appropriate return value in an error case.
+///
+// Confidence: Moderate
+// Copyright: (C) 2015 Julia Lawall, Inria. GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Options: --no-includes --include-headers
+
+virtual context
+virtual org
+virtual report
+
+// 
+
+@r depends on context || org || report@
+constant C;
+statement S;
+expression e, ret;
+position j0, j1;
+@@
+
+* e@j0 = platform_get_irq(...);
+(
+if@j1 (...) {
+  ...
+  return -C;
+} else S
+|
+if@j1 (...) {
+  ...
+  ret = -C;
+  ...
+  return ret;
+} else S
+)
+
+// 
+
+@script:python r_org depends on org@
+j0 << r.j0;
+j1 << r.j1;
+@@
+
+msg = "Propagate return value of platform_get_irq."
+coccilib.org.print_todo(j0[0], msg)
+coccilib.org.print_link(j1[0], "")
+
+// 
+
+@script:python r_report depends on report@
+j0 << r.j0;
+j1 << r.j1;
+@@
+
+msg = "Propagate return value of platform_get_irq around line %s." % 
(j1[0].line)
+coccilib.report.print_report(j0[0], msg)
+
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq

2015-12-26 Thread Julia Lawall
On Sun, 27 Dec 2015, Sergei Shtylyov wrote:

> On 12/26/2015 11:58 PM, Julia Lawall wrote:
> 
> > The error return value of platform_get_irq seems to often get dropped.
> > 
> > Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
> > 
> > ---
> > 
> > v2: Check for the direct return case also.  Added some mailing lists of
> > common offenders.
> > 
> > diff --git a/scripts/coccinelle/api/platform_get_irq_return.cocci
> > b/scripts/coccinelle/api/platform_get_irq_return.cocci
> > new file mode 100644
> > index 000..44680d0
> > --- /dev/null
> > +++ b/scripts/coccinelle/api/platform_get_irq_return.cocci
> > @@ -0,0 +1,58 @@
> > +/// Propagate the return value of platform_get_irq.
> > +//# Sometimes the return value of platform_get_irq is tested using <= 0,
> > but 0
> > +//# might not be an appropriate return value in an error case.
> > +///
> > +// Confidence: Moderate
> > +// Copyright: (C) 2015 Julia Lawall, Inria. GPLv2.
> > +// URL: http://coccinelle.lip6.fr/
> > +// Options: --no-includes --include-headers
> > +
> > +virtual context
> > +virtual org
> > +virtual report
> > +
> > +//
> > 
> > +
> > +@r depends on context || org || report@
> > +constant C;
> > +statement S;
> > +expression e, ret;
> > +position j0, j1;
> > +@@
> > +
> > +* e@j0 = platform_get_irq(...);
> > +(
> > +if@j1 (...) {
> > +  ...
> > +  return -C;
> > +} else S
> > +|
> > +if@j1 (...) {
> > +  ...
> > +  ret = -C;
> > +  ...
> > +  return ret;
> > +} else S
> 
>Well, this seems to also cover the (e <= 0) checks which do make same sense
> in the light of Linus considering IRQ0 invalid. So I'd be more specific about
> the checks here -- 0 should indeed be overridden with something if it's
> considered invalid.

That's what the limitations section says (lines with #).  This doesn't 
make any changes, it only makes warnings, which should include the 
limitations information, so perhaps people can consider what it is that 
they really intend to do.

If you think this is not a good idea, then I can make the test more 
specific.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Cocci] [PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq

2015-12-27 Thread Julia Lawall


On Sun, 27 Dec 2015, SF Markus Elfring wrote:

> > The error return value of platform_get_irq seems to often get dropped.
> 
> How do you think about any more fine-tuning here?
> 
> Commit message:
> * … of the platform_get_irq() function seems to get dropped too often.
> 
> * Why do you concentrate on a single function name?
>   Do you plan to extend this source code analysis approach?
> 
> 
> > +@script:python r_report depends on report@
> > +j0 << r.j0;
> > +j1 << r.j1;
> > +@@
> > +
> > +msg = "Propagate return value of platform_get_irq around line %s." % 
> > (j1[0].line)
> 
> Are there more unchecked return values which are interesting
> for further considerations?
> https://cwe.mitre.org/data/definitions/252.html

The value is not unchecked.  I made a specific rule because the specific 
problem is quite common.

julia

Re: [PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq

2015-12-26 Thread Julia Lawall
>Well, looking again, the patch should be good. I just thought its goal was
> to fix the code as well...

I could do that for the irq < 0 case, but I think that in that case, kbuild
will only run the patch version, and the <= cases will not be reported on.
I don't have a general fix for the <= 0.  Is it even correct to have < in
some cases and <= in others?

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection

2015-12-28 Thread Julia Lawall


On Mon, 28 Dec 2015, SF Markus Elfring wrote:

> >> Move the jump label directly before the desired log statement
> >> so that the variable "ret" will not be checked once more
> >> after it was determined that a function call failed.
> >
> > Why not avoid both unnecessary ifs
>
> I would find such a fine-tuning also nice in principle at more source code 
> places.
>
>
> > and the enormous ugliness of a label inside an if by making two returns:
> > a return 0 for success and a dev_dbg and return ret for failure?
>
> How should your suggestion finally work when the desired execution success
> can be determined for such functions only after several other calls succeeded?

Not idea what this means, but immediate return 0 followed by various code
for reacting to an error is very common, so it looks like it should be
possible here.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection

2015-12-28 Thread Julia Lawall
On Mon, 28 Dec 2015, SF Markus Elfring wrote:

> From: Markus Elfring 
> Date: Mon, 28 Dec 2015 10:10:34 +0100
>
> This issue was detected by using the Coccinelle software.
>
> Move the jump label directly before the desired log statement
> so that the variable "ret" will not be checked once more
> after it was determined that a function call failed.

Why not avoid both unnecessary ifs and the enormous ugliness of a label
inside an if by making two returns: a return 0 for success and a dev_dbg
and return ret for failure?

julia


> Signed-off-by: Markus Elfring 
> ---
>  drivers/media/tuners/m88rs6000t.c | 16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/tuners/m88rs6000t.c 
> b/drivers/media/tuners/m88rs6000t.c
> index 504bfbc..b45594e 100644
> --- a/drivers/media/tuners/m88rs6000t.c
> +++ b/drivers/media/tuners/m88rs6000t.c
> @@ -510,27 +510,27 @@ static int m88rs6000t_get_rf_strength(struct 
> dvb_frontend *fe, u16 *strength)
>
>   ret = regmap_read(dev->regmap, 0x5A, );
>   if (ret)
> - goto err;
> + goto report_failure;
>   RF_GC = val & 0x0f;
>
>   ret = regmap_read(dev->regmap, 0x5F, );
>   if (ret)
> - goto err;
> + goto report_failure;
>   IF_GC = val & 0x0f;
>
>   ret = regmap_read(dev->regmap, 0x3F, );
>   if (ret)
> - goto err;
> + goto report_failure;
>   TIA_GC = (val >> 4) & 0x07;
>
>   ret = regmap_read(dev->regmap, 0x77, );
>   if (ret)
> - goto err;
> + goto report_failure;
>   BB_GC = (val >> 4) & 0x0f;
>
>   ret = regmap_read(dev->regmap, 0x76, );
>   if (ret)
> - goto err;
> + goto report_failure;
>   PGA2_GC = val & 0x3f;
>   PGA2_cri = PGA2_GC >> 2;
>   PGA2_crf = PGA2_GC & 0x03;
> @@ -562,9 +562,11 @@ static int m88rs6000t_get_rf_strength(struct 
> dvb_frontend *fe, u16 *strength)
>   /* scale value to 0x-0x */
>   gain = clamp_val(gain, 1000U, 10500U);
>   *strength = (10500 - gain) * 0x / (10500 - 1000);
> -err:
> - if (ret)
> +
> + if (ret) {
> +report_failure:
>   dev_dbg(>client->dev, "failed=%d\n", ret);
> + }
>   return ret;
>  }
>
> --
> 2.6.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media] m88rs6000t: Better exception handling in five functions

2015-12-28 Thread Julia Lawall
On Mon, 28 Dec 2015, SF Markus Elfring wrote:

> >> Move the jump label directly before the desired log statement
> >> so that the variable "ret" will not be checked once more
> >> after a function call.
> >
> > This commit message fits with the previous change.
>
> Do you prefer an other wording?

Something like "Split the return into success and error cases, to avoid
the need for testing before logging."

The concept of the return being duplicated didn't come across in your
message.

> > It could be nice to put a blank line before the error handling code.
>
> Is it really a coding style requirement to insert another blank line between
> the suggested placement of the statement "return 0;" and the jump label?

I don't think it is a requirement.  But some files do it, and if other
functions in this file do it, then it would be nice to do the same.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions

2015-12-28 Thread Julia Lawall


On Mon, 28 Dec 2015, SF Markus Elfring wrote:

> From: Markus Elfring <elfr...@users.sourceforge.net>
> Date: Mon, 28 Dec 2015 15:10:30 +0100
>
> This issue was detected by using the Coccinelle software.
>
> Move the jump label directly before the desired log statement
> so that the variable "ret" will not be checked once more
> after a function call.

This commit message fits with the previous change.

It could be nice to put a blank line before the error handling code.  See
what is done elsewhere in the file.

julia

>
> Suggested-by: Julia Lawall <julia.law...@lip6.fr>
> Signed-off-by: Markus Elfring <elfr...@users.sourceforge.net>
> ---
>  drivers/media/tuners/m88rs6000t.c | 154 
> +++---
>  1 file changed, 78 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/media/tuners/m88rs6000t.c 
> b/drivers/media/tuners/m88rs6000t.c
> index 504bfbc..7e59a9f 100644
> --- a/drivers/media/tuners/m88rs6000t.c
> +++ b/drivers/media/tuners/m88rs6000t.c
> @@ -44,7 +44,7 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend 
> *fe)
>   /* select demod main mclk */
>   ret = regmap_read(dev->regmap, 0x15, );
>   if (ret)
> - goto err;
> + goto report_failure;
>   reg15 = utmp;
>   if (c->symbol_rate > 4501) {
>   reg11 = 0x0E;
> @@ -106,7 +106,7 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend 
> *fe)
>
>   ret = regmap_read(dev->regmap, 0x1D, );
>   if (ret)
> - goto err;
> + goto report_failure;
>   reg1D = utmp;
>   reg1D &= ~0x03;
>   reg1D |= N - 1;
> @@ -116,42 +116,42 @@ static int m88rs6000t_set_demod_mclk(struct 
> dvb_frontend *fe)
>   /* program and recalibrate demod PLL */
>   ret = regmap_write(dev->regmap, 0x05, 0x40);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x11, 0x08);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x15, reg15);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x16, reg16);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x1D, reg1D);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x1E, reg1E);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x1F, reg1F);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x17, 0xc1);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x17, 0x81);
>   if (ret)
> - goto err;
> + goto report_failure;
>   usleep_range(5000, 5);
>   ret = regmap_write(dev->regmap, 0x05, 0x00);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x11, reg11);
>   if (ret)
> - goto err;
> + goto report_failure;
>   usleep_range(5000, 5);
> -err:
> - if (ret)
> - dev_dbg(>client->dev, "failed=%d\n", ret);
> + return 0;
> +report_failure:
> + dev_dbg(>client->dev, "failed=%d\n", ret);
>   return ret;
>  }
>
> @@ -169,13 +169,13 @@ static int m88rs6000t_set_pll_freq(struct 
> m88rs6000t_dev *dev,
>
>   ret = regmap_write(dev->regmap, 0x36, (refDiv - 8));
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x31, 0x00);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x2c, 0x02);
>   if (ret)
> - goto err;
> + goto report_failure;
>
>   if (tuner_freq_MHz >= 1550) {
>   ucLoDiv1 = 2;
> @@ -227,105 +227,105 @@ static int m88rs6000t_set_pll_freq(struct 
> m88rs6000t_dev *dev,
>   reg27 = (((ulNDiv1 >> 8) & 0x0F) + ucLomod1) & 0x7F;
>   ret = regmap_write(dev->regmap, 0x27, reg27);
>   if (ret)
> - goto err;
> + goto report_failure;
>   ret = regmap_write(dev->regmap, 0x28, (u8)(ulNDiv1 & 0xFF));
>   if (ret)
> - goto err;

Re: On Lindent shortcomings and massive style fixing

2015-12-29 Thread Julia Lawall


On Tue, 29 Dec 2015, Andrey Utkin wrote:

> On Tue, Dec 29, 2015 at 9:32 AM, Mauro Carvalho Chehab
>  wrote:
> > IMHO, there are two problems by letting indent breaking long
> > lines:
> >
> > 1) indent would break strings on printks. This is something that we don't
> > want to break strings on multiple lines in the Kernel;
>
> Yeah, GNU indent does its work badly (although I believe it could be
> taught to respect long literals), this makes me want to have a better
> tool for clean "relayouting" C code.
> I believe that'd require at last a proper syntax parser. With such
> tool, it would be straightforward to rewrite source code automatically
> to please any demanding reviewer of code style, except for issues of
> higher level of thought (like naming or nesting limitations).
>
> > 2) It doesn't actually solve the problem of having too complex loops,
> > with is why the 80 columns warning is meant to warn. Worse than that,
> > if a piece of code is inside more than 4 or 5 indentation levels, the
> > resulting code of using indent for 80-cols line break is a total crap.
>
> Then I'd propose to enforce nesting limitation explicitly, because
> Documentation/CodingStyle appreciates low nesting, just doesn't give
> exact numbers.
> It's better this way, because the programmer could pay attention to N
> places of excessive nesting and fix it manually, and then carelessly
> reformat NNN places of "80 chars" issues automatically, comparing to
> reviewing all NNN places, to figure out if there's excessive nesting,
> or not.
> (CCed checkpatch.pl maintainers.)

Personally, I prefer to see only 80 characters per line, as long as it
doesn't require contorting the code in some other way.  So perhaps not
everyone would agree that the issue is only the amount of nesting.

julia

> > That's said, on a quick look at the driver, it seems that the 80-cols
> > violations are mostly (if not all) on the comments, like:
> >
> > int i_poc_lsb = (frame_seqno_in_gop << 1); /* why multiplied by 
> > two? TODO try without multiplication */
> >
> > and
> >
> > #define TW5864_UNDEF_REG_0x0224 0x0224  /* Undeclared in spec (or not yet 
> > added to tw5864-reg.h) but used */
> > #define TW5864_UNDEF_REG_0x4014 0x4014  /* Undeclared in spec (or not yet 
> > added to tw5864-reg.h) but used */
> > #define TW5864_UNDEF_REG_0xA800 0xA800  /* Undeclared in spec (or not yet 
> > added to tw5864-reg.h) but used */
> >
> > Btw, the content of tw5864-reg-undefined.h is weird... Why not just
> > add the stuff there at tw5864-reg.h and remove the comments for all
> > defines there?
>
> tw5864-reg-undefined.h will be edited for sure (maybe dropped), of
> course it won't stay as it is now.
> It was generated by script during reverse-engineering that bastard
> chip from hell.
>
> > Also, Lindent already did some crappy 80-cols like breaks, like:
> >
> > static int pci_i2c_multi_read(struct tw5864_dev *dev, u8 devid, u8 devfn, 
> > u8 *buf,
> >u32 count)
> >
> > (count is misaligned with the open parenthesis)
>
> I just added "static " after indenting.
> Actually, Documentation/CodingStyle says nothing about alignment of
> function declaration tail on open parenthesis.
> Also I'd like to mention that I hate such alignment, because it
> requires intermixing of tabs and spaces. I am not aware if this is K
> thing or not. If it is, then please don't kill me.
>
> Thanks for kind replies, gentlemen.
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] s5p-mfc: constify s5p_mfc_codec_ops structures

2015-11-21 Thread Julia Lawall
The s5p_mfc_codec_ops structures are never modified, so declare them as
const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c|4 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.h|2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|4 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.h|2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index d1a3f9b..e90ad7e 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -653,7 +653,7 @@ struct s5p_mfc_ctx {
unsigned int bits;
} slice_size;
 
-   struct s5p_mfc_codec_ops *c_ops;
+   const struct s5p_mfc_codec_ops *c_ops;
 
struct v4l2_ctrl *ctrls[MFC_MAX_CTRLS];
struct v4l2_ctrl_handler ctrl_handler;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 1c4998c..e741550 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -252,7 +252,7 @@ static int s5p_mfc_ctx_ready(struct s5p_mfc_ctx *ctx)
return 0;
 }
 
-static struct s5p_mfc_codec_ops decoder_codec_ops = {
+static const struct s5p_mfc_codec_ops decoder_codec_ops = {
.pre_seq_start  = NULL,
.post_seq_start = NULL,
.pre_frame_start= NULL,
@@ -1104,7 +1104,7 @@ static struct vb2_ops s5p_mfc_dec_qops = {
.buf_queue  = s5p_mfc_buf_queue,
 };
 
-struct s5p_mfc_codec_ops *get_dec_codec_ops(void)
+const struct s5p_mfc_codec_ops *get_dec_codec_ops(void)
 {
return _codec_ops;
 }
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.h
index d06a7ca..886628b 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.h
@@ -13,7 +13,7 @@
 #ifndef S5P_MFC_DEC_H_
 #define S5P_MFC_DEC_H_
 
-struct s5p_mfc_codec_ops *get_dec_codec_ops(void);
+const struct s5p_mfc_codec_ops *get_dec_codec_ops(void);
 struct vb2_ops *get_dec_queue_ops(void);
 const struct v4l2_ioctl_ops *get_dec_v4l2_ioctl_ops(void);
 struct s5p_mfc_fmt *get_dec_def_fmt(bool src);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 115b7da..dec228f 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -936,7 +936,7 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
return 0;
 }
 
-static struct s5p_mfc_codec_ops encoder_codec_ops = {
+static const struct s5p_mfc_codec_ops encoder_codec_ops = {
.pre_seq_start  = enc_pre_seq_start,
.post_seq_start = enc_post_seq_start,
.pre_frame_start= enc_pre_frame_start,
@@ -2052,7 +2052,7 @@ static struct vb2_ops s5p_mfc_enc_qops = {
.buf_queue  = s5p_mfc_buf_queue,
 };
 
-struct s5p_mfc_codec_ops *get_enc_codec_ops(void)
+const struct s5p_mfc_codec_ops *get_enc_codec_ops(void)
 {
return _codec_ops;
 }
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.h
index 5118d46..d0d42f8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.h
@@ -13,7 +13,7 @@
 #ifndef S5P_MFC_ENC_H_
 #define S5P_MFC_ENC_H_
 
-struct s5p_mfc_codec_ops *get_enc_codec_ops(void);
+const struct s5p_mfc_codec_ops *get_enc_codec_ops(void);
 struct vb2_ops *get_enc_queue_ops(void);
 const struct v4l2_ioctl_ops *get_enc_v4l2_ioctl_ops(void);
 struct s5p_mfc_fmt *get_enc_def_fmt(bool src);

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media, sound: tea575x: constify snd_tea575x_ops structures

2015-11-22 Thread Julia Lawall
The snd_tea575x_ops structures are never modified, so declare them as
const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/pci/bt8xx/bttv-cards.c  |2 +-
 drivers/media/radio/radio-maxiradio.c |2 +-
 drivers/media/radio/radio-sf16fmr2.c  |2 +-
 drivers/media/radio/radio-shark.c |2 +-
 include/media/drv-intf/tea575x.h  |2 +-
 sound/pci/es1968.c|2 +-
 sound/pci/fm801.c |2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index cb38cd1..514f260 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2605,7 +2605,7 @@ static void snd_es1968_tea575x_set_direction(struct 
snd_tea575x *tea, bool outpu
}
 }
 
-static struct snd_tea575x_ops snd_es1968_tea_ops = {
+static const struct snd_tea575x_ops snd_es1968_tea_ops = {
.set_pins = snd_es1968_tea575x_set_pins,
.get_pins = snd_es1968_tea575x_get_pins,
.set_direction = snd_es1968_tea575x_set_direction,
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 5144a7f..759295a 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -815,7 +815,7 @@ static void snd_fm801_tea575x_set_direction(struct 
snd_tea575x *tea, bool output
fm801_writew(chip, GPIO_CTRL, reg);
 }
 
-static struct snd_tea575x_ops snd_fm801_tea_ops = {
+static const struct snd_tea575x_ops snd_fm801_tea_ops = {
.set_pins = snd_fm801_tea575x_set_pins,
.get_pins = snd_fm801_tea575x_get_pins,
.set_direction = snd_fm801_tea575x_set_direction,
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c 
b/drivers/media/pci/bt8xx/bttv-cards.c
index 7a08102..8a17cc0 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -3808,7 +3808,7 @@ static void bttv_tea575x_set_direction(struct snd_tea575x 
*tea, bool output)
gpio_inout(mask, (1 << gpio.clk) | (1 << gpio.wren));
 }
 
-static struct snd_tea575x_ops bttv_tea_ops = {
+static const struct snd_tea575x_ops bttv_tea_ops = {
.set_pins = bttv_tea575x_set_pins,
.get_pins = bttv_tea575x_get_pins,
.set_direction = bttv_tea575x_set_direction,
diff --git a/drivers/media/radio/radio-sf16fmr2.c 
b/drivers/media/radio/radio-sf16fmr2.c
index 8e4f1d1..dc81d42 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -82,7 +82,7 @@ static void fmr2_tea575x_set_direction(struct snd_tea575x 
*tea, bool output)
 {
 }
 
-static struct snd_tea575x_ops fmr2_tea_ops = {
+static const struct snd_tea575x_ops fmr2_tea_ops = {
.set_pins = fmr2_tea575x_set_pins,
.get_pins = fmr2_tea575x_get_pins,
.set_direction = fmr2_tea575x_set_direction,
diff --git a/include/media/drv-intf/tea575x.h b/include/media/drv-intf/tea575x.h
index 5d09657..fb272d4 100644
--- a/include/media/drv-intf/tea575x.h
+++ b/include/media/drv-intf/tea575x.h
@@ -63,7 +63,7 @@ struct snd_tea575x {
u32 band;   /* 0: FM, 1: FM-Japan, 2: AM */
u32 freq;   /* frequency */
struct mutex mutex;
-   struct snd_tea575x_ops *ops;
+   const struct snd_tea575x_ops *ops;
void *private_data;
u8 card[32];
u8 bus_info[32];
diff --git a/drivers/media/radio/radio-shark.c 
b/drivers/media/radio/radio-shark.c
index 409fac1..85667a9 100644
--- a/drivers/media/radio/radio-shark.c
+++ b/drivers/media/radio/radio-shark.c
@@ -150,7 +150,7 @@ static u32 shark_read_val(struct snd_tea575x *tea)
return val;
 }
 
-static struct snd_tea575x_ops shark_tea_ops = {
+static const struct snd_tea575x_ops shark_tea_ops = {
.write_val = shark_write_val,
.read_val  = shark_read_val,
 };
diff --git a/drivers/media/radio/radio-maxiradio.c 
b/drivers/media/radio/radio-maxiradio.c
index 41c1652..70fd8e8 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -108,7 +108,7 @@ static void maxiradio_tea575x_set_direction(struct 
snd_tea575x *tea, bool output
 {
 }
 
-static struct snd_tea575x_ops maxiradio_tea_ops = {
+static const struct snd_tea575x_ops maxiradio_tea_ops = {
.set_pins = maxiradio_tea575x_set_pins,
.get_pins = maxiradio_tea575x_get_pins,
.set_direction = maxiradio_tea575x_set_direction,

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] soc_camera: constify v4l2_subdev_sensor_ops structures

2015-11-22 Thread Julia Lawall
The v4l2_subdev_sensor_ops structures are never modified, so declare them
as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/i2c/soc_camera/mt9m001.c |2 +-
 drivers/media/i2c/soc_camera/mt9t031.c |2 +-
 drivers/media/i2c/soc_camera/mt9v022.c |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/mt9m001.c 
b/drivers/media/i2c/soc_camera/mt9m001.c
index 2e14e52..69becc3 100644
--- a/drivers/media/i2c/soc_camera/mt9m001.c
+++ b/drivers/media/i2c/soc_camera/mt9m001.c
@@ -632,7 +632,7 @@ static struct v4l2_subdev_video_ops 
mt9m001_subdev_video_ops = {
.s_mbus_config  = mt9m001_s_mbus_config,
 };
 
-static struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = {
+static const struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = {
.g_skip_top_lines   = mt9m001_g_skip_top_lines,
 };
 
diff --git a/drivers/media/i2c/soc_camera/mt9t031.c 
b/drivers/media/i2c/soc_camera/mt9t031.c
index 3b6eeed..5c8e3ff 100644
--- a/drivers/media/i2c/soc_camera/mt9t031.c
+++ b/drivers/media/i2c/soc_camera/mt9t031.c
@@ -728,7 +728,7 @@ static struct v4l2_subdev_video_ops 
mt9t031_subdev_video_ops = {
.s_mbus_config  = mt9t031_s_mbus_config,
 };
 
-static struct v4l2_subdev_sensor_ops mt9t031_subdev_sensor_ops = {
+static const struct v4l2_subdev_sensor_ops mt9t031_subdev_sensor_ops = {
.g_skip_top_lines   = mt9t031_g_skip_top_lines,
 };
 
diff --git a/drivers/media/i2c/soc_camera/mt9v022.c 
b/drivers/media/i2c/soc_camera/mt9v022.c
index c2ba1fb..2721e58 100644
--- a/drivers/media/i2c/soc_camera/mt9v022.c
+++ b/drivers/media/i2c/soc_camera/mt9v022.c
@@ -860,7 +860,7 @@ static struct v4l2_subdev_video_ops 
mt9v022_subdev_video_ops = {
.s_mbus_config  = mt9v022_s_mbus_config,
 };
 
-static struct v4l2_subdev_sensor_ops mt9v022_subdev_sensor_ops = {
+static const struct v4l2_subdev_sensor_ops mt9v022_subdev_sensor_ops = {
.g_skip_top_lines   = mt9v022_g_skip_top_lines,
 };
 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] cx231xx: constify cx2341x_handler_ops structures

2015-11-22 Thread Julia Lawall
The cx2341x_handler_ops structures are never modified, so declare them as
const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/pci/cx18/cx18-controls.c  |2 +-
 drivers/media/pci/cx18/cx18-controls.h  |2 +-
 drivers/media/pci/ivtv/ivtv-controls.c  |2 +-
 drivers/media/pci/ivtv/ivtv-controls.h  |2 +-
 drivers/media/usb/cx231xx/cx231xx-417.c |2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index f59a6f1..66b1b00 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1901,7 +1901,7 @@ static int cx231xx_s_audio_sampling_freq(struct 
cx2341x_handler *cxhdl, u32 idx)
return 0;
 }
 
-static struct cx2341x_handler_ops cx231xx_ops = {
+static const struct cx2341x_handler_ops cx231xx_ops = {
/* needed for the video clock freq */
.s_audio_sampling_freq = cx231xx_s_audio_sampling_freq,
/* needed for setting up the video resolution */
diff --git a/drivers/media/pci/cx18/cx18-controls.c 
b/drivers/media/pci/cx18/cx18-controls.c
index 71227a1..adb5a8c 100644
--- a/drivers/media/pci/cx18/cx18-controls.c
+++ b/drivers/media/pci/cx18/cx18-controls.c
@@ -126,7 +126,7 @@ static int cx18_s_audio_mode(struct cx2341x_handler *cxhdl, 
u32 val)
return 0;
 }
 
-struct cx2341x_handler_ops cx18_cxhdl_ops = {
+const struct cx2341x_handler_ops cx18_cxhdl_ops = {
.s_audio_mode = cx18_s_audio_mode,
.s_audio_sampling_freq = cx18_s_audio_sampling_freq,
.s_video_encoding = cx18_s_video_encoding,
diff --git a/drivers/media/pci/cx18/cx18-controls.h 
b/drivers/media/pci/cx18/cx18-controls.h
index cb5dfc7..3267948 100644
--- a/drivers/media/pci/cx18/cx18-controls.h
+++ b/drivers/media/pci/cx18/cx18-controls.h
@@ -21,4 +21,4 @@
  *  02111-1307  USA
  */
 
-extern struct cx2341x_handler_ops cx18_cxhdl_ops;
+extern const struct cx2341x_handler_ops cx18_cxhdl_ops;
diff --git a/drivers/media/pci/ivtv/ivtv-controls.c 
b/drivers/media/pci/ivtv/ivtv-controls.c
index 8a55ccb..9666ca0 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.c
+++ b/drivers/media/pci/ivtv/ivtv-controls.c
@@ -96,7 +96,7 @@ static int ivtv_s_audio_mode(struct cx2341x_handler *cxhdl, 
u32 val)
return 0;
 }
 
-struct cx2341x_handler_ops ivtv_cxhdl_ops = {
+const struct cx2341x_handler_ops ivtv_cxhdl_ops = {
.s_audio_mode = ivtv_s_audio_mode,
.s_audio_sampling_freq = ivtv_s_audio_sampling_freq,
.s_video_encoding = ivtv_s_video_encoding,
diff --git a/drivers/media/pci/ivtv/ivtv-controls.h 
b/drivers/media/pci/ivtv/ivtv-controls.h
index 3999e63..ea397ba 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.h
+++ b/drivers/media/pci/ivtv/ivtv-controls.h
@@ -21,7 +21,7 @@
 #ifndef IVTV_CONTROLS_H
 #define IVTV_CONTROLS_H
 
-extern struct cx2341x_handler_ops ivtv_cxhdl_ops;
+extern const struct cx2341x_handler_ops ivtv_cxhdl_ops;
 extern const struct v4l2_ctrl_ops ivtv_hdl_out_ops;
 int ivtv_g_pts_frame(struct ivtv *itv, s64 *pts, s64 *frame);
 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] atmel-isc: fix platform_no_drv_owner.cocci warnings

2016-04-13 Thread Julia Lawall
 Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

CC: Songjun Wu <songjun...@atmel.com>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
---

 atmel-isc.c |1 -
 1 file changed, 1 deletion(-)

--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -1524,7 +1524,6 @@ static struct platform_driver atmel_isc_
.remove  = atmel_isc_remove,
.driver  = {
.name   = ATMEL_ISC_NAME,
-   .owner  = THIS_MODULE,
.of_match_table = of_match_ptr(atmel_isc_of_match),
},
 };
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] atmel-isc: fix compare_const_fl.cocci warnings

2016-04-13 Thread Julia Lawall
Move constants to the right of binary operators.

Generated by: scripts/coccinelle/misc/compare_const_fl.cocci

CC: Songjun Wu <songjun...@atmel.com>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
---

Up to you.  Seems a tiny bit more readable to me not to have ISC_DCTRL and
ISC_DCTRL_IE_IS right together.

 atmel-isc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -639,7 +639,7 @@ static inline void isc_start_dma(struct

addr = vb2_dma_contig_plane_dma_addr(>vb.vb2_buf, 0);

-   regmap_write(regmap, ISC_DCTRL, ISC_DCTRL_IE_IS | dview);
+   regmap_write(regmap, ISC_DCTRL, dview | ISC_DCTRL_IE_IS);
regmap_write(regmap, ISC_DAD0, addr);
regmap_update_bits(regmap, ISC_CTRLEN,
   ISC_CTRLEN_CAPTURE_MASK, ISC_CTRLEN_CAPTURE);
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] VPU: mediatek: fix platform_no_drv_owner.cocci warnings

2016-04-22 Thread Julia Lawall
Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

CC: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
---

base:   git://linuxtv.org/media_tree.git master

 mtk_vpu.c |1 -
 1 file changed, 1 deletion(-)

--- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
@@ -939,7 +939,6 @@ static struct platform_driver mtk_vpu_dr
.remove = mtk_vpu_remove,
.driver = {
.name   = "mtk_vpu",
-   .owner  = THIS_MODULE,
.of_match_table = mtk_vpu_match,
},
 };
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] VPU: mediatek: fix simple_open.cocci warnings

2016-04-22 Thread Julia Lawall
Remove an open coded simple_open() function
and replace file operations references to the function
with simple_open() instead.

Generated by: scripts/coccinelle/api/simple_open.cocci

CC: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
---

I'm just passing this along.  Simple_open additionally has a check that
inode->i_private is not NULL, before doing the assignment.  I don't know
if that difference is important in this case.

base:   git://linuxtv.org/media_tree.git master

 mtk_vpu.c |7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

--- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
@@ -599,11 +599,6 @@ static void vpu_init_ipi_handler(void *d
 }

 #ifdef CONFIG_DEBUG_FS
-static int vpu_debug_open(struct inode *inode, struct file *file)
-{
-   file->private_data = inode->i_private;
-   return 0;
-}

 static ssize_t vpu_debug_read(struct file *file, char __user *user_buf,
  size_t count, loff_t *ppos)
@@ -646,7 +641,7 @@ static ssize_t vpu_debug_read(struct fil
 }

 static const struct file_operations vpu_debug_fops = {
-   .open = vpu_debug_open,
+   .open = simple_open,
.read = vpu_debug_read,
 };
 #endif /* CONFIG_DEBUG_FS */
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/7] fix typo

2016-05-17 Thread Julia Lawall


On Tue, 17 May 2016, Kalle Valo wrote:

> Julia Lawall <julia.law...@lip6.fr> writes:
>
> > firmare -> firmware
> >
> > ---
> >
> >  drivers/media/dvb-frontends/mn88473.c   |2 +-
> >  drivers/net/wireless/ath/ath6kl/core.h  |2 +-
> >  drivers/net/wireless/marvell/mwifiex/pcie.c |2 +-
>
> It would be good to know in advance what tree you are planning to submit
> these for. For example, should I take ath6kl and mwifiex patches or
> someone else?

I have no preference.  They are all independent in any case.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/7] fix typo

2016-05-17 Thread Julia Lawall
firmare -> firmware

---

 drivers/media/dvb-frontends/mn88473.c   |2 +-
 drivers/net/wireless/ath/ath6kl/core.h  |2 +-
 drivers/net/wireless/marvell/mwifiex/pcie.c |2 +-
 drivers/scsi/pm8001/pm8001_init.c   |2 +-
 drivers/scsi/snic/snic_fwint.h  |2 +-
 drivers/staging/media/mn88472/mn88472.c |2 +-
 drivers/staging/wilc1000/linux_wlan.c   |2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/7] [media] mn88472: fix typo

2016-05-17 Thread Julia Lawall
firmare -> firmware

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/staging/media/mn88472/mn88472.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 7ea749c..5cfa22a 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -312,7 +312,7 @@ static int mn88472_init(struct dvb_frontend *fe)
/* request the firmware, this will block and timeout */
ret = request_firmware(, fw_file, >dev);
if (ret) {
-   dev_err(>dev, "firmare file '%s' not found\n",
+   dev_err(>dev, "firmware file '%s' not found\n",
fw_file);
goto err;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/7] [media] mn88473: fix typo

2016-05-17 Thread Julia Lawall
firmare -> firmware

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/dvb-frontends/mn88473.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/mn88473.c 
b/drivers/media/dvb-frontends/mn88473.c
index 6c5d5921..8f7b68f 100644
--- a/drivers/media/dvb-frontends/mn88473.c
+++ b/drivers/media/dvb-frontends/mn88473.c
@@ -330,7 +330,7 @@ static int mn88473_init(struct dvb_frontend *fe)
/* Request the firmware, this will block and timeout */
ret = request_firmware(, name, >dev);
if (ret) {
-   dev_err(>dev, "firmare file '%s' not found\n", name);
+   dev_err(>dev, "firmware file '%s' not found\n", name);
goto err;
}
 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] mtk-vcodec: constify venc_common_if structures

2016-08-09 Thread Julia Lawall
The venc_common_if structures are never modified, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h|2 +-
 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c |6 +++---
 drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c  |6 +++---
 drivers/media/platform/mtk-vcodec/venc_drv_if.c   |4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 94f0a42..b0cb3ed 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -240,7 +240,7 @@ struct mtk_vcodec_ctx {
enum mtk_encode_param param_change;
struct mtk_enc_params enc_params;
 
-   struct venc_common_if *enc_if;
+   const struct venc_common_if *enc_if;
unsigned long drv_handle;
 
int int_cond;
diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c 
b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
index 9a60052..532cd36 100644
--- a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
@@ -664,16 +664,16 @@ static int h264_enc_deinit(unsigned long handle)
return ret;
 }
 
-static struct venc_common_if venc_h264_if = {
+static const struct venc_common_if venc_h264_if = {
h264_enc_init,
h264_enc_encode,
h264_enc_set_param,
h264_enc_deinit,
 };
 
-struct venc_common_if *get_h264_enc_comm_if(void);
+const struct venc_common_if *get_h264_enc_comm_if(void);
 
-struct venc_common_if *get_h264_enc_comm_if(void)
+const struct venc_common_if *get_h264_enc_comm_if(void)
 {
return _h264_if;
 }
diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
index 60bbcd2..bdf6780 100644
--- a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
@@ -471,16 +471,16 @@ static int vp8_enc_deinit(unsigned long handle)
return ret;
 }
 
-static struct venc_common_if venc_vp8_if = {
+static const struct venc_common_if venc_vp8_if = {
vp8_enc_init,
vp8_enc_encode,
vp8_enc_set_param,
vp8_enc_deinit,
 };
 
-struct venc_common_if *get_vp8_enc_comm_if(void);
+const struct venc_common_if *get_vp8_enc_comm_if(void);
 
-struct venc_common_if *get_vp8_enc_comm_if(void)
+const struct venc_common_if *get_vp8_enc_comm_if(void)
 {
return _vp8_if;
 }
diff --git a/drivers/media/platform/mtk-vcodec/venc_drv_if.c 
b/drivers/media/platform/mtk-vcodec/venc_drv_if.c
index c4c83e7..d02d5f1 100644
--- a/drivers/media/platform/mtk-vcodec/venc_drv_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc_drv_if.c
@@ -26,8 +26,8 @@
 #include "mtk_vcodec_enc_pm.h"
 #include "mtk_vpu.h"
 
-struct venc_common_if *get_h264_enc_comm_if(void);
-struct venc_common_if *get_vp8_enc_comm_if(void);
+const struct venc_common_if *get_h264_enc_comm_if(void);
+const struct venc_common_if *get_vp8_enc_comm_if(void);
 
 int venc_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
 {

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] vcodec: mediatek: fix odd_ptr_err.cocci warnings

2016-09-06 Thread Julia Lawall
PTR_ERR should access the value just tested by IS_ERR

Generated by: scripts/coccinelle/tests/odd_ptr_err.cocci

CC: Tiffany Lin <tiffany@mediatek.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
---

 mtk_vcodec_dec_drv.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -255,7 +255,7 @@ static int mtk_vcodec_probe(struct platf
}
dev->reg_base[i] = devm_ioremap_resource(>dev, res);
if (IS_ERR((__force void *)dev->reg_base[i])) {
-   ret = PTR_ERR((__force void *)dev->reg_base);
+   ret = PTR_ERR((__force void *)dev->reg_base[i]);
goto err_res;
}
mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] pci: constify snd_pcm_ops structures

2016-09-07 Thread Julia Lawall
Check for snd_pcm_ops structures that are only stored in the ops field of a
snd_soc_platform_driver structure or passed as the third argument to
snd_pcm_set_ops.  The corresponding field or parameter is declared const,
so snd_pcm_ops structures that have this property can be declared as const
also.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct snd_pcm_ops i@p = { ... };

@ok1@
identifier r.i;
struct snd_soc_platform_driver e;
position p;
@@
e.ops = @p;

@ok2@
identifier r.i;
expression e1, e2;
position p;
@@
snd_pcm_set_ops(e1, e2, @p)

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct snd_pcm_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct snd_pcm_ops i = { ... };
// 

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/pci/cobalt/cobalt-alsa-pcm.c |4 ++--
 drivers/media/pci/cx18/cx18-alsa-pcm.c |2 +-
 drivers/media/pci/cx23885/cx23885-alsa.c   |2 +-
 drivers/media/pci/cx25821/cx25821-alsa.c   |2 +-
 drivers/media/pci/cx88/cx88-alsa.c |2 +-
 drivers/media/pci/ivtv/ivtv-alsa-pcm.c |2 +-
 drivers/media/pci/saa7134/saa7134-alsa.c   |2 +-
 drivers/media/pci/solo6x10/solo6x10-g723.c |2 +-
 drivers/media/pci/tw686x/tw686x-audio.c|2 +-
 9 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c 
b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
index f198b98..a26f980 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
@@ -318,7 +318,7 @@ static struct page *snd_pcm_get_vmalloc_page(struct 
snd_pcm_substream *subs,
return vmalloc_to_page(pageptr);
 }
 
-static struct snd_pcm_ops snd_ivtv_pcm_capture_ops = {
+static const struct snd_pcm_ops snd_ivtv_pcm_capture_ops = {
.open   = snd_ivtv_pcm_capture_open,
.close  = snd_ivtv_pcm_capture_close,
.ioctl  = snd_ivtv_pcm_ioctl,
diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c 
b/drivers/media/pci/solo6x10/solo6x10-g723.c
index 4a37a1c..6a35107 100644
--- a/drivers/media/pci/solo6x10/solo6x10-g723.c
+++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
@@ -252,7 +252,7 @@ static int snd_solo_pcm_copy(struct snd_pcm_substream *ss, 
int channel,
return 0;
 }
 
-static struct snd_pcm_ops snd_solo_pcm_ops = {
+static const struct snd_pcm_ops snd_solo_pcm_ops = {
.open = snd_solo_pcm_open,
.close = snd_solo_pcm_close,
.ioctl = snd_pcm_lib_ioctl,
diff --git a/drivers/media/pci/cx18/cx18-alsa-pcm.c 
b/drivers/media/pci/cx18/cx18-alsa-pcm.c
index ffb6acd..5344510 100644
--- a/drivers/media/pci/cx18/cx18-alsa-pcm.c
+++ b/drivers/media/pci/cx18/cx18-alsa-pcm.c
@@ -311,7 +311,7 @@ static struct page *snd_pcm_get_vmalloc_page(struct 
snd_pcm_substream *subs,
return vmalloc_to_page(pageptr);
 }
 
-static struct snd_pcm_ops snd_cx18_pcm_capture_ops = {
+static const struct snd_pcm_ops snd_cx18_pcm_capture_ops = {
.open   = snd_cx18_pcm_capture_open,
.close  = snd_cx18_pcm_capture_close,
.ioctl  = snd_cx18_pcm_ioctl,
diff --git a/drivers/media/pci/cobalt/cobalt-alsa-pcm.c 
b/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
index f0bdf10..49013c6 100644
--- a/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
+++ b/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
@@ -510,7 +510,7 @@ static struct page *snd_pcm_get_vmalloc_page(struct 
snd_pcm_substream *subs,
return vmalloc_to_page(pageptr);
 }
 
-static struct snd_pcm_ops snd_cobalt_pcm_capture_ops = {
+static const struct snd_pcm_ops snd_cobalt_pcm_capture_ops = {
.open   = snd_cobalt_pcm_capture_open,
.close  = snd_cobalt_pcm_capture_close,
.ioctl  = snd_cobalt_pcm_ioctl,
@@ -522,7 +522,7 @@ static struct snd_pcm_ops snd_cobalt_pcm_capture_ops = {
.page   = snd_pcm_get_vmalloc_page,
 };
 
-static struct snd_pcm_ops snd_cobalt_pcm_playback_ops = {
+static const struct snd_pcm_ops snd_cobalt_pcm_playback_ops = {
.open   = snd_cobalt_pcm_playback_open,
.close  = snd_cobalt_pcm_playback_close,
.ioctl  = snd_cobalt_pcm_ioctl,
diff --git a/drivers/media/pci/cx88/cx88-alsa.c 
b/drivers/media/pci/cx88/cx88-alsa.c
index f3f13eb..723f064 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -599,7 +599,7 @@ static struct page *snd_cx88_page(struct snd_pcm_substream 
*substream,
 /*
  * operators
  */
-static struct snd_pcm_ops snd_cx88_pcm_ops = {
+static const struct snd_pcm_ops snd_cx88_pcm_ops = {
.open = snd_cx88_pcm_open,
.close = snd_cx88_close,
.ioctl = snd_pcm_lib_ioctl,
diff --git a/drivers/media/pci/tw686x/tw686x-audio.c 
b/drivers/media/pci/tw686x/tw686x-audio.c
index 96e444c..7719076 

[PATCH] [media] usb: constify snd_pcm_ops structures

2016-09-07 Thread Julia Lawall
Check for snd_pcm_ops structures that are only stored in the ops field of a
snd_soc_platform_driver structure or passed as the third argument to
snd_pcm_set_ops.  The corresponding field or parameter is declared const,
so snd_pcm_ops structures that have this property can be declared as const
also.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct snd_pcm_ops i@p = { ... };

@ok1@
identifier r.i;
struct snd_soc_platform_driver e;
position p;
@@
e.ops = @p;

@ok2@
identifier r.i;
expression e1, e2;
position p;
@@
snd_pcm_set_ops(e1, e2, @p)

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct snd_pcm_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct snd_pcm_ops i = { ... };
// 

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/usb/cx231xx/cx231xx-audio.c |2 +-
 drivers/media/usb/em28xx/em28xx-audio.c   |2 +-
 drivers/media/usb/go7007/snd-go7007.c |2 +-
 drivers/media/usb/tm6000/tm6000-alsa.c|2 +-
 drivers/media/usb/usbtv/usbtv-audio.c |2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/em28xx/em28xx-audio.c 
b/drivers/media/usb/em28xx/em28xx-audio.c
index 78f3687..e11fe46 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -695,7 +695,7 @@ static int em28xx_cvol_new(struct snd_card *card, struct 
em28xx *dev,
 /*
  * register/unregister code and data
  */
-static struct snd_pcm_ops snd_em28xx_pcm_capture = {
+static const struct snd_pcm_ops snd_em28xx_pcm_capture = {
.open  = snd_em28xx_capture_open,
.close = snd_em28xx_pcm_close,
.ioctl = snd_pcm_lib_ioctl,
diff --git a/drivers/media/usb/go7007/snd-go7007.c 
b/drivers/media/usb/go7007/snd-go7007.c
index d22d7d5..070871f 100644
--- a/drivers/media/usb/go7007/snd-go7007.c
+++ b/drivers/media/usb/go7007/snd-go7007.c
@@ -198,7 +198,7 @@ static struct page *go7007_snd_pcm_page(struct 
snd_pcm_substream *substream,
return vmalloc_to_page(substream->runtime->dma_area + offset);
 }
 
-static struct snd_pcm_ops go7007_snd_capture_ops = {
+static const struct snd_pcm_ops go7007_snd_capture_ops = {
.open   = go7007_snd_capture_open,
.close  = go7007_snd_capture_close,
.ioctl  = snd_pcm_lib_ioctl,
diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c 
b/drivers/media/usb/cx231xx/cx231xx-audio.c
index 4cd5fa9..8263c4b 100644
--- a/drivers/media/usb/cx231xx/cx231xx-audio.c
+++ b/drivers/media/usb/cx231xx/cx231xx-audio.c
@@ -635,7 +635,7 @@ static struct page *snd_pcm_get_vmalloc_page(struct 
snd_pcm_substream *subs,
return vmalloc_to_page(pageptr);
 }
 
-static struct snd_pcm_ops snd_cx231xx_pcm_capture = {
+static const struct snd_pcm_ops snd_cx231xx_pcm_capture = {
.open = snd_cx231xx_capture_open,
.close = snd_cx231xx_pcm_close,
.ioctl = snd_pcm_lib_ioctl,
diff --git a/drivers/media/usb/usbtv/usbtv-audio.c 
b/drivers/media/usb/usbtv/usbtv-audio.c
index 1965ff1..9db31db 100644
--- a/drivers/media/usb/usbtv/usbtv-audio.c
+++ b/drivers/media/usb/usbtv/usbtv-audio.c
@@ -332,7 +332,7 @@ static snd_pcm_uframes_t snd_usbtv_pointer(struct 
snd_pcm_substream *substream)
return chip->snd_buffer_pos;
 }
 
-static struct snd_pcm_ops snd_usbtv_pcm_ops = {
+static const struct snd_pcm_ops snd_usbtv_pcm_ops = {
.open = snd_usbtv_pcm_open,
.close = snd_usbtv_pcm_close,
.ioctl = snd_pcm_lib_ioctl,
diff --git a/drivers/media/usb/tm6000/tm6000-alsa.c 
b/drivers/media/usb/tm6000/tm6000-alsa.c
index e21c7aa..f16fbd1 100644
--- a/drivers/media/usb/tm6000/tm6000-alsa.c
+++ b/drivers/media/usb/tm6000/tm6000-alsa.c
@@ -388,7 +388,7 @@ static struct page *snd_pcm_get_vmalloc_page(struct 
snd_pcm_substream *subs,
 /*
  * operators
  */
-static struct snd_pcm_ops snd_tm6000_pcm_ops = {
+static const struct snd_pcm_ops snd_tm6000_pcm_ops = {
.open = snd_tm6000_pcm_open,
.close = snd_tm6000_close,
.ioctl = snd_pcm_lib_ioctl,

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [media] pci: constify snd_pcm_ops structures

2016-09-07 Thread Julia Lawall


On Thu, 8 Sep 2016, Andrey Utkin wrote:

> Thanks for looking into this.
> I have tested that it compiles and passes checks (C=2) cleanly after
> this patch.
>
> Acked-by: Andrey Utkin 
>
> While we're at it, what about constification of
> *-core.c:static struct pci_driver *_pci_driver = {
> *-video.c:static struct vb2_ops *_video_qops = {
> *-video.c:static struct video_device *_video_template = {
>
> in drivers/media/pci/? Also there are even more similar entries not
> constified yet in drivers/media/, however I may be underestimating
> complexity of making semantic rules for catching that all.

I will check on these.  Thanks for the suggestion.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [media] pci: constify vb2_ops structures

2016-09-09 Thread Julia Lawall


On Fri, 9 Sep 2016, Andrey Utkin wrote:

> On Fri, Sep 09, 2016 at 01:59:18AM +0200, Julia Lawall wrote:
> > Check for vb2_ops structures that are only stored in the ops field of a
> > vb2_queue structure.  That field is declared const, so vb2_ops structures
> > that have this property can be declared as const also.
>
> > Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
> >
> > ---
> >  drivers/media/pci/cx23885/cx23885-417.c|2 +-
> >  drivers/media/pci/cx23885/cx23885-dvb.c|2 +-
> >  drivers/media/pci/cx23885/cx23885-video.c  |2 +-
> >  drivers/media/pci/cx25821/cx25821-video.c  |2 +-
> >  drivers/media/pci/cx88/cx88-blackbird.c|2 +-
> >  drivers/media/pci/cx88/cx88-dvb.c  |2 +-
> >  drivers/media/pci/cx88/cx88-video.c|2 +-
> >  drivers/media/pci/netup_unidvb/netup_unidvb_core.c |2 +-
> >  drivers/media/pci/saa7134/saa7134-empress.c|2 +-
> >  drivers/media/pci/saa7134/saa7134-video.c  |2 +-
> >  drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c |2 +-
> >  drivers/media/pci/tw68/tw68-video.c|2 +-
> >  drivers/media/pci/tw686x/tw686x-video.c|2 +-
> >  13 files changed, 13 insertions(+), 13 deletions(-)
>
> Applies and compiles cleanly on media tree.
> But please regenerate this patch on git://linuxtv.org/media_tree.git -
> it has a new driver by me, drivers/media/pci/tw5864 , which is affected.

Will this soon reach linux-next?

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [media] pci: constify vb2_ops structures

2016-09-09 Thread Julia Lawall


On Fri, 9 Sep 2016, Andrey Utkin wrote:

> On Fri, Sep 09, 2016 at 10:31:30PM +0800, Julia Lawall wrote:
> > Will this soon reach linux-next?
>
> No idea. Indeed it's simpler if you leave your patch as is, and then
> later we patch this new driver separately.

OK, thanks.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] [media] mxl111sf-tuner: constify dvb_tuner_ops structures

2016-09-11 Thread Julia Lawall
These structures are only used to copy into other structures, so declare
them as const.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct dvb_tuner_ops i@p = { ... };

@ok1@
identifier r.i;
expression e;
position p;
@@
e = i@p

@ok2@
identifier r.i;
expression e1, e2;
position p;
@@
memcpy(e1, @p, e2)

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct dvb_tuner_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct dvb_tuner_ops i = { ... };
// 

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c 
b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
index 7d16252..f141dcc 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
@@ -466,7 +466,7 @@ static int mxl111sf_tuner_release(struct dvb_frontend *fe)
 
 /* - */
 
-static struct dvb_tuner_ops mxl111sf_tuner_tuner_ops = {
+static const struct dvb_tuner_ops mxl111sf_tuner_tuner_ops = {
.info = {
.name = "MaxLinear MxL111SF",
 #if 0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] [media] tuners: constify dvb_tuner_ops structures

2016-09-11 Thread Julia Lawall
These structures are only used to copy into other structures, so declare
them as const.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct dvb_tuner_ops i@p = { ... };

@ok1@
identifier r.i;
expression e;
position p;
@@
e = i@p

@ok2@
identifier r.i;
expression e1, e2;
position p;
@@
memcpy(e1, @p, e2)

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct dvb_tuner_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct dvb_tuner_ops i = { ... };
// 

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/media/tuners/mt2063.c   |2 +-
 drivers/media/tuners/mt20xx.c   |4 ++--
 drivers/media/tuners/mxl5007t.c |2 +-
 drivers/media/tuners/tda827x.c  |4 ++--
 drivers/media/tuners/tea5761.c  |2 +-
 drivers/media/tuners/tea5767.c  |2 +-
 drivers/media/tuners/tuner-simple.c |2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/tuners/tea5767.c b/drivers/media/tuners/tea5767.c
index 36e85d8..6d86aa6 100644
--- a/drivers/media/tuners/tea5767.c
+++ b/drivers/media/tuners/tea5767.c
@@ -423,7 +423,7 @@ static int tea5767_set_config (struct dvb_frontend *fe, 
void *priv_cfg)
return 0;
 }
 
-static struct dvb_tuner_ops tea5767_tuner_ops = {
+static const struct dvb_tuner_ops tea5767_tuner_ops = {
.info = {
.name   = "tea5767", // Philips TEA5767HN FM Radio
},
diff --git a/drivers/media/tuners/mxl5007t.c b/drivers/media/tuners/mxl5007t.c
index f4ae04c..42569c6 100644
--- a/drivers/media/tuners/mxl5007t.c
+++ b/drivers/media/tuners/mxl5007t.c
@@ -794,7 +794,7 @@ static int mxl5007t_release(struct dvb_frontend *fe)
 
 /* - */
 
-static struct dvb_tuner_ops mxl5007t_tuner_ops = {
+static const struct dvb_tuner_ops mxl5007t_tuner_ops = {
.info = {
.name = "MaxLinear MxL5007T",
},
diff --git a/drivers/media/tuners/mt2063.c b/drivers/media/tuners/mt2063.c
index 7f0b9d5..dfec237 100644
--- a/drivers/media/tuners/mt2063.c
+++ b/drivers/media/tuners/mt2063.c
@@ -2201,7 +2201,7 @@ static int mt2063_get_bandwidth(struct dvb_frontend *fe, 
u32 *bw)
return 0;
 }
 
-static struct dvb_tuner_ops mt2063_ops = {
+static const struct dvb_tuner_ops mt2063_ops = {
.info = {
 .name = "MT2063 Silicon Tuner",
 .frequency_min = 4500,
diff --git a/drivers/media/tuners/mt20xx.c b/drivers/media/tuners/mt20xx.c
index 9e03104..52da467 100644
--- a/drivers/media/tuners/mt20xx.c
+++ b/drivers/media/tuners/mt20xx.c
@@ -363,7 +363,7 @@ static int mt2032_set_params(struct dvb_frontend *fe,
return ret;
 }
 
-static struct dvb_tuner_ops mt2032_tuner_ops = {
+static const struct dvb_tuner_ops mt2032_tuner_ops = {
.set_analog_params = mt2032_set_params,
.release   = microtune_release,
.get_frequency = microtune_get_frequency,
@@ -563,7 +563,7 @@ static int mt2050_set_params(struct dvb_frontend *fe,
return ret;
 }
 
-static struct dvb_tuner_ops mt2050_tuner_ops = {
+static const struct dvb_tuner_ops mt2050_tuner_ops = {
.set_analog_params = mt2050_set_params,
.release   = microtune_release,
.get_frequency = microtune_get_frequency,
diff --git a/drivers/media/tuners/tda827x.c b/drivers/media/tuners/tda827x.c
index edcb4a7..5050ce9 100644
--- a/drivers/media/tuners/tda827x.c
+++ b/drivers/media/tuners/tda827x.c
@@ -818,7 +818,7 @@ static int tda827x_initial_sleep(struct dvb_frontend *fe)
return fe->ops.tuner_ops.sleep(fe);
 }
 
-static struct dvb_tuner_ops tda827xo_tuner_ops = {
+static const struct dvb_tuner_ops tda827xo_tuner_ops = {
.info = {
.name = "Philips TDA827X",
.frequency_min  =  5500,
@@ -834,7 +834,7 @@ static struct dvb_tuner_ops tda827xo_tuner_ops = {
.get_bandwidth = tda827x_get_bandwidth,
 };
 
-static struct dvb_tuner_ops tda827xa_tuner_ops = {
+static const struct dvb_tuner_ops tda827xa_tuner_ops = {
.info = {
.name = "Philips TDA827XA",
.frequency_min  =  4400,
diff --git a/drivers/media/tuners/tuner-simple.c 
b/drivers/media/tuners/tuner-simple.c
index 8e9ce14..9ba9582 100644
--- a/drivers/media/tuners/tuner-simple.c
+++ b/drivers/media/tuners/tuner-simple.c
@@ -1035,7 +1035,7 @@ static int simple_get_bandwidth(struct dvb_frontend *fe, 
u32 *bandwidth)
return 0;
 }
 
-static struct dvb_tuner_ops simple_tuner_ops = {
+static const struct dvb_tuner_ops simple_tuner_ops = {
.init  = simple_init,
.sleep = simple_sleep,
.set_analog_params = simple_set_params,
diff --git a/drivers/me

[PATCH 0/3] constify dvb_tuner_ops structures

2016-09-11 Thread Julia Lawall
Constify dvb_tuner_ops structures

---

 drivers/media/dvb-frontends/ascot2e.c |2 +-
 drivers/media/dvb-frontends/dvb-pll.c |2 +-
 drivers/media/dvb-frontends/helene.c  |4 ++--
 drivers/media/dvb-frontends/horus3a.c |2 +-
 drivers/media/dvb-frontends/ix2505v.c |2 +-
 drivers/media/dvb-frontends/stb6000.c |2 +-
 drivers/media/dvb-frontends/stb6100.c |2 +-
 drivers/media/dvb-frontends/stv6110.c |2 +-
 drivers/media/dvb-frontends/stv6110x.c|2 +-
 drivers/media/dvb-frontends/tda18271c2dd.c|2 +-
 drivers/media/dvb-frontends/tda665x.c |2 +-
 drivers/media/dvb-frontends/tda8261.c |2 +-
 drivers/media/dvb-frontends/tda826x.c |2 +-
 drivers/media/dvb-frontends/ts2020.c  |2 +-
 drivers/media/dvb-frontends/tua6100.c |2 +-
 drivers/media/dvb-frontends/zl10036.c |2 +-
 drivers/media/dvb-frontends/zl10039.c |2 +-
 drivers/media/tuners/mt2063.c |2 +-
 drivers/media/tuners/mt20xx.c |4 ++--
 drivers/media/tuners/mxl5007t.c   |2 +-
 drivers/media/tuners/tda827x.c|4 ++--
 drivers/media/tuners/tea5761.c|2 +-
 drivers/media/tuners/tea5767.c|2 +-
 drivers/media/tuners/tuner-simple.c   |2 +-
 drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c |2 +-
 25 files changed, 28 insertions(+), 28 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/26] constify local structures

2016-09-11 Thread Julia Lawall

On Sun, 11 Sep 2016, Joe Perches wrote:

> On Sun, 2016-09-11 at 15:05 +0200, Julia Lawall wrote:
> > Constify local structures.
>
> Thanks Julia.
>
> A few suggestions & questions:
>
> Perhaps the script should go into scripts/coccinelle/
> so that future cases could be caught by the robot
> and commit message referenced by the patch instances.

OK.

> Can you please compile the files modified using the
> appropriate defconfig/allyesconfig and show the

I currently send patches for this issue only for files that compile using
the x86 allyesconfig.

> movement from data to const by using
>   $ size .new/old
> and include that in the changelogs (maybe next time)?

OK, thanks for the suggestion.

> Is it possible for a rule to trace the instances where
> an address of a struct or struct member is taken by
> locally defined and declared function call where the
> callee does not modify any dereferenced object?
>
> ie:
>
> struct foo {
>   int bar;
>   char *baz;
> };
>
> struct foo qux[] = {
>   { 1, "description 1" },
>   { 2, "dewcription 2" },
>   [ n, "etc" ]...,
> };
>
> void message(struct foo *msg)
> {
>   printk("%d %s\n", msg->bar, msg->baz);
> }
>
> where some code uses
>
>   message(qux[index]);
>
> So could a coccinelle script change:
>
> struct foo qux[] = { to const struct foo quz[] = {
>
> and
>
> void message(struct foo *msg) to void message(const struct foo *msg)

Yes, this could be possible too.

Thanks for the feedback.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


<    1   2   3   4   >