diff options
author | Steve Longerbeam <steve_longerbeam@mentor.com> | 2019-01-11 16:17:03 +0000 |
---|---|---|
committer | Ryo Kataoka <ryo.kataoka.wt@renesas.com> | 2019-03-22 20:50:31 +0900 |
commit | 2fba5e0e94db930a24af406a39cd3a2c0353f15b (patch) | |
tree | 4fb582392c868dad74ae8708d5e28b140818c3e3 | |
parent | 0786087e9766327cc9f741013a3f54de87783bb3 (diff) | |
download | renesas-bsp-2fba5e0e94db930a24af406a39cd3a2c0353f15b.tar.gz |
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.
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
[Kieran: Change sizeof() to dereference the pointer type]
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://patchwork.kernel.org/patch/10760277/
[koji.matsuoka.xm: the part of the patch for kernel v4.14.75
was rebased and imported]
Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
-rw-r--r-- | drivers/media/i2c/adv748x/adv748x-core.c | 5 |
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 947b23448e102..da8f0621a10b5 100644 --- a/drivers/media/i2c/adv748x/adv748x-core.c +++ b/drivers/media/i2c/adv748x/adv748x-core.c @@ -849,7 +849,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; @@ -947,7 +947,6 @@ err_cleanup_dt: adv748x_dt_cleanup(state); err_free_mutex: mutex_destroy(&state->mutex); - kfree(state); return ret; } @@ -966,8 +965,6 @@ static int adv748x_remove(struct i2c_client *client) adv748x_dt_cleanup(state); mutex_destroy(&state->mutex); - kfree(state); - return 0; } |