Skip to contentSkip to conversation

staging: android: ion: remove duplicate buffer field initializes

PATCH In review Todd Poynor 2 participants 2 messages Apr 21, 2018 – Apr 23, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: android: ion: remove duplicate buffer field initializes

As a result of various previous patches, ion_buffer_create() now has two sets of identical statements for initializing two fields of the buffer struct, next to each other. Remove one set.

Move the initialization of these two fields together with the statements that initialize the other two fields from the function parameters, prior to the heap allocate() call, for consistency.

---
 drivers/staging/android/ion/ion.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/android/ion/ion.c +2 -4
index e74db7902549..269a431646be 100644
@@ -74,6 +74,8 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 
 	buffer->heap = heap;
 	buffer->flags = flags;
+	buffer->dev = dev;
+	buffer->size = len;
 
 	ret = heap->ops->allocate(heap, buffer, len, flags);
 
@@ -93,11 +95,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 		goto err1;
 	}
 
-	buffer->dev = dev;
-	buffer->size = len;
 
-	buffer->dev = dev;
-	buffer->size = len;
 	INIT_LIST_HEAD(&buffer->attachments);
 	mutex_init(&buffer->lock);
 	mutex_lock(&dev->buffer_lock);
Signature · 1 line
2.17.0.484.g0c8726318c-goog
Acked-by on v1 1/1
#1 lore raw

Hello Todd,

Thanks for the patch.

Quoted 9 lines · Todd Poynor

As a result of various previous patches, ion_buffer_create() now has two sets of identical statements for initializing two fields of the buffer struct, next to each other. Remove one set.

Move the initialization of these two fields together with the statements that initialize the other two fields from the function parameters, prior to the heap allocate() call, for consistency.

Quoted 30 lines
---
 drivers/staging/android/ion/ion.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/android/ion/ion.c +2 -5
index e74db7902549..269a431646be 100644
@@ -74,6 +74,8 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 
        buffer->heap = heap;
        buffer->flags = flags;
+       buffer->dev = dev;
+       buffer->size = len;
 
        ret = heap->ops->allocate(heap, buffer, len, flags);
 
@@ -93,11 +95,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
                goto err1;
        }
 
-       buffer->dev = dev;
-       buffer->size = len;
 
-       buffer->dev = dev;
-       buffer->size = len;
        INIT_LIST_HEAD(&buffer->attachments);
        mutex_init(&buffer->lock);
        mutex_lock(&dev->buffer_lock);
--
Quoted 2 lines

2.17.0.484.g0c8726318c-goog

Best,
Sumit.