staging: bcm2835-camera: replace kmalloc with kzalloc
Subsystems (3)
PATCH v2 1/1 staging: bcm2835-camera: replace kmalloc with kzalloc
This patch replaces two instances of kmalloc and memset with kzalloc and refactors function get_msg_context(..)
Signed-off-by Aishwarya Pant <[email protected]>
---
Changes in v2:
- Return out of memory error number when kzalloc fails
- Refactor get_msg_context
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +5 -8
@@ -166,13 +166,9 @@ struct vchiq_mmal_instance {static struct mmal_msg_context *get_msg_context (struct vchiq_mmal_instance *instance) { -struct mmal_msg_context *msg_context; - -/* todo: should this be allocated from a pool to avoid kmalloc */ - msg_context =kmalloc (sizeof (*msg_context),GFP_KERNEL ); -memset (msg_context,0 ,sizeof (*msg_context)); +/* todo: should this be allocated from a pool to avoid kzalloc */ +return kzalloc (sizeof (*msg_context),GFP_KERNEL ); -return msg_context; }static void release_msg_context (struct mmal_msg_context *msg_context)
@@ -1881,8 +1877,9 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)return -EIO ; } - instance =kmalloc (sizeof (*instance),GFP_KERNEL ); -memset (instance,0 ,sizeof (*instance)); + instance =kzalloc (sizeof (*instance),GFP_KERNEL ); +if (!instance) +return -ENOMEM ;mutex_init (&instance->vchiq_mutex);mutex_init (&instance->bulk_mutex);
Signature · 1 line
2.7.4
Greg Kroah-Hartman
maintainerQuoted 2 lines · Aishwarya Pant
This patch replaces two instances of kmalloc and memset with kzalloc and refactors function
get_msg_context(..)
What did you refactor? Why do two things at once?
Quoted 16 lines
Signed-off-by Aishwarya Pant <[email protected]>---
Changes in v2:
- Return out of memory error number when kzalloc fails
- Refactorget_msg_contextdrivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +0
-0
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c struct vchiq_mmal_instance { · line 170
Quoted 10 lines
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +2
-5@@ -166,13 +166,9 @@ struct vchiq_mmal_instance {static struct mmal_msg_context *get_msg_context (struct vchiq_mmal_instance *instance) { -struct mmal_msg_context *msg_context; - -/* todo: should this be allocated from a pool to avoid kmalloc */ - msg_context =kmalloc (sizeof (*msg_context),GFP_KERNEL ); -memset (msg_context,0 ,sizeof (*msg_context)); +/* todo: should this be allocated from a pool to avoid kzalloc */ +return kzalloc (sizeof (*msg_context),GFP_KERNEL );
Why is this function even needed anymore? Why not just call kzalloc() instead of this one?
thanks,
greg k-h