[PATCH] Staging: dgnc: Using temporary value for repeated dereferences.

Yorick Rommers
2015-04-19T21:58:15Z

Hello Joe,

Thank you once again for the feedback.
I've changed my patch accordingly, see below.

--------------------------------------

A patch for a line being too long (>80) in dgnc_mgmt.c,
fixed by making a temporary value for dgnc_Board[brd],
replacing all instanced of dgnc_Board[brd] with temporary value,
and removing unnecessary typecasts.

Signed-off-by: Yorick Rommers <yorick-rommers@hotmail.com>
---
drivers/staging/dgnc/dgnc_mgmt.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index b13318a..0437117 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -131,6 +131,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
int brd;

struct digi_info di;
+ struct dgnc_board *bd = dgnc_Board[brd];

if (copy_from_user(&brd, uarg, sizeof(int)))
return -EFAULT;
@@ -142,19 +143,19 @@ 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);
+ 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;
--
2.3.5