Commit fb517583 authored by Steve Longerbeam's avatar Steve Longerbeam Committed by Mauro Carvalho Chehab

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: default avatarSteve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent cf20ae15
...@@ -631,7 +631,7 @@ static int adv748x_probe(struct i2c_client *client, ...@@ -631,7 +631,7 @@ static int adv748x_probe(struct i2c_client *client,
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -EIO; return -EIO;
state = kzalloc(sizeof(struct adv748x_state), GFP_KERNEL); state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
return -ENOMEM; return -ENOMEM;
...@@ -729,7 +729,6 @@ static int adv748x_probe(struct i2c_client *client, ...@@ -729,7 +729,6 @@ static int adv748x_probe(struct i2c_client *client,
adv748x_dt_cleanup(state); adv748x_dt_cleanup(state);
err_free_mutex: err_free_mutex:
mutex_destroy(&state->mutex); mutex_destroy(&state->mutex);
kfree(state);
return ret; return ret;
} }
...@@ -748,8 +747,6 @@ static int adv748x_remove(struct i2c_client *client) ...@@ -748,8 +747,6 @@ static int adv748x_remove(struct i2c_client *client)
adv748x_dt_cleanup(state); adv748x_dt_cleanup(state);
mutex_destroy(&state->mutex); mutex_destroy(&state->mutex);
kfree(state);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment