summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/adv748x
diff options
context:
space:
mode:
authorSteve Longerbeam <steve_longerbeam@mentor.com>2019-01-11 14:17:03 -0200
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-01-21 15:44:23 -0200
commitfb517583b3fe0bb6e64b8a861bfae5dc39f1cedb (patch)
tree2d055f4e12b80e50c611b7d0c06804ec4db4c6b7 /drivers/media/i2c/adv748x
parentcf20ae1535eb690a87c29b9cc7af51881384e967 (diff)
downloadlinux-stable-fb517583b3fe0bb6e64b8a861bfae5dc39f1cedb.tar.gz
linux-stable-fb517583b3fe0bb6e64b8a861bfae5dc39f1cedb.tar.bz2
linux-stable-fb517583b3fe0bb6e64b8a861bfae5dc39f1cedb.zip
media: i2c: adv748x: Use devm to allocate the device struct
Switch to devm_kzalloc() when allocating the adv748x device struct. The sizeof() is updated to determine the correct allocation size from the dereferenced pointer type rather than hardcoding the struct type. [Kieran: Change sizeof() to dereference the pointer type] Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/i2c/adv748x')
-rw-r--r--drivers/media/i2c/adv748x/adv748x-core.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
index d94c63cb6a2e..bd8a8c8d6f8e 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -631,7 +631,7 @@ static int adv748x_probe(struct i2c_client *client,
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -EIO;
- state = kzalloc(sizeof(struct adv748x_state), GFP_KERNEL);
+ state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
if (!state)
return -ENOMEM;
@@ -729,7 +729,6 @@ err_cleanup_dt:
adv748x_dt_cleanup(state);
err_free_mutex:
mutex_destroy(&state->mutex);
- kfree(state);
return ret;
}
@@ -748,8 +747,6 @@ static int adv748x_remove(struct i2c_client *client)
adv748x_dt_cleanup(state);
mutex_destroy(&state->mutex);
- kfree(state);
-
return 0;
}