aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/Kbuild2
-rw-r--r--include/linux/acpi.h10
-rw-r--r--include/linux/aio_abi.h2
-rw-r--r--include/linux/amba/pl08x.h10
-rw-r--r--include/linux/amba/pl330.h1
-rw-r--r--include/linux/compat.h32
-rw-r--r--include/linux/cpuidle.h22
-rw-r--r--include/linux/cpuset.h6
-rw-r--r--include/linux/dma-mapping.h2
-rw-r--r--include/linux/dmaengine.h35
-rw-r--r--include/linux/dw_dmac.h38
-rw-r--r--include/linux/ext2_fs.h569
-rw-r--r--include/linux/ext2_fs_sb.h126
-rw-r--r--include/linux/ext3_fs.h980
-rw-r--r--include/linux/ext3_fs_i.h151
-rw-r--r--include/linux/ext3_fs_sb.h91
-rw-r--r--include/linux/ext3_jbd.h229
-rw-r--r--include/linux/fdtable.h46
-rw-r--r--include/linux/fs.h4
-rw-r--r--include/linux/fsl/mxs-dma.h28
-rw-r--r--include/linux/ftrace_event.h2
-rw-r--r--include/linux/gpio_keys.h3
-rw-r--r--include/linux/kernel.h36
-rw-r--r--include/linux/lp8727.h18
-rw-r--r--include/linux/mfd/abx500.h273
-rw-r--r--include/linux/mfd/abx500/ab8500-bm.h474
-rw-r--r--include/linux/mfd/abx500/ux500_chargalg.h38
-rw-r--r--include/linux/mtd/bbm.h5
-rw-r--r--include/linux/mtd/blktrans.h1
-rw-r--r--include/linux/mtd/fsmc.h169
-rw-r--r--include/linux/mtd/mtd.h304
-rw-r--r--include/linux/mtd/nand.h7
-rw-r--r--include/linux/mtd/pmc551.h78
-rw-r--r--include/linux/mtd/sh_flctl.h40
-rw-r--r--include/linux/mtd/spear_smi.h65
-rw-r--r--include/linux/mtio.h1
-rw-r--r--include/linux/nfs4.h15
-rw-r--r--include/linux/nfsd/cld.h56
-rw-r--r--include/linux/perf_event.h90
-rw-r--r--include/linux/platform_data/spear_thermal.h26
-rw-r--r--include/linux/power/max17042_battery.h93
-rw-r--r--include/linux/power/smb347-charger.h117
-rw-r--r--include/linux/ring_buffer.h3
-rw-r--r--include/linux/rtc.h3
-rw-r--r--include/linux/sh_intc.h17
-rw-r--r--include/linux/spinlock_api_smp.h2
-rw-r--r--include/linux/sunrpc/svc_rdma.h4
-rw-r--r--include/linux/sysinfo.h24
-rw-r--r--include/linux/tboot.h1
-rw-r--r--include/linux/time.h2
-rw-r--r--include/linux/timex.h2
-rw-r--r--include/linux/virtio.h1
52 files changed, 1711 insertions, 2643 deletions
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index a25555381097..d05df2810354 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -120,7 +120,6 @@ header-y += errno.h
120header-y += errqueue.h 120header-y += errqueue.h
121header-y += ethtool.h 121header-y += ethtool.h
122header-y += eventpoll.h 122header-y += eventpoll.h
123header-y += ext2_fs.h
124header-y += fadvise.h 123header-y += fadvise.h
125header-y += falloc.h 124header-y += falloc.h
126header-y += fanotify.h 125header-y += fanotify.h
@@ -357,6 +356,7 @@ header-y += suspend_ioctls.h
357header-y += swab.h 356header-y += swab.h
358header-y += synclink.h 357header-y += synclink.h
359header-y += sysctl.h 358header-y += sysctl.h
359header-y += sysinfo.h
360header-y += taskstats.h 360header-y += taskstats.h
361header-y += tcp.h 361header-y += tcp.h
362header-y += telephony.h 362header-y += telephony.h
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index f53fea61f40a..f421dd84f29d 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -372,4 +372,14 @@ static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
372 372
373#endif /* !CONFIG_ACPI */ 373#endif /* !CONFIG_ACPI */
374 374
375#ifdef CONFIG_ACPI
376void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
377 u32 pm1a_ctrl, u32 pm1b_ctrl));
378
379acpi_status acpi_os_prepare_sleep(u8 sleep_state,
380 u32 pm1a_control, u32 pm1b_control);
381#else
382#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
383#endif
384
375#endif /*_LINUX_ACPI_H*/ 385#endif /*_LINUX_ACPI_H*/
diff --git a/include/linux/aio_abi.h b/include/linux/aio_abi.h
index 2c8731664180..86fa7a71336a 100644
--- a/include/linux/aio_abi.h
+++ b/include/linux/aio_abi.h
@@ -30,7 +30,7 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <asm/byteorder.h> 31#include <asm/byteorder.h>
32 32
33typedef unsigned long aio_context_t; 33typedef __kernel_ulong_t aio_context_t;
34 34
35enum { 35enum {
36 IOCB_CMD_PREAD = 0, 36 IOCB_CMD_PREAD = 0,
diff --git a/include/linux/amba/pl08x.h b/include/linux/amba/pl08x.h
index 033f6aa670de..e64ce2cfee99 100644
--- a/include/linux/amba/pl08x.h
+++ b/include/linux/amba/pl08x.h
@@ -47,9 +47,6 @@ enum {
47 * @muxval: a number usually used to poke into some mux regiser to 47 * @muxval: a number usually used to poke into some mux regiser to
48 * mux in the signal to this channel 48 * mux in the signal to this channel
49 * @cctl_opt: default options for the channel control register 49 * @cctl_opt: default options for the channel control register
50 * @device_fc: Flow Controller Settings for ccfg register. Only valid for slave
51 * channels. Fill with 'true' if peripheral should be flow controller. Direction
52 * will be selected at Runtime.
53 * @addr: source/target address in physical memory for this DMA channel, 50 * @addr: source/target address in physical memory for this DMA channel,
54 * can be the address of a FIFO register for burst requests for example. 51 * can be the address of a FIFO register for burst requests for example.
55 * This can be left undefined if the PrimeCell API is used for configuring 52 * This can be left undefined if the PrimeCell API is used for configuring
@@ -68,7 +65,6 @@ struct pl08x_channel_data {
68 int max_signal; 65 int max_signal;
69 u32 muxval; 66 u32 muxval;
70 u32 cctl; 67 u32 cctl;
71 bool device_fc;
72 dma_addr_t addr; 68 dma_addr_t addr;
73 bool circular_buffer; 69 bool circular_buffer;
74 bool single; 70 bool single;
@@ -176,13 +172,15 @@ enum pl08x_dma_chan_state {
176 * @runtime_addr: address for RX/TX according to the runtime config 172 * @runtime_addr: address for RX/TX according to the runtime config
177 * @runtime_direction: current direction of this channel according to 173 * @runtime_direction: current direction of this channel according to
178 * runtime config 174 * runtime config
179 * @lc: last completed transaction on this channel
180 * @pend_list: queued transactions pending on this channel 175 * @pend_list: queued transactions pending on this channel
181 * @at: active transaction on this channel 176 * @at: active transaction on this channel
182 * @lock: a lock for this channel data 177 * @lock: a lock for this channel data
183 * @host: a pointer to the host (internal use) 178 * @host: a pointer to the host (internal use)
184 * @state: whether the channel is idle, paused, running etc 179 * @state: whether the channel is idle, paused, running etc
185 * @slave: whether this channel is a device (slave) or for memcpy 180 * @slave: whether this channel is a device (slave) or for memcpy
181 * @device_fc: Flow Controller Settings for ccfg register. Only valid for slave
182 * channels. Fill with 'true' if peripheral should be flow controller. Direction
183 * will be selected at Runtime.
186 * @waiting: a TX descriptor on this channel which is waiting for a physical 184 * @waiting: a TX descriptor on this channel which is waiting for a physical
187 * channel to become available 185 * channel to become available
188 */ 186 */
@@ -198,13 +196,13 @@ struct pl08x_dma_chan {
198 u32 src_cctl; 196 u32 src_cctl;
199 u32 dst_cctl; 197 u32 dst_cctl;
200 enum dma_transfer_direction runtime_direction; 198 enum dma_transfer_direction runtime_direction;
201 dma_cookie_t lc;
202 struct list_head pend_list; 199 struct list_head pend_list;
203 struct pl08x_txd *at; 200 struct pl08x_txd *at;
204 spinlock_t lock; 201 spinlock_t lock;
205 struct pl08x_driver_data *host; 202 struct pl08x_driver_data *host;
206 enum pl08x_dma_chan_state state; 203 enum pl08x_dma_chan_state state;
207 bool slave; 204 bool slave;
205 bool device_fc;
208 struct pl08x_txd *waiting; 206 struct pl08x_txd *waiting;
209}; 207};
210 208
diff --git a/include/linux/amba/pl330.h b/include/linux/amba/pl330.h
index 12e023c19ac1..fe93758e8403 100644
--- a/include/linux/amba/pl330.h
+++ b/include/linux/amba/pl330.h
@@ -13,7 +13,6 @@
13#define __AMBA_PL330_H_ 13#define __AMBA_PL330_H_
14 14
15#include <linux/dmaengine.h> 15#include <linux/dmaengine.h>
16#include <asm/hardware/pl330.h>
17 16
18struct dma_pl330_platdata { 17struct dma_pl330_platdata {
19 /* 18 /*
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 7e05fcee75a1..5d46217f84ad 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -19,6 +19,10 @@
19#include <asm/siginfo.h> 19#include <asm/siginfo.h>
20#include <asm/signal.h> 20#include <asm/signal.h>
21 21
22#ifndef COMPAT_USE_64BIT_TIME
23#define COMPAT_USE_64BIT_TIME 0
24#endif
25
22#define compat_jiffies_to_clock_t(x) \ 26#define compat_jiffies_to_clock_t(x) \
23 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) 27 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
24 28
@@ -83,10 +87,26 @@ typedef struct {
83 compat_sigset_word sig[_COMPAT_NSIG_WORDS]; 87 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
84} compat_sigset_t; 88} compat_sigset_t;
85 89
90/*
91 * These functions operate strictly on struct compat_time*
92 */
86extern int get_compat_timespec(struct timespec *, 93extern int get_compat_timespec(struct timespec *,
87 const struct compat_timespec __user *); 94 const struct compat_timespec __user *);
88extern int put_compat_timespec(const struct timespec *, 95extern int put_compat_timespec(const struct timespec *,
89 struct compat_timespec __user *); 96 struct compat_timespec __user *);
97extern int get_compat_timeval(struct timeval *,
98 const struct compat_timeval __user *);
99extern int put_compat_timeval(const struct timeval *,
100 struct compat_timeval __user *);
101/*
102 * These functions operate on 32- or 64-bit specs depending on
103 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments and the
104 * naming as compat_get/put_ rather than get/put_compat_.
105 */
106extern int compat_get_timespec(struct timespec *, const void __user *);
107extern int compat_put_timespec(const struct timespec *, void __user *);
108extern int compat_get_timeval(struct timeval *, const void __user *);
109extern int compat_put_timeval(const struct timeval *, void __user *);
90 110
91struct compat_iovec { 111struct compat_iovec {
92 compat_uptr_t iov_base; 112 compat_uptr_t iov_base;
@@ -224,6 +244,7 @@ struct compat_sysinfo;
224struct compat_sysctl_args; 244struct compat_sysctl_args;
225struct compat_kexec_segment; 245struct compat_kexec_segment;
226struct compat_mq_attr; 246struct compat_mq_attr;
247struct compat_msgbuf;
227 248
228extern void compat_exit_robust_list(struct task_struct *curr); 249extern void compat_exit_robust_list(struct task_struct *curr);
229 250
@@ -234,13 +255,22 @@ asmlinkage long
234compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, 255compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
235 compat_size_t __user *len_ptr); 256 compat_size_t __user *len_ptr);
236 257
258#ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC
237long compat_sys_semctl(int first, int second, int third, void __user *uptr); 259long compat_sys_semctl(int first, int second, int third, void __user *uptr);
238long compat_sys_msgsnd(int first, int second, int third, void __user *uptr); 260long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
239long compat_sys_msgrcv(int first, int second, int msgtyp, int third, 261long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
240 int version, void __user *uptr); 262 int version, void __user *uptr);
241long compat_sys_msgctl(int first, int second, void __user *uptr);
242long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, 263long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
243 void __user *uptr); 264 void __user *uptr);
265#else
266long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
267long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
268 size_t msgsz, int msgflg);
269long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
270 size_t msgsz, long msgtyp, int msgflg);
271long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
272#endif
273long compat_sys_msgctl(int first, int second, void __user *uptr);
244long compat_sys_shmctl(int first, int second, void __user *uptr); 274long compat_sys_shmctl(int first, int second, void __user *uptr);
245long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, 275long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
246 unsigned nsems, const struct compat_timespec __user *timeout); 276 unsigned nsems, const struct compat_timespec __user *timeout);
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 712abcc205ae..6c26a3da0e03 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -15,6 +15,7 @@
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/kobject.h> 16#include <linux/kobject.h>
17#include <linux/completion.h> 17#include <linux/completion.h>
18#include <linux/hrtimer.h>
18 19
19#define CPUIDLE_STATE_MAX 8 20#define CPUIDLE_STATE_MAX 8
20#define CPUIDLE_NAME_LEN 16 21#define CPUIDLE_NAME_LEN 16
@@ -43,12 +44,15 @@ struct cpuidle_state {
43 44
44 unsigned int flags; 45 unsigned int flags;
45 unsigned int exit_latency; /* in US */ 46 unsigned int exit_latency; /* in US */
46 unsigned int power_usage; /* in mW */ 47 int power_usage; /* in mW */
47 unsigned int target_residency; /* in US */ 48 unsigned int target_residency; /* in US */
49 unsigned int disable;
48 50
49 int (*enter) (struct cpuidle_device *dev, 51 int (*enter) (struct cpuidle_device *dev,
50 struct cpuidle_driver *drv, 52 struct cpuidle_driver *drv,
51 int index); 53 int index);
54
55 int (*enter_dead) (struct cpuidle_device *dev, int index);
52}; 56};
53 57
54/* Idle State Flags */ 58/* Idle State Flags */
@@ -96,7 +100,6 @@ struct cpuidle_device {
96 struct list_head device_list; 100 struct list_head device_list;
97 struct kobject kobj; 101 struct kobject kobj;
98 struct completion kobj_unregister; 102 struct completion kobj_unregister;
99 void *governor_data;
100}; 103};
101 104
102DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices); 105DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
@@ -118,10 +121,12 @@ static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)
118 ****************************/ 121 ****************************/
119 122
120struct cpuidle_driver { 123struct cpuidle_driver {
121 char name[CPUIDLE_NAME_LEN]; 124 const char *name;
122 struct module *owner; 125 struct module *owner;
123 126
124 unsigned int power_specified:1; 127 unsigned int power_specified:1;
128 /* set to 1 to use the core cpuidle time keeping (for all states). */
129 unsigned int en_core_tk_irqen:1;
125 struct cpuidle_state states[CPUIDLE_STATE_MAX]; 130 struct cpuidle_state states[CPUIDLE_STATE_MAX];
126 int state_count; 131 int state_count;
127 int safe_state_index; 132 int safe_state_index;
@@ -140,6 +145,11 @@ extern void cpuidle_pause_and_lock(void);
140extern void cpuidle_resume_and_unlock(void); 145extern void cpuidle_resume_and_unlock(void);
141extern int cpuidle_enable_device(struct cpuidle_device *dev); 146extern int cpuidle_enable_device(struct cpuidle_device *dev);
142extern void cpuidle_disable_device(struct cpuidle_device *dev); 147extern void cpuidle_disable_device(struct cpuidle_device *dev);
148extern int cpuidle_wrap_enter(struct cpuidle_device *dev,
149 struct cpuidle_driver *drv, int index,
150 int (*enter)(struct cpuidle_device *dev,
151 struct cpuidle_driver *drv, int index));
152extern int cpuidle_play_dead(void);
143 153
144#else 154#else
145static inline void disable_cpuidle(void) { } 155static inline void disable_cpuidle(void) { }
@@ -157,6 +167,12 @@ static inline void cpuidle_resume_and_unlock(void) { }
157static inline int cpuidle_enable_device(struct cpuidle_device *dev) 167static inline int cpuidle_enable_device(struct cpuidle_device *dev)
158{return -ENODEV; } 168{return -ENODEV; }
159static inline void cpuidle_disable_device(struct cpuidle_device *dev) { } 169static inline void cpuidle_disable_device(struct cpuidle_device *dev) { }
170static inline int cpuidle_wrap_enter(struct cpuidle_device *dev,
171 struct cpuidle_driver *drv, int index,
172 int (*enter)(struct cpuidle_device *dev,
173 struct cpuidle_driver *drv, int index))
174{ return -ENODEV; }
175static inline int cpuidle_play_dead(void) {return -ENODEV; }
160 176
161#endif 177#endif
162 178
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 7a7e5fd2a277..668f66baac7b 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -22,7 +22,7 @@ extern int cpuset_init(void);
22extern void cpuset_init_smp(void); 22extern void cpuset_init_smp(void);
23extern void cpuset_update_active_cpus(void); 23extern void cpuset_update_active_cpus(void);
24extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask); 24extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
25extern int cpuset_cpus_allowed_fallback(struct task_struct *p); 25extern void cpuset_cpus_allowed_fallback(struct task_struct *p);
26extern nodemask_t cpuset_mems_allowed(struct task_struct *p); 26extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
27#define cpuset_current_mems_allowed (current->mems_allowed) 27#define cpuset_current_mems_allowed (current->mems_allowed)
28void cpuset_init_current_mems_allowed(void); 28void cpuset_init_current_mems_allowed(void);
@@ -135,10 +135,8 @@ static inline void cpuset_cpus_allowed(struct task_struct *p,
135 cpumask_copy(mask, cpu_possible_mask); 135 cpumask_copy(mask, cpu_possible_mask);
136} 136}
137 137
138static inline int cpuset_cpus_allowed_fallback(struct task_struct *p) 138static inline void cpuset_cpus_allowed_fallback(struct task_struct *p)
139{ 139{
140 do_set_cpus_allowed(p, cpu_possible_mask);
141 return cpumask_any(cpu_active_mask);
142} 140}
143 141
144static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) 142static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index e13117cbd2f7..5a736af3cc7a 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -77,7 +77,7 @@ static inline u64 dma_get_mask(struct device *dev)
77 return DMA_BIT_MASK(32); 77 return DMA_BIT_MASK(32);
78} 78}
79 79
80#ifdef ARCH_HAS_DMA_SET_COHERENT_MASK 80#ifdef CONFIG_ARCH_HAS_DMA_SET_COHERENT_MASK
81int dma_set_coherent_mask(struct device *dev, u64 mask); 81int dma_set_coherent_mask(struct device *dev, u64 mask);
82#else 82#else
83static inline int dma_set_coherent_mask(struct device *dev, u64 mask) 83static inline int dma_set_coherent_mask(struct device *dev, u64 mask)
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index a5966f691ef8..676f967390ae 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -18,14 +18,15 @@
18 * The full GNU General Public License is included in this distribution in the 18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING. 19 * file called COPYING.
20 */ 20 */
21#ifndef DMAENGINE_H 21#ifndef LINUX_DMAENGINE_H
22#define DMAENGINE_H 22#define LINUX_DMAENGINE_H
23 23
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/uio.h> 25#include <linux/uio.h>
26#include <linux/bug.h> 26#include <linux/bug.h>
27#include <linux/scatterlist.h> 27#include <linux/scatterlist.h>
28#include <linux/bitmap.h> 28#include <linux/bitmap.h>
29#include <linux/types.h>
29#include <asm/page.h> 30#include <asm/page.h>
30 31
31/** 32/**
@@ -258,6 +259,7 @@ struct dma_chan_percpu {
258 * struct dma_chan - devices supply DMA channels, clients use them 259 * struct dma_chan - devices supply DMA channels, clients use them
259 * @device: ptr to the dma device who supplies this channel, always !%NULL 260 * @device: ptr to the dma device who supplies this channel, always !%NULL
260 * @cookie: last cookie value returned to client 261 * @cookie: last cookie value returned to client
262 * @completed_cookie: last completed cookie for this channel
261 * @chan_id: channel ID for sysfs 263 * @chan_id: channel ID for sysfs
262 * @dev: class device for sysfs 264 * @dev: class device for sysfs
263 * @device_node: used to add this to the device chan list 265 * @device_node: used to add this to the device chan list
@@ -269,6 +271,7 @@ struct dma_chan_percpu {
269struct dma_chan { 271struct dma_chan {
270 struct dma_device *device; 272 struct dma_device *device;
271 dma_cookie_t cookie; 273 dma_cookie_t cookie;
274 dma_cookie_t completed_cookie;
272 275
273 /* sysfs */ 276 /* sysfs */
274 int chan_id; 277 int chan_id;
@@ -332,6 +335,9 @@ enum dma_slave_buswidth {
332 * may or may not be applicable on memory sources. 335 * may or may not be applicable on memory sources.
333 * @dst_maxburst: same as src_maxburst but for destination target 336 * @dst_maxburst: same as src_maxburst but for destination target
334 * mutatis mutandis. 337 * mutatis mutandis.
338 * @device_fc: Flow Controller Settings. Only valid for slave channels. Fill
339 * with 'true' if peripheral should be flow controller. Direction will be
340 * selected at Runtime.
335 * 341 *
336 * This struct is passed in as configuration data to a DMA engine 342 * This struct is passed in as configuration data to a DMA engine
337 * in order to set up a certain channel for DMA transport at runtime. 343 * in order to set up a certain channel for DMA transport at runtime.
@@ -358,6 +364,7 @@ struct dma_slave_config {
358 enum dma_slave_buswidth dst_addr_width; 364 enum dma_slave_buswidth dst_addr_width;
359 u32 src_maxburst; 365 u32 src_maxburst;
360 u32 dst_maxburst; 366 u32 dst_maxburst;
367 bool device_fc;
361}; 368};
362 369
363static inline const char *dma_chan_name(struct dma_chan *chan) 370static inline const char *dma_chan_name(struct dma_chan *chan)
@@ -576,10 +583,11 @@ struct dma_device {
576 struct dma_async_tx_descriptor *(*device_prep_slave_sg)( 583 struct dma_async_tx_descriptor *(*device_prep_slave_sg)(
577 struct dma_chan *chan, struct scatterlist *sgl, 584 struct dma_chan *chan, struct scatterlist *sgl,
578 unsigned int sg_len, enum dma_transfer_direction direction, 585 unsigned int sg_len, enum dma_transfer_direction direction,
579 unsigned long flags); 586 unsigned long flags, void *context);
580 struct dma_async_tx_descriptor *(*device_prep_dma_cyclic)( 587 struct dma_async_tx_descriptor *(*device_prep_dma_cyclic)(
581 struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, 588 struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
582 size_t period_len, enum dma_transfer_direction direction); 589 size_t period_len, enum dma_transfer_direction direction,
590 void *context);
583 struct dma_async_tx_descriptor *(*device_prep_interleaved_dma)( 591 struct dma_async_tx_descriptor *(*device_prep_interleaved_dma)(
584 struct dma_chan *chan, struct dma_interleaved_template *xt, 592 struct dma_chan *chan, struct dma_interleaved_template *xt,
585 unsigned long flags); 593 unsigned long flags);
@@ -613,7 +621,24 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single(
613 struct scatterlist sg; 621 struct scatterlist sg;
614 sg_init_one(&sg, buf, len); 622 sg_init_one(&sg, buf, len);
615 623
616 return chan->device->device_prep_slave_sg(chan, &sg, 1, dir, flags); 624 return chan->device->device_prep_slave_sg(chan, &sg, 1,
625 dir, flags, NULL);
626}
627
628static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_sg(
629 struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len,
630 enum dma_transfer_direction dir, unsigned long flags)
631{
632 return chan->device->device_prep_slave_sg(chan, sgl, sg_len,
633 dir, flags, NULL);
634}
635
636static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_cyclic(
637 struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
638 size_t period_len, enum dma_transfer_direction dir)
639{
640 return chan->device->device_prep_dma_cyclic(chan, buf_addr, buf_len,
641 period_len, dir, NULL);
617} 642}
618 643
619static inline int dmaengine_terminate_all(struct dma_chan *chan) 644static inline int dmaengine_terminate_all(struct dma_chan *chan)
diff --git a/include/linux/dw_dmac.h b/include/linux/dw_dmac.h
index f2c64f92c4a0..2412e02d7c0f 100644
--- a/include/linux/dw_dmac.h
+++ b/include/linux/dw_dmac.h
@@ -31,18 +31,6 @@ struct dw_dma_platform_data {
31 unsigned char chan_priority; 31 unsigned char chan_priority;
32}; 32};
33 33
34/**
35 * enum dw_dma_slave_width - DMA slave register access width.
36 * @DMA_SLAVE_WIDTH_8BIT: Do 8-bit slave register accesses
37 * @DMA_SLAVE_WIDTH_16BIT: Do 16-bit slave register accesses
38 * @DMA_SLAVE_WIDTH_32BIT: Do 32-bit slave register accesses
39 */
40enum dw_dma_slave_width {
41 DW_DMA_SLAVE_WIDTH_8BIT,
42 DW_DMA_SLAVE_WIDTH_16BIT,
43 DW_DMA_SLAVE_WIDTH_32BIT,
44};
45
46/* bursts size */ 34/* bursts size */
47enum dw_dma_msize { 35enum dw_dma_msize {
48 DW_DMA_MSIZE_1, 36 DW_DMA_MSIZE_1,
@@ -55,47 +43,21 @@ enum dw_dma_msize {
55 DW_DMA_MSIZE_256, 43 DW_DMA_MSIZE_256,
56}; 44};
57 45
58/* flow controller */
59enum dw_dma_fc {
60 DW_DMA_FC_D_M2M,
61 DW_DMA_FC_D_M2P,
62 DW_DMA_FC_D_P2M,
63 DW_DMA_FC_D_P2P,
64 DW_DMA_FC_P_P2M,
65 DW_DMA_FC_SP_P2P,
66 DW_DMA_FC_P_M2P,
67 DW_DMA_FC_DP_P2P,
68};
69
70/** 46/**
71 * struct dw_dma_slave - Controller-specific information about a slave 47 * struct dw_dma_slave - Controller-specific information about a slave
72 * 48 *
73 * @dma_dev: required DMA master device 49 * @dma_dev: required DMA master device
74 * @tx_reg: physical address of data register used for
75 * memory-to-peripheral transfers
76 * @rx_reg: physical address of data register used for
77 * peripheral-to-memory transfers
78 * @reg_width: peripheral register width
79 * @cfg_hi: Platform-specific initializer for the CFG_HI register 50 * @cfg_hi: Platform-specific initializer for the CFG_HI register
80 * @cfg_lo: Platform-specific initializer for the CFG_LO register 51 * @cfg_lo: Platform-specific initializer for the CFG_LO register
81 * @src_master: src master for transfers on allocated channel. 52 * @src_master: src master for transfers on allocated channel.
82 * @dst_master: dest master for transfers on allocated channel. 53 * @dst_master: dest master for transfers on allocated channel.
83 * @src_msize: src burst size.
84 * @dst_msize: dest burst size.
85 * @fc: flow controller for DMA transfer
86 */ 54 */
87struct dw_dma_slave { 55struct dw_dma_slave {
88 struct device *dma_dev; 56 struct device *dma_dev;
89 dma_addr_t tx_reg;
90 dma_addr_t rx_reg;
91 enum dw_dma_slave_width reg_width;
92 u32 cfg_hi; 57 u32 cfg_hi;
93 u32 cfg_lo; 58 u32 cfg_lo;
94 u8 src_master; 59 u8 src_master;
95 u8 dst_master; 60 u8 dst_master;
96 u8 src_msize;
97 u8 dst_msize;
98 u8 fc;
99}; 61};
100 62
101/* Platform-configurable bits in CFG_HI */ 63/* Platform-configurable bits in CFG_HI */
diff --git a/include/linux/ext2_fs.h b/include/linux/ext2_fs.h
index ce1b719e8bd4..2723e715f67a 100644
--- a/include/linux/ext2_fs.h
+++ b/include/linux/ext2_fs.h
@@ -18,574 +18,25 @@
18 18
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/magic.h> 20#include <linux/magic.h>
21#include <linux/fs.h>
22 21
23/* 22#define EXT2_NAME_LEN 255
24 * The second extended filesystem constants/structures
25 */
26
27/*
28 * Define EXT2FS_DEBUG to produce debug messages
29 */
30#undef EXT2FS_DEBUG
31
32/*
33 * Define EXT2_RESERVATION to reserve data blocks for expanding files
34 */
35#define EXT2_DEFAULT_RESERVE_BLOCKS 8
36/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */
37#define EXT2_MAX_RESERVE_BLOCKS 1027
38#define EXT2_RESERVE_WINDOW_NOT_ALLOCATED 0
39/*
40 * The second extended file system version
41 */
42#define EXT2FS_DATE "95/08/09"
43#define EXT2FS_VERSION "0.5b"
44
45/*
46 * Debug code
47 */
48#ifdef EXT2FS_DEBUG
49# define ext2_debug(f, a...) { \
50 printk ("EXT2-fs DEBUG (%s, %d): %s:", \
51 __FILE__, __LINE__, __func__); \
52 printk (f, ## a); \
53 }
54#else
55# define ext2_debug(f, a...) /**/
56#endif
57
58/*
59 * Special inode numbers
60 */
61#define EXT2_BAD_INO 1 /* Bad blocks inode */
62#define EXT2_ROOT_INO 2 /* Root inode */
63#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
64#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
65
66/* First non-reserved inode for old ext2 filesystems */
67#define EXT2_GOOD_OLD_FIRST_INO 11
68
69#ifdef __KERNEL__
70#include <linux/ext2_fs_sb.h>
71static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)
72{
73 return sb->s_fs_info;
74}
75#else
76/* Assume that user mode programs are passing in an ext2fs superblock, not
77 * a kernel struct super_block. This will allow us to call the feature-test
78 * macros from user land. */
79#define EXT2_SB(sb) (sb)
80#endif
81 23
82/* 24/*
83 * Maximal count of links to a file 25 * Maximal count of links to a file
84 */ 26 */
85#define EXT2_LINK_MAX 32000 27#define EXT2_LINK_MAX 32000
86 28
87/* 29#define EXT2_SB_MAGIC_OFFSET 0x38
88 * Macro-instructions used to manage several block sizes 30#define EXT2_SB_BLOCKS_OFFSET 0x04
89 */ 31#define EXT2_SB_BSIZE_OFFSET 0x18
90#define EXT2_MIN_BLOCK_SIZE 1024
91#define EXT2_MAX_BLOCK_SIZE 4096
92#define EXT2_MIN_BLOCK_LOG_SIZE 10
93#ifdef __KERNEL__
94# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
95#else
96# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
97#endif
98#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
99#ifdef __KERNEL__
100# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
101#else
102# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
103#endif
104#ifdef __KERNEL__
105#define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_addr_per_block_bits)
106#define EXT2_INODE_SIZE(s) (EXT2_SB(s)->s_inode_size)
107#define EXT2_FIRST_INO(s) (EXT2_SB(s)->s_first_ino)
108#else
109#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
110 EXT2_GOOD_OLD_INODE_SIZE : \
111 (s)->s_inode_size)
112#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
113 EXT2_GOOD_OLD_FIRST_INO : \
114 (s)->s_first_ino)
115#endif
116 32
117/* 33static inline u64 ext2_image_size(void *ext2_sb)
118 * Macro-instructions used to manage fragments
119 */
120#define EXT2_MIN_FRAG_SIZE 1024
121#define EXT2_MAX_FRAG_SIZE 4096
122#define EXT2_MIN_FRAG_LOG_SIZE 10
123#ifdef __KERNEL__
124# define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size)
125# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block)
126#else
127# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
128# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
129#endif
130
131/*
132 * Structure of a blocks group descriptor
133 */
134struct ext2_group_desc
135{ 34{
136 __le32 bg_block_bitmap; /* Blocks bitmap block */ 35 __u8 *p = ext2_sb;
137 __le32 bg_inode_bitmap; /* Inodes bitmap block */ 36 if (*(__le16 *)(p + EXT2_SB_MAGIC_OFFSET) != cpu_to_le16(EXT2_SUPER_MAGIC))
138 __le32 bg_inode_table; /* Inodes table block */ 37 return 0;
139 __le16 bg_free_blocks_count; /* Free blocks count */ 38 return (u64)le32_to_cpup((__le32 *)(p + EXT2_SB_BLOCKS_OFFSET)) <<
140 __le16 bg_free_inodes_count; /* Free inodes count */ 39 le32_to_cpup((__le32 *)(p + EXT2_SB_BSIZE_OFFSET));
141 __le16 bg_used_dirs_count; /* Directories count */
142 __le16 bg_pad;
143 __le32 bg_reserved[3];
144};
145
146/*
147 * Macro-instructions used to manage group descriptors
148 */
149#ifdef __KERNEL__
150# define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
151# define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block)
152# define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
153# define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits)
154#else
155# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
156# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
157# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
158#endif
159
160/*
161 * Constants relative to the data blocks
162 */
163#define EXT2_NDIR_BLOCKS 12
164#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
165#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
166#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
167#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
168
169/*
170 * Inode flags (GETFLAGS/SETFLAGS)
171 */
172#define EXT2_SECRM_FL FS_SECRM_FL /* Secure deletion */
173#define EXT2_UNRM_FL FS_UNRM_FL /* Undelete */
174#define EXT2_COMPR_FL FS_COMPR_FL /* Compress file */
175#define EXT2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
176#define EXT2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
177#define EXT2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
178#define EXT2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
179#define EXT2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
180/* Reserved for compression usage... */
181#define EXT2_DIRTY_FL FS_DIRTY_FL
182#define EXT2_COMPRBLK_FL FS_COMPRBLK_FL /* One or more compressed clusters */
183#define EXT2_NOCOMP_FL FS_NOCOMP_FL /* Don't compress */
184#define EXT2_ECOMPR_FL FS_ECOMPR_FL /* Compression error */
185/* End compression flags --- maybe not all used */
186#define EXT2_BTREE_FL FS_BTREE_FL /* btree format dir */
187#define EXT2_INDEX_FL FS_INDEX_FL /* hash-indexed directory */
188#define EXT2_IMAGIC_FL FS_IMAGIC_FL /* AFS directory */
189#define EXT2_JOURNAL_DATA_FL FS_JOURNAL_DATA_FL /* Reserved for ext3 */
190#define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
191#define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
192#define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
193#define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
194
195#define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
196#define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
197
198/* Flags that should be inherited by new inodes from their parent. */
199#define EXT2_FL_INHERITED (EXT2_SECRM_FL | EXT2_UNRM_FL | EXT2_COMPR_FL |\
200 EXT2_SYNC_FL | EXT2_NODUMP_FL |\
201 EXT2_NOATIME_FL | EXT2_COMPRBLK_FL |\
202 EXT2_NOCOMP_FL | EXT2_JOURNAL_DATA_FL |\
203 EXT2_NOTAIL_FL | EXT2_DIRSYNC_FL)
204
205/* Flags that are appropriate for regular files (all but dir-specific ones). */
206#define EXT2_REG_FLMASK (~(EXT2_DIRSYNC_FL | EXT2_TOPDIR_FL))
207
208/* Flags that are appropriate for non-directories/regular files. */
209#define EXT2_OTHER_FLMASK (EXT2_NODUMP_FL | EXT2_NOATIME_FL)
210
211/* Mask out flags that are inappropriate for the given type of inode. */
212static inline __u32 ext2_mask_flags(umode_t mode, __u32 flags)
213{
214 if (S_ISDIR(mode))
215 return flags;
216 else if (S_ISREG(mode))
217 return flags & EXT2_REG_FLMASK;
218 else
219 return flags & EXT2_OTHER_FLMASK;
220} 40}
221 41
222/*
223 * ioctl commands
224 */
225#define EXT2_IOC_GETFLAGS FS_IOC_GETFLAGS
226#define EXT2_IOC_SETFLAGS FS_IOC_SETFLAGS
227#define EXT2_IOC_GETVERSION FS_IOC_GETVERSION
228#define EXT2_IOC_SETVERSION FS_IOC_SETVERSION
229#define EXT2_IOC_GETRSVSZ _IOR('f', 5, long)
230#define EXT2_IOC_SETRSVSZ _IOW('f', 6, long)
231
232/*
233 * ioctl commands in 32 bit emulation
234 */
235#define EXT2_IOC32_GETFLAGS FS_IOC32_GETFLAGS
236#define EXT2_IOC32_SETFLAGS FS_IOC32_SETFLAGS
237#define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION
238#define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION
239
240/*
241 * Structure of an inode on the disk
242 */
243struct ext2_inode {
244 __le16 i_mode; /* File mode */
245 __le16 i_uid; /* Low 16 bits of Owner Uid */
246 __le32 i_size; /* Size in bytes */
247 __le32 i_atime; /* Access time */
248 __le32 i_ctime; /* Creation time */
249 __le32 i_mtime; /* Modification time */
250 __le32 i_dtime; /* Deletion Time */
251 __le16 i_gid; /* Low 16 bits of Group Id */
252 __le16 i_links_count; /* Links count */
253 __le32 i_blocks; /* Blocks count */
254 __le32 i_flags; /* File flags */
255 union {
256 struct {
257 __le32 l_i_reserved1;
258 } linux1;
259 struct {
260 __le32 h_i_translator;
261 } hurd1;
262 struct {
263 __le32 m_i_reserved1;
264 } masix1;
265 } osd1; /* OS dependent 1 */
266 __le32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
267 __le32 i_generation; /* File version (for NFS) */
268 __le32 i_file_acl; /* File ACL */
269 __le32 i_dir_acl; /* Directory ACL */
270 __le32 i_faddr; /* Fragment address */
271 union {
272 struct {
273 __u8 l_i_frag; /* Fragment number */
274 __u8 l_i_fsize; /* Fragment size */
275 __u16 i_pad1;
276 __le16 l_i_uid_high; /* these 2 fields */
277 __le16 l_i_gid_high; /* were reserved2[0] */
278 __u32 l_i_reserved2;
279 } linux2;
280 struct {
281 __u8 h_i_frag; /* Fragment number */
282 __u8 h_i_fsize; /* Fragment size */
283 __le16 h_i_mode_high;
284 __le16 h_i_uid_high;
285 __le16 h_i_gid_high;
286 __le32 h_i_author;
287 } hurd2;
288 struct {
289 __u8 m_i_frag; /* Fragment number */
290 __u8 m_i_fsize; /* Fragment size */
291 __u16 m_pad1;
292 __u32 m_i_reserved2[2];
293 } masix2;
294 } osd2; /* OS dependent 2 */
295};
296
297#define i_size_high i_dir_acl
298
299#if defined(__KERNEL__) || defined(__linux__)
300#define i_reserved1 osd1.linux1.l_i_reserved1
301#define i_frag osd2.linux2.l_i_frag
302#define i_fsize osd2.linux2.l_i_fsize
303#define i_uid_low i_uid
304#define i_gid_low i_gid
305#define i_uid_high osd2.linux2.l_i_uid_high
306#define i_gid_high osd2.linux2.l_i_gid_high
307#define i_reserved2 osd2.linux2.l_i_reserved2
308#endif
309
310#ifdef __hurd__
311#define i_translator osd1.hurd1.h_i_translator
312#define i_frag osd2.hurd2.h_i_frag
313#define i_fsize osd2.hurd2.h_i_fsize
314#define i_uid_high osd2.hurd2.h_i_uid_high
315#define i_gid_high osd2.hurd2.h_i_gid_high
316#define i_author osd2.hurd2.h_i_author
317#endif
318
319#ifdef __masix__
320#define i_reserved1 osd1.masix1.m_i_reserved1
321#define i_frag osd2.masix2.m_i_frag
322#define i_fsize osd2.masix2.m_i_fsize
323#define i_reserved2 osd2.masix2.m_i_reserved2
324#endif
325
326/*
327 * File system states
328 */
329#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
330#define EXT2_ERROR_FS 0x0002 /* Errors detected */
331
332/*
333 * Mount flags
334 */
335#define EXT2_MOUNT_CHECK 0x000001 /* Do mount-time checks */
336#define EXT2_MOUNT_OLDALLOC 0x000002 /* Don't use the new Orlov allocator */
337#define EXT2_MOUNT_GRPID 0x000004 /* Create files with directory's group */
338#define EXT2_MOUNT_DEBUG 0x000008 /* Some debugging messages */
339#define EXT2_MOUNT_ERRORS_CONT 0x000010 /* Continue on errors */
340#define EXT2_MOUNT_ERRORS_RO 0x000020 /* Remount fs ro on errors */
341#define EXT2_MOUNT_ERRORS_PANIC 0x000040 /* Panic on errors */
342#define EXT2_MOUNT_MINIX_DF 0x000080 /* Mimics the Minix statfs */
343#define EXT2_MOUNT_NOBH 0x000100 /* No buffer_heads */
344#define EXT2_MOUNT_NO_UID32 0x000200 /* Disable 32-bit UIDs */
345#define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */
346#define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */
347#define EXT2_MOUNT_XIP 0x010000 /* Execute in place */
348#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
349#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
350#define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
351
352
353#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
354#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
355#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
356 EXT2_MOUNT_##opt)
357/*
358 * Maximal mount counts between two filesystem checks
359 */
360#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
361#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
362
363/*
364 * Behaviour when detecting errors
365 */
366#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
367#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
368#define EXT2_ERRORS_PANIC 3 /* Panic */
369#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
370
371/*
372 * Structure of the super block
373 */
374struct ext2_super_block {
375 __le32 s_inodes_count; /* Inodes count */
376 __le32 s_blocks_count; /* Blocks count */
377 __le32 s_r_blocks_count; /* Reserved blocks count */
378 __le32 s_free_blocks_count; /* Free blocks count */
379 __le32 s_free_inodes_count; /* Free inodes count */
380 __le32 s_first_data_block; /* First Data Block */
381 __le32 s_log_block_size; /* Block size */
382 __le32 s_log_frag_size; /* Fragment size */
383 __le32 s_blocks_per_group; /* # Blocks per group */
384 __le32 s_frags_per_group; /* # Fragments per group */
385 __le32 s_inodes_per_group; /* # Inodes per group */
386 __le32 s_mtime; /* Mount time */
387 __le32 s_wtime; /* Write time */
388 __le16 s_mnt_count; /* Mount count */
389 __le16 s_max_mnt_count; /* Maximal mount count */
390 __le16 s_magic; /* Magic signature */
391 __le16 s_state; /* File system state */
392 __le16 s_errors; /* Behaviour when detecting errors */
393 __le16 s_minor_rev_level; /* minor revision level */
394 __le32 s_lastcheck; /* time of last check */
395 __le32 s_checkinterval; /* max. time between checks */
396 __le32 s_creator_os; /* OS */
397 __le32 s_rev_level; /* Revision level */
398 __le16 s_def_resuid; /* Default uid for reserved blocks */
399 __le16 s_def_resgid; /* Default gid for reserved blocks */
400 /*
401 * These fields are for EXT2_DYNAMIC_REV superblocks only.
402 *
403 * Note: the difference between the compatible feature set and
404 * the incompatible feature set is that if there is a bit set
405 * in the incompatible feature set that the kernel doesn't
406 * know about, it should refuse to mount the filesystem.
407 *
408 * e2fsck's requirements are more strict; if it doesn't know
409 * about a feature in either the compatible or incompatible
410 * feature set, it must abort and not try to meddle with
411 * things it doesn't understand...
412 */
413 __le32 s_first_ino; /* First non-reserved inode */
414 __le16 s_inode_size; /* size of inode structure */
415 __le16 s_block_group_nr; /* block group # of this superblock */
416 __le32 s_feature_compat; /* compatible feature set */
417 __le32 s_feature_incompat; /* incompatible feature set */
418 __le32 s_feature_ro_compat; /* readonly-compatible feature set */
419 __u8 s_uuid[16]; /* 128-bit uuid for volume */
420 char s_volume_name[16]; /* volume name */
421 char s_last_mounted[64]; /* directory where last mounted */
422 __le32 s_algorithm_usage_bitmap; /* For compression */
423 /*
424 * Performance hints. Directory preallocation should only
425 * happen if the EXT2_COMPAT_PREALLOC flag is on.
426 */
427 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
428 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
429 __u16 s_padding1;
430 /*
431 * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
432 */
433 __u8 s_journal_uuid[16]; /* uuid of journal superblock */
434 __u32 s_journal_inum; /* inode number of journal file */
435 __u32 s_journal_dev; /* device number of journal file */
436 __u32 s_last_orphan; /* start of list of inodes to delete */
437 __u32 s_hash_seed[4]; /* HTREE hash seed */
438 __u8 s_def_hash_version; /* Default hash version to use */
439 __u8 s_reserved_char_pad;
440 __u16 s_reserved_word_pad;
441 __le32 s_default_mount_opts;
442 __le32 s_first_meta_bg; /* First metablock block group */
443 __u32 s_reserved[190]; /* Padding to the end of the block */
444};
445
446/*
447 * Codes for operating systems
448 */
449#define EXT2_OS_LINUX 0
450#define EXT2_OS_HURD 1
451#define EXT2_OS_MASIX 2
452#define EXT2_OS_FREEBSD 3
453#define EXT2_OS_LITES 4
454
455/*
456 * Revision levels
457 */
458#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
459#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
460
461#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
462#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
463
464#define EXT2_GOOD_OLD_INODE_SIZE 128
465
466/*
467 * Feature set definitions
468 */
469
470#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
471 ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
472#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
473 ( EXT2_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
474#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
475 ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
476#define EXT2_SET_COMPAT_FEATURE(sb,mask) \
477 EXT2_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
478#define EXT2_SET_RO_COMPAT_FEATURE(sb,mask) \
479 EXT2_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
480#define EXT2_SET_INCOMPAT_FEATURE(sb,mask) \
481 EXT2_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
482#define EXT2_CLEAR_COMPAT_FEATURE(sb,mask) \
483 EXT2_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
484#define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
485 EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
486#define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
487 EXT2_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
488
489#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
490#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
491#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
492#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
493#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
494#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
495#define EXT2_FEATURE_COMPAT_ANY 0xffffffff
496
497#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
498#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
499#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
500#define EXT2_FEATURE_RO_COMPAT_ANY 0xffffffff
501
502#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
503#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
504#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
505#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
506#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
507#define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff
508
509#define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
510#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
511 EXT2_FEATURE_INCOMPAT_META_BG)
512#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
513 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
514 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
515#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP
516#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP
517
518/*
519 * Default values for user and/or group using reserved blocks
520 */
521#define EXT2_DEF_RESUID 0
522#define EXT2_DEF_RESGID 0
523
524/*
525 * Default mount options
526 */
527#define EXT2_DEFM_DEBUG 0x0001
528#define EXT2_DEFM_BSDGROUPS 0x0002
529#define EXT2_DEFM_XATTR_USER 0x0004
530#define EXT2_DEFM_ACL 0x0008
531#define EXT2_DEFM_UID16 0x0010
532 /* Not used by ext2, but reserved for use by ext3 */
533#define EXT3_DEFM_JMODE 0x0060
534#define EXT3_DEFM_JMODE_DATA 0x0020
535#define EXT3_DEFM_JMODE_ORDERED 0x0040
536#define EXT3_DEFM_JMODE_WBACK 0x0060
537
538/*
539 * Structure of a directory entry
540 */
541#define EXT2_NAME_LEN 255
542
543struct ext2_dir_entry {
544 __le32 inode; /* Inode number */
545 __le16 rec_len; /* Directory entry length */
546 __le16 name_len; /* Name length */
547 char name[EXT2_NAME_LEN]; /* File name */
548};
549
550/*
551 * The new version of the directory entry. Since EXT2 structures are
552 * stored in intel byte order, and the name_len field could never be
553 * bigger than 255 chars, it's safe to reclaim the extra byte for the
554 * file_type field.
555 */
556struct ext2_dir_entry_2 {
557 __le32 inode; /* Inode number */
558 __le16 rec_len; /* Directory entry length */
559 __u8 name_len; /* Name length */
560 __u8 file_type;
561 char name[EXT2_NAME_LEN]; /* File name */
562};
563
564/*
565 * Ext2 directory file types. Only the low 3 bits are used. The
566 * other bits are reserved for now.
567 */
568enum {
569 EXT2_FT_UNKNOWN = 0,
570 EXT2_FT_REG_FILE = 1,
571 EXT2_FT_DIR = 2,
572 EXT2_FT_CHRDEV = 3,
573 EXT2_FT_BLKDEV = 4,
574 EXT2_FT_FIFO = 5,
575 EXT2_FT_SOCK = 6,
576 EXT2_FT_SYMLINK = 7,
577 EXT2_FT_MAX
578};
579
580/*
581 * EXT2_DIR_PAD defines the directory entries boundaries
582 *
583 * NOTE: It must be a multiple of 4
584 */
585#define EXT2_DIR_PAD 4
586#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
587#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
588 ~EXT2_DIR_ROUND)
589#define EXT2_MAX_REC_LEN ((1<<16)-1)
590
591#endif /* _LINUX_EXT2_FS_H */ 42#endif /* _LINUX_EXT2_FS_H */
diff --git a/include/linux/ext2_fs_sb.h b/include/linux/ext2_fs_sb.h
deleted file mode 100644
index db4d9f586bb6..000000000000
--- a/include/linux/ext2_fs_sb.h
+++ /dev/null
@@ -1,126 +0,0 @@
1/*
2 * linux/include/linux/ext2_fs_sb.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs_sb.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT2_FS_SB
17#define _LINUX_EXT2_FS_SB
18
19#include <linux/blockgroup_lock.h>
20#include <linux/percpu_counter.h>
21#include <linux/rbtree.h>
22
23/* XXX Here for now... not interested in restructing headers JUST now */
24
25/* data type for block offset of block group */
26typedef int ext2_grpblk_t;
27
28/* data type for filesystem-wide blocks number */
29typedef unsigned long ext2_fsblk_t;
30
31#define E2FSBLK "%lu"
32
33struct ext2_reserve_window {
34 ext2_fsblk_t _rsv_start; /* First byte reserved */
35 ext2_fsblk_t _rsv_end; /* Last byte reserved or 0 */
36};
37
38struct ext2_reserve_window_node {
39 struct rb_node rsv_node;
40 __u32 rsv_goal_size;
41 __u32 rsv_alloc_hit;
42 struct ext2_reserve_window rsv_window;
43};
44
45struct ext2_block_alloc_info {
46 /* information about reservation window */
47 struct ext2_reserve_window_node rsv_window_node;
48 /*
49 * was i_next_alloc_block in ext2_inode_info
50 * is the logical (file-relative) number of the
51 * most-recently-allocated block in this file.
52 * We use this for detecting linearly ascending allocation requests.
53 */
54 __u32 last_alloc_logical_block;
55 /*
56 * Was i_next_alloc_goal in ext2_inode_info
57 * is the *physical* companion to i_next_alloc_block.
58 * it the the physical block number of the block which was most-recentl
59 * allocated to this file. This give us the goal (target) for the next
60 * allocation when we detect linearly ascending requests.
61 */
62 ext2_fsblk_t last_alloc_physical_block;
63};
64
65#define rsv_start rsv_window._rsv_start
66#define rsv_end rsv_window._rsv_end
67
68/*
69 * second extended-fs super-block data in memory
70 */
71struct ext2_sb_info {
72 unsigned long s_frag_size; /* Size of a fragment in bytes */
73 unsigned long s_frags_per_block;/* Number of fragments per block */
74 unsigned long s_inodes_per_block;/* Number of inodes per block */
75 unsigned long s_frags_per_group;/* Number of fragments in a group */
76 unsigned long s_blocks_per_group;/* Number of blocks in a group */
77 unsigned long s_inodes_per_group;/* Number of inodes in a group */
78 unsigned long s_itb_per_group; /* Number of inode table blocks per group */
79 unsigned long s_gdb_count; /* Number of group descriptor blocks */
80 unsigned long s_desc_per_block; /* Number of group descriptors per block */
81 unsigned long s_groups_count; /* Number of groups in the fs */
82 unsigned long s_overhead_last; /* Last calculated overhead */
83 unsigned long s_blocks_last; /* Last seen block count */
84 struct buffer_head * s_sbh; /* Buffer containing the super block */
85 struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */
86 struct buffer_head ** s_group_desc;
87 unsigned long s_mount_opt;
88 unsigned long s_sb_block;
89 uid_t s_resuid;
90 gid_t s_resgid;
91 unsigned short s_mount_state;
92 unsigned short s_pad;
93 int s_addr_per_block_bits;
94 int s_desc_per_block_bits;
95 int s_inode_size;
96 int s_first_ino;
97 spinlock_t s_next_gen_lock;
98 u32 s_next_generation;
99 unsigned long s_dir_count;
100 u8 *s_debts;
101 struct percpu_counter s_freeblocks_counter;
102 struct percpu_counter s_freeinodes_counter;
103 struct percpu_counter s_dirs_counter;
104 struct blockgroup_lock *s_blockgroup_lock;
105 /* root of the per fs reservation window tree */
106 spinlock_t s_rsv_window_lock;
107 struct rb_root s_rsv_window_root;
108 struct ext2_reserve_window_node s_rsv_window_head;
109 /*
110 * s_lock protects against concurrent modifications of s_mount_state,
111 * s_blocks_last, s_overhead_last and the content of superblock's
112 * buffer pointed to by sbi->s_es.
113 *
114 * Note: It is used in ext2_show_options() to provide a consistent view
115 * of the mount options.
116 */
117 spinlock_t s_lock;
118};
119
120static inline spinlock_t *
121sb_bgl_lock(struct ext2_sb_info *sbi, unsigned int block_group)
122{
123 return bgl_lock_ptr(sbi->s_blockgroup_lock, block_group);
124}
125
126#endif /* _LINUX_EXT2_FS_SB */
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
deleted file mode 100644
index f5a84eef6ed2..000000000000
--- a/include/linux/ext3_fs.h
+++ /dev/null
@@ -1,980 +0,0 @@
1/*
2 * linux/include/linux/ext3_fs.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT3_FS_H
17#define _LINUX_EXT3_FS_H
18
19#include <linux/types.h>
20#include <linux/magic.h>
21#include <linux/bug.h>
22
23/*
24 * The second extended filesystem constants/structures
25 */
26
27/*
28 * Define EXT3FS_DEBUG to produce debug messages
29 */
30#undef EXT3FS_DEBUG
31
32/*
33 * Define EXT3_RESERVATION to reserve data blocks for expanding files
34 */
35#define EXT3_DEFAULT_RESERVE_BLOCKS 8
36/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */
37#define EXT3_MAX_RESERVE_BLOCKS 1027
38#define EXT3_RESERVE_WINDOW_NOT_ALLOCATED 0
39
40/*
41 * Debug code
42 */
43#ifdef EXT3FS_DEBUG
44#define ext3_debug(f, a...) \
45 do { \
46 printk (KERN_DEBUG "EXT3-fs DEBUG (%s, %d): %s:", \
47 __FILE__, __LINE__, __func__); \
48 printk (KERN_DEBUG f, ## a); \
49 } while (0)
50#else
51#define ext3_debug(f, a...) do {} while (0)
52#endif
53
54/*
55 * Special inodes numbers
56 */
57#define EXT3_BAD_INO 1 /* Bad blocks inode */
58#define EXT3_ROOT_INO 2 /* Root inode */
59#define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */
60#define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */
61#define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */
62#define EXT3_JOURNAL_INO 8 /* Journal inode */
63
64/* First non-reserved inode for old ext3 filesystems */
65#define EXT3_GOOD_OLD_FIRST_INO 11
66
67/*
68 * Maximal count of links to a file
69 */
70#define EXT3_LINK_MAX 32000
71
72/*
73 * Macro-instructions used to manage several block sizes
74 */
75#define EXT3_MIN_BLOCK_SIZE 1024
76#define EXT3_MAX_BLOCK_SIZE 65536
77#define EXT3_MIN_BLOCK_LOG_SIZE 10
78#ifdef __KERNEL__
79# define EXT3_BLOCK_SIZE(s) ((s)->s_blocksize)
80#else
81# define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
82#endif
83#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
84#ifdef __KERNEL__
85# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
86#else
87# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
88#endif
89#ifdef __KERNEL__
90#define EXT3_ADDR_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_addr_per_block_bits)
91#define EXT3_INODE_SIZE(s) (EXT3_SB(s)->s_inode_size)
92#define EXT3_FIRST_INO(s) (EXT3_SB(s)->s_first_ino)
93#else
94#define EXT3_INODE_SIZE(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
95 EXT3_GOOD_OLD_INODE_SIZE : \
96 (s)->s_inode_size)
97#define EXT3_FIRST_INO(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
98 EXT3_GOOD_OLD_FIRST_INO : \
99 (s)->s_first_ino)
100#endif
101
102/*
103 * Macro-instructions used to manage fragments
104 */
105#define EXT3_MIN_FRAG_SIZE 1024
106#define EXT3_MAX_FRAG_SIZE 4096
107#define EXT3_MIN_FRAG_LOG_SIZE 10
108#ifdef __KERNEL__
109# define EXT3_FRAG_SIZE(s) (EXT3_SB(s)->s_frag_size)
110# define EXT3_FRAGS_PER_BLOCK(s) (EXT3_SB(s)->s_frags_per_block)
111#else
112# define EXT3_FRAG_SIZE(s) (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size)
113# define EXT3_FRAGS_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s))
114#endif
115
116/*
117 * Structure of a blocks group descriptor
118 */
119struct ext3_group_desc
120{
121 __le32 bg_block_bitmap; /* Blocks bitmap block */
122 __le32 bg_inode_bitmap; /* Inodes bitmap block */
123 __le32 bg_inode_table; /* Inodes table block */
124 __le16 bg_free_blocks_count; /* Free blocks count */
125 __le16 bg_free_inodes_count; /* Free inodes count */
126 __le16 bg_used_dirs_count; /* Directories count */
127 __u16 bg_pad;
128 __le32 bg_reserved[3];
129};
130
131/*
132 * Macro-instructions used to manage group descriptors
133 */
134#ifdef __KERNEL__
135# define EXT3_BLOCKS_PER_GROUP(s) (EXT3_SB(s)->s_blocks_per_group)
136# define EXT3_DESC_PER_BLOCK(s) (EXT3_SB(s)->s_desc_per_block)
137# define EXT3_INODES_PER_GROUP(s) (EXT3_SB(s)->s_inodes_per_group)
138# define EXT3_DESC_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_desc_per_block_bits)
139#else
140# define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
141# define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc))
142# define EXT3_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
143#endif
144
145/*
146 * Constants relative to the data blocks
147 */
148#define EXT3_NDIR_BLOCKS 12
149#define EXT3_IND_BLOCK EXT3_NDIR_BLOCKS
150#define EXT3_DIND_BLOCK (EXT3_IND_BLOCK + 1)
151#define EXT3_TIND_BLOCK (EXT3_DIND_BLOCK + 1)
152#define EXT3_N_BLOCKS (EXT3_TIND_BLOCK + 1)
153
154/*
155 * Inode flags
156 */
157#define EXT3_SECRM_FL 0x00000001 /* Secure deletion */
158#define EXT3_UNRM_FL 0x00000002 /* Undelete */
159#define EXT3_COMPR_FL 0x00000004 /* Compress file */
160#define EXT3_SYNC_FL 0x00000008 /* Synchronous updates */
161#define EXT3_IMMUTABLE_FL 0x00000010 /* Immutable file */
162#define EXT3_APPEND_FL 0x00000020 /* writes to file may only append */
163#define EXT3_NODUMP_FL 0x00000040 /* do not dump file */
164#define EXT3_NOATIME_FL 0x00000080 /* do not update atime */
165/* Reserved for compression usage... */
166#define EXT3_DIRTY_FL 0x00000100
167#define EXT3_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
168#define EXT3_NOCOMPR_FL 0x00000400 /* Don't compress */
169#define EXT3_ECOMPR_FL 0x00000800 /* Compression error */
170/* End compression flags --- maybe not all used */
171#define EXT3_INDEX_FL 0x00001000 /* hash-indexed directory */
172#define EXT3_IMAGIC_FL 0x00002000 /* AFS directory */
173#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
174#define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
175#define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
176#define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
177#define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
178
179#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
180#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
181
182/* Flags that should be inherited by new inodes from their parent. */
183#define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
184 EXT3_SYNC_FL | EXT3_NODUMP_FL |\
185 EXT3_NOATIME_FL | EXT3_COMPRBLK_FL |\
186 EXT3_NOCOMPR_FL | EXT3_JOURNAL_DATA_FL |\
187 EXT3_NOTAIL_FL | EXT3_DIRSYNC_FL)
188
189/* Flags that are appropriate for regular files (all but dir-specific ones). */
190#define EXT3_REG_FLMASK (~(EXT3_DIRSYNC_FL | EXT3_TOPDIR_FL))
191
192/* Flags that are appropriate for non-directories/regular files. */
193#define EXT3_OTHER_FLMASK (EXT3_NODUMP_FL | EXT3_NOATIME_FL)
194
195/* Mask out flags that are inappropriate for the given type of inode. */
196static inline __u32 ext3_mask_flags(umode_t mode, __u32 flags)
197{
198 if (S_ISDIR(mode))
199 return flags;
200 else if (S_ISREG(mode))
201 return flags & EXT3_REG_FLMASK;
202 else
203 return flags & EXT3_OTHER_FLMASK;
204}
205
206/* Used to pass group descriptor data when online resize is done */
207struct ext3_new_group_input {
208 __u32 group; /* Group number for this data */
209 __u32 block_bitmap; /* Absolute block number of block bitmap */
210 __u32 inode_bitmap; /* Absolute block number of inode bitmap */
211 __u32 inode_table; /* Absolute block number of inode table start */
212 __u32 blocks_count; /* Total number of blocks in this group */
213 __u16 reserved_blocks; /* Number of reserved blocks in this group */
214 __u16 unused;
215};
216
217/* The struct ext3_new_group_input in kernel space, with free_blocks_count */
218struct ext3_new_group_data {
219 __u32 group;
220 __u32 block_bitmap;
221 __u32 inode_bitmap;
222 __u32 inode_table;
223 __u32 blocks_count;
224 __u16 reserved_blocks;
225 __u16 unused;
226 __u32 free_blocks_count;
227};
228
229
230/*
231 * ioctl commands
232 */
233#define EXT3_IOC_GETFLAGS FS_IOC_GETFLAGS
234#define EXT3_IOC_SETFLAGS FS_IOC_SETFLAGS
235#define EXT3_IOC_GETVERSION _IOR('f', 3, long)
236#define EXT3_IOC_SETVERSION _IOW('f', 4, long)
237#define EXT3_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
238#define EXT3_IOC_GROUP_ADD _IOW('f', 8,struct ext3_new_group_input)
239#define EXT3_IOC_GETVERSION_OLD FS_IOC_GETVERSION
240#define EXT3_IOC_SETVERSION_OLD FS_IOC_SETVERSION
241#ifdef CONFIG_JBD_DEBUG
242#define EXT3_IOC_WAIT_FOR_READONLY _IOR('f', 99, long)
243#endif
244#define EXT3_IOC_GETRSVSZ _IOR('f', 5, long)
245#define EXT3_IOC_SETRSVSZ _IOW('f', 6, long)
246
247/*
248 * ioctl commands in 32 bit emulation
249 */
250#define EXT3_IOC32_GETFLAGS FS_IOC32_GETFLAGS
251#define EXT3_IOC32_SETFLAGS FS_IOC32_SETFLAGS
252#define EXT3_IOC32_GETVERSION _IOR('f', 3, int)
253#define EXT3_IOC32_SETVERSION _IOW('f', 4, int)
254#define EXT3_IOC32_GETRSVSZ _IOR('f', 5, int)
255#define EXT3_IOC32_SETRSVSZ _IOW('f', 6, int)
256#define EXT3_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
257#ifdef CONFIG_JBD_DEBUG
258#define EXT3_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
259#endif
260#define EXT3_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION
261#define EXT3_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
262
263
264/*
265 * Mount options
266 */
267struct ext3_mount_options {
268 unsigned long s_mount_opt;
269 uid_t s_resuid;
270 gid_t s_resgid;
271 unsigned long s_commit_interval;
272#ifdef CONFIG_QUOTA
273 int s_jquota_fmt;
274 char *s_qf_names[MAXQUOTAS];
275#endif
276};
277
278/*
279 * Structure of an inode on the disk
280 */
281struct ext3_inode {
282 __le16 i_mode; /* File mode */
283 __le16 i_uid; /* Low 16 bits of Owner Uid */
284 __le32 i_size; /* Size in bytes */
285 __le32 i_atime; /* Access time */
286 __le32 i_ctime; /* Creation time */
287 __le32 i_mtime; /* Modification time */
288 __le32 i_dtime; /* Deletion Time */
289 __le16 i_gid; /* Low 16 bits of Group Id */
290 __le16 i_links_count; /* Links count */
291 __le32 i_blocks; /* Blocks count */
292 __le32 i_flags; /* File flags */
293 union {
294 struct {
295 __u32 l_i_reserved1;
296 } linux1;
297 struct {
298 __u32 h_i_translator;
299 } hurd1;
300 struct {
301 __u32 m_i_reserved1;
302 } masix1;
303 } osd1; /* OS dependent 1 */
304 __le32 i_block[EXT3_N_BLOCKS];/* Pointers to blocks */
305 __le32 i_generation; /* File version (for NFS) */
306 __le32 i_file_acl; /* File ACL */
307 __le32 i_dir_acl; /* Directory ACL */
308 __le32 i_faddr; /* Fragment address */
309 union {
310 struct {
311 __u8 l_i_frag; /* Fragment number */
312 __u8 l_i_fsize; /* Fragment size */
313 __u16 i_pad1;
314 __le16 l_i_uid_high; /* these 2 fields */
315 __le16 l_i_gid_high; /* were reserved2[0] */
316 __u32 l_i_reserved2;
317 } linux2;
318 struct {
319 __u8 h_i_frag; /* Fragment number */
320 __u8 h_i_fsize; /* Fragment size */
321 __u16 h_i_mode_high;
322 __u16 h_i_uid_high;
323 __u16 h_i_gid_high;
324 __u32 h_i_author;
325 } hurd2;
326 struct {
327 __u8 m_i_frag; /* Fragment number */
328 __u8 m_i_fsize; /* Fragment size */
329 __u16 m_pad1;
330 __u32 m_i_reserved2[2];
331 } masix2;
332 } osd2; /* OS dependent 2 */
333 __le16 i_extra_isize;
334 __le16 i_pad1;
335};
336
337#define i_size_high i_dir_acl
338
339#if defined(__KERNEL__) || defined(__linux__)
340#define i_reserved1 osd1.linux1.l_i_reserved1
341#define i_frag osd2.linux2.l_i_frag
342#define i_fsize osd2.linux2.l_i_fsize
343#define i_uid_low i_uid
344#define i_gid_low i_gid
345#define i_uid_high osd2.linux2.l_i_uid_high
346#define i_gid_high osd2.linux2.l_i_gid_high
347#define i_reserved2 osd2.linux2.l_i_reserved2
348
349#elif defined(__GNU__)
350
351#define i_translator osd1.hurd1.h_i_translator
352#define i_frag osd2.hurd2.h_i_frag;
353#define i_fsize osd2.hurd2.h_i_fsize;
354#define i_uid_high osd2.hurd2.h_i_uid_high
355#define i_gid_high osd2.hurd2.h_i_gid_high
356#define i_author osd2.hurd2.h_i_author
357
358#elif defined(__masix__)
359
360#define i_reserved1 osd1.masix1.m_i_reserved1
361#define i_frag osd2.masix2.m_i_frag
362#define i_fsize osd2.masix2.m_i_fsize
363#define i_reserved2 osd2.masix2.m_i_reserved2
364
365#endif /* defined(__KERNEL__) || defined(__linux__) */
366
367/*
368 * File system states
369 */
370#define EXT3_VALID_FS 0x0001 /* Unmounted cleanly */
371#define EXT3_ERROR_FS 0x0002 /* Errors detected */
372#define EXT3_ORPHAN_FS 0x0004 /* Orphans being recovered */
373
374/*
375 * Misc. filesystem flags
376 */
377#define EXT2_FLAGS_SIGNED_HASH 0x0001 /* Signed dirhash in use */
378#define EXT2_FLAGS_UNSIGNED_HASH 0x0002 /* Unsigned dirhash in use */
379#define EXT2_FLAGS_TEST_FILESYS 0x0004 /* to test development code */
380
381/*
382 * Mount flags
383 */
384#define EXT3_MOUNT_CHECK 0x00001 /* Do mount-time checks */
385/* EXT3_MOUNT_OLDALLOC was there */
386#define EXT3_MOUNT_GRPID 0x00004 /* Create files with directory's group */
387#define EXT3_MOUNT_DEBUG 0x00008 /* Some debugging messages */
388#define EXT3_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */
389#define EXT3_MOUNT_ERRORS_RO 0x00020 /* Remount fs ro on errors */
390#define EXT3_MOUNT_ERRORS_PANIC 0x00040 /* Panic on errors */
391#define EXT3_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */
392#define EXT3_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/
393#define EXT3_MOUNT_ABORT 0x00200 /* Fatal error detected */
394#define EXT3_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */
395#define EXT3_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */
396#define EXT3_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */
397#define EXT3_MOUNT_WRITEBACK_DATA 0x00C00 /* No data ordering */
398#define EXT3_MOUNT_UPDATE_JOURNAL 0x01000 /* Update the journal format */
399#define EXT3_MOUNT_NO_UID32 0x02000 /* Disable 32-bit UIDs */
400#define EXT3_MOUNT_XATTR_USER 0x04000 /* Extended user attributes */
401#define EXT3_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
402#define EXT3_MOUNT_RESERVATION 0x10000 /* Preallocation */
403#define EXT3_MOUNT_BARRIER 0x20000 /* Use block barriers */
404#define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
405#define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
406#define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
407#define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
408 * error in ordered mode */
409
410/* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
411#ifndef _LINUX_EXT2_FS_H
412#define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt
413#define set_opt(o, opt) o |= EXT3_MOUNT_##opt
414#define test_opt(sb, opt) (EXT3_SB(sb)->s_mount_opt & \
415 EXT3_MOUNT_##opt)
416#else
417#define EXT2_MOUNT_NOLOAD EXT3_MOUNT_NOLOAD
418#define EXT2_MOUNT_ABORT EXT3_MOUNT_ABORT
419#define EXT2_MOUNT_DATA_FLAGS EXT3_MOUNT_DATA_FLAGS
420#endif
421
422#define ext3_set_bit __set_bit_le
423#define ext3_set_bit_atomic ext2_set_bit_atomic
424#define ext3_clear_bit __clear_bit_le
425#define ext3_clear_bit_atomic ext2_clear_bit_atomic
426#define ext3_test_bit test_bit_le
427#define ext3_find_next_zero_bit find_next_zero_bit_le
428
429/*
430 * Maximal mount counts between two filesystem checks
431 */
432#define EXT3_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
433#define EXT3_DFL_CHECKINTERVAL 0 /* Don't use interval check */
434
435/*
436 * Behaviour when detecting errors
437 */
438#define EXT3_ERRORS_CONTINUE 1 /* Continue execution */
439#define EXT3_ERRORS_RO 2 /* Remount fs read-only */
440#define EXT3_ERRORS_PANIC 3 /* Panic */
441#define EXT3_ERRORS_DEFAULT EXT3_ERRORS_CONTINUE
442
443/*
444 * Structure of the super block
445 */
446struct ext3_super_block {
447/*00*/ __le32 s_inodes_count; /* Inodes count */
448 __le32 s_blocks_count; /* Blocks count */
449 __le32 s_r_blocks_count; /* Reserved blocks count */
450 __le32 s_free_blocks_count; /* Free blocks count */
451/*10*/ __le32 s_free_inodes_count; /* Free inodes count */
452 __le32 s_first_data_block; /* First Data Block */
453 __le32 s_log_block_size; /* Block size */
454 __le32 s_log_frag_size; /* Fragment size */
455/*20*/ __le32 s_blocks_per_group; /* # Blocks per group */
456 __le32 s_frags_per_group; /* # Fragments per group */
457 __le32 s_inodes_per_group; /* # Inodes per group */
458 __le32 s_mtime; /* Mount time */
459/*30*/ __le32 s_wtime; /* Write time */
460 __le16 s_mnt_count; /* Mount count */
461 __le16 s_max_mnt_count; /* Maximal mount count */
462 __le16 s_magic; /* Magic signature */
463 __le16 s_state; /* File system state */
464 __le16 s_errors; /* Behaviour when detecting errors */
465 __le16 s_minor_rev_level; /* minor revision level */
466/*40*/ __le32 s_lastcheck; /* time of last check */
467 __le32 s_checkinterval; /* max. time between checks */
468 __le32 s_creator_os; /* OS */
469 __le32 s_rev_level; /* Revision level */
470/*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */
471 __le16 s_def_resgid; /* Default gid for reserved blocks */
472 /*
473 * These fields are for EXT3_DYNAMIC_REV superblocks only.
474 *
475 * Note: the difference between the compatible feature set and
476 * the incompatible feature set is that if there is a bit set
477 * in the incompatible feature set that the kernel doesn't
478 * know about, it should refuse to mount the filesystem.
479 *
480 * e2fsck's requirements are more strict; if it doesn't know
481 * about a feature in either the compatible or incompatible
482 * feature set, it must abort and not try to meddle with
483 * things it doesn't understand...
484 */
485 __le32 s_first_ino; /* First non-reserved inode */
486 __le16 s_inode_size; /* size of inode structure */
487 __le16 s_block_group_nr; /* block group # of this superblock */
488 __le32 s_feature_compat; /* compatible feature set */
489/*60*/ __le32 s_feature_incompat; /* incompatible feature set */
490 __le32 s_feature_ro_compat; /* readonly-compatible feature set */
491/*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
492/*78*/ char s_volume_name[16]; /* volume name */
493/*88*/ char s_last_mounted[64]; /* directory where last mounted */
494/*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
495 /*
496 * Performance hints. Directory preallocation should only
497 * happen if the EXT3_FEATURE_COMPAT_DIR_PREALLOC flag is on.
498 */
499 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
500 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
501 __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
502 /*
503 * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
504 */
505/*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
506/*E0*/ __le32 s_journal_inum; /* inode number of journal file */
507 __le32 s_journal_dev; /* device number of journal file */
508 __le32 s_last_orphan; /* start of list of inodes to delete */
509 __le32 s_hash_seed[4]; /* HTREE hash seed */
510 __u8 s_def_hash_version; /* Default hash version to use */
511 __u8 s_reserved_char_pad;
512 __u16 s_reserved_word_pad;
513 __le32 s_default_mount_opts;
514 __le32 s_first_meta_bg; /* First metablock block group */
515 __le32 s_mkfs_time; /* When the filesystem was created */
516 __le32 s_jnl_blocks[17]; /* Backup of the journal inode */
517 /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
518/*150*/ __le32 s_blocks_count_hi; /* Blocks count */
519 __le32 s_r_blocks_count_hi; /* Reserved blocks count */
520 __le32 s_free_blocks_count_hi; /* Free blocks count */
521 __le16 s_min_extra_isize; /* All inodes have at least # bytes */
522 __le16 s_want_extra_isize; /* New inodes should reserve # bytes */
523 __le32 s_flags; /* Miscellaneous flags */
524 __le16 s_raid_stride; /* RAID stride */
525 __le16 s_mmp_interval; /* # seconds to wait in MMP checking */
526 __le64 s_mmp_block; /* Block for multi-mount protection */
527 __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
528 __u8 s_log_groups_per_flex; /* FLEX_BG group size */
529 __u8 s_reserved_char_pad2;
530 __le16 s_reserved_pad;
531 __u32 s_reserved[162]; /* Padding to the end of the block */
532};
533
534#ifdef __KERNEL__
535#include <linux/ext3_fs_i.h>
536#include <linux/ext3_fs_sb.h>
537static inline struct ext3_sb_info * EXT3_SB(struct super_block *sb)
538{
539 return sb->s_fs_info;
540}
541static inline struct ext3_inode_info *EXT3_I(struct inode *inode)
542{
543 return container_of(inode, struct ext3_inode_info, vfs_inode);
544}
545
546static inline int ext3_valid_inum(struct super_block *sb, unsigned long ino)
547{
548 return ino == EXT3_ROOT_INO ||
549 ino == EXT3_JOURNAL_INO ||
550 ino == EXT3_RESIZE_INO ||
551 (ino >= EXT3_FIRST_INO(sb) &&
552 ino <= le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count));
553}
554
555/*
556 * Inode dynamic state flags
557 */
558enum {
559 EXT3_STATE_JDATA, /* journaled data exists */
560 EXT3_STATE_NEW, /* inode is newly created */
561 EXT3_STATE_XATTR, /* has in-inode xattrs */
562 EXT3_STATE_FLUSH_ON_CLOSE, /* flush dirty pages on close */
563};
564
565static inline int ext3_test_inode_state(struct inode *inode, int bit)
566{
567 return test_bit(bit, &EXT3_I(inode)->i_state_flags);
568}
569
570static inline void ext3_set_inode_state(struct inode *inode, int bit)
571{
572 set_bit(bit, &EXT3_I(inode)->i_state_flags);
573}
574
575static inline void ext3_clear_inode_state(struct inode *inode, int bit)
576{
577 clear_bit(bit, &EXT3_I(inode)->i_state_flags);
578}
579#else
580/* Assume that user mode programs are passing in an ext3fs superblock, not
581 * a kernel struct super_block. This will allow us to call the feature-test
582 * macros from user land. */
583#define EXT3_SB(sb) (sb)
584#endif
585
586#define NEXT_ORPHAN(inode) EXT3_I(inode)->i_dtime
587
588/*
589 * Codes for operating systems
590 */
591#define EXT3_OS_LINUX 0
592#define EXT3_OS_HURD 1
593#define EXT3_OS_MASIX 2
594#define EXT3_OS_FREEBSD 3
595#define EXT3_OS_LITES 4
596
597/*
598 * Revision levels
599 */
600#define EXT3_GOOD_OLD_REV 0 /* The good old (original) format */
601#define EXT3_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
602
603#define EXT3_CURRENT_REV EXT3_GOOD_OLD_REV
604#define EXT3_MAX_SUPP_REV EXT3_DYNAMIC_REV
605
606#define EXT3_GOOD_OLD_INODE_SIZE 128
607
608/*
609 * Feature set definitions
610 */
611
612#define EXT3_HAS_COMPAT_FEATURE(sb,mask) \
613 ( EXT3_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
614#define EXT3_HAS_RO_COMPAT_FEATURE(sb,mask) \
615 ( EXT3_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
616#define EXT3_HAS_INCOMPAT_FEATURE(sb,mask) \
617 ( EXT3_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
618#define EXT3_SET_COMPAT_FEATURE(sb,mask) \
619 EXT3_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
620#define EXT3_SET_RO_COMPAT_FEATURE(sb,mask) \
621 EXT3_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
622#define EXT3_SET_INCOMPAT_FEATURE(sb,mask) \
623 EXT3_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
624#define EXT3_CLEAR_COMPAT_FEATURE(sb,mask) \
625 EXT3_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
626#define EXT3_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
627 EXT3_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
628#define EXT3_CLEAR_INCOMPAT_FEATURE(sb,mask) \
629 EXT3_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
630
631#define EXT3_FEATURE_COMPAT_DIR_PREALLOC 0x0001
632#define EXT3_FEATURE_COMPAT_IMAGIC_INODES 0x0002
633#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
634#define EXT3_FEATURE_COMPAT_EXT_ATTR 0x0008
635#define EXT3_FEATURE_COMPAT_RESIZE_INODE 0x0010
636#define EXT3_FEATURE_COMPAT_DIR_INDEX 0x0020
637
638#define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
639#define EXT3_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
640#define EXT3_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
641
642#define EXT3_FEATURE_INCOMPAT_COMPRESSION 0x0001
643#define EXT3_FEATURE_INCOMPAT_FILETYPE 0x0002
644#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
645#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
646#define EXT3_FEATURE_INCOMPAT_META_BG 0x0010
647
648#define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
649#define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \
650 EXT3_FEATURE_INCOMPAT_RECOVER| \
651 EXT3_FEATURE_INCOMPAT_META_BG)
652#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
653 EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
654 EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
655
656/*
657 * Default values for user and/or group using reserved blocks
658 */
659#define EXT3_DEF_RESUID 0
660#define EXT3_DEF_RESGID 0
661
662/*
663 * Default mount options
664 */
665#define EXT3_DEFM_DEBUG 0x0001
666#define EXT3_DEFM_BSDGROUPS 0x0002
667#define EXT3_DEFM_XATTR_USER 0x0004
668#define EXT3_DEFM_ACL 0x0008
669#define EXT3_DEFM_UID16 0x0010
670#define EXT3_DEFM_JMODE 0x0060
671#define EXT3_DEFM_JMODE_DATA 0x0020
672#define EXT3_DEFM_JMODE_ORDERED 0x0040
673#define EXT3_DEFM_JMODE_WBACK 0x0060
674
675/*
676 * Structure of a directory entry
677 */
678#define EXT3_NAME_LEN 255
679
680struct ext3_dir_entry {
681 __le32 inode; /* Inode number */
682 __le16 rec_len; /* Directory entry length */
683 __le16 name_len; /* Name length */
684 char name[EXT3_NAME_LEN]; /* File name */
685};
686
687/*
688 * The new version of the directory entry. Since EXT3 structures are
689 * stored in intel byte order, and the name_len field could never be
690 * bigger than 255 chars, it's safe to reclaim the extra byte for the
691 * file_type field.
692 */
693struct ext3_dir_entry_2 {
694 __le32 inode; /* Inode number */
695 __le16 rec_len; /* Directory entry length */
696 __u8 name_len; /* Name length */
697 __u8 file_type;
698 char name[EXT3_NAME_LEN]; /* File name */
699};
700
701/*
702 * Ext3 directory file types. Only the low 3 bits are used. The
703 * other bits are reserved for now.
704 */
705#define EXT3_FT_UNKNOWN 0
706#define EXT3_FT_REG_FILE 1
707#define EXT3_FT_DIR 2
708#define EXT3_FT_CHRDEV 3
709#define EXT3_FT_BLKDEV 4
710#define EXT3_FT_FIFO 5
711#define EXT3_FT_SOCK 6
712#define EXT3_FT_SYMLINK 7
713
714#define EXT3_FT_MAX 8
715
716/*
717 * EXT3_DIR_PAD defines the directory entries boundaries
718 *
719 * NOTE: It must be a multiple of 4
720 */
721#define EXT3_DIR_PAD 4
722#define EXT3_DIR_ROUND (EXT3_DIR_PAD - 1)
723#define EXT3_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \
724 ~EXT3_DIR_ROUND)
725#define EXT3_MAX_REC_LEN ((1<<16)-1)
726
727/*
728 * Tests against MAX_REC_LEN etc were put in place for 64k block
729 * sizes; if that is not possible on this arch, we can skip
730 * those tests and speed things up.
731 */
732static inline unsigned ext3_rec_len_from_disk(__le16 dlen)
733{
734 unsigned len = le16_to_cpu(dlen);
735
736#if (PAGE_CACHE_SIZE >= 65536)
737 if (len == EXT3_MAX_REC_LEN)
738 return 1 << 16;
739#endif
740 return len;
741}
742
743static inline __le16 ext3_rec_len_to_disk(unsigned len)
744{
745#if (PAGE_CACHE_SIZE >= 65536)
746 if (len == (1 << 16))
747 return cpu_to_le16(EXT3_MAX_REC_LEN);
748 else if (len > (1 << 16))
749 BUG();
750#endif
751 return cpu_to_le16(len);
752}
753
754/*
755 * Hash Tree Directory indexing
756 * (c) Daniel Phillips, 2001
757 */
758
759#define is_dx(dir) (EXT3_HAS_COMPAT_FEATURE(dir->i_sb, \
760 EXT3_FEATURE_COMPAT_DIR_INDEX) && \
761 (EXT3_I(dir)->i_flags & EXT3_INDEX_FL))
762#define EXT3_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT3_LINK_MAX)
763#define EXT3_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
764
765/* Legal values for the dx_root hash_version field: */
766
767#define DX_HASH_LEGACY 0
768#define DX_HASH_HALF_MD4 1
769#define DX_HASH_TEA 2
770#define DX_HASH_LEGACY_UNSIGNED 3
771#define DX_HASH_HALF_MD4_UNSIGNED 4
772#define DX_HASH_TEA_UNSIGNED 5
773
774#ifdef __KERNEL__
775
776/* hash info structure used by the directory hash */
777struct dx_hash_info
778{
779 u32 hash;
780 u32 minor_hash;
781 int hash_version;
782 u32 *seed;
783};
784
785#define EXT3_HTREE_EOF 0x7fffffff
786
787/*
788 * Control parameters used by ext3_htree_next_block
789 */
790#define HASH_NB_ALWAYS 1
791
792
793/*
794 * Describe an inode's exact location on disk and in memory
795 */
796struct ext3_iloc
797{
798 struct buffer_head *bh;
799 unsigned long offset;
800 unsigned long block_group;
801};
802
803static inline struct ext3_inode *ext3_raw_inode(struct ext3_iloc *iloc)
804{
805 return (struct ext3_inode *) (iloc->bh->b_data + iloc->offset);
806}
807
808/*
809 * This structure is stuffed into the struct file's private_data field
810 * for directories. It is where we put information so that we can do
811 * readdir operations in hash tree order.
812 */
813struct dir_private_info {
814 struct rb_root root;
815 struct rb_node *curr_node;
816 struct fname *extra_fname;
817 loff_t last_pos;
818 __u32 curr_hash;
819 __u32 curr_minor_hash;
820 __u32 next_hash;
821};
822
823/* calculate the first block number of the group */
824static inline ext3_fsblk_t
825ext3_group_first_block_no(struct super_block *sb, unsigned long group_no)
826{
827 return group_no * (ext3_fsblk_t)EXT3_BLOCKS_PER_GROUP(sb) +
828 le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block);
829}
830
831/*
832 * Special error return code only used by dx_probe() and its callers.
833 */
834#define ERR_BAD_DX_DIR -75000
835
836/*
837 * Function prototypes
838 */
839
840/*
841 * Ok, these declarations are also in <linux/kernel.h> but none of the
842 * ext3 source programs needs to include it so they are duplicated here.
843 */
844# define NORET_TYPE /**/
845# define ATTRIB_NORET __attribute__((noreturn))
846# define NORET_AND noreturn,
847
848/* balloc.c */
849extern int ext3_bg_has_super(struct super_block *sb, int group);
850extern unsigned long ext3_bg_num_gdb(struct super_block *sb, int group);
851extern ext3_fsblk_t ext3_new_block (handle_t *handle, struct inode *inode,
852 ext3_fsblk_t goal, int *errp);
853extern ext3_fsblk_t ext3_new_blocks (handle_t *handle, struct inode *inode,
854 ext3_fsblk_t goal, unsigned long *count, int *errp);
855extern void ext3_free_blocks (handle_t *handle, struct inode *inode,
856 ext3_fsblk_t block, unsigned long count);
857extern void ext3_free_blocks_sb (handle_t *handle, struct super_block *sb,
858 ext3_fsblk_t block, unsigned long count,
859 unsigned long *pdquot_freed_blocks);
860extern ext3_fsblk_t ext3_count_free_blocks (struct super_block *);
861extern void ext3_check_blocks_bitmap (struct super_block *);
862extern struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb,
863 unsigned int block_group,
864 struct buffer_head ** bh);
865extern int ext3_should_retry_alloc(struct super_block *sb, int *retries);
866extern void ext3_init_block_alloc_info(struct inode *);
867extern void ext3_rsv_window_add(struct super_block *sb, struct ext3_reserve_window_node *rsv);
868extern int ext3_trim_fs(struct super_block *sb, struct fstrim_range *range);
869
870/* dir.c */
871extern int ext3_check_dir_entry(const char *, struct inode *,
872 struct ext3_dir_entry_2 *,
873 struct buffer_head *, unsigned long);
874extern int ext3_htree_store_dirent(struct file *dir_file, __u32 hash,
875 __u32 minor_hash,
876 struct ext3_dir_entry_2 *dirent);
877extern void ext3_htree_free_dir_info(struct dir_private_info *p);
878
879/* fsync.c */
880extern int ext3_sync_file(struct file *, loff_t, loff_t, int);
881
882/* hash.c */
883extern int ext3fs_dirhash(const char *name, int len, struct
884 dx_hash_info *hinfo);
885
886/* ialloc.c */
887extern struct inode * ext3_new_inode (handle_t *, struct inode *,
888 const struct qstr *, umode_t);
889extern void ext3_free_inode (handle_t *, struct inode *);
890extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
891extern unsigned long ext3_count_free_inodes (struct super_block *);
892extern unsigned long ext3_count_dirs (struct super_block *);
893extern void ext3_check_inodes_bitmap (struct super_block *);
894extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
895
896
897/* inode.c */
898int ext3_forget(handle_t *handle, int is_metadata, struct inode *inode,
899 struct buffer_head *bh, ext3_fsblk_t blocknr);
900struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
901struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
902int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
903 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
904 int create);
905
906extern struct inode *ext3_iget(struct super_block *, unsigned long);
907extern int ext3_write_inode (struct inode *, struct writeback_control *);
908extern int ext3_setattr (struct dentry *, struct iattr *);
909extern void ext3_evict_inode (struct inode *);
910extern int ext3_sync_inode (handle_t *, struct inode *);
911extern void ext3_discard_reservation (struct inode *);
912extern void ext3_dirty_inode(struct inode *, int);
913extern int ext3_change_inode_journal_flag(struct inode *, int);
914extern int ext3_get_inode_loc(struct inode *, struct ext3_iloc *);
915extern int ext3_can_truncate(struct inode *inode);
916extern void ext3_truncate(struct inode *inode);
917extern void ext3_set_inode_flags(struct inode *);
918extern void ext3_get_inode_flags(struct ext3_inode_info *);
919extern void ext3_set_aops(struct inode *inode);
920extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
921 u64 start, u64 len);
922
923/* ioctl.c */
924extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
925extern long ext3_compat_ioctl(struct file *, unsigned int, unsigned long);
926
927/* namei.c */
928extern int ext3_orphan_add(handle_t *, struct inode *);
929extern int ext3_orphan_del(handle_t *, struct inode *);
930extern int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash,
931 __u32 start_minor_hash, __u32 *next_hash);
932
933/* resize.c */
934extern int ext3_group_add(struct super_block *sb,
935 struct ext3_new_group_data *input);
936extern int ext3_group_extend(struct super_block *sb,
937 struct ext3_super_block *es,
938 ext3_fsblk_t n_blocks_count);
939
940/* super.c */
941extern __printf(3, 4)
942void ext3_error(struct super_block *, const char *, const char *, ...);
943extern void __ext3_std_error (struct super_block *, const char *, int);
944extern __printf(3, 4)
945void ext3_abort(struct super_block *, const char *, const char *, ...);
946extern __printf(3, 4)
947void ext3_warning(struct super_block *, const char *, const char *, ...);
948extern __printf(3, 4)
949void ext3_msg(struct super_block *, const char *, const char *, ...);
950extern void ext3_update_dynamic_rev (struct super_block *sb);
951
952#define ext3_std_error(sb, errno) \
953do { \
954 if ((errno)) \
955 __ext3_std_error((sb), __func__, (errno)); \
956} while (0)
957
958/*
959 * Inodes and files operations
960 */
961
962/* dir.c */
963extern const struct file_operations ext3_dir_operations;
964
965/* file.c */
966extern const struct inode_operations ext3_file_inode_operations;
967extern const struct file_operations ext3_file_operations;
968
969/* namei.c */
970extern const struct inode_operations ext3_dir_inode_operations;
971extern const struct inode_operations ext3_special_inode_operations;
972
973/* symlink.c */
974extern const struct inode_operations ext3_symlink_inode_operations;
975extern const struct inode_operations ext3_fast_symlink_inode_operations;
976
977
978#endif /* __KERNEL__ */
979
980#endif /* _LINUX_EXT3_FS_H */
diff --git a/include/linux/ext3_fs_i.h b/include/linux/ext3_fs_i.h
deleted file mode 100644
index f42c098aed8d..000000000000
--- a/include/linux/ext3_fs_i.h
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2 * linux/include/linux/ext3_fs_i.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs_i.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT3_FS_I
17#define _LINUX_EXT3_FS_I
18
19#include <linux/rwsem.h>
20#include <linux/rbtree.h>
21#include <linux/seqlock.h>
22#include <linux/mutex.h>
23
24/* data type for block offset of block group */
25typedef int ext3_grpblk_t;
26
27/* data type for filesystem-wide blocks number */
28typedef unsigned long ext3_fsblk_t;
29
30#define E3FSBLK "%lu"
31
32struct ext3_reserve_window {
33 ext3_fsblk_t _rsv_start; /* First byte reserved */
34 ext3_fsblk_t _rsv_end; /* Last byte reserved or 0 */
35};
36
37struct ext3_reserve_window_node {
38 struct rb_node rsv_node;
39 __u32 rsv_goal_size;
40 __u32 rsv_alloc_hit;
41 struct ext3_reserve_window rsv_window;
42};
43
44struct ext3_block_alloc_info {
45 /* information about reservation window */
46 struct ext3_reserve_window_node rsv_window_node;
47 /*
48 * was i_next_alloc_block in ext3_inode_info
49 * is the logical (file-relative) number of the
50 * most-recently-allocated block in this file.
51 * We use this for detecting linearly ascending allocation requests.
52 */
53 __u32 last_alloc_logical_block;
54 /*
55 * Was i_next_alloc_goal in ext3_inode_info
56 * is the *physical* companion to i_next_alloc_block.
57 * it the physical block number of the block which was most-recentl
58 * allocated to this file. This give us the goal (target) for the next
59 * allocation when we detect linearly ascending requests.
60 */
61 ext3_fsblk_t last_alloc_physical_block;
62};
63
64#define rsv_start rsv_window._rsv_start
65#define rsv_end rsv_window._rsv_end
66
67/*
68 * third extended file system inode data in memory
69 */
70struct ext3_inode_info {
71 __le32 i_data[15]; /* unconverted */
72 __u32 i_flags;
73#ifdef EXT3_FRAGMENTS
74 __u32 i_faddr;
75 __u8 i_frag_no;
76 __u8 i_frag_size;
77#endif
78 ext3_fsblk_t i_file_acl;
79 __u32 i_dir_acl;
80 __u32 i_dtime;
81
82 /*
83 * i_block_group is the number of the block group which contains
84 * this file's inode. Constant across the lifetime of the inode,
85 * it is ued for making block allocation decisions - we try to
86 * place a file's data blocks near its inode block, and new inodes
87 * near to their parent directory's inode.
88 */
89 __u32 i_block_group;
90 unsigned long i_state_flags; /* Dynamic state flags for ext3 */
91
92 /* block reservation info */
93 struct ext3_block_alloc_info *i_block_alloc_info;
94
95 __u32 i_dir_start_lookup;
96#ifdef CONFIG_EXT3_FS_XATTR
97 /*
98 * Extended attributes can be read independently of the main file
99 * data. Taking i_mutex even when reading would cause contention
100 * between readers of EAs and writers of regular file data, so
101 * instead we synchronize on xattr_sem when reading or changing
102 * EAs.
103 */
104 struct rw_semaphore xattr_sem;
105#endif
106
107 struct list_head i_orphan; /* unlinked but open inodes */
108
109 /*
110 * i_disksize keeps track of what the inode size is ON DISK, not
111 * in memory. During truncate, i_size is set to the new size by
112 * the VFS prior to calling ext3_truncate(), but the filesystem won't
113 * set i_disksize to 0 until the truncate is actually under way.
114 *
115 * The intent is that i_disksize always represents the blocks which
116 * are used by this file. This allows recovery to restart truncate
117 * on orphans if we crash during truncate. We actually write i_disksize
118 * into the on-disk inode when writing inodes out, instead of i_size.
119 *
120 * The only time when i_disksize and i_size may be different is when
121 * a truncate is in progress. The only things which change i_disksize
122 * are ext3_get_block (growth) and ext3_truncate (shrinkth).
123 */
124 loff_t i_disksize;
125
126 /* on-disk additional length */
127 __u16 i_extra_isize;
128
129 /*
130 * truncate_mutex is for serialising ext3_truncate() against
131 * ext3_getblock(). In the 2.4 ext2 design, great chunks of inode's
132 * data tree are chopped off during truncate. We can't do that in
133 * ext3 because whenever we perform intermediate commits during
134 * truncate, the inode and all the metadata blocks *must* be in a
135 * consistent state which allows truncation of the orphans to restart
136 * during recovery. Hence we must fix the get_block-vs-truncate race
137 * by other means, so we have truncate_mutex.
138 */
139 struct mutex truncate_mutex;
140
141 /*
142 * Transactions that contain inode's metadata needed to complete
143 * fsync and fdatasync, respectively.
144 */
145 atomic_t i_sync_tid;
146 atomic_t i_datasync_tid;
147
148 struct inode vfs_inode;
149};
150
151#endif /* _LINUX_EXT3_FS_I */
diff --git a/include/linux/ext3_fs_sb.h b/include/linux/ext3_fs_sb.h
deleted file mode 100644
index 64365252f1b0..000000000000
--- a/include/linux/ext3_fs_sb.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 * linux/include/linux/ext3_fs_sb.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs_sb.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT3_FS_SB
17#define _LINUX_EXT3_FS_SB
18
19#ifdef __KERNEL__
20#include <linux/timer.h>
21#include <linux/wait.h>
22#include <linux/blockgroup_lock.h>
23#include <linux/percpu_counter.h>
24#endif
25#include <linux/rbtree.h>
26
27/*
28 * third extended-fs super-block data in memory
29 */
30struct ext3_sb_info {
31 unsigned long s_frag_size; /* Size of a fragment in bytes */
32 unsigned long s_frags_per_block;/* Number of fragments per block */
33 unsigned long s_inodes_per_block;/* Number of inodes per block */
34 unsigned long s_frags_per_group;/* Number of fragments in a group */
35 unsigned long s_blocks_per_group;/* Number of blocks in a group */
36 unsigned long s_inodes_per_group;/* Number of inodes in a group */
37 unsigned long s_itb_per_group; /* Number of inode table blocks per group */
38 unsigned long s_gdb_count; /* Number of group descriptor blocks */
39 unsigned long s_desc_per_block; /* Number of group descriptors per block */
40 unsigned long s_groups_count; /* Number of groups in the fs */
41 unsigned long s_overhead_last; /* Last calculated overhead */
42 unsigned long s_blocks_last; /* Last seen block count */
43 struct buffer_head * s_sbh; /* Buffer containing the super block */
44 struct ext3_super_block * s_es; /* Pointer to the super block in the buffer */
45 struct buffer_head ** s_group_desc;
46 unsigned long s_mount_opt;
47 ext3_fsblk_t s_sb_block;
48 uid_t s_resuid;
49 gid_t s_resgid;
50 unsigned short s_mount_state;
51 unsigned short s_pad;
52 int s_addr_per_block_bits;
53 int s_desc_per_block_bits;
54 int s_inode_size;
55 int s_first_ino;
56 spinlock_t s_next_gen_lock;
57 u32 s_next_generation;
58 u32 s_hash_seed[4];
59 int s_def_hash_version;
60 int s_hash_unsigned; /* 3 if hash should be signed, 0 if not */
61 struct percpu_counter s_freeblocks_counter;
62 struct percpu_counter s_freeinodes_counter;
63 struct percpu_counter s_dirs_counter;
64 struct blockgroup_lock *s_blockgroup_lock;
65
66 /* root of the per fs reservation window tree */
67 spinlock_t s_rsv_window_lock;
68 struct rb_root s_rsv_window_root;
69 struct ext3_reserve_window_node s_rsv_window_head;
70
71 /* Journaling */
72 struct inode * s_journal_inode;
73 struct journal_s * s_journal;
74 struct list_head s_orphan;
75 struct mutex s_orphan_lock;
76 struct mutex s_resize_lock;
77 unsigned long s_commit_interval;
78 struct block_device *journal_bdev;
79#ifdef CONFIG_QUOTA
80 char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */
81 int s_jquota_fmt; /* Format of quota to use */
82#endif
83};
84
85static inline spinlock_t *
86sb_bgl_lock(struct ext3_sb_info *sbi, unsigned int block_group)
87{
88 return bgl_lock_ptr(sbi->s_blockgroup_lock, block_group);
89}
90
91#endif /* _LINUX_EXT3_FS_SB */
diff --git a/include/linux/ext3_jbd.h b/include/linux/ext3_jbd.h
deleted file mode 100644
index d7b5ddca99c2..000000000000
--- a/include/linux/ext3_jbd.h
+++ /dev/null
@@ -1,229 +0,0 @@
1/*
2 * linux/include/linux/ext3_jbd.h
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
5 *
6 * Copyright 1998--1999 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Ext3-specific journaling extensions.
13 */
14
15#ifndef _LINUX_EXT3_JBD_H
16#define _LINUX_EXT3_JBD_H
17
18#include <linux/fs.h>
19#include <linux/jbd.h>
20#include <linux/ext3_fs.h>
21
22#define EXT3_JOURNAL(inode) (EXT3_SB((inode)->i_sb)->s_journal)
23
24/* Define the number of blocks we need to account to a transaction to
25 * modify one block of data.
26 *
27 * We may have to touch one inode, one bitmap buffer, up to three
28 * indirection blocks, the group and superblock summaries, and the data
29 * block to complete the transaction. */
30
31#define EXT3_SINGLEDATA_TRANS_BLOCKS 8U
32
33/* Extended attribute operations touch at most two data buffers,
34 * two bitmap buffers, and two group summaries, in addition to the inode
35 * and the superblock, which are already accounted for. */
36
37#define EXT3_XATTR_TRANS_BLOCKS 6U
38
39/* Define the minimum size for a transaction which modifies data. This
40 * needs to take into account the fact that we may end up modifying two
41 * quota files too (one for the group, one for the user quota). The
42 * superblock only gets updated once, of course, so don't bother
43 * counting that again for the quota updates. */
44
45#define EXT3_DATA_TRANS_BLOCKS(sb) (EXT3_SINGLEDATA_TRANS_BLOCKS + \
46 EXT3_XATTR_TRANS_BLOCKS - 2 + \
47 EXT3_MAXQUOTAS_TRANS_BLOCKS(sb))
48
49/* Delete operations potentially hit one directory's namespace plus an
50 * entire inode, plus arbitrary amounts of bitmap/indirection data. Be
51 * generous. We can grow the delete transaction later if necessary. */
52
53#define EXT3_DELETE_TRANS_BLOCKS(sb) (EXT3_MAXQUOTAS_TRANS_BLOCKS(sb) + 64)
54
55/* Define an arbitrary limit for the amount of data we will anticipate
56 * writing to any given transaction. For unbounded transactions such as
57 * write(2) and truncate(2) we can write more than this, but we always
58 * start off at the maximum transaction size and grow the transaction
59 * optimistically as we go. */
60
61#define EXT3_MAX_TRANS_DATA 64U
62
63/* We break up a large truncate or write transaction once the handle's
64 * buffer credits gets this low, we need either to extend the
65 * transaction or to start a new one. Reserve enough space here for
66 * inode, bitmap, superblock, group and indirection updates for at least
67 * one block, plus two quota updates. Quota allocations are not
68 * needed. */
69
70#define EXT3_RESERVE_TRANS_BLOCKS 12U
71
72#define EXT3_INDEX_EXTRA_TRANS_BLOCKS 8
73
74#ifdef CONFIG_QUOTA
75/* Amount of blocks needed for quota update - we know that the structure was
76 * allocated so we need to update only inode+data */
77#define EXT3_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 2 : 0)
78/* Amount of blocks needed for quota insert/delete - we do some block writes
79 * but inode, sb and group updates are done only once */
80#define EXT3_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
81 (EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_INIT_REWRITE) : 0)
82#define EXT3_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
83 (EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_DEL_REWRITE) : 0)
84#else
85#define EXT3_QUOTA_TRANS_BLOCKS(sb) 0
86#define EXT3_QUOTA_INIT_BLOCKS(sb) 0
87#define EXT3_QUOTA_DEL_BLOCKS(sb) 0
88#endif
89#define EXT3_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_TRANS_BLOCKS(sb))
90#define EXT3_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_INIT_BLOCKS(sb))
91#define EXT3_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_DEL_BLOCKS(sb))
92
93int
94ext3_mark_iloc_dirty(handle_t *handle,
95 struct inode *inode,
96 struct ext3_iloc *iloc);
97
98/*
99 * On success, We end up with an outstanding reference count against
100 * iloc->bh. This _must_ be cleaned up later.
101 */
102
103int ext3_reserve_inode_write(handle_t *handle, struct inode *inode,
104 struct ext3_iloc *iloc);
105
106int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode);
107
108/*
109 * Wrapper functions with which ext3 calls into JBD. The intent here is
110 * to allow these to be turned into appropriate stubs so ext3 can control
111 * ext2 filesystems, so ext2+ext3 systems only nee one fs. This work hasn't
112 * been done yet.
113 */
114
115static inline void ext3_journal_release_buffer(handle_t *handle,
116 struct buffer_head *bh)
117{
118 journal_release_buffer(handle, bh);
119}
120
121void ext3_journal_abort_handle(const char *caller, const char *err_fn,
122 struct buffer_head *bh, handle_t *handle, int err);
123
124int __ext3_journal_get_undo_access(const char *where, handle_t *handle,
125 struct buffer_head *bh);
126
127int __ext3_journal_get_write_access(const char *where, handle_t *handle,
128 struct buffer_head *bh);
129
130int __ext3_journal_forget(const char *where, handle_t *handle,
131 struct buffer_head *bh);
132
133int __ext3_journal_revoke(const char *where, handle_t *handle,
134 unsigned long blocknr, struct buffer_head *bh);
135
136int __ext3_journal_get_create_access(const char *where,
137 handle_t *handle, struct buffer_head *bh);
138
139int __ext3_journal_dirty_metadata(const char *where,
140 handle_t *handle, struct buffer_head *bh);
141
142#define ext3_journal_get_undo_access(handle, bh) \
143 __ext3_journal_get_undo_access(__func__, (handle), (bh))
144#define ext3_journal_get_write_access(handle, bh) \
145 __ext3_journal_get_write_access(__func__, (handle), (bh))
146#define ext3_journal_revoke(handle, blocknr, bh) \
147 __ext3_journal_revoke(__func__, (handle), (blocknr), (bh))
148#define ext3_journal_get_create_access(handle, bh) \
149 __ext3_journal_get_create_access(__func__, (handle), (bh))
150#define ext3_journal_dirty_metadata(handle, bh) \
151 __ext3_journal_dirty_metadata(__func__, (handle), (bh))
152#define ext3_journal_forget(handle, bh) \
153 __ext3_journal_forget(__func__, (handle), (bh))
154
155int ext3_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
156
157handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks);
158int __ext3_journal_stop(const char *where, handle_t *handle);
159
160static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks)
161{
162 return ext3_journal_start_sb(inode->i_sb, nblocks);
163}
164
165#define ext3_journal_stop(handle) \
166 __ext3_journal_stop(__func__, (handle))
167
168static inline handle_t *ext3_journal_current_handle(void)
169{
170 return journal_current_handle();
171}
172
173static inline int ext3_journal_extend(handle_t *handle, int nblocks)
174{
175 return journal_extend(handle, nblocks);
176}
177
178static inline int ext3_journal_restart(handle_t *handle, int nblocks)
179{
180 return journal_restart(handle, nblocks);
181}
182
183static inline int ext3_journal_blocks_per_page(struct inode *inode)
184{
185 return journal_blocks_per_page(inode);
186}
187
188static inline int ext3_journal_force_commit(journal_t *journal)
189{
190 return journal_force_commit(journal);
191}
192
193/* super.c */
194int ext3_force_commit(struct super_block *sb);
195
196static inline int ext3_should_journal_data(struct inode *inode)
197{
198 if (!S_ISREG(inode->i_mode))
199 return 1;
200 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
201 return 1;
202 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
203 return 1;
204 return 0;
205}
206
207static inline int ext3_should_order_data(struct inode *inode)
208{
209 if (!S_ISREG(inode->i_mode))
210 return 0;
211 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
212 return 0;
213 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA)
214 return 1;
215 return 0;
216}
217
218static inline int ext3_should_writeback_data(struct inode *inode)
219{
220 if (!S_ISREG(inode->i_mode))
221 return 0;
222 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
223 return 0;
224 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)
225 return 1;
226 return 0;
227}
228
229#endif /* _LINUX_EXT3_JBD_H */
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index 82163c4b32c9..158a41eed314 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -21,23 +21,45 @@
21 */ 21 */
22#define NR_OPEN_DEFAULT BITS_PER_LONG 22#define NR_OPEN_DEFAULT BITS_PER_LONG
23 23
24/*
25 * The embedded_fd_set is a small fd_set,
26 * suitable for most tasks (which open <= BITS_PER_LONG files)
27 */
28struct embedded_fd_set {
29 unsigned long fds_bits[1];
30};
31
32struct fdtable { 24struct fdtable {
33 unsigned int max_fds; 25 unsigned int max_fds;
34 struct file __rcu **fd; /* current fd array */ 26 struct file __rcu **fd; /* current fd array */
35 fd_set *close_on_exec; 27 unsigned long *close_on_exec;
36 fd_set *open_fds; 28 unsigned long *open_fds;
37 struct rcu_head rcu; 29 struct rcu_head rcu;
38 struct fdtable *next; 30 struct fdtable *next;
39}; 31};
40 32
33static inline void __set_close_on_exec(int fd, struct fdtable *fdt)
34{
35 __set_bit(fd, fdt->close_on_exec);
36}
37
38static inline void __clear_close_on_exec(int fd, struct fdtable *fdt)
39{
40 __clear_bit(fd, fdt->close_on_exec);
41}
42
43static inline bool close_on_exec(int fd, const struct fdtable *fdt)
44{
45 return test_bit(fd, fdt->close_on_exec);
46}
47
48static inline void __set_open_fd(int fd, struct fdtable *fdt)
49{
50 __set_bit(fd, fdt->open_fds);
51}
52
53static inline void __clear_open_fd(int fd, struct fdtable *fdt)
54{
55 __clear_bit(fd, fdt->open_fds);
56}
57
58static inline bool fd_is_open(int fd, const struct fdtable *fdt)
59{
60 return test_bit(fd, fdt->open_fds);
61}
62
41/* 63/*
42 * Open file table structure 64 * Open file table structure
43 */ 65 */
@@ -53,8 +75,8 @@ struct files_struct {
53 */ 75 */
54 spinlock_t file_lock ____cacheline_aligned_in_smp; 76 spinlock_t file_lock ____cacheline_aligned_in_smp;
55 int next_fd; 77 int next_fd;
56 struct embedded_fd_set close_on_exec_init; 78 unsigned long close_on_exec_init[1];
57 struct embedded_fd_set open_fds_init; 79 unsigned long open_fds_init[1];
58 struct file __rcu * fd_array[NR_OPEN_DEFAULT]; 80 struct file __rcu * fd_array[NR_OPEN_DEFAULT];
59}; 81};
60 82
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c437f914d537..135693e79f2b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -92,6 +92,10 @@ struct inodes_stat_t {
92/* File is opened using open(.., 3, ..) and is writeable only for ioctls 92/* File is opened using open(.., 3, ..) and is writeable only for ioctls
93 (specialy hack for floppy.c) */ 93 (specialy hack for floppy.c) */
94#define FMODE_WRITE_IOCTL ((__force fmode_t)0x100) 94#define FMODE_WRITE_IOCTL ((__force fmode_t)0x100)
95/* 32bit hashes as llseek() offset (for directories) */
96#define FMODE_32BITHASH ((__force fmode_t)0x200)
97/* 64bit hashes as llseek() offset (for directories) */
98#define FMODE_64BITHASH ((__force fmode_t)0x400)
95 99
96/* 100/*
97 * Don't update ctime and mtime. 101 * Don't update ctime and mtime.
diff --git a/include/linux/fsl/mxs-dma.h b/include/linux/fsl/mxs-dma.h
new file mode 100644
index 000000000000..203d7c4a3e11
--- /dev/null
+++ b/include/linux/fsl/mxs-dma.h
@@ -0,0 +1,28 @@
1/*
2 * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef __MACH_MXS_DMA_H__
10#define __MACH_MXS_DMA_H__
11
12#include <linux/dmaengine.h>
13
14struct mxs_dma_data {
15 int chan_irq;
16};
17
18static inline int mxs_dma_is_apbh(struct dma_chan *chan)
19{
20 return !strcmp(dev_name(chan->device->dev), "mxs-dma-apbh");
21}
22
23static inline int mxs_dma_is_apbx(struct dma_chan *chan)
24{
25 return !strcmp(dev_name(chan->device->dev), "mxs-dma-apbx");
26}
27
28#endif /* __MACH_MXS_DMA_H__ */
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index dd478fc8f9f5..5f3f3be5af09 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -144,12 +144,14 @@ struct event_filter;
144enum trace_reg { 144enum trace_reg {
145 TRACE_REG_REGISTER, 145 TRACE_REG_REGISTER,
146 TRACE_REG_UNREGISTER, 146 TRACE_REG_UNREGISTER,
147#ifdef CONFIG_PERF_EVENTS
147 TRACE_REG_PERF_REGISTER, 148 TRACE_REG_PERF_REGISTER,
148 TRACE_REG_PERF_UNREGISTER, 149 TRACE_REG_PERF_UNREGISTER,
149 TRACE_REG_PERF_OPEN, 150 TRACE_REG_PERF_OPEN,
150 TRACE_REG_PERF_CLOSE, 151 TRACE_REG_PERF_CLOSE,
151 TRACE_REG_PERF_ADD, 152 TRACE_REG_PERF_ADD,
152 TRACE_REG_PERF_DEL, 153 TRACE_REG_PERF_DEL,
154#endif
153}; 155};
154 156
155struct ftrace_event_call; 157struct ftrace_event_call;
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index 004ff33ab38e..a7e977ff4abf 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -6,7 +6,7 @@ struct device;
6struct gpio_keys_button { 6struct gpio_keys_button {
7 /* Configuration parameters */ 7 /* Configuration parameters */
8 unsigned int code; /* input event code (KEY_*, SW_*) */ 8 unsigned int code; /* input event code (KEY_*, SW_*) */
9 int gpio; 9 int gpio; /* -1 if this key does not support gpio */
10 int active_low; 10 int active_low;
11 const char *desc; 11 const char *desc;
12 unsigned int type; /* input event type (EV_KEY, EV_SW, EV_ABS) */ 12 unsigned int type; /* input event type (EV_KEY, EV_SW, EV_ABS) */
@@ -14,6 +14,7 @@ struct gpio_keys_button {
14 int debounce_interval; /* debounce ticks interval in msecs */ 14 int debounce_interval; /* debounce ticks interval in msecs */
15 bool can_disable; 15 bool can_disable;
16 int value; /* axis value for EV_ABS */ 16 int value; /* axis value for EV_ABS */
17 unsigned int irq; /* Irq number in case of interrupt keys */
17}; 18};
18 19
19struct gpio_keys_platform_data { 20struct gpio_keys_platform_data {
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 5db52d0ff1d4..645231c373c8 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -1,6 +1,8 @@
1#ifndef _LINUX_KERNEL_H 1#ifndef _LINUX_KERNEL_H
2#define _LINUX_KERNEL_H 2#define _LINUX_KERNEL_H
3 3
4#include <linux/sysinfo.h>
5
4/* 6/*
5 * 'kernel.h' contains some often-used function prototypes etc 7 * 'kernel.h' contains some often-used function prototypes etc
6 */ 8 */
@@ -428,16 +430,10 @@ extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
428 * Most likely, you want to use tracing_on/tracing_off. 430 * Most likely, you want to use tracing_on/tracing_off.
429 */ 431 */
430#ifdef CONFIG_RING_BUFFER 432#ifdef CONFIG_RING_BUFFER
431void tracing_on(void);
432void tracing_off(void);
433/* trace_off_permanent stops recording with no way to bring it back */ 433/* trace_off_permanent stops recording with no way to bring it back */
434void tracing_off_permanent(void); 434void tracing_off_permanent(void);
435int tracing_is_on(void);
436#else 435#else
437static inline void tracing_on(void) { }
438static inline void tracing_off(void) { }
439static inline void tracing_off_permanent(void) { } 436static inline void tracing_off_permanent(void) { }
440static inline int tracing_is_on(void) { return 0; }
441#endif 437#endif
442 438
443enum ftrace_dump_mode { 439enum ftrace_dump_mode {
@@ -447,6 +443,10 @@ enum ftrace_dump_mode {
447}; 443};
448 444
449#ifdef CONFIG_TRACING 445#ifdef CONFIG_TRACING
446void tracing_on(void);
447void tracing_off(void);
448int tracing_is_on(void);
449
450extern void tracing_start(void); 450extern void tracing_start(void);
451extern void tracing_stop(void); 451extern void tracing_stop(void);
452extern void ftrace_off_permanent(void); 452extern void ftrace_off_permanent(void);
@@ -531,6 +531,11 @@ static inline void tracing_start(void) { }
531static inline void tracing_stop(void) { } 531static inline void tracing_stop(void) { }
532static inline void ftrace_off_permanent(void) { } 532static inline void ftrace_off_permanent(void) { }
533static inline void trace_dump_stack(void) { } 533static inline void trace_dump_stack(void) { }
534
535static inline void tracing_on(void) { }
536static inline void tracing_off(void) { }
537static inline int tracing_is_on(void) { return 0; }
538
534static inline int 539static inline int
535trace_printk(const char *fmt, ...) 540trace_printk(const char *fmt, ...)
536{ 541{
@@ -698,27 +703,8 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
698# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD 703# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
699#endif 704#endif
700 705
701struct sysinfo;
702extern int do_sysinfo(struct sysinfo *info); 706extern int do_sysinfo(struct sysinfo *info);
703 707
704#endif /* __KERNEL__ */ 708#endif /* __KERNEL__ */
705 709
706#define SI_LOAD_SHIFT 16
707struct sysinfo {
708 long uptime; /* Seconds since boot */
709 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
710 unsigned long totalram; /* Total usable main memory size */
711 unsigned long freeram; /* Available memory size */
712 unsigned long sharedram; /* Amount of shared memory */
713 unsigned long bufferram; /* Memory used by buffers */
714 unsigned long totalswap; /* Total swap space size */
715 unsigned long freeswap; /* swap space still available */
716 unsigned short procs; /* Number of current processes */
717 unsigned short pad; /* explicit padding for m68k */
718 unsigned long totalhigh; /* Total high memory size */
719 unsigned long freehigh; /* Available high memory size */
720 unsigned int mem_unit; /* Memory unit size in bytes */
721 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
722};
723
724#endif 710#endif
diff --git a/include/linux/lp8727.h b/include/linux/lp8727.h
index d21fa2865bf4..ea98c6133d32 100644
--- a/include/linux/lp8727.h
+++ b/include/linux/lp8727.h
@@ -1,4 +1,7 @@
1/* 1/*
2 * LP8727 Micro/Mini USB IC with integrated charger
3 *
4 * Copyright (C) 2011 Texas Instruments
2 * Copyright (C) 2011 National Semiconductor 5 * Copyright (C) 2011 National Semiconductor
3 * 6 *
4 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -32,13 +35,24 @@ enum lp8727_ichg {
32 ICHG_1000mA, 35 ICHG_1000mA,
33}; 36};
34 37
38/**
39 * struct lp8727_chg_param
40 * @eoc_level : end of charge level setting
41 * @ichg : charging current
42 */
35struct lp8727_chg_param { 43struct lp8727_chg_param {
36 /* end of charge level setting */
37 enum lp8727_eoc_level eoc_level; 44 enum lp8727_eoc_level eoc_level;
38 /* charging current */
39 enum lp8727_ichg ichg; 45 enum lp8727_ichg ichg;
40}; 46};
41 47
48/**
49 * struct lp8727_platform_data
50 * @get_batt_present : check battery status - exists or not
51 * @get_batt_level : get battery voltage (mV)
52 * @get_batt_capacity : get battery capacity (%)
53 * @get_batt_temp : get battery temperature
54 * @ac, @usb : charging parameters each charger type
55 */
42struct lp8727_platform_data { 56struct lp8727_platform_data {
43 u8 (*get_batt_present)(void); 57 u8 (*get_batt_present)(void);
44 u16 (*get_batt_level)(void); 58 u16 (*get_batt_level)(void);
diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h
index 5fa697477b71..ee96cd51d8b2 100644
--- a/include/linux/mfd/abx500.h
+++ b/include/linux/mfd/abx500.h
@@ -146,6 +146,279 @@ struct abx500_init_settings {
146 u8 setting; 146 u8 setting;
147}; 147};
148 148
149/* Battery driver related data */
150/*
151 * ADC for the battery thermistor.
152 * When using the ABx500_ADC_THERM_BATCTRL the battery ID resistor is combined
153 * with a NTC resistor to both identify the battery and to measure its
154 * temperature. Different phone manufactures uses different techniques to both
155 * identify the battery and to read its temperature.
156 */
157enum abx500_adc_therm {
158 ABx500_ADC_THERM_BATCTRL,
159 ABx500_ADC_THERM_BATTEMP,
160};
161
162/**
163 * struct abx500_res_to_temp - defines one point in a temp to res curve. To
164 * be used in battery packs that combines the identification resistor with a
165 * NTC resistor.
166 * @temp: battery pack temperature in Celcius
167 * @resist: NTC resistor net total resistance
168 */
169struct abx500_res_to_temp {
170 int temp;
171 int resist;
172};
173
174/**
175 * struct abx500_v_to_cap - Table for translating voltage to capacity
176 * @voltage: Voltage in mV
177 * @capacity: Capacity in percent
178 */
179struct abx500_v_to_cap {
180 int voltage;
181 int capacity;
182};
183
184/* Forward declaration */
185struct abx500_fg;
186
187/**
188 * struct abx500_fg_parameters - Fuel gauge algorithm parameters, in seconds
189 * if not specified
190 * @recovery_sleep_timer: Time between measurements while recovering
191 * @recovery_total_time: Total recovery time
192 * @init_timer: Measurement interval during startup
193 * @init_discard_time: Time we discard voltage measurement at startup
194 * @init_total_time: Total init time during startup
195 * @high_curr_time: Time current has to be high to go to recovery
196 * @accu_charging: FG accumulation time while charging
197 * @accu_high_curr: FG accumulation time in high current mode
198 * @high_curr_threshold: High current threshold, in mA
199 * @lowbat_threshold: Low battery threshold, in mV
200 * @overbat_threshold: Over battery threshold, in mV
201 * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0
202 * Resolution in 50 mV step.
203 * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1
204 * Resolution in 50 mV step.
205 * @user_cap_limit Capacity reported from user must be within this
206 * limit to be considered as sane, in percentage
207 * points.
208 * @maint_thres This is the threshold where we stop reporting
209 * battery full while in maintenance, in per cent
210 */
211struct abx500_fg_parameters {
212 int recovery_sleep_timer;
213 int recovery_total_time;
214 int init_timer;
215 int init_discard_time;
216 int init_total_time;
217 int high_curr_time;
218 int accu_charging;
219 int accu_high_curr;
220 int high_curr_threshold;
221 int lowbat_threshold;
222 int overbat_threshold;
223 int battok_falling_th_sel0;
224 int battok_raising_th_sel1;
225 int user_cap_limit;
226 int maint_thres;
227};
228
229/**
230 * struct abx500_charger_maximization - struct used by the board config.
231 * @use_maxi: Enable maximization for this battery type
232 * @maxi_chg_curr: Maximum charger current allowed
233 * @maxi_wait_cycles: cycles to wait before setting charger current
234 * @charger_curr_step delta between two charger current settings (mA)
235 */
236struct abx500_maxim_parameters {
237 bool ena_maxi;
238 int chg_curr;
239 int wait_cycles;
240 int charger_curr_step;
241};
242
243/**
244 * struct abx500_battery_type - different batteries supported
245 * @name: battery technology
246 * @resis_high: battery upper resistance limit
247 * @resis_low: battery lower resistance limit
248 * @charge_full_design: Maximum battery capacity in mAh
249 * @nominal_voltage: Nominal voltage of the battery in mV
250 * @termination_vol: max voltage upto which battery can be charged
251 * @termination_curr battery charging termination current in mA
252 * @recharge_vol battery voltage limit that will trigger a new
253 * full charging cycle in the case where maintenan-
254 * -ce charging has been disabled
255 * @normal_cur_lvl: charger current in normal state in mA
256 * @normal_vol_lvl: charger voltage in normal state in mV
257 * @maint_a_cur_lvl: charger current in maintenance A state in mA
258 * @maint_a_vol_lvl: charger voltage in maintenance A state in mV
259 * @maint_a_chg_timer_h: charge time in maintenance A state
260 * @maint_b_cur_lvl: charger current in maintenance B state in mA
261 * @maint_b_vol_lvl: charger voltage in maintenance B state in mV
262 * @maint_b_chg_timer_h: charge time in maintenance B state
263 * @low_high_cur_lvl: charger current in temp low/high state in mA
264 * @low_high_vol_lvl: charger voltage in temp low/high state in mV'
265 * @battery_resistance: battery inner resistance in mOhm.
266 * @n_r_t_tbl_elements: number of elements in r_to_t_tbl
267 * @r_to_t_tbl: table containing resistance to temp points
268 * @n_v_cap_tbl_elements: number of elements in v_to_cap_tbl
269 * @v_to_cap_tbl: Voltage to capacity (in %) table
270 * @n_batres_tbl_elements number of elements in the batres_tbl
271 * @batres_tbl battery internal resistance vs temperature table
272 */
273struct abx500_battery_type {
274 int name;
275 int resis_high;
276 int resis_low;
277 int charge_full_design;
278 int nominal_voltage;
279 int termination_vol;
280 int termination_curr;
281 int recharge_vol;
282 int normal_cur_lvl;
283 int normal_vol_lvl;
284 int maint_a_cur_lvl;
285 int maint_a_vol_lvl;
286 int maint_a_chg_timer_h;
287 int maint_b_cur_lvl;
288 int maint_b_vol_lvl;
289 int maint_b_chg_timer_h;
290 int low_high_cur_lvl;
291 int low_high_vol_lvl;
292 int battery_resistance;
293 int n_temp_tbl_elements;
294 struct abx500_res_to_temp *r_to_t_tbl;
295 int n_v_cap_tbl_elements;
296 struct abx500_v_to_cap *v_to_cap_tbl;
297 int n_batres_tbl_elements;
298 struct batres_vs_temp *batres_tbl;
299};
300
301/**
302 * struct abx500_bm_capacity_levels - abx500 capacity level data
303 * @critical: critical capacity level in percent
304 * @low: low capacity level in percent
305 * @normal: normal capacity level in percent
306 * @high: high capacity level in percent
307 * @full: full capacity level in percent
308 */
309struct abx500_bm_capacity_levels {
310 int critical;
311 int low;
312 int normal;
313 int high;
314 int full;
315};
316
317/**
318 * struct abx500_bm_charger_parameters - Charger specific parameters
319 * @usb_volt_max: maximum allowed USB charger voltage in mV
320 * @usb_curr_max: maximum allowed USB charger current in mA
321 * @ac_volt_max: maximum allowed AC charger voltage in mV
322 * @ac_curr_max: maximum allowed AC charger current in mA
323 */
324struct abx500_bm_charger_parameters {
325 int usb_volt_max;
326 int usb_curr_max;
327 int ac_volt_max;
328 int ac_curr_max;
329};
330
331/**
332 * struct abx500_bm_data - abx500 battery management data
333 * @temp_under under this temp, charging is stopped
334 * @temp_low between this temp and temp_under charging is reduced
335 * @temp_high between this temp and temp_over charging is reduced
336 * @temp_over over this temp, charging is stopped
337 * @temp_now present battery temperature
338 * @temp_interval_chg temperature measurement interval in s when charging
339 * @temp_interval_nochg temperature measurement interval in s when not charging
340 * @main_safety_tmr_h safety timer for main charger
341 * @usb_safety_tmr_h safety timer for usb charger
342 * @bkup_bat_v voltage which we charge the backup battery with
343 * @bkup_bat_i current which we charge the backup battery with
344 * @no_maintenance indicates that maintenance charging is disabled
345 * @abx500_adc_therm placement of thermistor, batctrl or battemp adc
346 * @chg_unknown_bat flag to enable charging of unknown batteries
347 * @enable_overshoot flag to enable VBAT overshoot control
348 * @auto_trig flag to enable auto adc trigger
349 * @fg_res resistance of FG resistor in 0.1mOhm
350 * @n_btypes number of elements in array bat_type
351 * @batt_id index of the identified battery in array bat_type
352 * @interval_charging charge alg cycle period time when charging (sec)
353 * @interval_not_charging charge alg cycle period time when not charging (sec)
354 * @temp_hysteresis temperature hysteresis
355 * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm)
356 * @maxi: maximization parameters
357 * @cap_levels capacity in percent for the different capacity levels
358 * @bat_type table of supported battery types
359 * @chg_params charger parameters
360 * @fg_params fuel gauge parameters
361 */
362struct abx500_bm_data {
363 int temp_under;
364 int temp_low;
365 int temp_high;
366 int temp_over;
367 int temp_now;
368 int temp_interval_chg;
369 int temp_interval_nochg;
370 int main_safety_tmr_h;
371 int usb_safety_tmr_h;
372 int bkup_bat_v;
373 int bkup_bat_i;
374 bool no_maintenance;
375 bool chg_unknown_bat;
376 bool enable_overshoot;
377 bool auto_trig;
378 enum abx500_adc_therm adc_therm;
379 int fg_res;
380 int n_btypes;
381 int batt_id;
382 int interval_charging;
383 int interval_not_charging;
384 int temp_hysteresis;
385 int gnd_lift_resistance;
386 const struct abx500_maxim_parameters *maxi;
387 const struct abx500_bm_capacity_levels *cap_levels;
388 const struct abx500_battery_type *bat_type;
389 const struct abx500_bm_charger_parameters *chg_params;
390 const struct abx500_fg_parameters *fg_params;
391};
392
393struct abx500_chargalg_platform_data {
394 char **supplied_to;
395 size_t num_supplicants;
396};
397
398struct abx500_charger_platform_data {
399 char **supplied_to;
400 size_t num_supplicants;
401 bool autopower_cfg;
402};
403
404struct abx500_btemp_platform_data {
405 char **supplied_to;
406 size_t num_supplicants;
407};
408
409struct abx500_fg_platform_data {
410 char **supplied_to;
411 size_t num_supplicants;
412};
413
414struct abx500_bm_plat_data {
415 struct abx500_bm_data *battery;
416 struct abx500_charger_platform_data *charger;
417 struct abx500_btemp_platform_data *btemp;
418 struct abx500_fg_platform_data *fg;
419 struct abx500_chargalg_platform_data *chargalg;
420};
421
149int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg, 422int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg,
150 u8 value); 423 u8 value);
151int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg, 424int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg,
diff --git a/include/linux/mfd/abx500/ab8500-bm.h b/include/linux/mfd/abx500/ab8500-bm.h
new file mode 100644
index 000000000000..44310c98ee6e
--- /dev/null
+++ b/include/linux/mfd/abx500/ab8500-bm.h
@@ -0,0 +1,474 @@
1/*
2 * Copyright ST-Ericsson 2012.
3 *
4 * Author: Arun Murthy <arun.murthy@stericsson.com>
5 * Licensed under GPLv2.
6 */
7
8#ifndef _AB8500_BM_H
9#define _AB8500_BM_H
10
11#include <linux/kernel.h>
12#include <linux/mfd/abx500.h>
13
14/*
15 * System control 2 register offsets.
16 * bank = 0x02
17 */
18#define AB8500_MAIN_WDOG_CTRL_REG 0x01
19#define AB8500_LOW_BAT_REG 0x03
20#define AB8500_BATT_OK_REG 0x04
21/*
22 * USB/ULPI register offsets
23 * Bank : 0x5
24 */
25#define AB8500_USB_LINE_STAT_REG 0x80
26
27/*
28 * Charger / status register offfsets
29 * Bank : 0x0B
30 */
31#define AB8500_CH_STATUS1_REG 0x00
32#define AB8500_CH_STATUS2_REG 0x01
33#define AB8500_CH_USBCH_STAT1_REG 0x02
34#define AB8500_CH_USBCH_STAT2_REG 0x03
35#define AB8500_CH_FSM_STAT_REG 0x04
36#define AB8500_CH_STAT_REG 0x05
37
38/*
39 * Charger / control register offfsets
40 * Bank : 0x0B
41 */
42#define AB8500_CH_VOLT_LVL_REG 0x40
43#define AB8500_CH_VOLT_LVL_MAX_REG 0x41 /*Only in Cut2.0*/
44#define AB8500_CH_OPT_CRNTLVL_REG 0x42
45#define AB8500_CH_OPT_CRNTLVL_MAX_REG 0x43 /*Only in Cut2.0*/
46#define AB8500_CH_WD_TIMER_REG 0x50
47#define AB8500_CHARG_WD_CTRL 0x51
48#define AB8500_BTEMP_HIGH_TH 0x52
49#define AB8500_LED_INDICATOR_PWM_CTRL 0x53
50#define AB8500_LED_INDICATOR_PWM_DUTY 0x54
51#define AB8500_BATT_OVV 0x55
52#define AB8500_CHARGER_CTRL 0x56
53#define AB8500_BAT_CTRL_CURRENT_SOURCE 0x60 /*Only in Cut2.0*/
54
55/*
56 * Charger / main control register offsets
57 * Bank : 0x0B
58 */
59#define AB8500_MCH_CTRL1 0x80
60#define AB8500_MCH_CTRL2 0x81
61#define AB8500_MCH_IPT_CURLVL_REG 0x82
62#define AB8500_CH_WD_REG 0x83
63
64/*
65 * Charger / USB control register offsets
66 * Bank : 0x0B
67 */
68#define AB8500_USBCH_CTRL1_REG 0xC0
69#define AB8500_USBCH_CTRL2_REG 0xC1
70#define AB8500_USBCH_IPT_CRNTLVL_REG 0xC2
71
72/*
73 * Gas Gauge register offsets
74 * Bank : 0x0C
75 */
76#define AB8500_GASG_CC_CTRL_REG 0x00
77#define AB8500_GASG_CC_ACCU1_REG 0x01
78#define AB8500_GASG_CC_ACCU2_REG 0x02
79#define AB8500_GASG_CC_ACCU3_REG 0x03
80#define AB8500_GASG_CC_ACCU4_REG 0x04
81#define AB8500_GASG_CC_SMPL_CNTRL_REG 0x05
82#define AB8500_GASG_CC_SMPL_CNTRH_REG 0x06
83#define AB8500_GASG_CC_SMPL_CNVL_REG 0x07
84#define AB8500_GASG_CC_SMPL_CNVH_REG 0x08
85#define AB8500_GASG_CC_CNTR_AVGOFF_REG 0x09
86#define AB8500_GASG_CC_OFFSET_REG 0x0A
87#define AB8500_GASG_CC_NCOV_ACCU 0x10
88#define AB8500_GASG_CC_NCOV_ACCU_CTRL 0x11
89#define AB8500_GASG_CC_NCOV_ACCU_LOW 0x12
90#define AB8500_GASG_CC_NCOV_ACCU_MED 0x13
91#define AB8500_GASG_CC_NCOV_ACCU_HIGH 0x14
92
93/*
94 * Interrupt register offsets
95 * Bank : 0x0E
96 */
97#define AB8500_IT_SOURCE2_REG 0x01
98#define AB8500_IT_SOURCE21_REG 0x14
99
100/*
101 * RTC register offsets
102 * Bank: 0x0F
103 */
104#define AB8500_RTC_BACKUP_CHG_REG 0x0C
105#define AB8500_RTC_CC_CONF_REG 0x01
106#define AB8500_RTC_CTRL_REG 0x0B
107
108/*
109 * OTP register offsets
110 * Bank : 0x15
111 */
112#define AB8500_OTP_CONF_15 0x0E
113
114/* GPADC constants from AB8500 spec, UM0836 */
115#define ADC_RESOLUTION 1024
116#define ADC_CH_MAIN_MIN 0
117#define ADC_CH_MAIN_MAX 20030
118#define ADC_CH_VBUS_MIN 0
119#define ADC_CH_VBUS_MAX 20030
120#define ADC_CH_VBAT_MIN 2300
121#define ADC_CH_VBAT_MAX 4800
122#define ADC_CH_BKBAT_MIN 0
123#define ADC_CH_BKBAT_MAX 3200
124
125/* Main charge i/p current */
126#define MAIN_CH_IP_CUR_0P9A 0x80
127#define MAIN_CH_IP_CUR_1P0A 0x90
128#define MAIN_CH_IP_CUR_1P1A 0xA0
129#define MAIN_CH_IP_CUR_1P2A 0xB0
130#define MAIN_CH_IP_CUR_1P3A 0xC0
131#define MAIN_CH_IP_CUR_1P4A 0xD0
132#define MAIN_CH_IP_CUR_1P5A 0xE0
133
134/* ChVoltLevel */
135#define CH_VOL_LVL_3P5 0x00
136#define CH_VOL_LVL_4P0 0x14
137#define CH_VOL_LVL_4P05 0x16
138#define CH_VOL_LVL_4P1 0x1B
139#define CH_VOL_LVL_4P15 0x20
140#define CH_VOL_LVL_4P2 0x25
141#define CH_VOL_LVL_4P6 0x4D
142
143/* ChOutputCurrentLevel */
144#define CH_OP_CUR_LVL_0P1 0x00
145#define CH_OP_CUR_LVL_0P2 0x01
146#define CH_OP_CUR_LVL_0P3 0x02
147#define CH_OP_CUR_LVL_0P4 0x03
148#define CH_OP_CUR_LVL_0P5 0x04
149#define CH_OP_CUR_LVL_0P6 0x05
150#define CH_OP_CUR_LVL_0P7 0x06
151#define CH_OP_CUR_LVL_0P8 0x07
152#define CH_OP_CUR_LVL_0P9 0x08
153#define CH_OP_CUR_LVL_1P4 0x0D
154#define CH_OP_CUR_LVL_1P5 0x0E
155#define CH_OP_CUR_LVL_1P6 0x0F
156
157/* BTEMP High thermal limits */
158#define BTEMP_HIGH_TH_57_0 0x00
159#define BTEMP_HIGH_TH_52 0x01
160#define BTEMP_HIGH_TH_57_1 0x02
161#define BTEMP_HIGH_TH_62 0x03
162
163/* current is mA */
164#define USB_0P1A 100
165#define USB_0P2A 200
166#define USB_0P3A 300
167#define USB_0P4A 400
168#define USB_0P5A 500
169
170#define LOW_BAT_3P1V 0x20
171#define LOW_BAT_2P3V 0x00
172#define LOW_BAT_RESET 0x01
173#define LOW_BAT_ENABLE 0x01
174
175/* Backup battery constants */
176#define BUP_ICH_SEL_50UA 0x00
177#define BUP_ICH_SEL_150UA 0x04
178#define BUP_ICH_SEL_300UA 0x08
179#define BUP_ICH_SEL_700UA 0x0C
180
181#define BUP_VCH_SEL_2P5V 0x00
182#define BUP_VCH_SEL_2P6V 0x01
183#define BUP_VCH_SEL_2P8V 0x02
184#define BUP_VCH_SEL_3P1V 0x03
185
186/* Battery OVV constants */
187#define BATT_OVV_ENA 0x02
188#define BATT_OVV_TH_3P7 0x00
189#define BATT_OVV_TH_4P75 0x01
190
191/* A value to indicate over voltage */
192#define BATT_OVV_VALUE 4750
193
194/* VBUS OVV constants */
195#define VBUS_OVV_SELECT_MASK 0x78
196#define VBUS_OVV_SELECT_5P6V 0x00
197#define VBUS_OVV_SELECT_5P7V 0x08
198#define VBUS_OVV_SELECT_5P8V 0x10
199#define VBUS_OVV_SELECT_5P9V 0x18
200#define VBUS_OVV_SELECT_6P0V 0x20
201#define VBUS_OVV_SELECT_6P1V 0x28
202#define VBUS_OVV_SELECT_6P2V 0x30
203#define VBUS_OVV_SELECT_6P3V 0x38
204
205#define VBUS_AUTO_IN_CURR_LIM_ENA 0x04
206
207/* Fuel Gauge constants */
208#define RESET_ACCU 0x02
209#define READ_REQ 0x01
210#define CC_DEEP_SLEEP_ENA 0x02
211#define CC_PWR_UP_ENA 0x01
212#define CC_SAMPLES_40 0x28
213#define RD_NCONV_ACCU_REQ 0x01
214#define CC_CALIB 0x08
215#define CC_INTAVGOFFSET_ENA 0x10
216#define CC_MUXOFFSET 0x80
217#define CC_INT_CAL_N_AVG_MASK 0x60
218#define CC_INT_CAL_SAMPLES_16 0x40
219#define CC_INT_CAL_SAMPLES_8 0x20
220#define CC_INT_CAL_SAMPLES_4 0x00
221
222/* RTC constants */
223#define RTC_BUP_CH_ENA 0x10
224
225/* BatCtrl Current Source Constants */
226#define BAT_CTRL_7U_ENA 0x01
227#define BAT_CTRL_20U_ENA 0x02
228#define BAT_CTRL_CMP_ENA 0x04
229#define FORCE_BAT_CTRL_CMP_HIGH 0x08
230#define BAT_CTRL_PULL_UP_ENA 0x10
231
232/* Battery type */
233#define BATTERY_UNKNOWN 00
234
235/**
236 * struct res_to_temp - defines one point in a temp to res curve. To
237 * be used in battery packs that combines the identification resistor with a
238 * NTC resistor.
239 * @temp: battery pack temperature in Celcius
240 * @resist: NTC resistor net total resistance
241 */
242struct res_to_temp {
243 int temp;
244 int resist;
245};
246
247/**
248 * struct batres_vs_temp - defines one point in a temp vs battery internal
249 * resistance curve.
250 * @temp: battery pack temperature in Celcius
251 * @resist: battery internal reistance in mOhm
252 */
253struct batres_vs_temp {
254 int temp;
255 int resist;
256};
257
258/* Forward declaration */
259struct ab8500_fg;
260
261/**
262 * struct ab8500_fg_parameters - Fuel gauge algorithm parameters, in seconds
263 * if not specified
264 * @recovery_sleep_timer: Time between measurements while recovering
265 * @recovery_total_time: Total recovery time
266 * @init_timer: Measurement interval during startup
267 * @init_discard_time: Time we discard voltage measurement at startup
268 * @init_total_time: Total init time during startup
269 * @high_curr_time: Time current has to be high to go to recovery
270 * @accu_charging: FG accumulation time while charging
271 * @accu_high_curr: FG accumulation time in high current mode
272 * @high_curr_threshold: High current threshold, in mA
273 * @lowbat_threshold: Low battery threshold, in mV
274 * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0
275 * Resolution in 50 mV step.
276 * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1
277 * Resolution in 50 mV step.
278 * @user_cap_limit Capacity reported from user must be within this
279 * limit to be considered as sane, in percentage
280 * points.
281 * @maint_thres This is the threshold where we stop reporting
282 * battery full while in maintenance, in per cent
283 */
284struct ab8500_fg_parameters {
285 int recovery_sleep_timer;
286 int recovery_total_time;
287 int init_timer;
288 int init_discard_time;
289 int init_total_time;
290 int high_curr_time;
291 int accu_charging;
292 int accu_high_curr;
293 int high_curr_threshold;
294 int lowbat_threshold;
295 int battok_falling_th_sel0;
296 int battok_raising_th_sel1;
297 int user_cap_limit;
298 int maint_thres;
299};
300
301/**
302 * struct ab8500_charger_maximization - struct used by the board config.
303 * @use_maxi: Enable maximization for this battery type
304 * @maxi_chg_curr: Maximum charger current allowed
305 * @maxi_wait_cycles: cycles to wait before setting charger current
306 * @charger_curr_step delta between two charger current settings (mA)
307 */
308struct ab8500_maxim_parameters {
309 bool ena_maxi;
310 int chg_curr;
311 int wait_cycles;
312 int charger_curr_step;
313};
314
315/**
316 * struct ab8500_bm_capacity_levels - ab8500 capacity level data
317 * @critical: critical capacity level in percent
318 * @low: low capacity level in percent
319 * @normal: normal capacity level in percent
320 * @high: high capacity level in percent
321 * @full: full capacity level in percent
322 */
323struct ab8500_bm_capacity_levels {
324 int critical;
325 int low;
326 int normal;
327 int high;
328 int full;
329};
330
331/**
332 * struct ab8500_bm_charger_parameters - Charger specific parameters
333 * @usb_volt_max: maximum allowed USB charger voltage in mV
334 * @usb_curr_max: maximum allowed USB charger current in mA
335 * @ac_volt_max: maximum allowed AC charger voltage in mV
336 * @ac_curr_max: maximum allowed AC charger current in mA
337 */
338struct ab8500_bm_charger_parameters {
339 int usb_volt_max;
340 int usb_curr_max;
341 int ac_volt_max;
342 int ac_curr_max;
343};
344
345/**
346 * struct ab8500_bm_data - ab8500 battery management data
347 * @temp_under under this temp, charging is stopped
348 * @temp_low between this temp and temp_under charging is reduced
349 * @temp_high between this temp and temp_over charging is reduced
350 * @temp_over over this temp, charging is stopped
351 * @temp_interval_chg temperature measurement interval in s when charging
352 * @temp_interval_nochg temperature measurement interval in s when not charging
353 * @main_safety_tmr_h safety timer for main charger
354 * @usb_safety_tmr_h safety timer for usb charger
355 * @bkup_bat_v voltage which we charge the backup battery with
356 * @bkup_bat_i current which we charge the backup battery with
357 * @no_maintenance indicates that maintenance charging is disabled
358 * @adc_therm placement of thermistor, batctrl or battemp adc
359 * @chg_unknown_bat flag to enable charging of unknown batteries
360 * @enable_overshoot flag to enable VBAT overshoot control
361 * @fg_res resistance of FG resistor in 0.1mOhm
362 * @n_btypes number of elements in array bat_type
363 * @batt_id index of the identified battery in array bat_type
364 * @interval_charging charge alg cycle period time when charging (sec)
365 * @interval_not_charging charge alg cycle period time when not charging (sec)
366 * @temp_hysteresis temperature hysteresis
367 * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm)
368 * @maxi: maximization parameters
369 * @cap_levels capacity in percent for the different capacity levels
370 * @bat_type table of supported battery types
371 * @chg_params charger parameters
372 * @fg_params fuel gauge parameters
373 */
374struct ab8500_bm_data {
375 int temp_under;
376 int temp_low;
377 int temp_high;
378 int temp_over;
379 int temp_interval_chg;
380 int temp_interval_nochg;
381 int main_safety_tmr_h;
382 int usb_safety_tmr_h;
383 int bkup_bat_v;
384 int bkup_bat_i;
385 bool no_maintenance;
386 bool chg_unknown_bat;
387 bool enable_overshoot;
388 enum abx500_adc_therm adc_therm;
389 int fg_res;
390 int n_btypes;
391 int batt_id;
392 int interval_charging;
393 int interval_not_charging;
394 int temp_hysteresis;
395 int gnd_lift_resistance;
396 const struct ab8500_maxim_parameters *maxi;
397 const struct ab8500_bm_capacity_levels *cap_levels;
398 const struct ab8500_bm_charger_parameters *chg_params;
399 const struct ab8500_fg_parameters *fg_params;
400};
401
402struct ab8500_charger_platform_data {
403 char **supplied_to;
404 size_t num_supplicants;
405 bool autopower_cfg;
406};
407
408struct ab8500_btemp_platform_data {
409 char **supplied_to;
410 size_t num_supplicants;
411};
412
413struct ab8500_fg_platform_data {
414 char **supplied_to;
415 size_t num_supplicants;
416};
417
418struct ab8500_chargalg_platform_data {
419 char **supplied_to;
420 size_t num_supplicants;
421};
422struct ab8500_btemp;
423struct ab8500_gpadc;
424struct ab8500_fg;
425#ifdef CONFIG_AB8500_BM
426void ab8500_fg_reinit(void);
427void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA);
428struct ab8500_btemp *ab8500_btemp_get(void);
429int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp);
430struct ab8500_fg *ab8500_fg_get(void);
431int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev);
432int ab8500_fg_inst_curr_start(struct ab8500_fg *di);
433int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res);
434int ab8500_fg_inst_curr_done(struct ab8500_fg *di);
435
436#else
437int ab8500_fg_inst_curr_done(struct ab8500_fg *di)
438{
439}
440static void ab8500_fg_reinit(void)
441{
442}
443static void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA)
444{
445}
446static struct ab8500_btemp *ab8500_btemp_get(void)
447{
448 return NULL;
449}
450static int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp)
451{
452 return 0;
453}
454struct ab8500_fg *ab8500_fg_get(void)
455{
456 return NULL;
457}
458static int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev)
459{
460 return -ENODEV;
461}
462
463static inline int ab8500_fg_inst_curr_start(struct ab8500_fg *di)
464{
465 return -ENODEV;
466}
467
468static inline int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res)
469{
470 return -ENODEV;
471}
472
473#endif
474#endif /* _AB8500_BM_H */
diff --git a/include/linux/mfd/abx500/ux500_chargalg.h b/include/linux/mfd/abx500/ux500_chargalg.h
new file mode 100644
index 000000000000..9b07725750c9
--- /dev/null
+++ b/include/linux/mfd/abx500/ux500_chargalg.h
@@ -0,0 +1,38 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2012
3 * Author: Johan Gardsmark <johan.gardsmark@stericsson.com> for ST-Ericsson.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#ifndef _UX500_CHARGALG_H
8#define _UX500_CHARGALG_H
9
10#include <linux/power_supply.h>
11
12#define psy_to_ux500_charger(x) container_of((x), \
13 struct ux500_charger, psy)
14
15/* Forward declaration */
16struct ux500_charger;
17
18struct ux500_charger_ops {
19 int (*enable) (struct ux500_charger *, int, int, int);
20 int (*kick_wd) (struct ux500_charger *);
21 int (*update_curr) (struct ux500_charger *, int);
22};
23
24/**
25 * struct ux500_charger - power supply ux500 charger sub class
26 * @psy power supply base class
27 * @ops ux500 charger operations
28 * @max_out_volt maximum output charger voltage in mV
29 * @max_out_curr maximum output charger current in mA
30 */
31struct ux500_charger {
32 struct power_supply psy;
33 struct ux500_charger_ops ops;
34 int max_out_volt;
35 int max_out_curr;
36};
37
38#endif
diff --git a/include/linux/mtd/bbm.h b/include/linux/mtd/bbm.h
index c4eec228eef9..650ef352f045 100644
--- a/include/linux/mtd/bbm.h
+++ b/include/linux/mtd/bbm.h
@@ -112,6 +112,11 @@ struct nand_bbt_descr {
112#define NAND_BBT_USE_FLASH 0x00020000 112#define NAND_BBT_USE_FLASH 0x00020000
113/* Do not store flash based bad block table in OOB area; store it in-band */ 113/* Do not store flash based bad block table in OOB area; store it in-band */
114#define NAND_BBT_NO_OOB 0x00040000 114#define NAND_BBT_NO_OOB 0x00040000
115/*
116 * Do not write new bad block markers to OOB; useful, e.g., when ECC covers
117 * entire spare area. Must be used with NAND_BBT_USE_FLASH.
118 */
119#define NAND_BBT_NO_OOB_BBM 0x00080000
115 120
116/* 121/*
117 * Flag set by nand_create_default_bbt_descr(), marking that the nand_bbt_descr 122 * Flag set by nand_create_default_bbt_descr(), marking that the nand_bbt_descr
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h
index 1bbd9f289245..ed270bd2e4df 100644
--- a/include/linux/mtd/blktrans.h
+++ b/include/linux/mtd/blktrans.h
@@ -47,6 +47,7 @@ struct mtd_blktrans_dev {
47 struct request_queue *rq; 47 struct request_queue *rq;
48 spinlock_t queue_lock; 48 spinlock_t queue_lock;
49 void *priv; 49 void *priv;
50 fmode_t file_mode;
50}; 51};
51 52
52struct mtd_blktrans_ops { 53struct mtd_blktrans_ops {
diff --git a/include/linux/mtd/fsmc.h b/include/linux/mtd/fsmc.h
index 6987995ad3cf..b20029221fb1 100644
--- a/include/linux/mtd/fsmc.h
+++ b/include/linux/mtd/fsmc.h
@@ -26,95 +26,83 @@
26#define FSMC_NAND_BW8 1 26#define FSMC_NAND_BW8 1
27#define FSMC_NAND_BW16 2 27#define FSMC_NAND_BW16 2
28 28
29/*
30 * The placement of the Command Latch Enable (CLE) and
31 * Address Latch Enable (ALE) is twisted around in the
32 * SPEAR310 implementation.
33 */
34#if defined(CONFIG_MACH_SPEAR310)
35#define PLAT_NAND_CLE (1 << 17)
36#define PLAT_NAND_ALE (1 << 16)
37#else
38#define PLAT_NAND_CLE (1 << 16)
39#define PLAT_NAND_ALE (1 << 17)
40#endif
41
42#define FSMC_MAX_NOR_BANKS 4 29#define FSMC_MAX_NOR_BANKS 4
43#define FSMC_MAX_NAND_BANKS 4 30#define FSMC_MAX_NAND_BANKS 4
44 31
45#define FSMC_FLASH_WIDTH8 1 32#define FSMC_FLASH_WIDTH8 1
46#define FSMC_FLASH_WIDTH16 2 33#define FSMC_FLASH_WIDTH16 2
47 34
48struct fsmc_nor_bank_regs { 35/* fsmc controller registers for NOR flash */
49 uint32_t ctrl; 36#define CTRL 0x0
50 uint32_t ctrl_tim; 37 /* ctrl register definitions */
51}; 38 #define BANK_ENABLE (1 << 0)
52 39 #define MUXED (1 << 1)
53/* ctrl register definitions */ 40 #define NOR_DEV (2 << 2)
54#define BANK_ENABLE (1 << 0) 41 #define WIDTH_8 (0 << 4)
55#define MUXED (1 << 1) 42 #define WIDTH_16 (1 << 4)
56#define NOR_DEV (2 << 2) 43 #define RSTPWRDWN (1 << 6)
57#define WIDTH_8 (0 << 4) 44 #define WPROT (1 << 7)
58#define WIDTH_16 (1 << 4) 45 #define WRT_ENABLE (1 << 12)
59#define RSTPWRDWN (1 << 6) 46 #define WAIT_ENB (1 << 13)
60#define WPROT (1 << 7) 47
61#define WRT_ENABLE (1 << 12) 48#define CTRL_TIM 0x4
62#define WAIT_ENB (1 << 13) 49 /* ctrl_tim register definitions */
63 50
64/* ctrl_tim register definitions */ 51#define FSMC_NOR_BANK_SZ 0x8
65
66struct fsmc_nand_bank_regs {
67 uint32_t pc;
68 uint32_t sts;
69 uint32_t comm;
70 uint32_t attrib;
71 uint32_t ioata;
72 uint32_t ecc1;
73 uint32_t ecc2;
74 uint32_t ecc3;
75};
76
77#define FSMC_NOR_REG_SIZE 0x40 52#define FSMC_NOR_REG_SIZE 0x40
78 53
79struct fsmc_regs { 54#define FSMC_NOR_REG(base, bank, reg) (base + \
80 struct fsmc_nor_bank_regs nor_bank_regs[FSMC_MAX_NOR_BANKS]; 55 FSMC_NOR_BANK_SZ * (bank) + \
81 uint8_t reserved_1[0x40 - 0x20]; 56 reg)
82 struct fsmc_nand_bank_regs bank_regs[FSMC_MAX_NAND_BANKS]; 57
83 uint8_t reserved_2[0xfe0 - 0xc0]; 58/* fsmc controller registers for NAND flash */
84 uint32_t peripid0; /* 0xfe0 */ 59#define PC 0x00
85 uint32_t peripid1; /* 0xfe4 */ 60 /* pc register definitions */
86 uint32_t peripid2; /* 0xfe8 */ 61 #define FSMC_RESET (1 << 0)
87 uint32_t peripid3; /* 0xfec */ 62 #define FSMC_WAITON (1 << 1)
88 uint32_t pcellid0; /* 0xff0 */ 63 #define FSMC_ENABLE (1 << 2)
89 uint32_t pcellid1; /* 0xff4 */ 64 #define FSMC_DEVTYPE_NAND (1 << 3)
90 uint32_t pcellid2; /* 0xff8 */ 65 #define FSMC_DEVWID_8 (0 << 4)
91 uint32_t pcellid3; /* 0xffc */ 66 #define FSMC_DEVWID_16 (1 << 4)
92}; 67 #define FSMC_ECCEN (1 << 6)
68 #define FSMC_ECCPLEN_512 (0 << 7)
69 #define FSMC_ECCPLEN_256 (1 << 7)
70 #define FSMC_TCLR_1 (1)
71 #define FSMC_TCLR_SHIFT (9)
72 #define FSMC_TCLR_MASK (0xF)
73 #define FSMC_TAR_1 (1)
74 #define FSMC_TAR_SHIFT (13)
75 #define FSMC_TAR_MASK (0xF)
76#define STS 0x04
77 /* sts register definitions */
78 #define FSMC_CODE_RDY (1 << 15)
79#define COMM 0x08
80 /* comm register definitions */
81 #define FSMC_TSET_0 0
82 #define FSMC_TSET_SHIFT 0
83 #define FSMC_TSET_MASK 0xFF
84 #define FSMC_TWAIT_6 6
85 #define FSMC_TWAIT_SHIFT 8
86 #define FSMC_TWAIT_MASK 0xFF
87 #define FSMC_THOLD_4 4
88 #define FSMC_THOLD_SHIFT 16
89 #define FSMC_THOLD_MASK 0xFF
90 #define FSMC_THIZ_1 1
91 #define FSMC_THIZ_SHIFT 24
92 #define FSMC_THIZ_MASK 0xFF
93#define ATTRIB 0x0C
94#define IOATA 0x10
95#define ECC1 0x14
96#define ECC2 0x18
97#define ECC3 0x1C
98#define FSMC_NAND_BANK_SZ 0x20
99
100#define FSMC_NAND_REG(base, bank, reg) (base + FSMC_NOR_REG_SIZE + \
101 (FSMC_NAND_BANK_SZ * (bank)) + \
102 reg)
93 103
94#define FSMC_BUSY_WAIT_TIMEOUT (1 * HZ) 104#define FSMC_BUSY_WAIT_TIMEOUT (1 * HZ)
95 105
96/* pc register definitions */
97#define FSMC_RESET (1 << 0)
98#define FSMC_WAITON (1 << 1)
99#define FSMC_ENABLE (1 << 2)
100#define FSMC_DEVTYPE_NAND (1 << 3)
101#define FSMC_DEVWID_8 (0 << 4)
102#define FSMC_DEVWID_16 (1 << 4)
103#define FSMC_ECCEN (1 << 6)
104#define FSMC_ECCPLEN_512 (0 << 7)
105#define FSMC_ECCPLEN_256 (1 << 7)
106#define FSMC_TCLR_1 (1 << 9)
107#define FSMC_TAR_1 (1 << 13)
108
109/* sts register definitions */
110#define FSMC_CODE_RDY (1 << 15)
111
112/* comm register definitions */
113#define FSMC_TSET_0 (0 << 0)
114#define FSMC_TWAIT_6 (6 << 8)
115#define FSMC_THOLD_4 (4 << 16)
116#define FSMC_THIZ_1 (1 << 24)
117
118/* 106/*
119 * There are 13 bytes of ecc for every 512 byte block in FSMC version 8 107 * There are 13 bytes of ecc for every 512 byte block in FSMC version 8
120 * and it has to be read consecutively and immediately after the 512 108 * and it has to be read consecutively and immediately after the 512
@@ -133,6 +121,20 @@ struct fsmc_eccplace {
133 struct fsmc_nand_eccplace eccplace[MAX_ECCPLACE_ENTRIES]; 121 struct fsmc_nand_eccplace eccplace[MAX_ECCPLACE_ENTRIES];
134}; 122};
135 123
124struct fsmc_nand_timings {
125 uint8_t tclr;
126 uint8_t tar;
127 uint8_t thiz;
128 uint8_t thold;
129 uint8_t twait;
130 uint8_t tset;
131};
132
133enum access_mode {
134 USE_DMA_ACCESS = 1,
135 USE_WORD_ACCESS,
136};
137
136/** 138/**
137 * fsmc_nand_platform_data - platform specific NAND controller config 139 * fsmc_nand_platform_data - platform specific NAND controller config
138 * @partitions: partition table for the platform, use a default fallback 140 * @partitions: partition table for the platform, use a default fallback
@@ -146,12 +148,23 @@ struct fsmc_eccplace {
146 * this may be set to NULL 148 * this may be set to NULL
147 */ 149 */
148struct fsmc_nand_platform_data { 150struct fsmc_nand_platform_data {
151 struct fsmc_nand_timings *nand_timings;
149 struct mtd_partition *partitions; 152 struct mtd_partition *partitions;
150 unsigned int nr_partitions; 153 unsigned int nr_partitions;
151 unsigned int options; 154 unsigned int options;
152 unsigned int width; 155 unsigned int width;
153 unsigned int bank; 156 unsigned int bank;
157
158 /* CLE, ALE offsets */
159 unsigned int cle_off;
160 unsigned int ale_off;
161 enum access_mode mode;
162
154 void (*select_bank)(uint32_t bank, uint32_t busw); 163 void (*select_bank)(uint32_t bank, uint32_t busw);
164
165 /* priv structures for dma accesses */
166 void *read_dma_priv;
167 void *write_dma_priv;
155}; 168};
156 169
157extern int __init fsmc_nor_init(struct platform_device *pdev, 170extern int __init fsmc_nor_init(struct platform_device *pdev,
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index d43dc25af82e..cf5ea8cdcf8e 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -164,6 +164,9 @@ struct mtd_info {
164 /* ECC layout structure pointer - read only! */ 164 /* ECC layout structure pointer - read only! */
165 struct nand_ecclayout *ecclayout; 165 struct nand_ecclayout *ecclayout;
166 166
167 /* max number of correctible bit errors per writesize */
168 unsigned int ecc_strength;
169
167 /* Data for variable erase regions. If numeraseregions is zero, 170 /* Data for variable erase regions. If numeraseregions is zero,
168 * it means that the whole device has erasesize as given above. 171 * it means that the whole device has erasesize as given above.
169 */ 172 */
@@ -174,52 +177,52 @@ struct mtd_info {
174 * Do not call via these pointers, use corresponding mtd_*() 177 * Do not call via these pointers, use corresponding mtd_*()
175 * wrappers instead. 178 * wrappers instead.
176 */ 179 */
177 int (*erase) (struct mtd_info *mtd, struct erase_info *instr); 180 int (*_erase) (struct mtd_info *mtd, struct erase_info *instr);
178 int (*point) (struct mtd_info *mtd, loff_t from, size_t len, 181 int (*_point) (struct mtd_info *mtd, loff_t from, size_t len,
179 size_t *retlen, void **virt, resource_size_t *phys); 182 size_t *retlen, void **virt, resource_size_t *phys);
180 void (*unpoint) (struct mtd_info *mtd, loff_t from, size_t len); 183 int (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
181 unsigned long (*get_unmapped_area) (struct mtd_info *mtd, 184 unsigned long (*_get_unmapped_area) (struct mtd_info *mtd,
182 unsigned long len, 185 unsigned long len,
183 unsigned long offset, 186 unsigned long offset,
184 unsigned long flags); 187 unsigned long flags);
185 int (*read) (struct mtd_info *mtd, loff_t from, size_t len, 188 int (*_read) (struct mtd_info *mtd, loff_t from, size_t len,
186 size_t *retlen, u_char *buf); 189 size_t *retlen, u_char *buf);
187 int (*write) (struct mtd_info *mtd, loff_t to, size_t len, 190 int (*_write) (struct mtd_info *mtd, loff_t to, size_t len,
188 size_t *retlen, const u_char *buf); 191 size_t *retlen, const u_char *buf);
189 int (*panic_write) (struct mtd_info *mtd, loff_t to, size_t len, 192 int (*_panic_write) (struct mtd_info *mtd, loff_t to, size_t len,
190 size_t *retlen, const u_char *buf); 193 size_t *retlen, const u_char *buf);
191 int (*read_oob) (struct mtd_info *mtd, loff_t from, 194 int (*_read_oob) (struct mtd_info *mtd, loff_t from,
192 struct mtd_oob_ops *ops);
193 int (*write_oob) (struct mtd_info *mtd, loff_t to,
194 struct mtd_oob_ops *ops); 195 struct mtd_oob_ops *ops);
195 int (*get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf, 196 int (*_write_oob) (struct mtd_info *mtd, loff_t to,
196 size_t len); 197 struct mtd_oob_ops *ops);
197 int (*read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, 198 int (*_get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf,
198 size_t len, size_t *retlen, u_char *buf); 199 size_t len);
199 int (*get_user_prot_info) (struct mtd_info *mtd, struct otp_info *buf, 200 int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from,
200 size_t len); 201 size_t len, size_t *retlen, u_char *buf);
201 int (*read_user_prot_reg) (struct mtd_info *mtd, loff_t from, 202 int (*_get_user_prot_info) (struct mtd_info *mtd, struct otp_info *buf,
202 size_t len, size_t *retlen, u_char *buf); 203 size_t len);
203 int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t to, size_t len, 204 int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from,
204 size_t *retlen, u_char *buf); 205 size_t len, size_t *retlen, u_char *buf);
205 int (*lock_user_prot_reg) (struct mtd_info *mtd, loff_t from, 206 int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to,
206 size_t len); 207 size_t len, size_t *retlen, u_char *buf);
207 int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, 208 int (*_lock_user_prot_reg) (struct mtd_info *mtd, loff_t from,
209 size_t len);
210 int (*_writev) (struct mtd_info *mtd, const struct kvec *vecs,
208 unsigned long count, loff_t to, size_t *retlen); 211 unsigned long count, loff_t to, size_t *retlen);
209 void (*sync) (struct mtd_info *mtd); 212 void (*_sync) (struct mtd_info *mtd);
210 int (*lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len); 213 int (*_lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
211 int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len); 214 int (*_unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
212 int (*is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len); 215 int (*_is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
213 int (*block_isbad) (struct mtd_info *mtd, loff_t ofs); 216 int (*_block_isbad) (struct mtd_info *mtd, loff_t ofs);
214 int (*block_markbad) (struct mtd_info *mtd, loff_t ofs); 217 int (*_block_markbad) (struct mtd_info *mtd, loff_t ofs);
215 int (*suspend) (struct mtd_info *mtd); 218 int (*_suspend) (struct mtd_info *mtd);
216 void (*resume) (struct mtd_info *mtd); 219 void (*_resume) (struct mtd_info *mtd);
217 /* 220 /*
218 * If the driver is something smart, like UBI, it may need to maintain 221 * If the driver is something smart, like UBI, it may need to maintain
219 * its own reference counting. The below functions are only for driver. 222 * its own reference counting. The below functions are only for driver.
220 */ 223 */
221 int (*get_device) (struct mtd_info *mtd); 224 int (*_get_device) (struct mtd_info *mtd);
222 void (*put_device) (struct mtd_info *mtd); 225 void (*_put_device) (struct mtd_info *mtd);
223 226
224 /* Backing device capabilities for this device 227 /* Backing device capabilities for this device
225 * - provides mmap capabilities 228 * - provides mmap capabilities
@@ -240,214 +243,75 @@ struct mtd_info {
240 int usecount; 243 int usecount;
241}; 244};
242 245
243/* 246int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
244 * Erase is an asynchronous operation. Device drivers are supposed 247int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
245 * to call instr->callback() whenever the operation completes, even 248 void **virt, resource_size_t *phys);
246 * if it completes with a failure. 249int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
247 * Callers are supposed to pass a callback function and wait for it 250unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
248 * to be called before writing to the block. 251 unsigned long offset, unsigned long flags);
249 */ 252int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
250static inline int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) 253 u_char *buf);
251{ 254int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
252 return mtd->erase(mtd, instr); 255 const u_char *buf);
253} 256int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
254 257 const u_char *buf);
255/*
256 * This stuff for eXecute-In-Place. phys is optional and may be set to NULL.
257 */
258static inline int mtd_point(struct mtd_info *mtd, loff_t from, size_t len,
259 size_t *retlen, void **virt, resource_size_t *phys)
260{
261 *retlen = 0;
262 if (!mtd->point)
263 return -EOPNOTSUPP;
264 return mtd->point(mtd, from, len, retlen, virt, phys);
265}
266
267/* We probably shouldn't allow XIP if the unpoint isn't a NULL */
268static inline void mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
269{
270 return mtd->unpoint(mtd, from, len);
271}
272
273/*
274 * Allow NOMMU mmap() to directly map the device (if not NULL)
275 * - return the address to which the offset maps
276 * - return -ENOSYS to indicate refusal to do the mapping
277 */
278static inline unsigned long mtd_get_unmapped_area(struct mtd_info *mtd,
279 unsigned long len,
280 unsigned long offset,
281 unsigned long flags)
282{
283 if (!mtd->get_unmapped_area)
284 return -EOPNOTSUPP;
285 return mtd->get_unmapped_area(mtd, len, offset, flags);
286}
287
288static inline int mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
289 size_t *retlen, u_char *buf)
290{
291 return mtd->read(mtd, from, len, retlen, buf);
292}
293
294static inline int mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
295 size_t *retlen, const u_char *buf)
296{
297 *retlen = 0;
298 if (!mtd->write)
299 return -EROFS;
300 return mtd->write(mtd, to, len, retlen, buf);
301}
302
303/*
304 * In blackbox flight recorder like scenarios we want to make successful writes
305 * in interrupt context. panic_write() is only intended to be called when its
306 * known the kernel is about to panic and we need the write to succeed. Since
307 * the kernel is not going to be running for much longer, this function can
308 * break locks and delay to ensure the write succeeds (but not sleep).
309 */
310static inline int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
311 size_t *retlen, const u_char *buf)
312{
313 *retlen = 0;
314 if (!mtd->panic_write)
315 return -EOPNOTSUPP;
316 return mtd->panic_write(mtd, to, len, retlen, buf);
317}
318 258
319static inline int mtd_read_oob(struct mtd_info *mtd, loff_t from, 259static inline int mtd_read_oob(struct mtd_info *mtd, loff_t from,
320 struct mtd_oob_ops *ops) 260 struct mtd_oob_ops *ops)
321{ 261{
322 ops->retlen = ops->oobretlen = 0; 262 ops->retlen = ops->oobretlen = 0;
323 if (!mtd->read_oob) 263 if (!mtd->_read_oob)
324 return -EOPNOTSUPP; 264 return -EOPNOTSUPP;
325 return mtd->read_oob(mtd, from, ops); 265 return mtd->_read_oob(mtd, from, ops);
326} 266}
327 267
328static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to, 268static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to,
329 struct mtd_oob_ops *ops) 269 struct mtd_oob_ops *ops)
330{ 270{
331 ops->retlen = ops->oobretlen = 0; 271 ops->retlen = ops->oobretlen = 0;
332 if (!mtd->write_oob) 272 if (!mtd->_write_oob)
333 return -EOPNOTSUPP;
334 return mtd->write_oob(mtd, to, ops);
335}
336
337/*
338 * Method to access the protection register area, present in some flash
339 * devices. The user data is one time programmable but the factory data is read
340 * only.
341 */
342static inline int mtd_get_fact_prot_info(struct mtd_info *mtd,
343 struct otp_info *buf, size_t len)
344{
345 if (!mtd->get_fact_prot_info)
346 return -EOPNOTSUPP; 273 return -EOPNOTSUPP;
347 return mtd->get_fact_prot_info(mtd, buf, len); 274 if (!(mtd->flags & MTD_WRITEABLE))
348} 275 return -EROFS;
349 276 return mtd->_write_oob(mtd, to, ops);
350static inline int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from,
351 size_t len, size_t *retlen,
352 u_char *buf)
353{
354 *retlen = 0;
355 if (!mtd->read_fact_prot_reg)
356 return -EOPNOTSUPP;
357 return mtd->read_fact_prot_reg(mtd, from, len, retlen, buf);
358}
359
360static inline int mtd_get_user_prot_info(struct mtd_info *mtd,
361 struct otp_info *buf,
362 size_t len)
363{
364 if (!mtd->get_user_prot_info)
365 return -EOPNOTSUPP;
366 return mtd->get_user_prot_info(mtd, buf, len);
367}
368
369static inline int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from,
370 size_t len, size_t *retlen,
371 u_char *buf)
372{
373 *retlen = 0;
374 if (!mtd->read_user_prot_reg)
375 return -EOPNOTSUPP;
376 return mtd->read_user_prot_reg(mtd, from, len, retlen, buf);
377}
378
379static inline int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to,
380 size_t len, size_t *retlen,
381 u_char *buf)
382{
383 *retlen = 0;
384 if (!mtd->write_user_prot_reg)
385 return -EOPNOTSUPP;
386 return mtd->write_user_prot_reg(mtd, to, len, retlen, buf);
387} 277}
388 278
389static inline int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, 279int mtd_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf,
390 size_t len) 280 size_t len);
391{ 281int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
392 if (!mtd->lock_user_prot_reg) 282 size_t *retlen, u_char *buf);
393 return -EOPNOTSUPP; 283int mtd_get_user_prot_info(struct mtd_info *mtd, struct otp_info *buf,
394 return mtd->lock_user_prot_reg(mtd, from, len); 284 size_t len);
395} 285int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
286 size_t *retlen, u_char *buf);
287int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
288 size_t *retlen, u_char *buf);
289int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len);
396 290
397int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, 291int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
398 unsigned long count, loff_t to, size_t *retlen); 292 unsigned long count, loff_t to, size_t *retlen);
399 293
400static inline void mtd_sync(struct mtd_info *mtd) 294static inline void mtd_sync(struct mtd_info *mtd)
401{ 295{
402 if (mtd->sync) 296 if (mtd->_sync)
403 mtd->sync(mtd); 297 mtd->_sync(mtd);
404}
405
406/* Chip-supported device locking */
407static inline int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
408{
409 if (!mtd->lock)
410 return -EOPNOTSUPP;
411 return mtd->lock(mtd, ofs, len);
412} 298}
413 299
414static inline int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) 300int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
415{ 301int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
416 if (!mtd->unlock) 302int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
417 return -EOPNOTSUPP; 303int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
418 return mtd->unlock(mtd, ofs, len); 304int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
419}
420
421static inline int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
422{
423 if (!mtd->is_locked)
424 return -EOPNOTSUPP;
425 return mtd->is_locked(mtd, ofs, len);
426}
427 305
428static inline int mtd_suspend(struct mtd_info *mtd) 306static inline int mtd_suspend(struct mtd_info *mtd)
429{ 307{
430 return mtd->suspend ? mtd->suspend(mtd) : 0; 308 return mtd->_suspend ? mtd->_suspend(mtd) : 0;
431} 309}
432 310
433static inline void mtd_resume(struct mtd_info *mtd) 311static inline void mtd_resume(struct mtd_info *mtd)
434{ 312{
435 if (mtd->resume) 313 if (mtd->_resume)
436 mtd->resume(mtd); 314 mtd->_resume(mtd);
437}
438
439static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
440{
441 if (!mtd->block_isbad)
442 return 0;
443 return mtd->block_isbad(mtd, ofs);
444}
445
446static inline int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)
447{
448 if (!mtd->block_markbad)
449 return -EOPNOTSUPP;
450 return mtd->block_markbad(mtd, ofs);
451} 315}
452 316
453static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) 317static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)
@@ -482,12 +346,12 @@ static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd)
482 346
483static inline int mtd_has_oob(const struct mtd_info *mtd) 347static inline int mtd_has_oob(const struct mtd_info *mtd)
484{ 348{
485 return mtd->read_oob && mtd->write_oob; 349 return mtd->_read_oob && mtd->_write_oob;
486} 350}
487 351
488static inline int mtd_can_have_bb(const struct mtd_info *mtd) 352static inline int mtd_can_have_bb(const struct mtd_info *mtd)
489{ 353{
490 return !!mtd->block_isbad; 354 return !!mtd->_block_isbad;
491} 355}
492 356
493 /* Kernel-side ioctl definitions */ 357 /* Kernel-side ioctl definitions */
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 63b5a8b6dfbd..1482340d3d9f 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -324,6 +324,7 @@ struct nand_hw_control {
324 * @steps: number of ECC steps per page 324 * @steps: number of ECC steps per page
325 * @size: data bytes per ECC step 325 * @size: data bytes per ECC step
326 * @bytes: ECC bytes per step 326 * @bytes: ECC bytes per step
327 * @strength: max number of correctible bits per ECC step
327 * @total: total number of ECC bytes per page 328 * @total: total number of ECC bytes per page
328 * @prepad: padding information for syndrome based ECC generators 329 * @prepad: padding information for syndrome based ECC generators
329 * @postpad: padding information for syndrome based ECC generators 330 * @postpad: padding information for syndrome based ECC generators
@@ -351,6 +352,7 @@ struct nand_ecc_ctrl {
351 int size; 352 int size;
352 int bytes; 353 int bytes;
353 int total; 354 int total;
355 int strength;
354 int prepad; 356 int prepad;
355 int postpad; 357 int postpad;
356 struct nand_ecclayout *layout; 358 struct nand_ecclayout *layout;
@@ -448,8 +450,9 @@ struct nand_buffers {
448 * will be copied to the appropriate nand_bbt_descr's. 450 * will be copied to the appropriate nand_bbt_descr's.
449 * @badblockpos: [INTERN] position of the bad block marker in the oob 451 * @badblockpos: [INTERN] position of the bad block marker in the oob
450 * area. 452 * area.
451 * @badblockbits: [INTERN] number of bits to left-shift the bad block 453 * @badblockbits: [INTERN] minimum number of set bits in a good block's
452 * number 454 * bad block marker position; i.e., BBM == 11110111b is
455 * not bad when badblockbits == 7
453 * @cellinfo: [INTERN] MLC/multichip data from chip ident 456 * @cellinfo: [INTERN] MLC/multichip data from chip ident
454 * @numchips: [INTERN] number of physical chips 457 * @numchips: [INTERN] number of physical chips
455 * @chipsize: [INTERN] the size of one chip for multichip arrays 458 * @chipsize: [INTERN] the size of one chip for multichip arrays
diff --git a/include/linux/mtd/pmc551.h b/include/linux/mtd/pmc551.h
deleted file mode 100644
index 27ad40aed19f..000000000000
--- a/include/linux/mtd/pmc551.h
+++ /dev/null
@@ -1,78 +0,0 @@
1/*
2 * PMC551 PCI Mezzanine Ram Device
3 *
4 * Author:
5 * Mark Ferrell
6 * Copyright 1999,2000 Nortel Networks
7 *
8 * License:
9 * As part of this driver was derrived from the slram.c driver it falls
10 * under the same license, which is GNU General Public License v2
11 */
12
13#ifndef __MTD_PMC551_H__
14#define __MTD_PMC551_H__
15
16#include <linux/mtd/mtd.h>
17
18#define PMC551_VERSION \
19 "Ramix PMC551 PCI Mezzanine Ram Driver. (C) 1999,2000 Nortel Networks.\n"
20
21/*
22 * Our personal and private information
23 */
24struct mypriv {
25 struct pci_dev *dev;
26 u_char *start;
27 u32 base_map0;
28 u32 curr_map0;
29 u32 asize;
30 struct mtd_info *nextpmc551;
31};
32
33/*
34 * Function Prototypes
35 */
36static int pmc551_erase(struct mtd_info *, struct erase_info *);
37static void pmc551_unpoint(struct mtd_info *, loff_t, size_t);
38static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
39 size_t *retlen, void **virt, resource_size_t *phys);
40static int pmc551_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *);
41static int pmc551_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
42
43
44/*
45 * Define the PCI ID's if the kernel doesn't define them for us
46 */
47#ifndef PCI_VENDOR_ID_V3_SEMI
48#define PCI_VENDOR_ID_V3_SEMI 0x11b0
49#endif
50
51#ifndef PCI_DEVICE_ID_V3_SEMI_V370PDC
52#define PCI_DEVICE_ID_V3_SEMI_V370PDC 0x0200
53#endif
54
55
56#define PMC551_PCI_MEM_MAP0 0x50
57#define PMC551_PCI_MEM_MAP1 0x54
58#define PMC551_PCI_MEM_MAP_MAP_ADDR_MASK 0x3ff00000
59#define PMC551_PCI_MEM_MAP_APERTURE_MASK 0x000000f0
60#define PMC551_PCI_MEM_MAP_REG_EN 0x00000002
61#define PMC551_PCI_MEM_MAP_ENABLE 0x00000001
62
63#define PMC551_SDRAM_MA 0x60
64#define PMC551_SDRAM_CMD 0x62
65#define PMC551_DRAM_CFG 0x64
66#define PMC551_SYS_CTRL_REG 0x78
67
68#define PMC551_DRAM_BLK0 0x68
69#define PMC551_DRAM_BLK1 0x6c
70#define PMC551_DRAM_BLK2 0x70
71#define PMC551_DRAM_BLK3 0x74
72#define PMC551_DRAM_BLK_GET_SIZE(x) (524288<<((x>>4)&0x0f))
73#define PMC551_DRAM_BLK_SET_COL_MUX(x,v) (((x) & ~0x00007000) | (((v) & 0x7) << 12))
74#define PMC551_DRAM_BLK_SET_ROW_MUX(x,v) (((x) & ~0x00000f00) | (((v) & 0xf) << 8))
75
76
77#endif /* __MTD_PMC551_H__ */
78
diff --git a/include/linux/mtd/sh_flctl.h b/include/linux/mtd/sh_flctl.h
index 9cf4c4c79555..a38e1fa8af01 100644
--- a/include/linux/mtd/sh_flctl.h
+++ b/include/linux/mtd/sh_flctl.h
@@ -23,6 +23,7 @@
23#include <linux/mtd/mtd.h> 23#include <linux/mtd/mtd.h>
24#include <linux/mtd/nand.h> 24#include <linux/mtd/nand.h>
25#include <linux/mtd/partitions.h> 25#include <linux/mtd/partitions.h>
26#include <linux/pm_qos.h>
26 27
27/* FLCTL registers */ 28/* FLCTL registers */
28#define FLCMNCR(f) (f->reg + 0x0) 29#define FLCMNCR(f) (f->reg + 0x0)
@@ -38,6 +39,7 @@
38#define FLDTFIFO(f) (f->reg + 0x24) 39#define FLDTFIFO(f) (f->reg + 0x24)
39#define FLECFIFO(f) (f->reg + 0x28) 40#define FLECFIFO(f) (f->reg + 0x28)
40#define FLTRCR(f) (f->reg + 0x2C) 41#define FLTRCR(f) (f->reg + 0x2C)
42#define FLHOLDCR(f) (f->reg + 0x38)
41#define FL4ECCRESULT0(f) (f->reg + 0x80) 43#define FL4ECCRESULT0(f) (f->reg + 0x80)
42#define FL4ECCRESULT1(f) (f->reg + 0x84) 44#define FL4ECCRESULT1(f) (f->reg + 0x84)
43#define FL4ECCRESULT2(f) (f->reg + 0x88) 45#define FL4ECCRESULT2(f) (f->reg + 0x88)
@@ -67,6 +69,30 @@
67#define CE0_ENABLE (0x1 << 3) /* Chip Enable 0 */ 69#define CE0_ENABLE (0x1 << 3) /* Chip Enable 0 */
68#define TYPESEL_SET (0x1 << 0) 70#define TYPESEL_SET (0x1 << 0)
69 71
72/*
73 * Clock settings using the PULSEx registers from FLCMNCR
74 *
75 * Some hardware uses bits called PULSEx instead of FCKSEL_E and QTSEL_E
76 * to control the clock divider used between the High-Speed Peripheral Clock
77 * and the FLCTL internal clock. If so, use CLK_8_BIT_xxx for connecting 8 bit
78 * and CLK_16_BIT_xxx for connecting 16 bit bus bandwith NAND chips. For the 16
79 * bit version the divider is seperate for the pulse width of high and low
80 * signals.
81 */
82#define PULSE3 (0x1 << 27)
83#define PULSE2 (0x1 << 17)
84#define PULSE1 (0x1 << 15)
85#define PULSE0 (0x1 << 9)
86#define CLK_8B_0_5 PULSE1
87#define CLK_8B_1 0x0
88#define CLK_8B_1_5 (PULSE1 | PULSE2)
89#define CLK_8B_2 PULSE0
90#define CLK_8B_3 (PULSE0 | PULSE1 | PULSE2)
91#define CLK_8B_4 (PULSE0 | PULSE2)
92#define CLK_16B_6L_2H PULSE0
93#define CLK_16B_9L_3H (PULSE0 | PULSE1 | PULSE2)
94#define CLK_16B_12L_4H (PULSE0 | PULSE2)
95
70/* FLCMDCR control bits */ 96/* FLCMDCR control bits */
71#define ADRCNT2_E (0x1 << 31) /* 5byte address enable */ 97#define ADRCNT2_E (0x1 << 31) /* 5byte address enable */
72#define ADRMD_E (0x1 << 26) /* Sector address access */ 98#define ADRMD_E (0x1 << 26) /* Sector address access */
@@ -85,6 +111,15 @@
85#define TRSTRT (0x1 << 0) /* translation start */ 111#define TRSTRT (0x1 << 0) /* translation start */
86#define TREND (0x1 << 1) /* translation end */ 112#define TREND (0x1 << 1) /* translation end */
87 113
114/*
115 * FLHOLDCR control bits
116 *
117 * HOLDEN: Bus Occupancy Enable (inverted)
118 * Enable this bit when the external bus might be used in between transfers.
119 * If not set and the bus gets used by other modules, a deadlock occurs.
120 */
121#define HOLDEN (0x1 << 0)
122
88/* FL4ECCCR control bits */ 123/* FL4ECCCR control bits */
89#define _4ECCFA (0x1 << 2) /* 4 symbols correct fault */ 124#define _4ECCFA (0x1 << 2) /* 4 symbols correct fault */
90#define _4ECCEND (0x1 << 1) /* 4 symbols end */ 125#define _4ECCEND (0x1 << 1) /* 4 symbols end */
@@ -97,6 +132,7 @@ struct sh_flctl {
97 struct mtd_info mtd; 132 struct mtd_info mtd;
98 struct nand_chip chip; 133 struct nand_chip chip;
99 struct platform_device *pdev; 134 struct platform_device *pdev;
135 struct dev_pm_qos_request pm_qos;
100 void __iomem *reg; 136 void __iomem *reg;
101 137
102 uint8_t done_buff[2048 + 64]; /* max size 2048 + 64 */ 138 uint8_t done_buff[2048 + 64]; /* max size 2048 + 64 */
@@ -108,11 +144,14 @@ struct sh_flctl {
108 int erase1_page_addr; /* page_addr in ERASE1 cmd */ 144 int erase1_page_addr; /* page_addr in ERASE1 cmd */
109 uint32_t erase_ADRCNT; /* bits of FLCMDCR in ERASE1 cmd */ 145 uint32_t erase_ADRCNT; /* bits of FLCMDCR in ERASE1 cmd */
110 uint32_t rw_ADRCNT; /* bits of FLCMDCR in READ WRITE cmd */ 146 uint32_t rw_ADRCNT; /* bits of FLCMDCR in READ WRITE cmd */
147 uint32_t flcmncr_base; /* base value of FLCMNCR */
111 148
112 int hwecc_cant_correct[4]; 149 int hwecc_cant_correct[4];
113 150
114 unsigned page_size:1; /* NAND page size (0 = 512, 1 = 2048) */ 151 unsigned page_size:1; /* NAND page size (0 = 512, 1 = 2048) */
115 unsigned hwecc:1; /* Hardware ECC (0 = disabled, 1 = enabled) */ 152 unsigned hwecc:1; /* Hardware ECC (0 = disabled, 1 = enabled) */
153 unsigned holden:1; /* Hardware has FLHOLDCR and HOLDEN is set */
154 unsigned qos_request:1; /* QoS request to prevent deep power shutdown */
116}; 155};
117 156
118struct sh_flctl_platform_data { 157struct sh_flctl_platform_data {
@@ -121,6 +160,7 @@ struct sh_flctl_platform_data {
121 unsigned long flcmncr_val; 160 unsigned long flcmncr_val;
122 161
123 unsigned has_hwecc:1; 162 unsigned has_hwecc:1;
163 unsigned use_holden:1;
124}; 164};
125 165
126static inline struct sh_flctl *mtd_to_flctl(struct mtd_info *mtdinfo) 166static inline struct sh_flctl *mtd_to_flctl(struct mtd_info *mtdinfo)
diff --git a/include/linux/mtd/spear_smi.h b/include/linux/mtd/spear_smi.h
new file mode 100644
index 000000000000..8ae1726044c3
--- /dev/null
+++ b/include/linux/mtd/spear_smi.h
@@ -0,0 +1,65 @@
1/*
2 * Copyright © 2010 ST Microelectronics
3 * Shiraz Hashim <shiraz.hashim@st.com>
4 *
5 * This file is licensed under the terms of the GNU General Public
6 * License version 2. This program is licensed "as is" without any
7 * warranty of any kind, whether express or implied.
8 */
9
10#ifndef __MTD_SPEAR_SMI_H
11#define __MTD_SPEAR_SMI_H
12
13#include <linux/types.h>
14#include <linux/mtd/mtd.h>
15#include <linux/mtd/partitions.h>
16#include <linux/platform_device.h>
17#include <linux/of.h>
18
19/* max possible slots for serial-nor flash chip in the SMI controller */
20#define MAX_NUM_FLASH_CHIP 4
21
22/* macro to define partitions for flash devices */
23#define DEFINE_PARTS(n, of, s) \
24{ \
25 .name = n, \
26 .offset = of, \
27 .size = s, \
28}
29
30/**
31 * struct spear_smi_flash_info - platform structure for passing flash
32 * information
33 *
34 * name: name of the serial nor flash for identification
35 * mem_base: the memory base on which the flash is mapped
36 * size: size of the flash in bytes
37 * partitions: parition details
38 * nr_partitions: number of partitions
39 * fast_mode: whether flash supports fast mode
40 */
41
42struct spear_smi_flash_info {
43 char *name;
44 unsigned long mem_base;
45 unsigned long size;
46 struct mtd_partition *partitions;
47 int nr_partitions;
48 u8 fast_mode;
49};
50
51/**
52 * struct spear_smi_plat_data - platform structure for configuring smi
53 *
54 * clk_rate: clk rate at which SMI must operate
55 * num_flashes: number of flashes present on board
56 * board_flash_info: specific details of each flash present on board
57 */
58struct spear_smi_plat_data {
59 unsigned long clk_rate;
60 int num_flashes;
61 struct spear_smi_flash_info *board_flash_info;
62 struct device_node *np[MAX_NUM_FLASH_CHIP];
63};
64
65#endif /* __MTD_SPEAR_SMI_H */
diff --git a/include/linux/mtio.h b/include/linux/mtio.h
index 8f825756c459..18543e2db06f 100644
--- a/include/linux/mtio.h
+++ b/include/linux/mtio.h
@@ -194,6 +194,7 @@ struct mtpos {
194#define MT_ST_SYSV 0x1000 194#define MT_ST_SYSV 0x1000
195#define MT_ST_NOWAIT 0x2000 195#define MT_ST_NOWAIT 0x2000
196#define MT_ST_SILI 0x4000 196#define MT_ST_SILI 0x4000
197#define MT_ST_NOWAIT_EOF 0x8000
197 198
198/* The mode parameters to be controlled. Parameter chosen with bits 20-28 */ 199/* The mode parameters to be controlled. Parameter chosen with bits 20-28 */
199#define MT_ST_CLEAR_DEFAULT 0xfffff 200#define MT_ST_CLEAR_DEFAULT 0xfffff
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
index 834df8bf08b6..0987146b0637 100644
--- a/include/linux/nfs4.h
+++ b/include/linux/nfs4.h
@@ -438,7 +438,20 @@ enum limit_by4 {
438enum open_delegation_type4 { 438enum open_delegation_type4 {
439 NFS4_OPEN_DELEGATE_NONE = 0, 439 NFS4_OPEN_DELEGATE_NONE = 0,
440 NFS4_OPEN_DELEGATE_READ = 1, 440 NFS4_OPEN_DELEGATE_READ = 1,
441 NFS4_OPEN_DELEGATE_WRITE = 2 441 NFS4_OPEN_DELEGATE_WRITE = 2,
442 NFS4_OPEN_DELEGATE_NONE_EXT = 3, /* 4.1 */
443};
444
445enum why_no_delegation4 { /* new to v4.1 */
446 WND4_NOT_WANTED = 0,
447 WND4_CONTENTION = 1,
448 WND4_RESOURCE = 2,
449 WND4_NOT_SUPP_FTYPE = 3,
450 WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4,
451 WND4_NOT_SUPP_UPGRADE = 5,
452 WND4_NOT_SUPP_DOWNGRADE = 6,
453 WND4_CANCELLED = 7,
454 WND4_IS_DIR = 8,
442}; 455};
443 456
444enum lock_type4 { 457enum lock_type4 {
diff --git a/include/linux/nfsd/cld.h b/include/linux/nfsd/cld.h
new file mode 100644
index 000000000000..f14a9ab06f1f
--- /dev/null
+++ b/include/linux/nfsd/cld.h
@@ -0,0 +1,56 @@
1/*
2 * Upcall description for nfsdcld communication
3 *
4 * Copyright (c) 2012 Red Hat, Inc.
5 * Author(s): Jeff Layton <jlayton@redhat.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#ifndef _NFSD_CLD_H
23#define _NFSD_CLD_H
24
25/* latest upcall version available */
26#define CLD_UPCALL_VERSION 1
27
28/* defined by RFC3530 */
29#define NFS4_OPAQUE_LIMIT 1024
30
31enum cld_command {
32 Cld_Create, /* create a record for this cm_id */
33 Cld_Remove, /* remove record of this cm_id */
34 Cld_Check, /* is this cm_id allowed? */
35 Cld_GraceDone, /* grace period is complete */
36};
37
38/* representation of long-form NFSv4 client ID */
39struct cld_name {
40 uint16_t cn_len; /* length of cm_id */
41 unsigned char cn_id[NFS4_OPAQUE_LIMIT]; /* client-provided */
42} __attribute__((packed));
43
44/* message struct for communication with userspace */
45struct cld_msg {
46 uint8_t cm_vers; /* upcall version */
47 uint8_t cm_cmd; /* upcall command */
48 int16_t cm_status; /* return code */
49 uint32_t cm_xid; /* transaction id */
50 union {
51 int64_t cm_gracetime; /* grace period start time */
52 struct cld_name cm_name;
53 } __attribute__((packed)) cm_u;
54} __attribute__((packed));
55
56#endif /* !_NFSD_CLD_H */
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index bd9f55a5958d..ddbb6a901f65 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -299,18 +299,31 @@ struct perf_event_mmap_page {
299 /* 299 /*
300 * Bits needed to read the hw events in user-space. 300 * Bits needed to read the hw events in user-space.
301 * 301 *
302 * u32 seq; 302 * u32 seq, time_mult, time_shift, idx, width;
303 * s64 count; 303 * u64 count, enabled, running;
304 * u64 cyc, time_offset;
305 * s64 pmc = 0;
304 * 306 *
305 * do { 307 * do {
306 * seq = pc->lock; 308 * seq = pc->lock;
307 *
308 * barrier() 309 * barrier()
309 * if (pc->index) { 310 *
310 * count = pmc_read(pc->index - 1); 311 * enabled = pc->time_enabled;
311 * count += pc->offset; 312 * running = pc->time_running;
312 * } else 313 *
313 * goto regular_read; 314 * if (pc->cap_usr_time && enabled != running) {
315 * cyc = rdtsc();
316 * time_offset = pc->time_offset;
317 * time_mult = pc->time_mult;
318 * time_shift = pc->time_shift;
319 * }
320 *
321 * idx = pc->index;
322 * count = pc->offset;
323 * if (pc->cap_usr_rdpmc && idx) {
324 * width = pc->pmc_width;
325 * pmc = rdpmc(idx - 1);
326 * }
314 * 327 *
315 * barrier(); 328 * barrier();
316 * } while (pc->lock != seq); 329 * } while (pc->lock != seq);
@@ -323,14 +336,57 @@ struct perf_event_mmap_page {
323 __s64 offset; /* add to hardware event value */ 336 __s64 offset; /* add to hardware event value */
324 __u64 time_enabled; /* time event active */ 337 __u64 time_enabled; /* time event active */
325 __u64 time_running; /* time event on cpu */ 338 __u64 time_running; /* time event on cpu */
326 __u32 time_mult, time_shift; 339 union {
340 __u64 capabilities;
341 __u64 cap_usr_time : 1,
342 cap_usr_rdpmc : 1,
343 cap_____res : 62;
344 };
345
346 /*
347 * If cap_usr_rdpmc this field provides the bit-width of the value
348 * read using the rdpmc() or equivalent instruction. This can be used
349 * to sign extend the result like:
350 *
351 * pmc <<= 64 - width;
352 * pmc >>= 64 - width; // signed shift right
353 * count += pmc;
354 */
355 __u16 pmc_width;
356
357 /*
358 * If cap_usr_time the below fields can be used to compute the time
359 * delta since time_enabled (in ns) using rdtsc or similar.
360 *
361 * u64 quot, rem;
362 * u64 delta;
363 *
364 * quot = (cyc >> time_shift);
365 * rem = cyc & ((1 << time_shift) - 1);
366 * delta = time_offset + quot * time_mult +
367 * ((rem * time_mult) >> time_shift);
368 *
369 * Where time_offset,time_mult,time_shift and cyc are read in the
370 * seqcount loop described above. This delta can then be added to
371 * enabled and possible running (if idx), improving the scaling:
372 *
373 * enabled += delta;
374 * if (idx)
375 * running += delta;
376 *
377 * quot = count / running;
378 * rem = count % running;
379 * count = quot * enabled + (rem * enabled) / running;
380 */
381 __u16 time_shift;
382 __u32 time_mult;
327 __u64 time_offset; 383 __u64 time_offset;
328 384
329 /* 385 /*
330 * Hole for extension of the self monitor capabilities 386 * Hole for extension of the self monitor capabilities
331 */ 387 */
332 388
333 __u64 __reserved[121]; /* align to 1k */ 389 __u64 __reserved[120]; /* align to 1k */
334 390
335 /* 391 /*
336 * Control data for the mmap() data buffer. 392 * Control data for the mmap() data buffer.
@@ -550,6 +606,7 @@ struct perf_guest_info_callbacks {
550#include <linux/irq_work.h> 606#include <linux/irq_work.h>
551#include <linux/static_key.h> 607#include <linux/static_key.h>
552#include <linux/atomic.h> 608#include <linux/atomic.h>
609#include <linux/sysfs.h>
553#include <asm/local.h> 610#include <asm/local.h>
554 611
555#define PERF_MAX_STACK_DEPTH 255 612#define PERF_MAX_STACK_DEPTH 255
@@ -1291,5 +1348,18 @@ do { \
1291 register_cpu_notifier(&fn##_nb); \ 1348 register_cpu_notifier(&fn##_nb); \
1292} while (0) 1349} while (0)
1293 1350
1351
1352#define PMU_FORMAT_ATTR(_name, _format) \
1353static ssize_t \
1354_name##_show(struct device *dev, \
1355 struct device_attribute *attr, \
1356 char *page) \
1357{ \
1358 BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \
1359 return sprintf(page, _format "\n"); \
1360} \
1361 \
1362static struct device_attribute format_attr_##_name = __ATTR_RO(_name)
1363
1294#endif /* __KERNEL__ */ 1364#endif /* __KERNEL__ */
1295#endif /* _LINUX_PERF_EVENT_H */ 1365#endif /* _LINUX_PERF_EVENT_H */
diff --git a/include/linux/platform_data/spear_thermal.h b/include/linux/platform_data/spear_thermal.h
new file mode 100644
index 000000000000..724f2e1cbbcb
--- /dev/null
+++ b/include/linux/platform_data/spear_thermal.h
@@ -0,0 +1,26 @@
1/*
2 * SPEAr thermal driver platform data.
3 *
4 * Copyright (C) 2011-2012 ST Microelectronics
5 * Author: Vincenzo Frascino <vincenzo.frascino@st.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17#ifndef SPEAR_THERMAL_H
18#define SPEAR_THERMAL_H
19
20/* SPEAr Thermal Sensor Platform Data */
21struct spear_thermal_pdata {
22 /* flags used to enable thermal sensor */
23 unsigned int thermal_flags;
24};
25
26#endif /* SPEAR_THERMAL_H */
diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
index fe99211fb2b8..e01b167e66f0 100644
--- a/include/linux/power/max17042_battery.h
+++ b/include/linux/power/max17042_battery.h
@@ -27,6 +27,8 @@
27#define MAX17042_BATTERY_FULL (100) 27#define MAX17042_BATTERY_FULL (100)
28#define MAX17042_DEFAULT_SNS_RESISTOR (10000) 28#define MAX17042_DEFAULT_SNS_RESISTOR (10000)
29 29
30#define MAX17042_CHARACTERIZATION_DATA_SIZE 48
31
30enum max17042_register { 32enum max17042_register {
31 MAX17042_STATUS = 0x00, 33 MAX17042_STATUS = 0x00,
32 MAX17042_VALRT_Th = 0x01, 34 MAX17042_VALRT_Th = 0x01,
@@ -40,11 +42,11 @@ enum max17042_register {
40 MAX17042_VCELL = 0x09, 42 MAX17042_VCELL = 0x09,
41 MAX17042_Current = 0x0A, 43 MAX17042_Current = 0x0A,
42 MAX17042_AvgCurrent = 0x0B, 44 MAX17042_AvgCurrent = 0x0B,
43 MAX17042_Qresidual = 0x0C, 45
44 MAX17042_SOC = 0x0D, 46 MAX17042_SOC = 0x0D,
45 MAX17042_AvSOC = 0x0E, 47 MAX17042_AvSOC = 0x0E,
46 MAX17042_RemCap = 0x0F, 48 MAX17042_RemCap = 0x0F,
47 MAX17402_FullCAP = 0x10, 49 MAX17042_FullCAP = 0x10,
48 MAX17042_TTE = 0x11, 50 MAX17042_TTE = 0x11,
49 MAX17042_V_empty = 0x12, 51 MAX17042_V_empty = 0x12,
50 52
@@ -62,14 +64,14 @@ enum max17042_register {
62 MAX17042_AvCap = 0x1F, 64 MAX17042_AvCap = 0x1F,
63 MAX17042_ManName = 0x20, 65 MAX17042_ManName = 0x20,
64 MAX17042_DevName = 0x21, 66 MAX17042_DevName = 0x21,
65 MAX17042_DevChem = 0x22,
66 67
68 MAX17042_FullCAPNom = 0x23,
67 MAX17042_TempNom = 0x24, 69 MAX17042_TempNom = 0x24,
68 MAX17042_TempCold = 0x25, 70 MAX17042_TempLim = 0x25,
69 MAX17042_TempHot = 0x26, 71 MAX17042_TempHot = 0x26,
70 MAX17042_AIN = 0x27, 72 MAX17042_AIN = 0x27,
71 MAX17042_LearnCFG = 0x28, 73 MAX17042_LearnCFG = 0x28,
72 MAX17042_SHFTCFG = 0x29, 74 MAX17042_FilterCFG = 0x29,
73 MAX17042_RelaxCFG = 0x2A, 75 MAX17042_RelaxCFG = 0x2A,
74 MAX17042_MiscCFG = 0x2B, 76 MAX17042_MiscCFG = 0x2B,
75 MAX17042_TGAIN = 0x2C, 77 MAX17042_TGAIN = 0x2C,
@@ -77,22 +79,41 @@ enum max17042_register {
77 MAX17042_CGAIN = 0x2E, 79 MAX17042_CGAIN = 0x2E,
78 MAX17042_COFF = 0x2F, 80 MAX17042_COFF = 0x2F,
79 81
80 MAX17042_Q_empty = 0x33, 82 MAX17042_MaskSOC = 0x32,
83 MAX17042_SOC_empty = 0x33,
81 MAX17042_T_empty = 0x34, 84 MAX17042_T_empty = 0x34,
82 85
86 MAX17042_FullCAP0 = 0x35,
87 MAX17042_LAvg_empty = 0x36,
88 MAX17042_FCTC = 0x37,
83 MAX17042_RCOMP0 = 0x38, 89 MAX17042_RCOMP0 = 0x38,
84 MAX17042_TempCo = 0x39, 90 MAX17042_TempCo = 0x39,
85 MAX17042_Rx = 0x3A, 91 MAX17042_EmptyTempCo = 0x3A,
86 MAX17042_T_empty0 = 0x3B, 92 MAX17042_K_empty0 = 0x3B,
87 MAX17042_TaskPeriod = 0x3C, 93 MAX17042_TaskPeriod = 0x3C,
88 MAX17042_FSTAT = 0x3D, 94 MAX17042_FSTAT = 0x3D,
89 95
90 MAX17042_SHDNTIMER = 0x3F, 96 MAX17042_SHDNTIMER = 0x3F,
91 97
92 MAX17042_VFRemCap = 0x4A, 98 MAX17042_dQacc = 0x45,
99 MAX17042_dPacc = 0x46,
100
101 MAX17042_VFSOC0 = 0x48,
93 102
94 MAX17042_QH = 0x4D, 103 MAX17042_QH = 0x4D,
95 MAX17042_QL = 0x4E, 104 MAX17042_QL = 0x4E,
105
106 MAX17042_VFSOC0Enable = 0x60,
107 MAX17042_MLOCKReg1 = 0x62,
108 MAX17042_MLOCKReg2 = 0x63,
109
110 MAX17042_MODELChrTbl = 0x80,
111
112 MAX17042_OCV = 0xEE,
113
114 MAX17042_OCVInternal = 0xFB,
115
116 MAX17042_VFSOC = 0xFF,
96}; 117};
97 118
98/* 119/*
@@ -105,10 +126,64 @@ struct max17042_reg_data {
105 u16 data; 126 u16 data;
106}; 127};
107 128
129struct max17042_config_data {
130 /* External current sense resistor value in milli-ohms */
131 u32 cur_sense_val;
132
133 /* A/D measurement */
134 u16 tgain; /* 0x2C */
135 u16 toff; /* 0x2D */
136 u16 cgain; /* 0x2E */
137 u16 coff; /* 0x2F */
138
139 /* Alert / Status */
140 u16 valrt_thresh; /* 0x01 */
141 u16 talrt_thresh; /* 0x02 */
142 u16 soc_alrt_thresh; /* 0x03 */
143 u16 config; /* 0x01D */
144 u16 shdntimer; /* 0x03F */
145
146 /* App data */
147 u16 design_cap; /* 0x18 */
148 u16 ichgt_term; /* 0x1E */
149
150 /* MG3 config */
151 u16 at_rate; /* 0x04 */
152 u16 learn_cfg; /* 0x28 */
153 u16 filter_cfg; /* 0x29 */
154 u16 relax_cfg; /* 0x2A */
155 u16 misc_cfg; /* 0x2B */
156 u16 masksoc; /* 0x32 */
157
158 /* MG3 save and restore */
159 u16 fullcap; /* 0x10 */
160 u16 fullcapnom; /* 0x23 */
161 u16 socempty; /* 0x33 */
162 u16 lavg_empty; /* 0x36 */
163 u16 dqacc; /* 0x45 */
164 u16 dpacc; /* 0x46 */
165
166 /* Cell technology from power_supply.h */
167 u16 cell_technology;
168
169 /* Cell Data */
170 u16 vempty; /* 0x12 */
171 u16 temp_nom; /* 0x24 */
172 u16 temp_lim; /* 0x25 */
173 u16 fctc; /* 0x37 */
174 u16 rcomp0; /* 0x38 */
175 u16 tcompc0; /* 0x39 */
176 u16 empty_tempco; /* 0x3A */
177 u16 kempty0; /* 0x3B */
178 u16 cell_char_tbl[MAX17042_CHARACTERIZATION_DATA_SIZE];
179} __packed;
180
108struct max17042_platform_data { 181struct max17042_platform_data {
109 struct max17042_reg_data *init_data; 182 struct max17042_reg_data *init_data;
183 struct max17042_config_data *config_data;
110 int num_init_data; /* Number of enties in init_data array */ 184 int num_init_data; /* Number of enties in init_data array */
111 bool enable_current_sense; 185 bool enable_current_sense;
186 bool enable_por_init; /* Use POR init from Maxim appnote */
112 187
113 /* 188 /*
114 * R_sns in micro-ohms. 189 * R_sns in micro-ohms.
diff --git a/include/linux/power/smb347-charger.h b/include/linux/power/smb347-charger.h
new file mode 100644
index 000000000000..b3cb20dab55f
--- /dev/null
+++ b/include/linux/power/smb347-charger.h
@@ -0,0 +1,117 @@
1/*
2 * Summit Microelectronics SMB347 Battery Charger Driver
3 *
4 * Copyright (C) 2011, Intel Corporation
5 *
6 * Authors: Bruce E. Robertson <bruce.e.robertson@intel.com>
7 * Mika Westerberg <mika.westerberg@linux.intel.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef SMB347_CHARGER_H
15#define SMB347_CHARGER_H
16
17#include <linux/types.h>
18#include <linux/power_supply.h>
19
20enum {
21 /* use the default compensation method */
22 SMB347_SOFT_TEMP_COMPENSATE_DEFAULT = -1,
23
24 SMB347_SOFT_TEMP_COMPENSATE_NONE,
25 SMB347_SOFT_TEMP_COMPENSATE_CURRENT,
26 SMB347_SOFT_TEMP_COMPENSATE_VOLTAGE,
27};
28
29/* Use default factory programmed value for hard/soft temperature limit */
30#define SMB347_TEMP_USE_DEFAULT -273
31
32/*
33 * Charging enable can be controlled by software (via i2c) by
34 * smb347-charger driver or by EN pin (active low/high).
35 */
36enum smb347_chg_enable {
37 SMB347_CHG_ENABLE_SW,
38 SMB347_CHG_ENABLE_PIN_ACTIVE_LOW,
39 SMB347_CHG_ENABLE_PIN_ACTIVE_HIGH,
40};
41
42/**
43 * struct smb347_charger_platform_data - platform data for SMB347 charger
44 * @battery_info: Information about the battery
45 * @max_charge_current: maximum current (in uA) the battery can be charged
46 * @max_charge_voltage: maximum voltage (in uV) the battery can be charged
47 * @pre_charge_current: current (in uA) to use in pre-charging phase
48 * @termination_current: current (in uA) used to determine when the
49 * charging cycle terminates
50 * @pre_to_fast_voltage: voltage (in uV) treshold used for transitioning to
51 * pre-charge to fast charge mode
52 * @mains_current_limit: maximum input current drawn from AC/DC input (in uA)
53 * @usb_hc_current_limit: maximum input high current (in uA) drawn from USB
54 * input
55 * @chip_temp_threshold: die temperature where device starts limiting charge
56 * current [%100 - %130] (in degree C)
57 * @soft_cold_temp_limit: soft cold temperature limit [%0 - %15] (in degree C),
58 * granularity is 5 deg C.
59 * @soft_hot_temp_limit: soft hot temperature limit [%40 - %55] (in degree C),
60 * granularity is 5 deg C.
61 * @hard_cold_temp_limit: hard cold temperature limit [%-5 - %10] (in degree C),
62 * granularity is 5 deg C.
63 * @hard_hot_temp_limit: hard hot temperature limit [%50 - %65] (in degree C),
64 * granularity is 5 deg C.
65 * @suspend_on_hard_temp_limit: suspend charging when hard limit is hit
66 * @soft_temp_limit_compensation: compensation method when soft temperature
67 * limit is hit
68 * @charge_current_compensation: current (in uA) for charging compensation
69 * current when temperature hits soft limits
70 * @use_mains: AC/DC input can be used
71 * @use_usb: USB input can be used
72 * @use_usb_otg: USB OTG output can be used (not implemented yet)
73 * @irq_gpio: GPIO number used for interrupts (%-1 if not used)
74 * @enable_control: how charging enable/disable is controlled
75 * (driver/pin controls)
76 *
77 * @use_main, @use_usb, and @use_usb_otg are means to enable/disable
78 * hardware support for these. This is useful when we want to have for
79 * example OTG charging controlled via OTG transceiver driver and not by
80 * the SMB347 hardware.
81 *
82 * Hard and soft temperature limit values are given as described in the
83 * device data sheet and assuming NTC beta value is %3750. Even if this is
84 * not the case, these values should be used. They can be mapped to the
85 * corresponding NTC beta values with the help of table %2 in the data
86 * sheet. So for example if NTC beta is %3375 and we want to program hard
87 * hot limit to be %53 deg C, @hard_hot_temp_limit should be set to %50.
88 *
89 * If zero value is given in any of the current and voltage values, the
90 * factory programmed default will be used. For soft/hard temperature
91 * values, pass in %SMB347_TEMP_USE_DEFAULT instead.
92 */
93struct smb347_charger_platform_data {
94 struct power_supply_info battery_info;
95 unsigned int max_charge_current;
96 unsigned int max_charge_voltage;
97 unsigned int pre_charge_current;
98 unsigned int termination_current;
99 unsigned int pre_to_fast_voltage;
100 unsigned int mains_current_limit;
101 unsigned int usb_hc_current_limit;
102 unsigned int chip_temp_threshold;
103 int soft_cold_temp_limit;
104 int soft_hot_temp_limit;
105 int hard_cold_temp_limit;
106 int hard_hot_temp_limit;
107 bool suspend_on_hard_temp_limit;
108 unsigned int soft_temp_limit_compensation;
109 unsigned int charge_current_compensation;
110 bool use_mains;
111 bool use_usb;
112 bool use_usb_otg;
113 int irq_gpio;
114 enum smb347_chg_enable enable_control;
115};
116
117#endif /* SMB347_CHARGER_H */
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 67be0376d8e3..7be2e88f23fd 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -151,6 +151,9 @@ int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu);
151 151
152void ring_buffer_record_disable(struct ring_buffer *buffer); 152void ring_buffer_record_disable(struct ring_buffer *buffer);
153void ring_buffer_record_enable(struct ring_buffer *buffer); 153void ring_buffer_record_enable(struct ring_buffer *buffer);
154void ring_buffer_record_off(struct ring_buffer *buffer);
155void ring_buffer_record_on(struct ring_buffer *buffer);
156int ring_buffer_record_is_on(struct ring_buffer *buffer);
154void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu); 157void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu);
155void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu); 158void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu);
156 159
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 93f4d035076b..fcabfb4873c8 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -202,7 +202,8 @@ struct rtc_device
202 struct hrtimer pie_timer; /* sub second exp, so needs hrtimer */ 202 struct hrtimer pie_timer; /* sub second exp, so needs hrtimer */
203 int pie_enabled; 203 int pie_enabled;
204 struct work_struct irqwork; 204 struct work_struct irqwork;
205 205 /* Some hardware can't support UIE mode */
206 int uie_unsupported;
206 207
207#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL 208#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
208 struct work_struct uie_task; 209 struct work_struct uie_task;
diff --git a/include/linux/sh_intc.h b/include/linux/sh_intc.h
index b160645f5599..6aed0805927f 100644
--- a/include/linux/sh_intc.h
+++ b/include/linux/sh_intc.h
@@ -3,6 +3,23 @@
3 3
4#include <linux/ioport.h> 4#include <linux/ioport.h>
5 5
6#ifdef CONFIG_SUPERH
7#define INTC_NR_IRQS 512
8#else
9#define INTC_NR_IRQS 1024
10#endif
11
12/*
13 * Convert back and forth between INTEVT and IRQ values.
14 */
15#ifdef CONFIG_CPU_HAS_INTEVT
16#define evt2irq(evt) (((evt) >> 5) - 16)
17#define irq2evt(irq) (((irq) + 16) << 5)
18#else
19#define evt2irq(evt) (evt)
20#define irq2evt(irq) (irq)
21#endif
22
6typedef unsigned char intc_enum; 23typedef unsigned char intc_enum;
7 24
8struct intc_vect { 25struct intc_vect {
diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_smp.h
index e253ccd7a604..51df117abe46 100644
--- a/include/linux/spinlock_api_smp.h
+++ b/include/linux/spinlock_api_smp.h
@@ -67,7 +67,7 @@ _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
67#define _raw_spin_trylock_bh(lock) __raw_spin_trylock_bh(lock) 67#define _raw_spin_trylock_bh(lock) __raw_spin_trylock_bh(lock)
68#endif 68#endif
69 69
70#ifdef CONFIG_INLINE_SPIN_UNLOCK 70#ifndef CONFIG_UNINLINE_SPIN_UNLOCK
71#define _raw_spin_unlock(lock) __raw_spin_unlock(lock) 71#define _raw_spin_unlock(lock) __raw_spin_unlock(lock)
72#endif 72#endif
73 73
diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
index c14fe86dac59..0b8e3e6bdacf 100644
--- a/include/linux/sunrpc/svc_rdma.h
+++ b/include/linux/sunrpc/svc_rdma.h
@@ -190,7 +190,7 @@ extern int svc_rdma_xdr_encode_error(struct svcxprt_rdma *,
190extern void svc_rdma_xdr_encode_write_list(struct rpcrdma_msg *, int); 190extern void svc_rdma_xdr_encode_write_list(struct rpcrdma_msg *, int);
191extern void svc_rdma_xdr_encode_reply_array(struct rpcrdma_write_array *, int); 191extern void svc_rdma_xdr_encode_reply_array(struct rpcrdma_write_array *, int);
192extern void svc_rdma_xdr_encode_array_chunk(struct rpcrdma_write_array *, int, 192extern void svc_rdma_xdr_encode_array_chunk(struct rpcrdma_write_array *, int,
193 u32, u64, u32); 193 __be32, __be64, u32);
194extern void svc_rdma_xdr_encode_reply_header(struct svcxprt_rdma *, 194extern void svc_rdma_xdr_encode_reply_header(struct svcxprt_rdma *,
195 struct rpcrdma_msg *, 195 struct rpcrdma_msg *,
196 struct rpcrdma_msg *, 196 struct rpcrdma_msg *,
@@ -292,7 +292,7 @@ svc_rdma_get_reply_array(struct rpcrdma_msg *rmsgp)
292 if (wr_ary) { 292 if (wr_ary) {
293 rp_ary = (struct rpcrdma_write_array *) 293 rp_ary = (struct rpcrdma_write_array *)
294 &wr_ary-> 294 &wr_ary->
295 wc_array[wr_ary->wc_nchunks].wc_target.rs_length; 295 wc_array[ntohl(wr_ary->wc_nchunks)].wc_target.rs_length;
296 296
297 goto found_it; 297 goto found_it;
298 } 298 }
diff --git a/include/linux/sysinfo.h b/include/linux/sysinfo.h
new file mode 100644
index 000000000000..934335a22522
--- /dev/null
+++ b/include/linux/sysinfo.h
@@ -0,0 +1,24 @@
1#ifndef _LINUX_SYSINFO_H
2#define _LINUX_SYSINFO_H
3
4#include <linux/types.h>
5
6#define SI_LOAD_SHIFT 16
7struct sysinfo {
8 __kernel_long_t uptime; /* Seconds since boot */
9 __kernel_ulong_t loads[3]; /* 1, 5, and 15 minute load averages */
10 __kernel_ulong_t totalram; /* Total usable main memory size */
11 __kernel_ulong_t freeram; /* Available memory size */
12 __kernel_ulong_t sharedram; /* Amount of shared memory */
13 __kernel_ulong_t bufferram; /* Memory used by buffers */
14 __kernel_ulong_t totalswap; /* Total swap space size */
15 __kernel_ulong_t freeswap; /* swap space still available */
16 __u16 procs; /* Number of current processes */
17 __u16 pad; /* Explicit padding for m68k */
18 __kernel_ulong_t totalhigh; /* Total high memory size */
19 __kernel_ulong_t freehigh; /* Available high memory size */
20 __u32 mem_unit; /* Memory unit size in bytes */
21 char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)]; /* Padding: libc5 uses this.. */
22};
23
24#endif /* _LINUX_SYSINFO_H */
diff --git a/include/linux/tboot.h b/include/linux/tboot.h
index 1dba6ee55203..c75128bed5fa 100644
--- a/include/linux/tboot.h
+++ b/include/linux/tboot.h
@@ -143,7 +143,6 @@ static inline int tboot_enabled(void)
143 143
144extern void tboot_probe(void); 144extern void tboot_probe(void);
145extern void tboot_shutdown(u32 shutdown_type); 145extern void tboot_shutdown(u32 shutdown_type);
146extern void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control);
147extern struct acpi_table_header *tboot_get_dmar_table( 146extern struct acpi_table_header *tboot_get_dmar_table(
148 struct acpi_table_header *dmar_tbl); 147 struct acpi_table_header *dmar_tbl);
149extern int tboot_force_iommu(void); 148extern int tboot_force_iommu(void);
diff --git a/include/linux/time.h b/include/linux/time.h
index b3061782dec3..33a92ead4d88 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -116,7 +116,6 @@ static inline struct timespec timespec_sub(struct timespec lhs,
116extern void read_persistent_clock(struct timespec *ts); 116extern void read_persistent_clock(struct timespec *ts);
117extern void read_boot_clock(struct timespec *ts); 117extern void read_boot_clock(struct timespec *ts);
118extern int update_persistent_clock(struct timespec now); 118extern int update_persistent_clock(struct timespec now);
119extern int no_sync_cmos_clock __read_mostly;
120void timekeeping_init(void); 119void timekeeping_init(void);
121extern int timekeeping_suspended; 120extern int timekeeping_suspended;
122 121
@@ -256,6 +255,7 @@ static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
256 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns); 255 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
257 a->tv_nsec = ns; 256 a->tv_nsec = ns;
258} 257}
258
259#endif /* __KERNEL__ */ 259#endif /* __KERNEL__ */
260 260
261#define NFDBITS __NFDBITS 261#define NFDBITS __NFDBITS
diff --git a/include/linux/timex.h b/include/linux/timex.h
index b75e1864ed19..99bc88b1fc02 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -252,7 +252,7 @@ extern void ntp_clear(void);
252/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */ 252/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */
253extern u64 ntp_tick_length(void); 253extern u64 ntp_tick_length(void);
254 254
255extern void second_overflow(void); 255extern int second_overflow(unsigned long secs);
256extern int do_adjtimex(struct timex *); 256extern int do_adjtimex(struct timex *);
257extern void hardpps(const struct timespec *, const struct timespec *); 257extern void hardpps(const struct timespec *, const struct timespec *);
258 258
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index d0018d27c281..8efd28ae5597 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -96,7 +96,6 @@ struct virtio_driver {
96 void (*config_changed)(struct virtio_device *dev); 96 void (*config_changed)(struct virtio_device *dev);
97#ifdef CONFIG_PM 97#ifdef CONFIG_PM
98 int (*freeze)(struct virtio_device *dev); 98 int (*freeze)(struct virtio_device *dev);
99 int (*thaw)(struct virtio_device *dev);
100 int (*restore)(struct virtio_device *dev); 99 int (*restore)(struct virtio_device *dev);
101#endif 100#endif
102}; 101};