All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] staging: vc04_services: Replace typedef with struct
@ 2017-03-15 13:14 Gargi Sharma
  2017-03-15 16:49 ` Gargi Sharma
  0 siblings, 1 reply; 2+ messages in thread
From: Gargi Sharma @ 2017-03-15 13:14 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: gregkh, Gargi Sharma

Using typedef for a structure type and upper case struct names is not
suggested in Linux kernel coding style guidelines. Hence, occurences
of typedefs have been removed and struct names converted to lowercase
in the file. Grep was also used to ensure that all occurence of the
typedefs have been removed. The module compiles without any warnings
or errors.

Script 1:
@r1@
type T;
@@

typedef struct { ... } T;

@script:python c1@
T2;
T << r1.T;
@@
if T[-2:] =="_T":
  coccinelle.T2 = T[:-2].lower();
  print T
else:
  coccinelle.T2=T.lower();

@r2@
type r1.T;
identifier c1.T2;
@@
-typedef
struct
+ T2
{ ... }
-T
;

@r3@
type r1.T;
identifier c1.T2;
@@
- T
+ struct T2

Script 2:
@@
typedef VCHIQ_ELEMENT_T;
@@

(
- VCHIQ_ELEMENT_T
+ struct vchiq_element
)

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
Changes in v4:
	- Rebased and sent the patch.
Changes in v3:
        - Add changes to the changelog.
Changes in v2:
        - Convert the struct name to lowercase.

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c   | 8 ++++----
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h    | 4 ++--
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 1dc8627..03e1a13 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -406,7 +406,7 @@ static void close_delivered(USER_SERVICE_T *user_service)
 }
 
 struct vchiq_io_copy_callback_context {
-	VCHIQ_ELEMENT_T *current_element;
+	struct vchiq_element *current_element;
 	size_t current_element_offset;
 	unsigned long elements_to_go;
 	size_t current_offset;
@@ -483,7 +483,7 @@ vchiq_ioc_copy_element_data(
  **************************************************************************/
 static VCHIQ_STATUS_T
 vchiq_ioc_queue_message(VCHIQ_SERVICE_HANDLE_T handle,
-			VCHIQ_ELEMENT_T *elements,
+			struct vchiq_element *elements,
 			unsigned long count)
 {
 	struct vchiq_io_copy_callback_context context;
@@ -752,9 +752,9 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 		if ((service != NULL) && (args.count <= MAX_ELEMENTS)) {
 			/* Copy elements into kernel space */
-			VCHIQ_ELEMENT_T elements[MAX_ELEMENTS];
+			struct vchiq_element elements[MAX_ELEMENTS];
 			if (copy_from_user(elements, args.elements,
-				args.count * sizeof(VCHIQ_ELEMENT_T)) == 0)
+				args.count * sizeof(struct vchiq_element)) == 0)
 				status = vchiq_ioc_queue_message
 					(args.handle,
 					elements, args.count);
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h
index 377e8e4..0e27085 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h
@@ -88,10 +88,10 @@ typedef struct vchiq_header_struct {
 	char data[0];           /* message */
 } VCHIQ_HEADER_T;
 
-typedef struct {
+struct vchiq_element {
 	const void *data;
 	unsigned int size;
-} VCHIQ_ELEMENT_T;
+};
 
 typedef unsigned int VCHIQ_SERVICE_HANDLE_T;
 
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h
index 6137ae9..9f85995 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h
@@ -50,7 +50,7 @@ typedef struct {
 typedef struct {
 	unsigned int handle;
 	unsigned int count;
-	const VCHIQ_ELEMENT_T *elements;
+	const struct vchiq_element *elements;
 } VCHIQ_QUEUE_MESSAGE_T;
 
 typedef struct {
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] staging: vc04_services: Replace typedef with struct
  2017-03-15 13:14 [PATCH v4] staging: vc04_services: Replace typedef with struct Gargi Sharma
@ 2017-03-15 16:49 ` Gargi Sharma
  0 siblings, 0 replies; 2+ messages in thread
From: Gargi Sharma @ 2017-03-15 16:49 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: Greg KH, Gargi Sharma

Please ignore. A rebased version has been sent.

