diff options
author | Vinit Shenoy <vinit.shenoy@st.com> | 2012-04-17 03:10:13 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2012-04-17 19:54:05 -0400 |
commit | eb798c641a34ae9cee9fcacfbe5dd40bd7777607 (patch) | |
tree | 3cbd69ef2fc8ffae67160b9919548aa38c0af916 /drivers/spi | |
parent | e816b57a337ea3b755de72bec38c10c864f23015 (diff) |
spi/pl022: Fix range checking for bits per word
pl022 ssp controller supports word lengths from 4 to 16 (or 32) bits.
Currently implemented checks were incorrect. It has following check
if (pl022->vendor->max_bpw >= 32)
which must be checking for <=.
Also error print message is incorrect, that prints "range is from 1 to
16".
Fix both these issues.
Signed-off-by: Vinit Shenoy <vinit.shenoy@st.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-pl022.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 09c925aaf320..1ead49dbebce 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c | |||
@@ -1823,9 +1823,12 @@ static int pl022_setup(struct spi_device *spi) | |||
1823 | } else | 1823 | } else |
1824 | chip->cs_control = chip_info->cs_control; | 1824 | chip->cs_control = chip_info->cs_control; |
1825 | 1825 | ||
1826 | if (bits <= 3) { | 1826 | /* Check bits per word with vendor specific range */ |
1827 | /* PL022 doesn't support less than 4-bits */ | 1827 | if ((bits <= 3) || (bits > pl022->vendor->max_bpw)) { |
1828 | status = -ENOTSUPP; | 1828 | status = -ENOTSUPP; |
1829 | dev_err(&spi->dev, "illegal data size for this controller!\n"); | ||
1830 | dev_err(&spi->dev, "This controller can only handle 4 <= n <= %d bit words\n", | ||
1831 | pl022->vendor->max_bpw); | ||
1829 | goto err_config_params; | 1832 | goto err_config_params; |
1830 | } else if (bits <= 8) { | 1833 | } else if (bits <= 8) { |
1831 | dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n"); | 1834 | dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n"); |
@@ -1838,20 +1841,10 @@ static int pl022_setup(struct spi_device *spi) | |||
1838 | chip->read = READING_U16; | 1841 | chip->read = READING_U16; |
1839 | chip->write = WRITING_U16; | 1842 | chip->write = WRITING_U16; |
1840 | } else { | 1843 | } else { |
1841 | if (pl022->vendor->max_bpw >= 32) { | 1844 | dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n"); |
1842 | dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n"); | 1845 | chip->n_bytes = 4; |
1843 | chip->n_bytes = 4; | 1846 | chip->read = READING_U32; |
1844 | chip->read = READING_U32; | 1847 | chip->write = WRITING_U32; |
1845 | chip->write = WRITING_U32; | ||
1846 | } else { | ||
1847 | dev_err(&spi->dev, | ||
1848 | "illegal data size for this controller!\n"); | ||
1849 | dev_err(&spi->dev, | ||
1850 | "a standard pl022 can only handle " | ||
1851 | "1 <= n <= 16 bit words\n"); | ||
1852 | status = -ENOTSUPP; | ||
1853 | goto err_config_params; | ||
1854 | } | ||
1855 | } | 1848 | } |
1856 | 1849 | ||
1857 | /* Now Initialize all register settings required for this chip */ | 1850 | /* Now Initialize all register settings required for this chip */ |