[media] soc-camera: use devm_kzalloc in subdevice drivers

I2C drivers can use devm_kzalloc() too in their .probe() methods. Doing so
simplifies their clean up paths.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Guennadi Liakhovetski 2012-12-21 10:28:43 -03:00 коммит произвёл Mauro Carvalho Chehab
Родитель 25a3481100
Коммит 70e176a5a9
15 изменённых файлов: 51 добавлений и 151 удалений

Просмотреть файл

@ -431,7 +431,6 @@ static int imx074_probe(struct i2c_client *client,
struct imx074 *priv; struct imx074 *priv;
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
int ret;
if (!ssdd) { if (!ssdd) {
dev_err(&client->dev, "IMX074: missing platform data!\n"); dev_err(&client->dev, "IMX074: missing platform data!\n");
@ -444,7 +443,7 @@ static int imx074_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
priv = kzalloc(sizeof(struct imx074), GFP_KERNEL); priv = devm_kzalloc(&client->dev, sizeof(struct imx074), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
@ -452,23 +451,15 @@ static int imx074_probe(struct i2c_client *client,
priv->fmt = &imx074_colour_fmts[0]; priv->fmt = &imx074_colour_fmts[0];
ret = imx074_video_probe(client); return imx074_video_probe(client);
if (ret < 0) {
kfree(priv);
return ret;
}
return ret;
} }
static int imx074_remove(struct i2c_client *client) static int imx074_remove(struct i2c_client *client)
{ {
struct imx074 *priv = to_imx074(client);
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
if (ssdd->free_bus) if (ssdd->free_bus)
ssdd->free_bus(ssdd); ssdd->free_bus(ssdd);
kfree(priv);
return 0; return 0;
} }

Просмотреть файл

@ -677,7 +677,7 @@ static int mt9m001_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
mt9m001 = kzalloc(sizeof(struct mt9m001), GFP_KERNEL); mt9m001 = devm_kzalloc(&client->dev, sizeof(struct mt9m001), GFP_KERNEL);
if (!mt9m001) if (!mt9m001)
return -ENOMEM; return -ENOMEM;
@ -697,12 +697,9 @@ static int mt9m001_probe(struct i2c_client *client,
&mt9m001_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0, &mt9m001_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0,
V4L2_EXPOSURE_AUTO); V4L2_EXPOSURE_AUTO);
mt9m001->subdev.ctrl_handler = &mt9m001->hdl; mt9m001->subdev.ctrl_handler = &mt9m001->hdl;
if (mt9m001->hdl.error) { if (mt9m001->hdl.error)
int err = mt9m001->hdl.error; return mt9m001->hdl.error;
kfree(mt9m001);
return err;
}
v4l2_ctrl_auto_cluster(2, &mt9m001->autoexposure, v4l2_ctrl_auto_cluster(2, &mt9m001->autoexposure,
V4L2_EXPOSURE_MANUAL, true); V4L2_EXPOSURE_MANUAL, true);
@ -714,10 +711,8 @@ static int mt9m001_probe(struct i2c_client *client,
mt9m001->rect.height = MT9M001_MAX_HEIGHT; mt9m001->rect.height = MT9M001_MAX_HEIGHT;
ret = mt9m001_video_probe(ssdd, client); ret = mt9m001_video_probe(ssdd, client);
if (ret) { if (ret)
v4l2_ctrl_handler_free(&mt9m001->hdl); v4l2_ctrl_handler_free(&mt9m001->hdl);
kfree(mt9m001);
}
return ret; return ret;
} }
@ -730,7 +725,6 @@ static int mt9m001_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(&mt9m001->subdev); v4l2_device_unregister_subdev(&mt9m001->subdev);
v4l2_ctrl_handler_free(&mt9m001->hdl); v4l2_ctrl_handler_free(&mt9m001->hdl);
mt9m001_video_remove(ssdd); mt9m001_video_remove(ssdd);
kfree(mt9m001);
return 0; return 0;
} }

Просмотреть файл

