Skip to content

Commit

Permalink
[media] s5p-tv: Use devm_* functions in sii9234_drv.c file
Browse files Browse the repository at this point in the history
devm_* functions are device managed functions and make error handling
and cleanup cleaner and simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Sachin Kamat authored and Mauro Carvalho Chehab committed Aug 15, 2012
1 parent f5c9903 commit 89e47e3
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions drivers/media/platform/s5p-tv/sii9234_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,26 +323,25 @@ static int __devinit sii9234_probe(struct i2c_client *client,
struct sii9234_context *ctx;
int ret;

ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
ctx = devm_kzalloc(&client->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx) {
dev_err(dev, "out of memory\n");
ret = -ENOMEM;
goto fail;
}
ctx->client = client;

ctx->power = regulator_get(dev, "hdmi-en");
ctx->power = devm_regulator_get(dev, "hdmi-en");
if (IS_ERR(ctx->power)) {
dev_err(dev, "failed to acquire regulator hdmi-en\n");
ret = PTR_ERR(ctx->power);
goto fail_ctx;
return PTR_ERR(ctx->power);
}

ctx->gpio_n_reset = pdata->gpio_n_reset;
ret = gpio_request(ctx->gpio_n_reset, "MHL_RST");
if (ret) {
dev_err(dev, "failed to acquire MHL_RST gpio\n");
goto fail_power;
return ret;
}

v4l2_i2c_subdev_init(&ctx->sd, client, &sii9234_ops);
Expand Down Expand Up @@ -373,12 +372,6 @@ static int __devinit sii9234_probe(struct i2c_client *client,
pm_runtime_disable(dev);
gpio_free(ctx->gpio_n_reset);

fail_power:
regulator_put(ctx->power);

fail_ctx:
kfree(ctx);

fail:
dev_err(dev, "probe failed\n");

Expand All @@ -393,8 +386,6 @@ static int __devexit sii9234_remove(struct i2c_client *client)

pm_runtime_disable(dev);
gpio_free(ctx->gpio_n_reset);
regulator_put(ctx->power);
kfree(ctx);

dev_info(dev, "remove successful\n");

Expand Down

0 comments on commit 89e47e3

Please sign in to comment.