]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 31 Oct 2008 14:52:51 +0000 (07:52 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 31 Oct 2008 14:52:51 +0000 (07:52 -0700)
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
  sparc64: Add missing null terminating entry to bq4802_match[].
  sparc: use the new byteorder headers
  rtc-m48t59: shift zero year to 1968 on sparc (rev 2)
  dbri: check dma_alloc_coherent errors
  sparc64: remove byteshifting from out* helpers

arch/sparc/include/asm/byteorder.h
arch/sparc/kernel/time.c
arch/sparc64/kernel/time.c
arch/sparc64/lib/PeeCeeI.c
drivers/rtc/rtc-m48t59.c
sound/sparc/dbri.c

index bcd83aa351c595e12cbb8dfc008b4395d7006384..5a70f137f1f7de30a568bad15e34d815e2aed6b4 100644 (file)
@@ -4,15 +4,14 @@
 #include <asm/types.h>
 #include <asm/asi.h>
 
-#ifdef __GNUC__
+#define __BIG_ENDIAN
 
 #ifdef CONFIG_SPARC32
 #define __SWAB_64_THRU_32__
 #endif
 
 #ifdef CONFIG_SPARC64
-
-static inline __u16 ___arch__swab16p(const __u16 *addr)
+static inline __u16 __arch_swab16p(const __u16 *addr)
 {
        __u16 ret;
 
@@ -21,8 +20,9 @@ static inline __u16 ___arch__swab16p(const __u16 *addr)
                              : "r" (addr), "i" (ASI_PL));
        return ret;
 }
+#define __arch_swab16p __arch_swab16p
 
-static inline __u32 ___arch__swab32p(const __u32 *addr)
+static inline __u32 __arch_swab32p(const __u32 *addr)
 {
        __u32 ret;
 
@@ -31,8 +31,9 @@ static inline __u32 ___arch__swab32p(const __u32 *addr)
                              : "r" (addr), "i" (ASI_PL));
        return ret;
 }
+#define __arch_swab32p __arch_swab32p
 
-static inline __u64 ___arch__swab64p(const __u64 *addr)
+static inline __u64 __arch_swab64p(const __u64 *addr)
 {
        __u64 ret;
 
@@ -41,17 +42,10 @@ static inline __u64 ___arch__swab64p(const __u64 *addr)
                              : "r" (addr), "i" (ASI_PL));
        return ret;
 }
-
-#define __arch__swab16p(x) ___arch__swab16p(x)
-#define __arch__swab32p(x) ___arch__swab32p(x)
-#define __arch__swab64p(x) ___arch__swab64p(x)
+#define __arch_swab64p __arch_swab64p
 
 #endif /* CONFIG_SPARC64 */
 
-#define __BYTEORDER_HAS_U64__
-
-#endif
-
-#include <linux/byteorder/big_endian.h>
+#include <linux/byteorder.h>
 
 #endif /* _SPARC_BYTEORDER_H */
index 62c1d94cb4348e832c7b0d993823cc69707df5e2..00f7383c765762f87292c52c3ef29d2e028d080b 100644 (file)
@@ -119,35 +119,16 @@ static unsigned char mostek_read_byte(struct device *dev, u32 ofs)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct m48t59_plat_data *pdata = pdev->dev.platform_data;
-       void __iomem *regs = pdata->ioaddr;
-       unsigned char val = readb(regs + ofs);
-
-       /* the year 0 is 1968 */
-       if (ofs == pdata->offset + M48T59_YEAR) {
-               val += 0x68;
-               if ((val & 0xf) > 9)
-                       val += 6;
-       }
-       return val;
+
+       return readb(pdata->ioaddr + ofs);
 }
 
 static void mostek_write_byte(struct device *dev, u32 ofs, u8 val)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct m48t59_plat_data *pdata = pdev->dev.platform_data;