@ -971,7 +971,7 @@ static int mt9m111_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
mt9m111 = kzalloc(sizeof(struct mt9m111), GFP_KERNEL); mt9m111 = devm_kzalloc(&client->dev, sizeof(struct mt9m111), GFP_KERNEL);
if (!mt9m111) if (!mt9m111)
return -ENOMEM; return -ENOMEM;
@ -989,12 +989,8 @@ static int mt9m111_probe(struct i2c_client *client,
&mt9m111_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0, &mt9m111_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0,
V4L2_EXPOSURE_AUTO); V4L2_EXPOSURE_AUTO);
mt9m111->subdev.ctrl_handler = &mt9m111->hdl; mt9m111->subdev.ctrl_handler = &mt9m111->hdl;
if (mt9m111->hdl.error) { if (mt9m111->hdl.error)
int err = mt9m111->hdl.error; return mt9m111->hdl.error;
kfree(mt9m111);
return err;
}
/* Second stage probe - when a capture adapter is there */ /* Second stage probe - when a capture adapter is there */
mt9m111->rect.left = MT9M111_MIN_DARK_COLS; mt9m111->rect.left = MT9M111_MIN_DARK_COLS;
@ -1006,10 +1002,8 @@ static int mt9m111_probe(struct i2c_client *client,
mutex_init(&mt9m111->power_lock); mutex_init(&mt9m111->power_lock);
ret = mt9m111_video_probe(client); ret = mt9m111_video_probe(client);
if (ret) { if (ret)
v4l2_ctrl_handler_free(&mt9m111->hdl); v4l2_ctrl_handler_free(&mt9m111->hdl);
kfree(mt9m111);
}
return ret; return ret;
} }
@ -1020,7 +1014,6 @@ static int mt9m111_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(&mt9m111->subdev); v4l2_device_unregister_subdev(&mt9m111->subdev);
v4l2_ctrl_handler_free(&mt9m111->hdl); v4l2_ctrl_handler_free(&mt9m111->hdl);
kfree(mt9m111);
return 0; return 0;
} }

Просмотреть файл

@ -773,7 +773,7 @@ static int mt9t031_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
mt9t031 = kzalloc(sizeof(struct mt9t031), GFP_KERNEL); mt9t031 = devm_kzalloc(&client->dev, sizeof(struct mt9t031), GFP_KERNEL);
if (!mt9t031) if (!mt9t031)
return -ENOMEM; return -ENOMEM;
@ -797,12 +797,9 @@ static int mt9t031_probe(struct i2c_client *client,
V4L2_CID_EXPOSURE, 1, 255, 1, 255); V4L2_CID_EXPOSURE, 1, 255, 1, 255);
mt9t031->subdev.ctrl_handler = &mt9t031->hdl; mt9t031->subdev.ctrl_handler = &mt9t031->hdl;
if (mt9t031->hdl.error) { if (mt9t031->hdl.error)
int err = mt9t031->hdl.error; return mt9t031->hdl.error;
kfree(mt9t031);
return err;
}
v4l2_ctrl_auto_cluster(2, &mt9t031->autoexposure, v4l2_ctrl_auto_cluster(2, &mt9t031->autoexposure,
V4L2_EXPOSURE_MANUAL, true); V4L2_EXPOSURE_MANUAL, true);
@ -816,10 +813,8 @@ static int mt9t031_probe(struct i2c_client *client,
mt9t031->yskip = 1; mt9t031->yskip = 1;
ret = mt9t031_video_probe(client); ret = mt9t031_video_probe(client);
if (ret) { if (ret)
v4l2_ctrl_handler_free(&mt9t031->hdl); v4l2_ctrl_handler_free(&mt9t031->hdl);
kfree(mt9t031);
}
return ret; return ret;
} }
@ -830,7 +825,6 @@ static int mt9t031_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(&mt9t031->subdev); v4l2_device_unregister_subdev(&mt9t031->subdev);
v4l2_ctrl_handler_free(&mt9t031->hdl); v4l2_ctrl_handler_free(&mt9t031->hdl);
kfree(mt9t031);
return 0; return 0;
} }

Просмотреть файл

