Skip to contentSkip to conversation

staging: bcm2835-camera: remove function get_msg_context

PATCH Superseded Aishwarya Pant 2 participants 4 messages Mar 6, 2017 – Mar 7, 2017

Subsystems (3)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover staging: bcm2835-camera: remove function get_msg_context

This patchset safely replaces function get_msg_context with a memory allocation at the caller.

Aishwarya Pant (2):
staging: bcm2835-camera: replace kmalloc and memset with kzalloc
staging: bcm2835-camera: remove redundant function get_msg_context

 .../staging/vc04_services/bcm2835-camera/mmal-vchiq.c    | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 staging: bcm2835-camera: replace kmalloc and memset with kzalloc

This patch replaces kmalloc and memset with kzalloc

---
 drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +2 -3
index ca6e9eb..ded9a99 100644
@@ -168,9 +168,8 @@ static struct mmal_msg_context *get_msg_context(struct vchiq_mmal_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 */
+	msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
 
 	return msg_context;
 }
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 1/2] staging: bcm2835-camera: replace kmalloc and memset with kzalloc

Quoted 12 lines · Aishwarya Pant

This patch replaces kmalloc and memset with kzalloc

---
 drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +0 -0
index ca6e9eb..ded9a99 100644

drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c static struct mmal_msg_context *get_msg_context(struct vchiq_mmal_instance · line 172

Quoted 8 lines
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +2 -3
@@ -168,9 +168,8 @@ static struct mmal_msg_context *get_msg_context(struct vchiq_mmal_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 */
+	msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);

This patch isn't needed in this series anymore, right? Please resend just the needed patch, don't change code that is going to be deleted on the next one for no reason.

thanks,

greg k-h

#3 lore raw

PATCH 2/2 staging: bcm2835-camera: remove redundant function get_msg_context

In reply to Aishwarya Pant

This patch removes get_msg_context(..) with a kzalloc at the caller. This is safe as the only usage was found in mmal-vchiq.c which has been refactored.

---
 drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +2 -13
index ded9a99..1650bbf 100644
@@ -163,17 +163,6 @@ struct vchiq_mmal_instance {
 	struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS];
 };
 
-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 kzalloc */
-	msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
-
-	return msg_context;
-}
-
 static void release_msg_context(struct mmal_msg_context *msg_context)
 {
 	kfree(msg_context);
@@ -394,8 +383,8 @@ buffer_from_host(struct vchiq_mmal_instance *instance,
 	if (mutex_lock_interruptible(&instance->bulk_mutex))
 		return -EINTR;
 
-	/* get context */
-	msg_context = get_msg_context(instance);
+	/* todo: should this be allocated from a pool to avoid kzalloc */
+	msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
 	if (!msg_context) {
 		ret = -ENOMEM;
 		goto unlock;
Signature · 1 line
2.7.4