asm-generic: merge branch 'master' of torvalds/linux-2.6
authorArnd Bergmann <arnd@arndb.de>
Fri, 12 Jun 2009 07:53:47 +0000 (09:53 +0200)
committerArnd Bergmann <arnd@arndb.de>
Fri, 12 Jun 2009 09:32:58 +0000 (11:32 +0200)
Fixes a merge conflict against the x86 tree caused by a fix to
atomic.h which I renamed to atomic_long.h.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1  2 
arch/frv/include/asm/pci.h
arch/sh/include/asm/atomic.h
arch/x86/include/asm/atomic_32.h
include/asm-generic/atomic-long.h
lib/Makefile

@@@ -10,8 -10,8 +10,8 @@@
   * 2 of the License, or (at your option) any later version.
   */
  
 -#ifndef ASM_PCI_H
 -#define       ASM_PCI_H
 +#ifndef _ASM_FRV_PCI_H
 +#define _ASM_FRV_PCI_H
  
  #include <linux/mm.h>
  #include <asm/scatterlist.h>
@@@ -43,6 -43,12 +43,6 @@@ extern void pci_free_consistent(struct 
  /* Return the index of the PCI controller for device PDEV. */
  #define pci_controller_num(PDEV)      (0)
  
 -/* The PCI address space does equal the physical memory
 - * address space.  The networking and block device layers use
 - * this boolean for bounce buffer decisions.
 - */
 -#define PCI_DMA_BUS_IS_PHYS   (1)
 -
  /* pci_unmap_{page,single} is a nop so... */
  #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
  #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
@@@ -81,8 -87,7 +81,7 @@@ static inline void pci_dma_sync_single(
                                       dma_addr_t dma_handle,
                                       size_t size, int direction)
  {
-       if (direction == PCI_DMA_NONE)
-                 BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
  
        frv_cache_wback_inv((unsigned long)bus_to_virt(dma_handle),
                            (unsigned long)bus_to_virt(dma_handle) + size);
@@@ -99,13 -104,12 +98,11 @@@ static inline void pci_dma_sync_sg(stru
                                   int nelems, int direction)
  {
        int i;
-       if (direction == PCI_DMA_NONE)
-                 BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
  
        for (i = 0; i < nelems; i++)
                frv_cache_wback_inv(sg_dma_address(&sg[i]),
                                    sg_dma_address(&sg[i])+sg_dma_len(&sg[i]));
  }
  
 -
 -#endif
 +#endif /* _ASM_FRV_PCI_H */
@@@ -45,7 -45,7 +45,7 @@@
  #define atomic_inc(v) atomic_add(1,(v))
  #define atomic_dec(v) atomic_sub(1,(v))
  
- #ifndef CONFIG_GUSA_RB
+ #if !defined(CONFIG_GUSA_RB) && !defined(CONFIG_CPU_SH4A)
  static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
  {
        int ret;
@@@ -73,7 -73,7 +73,7 @@@ static inline int atomic_add_unless(ato
  
        return ret != u;
  }
- #endif
+ #endif /* !CONFIG_GUSA_RB && !CONFIG_CPU_SH4A */
  
  #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
  #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
@@@ -84,5 -84,5 +84,5 @@@
  #define smp_mb__before_atomic_inc()   barrier()
  #define smp_mb__after_atomic_inc()    barrier()
  
 -#include <asm-generic/atomic.h>
 +#include <asm-generic/atomic-long.h>
  #endif /* __ASM_SH_ATOMIC_H */
@@@ -247,5 -247,241 +247,241 @@@ static inline int atomic_add_unless(ato
  #define smp_mb__before_atomic_inc()   barrier()
  #define smp_mb__after_atomic_inc()    barrier()
  
 -#include <asm-generic/atomic.h>
+ /* An 64bit atomic type */
+ typedef struct {
+       unsigned long long counter;
+ } atomic64_t;
+ #define ATOMIC64_INIT(val)    { (val) }
+ /**
+  * atomic64_read - read atomic64 variable
+  * @v: pointer of type atomic64_t
+  *
+  * Atomically reads the value of @v.
+  * Doesn't imply a read memory barrier.
+  */
+ #define __atomic64_read(ptr)          ((ptr)->counter)
+ static inline unsigned long long
+ cmpxchg8b(unsigned long long *ptr, unsigned long long old, unsigned long long new)
+ {
+       asm volatile(
+               LOCK_PREFIX "cmpxchg8b (%[ptr])\n"
+                    :          "=A" (old)
+                    : [ptr]    "D" (ptr),
+                               "A" (old),
+                               "b" (ll_low(new)),
+                               "c" (ll_high(new))
+                    : "memory");
+       return old;
+ }
+ static inline unsigned long long
+ atomic64_cmpxchg(atomic64_t *ptr, unsigned long long old_val,
+                unsigned long long new_val)
+ {
+       return cmpxchg8b(&ptr->counter, old_val, new_val);
+ }
+ /**
+  * atomic64_xchg - xchg atomic64 variable
+  * @ptr:      pointer to type atomic64_t
+  * @new_val:  value to assign
+  * @old_val:  old value that was there
+  *
+  * Atomically xchgs the value of @ptr to @new_val and returns
+  * the old value.
+  */
+ static inline unsigned long long
+ atomic64_xchg(atomic64_t *ptr, unsigned long long new_val)
+ {
+       unsigned long long old_val;
+       do {
+               old_val = atomic_read(ptr);
+       } while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val);
+       return old_val;
+ }
+ /**
+  * atomic64_set - set atomic64 variable
+  * @ptr:      pointer to type atomic64_t
+  * @new_val:  value to assign
+  *
+  * Atomically sets the value of @ptr to @new_val.
+  */
+ static inline void atomic64_set(atomic64_t *ptr, unsigned long long new_val)
+ {
+       atomic64_xchg(ptr, new_val);
+ }
+ /**
+  * atomic64_read - read atomic64 variable
+  * @ptr:      pointer to type atomic64_t
+  *
+  * Atomically reads the value of @ptr and returns it.
+  */
+ static inline unsigned long long atomic64_read(atomic64_t *ptr)
+ {
+       unsigned long long curr_val;
+       do {
+               curr_val = __atomic64_read(ptr);
+       } while (atomic64_cmpxchg(ptr, curr_val, curr_val) != curr_val);
+       return curr_val;
+ }
+ /**
+  * atomic64_add_return - add and return
+  * @delta: integer value to add
+  * @ptr:   pointer to type atomic64_t
+  *
+  * Atomically adds @delta to @ptr and returns @delta + *@ptr
+  */
+ static inline unsigned long long
+ atomic64_add_return(unsigned long long delta, atomic64_t *ptr)
+ {
+       unsigned long long old_val, new_val;
+       do {
+               old_val = atomic_read(ptr);
+               new_val = old_val + delta;
+       } while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val);
+       return new_val;
+ }
+ static inline long atomic64_sub_return(unsigned long long delta, atomic64_t *ptr)
+ {
+       return atomic64_add_return(-delta, ptr);
+ }
+ static inline long atomic64_inc_return(atomic64_t *ptr)
+ {
+       return atomic64_add_return(1, ptr);
+ }
+ static inline long atomic64_dec_return(atomic64_t *ptr)
+ {
+       return atomic64_sub_return(1, ptr);
+ }
+ /**
+  * atomic64_add - add integer to atomic64 variable
+  * @delta: integer value to add
+  * @ptr:   pointer to type atomic64_t
+  *
+  * Atomically adds @delta to @ptr.
+  */
+ static inline void atomic64_add(unsigned long long delta, atomic64_t *ptr)
+ {
+       atomic64_add_return(delta, ptr);
+ }
+ /**
+  * atomic64_sub - subtract the atomic64 variable
+  * @delta: integer value to subtract
+  * @ptr:   pointer to type atomic64_t
+  *
+  * Atomically subtracts @delta from @ptr.
+  */
+ static inline void atomic64_sub(unsigned long long delta, atomic64_t *ptr)
+ {
+       atomic64_add(-delta, ptr);
+ }
+ /**
+  * atomic64_sub_and_test - subtract value from variable and test result
+  * @delta: integer value to subtract
+  * @ptr:   pointer to type atomic64_t
+  *
+  * Atomically subtracts @delta from @ptr and returns
+  * true if the result is zero, or false for all
+  * other cases.
+  */
+ static inline int
+ atomic64_sub_and_test(unsigned long long delta, atomic64_t *ptr)
+ {
+       unsigned long long old_val = atomic64_sub_return(delta, ptr);
+       return old_val == 0;
+ }
+ /**
+  * atomic64_inc - increment atomic64 variable
+  * @ptr: pointer to type atomic64_t
+  *
+  * Atomically increments @ptr by 1.
+  */
+ static inline void atomic64_inc(atomic64_t *ptr)
+ {
+       atomic64_add(1, ptr);
+ }
+ /**
+  * atomic64_dec - decrement atomic64 variable
+  * @ptr: pointer to type atomic64_t
+  *
+  * Atomically decrements @ptr by 1.
+  */
+ static inline void atomic64_dec(atomic64_t *ptr)
+ {
+       atomic64_sub(1, ptr);
+ }
+ /**
+  * atomic64_dec_and_test - decrement and test
+  * @ptr: pointer to type atomic64_t
+  *
+  * Atomically decrements @ptr by 1 and
+  * returns true if the result is 0, or false for all other
+  * cases.
+  */
+ static inline int atomic64_dec_and_test(atomic64_t *ptr)
+ {
+       return atomic64_sub_and_test(1, ptr);
+ }
+ /**
+  * atomic64_inc_and_test - increment and test
+  * @ptr: pointer to type atomic64_t
+  *
+  * Atomically increments @ptr by 1
+  * and returns true if the result is zero, or false for all
+  * other cases.
+  */
+ static inline int atomic64_inc_and_test(atomic64_t *ptr)
+ {
+       return atomic64_sub_and_test(-1, ptr);
+ }
+ /**
+  * atomic64_add_negative - add and test if negative
+  * @delta: integer value to add
+  * @ptr:   pointer to type atomic64_t
+  *
+  * Atomically adds @delta to @ptr and returns true
+  * if the result is negative, or false when
+  * result is greater than or equal to zero.
+  */
+ static inline int
+ atomic64_add_negative(unsigned long long delta, atomic64_t *ptr)
+ {
+       long long old_val = atomic64_add_return(delta, ptr);
+       return old_val < 0;
+ }
 +#include <asm-generic/atomic-long.h>
  #endif /* _ASM_X86_ATOMIC_32_H */
index 76e27d6,0000000..b7babf0
mode 100644,000000..100644
--- /dev/null
@@@ -1,258 -1,0 +1,258 @@@
-       (atomic64_xchg((atomic64_t *)(l), (new)))
 +#ifndef _ASM_GENERIC_ATOMIC_LONG_H
 +#define _ASM_GENERIC_ATOMIC_LONG_H
 +/*
 + * Copyright (C) 2005 Silicon Graphics, Inc.
 + *    Christoph Lameter
 + *
 + * Allows to provide arch independent atomic definitions without the need to
 + * edit all arch specific atomic.h files.
 + */
 +
 +#include <asm/types.h>
 +
 +/*
 + * Suppport for atomic_long_t
 + *
 + * Casts for parameters are avoided for existing atomic functions in order to
 + * avoid issues with cast-as-lval under gcc 4.x and other limitations that the
 + * macros of a platform may have.
 + */
 +
 +#if BITS_PER_LONG == 64
 +
 +typedef atomic64_t atomic_long_t;
 +
 +#define ATOMIC_LONG_INIT(i)   ATOMIC64_INIT(i)
 +
 +static inline long atomic_long_read(atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      return (long)atomic64_read(v);
 +}
 +
 +static inline void atomic_long_set(atomic_long_t *l, long i)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      atomic64_set(v, i);
 +}
 +
 +static inline void atomic_long_inc(atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      atomic64_inc(v);
 +}
 +
 +static inline void atomic_long_dec(atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      atomic64_dec(v);
 +}
 +
 +static inline void atomic_long_add(long i, atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      atomic64_add(i, v);
 +}
 +
 +static inline void atomic_long_sub(long i, atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      atomic64_sub(i, v);
 +}
 +
 +static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      return atomic64_sub_and_test(i, v);
 +}
 +
 +static inline int atomic_long_dec_and_test(atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      return atomic64_dec_and_test(v);
 +}
 +
 +static inline int atomic_long_inc_and_test(atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      return atomic64_inc_and_test(v);
 +}
 +
 +static inline int atomic_long_add_negative(long i, atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      return atomic64_add_negative(i, v);
 +}
 +
 +static inline long atomic_long_add_return(long i, atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      return (long)atomic64_add_return(i, v);
 +}
 +
 +static inline long atomic_long_sub_return(long i, atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      return (long)atomic64_sub_return(i, v);
 +}
 +
 +static inline long atomic_long_inc_return(atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      return (long)atomic64_inc_return(v);
 +}
 +
 +static inline long atomic_long_dec_return(atomic_long_t *l)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      return (long)atomic64_dec_return(v);
 +}
 +
 +static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
 +{
 +      atomic64_t *v = (atomic64_t *)l;
 +
 +      return (long)atomic64_add_unless(v, a, u);
 +}
 +
 +#define atomic_long_inc_not_zero(l) atomic64_inc_not_zero((atomic64_t *)(l))
 +
 +#define atomic_long_cmpxchg(l, old, new) \
 +      (atomic64_cmpxchg((atomic64_t *)(l), (old), (new)))
 +#define atomic_long_xchg(v, new) \