@ -1092,7 +1092,7 @@ static int mt9t112_probe(struct i2c_client *client,
return -EINVAL; return -EINVAL;
} }
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
@ -1101,10 +1101,8 @@ static int mt9t112_probe(struct i2c_client *client,
v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops); v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);
ret = mt9t112_camera_probe(client); ret = mt9t112_camera_probe(client);
if (ret) { if (ret)
kfree(priv);
return ret; return ret;
}
/* Cannot fail: using the default supported pixel code */ /* Cannot fail: using the default supported pixel code */
mt9t112_set_params(priv, &rect, V4L2_MBUS_FMT_UYVY8_2X8); mt9t112_set_params(priv, &rect, V4L2_MBUS_FMT_UYVY8_2X8);
@ -1114,9 +1112,6 @@ static int mt9t112_probe(struct i2c_client *client,
static int mt9t112_remove(struct i2c_client *client) static int mt9t112_remove(struct i2c_client *client)
{ {
struct mt9t112_priv *priv = to_mt9t112(client);
kfree(priv);
return 0; return 0;
} }

Просмотреть файл

@ -889,7 +889,7 @@ static int mt9v022_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
mt9v022 = kzalloc(sizeof(struct mt9v022), GFP_KERNEL); mt9v022 = devm_kzalloc(&client->dev, sizeof(struct mt9v022), GFP_KERNEL);
if (!mt9v022) if (!mt9v022)
return -ENOMEM; return -ENOMEM;
@ -930,7 +930,6 @@ static int mt9v022_probe(struct i2c_client *client,
int err = mt9v022->hdl.error; int err = mt9v022->hdl.error;
dev_err(&client->dev, "control initialisation err %d\n", err); dev_err(&client->dev, "control initialisation err %d\n", err);
kfree(mt9v022);
return err; return err;
} }
v4l2_ctrl_auto_cluster(2, &mt9v022->autoexposure, v4l2_ctrl_auto_cluster(2, &mt9v022->autoexposure,
@ -950,10 +949,8 @@ static int mt9v022_probe(struct i2c_client *client,
mt9v022->rect.height = MT9V022_MAX_HEIGHT; mt9v022->rect.height = MT9V022_MAX_HEIGHT;
ret = mt9v022_video_probe(client); ret = mt9v022_video_probe(client);
if (ret) { if (ret)
v4l2_ctrl_handler_free(&mt9v022->hdl); v4l2_ctrl_handler_free(&mt9v022->hdl);
kfree(mt9v022);
}
return ret; return ret;
} }
@ -967,7 +964,6 @@ static int mt9v022_remove(struct i2c_client *client)
if (ssdd->free_bus) if (ssdd->free_bus)
ssdd->free_bus(ssdd); ssdd->free_bus(ssdd);
v4l2_ctrl_handler_free(&mt9v022->hdl); v4l2_ctrl_handler_free(&mt9v022->hdl);
kfree(mt9v022);
return 0; return 0;
} }

Просмотреть файл

@ -1096,7 +1096,7 @@ static int ov2640_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
priv = kzalloc(sizeof(struct ov2640_priv), GFP_KERNEL); priv = devm_kzalloc(&client->dev, sizeof(struct ov2640_priv), GFP_KERNEL);
if (!priv) { if (!priv) {
dev_err(&adapter->dev, dev_err(&adapter->dev,
"Failed to allocate memory for private data!\n"); "Failed to allocate memory for private data!\n");
@ -1110,20 +1110,14 @@ static int ov2640_probe(struct i2c_client *client,
v4l2_ctrl_new_std(&priv->hdl, &ov2640_ctrl_ops, v4l2_ctrl_new_std(&priv->hdl, &ov2640_ctrl_ops,
V4L2_CID_HFLIP, 0, 1, 1, 0); V4L2_CID_HFLIP, 0, 1, 1, 0);
priv->subdev.ctrl_handler = &priv->hdl; priv->subdev.ctrl_handler = &priv->hdl;
if (priv->hdl.error) { if (priv->hdl.error)
int err = priv->hdl.error; return priv->hdl.error;
kfree(priv);
return err;
}
ret = ov2640_video_probe(client); ret = ov2640_video_probe(client);
if (ret) { if (ret)
v4l2_ctrl_handler_free(&priv->hdl); v4l2_ctrl_handler_free(&priv->hdl);
kfree(priv); else
} else {
dev_info(&adapter->dev, "OV2640 Probed\n"); dev_info(&adapter->dev, "OV2640 Probed\n");
}
return ret; return ret;
} }
@ -1134,7 +1128,6 @@ static int ov2640_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(&priv->subdev); v4l2_device_unregister_subdev(&priv->subdev);
v4l2_ctrl_handler_free(&priv->hdl); v4l2_ctrl_handler_free(&priv->hdl);
kfree(priv);
return 0; return 0;
} }

Просмотреть файл

@ -1021,14 +1021,13 @@ static int ov5642_probe(struct i2c_client *client,
{ {
struct ov5642 *priv; struct ov5642 *priv;
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
int ret;
if (!ssdd) { if (!ssdd) {
dev_err(&client->dev, "OV5642: missing platform data!\n"); dev_err(&client->dev, "OV5642: missing platform data!\n");
return -EINVAL; return -EINVAL;
} }
priv = kzalloc(sizeof(struct ov5642), GFP_KERNEL); priv = devm_kzalloc(&client->dev, sizeof(struct ov5642), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
@ -1043,25 +1042,15 @@ static int ov5642_probe(struct i2c_client *client,
priv->total_width = OV5642_DEFAULT_WIDTH + BLANKING_EXTRA_WIDTH; priv->total_width = OV5642_DEFAULT_WIDTH + BLANKING_EXTRA_WIDTH;
priv->total_height = BLANKING_MIN_HEIGHT; priv->total_height = BLANKING_MIN_HEIGHT;
ret = ov5642_video_probe(client); return ov5642_video_probe(client);
if (ret < 0)
goto error;
return 0;
error:
kfree(priv);
return ret;
} }
static int ov5642_remove(struct i2c_client *client) static int ov5642_remove(struct i2c_client *client)
{ {
struct ov5642 *priv = to_ov5642(client);
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
if (ssdd->free_bus) if (ssdd->free_bus)
ssdd->free_bus(ssdd); ssdd->free_bus(ssdd);
kfree(priv);
return 0; return 0;
} }

Просмотреть файл

@ -971,7 +971,7 @@ static int ov6650_probe(struct i2c_client *client,
return -EINVAL; return -EINVAL;
} }
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) { if (!priv) {
dev_err(&client->dev, dev_err(&client->dev,
"Failed to allocate memory for private data!\n"); "Failed to allocate memory for private data!\n");
@ -1009,12 +1009,9 @@ static int ov6650_probe(struct i2c_client *client,
V4L2_CID_GAMMA, 0, 0xff, 1, 0x12); V4L2_CID_GAMMA, 0, 0xff, 1, 0x12);
priv->subdev.ctrl_handler = &priv->hdl; priv->subdev.ctrl_handler = &priv->hdl;
if (priv->hdl.error) { if (priv->hdl.error)
int err = priv->hdl.error; return priv->hdl.error;
kfree(priv);
return err;
}
v4l2_ctrl_auto_cluster(2, &priv->autogain, 0, true); v4l2_ctrl_auto_cluster(2, &priv->autogain, 0, true);
v4l2_ctrl_auto_cluster(3, &priv->autowb, 0, true); v4l2_ctrl_auto_cluster(3, &priv->autowb, 0, true);
v4l2_ctrl_auto_cluster(2, &priv->autoexposure, v4l2_ctrl_auto_cluster(2, &priv->autoexposure,
@ -1029,10 +1026,8 @@ static int ov6650_probe(struct i2c_client *client,
priv->colorspace = V4L2_COLORSPACE_JPEG; priv->colorspace = V4L2_COLORSPACE_JPEG;
ret = ov6650_video_probe(client); ret = ov6650_video_probe(client);
if (ret) { if (ret)
v4l2_ctrl_handler_free(&priv->hdl); v4l2_ctrl_handler_free(&priv->hdl);
kfree(priv);
}
return ret; return ret;
} }
@ -1043,7 +1038,6 @@ static int ov6650_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(&priv->subdev); v4l2_device_unregister_subdev(&priv->subdev);
v4l2_ctrl_handler_free(&priv->hdl); v4l2_ctrl_handler_free(&priv->hdl);
kfree(priv);
return 0; return 0;
} }

Просмотреть файл

@ -1070,7 +1070,7 @@ static int ov772x_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
@ -1085,22 +1085,15 @@ static int ov772x_probe(struct i2c_client *client,
v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops,
V4L2_CID_BAND_STOP_FILTER, 0, 256, 1, 0); V4L2_CID_BAND_STOP_FILTER, 0, 256, 1, 0);
priv->subdev.ctrl_handler = &priv->hdl; priv->subdev.ctrl_handler = &priv->hdl;
if (priv->hdl.error) { if (priv->hdl.error)
ret = priv->hdl.error; return priv->hdl.error;
goto done;
}
ret = ov772x_video_probe(priv); ret = ov772x_video_probe(priv);
if (ret < 0) if (ret < 0) {
goto done; v4l2_ctrl_handler_free(&priv->hdl);
} else {
priv->cfmt = &ov772x_cfmts[0]; priv->cfmt = &ov772x_cfmts[0];
priv->win = &ov772x_win_sizes[0]; priv->win = &ov772x_win_sizes[0];
done:
if (ret) {
v4l2_ctrl_handler_free(&priv->hdl);
kfree(priv);
} }
return ret; return ret;
} }
@ -1111,7 +1104,6 @@ static int ov772x_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(&priv->subdev); v4l2_device_unregister_subdev(&priv->subdev);
v4l2_ctrl_handler_free(&priv->hdl); v4l2_ctrl_handler_free(&priv->hdl);
kfree(priv);
return 0; return 0;
} }