Thanks,
Gargi
On Wed, Mar 15, 2017 at 6:44 PM, Gargi Sharma <gs051095@gmail.com> wrote:
> Using typedef for a structure type and upper case struct names is not
> suggested in Linux kernel coding style guidelines. Hence, occurences
> of typedefs have been removed and struct names converted to lowercase
> in the file. Grep was also used to ensure that all occurence of the
> typedefs have been removed. The module compiles without any warnings
> or errors.
>
> Script 1:
> @r1@
> type T;
> @@
>
> typedef struct { ... } T;
>
> @script:python c1@
> T2;
> T << r1.T;
> @@
> if T[-2:] =="_T":
>   coccinelle.T2 = T[:-2].lower();
>   print T
> else:
>   coccinelle.T2=T.lower();
>
> @r2@
> type r1.T;
> identifier c1.T2;
> @@
> -typedef
> struct
> + T2
> { ... }
> -T
> ;
>
> @r3@
> type r1.T;
> identifier c1.T2;
> @@
> - T
> + struct T2
>
> Script 2:
> @@
> typedef VCHIQ_ELEMENT_T;
> @@
>
> (
> - VCHIQ_ELEMENT_T
> + struct vchiq_element
> )
>
> Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> ---
> Changes in v4:
>         - Rebased and sent the patch.
> Changes in v3:
>         - Add changes to the changelog.
> Changes in v2:
>         - Convert the struct name to lowercase.
>
> Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> ---
>  drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c   | 8 ++++----
>  drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h    | 4 ++--
>  drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 2 +-
>  3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> index 1dc8627..03e1a13 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> @@ -406,7 +406,7 @@ static void close_delivered(USER_SERVICE_T *user_service)
>  }
>
>  struct vchiq_io_copy_callback_context {
> -       VCHIQ_ELEMENT_T *current_element;
> +       struct vchiq_element *current_element;
>         size_t current_element_offset;
>         unsigned long elements_to_go;
>         size_t current_offset;
> @@ -483,7 +483,7 @@ vchiq_ioc_copy_element_data(
>   **************************************************************************/
>  static VCHIQ_STATUS_T
>  vchiq_ioc_queue_message(VCHIQ_SERVICE_HANDLE_T handle,
> -                       VCHIQ_ELEMENT_T *elements,
> +                       struct vchiq_element *elements,
>                         unsigned long count)
>  {
>         struct vchiq_io_copy_callback_context context;
> @@ -752,9 +752,9 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>
>                 if ((service != NULL) && (args.count <= MAX_ELEMENTS)) {
>                         /* Copy elements into kernel space */
> -                       VCHIQ_ELEMENT_T elements[MAX_ELEMENTS];
> +                       struct vchiq_element elements[MAX_ELEMENTS];
>                         if (copy_from_user(elements, args.elements,
> -                               args.count * sizeof(VCHIQ_ELEMENT_T)) == 0)
> +                               args.count * sizeof(struct vchiq_element)) == 0)
>                                 status = vchiq_ioc_queue_message
>                                         (args.handle,
>                                         elements, args.count);
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h
> index 377e8e4..0e27085 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h
> @@ -88,10 +88,10 @@ typedef struct vchiq_header_struct {
>         char data[0];           /* message */
>  } VCHIQ_HEADER_T;
>
> -typedef struct {
> +struct vchiq_element {
>         const void *data;
>         unsigned int size;
> -} VCHIQ_ELEMENT_T;
> +};
>
>  typedef unsigned int VCHIQ_SERVICE_HANDLE_T;
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h
> index 6137ae9..9f85995 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h
> @@ -50,7 +50,7 @@ typedef struct {
>  typedef struct {
>         unsigned int handle;
>         unsigned int count;
> -       const VCHIQ_ELEMENT_T *elements;
> +       const struct vchiq_element *elements;
>  } VCHIQ_QUEUE_MESSAGE_T;
>
>  typedef struct {
> --
> 2.7.4
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-15 16:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-15 13:14 [PATCH v4] staging: vc04_services: Replace typedef with struct Gargi Sharma
2017-03-15 16:49 ` Gargi Sharma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.