-       void __iomem *regs = pdata->ioaddr;
-
-       if (ofs == pdata->offset + M48T59_YEAR) {
-               if (val < 0x68)
-                       val += 0x32;
-               else
-                       val -= 0x68;
-               if ((val & 0xf) > 9)
-                       val += 6;
-               if ((val & 0xf0) > 0x9A)
-                       val += 0x60;
-       }
-       writeb(val, regs + ofs);
+
+       writeb(val, pdata->ioaddr + ofs);
 }
 
 static struct m48t59_plat_data m48t59_data = {
index 80d71a5ce1e3ab414cc81cda2eb6bf63973ef368..141da375909129dea0ab0fffc9d5359d85e9a039 100644 (file)
@@ -490,6 +490,7 @@ static struct of_device_id __initdata bq4802_match[] = {
                .name = "rtc",
                .compatible = "bq4802",
        },
+       {},
 };
 
 static struct of_platform_driver bq4802_driver = {
@@ -503,39 +504,16 @@ static struct of_platform_driver bq4802_driver = {
 static unsigned char mostek_read_byte(struct device *dev, u32 ofs)
 {
        struct platform_device *pdev = to_platform_device(dev);
-       struct m48t59_plat_data *pdata = pdev->dev.platform_data;
-       void __iomem *regs;
-       unsigned char val;
-
-       regs = (void __iomem *) pdev->resource[0].start;
-       val = readb(regs + ofs);
-
-       /* the year 0 is 1968 */
-       if (ofs == pdata->offset + M48T59_YEAR) {
-               val += 0x68;
-               if ((val & 0xf) > 9)
-                       val += 6;
-       }
-       return val;
+       void __iomem *regs = (void __iomem *) pdev->resource[0].start;
+
+       return readb(regs + ofs);
 }
 
 static void mostek_write_byte(struct device *dev, u32 ofs, u8 val)
 {
        struct platform_device *pdev = to_platform_device(dev);
-       struct m48t59_plat_data *pdata = pdev->dev.platform_data;
-       void __iomem *regs;
-
-       regs = (void __iomem *) pdev->resource[0].start;
-       if (ofs == pdata->offset + M48T59_YEAR) {
-               if (val < 0x68)
-                       val += 0x32;
-               else
-                       val -= 0x68;
-               if ((val & 0xf) > 9)
-                       val += 6;
-               if ((val & 0xf0) > 0x9A)
-                       val += 0x60;
-       }
+       void __iomem *regs = (void __iomem *) pdev->resource[0].start;
+
        writeb(val, regs + ofs);
 }
 
index 8b313f11bc8d4aed6db0cf856204c15a507a551e..46053e6ddd7b815fb1acf2e2f7a55ecba72837c7 100644 (file)
@@ -20,107 +20,62 @@ void outsw(unsigned long __addr, const void *src, unsigned long count)
 {
        void __iomem *addr = (void __iomem *) __addr;
 
-       if (count) {
-               u16 *ps = (u16 *)src;
-               u32 *pi;
-
-               if (((u64)src) & 0x2) {
-                       u16 val = le16_to_cpup(ps);
-                       outw(val, addr);
-                       ps++;
-                       count--;
-               }
-               pi = (u32 *)ps;
-               while (count >= 2) {
-                       u32 w = le32_to_cpup(pi);
-
-                       pi++;
-                       outw(w >> 0, addr);
-                       outw(w >> 16, addr);
-                       count -= 2;
-               }
-               ps = (u16 *)pi;
-               if (count) {
-                       u16 val = le16_to_cpup(ps);
-                       outw(val, addr);
-               }
+       while (count--) {
+               __raw_writew(*(u16 *)src, addr);
+               src += sizeof(u16);
        }
 }
 
 void outsl(unsigned long __addr, const void *src, unsigned long count)
 {
        void __iomem *addr = (void __iomem *) __addr;
+       u32 l, l2;
 
-       if (count) {
-               if ((((u64)src) & 0x3) == 0) {
-                       u32 *p = (u32 *)src;
-                       while (count--) {
-                               u32 val = cpu_to_le32p(p);
-                               outl(val, addr);
-                               p++;
-                       }
-               } else {
-                       u8 *pb;
-                       u16 *ps = (u16 *)src;
-                       u32 l = 0, l2;
-                       u32 *pi;
-
-                       switch (((u64)src) & 0x3) {
-                       case 0x2:
-                               count -= 1;
-                               l = cpu_to_le16p(ps) << 16;
-                               ps++;
-                               pi = (u32 *)ps;
-                               while (count--) {
-                                       l2 = cpu_to_le32p(pi);
-                                       pi++;
-                                       outl(((l >> 16) | (l2 << 16)), addr);
-                                       l = l2;
-                               }
-                               ps = (u16 *)pi;
-                               l2 = cpu_to_le16p(ps);
-                               outl(((l >> 16) | (l2 << 16)), addr);
-                               break;
-
-                       case 0x1:
-                               count -= 1;
-                               pb = (u8 *)src;
-                               l = (*pb++ << 8);
-                               ps = (u16 *)pb;
-                               l2 = cpu_to_le16p(ps);
-                               ps++;
-                               l |= (l2 << 16);
-                               pi = (u32 *)ps;
-                               while (count--) {
-                                       l2 = cpu_to_le32p(pi);
-                                       pi++;
-                                       outl(((l >> 8) | (l2 << 24)), addr);
-                                       l = l2;
-                               }
-                               pb = (u8 *)pi;
-                               outl(((l >> 8) | (*pb << 24)), addr);
-                               break;
+       if (!count)
+               return;
 
-                       case 0x3:
-                               count -= 1;
-                               pb = (u8 *)src;
-                               l = (*pb++ << 24);
-                               pi = (u32 *)pb;
-                               while (count--) {
-                                       l2 = cpu_to_le32p(pi);
-                                       pi++;
-                                       outl(((l >> 24) | (l2 << 8)), addr);
-                                       l = l2;
-                               }
-                               ps = (u16 *)pi;
-                               l2 = cpu_to_le16p(ps);
-                               ps++;
-                               pb = (u8 *)ps;
-                               l2 |= (*pb << 16);
-                               outl(((l >> 24) | (l2 << 8)), addr);
-                               break;
-                       }
+       switch (((unsigned long)src) & 0x3) {
+       case 0x0:
+               /* src is naturally aligned */
+               while (count--) {
+                       __raw_writel(*(u32 *)src, addr);
+                       src += sizeof(u32);
+               }
+               break;
+       case 0x2:
+               /* 2-byte alignment */
+               while (count--) {
+                       l = (*(u16 *)src) << 16;
+                       l |= *(u16 *)(src + sizeof(u16));
+                       __raw_writel(l, addr);
+                       src += sizeof(u32);
+               }
+               break;
+       case 0x1:
+               /* Hold three bytes in l each time, grab a byte from l2 */
+               l = (*(u8 *)src) << 24;
+               l |= (*(u16 *)(src + sizeof(u8))) << 8;
+               src += sizeof(u8) + sizeof(u16);
+               while (count--) {
+                       l2 = *(u32 *)src;
+                       l |= (l2 >> 24);
+                       __raw_writel(l, addr);
+                       l = l2 << 8;
+                       src += sizeof(u32);
+               }
+               break;
+       case 0x3:
+               /* Hold a byte in l each time, grab 3 bytes from l2 */
+               l = (*(u8 *)src) << 24;
+               src += sizeof(u8);
+               while (count--) {
+                       l2 = *(u32 *)src;
+                       l |= (l2 >> 8);
+                       __raw_writel(l, addr);
+                       l = l2 << 24;
+                       src += sizeof(u32);
                }
+               break;
        }
 }
 
index 04b63dab693254885893ea622a7cf99cebc1b3cf..43afb7ab5289a3648212a1a7759d14a4ccb00289 100644 (file)
@@ -87,6 +87,10 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm)
                dev_dbg(dev, "Century bit is enabled\n");
                tm->tm_year += 100;     /* one century */
        }
+#ifdef CONFIG_SPARC
+       /* Sun SPARC machines count years since 1968 */
+       tm->tm_year += 68;
+#endif
 
        tm->tm_wday     = bcd2bin(val & 0x07);
        tm->tm_hour     = bcd2bin(M48T59_READ(M48T59_HOUR) & 0x3F);
@@ -110,11 +114,20 @@ static int m48t59_rtc_set_time(struct device *dev, struct rtc_time *tm)
        struct m48t59_private *m48t59 = platform_get_drvdata(pdev);
        unsigned long flags;
        u8 val = 0;
+       int year = tm->tm_year;
+
+#ifdef CONFIG_SPARC
+       /* Sun SPARC machines count years since 1968 */
+       year -= 68;
+#endif
 
        dev_dbg(dev, "RTC set time %04d-%02d-%02d %02d/%02d/%02d\n",
-               tm->tm_year + 1900, tm->tm_mon, tm->tm_mday,
+               year + 1900, tm->tm_mon, tm->tm_mday,
                tm->tm_hour, tm->tm_min, tm->tm_sec);
 
+       if (year < 0)
+               return -EINVAL;
+
        spin_lock_irqsave(&m48t59->lock, flags);
        /* Issue the WRITE command */
        M48T59_SET_BITS(M48T59_CNTL_WRITE, M48T59_CNTL);
@@ -125,9 +138,9 @@ static int m48t59_rtc_set_time(struct device *dev, struct rtc_time *tm)
        M48T59_WRITE((bin2bcd(tm->tm_mday) & 0x3F), M48T59_MDAY);
        /* tm_mon is 0-11 */
        M48T59_WRITE((bin2bcd(tm->tm_mon + 1) & 0x1F), M48T59_MONTH);
-       M48T59_WRITE(bin2bcd(tm->tm_year % 100), M48T59_YEAR);
+       M48T59_WRITE(bin2bcd(year % 100), M48T59_YEAR);
 
-       if (pdata->type == M48T59RTC_TYPE_M48T59 && (tm->tm_year / 100))
+       if (pdata->type == M48T59RTC_TYPE_M48T59 && (year / 100))
                val = (M48T59_WDAY_CEB | M48T59_WDAY_CB);
        val |= (bin2bcd(tm->tm_wday) & 0x07);
        M48T59_WRITE(val, M48T59_WDAY);
@@ -159,6 +172,10 @@ static int m48t59_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
        M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL);
 
        tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR));