Просмотреть файл

@ -698,7 +698,7 @@ static int ov9640_probe(struct i2c_client *client,
return -EINVAL; return -EINVAL;
} }
priv = kzalloc(sizeof(struct ov9640_priv), GFP_KERNEL); priv = devm_kzalloc(&client->dev, sizeof(struct ov9640_priv), GFP_KERNEL);
if (!priv) { if (!priv) {
dev_err(&client->dev, dev_err(&client->dev,
"Failed to allocate memory for private data!\n"); "Failed to allocate memory for private data!\n");
@ -713,19 +713,13 @@ static int ov9640_probe(struct i2c_client *client,
v4l2_ctrl_new_std(&priv->hdl, &ov9640_ctrl_ops, v4l2_ctrl_new_std(&priv->hdl, &ov9640_ctrl_ops,
V4L2_CID_HFLIP, 0, 1, 1, 0); V4L2_CID_HFLIP, 0, 1, 1, 0);
priv->subdev.ctrl_handler = &priv->hdl; priv->subdev.ctrl_handler = &priv->hdl;
if (priv->hdl.error) { if (priv->hdl.error)
int err = priv->hdl.error; return priv->hdl.error;
kfree(priv);
return err;
}
ret = ov9640_video_probe(client); ret = ov9640_video_probe(client);
if (ret) { if (ret)
v4l2_ctrl_handler_free(&priv->hdl); v4l2_ctrl_handler_free(&priv->hdl);
kfree(priv);
}
return ret; return ret;
} }
@ -737,7 +731,6 @@ static int ov9640_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(&priv->subdev); v4l2_device_unregister_subdev(&priv->subdev);
v4l2_ctrl_handler_free(&priv->hdl); v4l2_ctrl_handler_free(&priv->hdl);
kfree(priv);
return 0; return 0;
} }

Просмотреть файл

@ -959,7 +959,7 @@ static int ov9740_probe(struct i2c_client *client,
return -EINVAL; return -EINVAL;
} }
priv = kzalloc(sizeof(struct ov9740_priv), GFP_KERNEL); priv = devm_kzalloc(&client->dev, sizeof(struct ov9740_priv), GFP_KERNEL);
if (!priv) { if (!priv) {
dev_err(&client->dev, "Failed to allocate private data!\n"); dev_err(&client->dev, "Failed to allocate private data!\n");
return -ENOMEM; return -ENOMEM;
@ -972,18 +972,12 @@ static int ov9740_probe(struct i2c_client *client,
v4l2_ctrl_new_std(&priv->hdl, &ov9740_ctrl_ops, v4l2_ctrl_new_std(&priv->hdl, &ov9740_ctrl_ops,
V4L2_CID_HFLIP, 0, 1, 1, 0); V4L2_CID_HFLIP, 0, 1, 1, 0);
priv->subdev.ctrl_handler = &priv->hdl; priv->subdev.ctrl_handler = &priv->hdl;
if (priv->hdl.error) { if (priv->hdl.error)
int err = priv->hdl.error; return priv->hdl.error;
kfree(priv);
return err;
}
ret = ov9740_video_probe(client); ret = ov9740_video_probe(client);
if (ret < 0) { if (ret < 0)
v4l2_ctrl_handler_free(&priv->hdl); v4l2_ctrl_handler_free(&priv->hdl);
kfree(priv);
}
return ret; return ret;
} }
@ -994,7 +988,6 @@ static int ov9740_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(&priv->subdev); v4l2_device_unregister_subdev(&priv->subdev);
v4l2_ctrl_handler_free(&priv->hdl); v4l2_ctrl_handler_free(&priv->hdl);
kfree(priv);
return 0; return 0;
} }

