Message ID | 1428361053-20411-3-git-send-email-sakari.ailus@iki.fi (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hello Sakari, Thank you for the patch. On Tuesday 07 April 2015 01:57:30 Sakari Ailus wrote: > Clean the entire struct starting from bus_type. As more fields are added, no > changes will be needed in the function to reset their value explicitly. I would s/Clean/Clear/ or s/Clean/Zero/. Same for the comment in the code. Apart from that, Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> > --- > drivers/media/v4l2-core/v4l2-of.c | 5 +++-- > include/media/v4l2-of.h | 1 + > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-of.c > b/drivers/media/v4l2-core/v4l2-of.c index 83143d3..3ac6348 100644 > --- a/drivers/media/v4l2-core/v4l2-of.c > +++ b/drivers/media/v4l2-core/v4l2-of.c > @@ -149,8 +149,9 @@ int v4l2_of_parse_endpoint(const struct device_node > *node, int rval; > > of_graph_parse_endpoint(node, &endpoint->base); > - endpoint->bus_type = 0; > - memset(&endpoint->bus, 0, sizeof(endpoint->bus)); > + /* Zero fields from bus_type to until the end */ > + memset(&endpoint->bus_type, 0, sizeof(*endpoint) - > + offsetof(typeof(*endpoint), bus_type)); > > rval = v4l2_of_parse_csi_bus(node, endpoint); > if (rval) > diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h > index f66b92c..5bbdfbf 100644 > --- a/include/media/v4l2-of.h > +++ b/include/media/v4l2-of.h > @@ -60,6 +60,7 @@ struct v4l2_of_bus_parallel { > */ > struct v4l2_of_endpoint { > struct of_endpoint base; > + /* Fields below this line will be cleaned by v4l2_of_parse_endpoint() */ > enum v4l2_mbus_type bus_type; > union { > struct v4l2_of_bus_parallel parallel;
On Tue, Apr 07, 2015 at 12:47:56PM +0300, Laurent Pinchart wrote: > Hello Sakari, > > Thank you for the patch. > > On Tuesday 07 April 2015 01:57:30 Sakari Ailus wrote: > > Clean the entire struct starting from bus_type. As more fields are added, no > > changes will be needed in the function to reset their value explicitly. > > I would s/Clean/Clear/ or s/Clean/Zero/. Same for the comment in the code. > Apart from that, I'll use zero. It's clearer. :-) > Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Thanks!!
diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c index 83143d3..3ac6348 100644 --- a/drivers/media/v4l2-core/v4l2-of.c +++ b/drivers/media/v4l2-core/v4l2-of.c @@ -149,8 +149,9 @@ int v4l2_of_parse_endpoint(const struct device_node *node, int rval; of_graph_parse_endpoint(node, &endpoint->base); - endpoint->bus_type = 0; - memset(&endpoint->bus, 0, sizeof(endpoint->bus)); + /* Zero fields from bus_type to until the end */ + memset(&endpoint->bus_type, 0, sizeof(*endpoint) - + offsetof(typeof(*endpoint), bus_type)); rval = v4l2_of_parse_csi_bus(node, endpoint); if (rval) diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h index f66b92c..5bbdfbf 100644 --- a/include/media/v4l2-of.h +++ b/include/media/v4l2-of.h @@ -60,6 +60,7 @@ struct v4l2_of_bus_parallel { */ struct v4l2_of_endpoint { struct of_endpoint base; + /* Fields below this line will be cleaned by v4l2_of_parse_endpoint() */ enum v4l2_mbus_type bus_type; union { struct v4l2_of_bus_parallel parallel;
Clean the entire struct starting from bus_type. As more fields are added, no changes will be needed in the function to reset their value explicitly. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> --- drivers/media/v4l2-core/v4l2-of.c | 5 +++-- include/media/v4l2-of.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)