+#ifdef CONFIG_SPARC
+       /* Sun SPARC machines count years since 1968 */
+       tm->tm_year += 68;
+#endif
        /* tm_mon is 0-11 */
        tm->tm_mon = bcd2bin(M48T59_READ(M48T59_MONTH)) - 1;
 
@@ -192,11 +209,20 @@ static int m48t59_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
        struct rtc_time *tm = &alrm->time;
        u8 mday, hour, min, sec;
        unsigned long flags;
+       int year = tm->tm_year;
+
+#ifdef CONFIG_SPARC
+       /* Sun SPARC machines count years since 1968 */
+       year -= 68;
+#endif
 
        /* If no irq, we don't support ALARM */
        if (m48t59->irq == NO_IRQ)
                return -EIO;
 
+       if (year < 0)
+               return -EINVAL;
+
        /*
         * 0xff means "always match"
         */
@@ -228,7 +254,7 @@ static int m48t59_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
        spin_unlock_irqrestore(&m48t59->lock, flags);
 
        dev_dbg(dev, "RTC set alarm time %04d-%02d-%02d %02d/%02d/%02d\n",
-               tm->tm_year + 1900, tm->tm_mon, tm->tm_mday,
+               year + 1900, tm->tm_mon, tm->tm_mday,
                tm->tm_hour, tm->tm_min, tm->tm_sec);
        return 0;
 }
index c257ad8bdfbcf2f02055002cad0f6ed104a7db5e..23ed6f04a718c30d30db22e577974c4ee54f8190 100644 (file)
@@ -2534,6 +2534,8 @@ static int __devinit snd_dbri_create(struct snd_card *card,
        dbri->dma = dma_alloc_coherent(&op->dev,
                                       sizeof(struct dbri_dma),
                                       &dbri->dma_dvma, GFP_ATOMIC);
+       if (!dbri->dma)
+               return -ENOMEM;
        memset((void *)dbri->dma, 0, sizeof(struct dbri_dma));
 
        dprintk(D_GEN, "DMA Cmd Block 0x%p (0x%08x)\n",