Просмотреть файл

@ -1352,7 +1352,7 @@ static int rj54n1_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
rj54n1 = kzalloc(sizeof(struct rj54n1), GFP_KERNEL); rj54n1 = devm_kzalloc(&client->dev, sizeof(struct rj54n1), GFP_KERNEL);
if (!rj54n1) if (!rj54n1)
return -ENOMEM; return -ENOMEM;
@ -1367,12 +1367,8 @@ static int rj54n1_probe(struct i2c_client *client,
v4l2_ctrl_new_std(&rj54n1->hdl, &rj54n1_ctrl_ops, v4l2_ctrl_new_std(&rj54n1->hdl, &rj54n1_ctrl_ops,
V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1); V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1);
rj54n1->subdev.ctrl_handler = &rj54n1->hdl; rj54n1->subdev.ctrl_handler = &rj54n1->hdl;
if (rj54n1->hdl.error) { if (rj54n1->hdl.error)
int err = rj54n1->hdl.error; return rj54n1->hdl.error;
kfree(rj54n1);
return err;
}
rj54n1->clk_div = clk_div; rj54n1->clk_div = clk_div;
rj54n1->rect.left = RJ54N1_COLUMN_SKIP; rj54n1->rect.left = RJ54N1_COLUMN_SKIP;
@ -1387,10 +1383,8 @@ static int rj54n1_probe(struct i2c_client *client,
(clk_div.ratio_tg + 1) / (clk_div.ratio_t + 1); (clk_div.ratio_tg + 1) / (clk_div.ratio_t + 1);
ret = rj54n1_video_probe(client, rj54n1_priv); ret = rj54n1_video_probe(client, rj54n1_priv);
if (ret < 0) { if (ret < 0)
v4l2_ctrl_handler_free(&rj54n1->hdl); v4l2_ctrl_handler_free(&rj54n1->hdl);
kfree(rj54n1);
}
return ret; return ret;
} }
@ -1404,7 +1398,6 @@ static int rj54n1_remove(struct i2c_client *client)
if (ssdd->free_bus) if (ssdd->free_bus)
ssdd->free_bus(ssdd); ssdd->free_bus(ssdd);
v4l2_ctrl_handler_free(&rj54n1->hdl); v4l2_ctrl_handler_free(&rj54n1->hdl);
kfree(rj54n1);
return 0; return 0;
} }

Просмотреть файл

@ -912,7 +912,6 @@ static int tw9910_probe(struct i2c_client *client,
struct i2c_adapter *adapter = struct i2c_adapter *adapter =
to_i2c_adapter(client->dev.parent); to_i2c_adapter(client->dev.parent);
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
int ret;
if (!ssdd || !ssdd->drv_priv) { if (!ssdd || !ssdd->drv_priv) {
dev_err(&client->dev, "TW9910: missing platform data!\n"); dev_err(&client->dev, "TW9910: missing platform data!\n");
@ -928,7 +927,7 @@ static int tw9910_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
@ -936,18 +935,11 @@ static int tw9910_probe(struct i2c_client *client,
v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops); v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops);
ret = tw9910_video_probe(client); return tw9910_video_probe(client);
if (ret)
kfree(priv);
return ret;
} }
static int tw9910_remove(struct i2c_client *client) static int tw9910_remove(struct i2c_client *client)
{ {
struct tw9910_priv *priv = to_tw9910(client);
kfree(priv);
return 0; return 0;
} }

Просмотреть файл

@ -148,7 +148,7 @@ static int soc_camera_platform_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
@ -173,7 +173,6 @@ static int soc_camera_platform_probe(struct platform_device *pdev)
evdrs: evdrs:
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(priv);
return ret; return ret;
} }
@ -185,7 +184,6 @@ static int soc_camera_platform_remove(struct platform_device *pdev)
p->icd->control = NULL; p->icd->control = NULL;
v4l2_device_unregister_subdev(&priv->subdev); v4l2_device_unregister_subdev(&priv->subdev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(priv);
return 0; return 0;
} }