Re: [patch 15/17] drivers/scsi: Use DIV_ROUND_UP

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

 



On Mon, 22 Sep 2008, Matthew Wilcox wrote:

> On Mon, Sep 22, 2008 at 02:56:51PM -0700, akpm@xxxxxxxxxxxxxxxxxxxx wrote:
> >  
> >  		one_clock = esp->ccycle / 1000;
> >  		rounded_up = (period << 2);
> > -		rounded_up = (rounded_up + one_clock - 1) / one_clock;
> > +		rounded_up = DIV_ROUND_UP(rounded_up, one_clock);
> >  		stp = rounded_up;
> >  		if (stp && esp->rev >= FAS236) {
> >  			if (stp >= 50)
> 
> Is this not exactly equivalent to:
> 
> 		one_clock = esp->ccycle / 1000;
> 		stp = DIV_ROUND_UP(period << 2, one_clock);
> 
> (rounded_up is local to this if condition).

Agreed.  An updated patch is below.

julia

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

From: Julia Lawall <julia@xxxxxxx>

Use the macro DIV_ROUND_UP and eliminate the variable rounded_up, as
suggested by Matthew Wilcox.

Signed-off-by: Julia Lawall <julia@xxxxxxx>

---

 drivers/scsi/esp_scsi.c       |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index 62a4618..a680e18 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -1453,7 +1453,7 @@ static void esp_msgin_sdtr(struct esp *esp, struct esp_target_data *tp)
 		offset = 0;
 
 	if (offset) {
-		int rounded_up, one_clock;
+		int one_clock;
 
 		if (period > esp->max_period) {
 			period = offset = 0;
@@ -1463,9 +1463,7 @@ static void esp_msgin_sdtr(struct esp *esp, struct esp_target_data *tp)
 			goto do_reject;
 
 		one_clock = esp->ccycle / 1000;
-		rounded_up = (period << 2);
-		rounded_up = (rounded_up + one_clock - 1) / one_clock;
-		stp = rounded_up;
+		stp = DIV_ROUND_UP(period << 2, one_clock);
 		if (stp && esp->rev >= FAS236) {
 			if (stp >= 50)
 				stp--;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux