[Patch v1 01/21] staging: gpib: Using struct gpib_board_type_ioctl

Michael Rubin posted 21 patches 10 months ago
[Patch v1 01/21] staging: gpib: Using struct gpib_board_type_ioctl
Posted by Michael Rubin 10 months ago
Using Linux code style for 'struct gpib_board_type_ioctl' to remove typedef.

Adhering to Linux code style.

Reported by checkpatch.pl

In general, a pointer, or a struct that has elements that can reasonably be
directly accessed should never be a typedef.

Signed-off-by: Michael Rubin <matchstick@neverthere.org>
---
 drivers/staging/gpib/common/gpib_os.c  | 5 +++--
 drivers/staging/gpib/uapi/gpib_ioctl.h | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/gpib/common/gpib_os.c b/drivers/staging/gpib/common/gpib_os.c
index a1992a2b06a0..e12a9e56d808 100644
--- a/drivers/staging/gpib/common/gpib_os.c
+++ b/drivers/staging/gpib/common/gpib_os.c
@@ -813,7 +813,7 @@ static int board_type_ioctl(struct gpib_file_private *file_priv,
 			    struct gpib_board *board, unsigned long arg)
 {
 	struct list_head *list_ptr;
-	board_type_ioctl_t cmd;
+	struct gpib_board_type_ioctl cmd;
 	int retval;
 
 	if (!capable(CAP_SYS_ADMIN))
@@ -821,7 +821,8 @@ static int board_type_ioctl(struct gpib_file_private *file_priv,
 	if (board->online)
 		return -EBUSY;
 
-	retval = copy_from_user(&cmd, (void __user *)arg, sizeof(board_type_ioctl_t));
+	retval = copy_from_user(&cmd, (void __user *)arg,
+				sizeof(struct gpib_board_type_ioctl));
 	if (retval)
 		return retval;
 
diff --git a/drivers/staging/gpib/uapi/gpib_ioctl.h b/drivers/staging/gpib/uapi/gpib_ioctl.h
index 6202865278ea..4ddcbc2a81b0 100644
--- a/drivers/staging/gpib/uapi/gpib_ioctl.h
+++ b/drivers/staging/gpib/uapi/gpib_ioctl.h
@@ -12,9 +12,9 @@
 
 #define GPIB_CODE 160
 
-typedef struct {
+struct gpib_board_type_ioctl {
 	char name[100];
-} board_type_ioctl_t;
+};
 
 /* argument for read/write/command ioctls */
 typedef struct {
@@ -143,7 +143,7 @@ enum gpib_ioctl {
 	CFCBASE = _IOW(GPIB_CODE, 21, uint64_t),
 	CFCIRQ = _IOW(GPIB_CODE, 22, unsigned int),
 	CFCDMA = _IOW(GPIB_CODE, 23, unsigned int),
-	CFCBOARDTYPE = _IOW(GPIB_CODE, 24, board_type_ioctl_t),
+	CFCBOARDTYPE = _IOW(GPIB_CODE, 24, struct gpib_board_type_ioctl),
 
 	IBMUTEX = _IOW(GPIB_CODE, 26, int),
 	IBSPOLL_BYTES = _IOWR(GPIB_CODE, 27, spoll_bytes_ioctl_t),
-- 
2.43.0
Re: [Patch v1 01/21] staging: gpib: Using struct gpib_board_type_ioctl
Posted by Dan Carpenter 10 months ago
On Wed, Apr 09, 2025 at 05:58:43AM +0000, Michael Rubin wrote:
> diff --git a/drivers/staging/gpib/uapi/gpib_ioctl.h b/drivers/staging/gpib/uapi/gpib_ioctl.h
> index 6202865278ea..4ddcbc2a81b0 100644
> --- a/drivers/staging/gpib/uapi/gpib_ioctl.h
> +++ b/drivers/staging/gpib/uapi/gpib_ioctl.h
> @@ -12,9 +12,9 @@
>  
>  #define GPIB_CODE 160
>  
> -typedef struct {
> +struct gpib_board_type_ioctl {
>  	char name[100];
> -} board_type_ioctl_t;
> +};

This breaks user API so now user space can't compile.  I don't think
any of these 21 patches can be applied.

regards,
dan carpenter
Re: [Patch v1 01/21] staging: gpib: Using struct gpib_board_type_ioctl
Posted by Dave Penkler 10 months ago
On Wed, Apr 09, 2025 at 11:10:41AM +0300, Dan Carpenter wrote:
> On Wed, Apr 09, 2025 at 05:58:43AM +0000, Michael Rubin wrote:
> > diff --git a/drivers/staging/gpib/uapi/gpib_ioctl.h b/drivers/staging/gpib/uapi/gpib_ioctl.h
> > index 6202865278ea..4ddcbc2a81b0 100644
> > --- a/drivers/staging/gpib/uapi/gpib_ioctl.h
> > +++ b/drivers/staging/gpib/uapi/gpib_ioctl.h
> > @@ -12,9 +12,9 @@
> >  
> >  #define GPIB_CODE 160
> >  
> > -typedef struct {
> > +struct gpib_board_type_ioctl {
> >  	char name[100];
> > -} board_type_ioctl_t;
> > +};
> 
> This breaks user API so now user space can't compile.  I don't think
> any of these 21 patches can be applied.
>
> regards,
> dan carpenter
> 
 
These patches are OK. I will make a new release of the userspace libraries
with a compat include that defines the typedefs.
cheers,
-Dave
Re: [Patch v1 01/21] staging: gpib: Using struct gpib_board_type_ioctl
Posted by Dan Carpenter 10 months ago
On Wed, Apr 09, 2025 at 10:56:42AM +0200, Dave Penkler wrote:
> On Wed, Apr 09, 2025 at 11:10:41AM +0300, Dan Carpenter wrote:
> > On Wed, Apr 09, 2025 at 05:58:43AM +0000, Michael Rubin wrote:
> > > diff --git a/drivers/staging/gpib/uapi/gpib_ioctl.h b/drivers/staging/gpib/uapi/gpib_ioctl.h
> > > index 6202865278ea..4ddcbc2a81b0 100644
> > > --- a/drivers/staging/gpib/uapi/gpib_ioctl.h
> > > +++ b/drivers/staging/gpib/uapi/gpib_ioctl.h
> > > @@ -12,9 +12,9 @@
> > >  
> > >  #define GPIB_CODE 160
> > >  
> > > -typedef struct {
> > > +struct gpib_board_type_ioctl {
> > >  	char name[100];
> > > -} board_type_ioctl_t;
> > > +};
> > 
> > This breaks user API so now user space can't compile.  I don't think
> > any of these 21 patches can be applied.
> >
> > regards,
> > dan carpenter
> > 
>  
> These patches are OK. I will make a new release of the userspace libraries
> with a compat include that defines the typedefs.

Ah that's fine then.  Thanks.

regards,
dan carpenter