Skip to contentSkip to conversation

Fix multiple checkpatch warning

PATCH In review Anchal Jain 3 participants 5 messages Sep 30, 2016 – Oct 2, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Fix multiple checkpatch warning

0001-staging-android-ion-add-comment-to-mutex.patch 0002-staging-android-ion-Replace-structure-with-the-point.patch

Anchal Jain (2):

staging: android: ion: Replace structure with the *pointer of
structure in kzalloc
staging: android: ion: add comment to mutex

 drivers/staging/android/ion/ion.c       | 14 +++++++-------
 drivers/staging/iio/adc/ad7192.c        | 15 ++++++++++-----
 drivers/staging/rtl8188eu/core/rtw_ap.c |  6 +++---
 3 files changed, 20 insertions(+), 15 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 staging: iio: adc: ad7192: Fix block comment

This patch fix the problem of block comment when the block comment detect by the checkpatch.pl
CHECK: Block comments use a trailing */ on a separate line
so to fix this problem just remove trailing */ and add it on the next line

---
 drivers/staging/iio/adc/ad7192.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/staging/iio/adc/ad7192.c +10 -5
index f843f19..7c0635f 100644
@@ -36,9 +36,11 @@
 #define AD7192_REG_ID		4 /* ID Register	     (RO, 8-bit) */
 #define AD7192_REG_GPOCON	5 /* GPOCON Register	     (RO, 8-bit) */
 #define AD7192_REG_OFFSET	6 /* Offset Register	     (RW, 16-bit
-				   * (AD7792)/24-bit (AD7192)) */
+				   * (AD7792)/24-bit (AD7192))
+				   */
 #define AD7192_REG_FULLSALE	7 /* Full-Scale Register
-				   * (RW, 16-bit (AD7792)/24-bit (AD7192)) */
+				   * (RW, 16-bit (AD7792)/24-bit (AD7192))
+				   */
 
 /* Communications Register Bit Designations (AD7192_REG_COMM) */
 #define AD7192_COMM_WEN		BIT(7) /* Write Enable */
@@ -81,12 +83,15 @@
 
 /* Mode Register: AD7192_MODE_CLKSRC options */
 #define AD7192_CLK_EXT_MCLK1_2		0 /* External 4.92 MHz Clock connected
-					   * from MCLK1 to MCLK2 */
+					   * from MCLK1 to MCLK2
+					   */
 #define AD7192_CLK_EXT_MCLK2		1 /* External Clock applied to MCLK2 */
 #define AD7192_CLK_INT			2 /* Internal 4.92 MHz Clock not
-					   * available at the MCLK2 pin */
+					   * available at the MCLK2 pin
+					   */
 #define AD7192_CLK_INT_CO		3 /* Internal 4.92 MHz Clock available
-					   * at the MCLK2 pin */
+					   * at the MCLK2 pin
+					   */
 
 /* Configuration Register Bit Designations (AD7192_REG_CONF) */
 
Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH] staging: iio: adc: ad7192: Fix block comment

Quoted 9 lines · Anchal Jain

This patch fix the problem of block comment when the block comment detect by the checkpatch.pl
CHECK: Block comments use a trailing */ on a separate line
so to fix this problem just remove trailing */ and add it on the next line

---
 drivers/staging/iio/adc/ad7192.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Please always cc: the proper maintainers for stuff like this, I think you forgot some...

thanks,

greg k-h

#3 lore raw

PATCH 2/2 staging: android: ion: Replace structure with the *pointer of structure in kzalloc

In reply to Anchal Jain

Replace structure with the *pointer of stucture in kzalloc Use pointer instead of structure to save memory and run faster because it doesn't have to duplicate the data.

---
 drivers/staging/android/ion/ion.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/android/ion/ion.c +5 -5
index 7ff2a7e..5f94aee 100644
@@ -184,7 +184,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 	struct scatterlist *sg;
 	int i, ret;
 
-	buffer = kzalloc(sizeof(struct ion_buffer), GFP_KERNEL);
+	buffer = kzalloc(sizeof(*ion_buffer_create), GFP_KERNEL);
 	if (!buffer)
 		return ERR_PTR(-ENOMEM);
 
