From b01edcbd409cf713ff4516c6e1e057834b4b43d6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 18 Jan 2021 02:52:58 +0100 Subject: media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The functions that add an async subdev to an async subdev notifier take as an argument the size of the container structure they need to allocate. This is error prone, as passing an invalid size will not be caught by the compiler. Wrap those functions in macros that take a container type instead of a size, and cast the returned pointer to the desired type. The compiler will catch mistakes if the incorrect type is passed to the macro, as the assignment types won't match. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi Signed-off-by: Ezequiel Garcia Signed-off-by: Sakari Ailus Reviewed-by: Helen Koike Reviewed-by: Tomi Valkeinen (core+ti-cal) Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/ti-vpe/cal.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers/media/platform/ti-vpe/cal.c') diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index 5fb627811c6b..fa0931788040 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -685,23 +685,21 @@ static int cal_async_notifier_register(struct cal_dev *cal) for (i = 0; i < cal->data->num_csi2_phy; ++i) { struct cal_camerarx *phy = cal->phy[i]; struct cal_v4l2_async_subdev *casd; - struct v4l2_async_subdev *asd; struct fwnode_handle *fwnode; if (!phy->sensor_node) continue; fwnode = of_fwnode_handle(phy->sensor_node); - asd = v4l2_async_notifier_add_fwnode_subdev(&cal->notifier, - fwnode, - sizeof(*casd)); - if (IS_ERR(asd)) { + casd = v4l2_async_notifier_add_fwnode_subdev(&cal->notifier, + fwnode, + struct cal_v4l2_async_subdev); + if (IS_ERR(casd)) { phy_err(phy, "Failed to add subdev to notifier\n"); - ret = PTR_ERR(asd); + ret = PTR_ERR(casd); goto error; } - casd = to_cal_asd(asd); casd->phy = phy; } -- cgit v1.2.3