]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
spi/fsl-espi: make the clock computation easier to read
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Thu, 15 Mar 2012 17:42:31 +0000 (18:42 +0100)
committerGrant Likely <grant.likely@secretlab.ca>
Thu, 15 Mar 2012 21:14:13 +0000 (15:14 -0600)
The -1 +1 thingy should probably do what DIV_ROUND_UP does. The 4 is 2
the  "platform_clock => sysclock" and 2 from the computation part. The 64
is the same 4 times 16.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
drivers/spi/spi-fsl-espi.c

index d770f03705c32b86a661dfc0a83d7997b7bfda1c..43350f99931418655852357d7640ee93ec14c9ab 100644 (file)
@@ -180,7 +180,7 @@ static int fsl_espi_setup_transfer(struct spi_device *spi,
 
        if ((mpc8xxx_spi->spibrg / hz) > 64) {
                cs->hw_mode |= CSMODE_DIV16;
-               pm = (mpc8xxx_spi->spibrg - 1) / (hz * 64) + 1;
+               pm = DIV_ROUND_UP(mpc8xxx_spi->spibrg, hz * 16 * 4);
 
                WARN_ONCE(pm > 16, "%s: Requested speed is too low: %d Hz. "
                          "Will use %d Hz instead.\n", dev_name(&spi->dev),
@@ -188,7 +188,7 @@ static int fsl_espi_setup_transfer(struct spi_device *spi,
                if (pm > 16)
                        pm = 16;
        } else {
-               pm = (mpc8xxx_spi->spibrg - 1) / (hz * 4) + 1;
+               pm = DIV_ROUND_UP(mpc8xxx_spi->spibrg, hz * 4);
        }
        if (pm)
                pm--;