@@ -341,7 +341,7 @@ static struct ion_handle *ion_handle_create(struct ion_client *client,
 {
 	struct ion_handle *handle;
 
-	handle = kzalloc(sizeof(struct ion_handle), GFP_KERNEL);
+	handle = kzalloc(sizeof(*handle), GFP_KERNEL);
 	if (!handle)
 		return ERR_PTR(-ENOMEM);
 	kref_init(&handle->ref);
@@ -802,7 +802,7 @@ struct ion_client *ion_client_create(struct ion_device *dev,
 	}
 	task_unlock(current->group_leader);
 
-	client = kzalloc(sizeof(struct ion_client), GFP_KERNEL);
+	client = kzalloc(sizeof(*ion_client_create), GFP_KERNEL);
 	if (!client)
 		goto err_put_task_struct;
 
@@ -1010,7 +1010,7 @@ static void ion_vm_open(struct vm_area_struct *vma)
 	struct ion_buffer *buffer = vma->vm_private_data;
 	struct ion_vma_list *vma_list;
 
-	vma_list = kmalloc(sizeof(struct ion_vma_list), GFP_KERNEL);
+	vma_list = kmalloc(sizeof(*vma_list), GFP_KERNEL);
 	if (!vma_list)
 		return;
 	vma_list->vma = vma;
@@ -1621,7 +1621,7 @@ struct ion_device *ion_device_create(long (*custom_ioctl)
 	struct ion_device *idev;
 	int ret;
 
-	idev = kzalloc(sizeof(struct ion_device), GFP_KERNEL);
+	idev = kzalloc(sizeof(*ion_device_create), GFP_KERNEL);
 	if (!idev)
 		return ERR_PTR(-ENOMEM);
 
Signature · 1 line
1.9.1
#4 lore raw

Re: [Outreachy kernel] [PATCH 2/2] staging: android: ion: Replace structure with the *pointer of structure in kzalloc

Quoted 3 lines · Anchal Jain

Replace structure with the *pointer of stucture in kzalloc Use pointer instead of structure to save memory and run faster because it doesn't have to duplicate the data.

The explanation is not correct. The argument of sizeof is not evaluated. The compiler just checks the type, and replaces the sizeof call with the size of the type.

Look at Documentation/CodingStyle for the proper reason why the form *x may be preferred.

Quoted 11 lines
---
 drivers/staging/android/ion/ion.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/android/ion/ion.c +0 -0
index 7ff2a7e..5f94aee 100644

drivers/staging/android/ion/ion.c static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, · line 187

Quoted 5 lines
drivers/staging/android/ion/ion.c +1 -1
@@ -184,7 +184,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 	struct scatterlist *sg;
 	int i, ret;
 
-	buffer = kzalloc(sizeof(struct ion_buffer), GFP_KERNEL);
+	buffer = kzalloc(sizeof(*ion_buffer_create), GFP_KERNEL);

This is not correct. ion_buffer_create is a function that returns a value of type struct ion_buffer. I'm a bit surprised that this would compile, but in any case it would not give the same size as the size of the structure.

Check the subsequent changes accordingly.

julia

Quoted 49 lines
drivers/staging/android/ion/ion.c +4 -5
 	if (!buffer)
 		return ERR_PTR(-ENOMEM);
 
@@ -341,7 +341,7 @@ static struct ion_handle *ion_handle_create(struct ion_client *client,
 {
 	struct ion_handle *handle;
 
-	handle = kzalloc(sizeof(struct ion_handle), GFP_KERNEL);
+	handle = kzalloc(sizeof(*handle), GFP_KERNEL);
 	if (!handle)
 		return ERR_PTR(-ENOMEM);
 	kref_init(&handle->ref);
@@ -802,7 +802,7 @@ struct ion_client *ion_client_create(struct ion_device *dev,
 	}
 	task_unlock(current->group_leader);
 
-	client = kzalloc(sizeof(struct ion_client), GFP_KERNEL);
+	client = kzalloc(sizeof(*ion_client_create), GFP_KERNEL);
 	if (!client)
 		goto err_put_task_struct;
 
@@ -1010,7 +1010,7 @@ static void ion_vm_open(struct vm_area_struct *vma)
 	struct ion_buffer *buffer = vma->vm_private_data;
 	struct ion_vma_list *vma_list;
 
-	vma_list = kmalloc(sizeof(struct ion_vma_list), GFP_KERNEL);
+	vma_list = kmalloc(sizeof(*vma_list), GFP_KERNEL);
 	if (!vma_list)
 		return;
 	vma_list->vma = vma;
@@ -1621,7 +1621,7 @@ struct ion_device *ion_device_create(long (*custom_ioctl)
 	struct ion_device *idev;
 	int ret;
 
-	idev = kzalloc(sizeof(struct ion_device), GFP_KERNEL);
+	idev = kzalloc(sizeof(*ion_device_create), GFP_KERNEL);
 	if (!idev)
 		return ERR_PTR(-ENOMEM);
 
--

1.9.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/2d05b9d8c7873fa3e04438f4deabadc372e132df.1475252219.git.anchalj109%40gmail.com.
For more options, visit https://groups.google.com/d/optout.