Re: [PATCH] Staging: dgnc: fixed code style issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2015-04-19 at 21:18 +0200, Yorick Rommers wrote:
> A patch for a line being too long (>80) in dgnc_mgmt.c,
> fixed by making a temporary value for dgnc_Board[brd], and removing
> an unnecessary typecast.

Hello Yorick.

The patch subject isn't very descriptive.

A better subject might be something like:
"staging: dgnc: Use a temporary for repeated dereferences"

> diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
[]
> @@ -143,12 +143,14 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  		di.info_bdnum = brd;
>  
>  		spin_lock_irqsave(&dgnc_Board[brd]->bd_lock, flags);
> +		struct dgnc_board *bd = dgnc_Board[brd];

Linux style doesn't declare variables in the middle
of a function,  Variables are only declared after
an open brace.

>  
>  		di.info_bdtype = dgnc_Board[brd]->dpatype;
>  		di.info_bdstate = dgnc_Board[brd]->dpastatus;

Please change all the references of dgnc_Board[brd]-> to bd->
in this function instead of just the long line ones.

>  		di.info_ioport = 0;
>  		di.info_physaddr = (ulong) dgnc_Board[brd]->membase;
> -		di.info_physsize = (ulong) dgnc_Board[brd]->membase - dgnc_Board[brd]->membase_end;
> +		di.info_physsize = bd->membase - bd->membase_end;
> +
>  		if (dgnc_Board[brd]->state != BOARD_FAILED)
>  			di.info_nports = dgnc_Board[brd]->nasync;
>  		else


Something like:

 drivers/staging/dgnc/dgnc_mgmt.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index b13318a..215f37b 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -129,8 +129,8 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	case DIGI_GETBD:
 	{
 		int brd;
-
 		struct digi_info di;
+		struct dgnc_board *bd;
 
 		if (copy_from_user(&brd, uarg, sizeof(int)))
 			return -EFAULT;
@@ -142,19 +142,21 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 		di.info_bdnum = brd;
 
-		spin_lock_irqsave(&dgnc_Board[brd]->bd_lock, flags);
+		bd = dgnc_Board[brd];
+
+		spin_lock_irqsave(&bd->bd_lock, flags);
 
-		di.info_bdtype = dgnc_Board[brd]->dpatype;
-		di.info_bdstate = dgnc_Board[brd]->dpastatus;
+		di.info_bdtype = bd->dpatype;
+		di.info_bdstate = bd->dpastatus;
 		di.info_ioport = 0;
-		di.info_physaddr = (ulong) dgnc_Board[brd]->membase;
-		di.info_physsize = (ulong) dgnc_Board[brd]->membase - dgnc_Board[brd]->membase_end;
-		if (dgnc_Board[brd]->state != BOARD_FAILED)
-			di.info_nports = dgnc_Board[brd]->nasync;
+		di.info_physaddr = bd->membase;
+		di.info_physsize = bd->membase - bd->membase_end;
+		if (bd->state != BOARD_FAILED)
+			di.info_nports = bd->nasync;
 		else
 			di.info_nports = 0;
 
-		spin_unlock_irqrestore(&dgnc_Board[brd]->bd_lock, flags);
+		spin_unlock_irqrestore(&bd->bd_lock, flags);
 
 		if (copy_to_user(uarg, &di, sizeof(di)))
 			return -EFAULT;


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux