aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/ths7303.c
diff options
context:
space:
mode:
authorLad, Prabhakar <prabhakar.csengg@gmail.com>2013-05-25 12:39:36 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-13 10:42:17 -0400
commitdd8c393b3c39f7ebd9ad69ce50cc836773d512b6 (patch)
tree9d0364b9ff8de67daef444390dd26f1d85da286c /drivers/media/i2c/ths7303.c
parent8524ce558a0111762efa1a6b5ba9ce5e092b4707 (diff)
[media] media: i2c: ths7303: make the pdata as a constant pointer
generally the pdata needs to be a constant pointer in the device state structure. This patch makes the pdata as a constant pointer and alongside returns -EINVAL when pdata is NULL. Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/i2c/ths7303.c')
-rw-r--r--drivers/media/i2c/ths7303.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c
index af06187c74f8..b954195cfbe7 100644
--- a/drivers/media/i2c/ths7303.c
+++ b/drivers/media/i2c/ths7303.c
@@ -35,7 +35,7 @@
35 35
36struct ths7303_state { 36struct ths7303_state {
37 struct v4l2_subdev sd; 37 struct v4l2_subdev sd;
38 struct ths7303_platform_data pdata; 38 const struct ths7303_platform_data *pdata;
39 struct v4l2_bt_timings bt; 39 struct v4l2_bt_timings bt;
40 int std_id; 40 int std_id;
41 int stream_on; 41 int stream_on;
@@ -89,7 +89,7 @@ int ths7303_setval(struct v4l2_subdev *sd, enum ths7303_filter_mode mode)
89{ 89{
90 struct i2c_client *client = v4l2_get_subdevdata(sd); 90 struct i2c_client *client = v4l2_get_subdevdata(sd);
91 struct ths7303_state *state = to_state(sd); 91 struct ths7303_state *state = to_state(sd);
92 struct ths7303_platform_data *pdata = &state->pdata; 92 const struct ths7303_platform_data *pdata = state->pdata;
93 u8 val, sel = 0; 93 u8 val, sel = 0;
94 int err, disable = 0; 94 int err, disable = 0;
95 95
@@ -356,6 +356,11 @@ static int ths7303_probe(struct i2c_client *client,
356 struct ths7303_state *state; 356 struct ths7303_state *state;
357 struct v4l2_subdev *sd; 357 struct v4l2_subdev *sd;
358 358
359 if (pdata == NULL) {
360 dev_err(&client->dev, "No platform data\n");
361 return -EINVAL;
362 }
363
359 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 364 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
360 return -ENODEV; 365 return -ENODEV;
361 366
@@ -367,11 +372,7 @@ static int ths7303_probe(struct i2c_client *client,
367 if (!state) 372 if (!state)
368 return -ENOMEM; 373 return -ENOMEM;
369 374
370 if (!pdata) 375 state->pdata = pdata;
371 v4l_warn(client, "No platform data, using default data!\n");
372 else
373 state->pdata = *pdata;
374
375 sd = &state->sd; 376 sd = &state->sd;
376 v4l2_i2c_subdev_init(sd, client, &ths7303_ops); 377 v4l2_i2c_subdev_init(sd, client, &ths7303_ops);
377 378