++      (atomic64_xchg((atomic64_t *)(v), (new)))
 +
 +#else  /*  BITS_PER_LONG == 64  */
 +
 +typedef atomic_t atomic_long_t;
 +
 +#define ATOMIC_LONG_INIT(i)   ATOMIC_INIT(i)
 +static inline long atomic_long_read(atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      return (long)atomic_read(v);
 +}
 +
 +static inline void atomic_long_set(atomic_long_t *l, long i)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      atomic_set(v, i);
 +}
 +
 +static inline void atomic_long_inc(atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      atomic_inc(v);
 +}
 +
 +static inline void atomic_long_dec(atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      atomic_dec(v);
 +}
 +
 +static inline void atomic_long_add(long i, atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      atomic_add(i, v);
 +}
 +
 +static inline void atomic_long_sub(long i, atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      atomic_sub(i, v);
 +}
 +
 +static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      return atomic_sub_and_test(i, v);
 +}
 +
 +static inline int atomic_long_dec_and_test(atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      return atomic_dec_and_test(v);
 +}
 +
 +static inline int atomic_long_inc_and_test(atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      return atomic_inc_and_test(v);
 +}
 +
 +static inline int atomic_long_add_negative(long i, atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      return atomic_add_negative(i, v);
 +}
 +
 +static inline long atomic_long_add_return(long i, atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      return (long)atomic_add_return(i, v);
 +}
 +
 +static inline long atomic_long_sub_return(long i, atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      return (long)atomic_sub_return(i, v);
 +}
 +
 +static inline long atomic_long_inc_return(atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      return (long)atomic_inc_return(v);
 +}
 +
 +static inline long atomic_long_dec_return(atomic_long_t *l)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      return (long)atomic_dec_return(v);
 +}
 +
 +static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
 +{
 +      atomic_t *v = (atomic_t *)l;
 +
 +      return (long)atomic_add_unless(v, a, u);
 +}
 +
 +#define atomic_long_inc_not_zero(l) atomic_inc_not_zero((atomic_t *)(l))
 +
 +#define atomic_long_cmpxchg(l, old, new) \
 +      (atomic_cmpxchg((atomic_t *)(l), (old), (new)))
 +#define atomic_long_xchg(v, new) \
 +      (atomic_xchg((atomic_t *)(v), (new)))
 +
 +#endif  /*  BITS_PER_LONG == 64  */
 +
 +#endif  /*  _ASM_GENERIC_ATOMIC_LONG_H  */
diff --combined lib/Makefile
@@@ -50,6 -50,7 +50,7 @@@ ifneq ($(CONFIG_HAVE_DEC_LOCK),y
  endif
  
  obj-$(CONFIG_BITREVERSE) += bitrev.o
+ obj-$(CONFIG_RATIONAL)        += rational.o
  obj-$(CONFIG_CRC_CCITT)       += crc-ccitt.o
  obj-$(CONFIG_CRC16)   += crc16.o
  obj-$(CONFIG_CRC_T10DIF)+= crc-t10dif.o
@@@ -92,8 -93,6 +93,8 @@@ obj-$(CONFIG_NLATTR) += nlattr.
  
  obj-$(CONFIG_DMA_API_DEBUG) += dma-debug.o
  
 +obj-$(CONFIG_GENERIC_CSUM) += checksum.o
 +
  hostprogs-y   := gen_crc32table
  clean-files   := crc32table.h