~ubuntu-branches/ubuntu/precise/linux-linaro-u8500/precise

« back to all changes in this revision

Viewing changes to include/linux/align.h

  • Committer: Bazaar Package Importer
  • Author(s): John Rigby, Upstream Fixes, Andy Green, John Rigby
  • Date: 2011-04-14 12:16:06 UTC
  • Revision ID: james.westby@ubuntu.com-20110414121606-b77podkyqgr2oix7
Tags: 2.6.38-1002.3
[ Upstream Fixes ]

* MUSB: shutdown: Make sure block is awake before doing shutdown
  - LP: #745737
* Fixed gpio polarity of gpio USB-phy reset.
  - LP: #747639

[ Andy Green ]

* LINARO: SAUCE: disable CONFIG_OMAP_RESET_CLOCKS
  - LP: #752900

[ John Rigby ]

* Rebase to new upstreams:
  Linux v2.6.38.1
  linaro-linux-2.6.38-upstream-29Mar2011
  Ubuntu-2.6.38-7.35
* SAUCE: OMAP4: clock: wait for module to become accessible on
  a clk enable
  - LP: #745737
* Rebase to new upstreams:
  Linux v2.6.38.2
  linaro-linux-2.6.38-upstream-5Apr2011
  Ubuntu-2.6.38-8.41
  - LP: #732842
* Update configs for device tree, dvfs and lttng
* LINARO: add building of dtb's
* LINARO: SAUCE: Disable lowest operating freqs on omap34xx
  - LP: #732912

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _LINUX_ALIGN_H
 
2
#define _LINUX_ALIGN_H
 
3
 
 
4
#define __ALIGN_KERNEL(x, a)    __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
 
5
#define __ALIGN_KERNEL_MASK(x, mask) \
 
6
                                (((x) + (mask)) & ~(mask))
 
7
 
 
8
#ifdef __KERNEL__
 
9
 
 
10
#include <linux/types.h>
 
11
 
 
12
#define ALIGN(x, a)             __ALIGN_KERNEL(x, a)
 
13
#define __ALIGN_MASK(x, mask)   __ALIGN_KERNEL_MASK(x, mask)
 
14
#define PTR_ALIGN(p, a)         ((typeof(p)) ALIGN((unsigned long) (p), a))
 
15
#define ALIGN_FLOOR(x, a)       __ALIGN_FLOOR_MASK(x, (typeof(x)) (a) - 1)
 
16
#define __ALIGN_FLOOR_MASK(x, mask)     ((x) & ~(mask))
 
17
#define PTR_ALIGN_FLOOR(p, a) \
 
18
                        ((typeof(p)) ALIGN_FLOOR((unsigned long) (p), a))
 
19
#define IS_ALIGNED(x, a)        (((x) & ((typeof(x)) (a) - 1)) == 0)
 
20
 
 
21
/*
 
22
 * Align pointer on natural object alignment.
 
23
 */
 
24
#define object_align(obj)       PTR_ALIGN(obj, __alignof__(*(obj)))
 
25
#define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj)))
 
26
 
 
27
/**
 
28
 * offset_align - Calculate the offset needed to align an object on its natural
 
29
 *                alignment towards higher addresses.
 
30
 * @align_drift:  object offset from an "alignment"-aligned address.
 
31
 * @alignment:    natural object alignment. Must be non-zero, power of 2.
 
32
 *
 
33
 * Returns the offset that must be added to align towards higher
 
34
 * addresses.
 
35
 */
 
36
#define offset_align(align_drift, alignment)                                   \
 
37
        ({                                                                     \
 
38
                MAYBE_BUILD_BUG_ON((alignment) == 0                            \
 
39
                                   || ((alignment) & ((alignment) - 1)));      \
 
40
                (((alignment) - (align_drift)) & ((alignment) - 1));           \
 
41
        })
 
42
 
 
43
/**
 
44
 * offset_align_floor - Calculate the offset needed to align an object
 
45
 *                      on its natural alignment towards lower addresses.
 
46
 * @align_drift:  object offset from an "alignment"-aligned address.
 
47
 * @alignment:    natural object alignment. Must be non-zero, power of 2.
 
48
 *
 
49
 * Returns the offset that must be substracted to align towards lower addresses.
 
50
 */
 
51
#define offset_align_floor(align_drift, alignment)                             \
 
52
        ({                                                                     \
 
53
                MAYBE_BUILD_BUG_ON((alignment) == 0                            \
 
54
                                   || ((alignment) & ((alignment) - 1)));      \
 
55
                (((align_drift) - (alignment)) & ((alignment) - 1);            \
 
56
        })
 
57
 
 
58
#endif /* __KERNEL__ */
 
59
 
 
60
#endif