From: Yorick Rommers <yorick-rommers@hotmail.com> To: joe@perches.com Cc: lidza.louina@gmail.com, markh@compro.net, gregkh@linuxfoundation.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Yorick Rommers <yorick-rommers@hotmail.com> Subject: [PATCH] Staging: dgnc: Using a temporary value for repeated dereferences. Date: Mon, 20 Apr 2015 09:33:04 +0200 [thread overview] Message-ID: <BLU436-SMTP4415B31E1C38072994283D9EE00@phx.gbl> (raw) In-Reply-To: <1429491259.27863.1.camel@perches.com> Sorry, it has been changed in the patch 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 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c index b13318a..ac2581a 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; if (copy_from_user(&brd, uarg, sizeof(int))) return -EFAULT; @@ -142,19 +143,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]; - di.info_bdtype = dgnc_Board[brd]->dpatype; - di.info_bdstate = dgnc_Board[brd]->dpastatus; + spin_lock_irqsave(&bd->bd_lock, flags); + + 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
WARNING: multiple messages have this Message-ID (diff)
From: Yorick Rommers <yorick-rommers@hotmail.com> To: joe@perches.com Cc: devel@driverdev.osuosl.org, lidza.louina@gmail.com, driverdev-devel@linuxdriverproject.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, Yorick Rommers <yorick-rommers@hotmail.com> Subject: [PATCH] Staging: dgnc: Using a temporary value for repeated dereferences. Date: Mon, 20 Apr 2015 09:33:04 +0200 [thread overview] Message-ID: <BLU436-SMTP4415B31E1C38072994283D9EE00@phx.gbl> (raw) In-Reply-To: <1429491259.27863.1.camel@perches.com> Sorry, it has been changed in the patch 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 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c index b13318a..ac2581a 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; if (copy_from_user(&brd, uarg, sizeof(int))) return -EFAULT; @@ -142,19 +143,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]; - di.info_bdtype = dgnc_Board[brd]->dpatype; - di.info_bdstate = dgnc_Board[brd]->dpastatus; + spin_lock_irqsave(&bd->bd_lock, flags); + + 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 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2015-04-20 7:31 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-04-19 19:18 [PATCH] Staging: dgnc: fixed code style issue Yorick Rommers 2015-04-19 20:34 ` Joe Perches 2015-04-19 21:58 ` [PATCH] Staging: dgnc: Using temporary value for repeated dereferences Yorick Rommers 2015-04-20 0:54 ` Joe Perches 2015-04-20 0:54 ` Joe Perches 2015-04-20 7:33 ` Yorick Rommers [this message] 2015-04-20 7:33 ` [PATCH] Staging: dgnc: Using a " Yorick Rommers 2015-05-03 18:50 ` Greg KH 2015-05-03 18:50 ` Greg KH 2015-04-20 8:33 ` [PATCH] Staging: dgnc: Using " Dan Carpenter 2015-04-20 10:42 ` gcc doesn't warn about uninitialized variable use in switch/case with -O (was: Re: [PATCH] Staging: dgnc: Using temporary value for repeated dereferences) Joe Perches 2015-04-20 12:28 ` Joe Perches 2015-04-20 12:28 ` Joe Perches 2015-04-20 8:27 ` [PATCH] Staging: dgnc: Using temporary value for repeated dereferences Dan Carpenter 2015-04-20 8:13 ` [PATCH] Staging: dgnc: fixed code style issue Dan Carpenter
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=BLU436-SMTP4415B31E1C38072994283D9EE00@phx.gbl \ --to=yorick-rommers@hotmail.com \ --cc=devel@driverdev.osuosl.org \ --cc=driverdev-devel@linuxdriverproject.org \ --cc=gregkh@linuxfoundation.org \ --cc=joe@perches.com \ --cc=lidza.louina@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=markh@compro.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.