diff options
Diffstat (limited to 'include/linux')
64 files changed, 1962 insertions, 900 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 7628219e5386..35b00746c712 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h | |||
| @@ -31,6 +31,7 @@ enum bdi_state { | |||
| 31 | BDI_async_congested, /* The async (write) queue is getting full */ | 31 | BDI_async_congested, /* The async (write) queue is getting full */ |
| 32 | BDI_sync_congested, /* The sync queue is getting full */ | 32 | BDI_sync_congested, /* The sync queue is getting full */ |
| 33 | BDI_registered, /* bdi_register() was done */ | 33 | BDI_registered, /* bdi_register() was done */ |
| 34 | BDI_writeback_running, /* Writeback is in progress */ | ||
| 34 | BDI_unused, /* Available bits start here */ | 35 | BDI_unused, /* Available bits start here */ |
| 35 | }; | 36 | }; |
| 36 | 37 | ||
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 53691774d34e..ca83a97c9715 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h | |||
| @@ -150,6 +150,7 @@ enum rq_flag_bits { | |||
| 150 | __REQ_FLUSH, /* request for cache flush */ | 150 | __REQ_FLUSH, /* request for cache flush */ |
| 151 | __REQ_IO_STAT, /* account I/O stat */ | 151 | __REQ_IO_STAT, /* account I/O stat */ |
| 152 | __REQ_MIXED_MERGE, /* merge of different types, fail separately */ | 152 | __REQ_MIXED_MERGE, /* merge of different types, fail separately */ |
| 153 | __REQ_SECURE, /* secure discard (used with __REQ_DISCARD) */ | ||
| 153 | __REQ_NR_BITS, /* stops here */ | 154 | __REQ_NR_BITS, /* stops here */ |
| 154 | }; | 155 | }; |
| 155 | 156 | ||
| @@ -190,5 +191,6 @@ enum rq_flag_bits { | |||
| 190 | #define REQ_FLUSH (1 << __REQ_FLUSH) | 191 | #define REQ_FLUSH (1 << __REQ_FLUSH) |
| 191 | #define REQ_IO_STAT (1 << __REQ_IO_STAT) | 192 | #define REQ_IO_STAT (1 << __REQ_IO_STAT) |
| 192 | #define REQ_MIXED_MERGE (1 << __REQ_MIXED_MERGE) | 193 | #define REQ_MIXED_MERGE (1 << __REQ_MIXED_MERGE) |
| 194 | #define REQ_SECURE (1 << __REQ_SECURE) | ||
| 193 | 195 | ||
| 194 | #endif /* __LINUX_BLK_TYPES_H */ | 196 | #endif /* __LINUX_BLK_TYPES_H */ |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 89c855c5655c..2c54906f678f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -389,6 +389,7 @@ struct request_queue | |||
| 389 | #define QUEUE_FLAG_DISCARD 16 /* supports DISCARD */ | 389 | #define QUEUE_FLAG_DISCARD 16 /* supports DISCARD */ |
| 390 | #define QUEUE_FLAG_NOXMERGES 17 /* No extended merges */ | 390 | #define QUEUE_FLAG_NOXMERGES 17 /* No extended merges */ |
| 391 | #define QUEUE_FLAG_ADD_RANDOM 18 /* Contributes to random pool */ | 391 | #define QUEUE_FLAG_ADD_RANDOM 18 /* Contributes to random pool */ |
| 392 | #define QUEUE_FLAG_SECDISCARD 19 /* supports SECDISCARD */ | ||
| 392 | 393 | ||
| 393 | #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ | 394 | #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ |
| 394 | (1 << QUEUE_FLAG_CLUSTER) | \ | 395 | (1 << QUEUE_FLAG_CLUSTER) | \ |
| @@ -524,6 +525,8 @@ enum { | |||
| 524 | #define blk_queue_stackable(q) \ | 525 | #define blk_queue_stackable(q) \ |
| 525 | test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags) | 526 | test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags) |
| 526 | #define blk_queue_discard(q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags) | 527 | #define blk_queue_discard(q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags) |
| 528 | #define blk_queue_secdiscard(q) (blk_queue_discard(q) && \ | ||
| 529 | test_bit(QUEUE_FLAG_SECDISCARD, &(q)->queue_flags)) | ||
| 527 | 530 | ||
| 528 | #define blk_noretry_request(rq) \ | 531 | #define blk_noretry_request(rq) \ |
| 529 | ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ | 532 | ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ |
| @@ -918,10 +921,12 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt, | |||
| 918 | } | 921 | } |
| 919 | enum{ | 922 | enum{ |
| 920 | BLKDEV_WAIT, /* wait for completion */ | 923 | BLKDEV_WAIT, /* wait for completion */ |
| 921 | BLKDEV_BARRIER, /*issue request with barrier */ | 924 | BLKDEV_BARRIER, /* issue request with barrier */ |
| 925 | BLKDEV_SECURE, /* secure discard */ | ||
| 922 | }; | 926 | }; |
| 923 | #define BLKDEV_IFL_WAIT (1 << BLKDEV_WAIT) | 927 | #define BLKDEV_IFL_WAIT (1 << BLKDEV_WAIT) |
| 924 | #define BLKDEV_IFL_BARRIER (1 << BLKDEV_BARRIER) | 928 | #define BLKDEV_IFL_BARRIER (1 << BLKDEV_BARRIER) |
| 929 | #define BLKDEV_IFL_SECURE (1 << BLKDEV_SECURE) | ||
| 925 | extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *, | 930 | extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *, |
| 926 | unsigned long); | 931 | unsigned long); |
| 927 | extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | 932 | extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector, |
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index d23be0386e2d..6a4aea30aa09 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
| @@ -315,6 +315,7 @@ extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); | |||
| 315 | 315 | ||
| 316 | extern char *__d_path(const struct path *path, struct path *root, char *, int); | 316 | extern char *__d_path(const struct path *path, struct path *root, char *, int); |
| 317 | extern char *d_path(const struct path *, char *, int); | 317 | extern char *d_path(const struct path *, char *, int); |
| 318 | extern char *d_path_with_unreachable(const struct path *, char *, int); | ||
| 318 | extern char *__dentry_path(struct dentry *, char *, int); | 319 | extern char *__dentry_path(struct dentry *, char *, int); |
| 319 | extern char *dentry_path(struct dentry *, char *, int); | 320 | extern char *dentry_path(struct dentry *, char *, int); |
| 320 | 321 | ||
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 1381cd97b4ed..2970022faa63 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h | |||
| @@ -22,7 +22,7 @@ typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; | |||
| 22 | union map_info { | 22 | union map_info { |
| 23 | void *ptr; | 23 | void *ptr; |
| 24 | unsigned long long ll; | 24 | unsigned long long ll; |
| 25 | unsigned flush_request; | 25 | unsigned target_request_nr; |
| 26 | }; | 26 | }; |
| 27 | 27 | ||
| 28 | /* | 28 | /* |
| @@ -174,12 +174,18 @@ struct dm_target { | |||
| 174 | * A number of zero-length barrier requests that will be submitted | 174 | * A number of zero-length barrier requests that will be submitted |
| 175 | * to the target for the purpose of flushing cache. | 175 | * to the target for the purpose of flushing cache. |
| 176 | * | 176 | * |
| 177 | * The request number will be placed in union map_info->flush_request. | 177 | * The request number will be placed in union map_info->target_request_nr. |
| 178 | * It is a responsibility of the target driver to remap these requests | 178 | * It is a responsibility of the target driver to remap these requests |
| 179 | * to the real underlying devices. | 179 | * to the real underlying devices. |
| 180 | */ | 180 | */ |
| 181 | unsigned num_flush_requests; | 181 | unsigned num_flush_requests; |
| 182 | 182 | ||
| 183 | /* | ||
| 184 | * The number of discard requests that will be submitted to the | ||
| 185 | * target. map_info->request_nr is used just like num_flush_requests. | ||
| 186 | */ | ||
| 187 | unsigned num_discard_requests; | ||
| 188 | |||
| 183 | /* target specific data */ | 189 | /* target specific data */ |
| 184 | void *private; | 190 | void *private; |
| 185 | 191 | ||
| @@ -392,6 +398,12 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size); | |||
| 392 | #define dm_array_too_big(fixed, obj, num) \ | 398 | #define dm_array_too_big(fixed, obj, num) \ |
| 393 | ((num) > (UINT_MAX - (fixed)) / (obj)) | 399 | ((num) > (UINT_MAX - (fixed)) / (obj)) |
| 394 | 400 | ||
| 401 | /* | ||
| 402 | * Sector offset taken relative to the start of the target instead of | ||
| 403 | * relative to the start of the device. | ||
| 404 | */ | ||
| 405 | #define dm_target_offset(ti, sector) ((sector) - (ti)->begin) | ||
| 406 | |||
| 395 | static inline sector_t to_sector(unsigned long n) | 407 | static inline sector_t to_sector(unsigned long n) |
| 396 | { | 408 | { |
| 397 | return (n >> SECTOR_SHIFT); | 409 | return (n >> SECTOR_SHIFT); |
diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h index 2c445e113790..49eab360d5d4 100644 --- a/include/linux/dm-ioctl.h +++ b/include/linux/dm-ioctl.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
| 12 | 12 | ||
| 13 | #define DM_DIR "mapper" /* Slashes not supported */ | 13 | #define DM_DIR "mapper" /* Slashes not supported */ |
| 14 | #define DM_CONTROL_NODE "control" | ||
| 14 | #define DM_MAX_TYPE_NAME 16 | 15 | #define DM_MAX_TYPE_NAME 16 |
| 15 | #define DM_NAME_LEN 128 | 16 | #define DM_NAME_LEN 128 |
| 16 | #define DM_UUID_LEN 129 | 17 | #define DM_UUID_LEN 129 |
| @@ -266,9 +267,9 @@ enum { | |||
| 266 | #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) | 267 | #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) |
| 267 | 268 | ||
| 268 | #define DM_VERSION_MAJOR 4 | 269 | #define DM_VERSION_MAJOR 4 |
| 269 | #define DM_VERSION_MINOR 17 | 270 | #define DM_VERSION_MINOR 18 |
| 270 | #define DM_VERSION_PATCHLEVEL 0 | 271 | #define DM_VERSION_PATCHLEVEL 0 |
| 271 | #define DM_VERSION_EXTRA "-ioctl (2010-03-05)" | 272 | #define DM_VERSION_EXTRA "-ioctl (2010-06-29)" |
| 272 | 273 | ||
| 273 | /* Status bits */ | 274 | /* Status bits */ |
| 274 | #define DM_READONLY_FLAG (1 << 0) /* In/Out */ | 275 | #define DM_READONLY_FLAG (1 << 0) /* In/Out */ |
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 89b7e1a605b8..e0670a512056 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h | |||
| @@ -142,6 +142,14 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) | |||
| 142 | return -EIO; | 142 | return -EIO; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | static inline int dma_get_cache_alignment(void) | ||
| 146 | { | ||
| 147 | #ifdef ARCH_DMA_MINALIGN | ||
| 148 | return ARCH_DMA_MINALIGN; | ||
| 149 | #endif | ||
| 150 | return 1; | ||
| 151 | } | ||
| 152 | |||
| 145 | /* flags for the coherent memory api */ | 153 | /* flags for the coherent memory api */ |
| 146 | #define DMA_MEMORY_MAP 0x01 | 154 | #define DMA_MEMORY_MAP 0x01 |
| 147 | #define DMA_MEMORY_IO 0x02 | 155 | #define DMA_MEMORY_IO 0x02 |
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index 848480bc2bf9..2308fbb4523a 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h | |||
| @@ -129,7 +129,7 @@ static inline void random_ether_addr(u8 *addr) | |||
| 129 | /** | 129 | /** |
| 130 | * dev_hw_addr_random - Create random MAC and set device flag | 130 | * dev_hw_addr_random - Create random MAC and set device flag |
| 131 | * @dev: pointer to net_device structure | 131 | * @dev: pointer to net_device structure |
| 132 | * @addr: Pointer to a six-byte array containing the Ethernet address | 132 | * @hwaddr: Pointer to a six-byte array containing the Ethernet address |
| 133 | * | 133 | * |
| 134 | * Generate random MAC to be used by a device and set addr_assign_type | 134 | * Generate random MAC to be used by a device and set addr_assign_type |
| 135 | * so the state can be read by sysfs and be used by udev. | 135 | * so the state can be read by sysfs and be used by udev. |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 1542e0e52b2e..7a0625e26a39 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -93,7 +93,7 @@ struct inodes_stat_t { | |||
| 93 | #define FMODE_RANDOM ((__force fmode_t)0x1000) | 93 | #define FMODE_RANDOM ((__force fmode_t)0x1000) |
| 94 | 94 | ||
| 95 | /* File was opened by fanotify and shouldn't generate fanotify events */ | 95 | /* File was opened by fanotify and shouldn't generate fanotify events */ |
| 96 | #define FMODE_NONOTIFY ((__force fmode_t)16777216) /* 0x1000000 */ | 96 | #define FMODE_NONOTIFY ((__force fmode_t)0x1000000) |
| 97 | 97 | ||
| 98 | /* | 98 | /* |
| 99 | * The below are the various read and write types that we support. Some of | 99 | * The below are the various read and write types that we support. Some of |
| @@ -174,6 +174,7 @@ struct inodes_stat_t { | |||
| 174 | */ | 174 | */ |
| 175 | #define DISCARD_NOBARRIER (WRITE | REQ_DISCARD) | 175 | #define DISCARD_NOBARRIER (WRITE | REQ_DISCARD) |
| 176 | #define DISCARD_BARRIER (WRITE | REQ_DISCARD | REQ_HARDBARRIER) | 176 | #define DISCARD_BARRIER (WRITE | REQ_DISCARD | REQ_HARDBARRIER) |
| 177 | #define DISCARD_SECURE (DISCARD_NOBARRIER | REQ_SECURE) | ||
| 177 | 178 | ||
| 178 | #define SEL_IN 1 | 179 | #define SEL_IN 1 |
| 179 | #define SEL_OUT 2 | 180 | #define SEL_OUT 2 |
| @@ -317,6 +318,7 @@ struct inodes_stat_t { | |||
| 317 | #define BLKALIGNOFF _IO(0x12,122) | 318 | #define BLKALIGNOFF _IO(0x12,122) |
| 318 | #define BLKPBSZGET _IO(0x12,123) | 319 | #define BLKPBSZGET _IO(0x12,123) |
| 319 | #define BLKDISCARDZEROES _IO(0x12,124) | 320 | #define BLKDISCARDZEROES _IO(0x12,124) |
| 321 | #define BLKSECDISCARD _IO(0x12,125) | ||
| 320 | 322 | ||
| 321 | #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ | 323 | #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ |
| 322 | #define FIBMAP _IO(0x00,1) /* bmap access */ | 324 | #define FIBMAP _IO(0x00,1) /* bmap access */ |
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h index 78a05bfcd8eb..eca3d5202138 100644 --- a/include/linux/fs_struct.h +++ b/include/linux/fs_struct.h | |||
| @@ -21,4 +21,31 @@ extern void free_fs_struct(struct fs_struct *); | |||
| 21 | extern void daemonize_fs_struct(void); | 21 | extern void daemonize_fs_struct(void); |
| 22 | extern int unshare_fs_struct(void); | 22 | extern int unshare_fs_struct(void); |
| 23 | 23 | ||
| 24 | static inline void get_fs_root(struct fs_struct *fs, struct path *root) | ||
| 25 | { | ||
| 26 | read_lock(&fs->lock); | ||
| 27 | *root = fs->root; | ||
| 28 | path_get(root); | ||
| 29 | read_unlock(&fs->lock); | ||
| 30 | } | ||
| 31 | |||
| 32 | static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd) | ||
| 33 | { | ||
| 34 | read_lock(&fs->lock); | ||
| 35 | *pwd = fs->pwd; | ||
| 36 | path_get(pwd); | ||
| 37 | read_unlock(&fs->lock); | ||
| 38 | } | ||
| 39 | |||
| 40 | static inline void get_fs_root_and_pwd(struct fs_struct *fs, struct path *root, | ||
| 41 | struct path *pwd) | ||
| 42 | { | ||
| 43 | read_lock(&fs->lock); | ||
| 44 | *root = fs->root; | ||
| 45 | path_get(root); | ||
| 46 | *pwd = fs->pwd; | ||
| 47 | path_get(pwd); | ||
| 48 | read_unlock(&fs->lock); | ||
| 49 | } | ||
| 50 | |||
| 24 | #endif /* _LINUX_FS_STRUCT_H */ | 51 | #endif /* _LINUX_FS_STRUCT_H */ |
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index e4e2204187ee..59d0df43ff9d 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h | |||
| @@ -26,18 +26,19 @@ static inline void fsnotify_d_instantiate(struct dentry *dentry, | |||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | /* Notify this dentry's parent about a child's events. */ | 28 | /* Notify this dentry's parent about a child's events. */ |
| 29 | static inline void fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask) | 29 | static inline void fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) |
| 30 | { | 30 | { |
| 31 | if (!dentry) | 31 | if (!dentry) |
| 32 | dentry = file->f_path.dentry; | 32 | dentry = path->dentry; |
| 33 | 33 | ||
| 34 | __fsnotify_parent(file, dentry, mask); | 34 | __fsnotify_parent(path, dentry, mask); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | /* simple call site for access decisions */ | 37 | /* simple call site for access decisions */ |
| 38 | static inline int fsnotify_perm(struct file *file, int mask) | 38 | static inline int fsnotify_perm(struct file *file, int mask) |
| 39 | { | 39 | { |
| 40 | struct inode *inode = file->f_path.dentry->d_inode; | 40 | struct path *path = &file->f_path; |
| 41 | struct inode *inode = path->dentry->d_inode; | ||
| 41 | __u32 fsnotify_mask = 0; | 42 | __u32 fsnotify_mask = 0; |
| 42 | 43 | ||
| 43 | if (file->f_mode & FMODE_NONOTIFY) | 44 | if (file->f_mode & FMODE_NONOTIFY) |
| @@ -51,7 +52,7 @@ static inline int fsnotify_perm(struct file *file, int mask) | |||
| 51 | else | 52 | else |
| 52 | BUG(); | 53 | BUG(); |
| 53 | 54 | ||
| 54 | return fsnotify(inode, fsnotify_mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 55 | return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | /* | 58 | /* |
| @@ -186,15 +187,16 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) | |||
| 186 | */ | 187 | */ |
| 187 | static inline void fsnotify_access(struct file *file) | 188 | static inline void fsnotify_access(struct file *file) |
| 188 | { | 189 | { |
| 189 | struct inode *inode = file->f_path.dentry->d_inode; | 190 | struct path *path = &file->f_path; |
| 191 | struct inode *inode = path->dentry->d_inode; | ||
| 190 | __u32 mask = FS_ACCESS; | 192 | __u32 mask = FS_ACCESS; |
| 191 | 193 | ||
| 192 | if (S_ISDIR(inode->i_mode)) | 194 | if (S_ISDIR(inode->i_mode)) |
| 193 | mask |= FS_IN_ISDIR; | 195 | mask |= FS_IN_ISDIR; |
| 194 | 196 | ||
| 195 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 197 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
| 196 | fsnotify_parent(file, NULL, mask); | 198 | fsnotify_parent(path, NULL, mask); |
| 197 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 199 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
| 198 | } | 200 | } |
| 199 | } | 201 | } |
| 200 | 202 | ||
| @@ -203,15 +205,16 @@ static inline void fsnotify_access(struct file *file) | |||
| 203 | */ | 205 | */ |
| 204 | static inline void fsnotify_modify(struct file *file) | 206 | static inline void fsnotify_modify(struct file *file) |
| 205 | { | 207 | { |
| 206 | struct inode *inode = file->f_path.dentry->d_inode; | 208 | struct path *path = &file->f_path; |
| 209 | struct inode *inode = path->dentry->d_inode; | ||
| 207 | __u32 mask = FS_MODIFY; | 210 | __u32 mask = FS_MODIFY; |
| 208 | 211 | ||
| 209 | if (S_ISDIR(inode->i_mode)) | 212 | if (S_ISDIR(inode->i_mode)) |
| 210 | mask |= FS_IN_ISDIR; | 213 | mask |= FS_IN_ISDIR; |
| 211 | 214 | ||
| 212 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 215 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
| 213 | fsnotify_parent(file, NULL, mask); | 216 | fsnotify_parent(path, NULL, mask); |
| 214 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 217 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
| 215 | } | 218 | } |
| 216 | } | 219 | } |
| 217 | 220 | ||
| @@ -220,15 +223,16 @@ static inline void fsnotify_modify(struct file *file) | |||
| 220 | */ | 223 | */ |
| 221 | static inline void fsnotify_open(struct file *file) | 224 | static inline void fsnotify_open(struct file *file) |
| 222 | { | 225 | { |
| 223 | struct inode *inode = file->f_path.dentry->d_inode; | 226 | struct path *path = &file->f_path; |
| 227 | struct inode *inode = path->dentry->d_inode; | ||
| 224 | __u32 mask = FS_OPEN; | 228 | __u32 mask = FS_OPEN; |
| 225 | 229 | ||
| 226 | if (S_ISDIR(inode->i_mode)) | 230 | if (S_ISDIR(inode->i_mode)) |
| 227 | mask |= FS_IN_ISDIR; | 231 | mask |= FS_IN_ISDIR; |
| 228 | 232 | ||
| 229 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 233 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
| 230 | fsnotify_parent(file, NULL, mask); | 234 | fsnotify_parent(path, NULL, mask); |
| 231 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 235 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
| 232 | } | 236 | } |
| 233 | } | 237 | } |
| 234 | 238 | ||
| @@ -237,6 +241,7 @@ static inline void fsnotify_open(struct file *file) | |||
| 237 | */ | 241 | */ |
| 238 | static inline void fsnotify_close(struct file *file) | 242 | static inline void fsnotify_close(struct file *file) |
| 239 | { | 243 | { |
| 244 | struct path *path = &file->f_path; | ||
| 240 | struct inode *inode = file->f_path.dentry->d_inode; | 245 | struct inode *inode = file->f_path.dentry->d_inode; |
| 241 | fmode_t mode = file->f_mode; | 246 | fmode_t mode = file->f_mode; |
| 242 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; | 247 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; |
| @@ -245,8 +250,8 @@ static inline void fsnotify_close(struct file *file) | |||
| 245 | mask |= FS_IN_ISDIR; | 250 | mask |= FS_IN_ISDIR; |
| 246 | 251 | ||
| 247 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 252 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
| 248 | fsnotify_parent(file, NULL, mask); | 253 | fsnotify_parent(path, NULL, mask); |
| 249 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 254 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
| 250 | } | 255 | } |
| 251 | } | 256 | } |
| 252 | 257 | ||
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 9bbfd7204b04..ed36fb57c426 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h | |||
| @@ -203,20 +203,20 @@ struct fsnotify_event { | |||
| 203 | /* to_tell may ONLY be dereferenced during handle_event(). */ | 203 | /* to_tell may ONLY be dereferenced during handle_event(). */ |
| 204 | struct inode *to_tell; /* either the inode the event happened to or its parent */ | 204 | struct inode *to_tell; /* either the inode the event happened to or its parent */ |
| 205 | /* | 205 | /* |
| 206 | * depending on the event type we should have either a file or inode | 206 | * depending on the event type we should have either a path or inode |
| 207 | * We hold a reference on file, but NOT on inode. Since we have the ref on | 207 | * We hold a reference on path, but NOT on inode. Since we have the ref on |
| 208 | * the file, it may be dereferenced at any point during this object's | 208 | * the path, it may be dereferenced at any point during this object's |
| 209 | * lifetime. That reference is dropped when this object's refcnt hits | 209 | * lifetime. That reference is dropped when this object's refcnt hits |
| 210 | * 0. If this event contains an inode instead of a file, the inode may | 210 | * 0. If this event contains an inode instead of a path, the inode may |
| 211 | * ONLY be used during handle_event(). | 211 | * ONLY be used during handle_event(). |
| 212 | */ | 212 | */ |
| 213 | union { | 213 | union { |
| 214 | struct file *file; | 214 | struct path path; |
| 215 | struct inode *inode; | 215 | struct inode *inode; |
| 216 | }; | 216 | }; |
| 217 | /* when calling fsnotify tell it if the data is a path or inode */ | 217 | /* when calling fsnotify tell it if the data is a path or inode */ |
| 218 | #define FSNOTIFY_EVENT_NONE 0 | 218 | #define FSNOTIFY_EVENT_NONE 0 |
| 219 | #define FSNOTIFY_EVENT_FILE 1 | 219 | #define FSNOTIFY_EVENT_PATH 1 |
| 220 | #define FSNOTIFY_EVENT_INODE 2 | 220 | #define FSNOTIFY_EVENT_INODE 2 |
| 221 | int data_type; /* which of the above union we have */ | 221 | int data_type; /* which of the above union we have */ |
| 222 | atomic_t refcnt; /* how many groups still are using/need to send this event */ | 222 | atomic_t refcnt; /* how many groups still are using/need to send this event */ |
| @@ -293,7 +293,7 @@ struct fsnotify_mark { | |||
| 293 | /* main fsnotify call to send events */ | 293 | /* main fsnotify call to send events */ |
| 294 | extern int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, | 294 | extern int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, |
| 295 | const unsigned char *name, u32 cookie); | 295 | const unsigned char *name, u32 cookie); |
| 296 | extern void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask); | 296 | extern void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask); |
| 297 | extern void __fsnotify_inode_delete(struct inode *inode); | 297 | extern void __fsnotify_inode_delete(struct inode *inode); |
| 298 | extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); | 298 | extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); |
| 299 | extern u32 fsnotify_get_cookie(void); | 299 | extern u32 fsnotify_get_cookie(void); |
| @@ -422,7 +422,7 @@ static inline int fsnotify(struct inode *to_tell, __u32 mask, void *data, int da | |||
| 422 | return 0; | 422 | return 0; |
| 423 | } | 423 | } |
| 424 | 424 | ||
| 425 | static inline void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask) | 425 | static inline void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) |
| 426 | {} | 426 | {} |
| 427 | 427 | ||
| 428 | static inline void __fsnotify_inode_delete(struct inode *inode) | 428 | static inline void __fsnotify_inode_delete(struct inode *inode) |
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 78b4bc64c006..f479700df61b 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #define _LINUX_HUGETLB_H | 2 | #define _LINUX_HUGETLB_H |
| 3 | 3 | ||
| 4 | #include <linux/fs.h> | 4 | #include <linux/fs.h> |
| 5 | #include <linux/hugetlb_inline.h> | ||
| 5 | 6 | ||
| 6 | struct ctl_table; | 7 | struct ctl_table; |
| 7 | struct user_struct; | 8 | struct user_struct; |
| @@ -14,11 +15,6 @@ struct user_struct; | |||
| 14 | 15 | ||
| 15 | int PageHuge(struct page *page); | 16 | int PageHuge(struct page *page); |
| 16 | 17 | ||
| 17 | static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) | ||
| 18 | { | ||
| 19 | return vma->vm_flags & VM_HUGETLB; | ||
| 20 | } | ||
| 21 | |||
| 22 | void reset_vma_resv_huge_pages(struct vm_area_struct *vma); | 18 | void reset_vma_resv_huge_pages(struct vm_area_struct *vma); |
| 23 | int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); | 19 | int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); |
| 24 | int hugetlb_overcommit_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); | 20 | int hugetlb_overcommit_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); |
| @@ -47,6 +43,7 @@ int hugetlb_reserve_pages(struct inode *inode, long from, long to, | |||
| 47 | struct vm_area_struct *vma, | 43 | struct vm_area_struct *vma, |
| 48 | int acctflags); | 44 | int acctflags); |
| 49 | void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); | 45 | void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); |
| 46 | void __isolate_hwpoisoned_huge_page(struct page *page); | ||
| 50 | 47 | ||
| 51 | extern unsigned long hugepages_treat_as_movable; | 48 | extern unsigned long hugepages_treat_as_movable; |
| 52 | extern const unsigned long hugetlb_zero, hugetlb_infinity; | 49 | extern const unsigned long hugetlb_zero, hugetlb_infinity; |
| @@ -77,11 +74,6 @@ static inline int PageHuge(struct page *page) | |||
| 77 | return 0; | 74 | return 0; |
| 78 | } | 75 | } |
| 79 | 76 | ||
| 80 | static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) | ||
| 81 | { | ||
| 82 | return 0; | ||
| 83 | } | ||
| 84 | |||
| 85 | static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma) | 77 | static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma) |
| 86 | { | 78 | { |
| 87 | } | 79 | } |
| @@ -108,6 +100,8 @@ static inline void hugetlb_report_meminfo(struct seq_file *m) | |||
| 108 | #define is_hugepage_only_range(mm, addr, len) 0 | 100 | #define is_hugepage_only_range(mm, addr, len) 0 |
| 109 | #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) | 101 | #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) |
| 110 | #define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; }) | 102 | #define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; }) |
| 103 | #define huge_pte_offset(mm, address) 0 | ||
| 104 | #define __isolate_hwpoisoned_huge_page(page) 0 | ||
| 111 | 105 | ||
| 112 | #define hugetlb_change_protection(vma, address, end, newprot) | 106 | #define hugetlb_change_protection(vma, address, end, newprot) |
| 113 | 107 | ||
diff --git a/include/linux/hugetlb_inline.h b/include/linux/hugetlb_inline.h new file mode 100644 index 000000000000..6931489a5c14 --- /dev/null +++ b/include/linux/hugetlb_inline.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | #ifndef _LINUX_HUGETLB_INLINE_H | ||
| 2 | #define _LINUX_HUGETLB_INLINE_H | ||
| 3 | |||
| 4 | #ifdef CONFIG_HUGETLB_PAGE | ||
| 5 | |||
| 6 | #include <linux/mm.h> | ||
| 7 | |||
| 8 | static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) | ||
| 9 | { | ||
| 10 | return vma->vm_flags & VM_HUGETLB; | ||
| 11 | } | ||
| 12 | |||
| 13 | #else | ||
| 14 | |||
| 15 | static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) | ||
| 16 | { | ||
| 17 | return 0; | ||
| 18 | } | ||
| 19 | |||
| 20 | #endif | ||
| 21 | |||
| 22 | #endif | ||
diff --git a/include/linux/i2c-mux.h b/include/linux/i2c-mux.h new file mode 100644 index 000000000000..34536effd652 --- /dev/null +++ b/include/linux/i2c-mux.h | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | /* | ||
| 2 | * | ||
| 3 | * i2c-mux.h - functions for the i2c-bus mux support | ||
| 4 | * | ||
| 5 | * Copyright (c) 2008-2009 Rodolfo Giometti <giometti@linux.it> | ||
| 6 | * Copyright (c) 2008-2009 Eurotech S.p.A. <info@eurotech.it> | ||
| 7 | * Michael Lawnick <michael.lawnick.ext@nsn.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 as published by | ||
| 11 | * the Free Software Foundation; either version 2 of the License, or | ||
| 12 | * (at your option) any later version. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License | ||
| 20 | * along with this program; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 22 | */ | ||
| 23 | |||
| 24 | #ifndef _LINUX_I2C_MUX_H | ||
| 25 | #define _LINUX_I2C_MUX_H | ||
| 26 | |||
| 27 | #ifdef __KERNEL__ | ||
| 28 | |||
| 29 | /* | ||
| 30 | * Called to create a i2c bus on a multiplexed bus segment. | ||
| 31 | * The mux_dev and chan_id parameters are passed to the select | ||
| 32 | * and deselect callback functions to perform hardware-specific | ||
| 33 | * mux control. | ||
| 34 | */ | ||
| 35 | struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, | ||
| 36 | void *mux_dev, u32 force_nr, u32 chan_id, | ||
| 37 | int (*select) (struct i2c_adapter *, | ||
| 38 | void *mux_dev, u32 chan_id), | ||
| 39 | int (*deselect) (struct i2c_adapter *, | ||
| 40 | void *mux_dev, u32 chan_id)); | ||
| 41 | |||
| 42 | int i2c_del_mux_adapter(struct i2c_adapter *adap); | ||
| 43 | |||
| 44 | #endif /* __KERNEL__ */ | ||
| 45 | |||
| 46 | #endif /* _LINUX_I2C_MUX_H */ | ||
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 38dd4025aa4e..4bae0b72ed3c 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | #include <linux/of.h> /* for struct device_node */ | 37 | #include <linux/of.h> /* for struct device_node */ |
| 38 | 38 | ||
| 39 | extern struct bus_type i2c_bus_type; | 39 | extern struct bus_type i2c_bus_type; |
| 40 | extern struct device_type i2c_adapter_type; | ||
| 40 | 41 | ||
| 41 | /* --- General options ------------------------------------------------ */ | 42 | /* --- General options ------------------------------------------------ */ |
| 42 | 43 | ||
| @@ -284,12 +285,18 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info); | |||
| 284 | 285 | ||
| 285 | /* If you don't know the exact address of an I2C device, use this variant | 286 | /* If you don't know the exact address of an I2C device, use this variant |
| 286 | * instead, which can probe for device presence in a list of possible | 287 | * instead, which can probe for device presence in a list of possible |
| 287 | * addresses. | 288 | * addresses. The "probe" callback function is optional. If it is provided, |
| 289 | * it must return 1 on successful probe, 0 otherwise. If it is not provided, | ||
| 290 | * a default probing method is used. | ||
| 288 | */ | 291 | */ |
| 289 | extern struct i2c_client * | 292 | extern struct i2c_client * |
| 290 | i2c_new_probed_device(struct i2c_adapter *adap, | 293 | i2c_new_probed_device(struct i2c_adapter *adap, |
| 291 | struct i2c_board_info *info, | 294 | struct i2c_board_info *info, |
| 292 | unsigned short const *addr_list); | 295 | unsigned short const *addr_list, |
| 296 | int (*probe)(struct i2c_adapter *, unsigned short addr)); | ||
| 297 | |||
| 298 | /* Common custom probe functions */ | ||
| 299 | extern int i2c_probe_func_quick_read(struct i2c_adapter *, unsigned short addr); | ||
| 293 | 300 | ||
| 294 | /* For devices that use several addresses, use i2c_new_dummy() to make | 301 | /* For devices that use several addresses, use i2c_new_dummy() to make |
| 295 | * client handles for the extra addresses. | 302 | * client handles for the extra addresses. |
| @@ -362,6 +369,7 @@ struct i2c_adapter { | |||
| 362 | char name[48]; | 369 | char name[48]; |
| 363 | struct completion dev_released; | 370 | struct completion dev_released; |
| 364 | 371 | ||
| 372 | struct mutex userspace_clients_lock; | ||
| 365 | struct list_head userspace_clients; | 373 | struct list_head userspace_clients; |
| 366 | }; | 374 | }; |
| 367 | #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) | 375 | #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) |
| @@ -376,23 +384,16 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data) | |||
| 376 | dev_set_drvdata(&dev->dev, data); | 384 | dev_set_drvdata(&dev->dev, data); |
| 377 | } | 385 | } |
| 378 | 386 | ||
| 379 | /** | 387 | static inline int i2c_parent_is_i2c_adapter(const struct i2c_adapter *adapter) |
| 380 | * i2c_lock_adapter - Prevent access to an I2C bus segment | ||
| 381 | * @adapter: Target I2C bus segment | ||
| 382 | */ | ||
| 383 | static inline void i2c_lock_adapter(struct i2c_adapter *adapter) | ||
| 384 | { | 388 | { |
| 385 | rt_mutex_lock(&adapter->bus_lock); | 389 | return adapter->dev.parent != NULL |
| 390 | && adapter->dev.parent->bus == &i2c_bus_type | ||
| 391 | && adapter->dev.parent->type == &i2c_adapter_type; | ||
| 386 | } | 392 | } |
| 387 | 393 | ||
| 388 | /** | 394 | /* Adapter locking functions, exported for shared pin cases */ |
| 389 | * i2c_unlock_adapter - Reauthorize access to an I2C bus segment | 395 | void i2c_lock_adapter(struct i2c_adapter *); |
| 390 | * @adapter: Target I2C bus segment | 396 | void i2c_unlock_adapter(struct i2c_adapter *); |
| 391 | */ | ||
| 392 | static inline void i2c_unlock_adapter(struct i2c_adapter *adapter) | ||
| 393 | { | ||
| 394 | rt_mutex_unlock(&adapter->bus_lock); | ||
| 395 | } | ||
| 396 | 397 | ||
| 397 | /*flags for the client struct: */ | 398 | /*flags for the client struct: */ |
| 398 | #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */ | 399 | #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */ |
diff --git a/include/linux/i2c/pca954x.h b/include/linux/i2c/pca954x.h new file mode 100644 index 000000000000..28f1f8d5ab1f --- /dev/null +++ b/include/linux/i2c/pca954x.h | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | /* | ||
| 2 | * | ||
| 3 | * pca954x.h - I2C multiplexer/switch support | ||
| 4 | * | ||
| 5 | * Copyright (c) 2008-2009 Rodolfo Giometti <giometti@linux.it> | ||
| 6 | * Copyright (c) 2008-2009 Eurotech S.p.A. <info@eurotech.it> | ||
| 7 | * Michael Lawnick <michael.lawnick.ext@nsn.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 as published by | ||
| 11 | * the Free Software Foundation; either version 2 of the License, or | ||
| 12 | * (at your option) any later version. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License | ||
| 20 | * along with this program; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 22 | */ | ||
| 23 | |||
| 24 | |||
| 25 | #ifndef _LINUX_I2C_PCA954X_H | ||
| 26 | #define _LINUX_I2C_PCA954X_H | ||
| 27 | |||
| 28 | /* Platform data for the PCA954x I2C multiplexers */ | ||
| 29 | |||
| 30 | /* Per channel initialisation data: | ||
| 31 | * @adap_id: bus number for the adapter. 0 = don't care | ||
| 32 | * @deselect_on_exit: set this entry to 1, if your H/W needs deselection | ||
| 33 | * of this channel after transaction. | ||
| 34 | * | ||
| 35 | */ | ||
| 36 | struct pca954x_platform_mode { | ||
| 37 | int adap_id; | ||
| 38 | unsigned int deselect_on_exit:1; | ||
| 39 | }; | ||
| 40 | |||
| 41 | /* Per mux/switch data, used with i2c_register_board_info */ | ||
| 42 | struct pca954x_platform_data { | ||
| 43 | struct pca954x_platform_mode *modes; | ||
| 44 | int num_modes; | ||
| 45 | }; | ||
| 46 | |||
| 47 | #endif /* _LINUX_I2C_PCA954X_H */ | ||
diff --git a/include/linux/i2c/sx150x.h b/include/linux/i2c/sx150x.h new file mode 100644 index 000000000000..ee3049cb9ba5 --- /dev/null +++ b/include/linux/i2c/sx150x.h | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Semtech SX150x I2C GPIO Expanders | ||
| 3 | * | ||
| 4 | * Copyright (c) 2010, Code Aurora Forum. All rights reserved. | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 and | ||
| 8 | * only version 2 as published by the Free Software Foundation. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| 18 | * 02110-1301, USA. | ||
| 19 | */ | ||
| 20 | #ifndef __LINUX_I2C_SX150X_H | ||
| 21 | #define __LINUX_I2C_SX150X_H | ||
| 22 | |||
| 23 | /** | ||
| 24 | * struct sx150x_platform_data - config data for SX150x driver | ||
| 25 | * @gpio_base: The index number of the first GPIO assigned to this | ||
| 26 | * GPIO expander. The expander will create a block of | ||
| 27 | * consecutively numbered gpios beginning at the given base, | ||
| 28 | * with the size of the block depending on the model of the | ||
| 29 | * expander chip. | ||
| 30 | * @oscio_is_gpo: If set to true, the driver will configure OSCIO as a GPO | ||
| 31 | * instead of as an oscillator, increasing the size of the | ||
| 32 | * GP(I)O pool created by this expander by one. The | ||
| 33 | * output-only GPO pin will be added at the end of the block. | ||
| 34 | * @io_pullup_ena: A bit-mask which enables or disables the pull-up resistor | ||
| 35 | * for each IO line in the expander. Setting the bit at | ||
| 36 | * position n will enable the pull-up for the IO at | ||
| 37 | * the corresponding offset. For chips with fewer than | ||
| 38 | * 16 IO pins, high-end bits are ignored. | ||
| 39 | * @io_pulldn_ena: A bit-mask which enables-or disables the pull-down | ||
| 40 | * resistor for each IO line in the expander. Setting the | ||
| 41 | * bit at position n will enable the pull-down for the IO at | ||
| 42 | * the corresponding offset. For chips with fewer than | ||
| 43 | * 16 IO pins, high-end bits are ignored. | ||
| 44 | * @io_open_drain_ena: A bit-mask which enables-or disables open-drain | ||
| 45 | * operation for each IO line in the expander. Setting the | ||
| 46 | * bit at position n enables open-drain operation for | ||
| 47 | * the IO at the corresponding offset. Clearing the bit | ||
| 48 | * enables regular push-pull operation for that IO. | ||
| 49 | * For chips with fewer than 16 IO pins, high-end bits | ||
| 50 | * are ignored. | ||
| 51 | * @io_polarity: A bit-mask which enables polarity inversion for each IO line | ||
| 52 | * in the expander. Setting the bit at position n inverts | ||
| 53 | * the polarity of that IO line, while clearing it results | ||
| 54 | * in normal polarity. For chips with fewer than 16 IO pins, | ||
| 55 | * high-end bits are ignored. | ||
| 56 | * @irq_summary: The 'summary IRQ' line to which the GPIO expander's INT line | ||
| 57 | * is connected, via which it reports interrupt events | ||
| 58 | * across all GPIO lines. This must be a real, | ||
| 59 | * pre-existing IRQ line. | ||
| 60 | * Setting this value < 0 disables the irq_chip functionality | ||
| 61 | * of the driver. | ||
| 62 | * @irq_base: The first 'virtual IRQ' line at which our block of GPIO-based | ||
| 63 | * IRQ lines will appear. Similarly to gpio_base, the expander | ||
| 64 | * will create a block of irqs beginning at this number. | ||
| 65 | * This value is ignored if irq_summary is < 0. | ||
| 66 | */ | ||
| 67 | struct sx150x_platform_data { | ||
| 68 | unsigned gpio_base; | ||
| 69 | bool oscio_is_gpo; | ||
| 70 | u16 io_pullup_ena; | ||
| 71 | u16 io_pulldn_ena; | ||
| 72 | u16 io_open_drain_ena; | ||
| 73 | u16 io_polarity; | ||
| 74 | int irq_summary; | ||
| 75 | unsigned irq_base; | ||
| 76 | }; | ||
| 77 | |||
| 78 | #endif /* __LINUX_I2C_SX150X_H */ | ||
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h index e0ea40f6c515..0a6b3d5c490c 100644 --- a/include/linux/io-mapping.h +++ b/include/linux/io-mapping.h | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
| 23 | #include <asm/io.h> | 23 | #include <asm/io.h> |
| 24 | #include <asm/page.h> | 24 | #include <asm/page.h> |
| 25 | #include <asm/iomap.h> | ||
| 26 | 25 | ||
| 27 | /* | 26 | /* |
| 28 | * The io_mapping mechanism provides an abstraction for mapping | 27 | * The io_mapping mechanism provides an abstraction for mapping |
| @@ -33,6 +32,8 @@ | |||
| 33 | 32 | ||
| 34 | #ifdef CONFIG_HAVE_ATOMIC_IOMAP | 33 | #ifdef CONFIG_HAVE_ATOMIC_IOMAP |
| 35 | 34 | ||
| 35 | #include <asm/iomap.h> | ||
| 36 | |||
| 36 | struct io_mapping { | 37 | struct io_mapping { |
| 37 | resource_size_t base; | 38 | resource_size_t base; |
| 38 | unsigned long size; | 39 | unsigned long size; |
diff --git a/include/linux/jz4740-adc.h b/include/linux/jz4740-adc.h new file mode 100644 index 000000000000..9053f95e9687 --- /dev/null +++ b/include/linux/jz4740-adc.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | |||
| 2 | #ifndef __LINUX_JZ4740_ADC | ||
| 3 | #define __LINUX_JZ4740_ADC | ||
| 4 | |||
| 5 | #include <linux/device.h> | ||
| 6 | |||
| 7 | /* | ||
| 8 | * jz4740_adc_set_config - Configure a JZ4740 adc device | ||
| 9 | * @dev: Pointer to a jz4740-adc device | ||
| 10 | * @mask: Mask for the config value to be set | ||
| 11 | * @val: Value to be set | ||
| 12 | * | ||
| 13 | * This function can be used by the JZ4740 ADC mfd cells to configure their | ||
| 14 | * options in the shared config register. | ||
| 15 | */ | ||
| 16 | int jz4740_adc_set_config(struct device *dev, uint32_t mask, uint32_t val); | ||
| 17 | |||
| 18 | #define JZ_ADC_CONFIG_SPZZ BIT(31) | ||
| 19 | #define JZ_ADC_CONFIG_EX_IN BIT(30) | ||
| 20 | #define JZ_ADC_CONFIG_DNUM_MASK (0x7 << 16) | ||
| 21 | #define JZ_ADC_CONFIG_DMA_ENABLE BIT(15) | ||
| 22 | #define JZ_ADC_CONFIG_XYZ_MASK (0x2 << 13) | ||
| 23 | #define JZ_ADC_CONFIG_SAMPLE_NUM_MASK (0x7 << 10) | ||
| 24 | #define JZ_ADC_CONFIG_CLKDIV_MASK (0xf << 5) | ||
| 25 | #define JZ_ADC_CONFIG_BAT_MB BIT(4) | ||
| 26 | |||
| 27 | #define JZ_ADC_CONFIG_DNUM(dnum) ((dnum) << 16) | ||
| 28 | #define JZ_ADC_CONFIG_XYZ_OFFSET(dnum) ((xyz) << 13) | ||
| 29 | #define JZ_ADC_CONFIG_SAMPLE_NUM(x) ((x) << 10) | ||
| 30 | #define JZ_ADC_CONFIG_CLKDIV(div) ((div) << 5) | ||
| 31 | |||
| 32 | #endif | ||
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 5b57236dfbd0..2b0a35e6bc69 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -177,11 +177,12 @@ struct va_format { | |||
| 177 | }; | 177 | }; |
| 178 | 178 | ||
| 179 | extern struct atomic_notifier_head panic_notifier_list; | 179 | extern struct atomic_notifier_head panic_notifier_list; |
| 180 | extern long (*panic_blink)(long time); | 180 | extern long (*panic_blink)(int state); |
| 181 | NORET_TYPE void panic(const char * fmt, ...) | 181 | NORET_TYPE void panic(const char * fmt, ...) |
| 182 | __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; | 182 | __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; |
| 183 | extern void oops_enter(void); | 183 | extern void oops_enter(void); |
| 184 | extern void oops_exit(void); | 184 | extern void oops_exit(void); |
| 185 | void print_oops_end_marker(void); | ||
| 185 | extern int oops_may_print(void); | 186 | extern int oops_may_print(void); |
| 186 | NORET_TYPE void do_exit(long error_code) | 187 | NORET_TYPE void do_exit(long error_code) |
| 187 | ATTRIB_NORET; | 188 | ATTRIB_NORET; |
| @@ -305,6 +306,13 @@ static inline void log_buf_kexec_setup(void) | |||
| 305 | } | 306 | } |
| 306 | #endif | 307 | #endif |
| 307 | 308 | ||
| 309 | /* | ||
| 310 | * Dummy printk for disabled debugging statements to use whilst maintaining | ||
| 311 | * gcc's format and side-effect checking. | ||
| 312 | */ | ||
| 313 | static inline __attribute__ ((format (printf, 1, 2))) | ||
| 314 | int no_printk(const char *s, ...) { return 0; } | ||
| 315 | |||
| 308 | extern int printk_needs_cpu(int cpu); | 316 | extern int printk_needs_cpu(int cpu); |
| 309 | extern void printk_tick(void); | 317 | extern void printk_tick(void); |
| 310 | 318 | ||
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h index 9fad0527344f..311f8753d713 100644 --- a/include/linux/kfifo.h +++ b/include/linux/kfifo.h | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * A generic kernel FIFO implementation. | 2 | * A generic kernel FIFO implementation |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2009 Stefani Seibold <stefani@seibold.net> | 4 | * Copyright (C) 2009/2010 Stefani Seibold <stefani@seibold.net> |
| 5 | * Copyright (C) 2004 Stelian Pop <stelian@popies.net> | ||
| 6 | * | 5 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | 6 | * 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 | 7 | * it under the terms of the GNU General Public License as published by |
| @@ -20,8 +19,11 @@ | |||
| 20 | * | 19 | * |
| 21 | */ | 20 | */ |
| 22 | 21 | ||
| 22 | #ifndef _LINUX_KFIFO_H | ||
| 23 | #define _LINUX_KFIFO_H | ||
| 24 | |||
| 23 | /* | 25 | /* |
| 24 | * Howto porting drivers to the new generic fifo API: | 26 | * How to porting drivers to the new generic FIFO API: |
| 25 | * | 27 | * |
| 26 | * - Modify the declaration of the "struct kfifo *" object into a | 28 | * - Modify the declaration of the "struct kfifo *" object into a |
| 27 | * in-place "struct kfifo" object | 29 | * in-place "struct kfifo" object |
| @@ -30,586 +32,813 @@ | |||
| 30 | * passed as the first argument to this functions | 32 | * passed as the first argument to this functions |
| 31 | * - Replace the use of __kfifo_put into kfifo_in and __kfifo_get | 33 | * - Replace the use of __kfifo_put into kfifo_in and __kfifo_get |
| 32 | * into kfifo_out | 34 | * into kfifo_out |
| 33 | * - Replace the use of kfifo_put into kfifo_in_locked and kfifo_get | 35 | * - Replace the use of kfifo_put into kfifo_in_spinlocked and kfifo_get |
| 34 | * into kfifo_out_locked | 36 | * into kfifo_out_spinlocked |
| 35 | * Note: the spinlock pointer formerly passed to kfifo_init/kfifo_alloc | 37 | * Note: the spinlock pointer formerly passed to kfifo_init/kfifo_alloc |
| 36 | * must be passed now to the kfifo_in_locked and kfifo_out_locked | 38 | * must be passed now to the kfifo_in_spinlocked and kfifo_out_spinlocked |
| 37 | * as the last parameter. | 39 | * as the last parameter |
| 38 | * - All formerly name __kfifo_* functions has been renamed into kfifo_* | 40 | * - The formerly __kfifo_* functions are renamed into kfifo_* |
| 39 | */ | 41 | */ |
| 40 | 42 | ||
| 41 | #ifndef _LINUX_KFIFO_H | 43 | /* |
| 42 | #define _LINUX_KFIFO_H | 44 | * Note about locking : There is no locking required until only * one reader |
| 45 | * and one writer is using the fifo and no kfifo_reset() will be * called | ||
| 46 | * kfifo_reset_out() can be safely used, until it will be only called | ||
| 47 | * in the reader thread. | ||
| 48 | * For multiple writer and one reader there is only a need to lock the writer. | ||
| 49 | * And vice versa for only one writer and multiple reader there is only a need | ||
| 50 | * to lock the reader. | ||
| 51 | */ | ||
| 43 | 52 | ||
| 44 | #include <linux/kernel.h> | 53 | #include <linux/kernel.h> |
| 45 | #include <linux/spinlock.h> | 54 | #include <linux/spinlock.h> |
| 46 | 55 | #include <linux/stddef.h> | |
| 47 | struct kfifo { | 56 | #include <linux/scatterlist.h> |
| 48 | unsigned char *buffer; /* the buffer holding the data */ | 57 | |
| 49 | unsigned int size; /* the size of the allocated buffer */ | 58 | struct __kfifo { |
| 50 | unsigned int in; /* data is added at offset (in % size) */ | 59 | unsigned int in; |
| 51 | unsigned int out; /* data is extracted from off. (out % size) */ | 60 | unsigned int out; |
| 61 | unsigned int mask; | ||
| 62 | unsigned int esize; | ||
| 63 | void *data; | ||
| 52 | }; | 64 | }; |
| 53 | 65 | ||
| 54 | /* | 66 | #define __STRUCT_KFIFO_COMMON(datatype, recsize, ptrtype) \ |
| 55 | * Macros for declaration and initialization of the kfifo datatype | 67 | union { \ |
| 56 | */ | 68 | struct __kfifo kfifo; \ |
| 57 | 69 | datatype *type; \ | |
| 58 | /* helper macro */ | 70 | char (*rectype)[recsize]; \ |
| 59 | #define __kfifo_initializer(s, b) \ | 71 | ptrtype *ptr; \ |
| 60 | (struct kfifo) { \ | 72 | const ptrtype *ptr_const; \ |
| 61 | .size = s, \ | ||
| 62 | .in = 0, \ | ||
| 63 | .out = 0, \ | ||
| 64 | .buffer = b \ | ||
| 65 | } | 73 | } |
| 66 | 74 | ||
| 67 | /** | 75 | #define __STRUCT_KFIFO(type, size, recsize, ptrtype) \ |
| 68 | * DECLARE_KFIFO - macro to declare a kfifo and the associated buffer | 76 | { \ |
| 69 | * @name: name of the declared kfifo datatype | 77 | __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \ |
| 70 | * @size: size of the fifo buffer. Must be a power of two. | 78 | type buf[((size < 2) || (size & (size - 1))) ? -1 : size]; \ |
| 71 | * | ||
| 72 | * Note1: the macro can be used inside struct or union declaration | ||
| 73 | * Note2: the macro creates two objects: | ||
| 74 | * A kfifo object with the given name and a buffer for the kfifo | ||
| 75 | * object named name##kfifo_buffer | ||
| 76 | */ | ||
| 77 | #define DECLARE_KFIFO(name, size) \ | ||
| 78 | union { \ | ||
| 79 | struct kfifo name; \ | ||
| 80 | unsigned char name##kfifo_buffer[size + sizeof(struct kfifo)]; \ | ||
| 81 | } | 79 | } |
| 82 | 80 | ||
| 83 | /** | 81 | #define STRUCT_KFIFO(type, size) \ |
| 84 | * INIT_KFIFO - Initialize a kfifo declared by DECLARE_KFIFO | 82 | struct __STRUCT_KFIFO(type, size, 0, type) |
| 85 | * @name: name of the declared kfifo datatype | 83 | |
| 84 | #define __STRUCT_KFIFO_PTR(type, recsize, ptrtype) \ | ||
| 85 | { \ | ||
| 86 | __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \ | ||
| 87 | type buf[0]; \ | ||
| 88 | } | ||
| 89 | |||
| 90 | #define STRUCT_KFIFO_PTR(type) \ | ||
| 91 | struct __STRUCT_KFIFO_PTR(type, 0, type) | ||
| 92 | |||
| 93 | /* | ||
| 94 | * define compatibility "struct kfifo" for dynamic allocated fifos | ||
| 86 | */ | 95 | */ |
| 87 | #define INIT_KFIFO(name) \ | 96 | struct kfifo __STRUCT_KFIFO_PTR(unsigned char, 0, void); |
| 88 | name = __kfifo_initializer(sizeof(name##kfifo_buffer) - \ | ||
| 89 | sizeof(struct kfifo), \ | ||
| 90 | name##kfifo_buffer + sizeof(struct kfifo)) | ||
| 91 | 97 | ||
| 92 | /** | 98 | #define STRUCT_KFIFO_REC_1(size) \ |
| 93 | * DEFINE_KFIFO - macro to define and initialize a kfifo | 99 | struct __STRUCT_KFIFO(unsigned char, size, 1, void) |
| 94 | * @name: name of the declared kfifo datatype | 100 | |
| 95 | * @size: size of the fifo buffer. Must be a power of two. | 101 | #define STRUCT_KFIFO_REC_2(size) \ |
| 96 | * | 102 | struct __STRUCT_KFIFO(unsigned char, size, 2, void) |
| 97 | * Note1: the macro can be used for global and local kfifo data type variables | 103 | |
| 98 | * Note2: the macro creates two objects: | 104 | /* |
| 99 | * A kfifo object with the given name and a buffer for the kfifo | 105 | * define kfifo_rec types |
| 100 | * object named name##kfifo_buffer | ||
| 101 | */ | 106 | */ |
| 102 | #define DEFINE_KFIFO(name, size) \ | 107 | struct kfifo_rec_ptr_1 __STRUCT_KFIFO_PTR(unsigned char, 1, void); |
| 103 | unsigned char name##kfifo_buffer[size]; \ | 108 | struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void); |
| 104 | struct kfifo name = __kfifo_initializer(size, name##kfifo_buffer) | ||
| 105 | 109 | ||
| 106 | extern void kfifo_init(struct kfifo *fifo, void *buffer, | 110 | /* |
| 107 | unsigned int size); | 111 | * helper macro to distinguish between real in place fifo where the fifo |
| 108 | extern __must_check int kfifo_alloc(struct kfifo *fifo, unsigned int size, | 112 | * array is a part of the structure and the fifo type where the array is |
| 109 | gfp_t gfp_mask); | 113 | * outside of the fifo structure. |
| 110 | extern void kfifo_free(struct kfifo *fifo); | 114 | */ |
| 111 | extern unsigned int kfifo_in(struct kfifo *fifo, | 115 | #define __is_kfifo_ptr(fifo) (sizeof(*fifo) == sizeof(struct __kfifo)) |
| 112 | const void *from, unsigned int len); | ||
| 113 | extern __must_check unsigned int kfifo_out(struct kfifo *fifo, | ||
| 114 | void *to, unsigned int len); | ||
| 115 | extern __must_check unsigned int kfifo_out_peek(struct kfifo *fifo, | ||
| 116 | void *to, unsigned int len, unsigned offset); | ||
| 117 | 116 | ||
| 118 | /** | 117 | /** |
| 119 | * kfifo_initialized - Check if kfifo is initialized. | 118 | * DECLARE_KFIFO_PTR - macro to declare a fifo pointer object |
| 120 | * @fifo: fifo to check | 119 | * @fifo: name of the declared fifo |
| 121 | * Return %true if FIFO is initialized, otherwise %false. | 120 | * @type: type of the fifo elements |
| 122 | * Assumes the fifo was 0 before. | ||
| 123 | */ | 121 | */ |
| 124 | static inline bool kfifo_initialized(struct kfifo *fifo) | 122 | #define DECLARE_KFIFO_PTR(fifo, type) STRUCT_KFIFO_PTR(type) fifo |
| 125 | { | ||
| 126 | return fifo->buffer != NULL; | ||
| 127 | } | ||
| 128 | 123 | ||
| 129 | /** | 124 | /** |
| 130 | * kfifo_reset - removes the entire FIFO contents | 125 | * DECLARE_KFIFO - macro to declare a fifo object |
| 131 | * @fifo: the fifo to be emptied. | 126 | * @fifo: name of the declared fifo |
| 127 | * @type: type of the fifo elements | ||
| 128 | * @size: the number of elements in the fifo, this must be a power of 2 | ||
| 132 | */ | 129 | */ |
| 133 | static inline void kfifo_reset(struct kfifo *fifo) | 130 | #define DECLARE_KFIFO(fifo, type, size) STRUCT_KFIFO(type, size) fifo |
| 134 | { | ||
| 135 | fifo->in = fifo->out = 0; | ||
| 136 | } | ||
| 137 | 131 | ||
| 138 | /** | 132 | /** |
| 139 | * kfifo_reset_out - skip FIFO contents | 133 | * INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO |
| 140 | * @fifo: the fifo to be emptied. | 134 | * @fifo: name of the declared fifo datatype |
| 141 | */ | 135 | */ |
| 142 | static inline void kfifo_reset_out(struct kfifo *fifo) | 136 | #define INIT_KFIFO(fifo) \ |
| 143 | { | 137 | (void)({ \ |
| 144 | smp_mb(); | 138 | typeof(&(fifo)) __tmp = &(fifo); \ |
| 145 | fifo->out = fifo->in; | 139 | struct __kfifo *__kfifo = &__tmp->kfifo; \ |
| 146 | } | 140 | __kfifo->in = 0; \ |
| 141 | __kfifo->out = 0; \ | ||
| 142 | __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : ARRAY_SIZE(__tmp->buf) - 1;\ | ||
| 143 | __kfifo->esize = sizeof(*__tmp->buf); \ | ||
| 144 | __kfifo->data = __is_kfifo_ptr(__tmp) ? NULL : __tmp->buf; \ | ||
| 145 | }) | ||
| 147 | 146 | ||
| 148 | /** | 147 | /** |
| 149 | * kfifo_size - returns the size of the fifo in bytes | 148 | * DEFINE_KFIFO - macro to define and initialize a fifo |
| 150 | * @fifo: the fifo to be used. | 149 | * @fifo: name of the declared fifo datatype |
| 151 | */ | 150 | * @type: type of the fifo elements |
| 152 | static inline __must_check unsigned int kfifo_size(struct kfifo *fifo) | 151 | * @size: the number of elements in the fifo, this must be a power of 2 |
| 152 | * | ||
| 153 | * Note: the macro can be used for global and local fifo data type variables. | ||
| 154 | */ | ||
| 155 | #define DEFINE_KFIFO(fifo, type, size) \ | ||
| 156 | DECLARE_KFIFO(fifo, type, size) = \ | ||
| 157 | (typeof(fifo)) { \ | ||
| 158 | { \ | ||
| 159 | { \ | ||
| 160 | .in = 0, \ | ||
| 161 | .out = 0, \ | ||
| 162 | .mask = __is_kfifo_ptr(&(fifo)) ? \ | ||
| 163 | 0 : \ | ||
| 164 | ARRAY_SIZE((fifo).buf) - 1, \ | ||
| 165 | .esize = sizeof(*(fifo).buf), \ | ||
| 166 | .data = __is_kfifo_ptr(&(fifo)) ? \ | ||
| 167 | NULL : \ | ||
| 168 | (fifo).buf, \ | ||
| 169 | } \ | ||
| 170 | } \ | ||
| 171 | } | ||
| 172 | |||
| 173 | |||
| 174 | static inline unsigned int __must_check | ||
| 175 | __kfifo_must_check_helper(unsigned int val) | ||
| 153 | { | 176 | { |
| 154 | return fifo->size; | 177 | return val; |
| 155 | } | 178 | } |
| 156 | 179 | ||
| 157 | /** | 180 | /** |
| 158 | * kfifo_len - returns the number of used bytes in the FIFO | 181 | * kfifo_initialized - Check if the fifo is initialized |
| 159 | * @fifo: the fifo to be used. | 182 | * @fifo: address of the fifo to check |
| 183 | * | ||
| 184 | * Return %true if fifo is initialized, otherwise %false. | ||
| 185 | * Assumes the fifo was 0 before. | ||
| 160 | */ | 186 | */ |
| 161 | static inline unsigned int kfifo_len(struct kfifo *fifo) | 187 | #define kfifo_initialized(fifo) ((fifo)->kfifo.mask) |
| 162 | { | ||
| 163 | register unsigned int out; | ||
| 164 | |||
| 165 | out = fifo->out; | ||
| 166 | smp_rmb(); | ||
| 167 | return fifo->in - out; | ||
| 168 | } | ||
| 169 | 188 | ||
| 170 | /** | 189 | /** |
| 171 | * kfifo_is_empty - returns true if the fifo is empty | 190 | * kfifo_esize - returns the size of the element managed by the fifo |
| 172 | * @fifo: the fifo to be used. | 191 | * @fifo: address of the fifo to be used |
| 173 | */ | 192 | */ |
| 174 | static inline __must_check int kfifo_is_empty(struct kfifo *fifo) | 193 | #define kfifo_esize(fifo) ((fifo)->kfifo.esize) |
| 175 | { | ||
| 176 | return fifo->in == fifo->out; | ||
| 177 | } | ||
| 178 | 194 | ||
| 179 | /** | 195 | /** |
| 180 | * kfifo_is_full - returns true if the fifo is full | 196 | * kfifo_recsize - returns the size of the record length field |
| 181 | * @fifo: the fifo to be used. | 197 | * @fifo: address of the fifo to be used |
| 182 | */ | 198 | */ |
| 183 | static inline __must_check int kfifo_is_full(struct kfifo *fifo) | 199 | #define kfifo_recsize(fifo) (sizeof(*(fifo)->rectype)) |
| 184 | { | ||
| 185 | return kfifo_len(fifo) == kfifo_size(fifo); | ||
| 186 | } | ||
| 187 | 200 | ||
| 188 | /** | 201 | /** |
| 189 | * kfifo_avail - returns the number of bytes available in the FIFO | 202 | * kfifo_size - returns the size of the fifo in elements |
| 190 | * @fifo: the fifo to be used. | 203 | * @fifo: address of the fifo to be used |
| 191 | */ | 204 | */ |
| 192 | static inline __must_check unsigned int kfifo_avail(struct kfifo *fifo) | 205 | #define kfifo_size(fifo) ((fifo)->kfifo.mask + 1) |
| 193 | { | ||
| 194 | return kfifo_size(fifo) - kfifo_len(fifo); | ||
| 195 | } | ||
| 196 | 206 | ||
| 197 | /** | 207 | /** |
| 198 | * kfifo_in_locked - puts some data into the FIFO using a spinlock for locking | 208 | * kfifo_reset - removes the entire fifo content |
| 199 | * @fifo: the fifo to be used. | 209 | * @fifo: address of the fifo to be used |
| 200 | * @from: the data to be added. | ||
| 201 | * @n: the length of the data to be added. | ||
| 202 | * @lock: pointer to the spinlock to use for locking. | ||
| 203 | * | 210 | * |
| 204 | * This function copies at most @n bytes from the @from buffer into | 211 | * Note: usage of kfifo_reset() is dangerous. It should be only called when the |
| 205 | * the FIFO depending on the free space, and returns the number of | 212 | * fifo is exclusived locked or when it is secured that no other thread is |
| 206 | * bytes copied. | 213 | * accessing the fifo. |
| 207 | */ | 214 | */ |
| 208 | static inline unsigned int kfifo_in_locked(struct kfifo *fifo, | 215 | #define kfifo_reset(fifo) \ |
| 209 | const void *from, unsigned int n, spinlock_t *lock) | 216 | (void)({ \ |
| 210 | { | 217 | typeof(fifo + 1) __tmp = (fifo); \ |
| 211 | unsigned long flags; | 218 | __tmp->kfifo.in = __tmp->kfifo.out = 0; \ |
| 212 | unsigned int ret; | 219 | }) |
| 213 | |||
| 214 | spin_lock_irqsave(lock, flags); | ||
| 215 | |||
| 216 | ret = kfifo_in(fifo, from, n); | ||
| 217 | |||
| 218 | spin_unlock_irqrestore(lock, flags); | ||
| 219 | |||
| 220 | return ret; | ||
| 221 | } | ||
| 222 | 220 | ||
| 223 | /** | 221 | /** |
| 224 | * kfifo_out_locked - gets some data from the FIFO using a spinlock for locking | 222 | * kfifo_reset_out - skip fifo content |
| 225 | * @fifo: the fifo to be used. | 223 | * @fifo: address of the fifo to be used |
| 226 | * @to: where the data must be copied. | ||
| 227 | * @n: the size of the destination buffer. | ||
| 228 | * @lock: pointer to the spinlock to use for locking. | ||
| 229 | * | 224 | * |
| 230 | * This function copies at most @n bytes from the FIFO into the | 225 | * Note: The usage of kfifo_reset_out() is safe until it will be only called |
| 231 | * @to buffer and returns the number of copied bytes. | 226 | * from the reader thread and there is only one concurrent reader. Otherwise |
| 232 | */ | 227 | * it is dangerous and must be handled in the same way as kfifo_reset(). |
| 233 | static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo, | ||
| 234 | void *to, unsigned int n, spinlock_t *lock) | ||
| 235 | { | ||
| 236 | unsigned long flags; | ||
| 237 | unsigned int ret; | ||
| 238 | |||
| 239 | spin_lock_irqsave(lock, flags); | ||
| 240 | |||
| 241 | ret = kfifo_out(fifo, to, n); | ||
| 242 | |||
| 243 | spin_unlock_irqrestore(lock, flags); | ||
| 244 | |||
| 245 | return ret; | ||
| 246 | } | ||
| 247 | |||
| 248 | extern void kfifo_skip(struct kfifo *fifo, unsigned int len); | ||
| 249 | |||
| 250 | extern __must_check int kfifo_from_user(struct kfifo *fifo, | ||
| 251 | const void __user *from, unsigned int n, unsigned *lenout); | ||
| 252 | |||
| 253 | extern __must_check int kfifo_to_user(struct kfifo *fifo, | ||
| 254 | void __user *to, unsigned int n, unsigned *lenout); | ||
| 255 | |||
| 256 | /* | ||
| 257 | * __kfifo_add_out internal helper function for updating the out offset | ||
| 258 | */ | 228 | */ |
| 259 | static inline void __kfifo_add_out(struct kfifo *fifo, | 229 | #define kfifo_reset_out(fifo) \ |
| 260 | unsigned int off) | 230 | (void)({ \ |
| 261 | { | 231 | typeof(fifo + 1) __tmp = (fifo); \ |
| 262 | smp_mb(); | 232 | __tmp->kfifo.out = __tmp->kfifo.in; \ |
| 263 | fifo->out += off; | 233 | }) |
| 264 | } | ||
| 265 | 234 | ||
| 266 | /* | 235 | /** |
| 267 | * __kfifo_add_in internal helper function for updating the in offset | 236 | * kfifo_len - returns the number of used elements in the fifo |
| 237 | * @fifo: address of the fifo to be used | ||
| 268 | */ | 238 | */ |
| 269 | static inline void __kfifo_add_in(struct kfifo *fifo, | 239 | #define kfifo_len(fifo) \ |
| 270 | unsigned int off) | 240 | ({ \ |
| 271 | { | 241 | typeof(fifo + 1) __tmpl = (fifo); \ |
| 272 | smp_wmb(); | 242 | __tmpl->kfifo.in - __tmpl->kfifo.out; \ |
| 273 | fifo->in += off; | 243 | }) |
| 274 | } | ||
| 275 | 244 | ||
| 276 | /* | 245 | /** |
| 277 | * __kfifo_off internal helper function for calculating the index of a | 246 | * kfifo_is_empty - returns true if the fifo is empty |
| 278 | * given offeset | 247 | * @fifo: address of the fifo to be used |
| 279 | */ | 248 | */ |
| 280 | static inline unsigned int __kfifo_off(struct kfifo *fifo, unsigned int off) | 249 | #define kfifo_is_empty(fifo) \ |
| 281 | { | 250 | ({ \ |
| 282 | return off & (fifo->size - 1); | 251 | typeof(fifo + 1) __tmpq = (fifo); \ |
| 283 | } | 252 | __tmpq->kfifo.in == __tmpq->kfifo.out; \ |
| 253 | }) | ||
| 284 | 254 | ||
| 285 | /* | 255 | /** |
| 286 | * __kfifo_peek_n internal helper function for determinate the length of | 256 | * kfifo_is_full - returns true if the fifo is full |
| 287 | * the next record in the fifo | 257 | * @fifo: address of the fifo to be used |
| 288 | */ | 258 | */ |
| 289 | static inline unsigned int __kfifo_peek_n(struct kfifo *fifo, | 259 | #define kfifo_is_full(fifo) \ |
| 290 | unsigned int recsize) | 260 | ({ \ |
| 291 | { | 261 | typeof(fifo + 1) __tmpq = (fifo); \ |
| 292 | #define __KFIFO_GET(fifo, off, shift) \ | 262 | kfifo_len(__tmpq) > __tmpq->kfifo.mask; \ |
| 293 | ((fifo)->buffer[__kfifo_off((fifo), (fifo)->out+(off))] << (shift)) | 263 | }) |
| 294 | 264 | ||
| 295 | unsigned int l; | 265 | /** |
| 266 | * kfifo_avail - returns the number of unused elements in the fifo | ||
| 267 | * @fifo: address of the fifo to be used | ||
| 268 | */ | ||
| 269 | #define kfifo_avail(fifo) \ | ||
| 270 | __kfifo_must_check_helper( \ | ||
| 271 | ({ \ | ||
| 272 | typeof(fifo + 1) __tmpq = (fifo); \ | ||
| 273 | const size_t __recsize = sizeof(*__tmpq->rectype); \ | ||
| 274 | unsigned int __avail = kfifo_size(__tmpq) - kfifo_len(__tmpq); \ | ||
| 275 | (__recsize) ? ((__avail <= __recsize) ? 0 : \ | ||
| 276 | __kfifo_max_r(__avail - __recsize, __recsize)) : \ | ||
| 277 | __avail; \ | ||
| 278 | }) \ | ||
| 279 | ) | ||
| 296 | 280 | ||
| 297 | l = __KFIFO_GET(fifo, 0, 0); | 281 | /** |
| 282 | * kfifo_skip - skip output data | ||
| 283 | * @fifo: address of the fifo to be used | ||
| 284 | */ | ||
| 285 | #define kfifo_skip(fifo) \ | ||
| 286 | (void)({ \ | ||
| 287 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 288 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 289 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 290 | if (__recsize) \ | ||
| 291 | __kfifo_skip_r(__kfifo, __recsize); \ | ||
| 292 | else \ | ||
| 293 | __kfifo->out++; \ | ||
| 294 | }) | ||
| 298 | 295 | ||
| 299 | if (--recsize) | 296 | /** |
| 300 | l |= __KFIFO_GET(fifo, 1, 8); | 297 | * kfifo_peek_len - gets the size of the next fifo record |
| 298 | * @fifo: address of the fifo to be used | ||
| 299 | * | ||
| 300 | * This function returns the size of the next fifo record in number of bytes. | ||
| 301 | */ | ||
| 302 | #define kfifo_peek_len(fifo) \ | ||
| 303 | __kfifo_must_check_helper( \ | ||
| 304 | ({ \ | ||
| 305 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 306 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 307 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 308 | (!__recsize) ? kfifo_len(__tmp) * sizeof(*__tmp->type) : \ | ||
| 309 | __kfifo_len_r(__kfifo, __recsize); \ | ||
| 310 | }) \ | ||
| 311 | ) | ||
| 301 | 312 | ||
| 302 | return l; | 313 | /** |
| 303 | #undef __KFIFO_GET | 314 | * kfifo_alloc - dynamically allocates a new fifo buffer |
| 304 | } | 315 | * @fifo: pointer to the fifo |
| 316 | * @size: the number of elements in the fifo, this must be a power of 2 | ||
| 317 | * @gfp_mask: get_free_pages mask, passed to kmalloc() | ||
| 318 | * | ||
| 319 | * This macro dynamically allocates a new fifo buffer. | ||
| 320 | * | ||
| 321 | * The numer of elements will be rounded-up to a power of 2. | ||
| 322 | * The fifo will be release with kfifo_free(). | ||
| 323 | * Return 0 if no error, otherwise an error code. | ||
| 324 | */ | ||
| 325 | #define kfifo_alloc(fifo, size, gfp_mask) \ | ||
| 326 | __kfifo_must_check_helper( \ | ||
| 327 | ({ \ | ||
| 328 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 329 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 330 | __is_kfifo_ptr(__tmp) ? \ | ||
| 331 | __kfifo_alloc(__kfifo, size, sizeof(*__tmp->type), gfp_mask) : \ | ||
| 332 | -EINVAL; \ | ||
| 333 | }) \ | ||
| 334 | ) | ||
| 305 | 335 | ||
| 306 | /* | 336 | /** |
| 307 | * __kfifo_poke_n internal helper function for storing the length of | 337 | * kfifo_free - frees the fifo |
| 308 | * the next record into the fifo | 338 | * @fifo: the fifo to be freed |
| 309 | */ | 339 | */ |
| 310 | static inline void __kfifo_poke_n(struct kfifo *fifo, | 340 | #define kfifo_free(fifo) \ |
| 311 | unsigned int recsize, unsigned int n) | 341 | ({ \ |
| 312 | { | 342 | typeof(fifo + 1) __tmp = (fifo); \ |
| 313 | #define __KFIFO_PUT(fifo, off, val, shift) \ | 343 | struct __kfifo *__kfifo = &__tmp->kfifo; \ |
| 314 | ( \ | 344 | if (__is_kfifo_ptr(__tmp)) \ |
| 315 | (fifo)->buffer[__kfifo_off((fifo), (fifo)->in+(off))] = \ | 345 | __kfifo_free(__kfifo); \ |
| 316 | (unsigned char)((val) >> (shift)) \ | 346 | }) |
| 317 | ) | ||
| 318 | 347 | ||
| 319 | __KFIFO_PUT(fifo, 0, n, 0); | 348 | /** |
| 349 | * kfifo_init - initialize a fifo using a preallocated buffer | ||
| 350 | * @fifo: the fifo to assign the buffer | ||
| 351 | * @buffer: the preallocated buffer to be used | ||
| 352 | * @size: the size of the internal buffer, this have to be a power of 2 | ||
| 353 | * | ||
| 354 | * This macro initialize a fifo using a preallocated buffer. | ||
| 355 | * | ||
| 356 | * The numer of elements will be rounded-up to a power of 2. | ||
| 357 | * Return 0 if no error, otherwise an error code. | ||
| 358 | */ | ||
| 359 | #define kfifo_init(fifo, buffer, size) \ | ||
| 360 | ({ \ | ||
| 361 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 362 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 363 | __is_kfifo_ptr(__tmp) ? \ | ||
| 364 | __kfifo_init(__kfifo, buffer, size, sizeof(*__tmp->type)) : \ | ||
| 365 | -EINVAL; \ | ||
| 366 | }) | ||
| 320 | 367 | ||
| 321 | if (--recsize) | 368 | /** |
| 322 | __KFIFO_PUT(fifo, 1, n, 8); | 369 | * kfifo_put - put data into the fifo |
| 323 | #undef __KFIFO_PUT | 370 | * @fifo: address of the fifo to be used |
| 324 | } | 371 | * @val: the data to be added |
| 372 | * | ||
| 373 | * This macro copies the given value into the fifo. | ||
| 374 | * It returns 0 if the fifo was full. Otherwise it returns the number | ||
| 375 | * processed elements. | ||
| 376 | * | ||
| 377 | * Note that with only one concurrent reader and one concurrent | ||
| 378 | * writer, you don't need extra locking to use these macro. | ||
| 379 | */ | ||
| 380 | #define kfifo_put(fifo, val) \ | ||
| 381 | ({ \ | ||
| 382 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 383 | typeof(val + 1) __val = (val); \ | ||
| 384 | unsigned int __ret; \ | ||
| 385 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 386 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 387 | if (0) { \ | ||
| 388 | typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \ | ||
| 389 | __dummy = (typeof(__val))NULL; \ | ||
| 390 | } \ | ||
| 391 | if (__recsize) \ | ||
| 392 | __ret = __kfifo_in_r(__kfifo, __val, sizeof(*__val), \ | ||
| 393 | __recsize); \ | ||
| 394 | else { \ | ||
| 395 | __ret = !kfifo_is_full(__tmp); \ | ||
| 396 | if (__ret) { \ | ||
| 397 | (__is_kfifo_ptr(__tmp) ? \ | ||
| 398 | ((typeof(__tmp->type))__kfifo->data) : \ | ||
| 399 | (__tmp->buf) \ | ||
| 400 | )[__kfifo->in & __tmp->kfifo.mask] = \ | ||
| 401 | *(typeof(__tmp->type))__val; \ | ||
| 402 | smp_wmb(); \ | ||
| 403 | __kfifo->in++; \ | ||
| 404 | } \ | ||
| 405 | } \ | ||
| 406 | __ret; \ | ||
| 407 | }) | ||
| 325 | 408 | ||
| 326 | /* | 409 | /** |
| 327 | * __kfifo_in_... internal functions for put date into the fifo | 410 | * kfifo_get - get data from the fifo |
| 328 | * do not call it directly, use kfifo_in_rec() instead | 411 | * @fifo: address of the fifo to be used |
| 329 | */ | 412 | * @val: the var where to store the data to be added |
| 330 | extern unsigned int __kfifo_in_n(struct kfifo *fifo, | 413 | * |
| 331 | const void *from, unsigned int n, unsigned int recsize); | 414 | * This macro reads the data from the fifo. |
| 415 | * It returns 0 if the fifo was empty. Otherwise it returns the number | ||
| 416 | * processed elements. | ||
| 417 | * | ||
| 418 | * Note that with only one concurrent reader and one concurrent | ||
| 419 | * writer, you don't need extra locking to use these macro. | ||
| 420 | */ | ||
| 421 | #define kfifo_get(fifo, val) \ | ||
| 422 | __kfifo_must_check_helper( \ | ||
| 423 | ({ \ | ||
| 424 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 425 | typeof(val + 1) __val = (val); \ | ||
| 426 | unsigned int __ret; \ | ||
| 427 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 428 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 429 | if (0) \ | ||
| 430 | __val = (typeof(__tmp->ptr))0; \ | ||
| 431 | if (__recsize) \ | ||
| 432 | __ret = __kfifo_out_r(__kfifo, __val, sizeof(*__val), \ | ||
| 433 | __recsize); \ | ||
| 434 | else { \ | ||
| 435 | __ret = !kfifo_is_empty(__tmp); \ | ||
| 436 | if (__ret) { \ | ||
| 437 | *(typeof(__tmp->type))__val = \ | ||
| 438 | (__is_kfifo_ptr(__tmp) ? \ | ||
| 439 | ((typeof(__tmp->type))__kfifo->data) : \ | ||
| 440 | (__tmp->buf) \ | ||
| 441 | )[__kfifo->out & __tmp->kfifo.mask]; \ | ||
| 442 | smp_wmb(); \ | ||
| 443 | __kfifo->out++; \ | ||
| 444 | } \ | ||
| 445 | } \ | ||
| 446 | __ret; \ | ||
| 447 | }) \ | ||
| 448 | ) | ||
| 332 | 449 | ||
| 333 | extern unsigned int __kfifo_in_generic(struct kfifo *fifo, | 450 | /** |
| 334 | const void *from, unsigned int n, unsigned int recsize); | 451 | * kfifo_peek - get data from the fifo without removing |
| 452 | * @fifo: address of the fifo to be used | ||
| 453 | * @val: the var where to store the data to be added | ||
| 454 | * | ||
| 455 | * This reads the data from the fifo without removing it from the fifo. | ||
| 456 | * It returns 0 if the fifo was empty. Otherwise it returns the number | ||
| 457 | * processed elements. | ||
| 458 | * | ||
| 459 | * Note that with only one concurrent reader and one concurrent | ||
| 460 | * writer, you don't need extra locking to use these macro. | ||
| 461 | */ | ||
| 462 | #define kfifo_peek(fifo, val) \ | ||
| 463 | __kfifo_must_check_helper( \ | ||
| 464 | ({ \ | ||
| 465 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 466 | typeof(val + 1) __val = (val); \ | ||
| 467 | unsigned int __ret; \ | ||
| 468 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 469 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 470 | if (0) \ | ||
| 471 | __val = (typeof(__tmp->ptr))NULL; \ | ||
| 472 | if (__recsize) \ | ||
| 473 | __ret = __kfifo_out_peek_r(__kfifo, __val, sizeof(*__val), \ | ||
| 474 | __recsize); \ | ||
| 475 | else { \ | ||
| 476 | __ret = !kfifo_is_empty(__tmp); \ | ||
| 477 | if (__ret) { \ | ||
| 478 | *(typeof(__tmp->type))__val = \ | ||
| 479 | (__is_kfifo_ptr(__tmp) ? \ | ||
| 480 | ((typeof(__tmp->type))__kfifo->data) : \ | ||
| 481 | (__tmp->buf) \ | ||
| 482 | )[__kfifo->out & __tmp->kfifo.mask]; \ | ||
| 483 | smp_wmb(); \ | ||
| 484 | } \ | ||
| 485 | } \ | ||
| 486 | __ret; \ | ||
| 487 | }) \ | ||
| 488 | ) | ||
| 335 | 489 | ||
| 336 | static inline unsigned int __kfifo_in_rec(struct kfifo *fifo, | 490 | /** |
| 337 | const void *from, unsigned int n, unsigned int recsize) | 491 | * kfifo_in - put data into the fifo |
| 338 | { | 492 | * @fifo: address of the fifo to be used |
| 339 | unsigned int ret; | 493 | * @buf: the data to be added |
| 494 | * @n: number of elements to be added | ||
| 495 | * | ||
| 496 | * This macro copies the given buffer into the fifo and returns the | ||
| 497 | * number of copied elements. | ||
| 498 | * | ||
| 499 | * Note that with only one concurrent reader and one concurrent | ||
| 500 | * writer, you don't need extra locking to use these macro. | ||
| 501 | */ | ||
| 502 | #define kfifo_in(fifo, buf, n) \ | ||
| 503 | ({ \ | ||
| 504 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 505 | typeof(buf + 1) __buf = (buf); \ | ||
| 506 | unsigned long __n = (n); \ | ||
| 507 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 508 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 509 | if (0) { \ | ||
| 510 | typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \ | ||
| 511 | __dummy = (typeof(__buf))NULL; \ | ||
| 512 | } \ | ||
| 513 | (__recsize) ?\ | ||
| 514 | __kfifo_in_r(__kfifo, __buf, __n, __recsize) : \ | ||
| 515 | __kfifo_in(__kfifo, __buf, __n); \ | ||
| 516 | }) | ||
| 340 | 517 | ||
| 341 | ret = __kfifo_in_n(fifo, from, n, recsize); | 518 | /** |
| 519 | * kfifo_in_spinlocked - put data into the fifo using a spinlock for locking | ||
| 520 | * @fifo: address of the fifo to be used | ||
| 521 | * @buf: the data to be added | ||
| 522 | * @n: number of elements to be added | ||
| 523 | * @lock: pointer to the spinlock to use for locking | ||
| 524 | * | ||
| 525 | * This macro copies the given values buffer into the fifo and returns the | ||
| 526 | * number of copied elements. | ||
| 527 | */ | ||
| 528 | #define kfifo_in_spinlocked(fifo, buf, n, lock) \ | ||
| 529 | ({ \ | ||
| 530 | unsigned long __flags; \ | ||
| 531 | unsigned int __ret; \ | ||
| 532 | spin_lock_irqsave(lock, __flags); \ | ||
| 533 | __ret = kfifo_in(fifo, buf, n); \ | ||
| 534 | spin_unlock_irqrestore(lock, __flags); \ | ||
| 535 | __ret; \ | ||
| 536 | }) | ||
| 537 | |||
| 538 | /* alias for kfifo_in_spinlocked, will be removed in a future release */ | ||
| 539 | #define kfifo_in_locked(fifo, buf, n, lock) \ | ||
| 540 | kfifo_in_spinlocked(fifo, buf, n, lock) | ||
| 342 | 541 | ||
| 343 | if (likely(ret == 0)) { | 542 | /** |
| 344 | if (recsize) | 543 | * kfifo_out - get data from the fifo |
| 345 | __kfifo_poke_n(fifo, recsize, n); | 544 | * @fifo: address of the fifo to be used |
| 346 | __kfifo_add_in(fifo, n + recsize); | 545 | * @buf: pointer to the storage buffer |
| 347 | } | 546 | * @n: max. number of elements to get |
| 348 | return ret; | 547 | * |
| 349 | } | 548 | * This macro get some data from the fifo and return the numbers of elements |
| 549 | * copied. | ||
| 550 | * | ||
| 551 | * Note that with only one concurrent reader and one concurrent | ||
| 552 | * writer, you don't need extra locking to use these macro. | ||
| 553 | */ | ||
| 554 | #define kfifo_out(fifo, buf, n) \ | ||
| 555 | __kfifo_must_check_helper( \ | ||
| 556 | ({ \ | ||
| 557 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 558 | typeof(buf + 1) __buf = (buf); \ | ||
| 559 | unsigned long __n = (n); \ | ||
| 560 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 561 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 562 | if (0) { \ | ||
| 563 | typeof(__tmp->ptr) __dummy = NULL; \ | ||
| 564 | __buf = __dummy; \ | ||
| 565 | } \ | ||
| 566 | (__recsize) ?\ | ||
| 567 | __kfifo_out_r(__kfifo, __buf, __n, __recsize) : \ | ||
| 568 | __kfifo_out(__kfifo, __buf, __n); \ | ||
| 569 | }) \ | ||
| 570 | ) | ||
| 571 | |||
| 572 | /** | ||
| 573 | * kfifo_out_spinlocked - get data from the fifo using a spinlock for locking | ||
| 574 | * @fifo: address of the fifo to be used | ||
| 575 | * @buf: pointer to the storage buffer | ||
| 576 | * @n: max. number of elements to get | ||
| 577 | * @lock: pointer to the spinlock to use for locking | ||
| 578 | * | ||
| 579 | * This macro get the data from the fifo and return the numbers of elements | ||
| 580 | * copied. | ||
| 581 | */ | ||
| 582 | #define kfifo_out_spinlocked(fifo, buf, n, lock) \ | ||
| 583 | __kfifo_must_check_helper( \ | ||
| 584 | ({ \ | ||
| 585 | unsigned long __flags; \ | ||
| 586 | unsigned int __ret; \ | ||
| 587 | spin_lock_irqsave(lock, __flags); \ | ||
| 588 | __ret = kfifo_out(fifo, buf, n); \ | ||
| 589 | spin_unlock_irqrestore(lock, __flags); \ | ||
| 590 | __ret; \ | ||
| 591 | }) \ | ||
| 592 | ) | ||
| 593 | |||
| 594 | /* alias for kfifo_out_spinlocked, will be removed in a future release */ | ||
| 595 | #define kfifo_out_locked(fifo, buf, n, lock) \ | ||
| 596 | kfifo_out_spinlocked(fifo, buf, n, lock) | ||
| 350 | 597 | ||
| 351 | /** | 598 | /** |
| 352 | * kfifo_in_rec - puts some record data into the FIFO | 599 | * kfifo_from_user - puts some data from user space into the fifo |
| 353 | * @fifo: the fifo to be used. | 600 | * @fifo: address of the fifo to be used |
| 354 | * @from: the data to be added. | 601 | * @from: pointer to the data to be added |
| 355 | * @n: the length of the data to be added. | 602 | * @len: the length of the data to be added |
| 356 | * @recsize: size of record field | 603 | * @copied: pointer to output variable to store the number of copied bytes |
| 357 | * | 604 | * |
| 358 | * This function copies @n bytes from the @from into the FIFO and returns | 605 | * This macro copies at most @len bytes from the @from into the |
| 359 | * the number of bytes which cannot be copied. | 606 | * fifo, depending of the available space and returns -EFAULT/0. |
| 360 | * A returned value greater than the @n value means that the record doesn't | ||
| 361 | * fit into the buffer. | ||
| 362 | * | 607 | * |
| 363 | * Note that with only one concurrent reader and one concurrent | 608 | * Note that with only one concurrent reader and one concurrent |
| 364 | * writer, you don't need extra locking to use these functions. | 609 | * writer, you don't need extra locking to use these macro. |
| 365 | */ | 610 | */ |
| 366 | static inline __must_check unsigned int kfifo_in_rec(struct kfifo *fifo, | 611 | #define kfifo_from_user(fifo, from, len, copied) \ |
| 367 | void *from, unsigned int n, unsigned int recsize) | 612 | __kfifo_must_check_helper( \ |
| 368 | { | 613 | ({ \ |
| 369 | if (!__builtin_constant_p(recsize)) | 614 | typeof(fifo + 1) __tmp = (fifo); \ |
| 370 | return __kfifo_in_generic(fifo, from, n, recsize); | 615 | const void __user *__from = (from); \ |
| 371 | return __kfifo_in_rec(fifo, from, n, recsize); | 616 | unsigned int __len = (len); \ |
| 372 | } | 617 | unsigned int *__copied = (copied); \ |
| 618 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 619 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 620 | (__recsize) ? \ | ||
| 621 | __kfifo_from_user_r(__kfifo, __from, __len, __copied, __recsize) : \ | ||
| 622 | __kfifo_from_user(__kfifo, __from, __len, __copied); \ | ||
| 623 | }) \ | ||
| 624 | ) | ||
| 373 | 625 | ||
| 374 | /* | 626 | /** |
| 375 | * __kfifo_out_... internal functions for get date from the fifo | 627 | * kfifo_to_user - copies data from the fifo into user space |
| 376 | * do not call it directly, use kfifo_out_rec() instead | 628 | * @fifo: address of the fifo to be used |
| 377 | */ | 629 | * @to: where the data must be copied |
| 378 | extern unsigned int __kfifo_out_n(struct kfifo *fifo, | 630 | * @len: the size of the destination buffer |
| 379 | void *to, unsigned int reclen, unsigned int recsize); | 631 | * @copied: pointer to output variable to store the number of copied bytes |
| 632 | * | ||
| 633 | * This macro copies at most @len bytes from the fifo into the | ||
| 634 | * @to buffer and returns -EFAULT/0. | ||
| 635 | * | ||
| 636 | * Note that with only one concurrent reader and one concurrent | ||
| 637 | * writer, you don't need extra locking to use these macro. | ||
| 638 | */ | ||
| 639 | #define kfifo_to_user(fifo, to, len, copied) \ | ||
| 640 | __kfifo_must_check_helper( \ | ||
| 641 | ({ \ | ||
| 642 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 643 | void __user *__to = (to); \ | ||
| 644 | unsigned int __len = (len); \ | ||
| 645 | unsigned int *__copied = (copied); \ | ||
| 646 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 647 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 648 | (__recsize) ? \ | ||
| 649 | __kfifo_to_user_r(__kfifo, __to, __len, __copied, __recsize) : \ | ||
| 650 | __kfifo_to_user(__kfifo, __to, __len, __copied); \ | ||
| 651 | }) \ | ||
| 652 | ) | ||
| 653 | |||
| 654 | /** | ||
| 655 | * kfifo_dma_in_prepare - setup a scatterlist for DMA input | ||
| 656 | * @fifo: address of the fifo to be used | ||
| 657 | * @sgl: pointer to the scatterlist array | ||
| 658 | * @nents: number of entries in the scatterlist array | ||
| 659 | * @len: number of elements to transfer | ||
| 660 | * | ||
| 661 | * This macro fills a scatterlist for DMA input. | ||
| 662 | * It returns the number entries in the scatterlist array. | ||
| 663 | * | ||
| 664 | * Note that with only one concurrent reader and one concurrent | ||
| 665 | * writer, you don't need extra locking to use these macros. | ||
| 666 | */ | ||
| 667 | #define kfifo_dma_in_prepare(fifo, sgl, nents, len) \ | ||
| 668 | ({ \ | ||
| 669 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 670 | struct scatterlist *__sgl = (sgl); \ | ||
| 671 | int __nents = (nents); \ | ||
| 672 | unsigned int __len = (len); \ | ||
| 673 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 674 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 675 | (__recsize) ? \ | ||
| 676 | __kfifo_dma_in_prepare_r(__kfifo, __sgl, __nents, __len, __recsize) : \ | ||
| 677 | __kfifo_dma_in_prepare(__kfifo, __sgl, __nents, __len); \ | ||
| 678 | }) | ||
| 380 | 679 | ||
| 381 | extern unsigned int __kfifo_out_generic(struct kfifo *fifo, | 680 | /** |
| 382 | void *to, unsigned int n, | 681 | * kfifo_dma_in_finish - finish a DMA IN operation |
| 383 | unsigned int recsize, unsigned int *total); | 682 | * @fifo: address of the fifo to be used |
| 683 | * @len: number of bytes to received | ||
| 684 | * | ||
| 685 | * This macro finish a DMA IN operation. The in counter will be updated by | ||
| 686 | * the len parameter. No error checking will be done. | ||
| 687 | * | ||
| 688 | * Note that with only one concurrent reader and one concurrent | ||
| 689 | * writer, you don't need extra locking to use these macros. | ||
| 690 | */ | ||
| 691 | #define kfifo_dma_in_finish(fifo, len) \ | ||
| 692 | (void)({ \ | ||
| 693 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 694 | unsigned int __len = (len); \ | ||
| 695 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 696 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 697 | if (__recsize) \ | ||
| 698 | __kfifo_dma_in_finish_r(__kfifo, __len, __recsize); \ | ||
| 699 | else \ | ||
| 700 | __kfifo->in += __len / sizeof(*__tmp->type); \ | ||
| 701 | }) | ||
| 384 | 702 | ||
| 385 | static inline unsigned int __kfifo_out_rec(struct kfifo *fifo, | 703 | /** |
| 386 | void *to, unsigned int n, unsigned int recsize, | 704 | * kfifo_dma_out_prepare - setup a scatterlist for DMA output |
| 387 | unsigned int *total) | 705 | * @fifo: address of the fifo to be used |
| 388 | { | 706 | * @sgl: pointer to the scatterlist array |
| 389 | unsigned int l; | 707 | * @nents: number of entries in the scatterlist array |
| 390 | 708 | * @len: number of elements to transfer | |
| 391 | if (!recsize) { | 709 | * |
| 392 | l = n; | 710 | * This macro fills a scatterlist for DMA output which at most @len bytes |
| 393 | if (total) | 711 | * to transfer. |
| 394 | *total = l; | 712 | * It returns the number entries in the scatterlist array. |
| 395 | } else { | 713 | * A zero means there is no space available and the scatterlist is not filled. |
| 396 | l = __kfifo_peek_n(fifo, recsize); | 714 | * |
| 397 | if (total) | 715 | * Note that with only one concurrent reader and one concurrent |
| 398 | *total = l; | 716 | * writer, you don't need extra locking to use these macros. |
| 399 | if (n < l) | 717 | */ |
| 400 | return l; | 718 | #define kfifo_dma_out_prepare(fifo, sgl, nents, len) \ |
| 401 | } | 719 | ({ \ |
| 720 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 721 | struct scatterlist *__sgl = (sgl); \ | ||
| 722 | int __nents = (nents); \ | ||
| 723 | unsigned int __len = (len); \ | ||
| 724 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 725 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 726 | (__recsize) ? \ | ||
| 727 | __kfifo_dma_out_prepare_r(__kfifo, __sgl, __nents, __len, __recsize) : \ | ||
| 728 | __kfifo_dma_out_prepare(__kfifo, __sgl, __nents, __len); \ | ||
| 729 | }) | ||
| 402 | 730 | ||
| 403 | return __kfifo_out_n(fifo, to, l, recsize); | 731 | /** |
| 404 | } | 732 | * kfifo_dma_out_finish - finish a DMA OUT operation |
| 733 | * @fifo: address of the fifo to be used | ||
| 734 | * @len: number of bytes transferd | ||
| 735 | * | ||
| 736 | * This macro finish a DMA OUT operation. The out counter will be updated by | ||
| 737 | * the len parameter. No error checking will be done. | ||
| 738 | * | ||
| 739 | * Note that with only one concurrent reader and one concurrent | ||
| 740 | * writer, you don't need extra locking to use these macros. | ||
| 741 | */ | ||
| 742 | #define kfifo_dma_out_finish(fifo, len) \ | ||
| 743 | (void)({ \ | ||
| 744 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 745 | unsigned int __len = (len); \ | ||
| 746 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 747 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 748 | if (__recsize) \ | ||
| 749 | __kfifo_dma_out_finish_r(__kfifo, __recsize); \ | ||
| 750 | else \ | ||
| 751 | __kfifo->out += __len / sizeof(*__tmp->type); \ | ||
| 752 | }) | ||
| 405 | 753 | ||
| 406 | /** | 754 | /** |
| 407 | * kfifo_out_rec - gets some record data from the FIFO | 755 | * kfifo_out_peek - gets some data from the fifo |
| 408 | * @fifo: the fifo to be used. | 756 | * @fifo: address of the fifo to be used |
| 409 | * @to: where the data must be copied. | 757 | * @buf: pointer to the storage buffer |
| 410 | * @n: the size of the destination buffer. | 758 | * @n: max. number of elements to get |
| 411 | * @recsize: size of record field | ||
| 412 | * @total: pointer where the total number of to copied bytes should stored | ||
| 413 | * | 759 | * |
| 414 | * This function copies at most @n bytes from the FIFO to @to and returns the | 760 | * This macro get the data from the fifo and return the numbers of elements |
| 415 | * number of bytes which cannot be copied. | 761 | * copied. The data is not removed from the fifo. |
| 416 | * A returned value greater than the @n value means that the record doesn't | ||
| 417 | * fit into the @to buffer. | ||
| 418 | * | 762 | * |
| 419 | * Note that with only one concurrent reader and one concurrent | 763 | * Note that with only one concurrent reader and one concurrent |
| 420 | * writer, you don't need extra locking to use these functions. | 764 | * writer, you don't need extra locking to use these macro. |
| 421 | */ | 765 | */ |
| 422 | static inline __must_check unsigned int kfifo_out_rec(struct kfifo *fifo, | 766 | #define kfifo_out_peek(fifo, buf, n) \ |
| 423 | void *to, unsigned int n, unsigned int recsize, | 767 | __kfifo_must_check_helper( \ |
| 424 | unsigned int *total) | 768 | ({ \ |
| 769 | typeof(fifo + 1) __tmp = (fifo); \ | ||
| 770 | typeof(buf + 1) __buf = (buf); \ | ||
| 771 | unsigned long __n = (n); \ | ||
| 772 | const size_t __recsize = sizeof(*__tmp->rectype); \ | ||
| 773 | struct __kfifo *__kfifo = &__tmp->kfifo; \ | ||
| 774 | if (0) { \ | ||
| 775 | typeof(__tmp->ptr) __dummy __attribute__ ((unused)) = NULL; \ | ||
| 776 | __buf = __dummy; \ | ||
| 777 | } \ | ||
| 778 | (__recsize) ? \ | ||
| 779 | __kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \ | ||
| 780 | __kfifo_out_peek(__kfifo, __buf, __n); \ | ||
| 781 | }) \ | ||
| 782 | ) | ||
| 425 | 783 | ||
| 426 | { | 784 | extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, |
| 427 | if (!__builtin_constant_p(recsize)) | 785 | size_t esize, gfp_t gfp_mask); |
| 428 | return __kfifo_out_generic(fifo, to, n, recsize, total); | ||
| 429 | return __kfifo_out_rec(fifo, to, n, recsize, total); | ||
| 430 | } | ||
| 431 | 786 | ||
| 432 | /* | 787 | extern void __kfifo_free(struct __kfifo *fifo); |
| 433 | * __kfifo_from_user_... internal functions for transfer from user space into | ||
| 434 | * the fifo. do not call it directly, use kfifo_from_user_rec() instead | ||
| 435 | */ | ||
| 436 | extern unsigned int __kfifo_from_user_n(struct kfifo *fifo, | ||
| 437 | const void __user *from, unsigned int n, unsigned int recsize); | ||
| 438 | 788 | ||
| 439 | extern unsigned int __kfifo_from_user_generic(struct kfifo *fifo, | 789 | extern int __kfifo_init(struct __kfifo *fifo, void *buffer, |
| 440 | const void __user *from, unsigned int n, unsigned int recsize); | 790 | unsigned int size, size_t esize); |
| 441 | 791 | ||
| 442 | static inline unsigned int __kfifo_from_user_rec(struct kfifo *fifo, | 792 | extern unsigned int __kfifo_in(struct __kfifo *fifo, |
| 443 | const void __user *from, unsigned int n, unsigned int recsize) | 793 | const void *buf, unsigned int len); |
| 444 | { | ||
| 445 | unsigned int ret; | ||
| 446 | 794 | ||
| 447 | ret = __kfifo_from_user_n(fifo, from, n, recsize); | 795 | extern unsigned int __kfifo_out(struct __kfifo *fifo, |
| 796 | void *buf, unsigned int len); | ||
| 448 | 797 | ||
| 449 | if (likely(ret == 0)) { | 798 | extern int __kfifo_from_user(struct __kfifo *fifo, |
| 450 | if (recsize) | 799 | const void __user *from, unsigned long len, unsigned int *copied); |
| 451 | __kfifo_poke_n(fifo, recsize, n); | ||
| 452 | __kfifo_add_in(fifo, n + recsize); | ||
| 453 | } | ||
| 454 | return ret; | ||
| 455 | } | ||
| 456 | 800 | ||
| 457 | /** | 801 | extern int __kfifo_to_user(struct __kfifo *fifo, |
| 458 | * kfifo_from_user_rec - puts some data from user space into the FIFO | 802 | void __user *to, unsigned long len, unsigned int *copied); |
| 459 | * @fifo: the fifo to be used. | ||
| 460 | * @from: pointer to the data to be added. | ||
| 461 | * @n: the length of the data to be added. | ||
| 462 | * @recsize: size of record field | ||
| 463 | * | ||
| 464 | * This function copies @n bytes from the @from into the | ||
| 465 | * FIFO and returns the number of bytes which cannot be copied. | ||
| 466 | * | ||
| 467 | * If the returned value is equal or less the @n value, the copy_from_user() | ||
| 468 | * functions has failed. Otherwise the record doesn't fit into the buffer. | ||
| 469 | * | ||
| 470 | * Note that with only one concurrent reader and one concurrent | ||
| 471 | * writer, you don't need extra locking to use these functions. | ||
| 472 | */ | ||
| 473 | static inline __must_check unsigned int kfifo_from_user_rec(struct kfifo *fifo, | ||
| 474 | const void __user *from, unsigned int n, unsigned int recsize) | ||
| 475 | { | ||
| 476 | if (!__builtin_constant_p(recsize)) | ||
| 477 | return __kfifo_from_user_generic(fifo, from, n, recsize); | ||
| 478 | return __kfifo_from_user_rec(fifo, from, n, recsize); | ||
| 479 | } | ||
| 480 | 803 | ||
| 481 | /* | 804 | extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo, |
| 482 | * __kfifo_to_user_... internal functions for transfer fifo data into user space | 805 | struct scatterlist *sgl, int nents, unsigned int len); |
| 483 | * do not call it directly, use kfifo_to_user_rec() instead | ||
| 484 | */ | ||
| 485 | extern unsigned int __kfifo_to_user_n(struct kfifo *fifo, | ||
| 486 | void __user *to, unsigned int n, unsigned int reclen, | ||
| 487 | unsigned int recsize); | ||
| 488 | 806 | ||
| 489 | extern unsigned int __kfifo_to_user_generic(struct kfifo *fifo, | 807 | extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo, |
| 490 | void __user *to, unsigned int n, unsigned int recsize, | 808 | struct scatterlist *sgl, int nents, unsigned int len); |
| 491 | unsigned int *total); | ||
| 492 | 809 | ||
| 493 | static inline unsigned int __kfifo_to_user_rec(struct kfifo *fifo, | 810 | extern unsigned int __kfifo_out_peek(struct __kfifo *fifo, |
| 494 | void __user *to, unsigned int n, | 811 | void *buf, unsigned int len); |
| 495 | unsigned int recsize, unsigned int *total) | ||
| 496 | { | ||
| 497 | unsigned int l; | ||
| 498 | |||
| 499 | if (!recsize) { | ||
| 500 | l = n; | ||
| 501 | if (total) | ||
| 502 | *total = l; | ||
| 503 | } else { | ||
| 504 | l = __kfifo_peek_n(fifo, recsize); | ||
| 505 | if (total) | ||
| 506 | *total = l; | ||
| 507 | if (n < l) | ||
| 508 | return l; | ||
| 509 | } | ||
| 510 | 812 | ||
| 511 | return __kfifo_to_user_n(fifo, to, n, l, recsize); | 813 | extern unsigned int __kfifo_in_r(struct __kfifo *fifo, |
| 512 | } | 814 | const void *buf, unsigned int len, size_t recsize); |
| 513 | 815 | ||
| 514 | /** | 816 | extern unsigned int __kfifo_out_r(struct __kfifo *fifo, |
| 515 | * kfifo_to_user_rec - gets data from the FIFO and write it to user space | 817 | void *buf, unsigned int len, size_t recsize); |
| 516 | * @fifo: the fifo to be used. | ||
| 517 | * @to: where the data must be copied. | ||
| 518 | * @n: the size of the destination buffer. | ||
| 519 | * @recsize: size of record field | ||
| 520 | * @total: pointer where the total number of to copied bytes should stored | ||
| 521 | * | ||
| 522 | * This function copies at most @n bytes from the FIFO to the @to. | ||
| 523 | * In case of an error, the function returns the number of bytes which cannot | ||
| 524 | * be copied. | ||
| 525 | * If the returned value is equal or less the @n value, the copy_to_user() | ||
| 526 | * functions has failed. Otherwise the record doesn't fit into the @to buffer. | ||
| 527 | * | ||
| 528 | * Note that with only one concurrent reader and one concurrent | ||
| 529 | * writer, you don't need extra locking to use these functions. | ||
| 530 | */ | ||
| 531 | static inline __must_check unsigned int kfifo_to_user_rec(struct kfifo *fifo, | ||
| 532 | void __user *to, unsigned int n, unsigned int recsize, | ||
| 533 | unsigned int *total) | ||
| 534 | { | ||
| 535 | if (!__builtin_constant_p(recsize)) | ||
| 536 | return __kfifo_to_user_generic(fifo, to, n, recsize, total); | ||
| 537 | return __kfifo_to_user_rec(fifo, to, n, recsize, total); | ||
| 538 | } | ||
| 539 | 818 | ||
| 540 | /* | 819 | extern int __kfifo_from_user_r(struct __kfifo *fifo, |
| 541 | * __kfifo_peek_... internal functions for peek into the next fifo record | 820 | const void __user *from, unsigned long len, unsigned int *copied, |
| 542 | * do not call it directly, use kfifo_peek_rec() instead | 821 | size_t recsize); |
| 543 | */ | ||
| 544 | extern unsigned int __kfifo_peek_generic(struct kfifo *fifo, | ||
| 545 | unsigned int recsize); | ||
| 546 | 822 | ||
| 547 | /** | 823 | extern int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to, |
| 548 | * kfifo_peek_rec - gets the size of the next FIFO record data | 824 | unsigned long len, unsigned int *copied, size_t recsize); |
| 549 | * @fifo: the fifo to be used. | ||
| 550 | * @recsize: size of record field | ||
| 551 | * | ||
| 552 | * This function returns the size of the next FIFO record in number of bytes | ||
| 553 | */ | ||
| 554 | static inline __must_check unsigned int kfifo_peek_rec(struct kfifo *fifo, | ||
| 555 | unsigned int recsize) | ||
| 556 | { | ||
| 557 | if (!__builtin_constant_p(recsize)) | ||
| 558 | return __kfifo_peek_generic(fifo, recsize); | ||
| 559 | if (!recsize) | ||
| 560 | return kfifo_len(fifo); | ||
| 561 | return __kfifo_peek_n(fifo, recsize); | ||
| 562 | } | ||
| 563 | 825 | ||
| 564 | /* | 826 | extern unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo, |
| 565 | * __kfifo_skip_... internal functions for skip the next fifo record | 827 | struct scatterlist *sgl, int nents, unsigned int len, size_t recsize); |
| 566 | * do not call it directly, use kfifo_skip_rec() instead | ||
| 567 | */ | ||
| 568 | extern void __kfifo_skip_generic(struct kfifo *fifo, unsigned int recsize); | ||
| 569 | 828 | ||
| 570 | static inline void __kfifo_skip_rec(struct kfifo *fifo, | 829 | extern void __kfifo_dma_in_finish_r(struct __kfifo *fifo, |
| 571 | unsigned int recsize) | 830 | unsigned int len, size_t recsize); |
| 572 | { | ||
| 573 | unsigned int l; | ||
| 574 | 831 | ||
| 575 | if (recsize) { | 832 | extern unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo, |
| 576 | l = __kfifo_peek_n(fifo, recsize); | 833 | struct scatterlist *sgl, int nents, unsigned int len, size_t recsize); |
| 577 | 834 | ||
| 578 | if (l + recsize <= kfifo_len(fifo)) { | 835 | extern void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize); |
| 579 | __kfifo_add_out(fifo, l + recsize); | ||
| 580 | return; | ||
| 581 | } | ||
| 582 | } | ||
| 583 | kfifo_reset_out(fifo); | ||
| 584 | } | ||
| 585 | 836 | ||
| 586 | /** | 837 | extern unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize); |
| 587 | * kfifo_skip_rec - skip the next fifo out record | ||
| 588 | * @fifo: the fifo to be used. | ||
| 589 | * @recsize: size of record field | ||
| 590 | * | ||
| 591 | * This function skips the next FIFO record | ||
| 592 | */ | ||
| 593 | static inline void kfifo_skip_rec(struct kfifo *fifo, | ||
| 594 | unsigned int recsize) | ||
| 595 | { | ||
| 596 | if (!__builtin_constant_p(recsize)) | ||
| 597 | __kfifo_skip_generic(fifo, recsize); | ||
| 598 | else | ||
| 599 | __kfifo_skip_rec(fifo, recsize); | ||
| 600 | } | ||
| 601 | 838 | ||
| 602 | /** | 839 | extern unsigned int __kfifo_out_peek_r(struct __kfifo *fifo, |
| 603 | * kfifo_avail_rec - returns the number of bytes available in a record FIFO | 840 | void *buf, unsigned int len, size_t recsize); |
| 604 | * @fifo: the fifo to be used. | ||
| 605 | * @recsize: size of record field | ||
| 606 | */ | ||
| 607 | static inline __must_check unsigned int kfifo_avail_rec(struct kfifo *fifo, | ||
| 608 | unsigned int recsize) | ||
| 609 | { | ||
| 610 | unsigned int l = kfifo_size(fifo) - kfifo_len(fifo); | ||
| 611 | 841 | ||
| 612 | return (l > recsize) ? l - recsize : 0; | 842 | extern unsigned int __kfifo_max_r(unsigned int len, size_t recsize); |
| 613 | } | ||
| 614 | 843 | ||
| 615 | #endif | 844 | #endif |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 73564cac38c7..159a0762aeaf 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
| @@ -123,8 +123,7 @@ static inline bool mem_cgroup_disabled(void) | |||
| 123 | 123 | ||
| 124 | void mem_cgroup_update_file_mapped(struct page *page, int val); | 124 | void mem_cgroup_update_file_mapped(struct page *page, int val); |
| 125 | unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, | 125 | unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, |
| 126 | gfp_t gfp_mask, int nid, | 126 | gfp_t gfp_mask); |
| 127 | int zid); | ||
| 128 | u64 mem_cgroup_get_limit(struct mem_cgroup *mem); | 127 | u64 mem_cgroup_get_limit(struct mem_cgroup *mem); |
| 129 | 128 | ||
| 130 | #else /* CONFIG_CGROUP_MEM_RES_CTLR */ | 129 | #else /* CONFIG_CGROUP_MEM_RES_CTLR */ |
| @@ -301,7 +300,7 @@ static inline void mem_cgroup_update_file_mapped(struct page *page, | |||
| 301 | 300 | ||
| 302 | static inline | 301 | static inline |
| 303 | unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, | 302 | unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, |
| 304 | gfp_t gfp_mask, int nid, int zid) | 303 | gfp_t gfp_mask) |
| 305 | { | 304 | { |
| 306 | return 0; | 305 | return 0; |
| 307 | } | 306 | } |
diff --git a/include/linux/mfd/ab8500.h b/include/linux/mfd/ab8500.h index b63ff3ba3351..f5cec4500f38 100644 --- a/include/linux/mfd/ab8500.h +++ b/include/linux/mfd/ab8500.h | |||
| @@ -76,6 +76,8 @@ | |||
| 76 | #define AB8500_NR_IRQS 104 | 76 | #define AB8500_NR_IRQS 104 |
| 77 | #define AB8500_NUM_IRQ_REGS 13 | 77 | #define AB8500_NUM_IRQ_REGS 13 |
| 78 | 78 | ||
| 79 | #define AB8500_NUM_REGULATORS 15 | ||
| 80 | |||
| 79 | /** | 81 | /** |
| 80 | * struct ab8500 - ab8500 internal structure | 82 | * struct ab8500 - ab8500 internal structure |
| 81 | * @dev: parent device | 83 | * @dev: parent device |
| @@ -108,14 +110,18 @@ struct ab8500 { | |||
| 108 | u8 oldmask[AB8500_NUM_IRQ_REGS]; | 110 | u8 oldmask[AB8500_NUM_IRQ_REGS]; |
| 109 | }; | 111 | }; |
| 110 | 112 | ||
| 113 | struct regulator_init_data; | ||
| 114 | |||
| 111 | /** | 115 | /** |
| 112 | * struct ab8500_platform_data - AB8500 platform data | 116 | * struct ab8500_platform_data - AB8500 platform data |
| 113 | * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used | 117 | * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used |
| 114 | * @init: board-specific initialization after detection of ab8500 | 118 | * @init: board-specific initialization after detection of ab8500 |
| 119 | * @regulator: machine-specific constraints for regulators | ||
| 115 | */ | 120 | */ |
| 116 | struct ab8500_platform_data { | 121 | struct ab8500_platform_data { |
| 117 | int irq_base; | 122 | int irq_base; |
| 118 | void (*init) (struct ab8500 *); | 123 | void (*init) (struct ab8500 *); |
| 124 | struct regulator_init_data *regulator[AB8500_NUM_REGULATORS]; | ||
| 119 | }; | 125 | }; |
| 120 | 126 | ||
| 121 | extern int ab8500_write(struct ab8500 *a8500, u16 addr, u8 data); | 127 | extern int ab8500_write(struct ab8500 *a8500, u16 addr, u8 data); |
diff --git a/include/linux/mfd/max8998-private.h b/include/linux/mfd/max8998-private.h new file mode 100644 index 000000000000..6dc75b3e2d33 --- /dev/null +++ b/include/linux/mfd/max8998-private.h | |||
| @@ -0,0 +1,112 @@ | |||
| 1 | /* | ||
| 2 | * max8698.h - Voltage regulator driver for the Maxim 8998 | ||
| 3 | * | ||
| 4 | * Copyright (C) 2009-2010 Samsung Electrnoics | ||
| 5 | * Kyungmin Park <kyungmin.park@samsung.com> | ||
| 6 | * Marek Szyprowski <m.szyprowski@samsung.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License, or | ||
| 11 | * (at your option) any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License | ||
| 19 | * along with this program; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 21 | */ | ||
| 22 | |||
| 23 | #ifndef __LINUX_MFD_MAX8998_PRIV_H | ||
| 24 | #define __LINUX_MFD_MAX8998_PRIV_H | ||
| 25 | |||
| 26 | /* MAX 8998 registers */ | ||
| 27 | enum { | ||
| 28 | MAX8998_REG_IRQ1, | ||
| 29 | MAX8998_REG_IRQ2, | ||
| 30 | MAX8998_REG_IRQ3, | ||
| 31 | MAX8998_REG_IRQ4, | ||
| 32 | MAX8998_REG_IRQM1, | ||
| 33 | MAX8998_REG_IRQM2, | ||
| 34 | MAX8998_REG_IRQM3, | ||
| 35 | MAX8998_REG_IRQM4, | ||
| 36 | MAX8998_REG_STATUS1, | ||
| 37 | MAX8998_REG_STATUS2, | ||
| 38 | MAX8998_REG_STATUSM1, | ||
| 39 | MAX8998_REG_STATUSM2, | ||
| 40 | MAX8998_REG_CHGR1, | ||
| 41 | MAX8998_REG_CHGR2, | ||
| 42 | MAX8998_REG_LDO_ACTIVE_DISCHARGE1, | ||
| 43 | MAX8998_REG_LDO_ACTIVE_DISCHARGE2, | ||
| 44 | MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, | ||
| 45 | MAX8998_REG_ONOFF1, | ||
| 46 | MAX8998_REG_ONOFF2, | ||
| 47 | MAX8998_REG_ONOFF3, | ||
| 48 | MAX8998_REG_ONOFF4, | ||
| 49 | MAX8998_REG_BUCK1_DVSARM1, | ||
| 50 | MAX8998_REG_BUCK1_DVSARM2, | ||
| 51 | MAX8998_REG_BUCK1_DVSARM3, | ||
| 52 | MAX8998_REG_BUCK1_DVSARM4, | ||
| 53 | MAX8998_REG_BUCK2_DVSINT1, | ||
| 54 | MAX8998_REG_BUCK2_DVSINT2, | ||
| 55 | MAX8998_REG_BUCK3, | ||
| 56 | MAX8998_REG_BUCK4, | ||
| 57 | MAX8998_REG_LDO2_LDO3, | ||
| 58 | MAX8998_REG_LDO4, | ||
| 59 | MAX8998_REG_LDO5, | ||
| 60 | MAX8998_REG_LDO6, | ||
| 61 | MAX8998_REG_LDO7, | ||
| 62 | MAX8998_REG_LDO8_LDO9, | ||
| 63 | MAX8998_REG_LDO10_LDO11, | ||
| 64 | MAX8998_REG_LDO12, | ||
| 65 | MAX8998_REG_LDO13, | ||
| 66 | MAX8998_REG_LDO14, | ||
| 67 | MAX8998_REG_LDO15, | ||
| 68 | MAX8998_REG_LDO16, | ||
| 69 | MAX8998_REG_LDO17, | ||
| 70 | MAX8998_REG_BKCHR, | ||
| 71 | MAX8998_REG_LBCNFG1, | ||
| 72 | MAX8998_REG_LBCNFG2, | ||
| 73 | }; | ||
| 74 | |||
| 75 | /** | ||
| 76 | * struct max8998_dev - max8998 master device for sub-drivers | ||
| 77 | * @dev: master device of the chip (can be used to access platform data) | ||
| 78 | * @i2c_client: i2c client private data | ||
| 79 | * @dev_read(): chip register read function | ||
| 80 | * @dev_write(): chip register write function | ||
| 81 | * @dev_update(): chip register update function | ||
| 82 | * @iolock: mutex for serializing io access | ||
| 83 | */ | ||
| 84 | |||
| 85 | struct max8998_dev { | ||
| 86 | struct device *dev; | ||
| 87 | struct i2c_client *i2c_client; | ||
| 88 | int (*dev_read)(struct max8998_dev *max8998, u8 reg, u8 *dest); | ||
| 89 | int (*dev_write)(struct max8998_dev *max8998, u8 reg, u8 val); | ||
| 90 | int (*dev_update)(struct max8998_dev *max8998, u8 reg, u8 val, u8 mask); | ||
| 91 | struct mutex iolock; | ||
| 92 | }; | ||
| 93 | |||
| 94 | static inline int max8998_read_reg(struct max8998_dev *max8998, u8 reg, | ||
| 95 | u8 *value) | ||
| 96 | { | ||
| 97 | return max8998->dev_read(max8998, reg, value); | ||
| 98 | } | ||
| 99 | |||
| 100 | static inline int max8998_write_reg(struct max8998_dev *max8998, u8 reg, | ||
| 101 | u8 value) | ||
| 102 | { | ||
| 103 | return max8998->dev_write(max8998, reg, value); | ||
| 104 | } | ||
| 105 | |||
| 106 | static inline int max8998_update_reg(struct max8998_dev *max8998, u8 reg, | ||
| 107 | u8 value, u8 mask) | ||
| 108 | { | ||
| 109 | return max8998->dev_update(max8998, reg, value, mask); | ||
| 110 | } | ||
| 111 | |||
| 112 | #endif /* __LINUX_MFD_MAX8998_PRIV_H */ | ||
diff --git a/include/linux/mfd/max8998.h b/include/linux/mfd/max8998.h new file mode 100644 index 000000000000..1d3601a2d853 --- /dev/null +++ b/include/linux/mfd/max8998.h | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | /* | ||
| 2 | * max8698.h - Voltage regulator driver for the Maxim 8998 | ||
| 3 | * | ||
| 4 | * Copyright (C) 2009-2010 Samsung Electrnoics | ||
| 5 | * Kyungmin Park <kyungmin.park@samsung.com> | ||
| 6 | * Marek Szyprowski <m.szyprowski@samsung.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License, or | ||
| 11 | * (at your option) any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License | ||
| 19 | * along with this program; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 21 | */ | ||
| 22 | |||
| 23 | #ifndef __LINUX_MFD_MAX8998_H | ||
| 24 | #define __LINUX_MFD_MAX8998_H | ||
| 25 | |||
| 26 | #include <linux/regulator/machine.h> | ||
| 27 | |||
| 28 | /* MAX 8998 regulator ids */ | ||
| 29 | enum { | ||
| 30 | MAX8998_LDO2 = 2, | ||
| 31 | MAX8998_LDO3, | ||
| 32 | MAX8998_LDO4, | ||
| 33 | MAX8998_LDO5, | ||
| 34 | MAX8998_LDO6, | ||
| 35 | MAX8998_LDO7, | ||
| 36 | MAX8998_LDO8, | ||
| 37 | MAX8998_LDO9, | ||
| 38 | MAX8998_LDO10, | ||
| 39 | MAX8998_LDO11, | ||
| 40 | MAX8998_LDO12, | ||
| 41 | MAX8998_LDO13, | ||
| 42 | MAX8998_LDO14, | ||
| 43 | MAX8998_LDO15, | ||
| 44 | MAX8998_LDO16, | ||
| 45 | MAX8998_LDO17, | ||
| 46 | MAX8998_BUCK1, | ||
| 47 | MAX8998_BUCK2, | ||
| 48 | MAX8998_BUCK3, | ||
| 49 | MAX8998_BUCK4, | ||
| 50 | MAX8998_EN32KHZ_AP, | ||
| 51 | MAX8998_EN32KHZ_CP, | ||
| 52 | MAX8998_ENVICHG, | ||
| 53 | MAX8998_ESAFEOUT1, | ||
| 54 | MAX8998_ESAFEOUT2, | ||
| 55 | }; | ||
| 56 | |||
| 57 | /** | ||
| 58 | * max8998_regulator_data - regulator data | ||
| 59 | * @id: regulator id | ||
| 60 | * @initdata: regulator init data (contraints, supplies, ...) | ||
| 61 | */ | ||
| 62 | struct max8998_regulator_data { | ||
| 63 | int id; | ||
| 64 | struct regulator_init_data *initdata; | ||
| 65 | }; | ||
| 66 | |||
| 67 | /** | ||
| 68 | * struct max8998_board - packages regulator init data | ||
| 69 | * @num_regulators: number of regultors used | ||
| 70 | * @regulators: array of defined regulators | ||
| 71 | */ | ||
| 72 | |||
| 73 | struct max8998_platform_data { | ||
| 74 | int num_regulators; | ||
| 75 | struct max8998_regulator_data *regulators; | ||
| 76 | }; | ||
| 77 | |||
| 78 | #endif /* __LINUX_MFD_MAX8998_H */ | ||
diff --git a/include/linux/mfd/mc13783-private.h b/include/linux/mfd/mc13783-private.h deleted file mode 100644 index 95cf9360553f..000000000000 --- a/include/linux/mfd/mc13783-private.h +++ /dev/null | |||
| @@ -1,220 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de> | ||
| 3 | * | ||
| 4 | * Initial development of this code was funded by | ||
| 5 | * Phytec Messtechnik GmbH, http://www.phytec.de | ||
| 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 __LINUX_MFD_MC13783_PRIV_H | ||
| 23 | #define __LINUX_MFD_MC13783_PRIV_H | ||
| 24 | |||
| 25 | #include <linux/platform_device.h> | ||
| 26 | #include <linux/mfd/mc13783.h> | ||
| 27 | #include <linux/mutex.h> | ||
| 28 | #include <linux/interrupt.h> | ||
| 29 | |||
| 30 | struct mc13783 { | ||
| 31 | struct spi_device *spidev; | ||
| 32 | struct mutex lock; | ||
| 33 | int irq; | ||
| 34 | int flags; | ||
| 35 | |||
| 36 | irq_handler_t irqhandler[MC13783_NUM_IRQ]; | ||
| 37 | void *irqdata[MC13783_NUM_IRQ]; | ||
| 38 | |||
| 39 | /* XXX these should go as platformdata to the regulator subdevice */ | ||
| 40 | struct mc13783_regulator_init_data *regulators; | ||
| 41 | int num_regulators; | ||
| 42 | }; | ||
| 43 | |||
| 44 | #define MC13783_REG_INTERRUPT_STATUS_0 0 | ||
| 45 | #define MC13783_REG_INTERRUPT_MASK_0 1 | ||
| 46 | #define MC13783_REG_INTERRUPT_SENSE_0 2 | ||
| 47 | #define MC13783_REG_INTERRUPT_STATUS_1 3 | ||
| 48 | #define MC13783_REG_INTERRUPT_MASK_1 4 | ||
| 49 | #define MC13783_REG_INTERRUPT_SENSE_1 5 | ||
| 50 | #define MC13783_REG_POWER_UP_MODE_SENSE 6 | ||
| 51 | #define MC13783_REG_REVISION 7 | ||
| 52 | #define MC13783_REG_SEMAPHORE 8 | ||
| 53 | #define MC13783_REG_ARBITRATION_PERIPHERAL_AUDIO 9 | ||
| 54 | #define MC13783_REG_ARBITRATION_SWITCHERS 10 | ||
| 55 | #define MC13783_REG_ARBITRATION_REGULATORS_0 11 | ||
| 56 | #define MC13783_REG_ARBITRATION_REGULATORS_1 12 | ||
| 57 | #define MC13783_REG_POWER_CONTROL_0 13 | ||
| 58 | #define MC13783_REG_POWER_CONTROL_1 14 | ||
| 59 | #define MC13783_REG_POWER_CONTROL_2 15 | ||
| 60 | #define MC13783_REG_REGEN_ASSIGNMENT 16 | ||
| 61 | #define MC13783_REG_CONTROL_SPARE 17 | ||
| 62 | #define MC13783_REG_MEMORY_A 18 | ||
| 63 | #define MC13783_REG_MEMORY_B 19 | ||
| 64 | #define MC13783_REG_RTC_TIME 20 | ||
| 65 | #define MC13783_REG_RTC_ALARM 21 | ||
| 66 | #define MC13783_REG_RTC_DAY 22 | ||
| 67 | #define MC13783_REG_RTC_DAY_ALARM 23 | ||
| 68 | #define MC13783_REG_SWITCHERS_0 24 | ||
| 69 | #define MC13783_REG_SWITCHERS_1 25 | ||
| 70 | #define MC13783_REG_SWITCHERS_2 26 | ||
| 71 | #define MC13783_REG_SWITCHERS_3 27 | ||
| 72 | #define MC13783_REG_SWITCHERS_4 28 | ||
| 73 | #define MC13783_REG_SWITCHERS_5 29 | ||
| 74 | #define MC13783_REG_REGULATOR_SETTING_0 30 | ||
| 75 | #define MC13783_REG_REGULATOR_SETTING_1 31 | ||
| 76 | #define MC13783_REG_REGULATOR_MODE_0 32 | ||
| 77 | #define MC13783_REG_REGULATOR_MODE_1 33 | ||
| 78 | #define MC13783_REG_POWER_MISCELLANEOUS 34 | ||
| 79 | #define MC13783_REG_POWER_SPARE 35 | ||
| 80 | #define MC13783_REG_AUDIO_RX_0 36 | ||
| 81 | #define MC13783_REG_AUDIO_RX_1 37 | ||
| 82 | #define MC13783_REG_AUDIO_TX 38 | ||
| 83 | #define MC13783_REG_AUDIO_SSI_NETWORK 39 | ||
| 84 | #define MC13783_REG_AUDIO_CODEC 40 | ||
| 85 | #define MC13783_REG_AUDIO_STEREO_DAC 41 | ||
| 86 | #define MC13783_REG_AUDIO_SPARE 42 | ||
| 87 | #define MC13783_REG_ADC_0 43 | ||
| 88 | #define MC13783_REG_ADC_1 44 | ||
| 89 | #define MC13783_REG_ADC_2 45 | ||
| 90 | #define MC13783_REG_ADC_3 46 | ||
| 91 | #define MC13783_REG_ADC_4 47 | ||
| 92 | #define MC13783_REG_CHARGER 48 | ||
| 93 | #define MC13783_REG_USB 49 | ||
| 94 | #define MC13783_REG_CHARGE_USB_SPARE 50 | ||
| 95 | #define MC13783_REG_LED_CONTROL_0 51 | ||
| 96 | #define MC13783_REG_LED_CONTROL_1 52 | ||
| 97 | #define MC13783_REG_LED_CONTROL_2 53 | ||
| 98 | #define MC13783_REG_LED_CONTROL_3 54 | ||
| 99 | #define MC13783_REG_LED_CONTROL_4 55 | ||
| 100 | #define MC13783_REG_LED_CONTROL_5 56 | ||
| 101 | #define MC13783_REG_SPARE 57 | ||
| 102 | #define MC13783_REG_TRIM_0 58 | ||
| 103 | #define MC13783_REG_TRIM_1 59 | ||
| 104 | #define MC13783_REG_TEST_0 60 | ||
| 105 | #define MC13783_REG_TEST_1 61 | ||
| 106 | #define MC13783_REG_TEST_2 62 | ||
| 107 | #define MC13783_REG_TEST_3 63 | ||
| 108 | #define MC13783_REG_NB 64 | ||
| 109 | |||
| 110 | /* | ||
| 111 | * Reg Regulator Mode 0 | ||
| 112 | */ | ||
| 113 | #define MC13783_REGCTRL_VAUDIO_EN (1 << 0) | ||
| 114 | #define MC13783_REGCTRL_VAUDIO_STBY (1 << 1) | ||
| 115 | #define MC13783_REGCTRL_VAUDIO_MODE (1 << 2) | ||
| 116 | #define MC13783_REGCTRL_VIOHI_EN (1 << 3) | ||
| 117 | #define MC13783_REGCTRL_VIOHI_STBY (1 << 4) | ||
| 118 | #define MC13783_REGCTRL_VIOHI_MODE (1 << 5) | ||
| 119 | #define MC13783_REGCTRL_VIOLO_EN (1 << 6) | ||
| 120 | #define MC13783_REGCTRL_VIOLO_STBY (1 << 7) | ||
| 121 | #define MC13783_REGCTRL_VIOLO_MODE (1 << 8) | ||
| 122 | #define MC13783_REGCTRL_VDIG_EN (1 << 9) | ||
| 123 | #define MC13783_REGCTRL_VDIG_STBY (1 << 10) | ||
| 124 | #define MC13783_REGCTRL_VDIG_MODE (1 << 11) | ||
| 125 | #define MC13783_REGCTRL_VGEN_EN (1 << 12) | ||
| 126 | #define MC13783_REGCTRL_VGEN_STBY (1 << 13) | ||
| 127 | #define MC13783_REGCTRL_VGEN_MODE (1 << 14) | ||
| 128 | #define MC13783_REGCTRL_VRFDIG_EN (1 << 15) | ||
| 129 | #define MC13783_REGCTRL_VRFDIG_STBY (1 << 16) | ||
| 130 | #define MC13783_REGCTRL_VRFDIG_MODE (1 << 17) | ||
| 131 | #define MC13783_REGCTRL_VRFREF_EN (1 << 18) | ||
| 132 | #define MC13783_REGCTRL_VRFREF_STBY (1 << 19) | ||
| 133 | #define MC13783_REGCTRL_VRFREF_MODE (1 << 20) | ||
| 134 | #define MC13783_REGCTRL_VRFCP_EN (1 << 21) | ||
| 135 | #define MC13783_REGCTRL_VRFCP_STBY (1 << 22) | ||
| 136 | #define MC13783_REGCTRL_VRFCP_MODE (1 << 23) | ||
| 137 | |||
| 138 | /* | ||
| 139 | * Reg Regulator Mode 1 | ||
| 140 | */ | ||
| 141 | #define MC13783_REGCTRL_VSIM_EN (1 << 0) | ||
| 142 | #define MC13783_REGCTRL_VSIM_STBY (1 << 1) | ||
| 143 | #define MC13783_REGCTRL_VSIM_MODE (1 << 2) | ||
| 144 | #define MC13783_REGCTRL_VESIM_EN (1 << 3) | ||
| 145 | #define MC13783_REGCTRL_VESIM_STBY (1 << 4) | ||
| 146 | #define MC13783_REGCTRL_VESIM_MODE (1 << 5) | ||
| 147 | #define MC13783_REGCTRL_VCAM_EN (1 << 6) | ||
| 148 | #define MC13783_REGCTRL_VCAM_STBY (1 << 7) | ||
| 149 | #define MC13783_REGCTRL_VCAM_MODE (1 << 8) | ||
| 150 | #define MC13783_REGCTRL_VRFBG_EN (1 << 9) | ||
| 151 | #define MC13783_REGCTRL_VRFBG_STBY (1 << 10) | ||
| 152 | #define MC13783_REGCTRL_VVIB_EN (1 << 11) | ||
| 153 | #define MC13783_REGCTRL_VRF1_EN (1 << 12) | ||
| 154 | #define MC13783_REGCTRL_VRF1_STBY (1 << 13) | ||
| 155 | #define MC13783_REGCTRL_VRF1_MODE (1 << 14) | ||
| 156 | #define MC13783_REGCTRL_VRF2_EN (1 << 15) | ||
| 157 | #define MC13783_REGCTRL_VRF2_STBY (1 << 16) | ||
| 158 | #define MC13783_REGCTRL_VRF2_MODE (1 << 17) | ||
| 159 | #define MC13783_REGCTRL_VMMC1_EN (1 << 18) | ||
| 160 | #define MC13783_REGCTRL_VMMC1_STBY (1 << 19) | ||
| 161 | #define MC13783_REGCTRL_VMMC1_MODE (1 << 20) | ||
| 162 | #define MC13783_REGCTRL_VMMC2_EN (1 << 21) | ||
| 163 | #define MC13783_REGCTRL_VMMC2_STBY (1 << 22) | ||
| 164 | #define MC13783_REGCTRL_VMMC2_MODE (1 << 23) | ||
| 165 | |||
| 166 | /* | ||
| 167 | * Reg Regulator Misc. | ||
| 168 | */ | ||
| 169 | #define MC13783_REGCTRL_GPO1_EN (1 << 6) | ||
| 170 | #define MC13783_REGCTRL_GPO2_EN (1 << 8) | ||
| 171 | #define MC13783_REGCTRL_GPO3_EN (1 << 10) | ||
| 172 | #define MC13783_REGCTRL_GPO4_EN (1 << 12) | ||
| 173 | #define MC13783_REGCTRL_VIBPINCTRL (1 << 14) | ||
| 174 | |||
| 175 | /* | ||
| 176 | * Reg Switcher 4 | ||
| 177 | */ | ||
| 178 | #define MC13783_SWCTRL_SW1A_MODE (1 << 0) | ||
| 179 | #define MC13783_SWCTRL_SW1A_STBY_MODE (1 << 2) | ||
| 180 | #define MC13783_SWCTRL_SW1A_DVS_SPEED (1 << 6) | ||
| 181 | #define MC13783_SWCTRL_SW1A_PANIC_MODE (1 << 8) | ||
| 182 | #define MC13783_SWCTRL_SW1A_SOFTSTART (1 << 9) | ||
| 183 | #define MC13783_SWCTRL_SW1B_MODE (1 << 10) | ||
| 184 | #define MC13783_SWCTRL_SW1B_STBY_MODE (1 << 12) | ||
| 185 | #define MC13783_SWCTRL_SW1B_DVS_SPEED (1 << 14) | ||
| 186 | #define MC13783_SWCTRL_SW1B_PANIC_MODE (1 << 16) | ||
| 187 | #define MC13783_SWCTRL_SW1B_SOFTSTART (1 << 17) | ||
| 188 | #define MC13783_SWCTRL_PLL_EN (1 << 18) | ||
| 189 | #define MC13783_SWCTRL_PLL_FACTOR (1 << 19) | ||
| 190 | |||
| 191 | /* | ||
| 192 | * Reg Switcher 5 | ||
| 193 | */ | ||
| 194 | #define MC13783_SWCTRL_SW2A_MODE (1 << 0) | ||
| 195 | #define MC13783_SWCTRL_SW2A_STBY_MODE (1 << 2) | ||
| 196 | #define MC13783_SWCTRL_SW2A_DVS_SPEED (1 << 6) | ||
| 197 | #define MC13783_SWCTRL_SW2A_PANIC_MODE (1 << 8) | ||
| 198 | #define MC13783_SWCTRL_SW2A_SOFTSTART (1 << 9) | ||
| 199 | #define MC13783_SWCTRL_SW2B_MODE (1 << 10) | ||
| 200 | #define MC13783_SWCTRL_SW2B_STBY_MODE (1 << 12) | ||
| 201 | #define MC13783_SWCTRL_SW2B_DVS_SPEED (1 << 14) | ||
| 202 | #define MC13783_SWCTRL_SW2B_PANIC_MODE (1 << 16) | ||
| 203 | #define MC13783_SWCTRL_SW2B_SOFTSTART (1 << 17) | ||
| 204 | #define MC13783_SWSET_SW3 (1 << 18) | ||
| 205 | #define MC13783_SWCTRL_SW3_EN (1 << 20) | ||
| 206 | #define MC13783_SWCTRL_SW3_STBY (1 << 21) | ||
| 207 | #define MC13783_SWCTRL_SW3_MODE (1 << 22) | ||
| 208 | |||
| 209 | static inline int mc13783_set_bits(struct mc13783 *mc13783, unsigned int offset, | ||
| 210 | u32 mask, u32 val) | ||
| 211 | { | ||
| 212 | int ret; | ||
| 213 | mc13783_lock(mc13783); | ||
| 214 | ret = mc13783_reg_rmw(mc13783, offset, mask, val); | ||
| 215 | mc13783_unlock(mc13783); | ||
| 216 | |||
| 217 | return ret; | ||
| 218 | } | ||
| 219 | |||
| 220 | #endif /* __LINUX_MFD_MC13783_PRIV_H */ | ||
diff --git a/include/linux/mfd/mc13783.h b/include/linux/mfd/mc13783.h index 4a894f688549..0fa44fb8dd26 100644 --- a/include/linux/mfd/mc13783.h +++ b/include/linux/mfd/mc13783.h | |||
| @@ -21,6 +21,8 @@ int mc13783_reg_write(struct mc13783 *mc13783, unsigned int offset, u32 val); | |||
| 21 | int mc13783_reg_rmw(struct mc13783 *mc13783, unsigned int offset, | 21 | int mc13783_reg_rmw(struct mc13783 *mc13783, unsigned int offset, |
| 22 | u32 mask, u32 val); | 22 | u32 mask, u32 val); |
| 23 | 23 | ||
| 24 | int mc13783_get_flags(struct mc13783 *mc13783); | ||
| 25 | |||
| 24 | int mc13783_irq_request(struct mc13783 *mc13783, int irq, | 26 | int mc13783_irq_request(struct mc13783 *mc13783, int irq, |
| 25 | irq_handler_t handler, const char *name, void *dev); | 27 | irq_handler_t handler, const char *name, void *dev); |
| 26 | int mc13783_irq_request_nounmask(struct mc13783 *mc13783, int irq, | 28 | int mc13783_irq_request_nounmask(struct mc13783 *mc13783, int irq, |
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h new file mode 100644 index 000000000000..39ca7588659b --- /dev/null +++ b/include/linux/mfd/stmpe.h | |||
| @@ -0,0 +1,201 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) ST-Ericsson SA 2010 | ||
| 3 | * | ||
| 4 | * License Terms: GNU General Public License, version 2 | ||
| 5 | * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef __LINUX_MFD_STMPE_H | ||
| 9 | #define __LINUX_MFD_STMPE_H | ||
| 10 | |||
| 11 | #include <linux/device.h> | ||
| 12 | |||
| 13 | enum stmpe_block { | ||
| 14 | STMPE_BLOCK_GPIO = 1 << 0, | ||
| 15 | STMPE_BLOCK_KEYPAD = 1 << 1, | ||
| 16 | STMPE_BLOCK_TOUCHSCREEN = 1 << 2, | ||
| 17 | STMPE_BLOCK_ADC = 1 << 3, | ||
| 18 | STMPE_BLOCK_PWM = 1 << 4, | ||
| 19 | STMPE_BLOCK_ROTATOR = 1 << 5, | ||
| 20 | }; | ||
| 21 | |||
| 22 | enum stmpe_partnum { | ||
| 23 | STMPE811, | ||
| 24 | STMPE1601, | ||
| 25 | STMPE2401, | ||
| 26 | STMPE2403, | ||
| 27 | }; | ||
| 28 | |||
| 29 | /* | ||
| 30 | * For registers whose locations differ on variants, the correct address is | ||
| 31 | * obtained by indexing stmpe->regs with one of the following. | ||
| 32 | */ | ||
| 33 | enum { | ||
| 34 | STMPE_IDX_CHIP_ID, | ||
| 35 | STMPE_IDX_ICR_LSB, | ||
| 36 | STMPE_IDX_IER_LSB, | ||
| 37 | STMPE_IDX_ISR_MSB, | ||
| 38 | STMPE_IDX_GPMR_LSB, | ||
| 39 | STMPE_IDX_GPSR_LSB, | ||
| 40 | STMPE_IDX_GPCR_LSB, | ||
| 41 | STMPE_IDX_GPDR_LSB, | ||
| 42 | STMPE_IDX_GPEDR_MSB, | ||
| 43 | STMPE_IDX_GPRER_LSB, | ||
| 44 | STMPE_IDX_GPFER_LSB, | ||
| 45 | STMPE_IDX_GPAFR_U_MSB, | ||
| 46 | STMPE_IDX_IEGPIOR_LSB, | ||
| 47 | STMPE_IDX_ISGPIOR_MSB, | ||
| 48 | STMPE_IDX_MAX, | ||
| 49 | }; | ||
| 50 | |||
| 51 | |||
| 52 | struct stmpe_variant_info; | ||
| 53 | |||
| 54 | /** | ||
| 55 | * struct stmpe - STMPE MFD structure | ||
| 56 | * @lock: lock protecting I/O operations | ||
| 57 | * @irq_lock: IRQ bus lock | ||
| 58 | * @dev: device, mostly for dev_dbg() | ||
| 59 | * @i2c: i2c client | ||
| 60 | * @variant: the detected STMPE model number | ||
| 61 | * @regs: list of addresses of registers which are at different addresses on | ||
| 62 | * different variants. Indexed by one of STMPE_IDX_*. | ||
| 63 | * @irq_base: starting IRQ number for internal IRQs | ||
| 64 | * @num_gpios: number of gpios, differs for variants | ||
| 65 | * @ier: cache of IER registers for bus_lock | ||
| 66 | * @oldier: cache of IER registers for bus_lock | ||
| 67 | * @pdata: platform data | ||
| 68 | */ | ||
| 69 | struct stmpe { | ||
| 70 | struct mutex lock; | ||
| 71 | struct mutex irq_lock; | ||
| 72 | struct device *dev; | ||
| 73 | struct i2c_client *i2c; | ||
| 74 | enum stmpe_partnum partnum; | ||
| 75 | struct stmpe_variant_info *variant; | ||
| 76 | const u8 *regs; | ||
| 77 | |||
| 78 | int irq_base; | ||
| 79 | int num_gpios; | ||
| 80 | u8 ier[2]; | ||
| 81 | u8 oldier[2]; | ||
| 82 | struct stmpe_platform_data *pdata; | ||
| 83 | }; | ||
| 84 | |||
| 85 | extern int stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 data); | ||
| 86 | extern int stmpe_reg_read(struct stmpe *stmpe, u8 reg); | ||
| 87 | extern int stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length, | ||
| 88 | u8 *values); | ||
| 89 | extern int stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length, | ||
| 90 | const u8 *values); | ||
| 91 | extern int stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val); | ||
| 92 | extern int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, | ||
| 93 | enum stmpe_block block); | ||
| 94 | extern int stmpe_enable(struct stmpe *stmpe, unsigned int blocks); | ||
| 95 | extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks); | ||
| 96 | |||
| 97 | struct matrix_keymap_data; | ||
| 98 | |||
| 99 | /** | ||
| 100 | * struct stmpe_keypad_platform_data - STMPE keypad platform data | ||
| 101 | * @keymap_data: key map table and size | ||
| 102 | * @debounce_ms: debounce interval, in ms. Maximum is | ||
| 103 | * %STMPE_KEYPAD_MAX_DEBOUNCE. | ||
| 104 | * @scan_count: number of key scanning cycles to confirm key data. | ||
| 105 | * Maximum is %STMPE_KEYPAD_MAX_SCAN_COUNT. | ||
| 106 | * @no_autorepeat: disable key autorepeat | ||
| 107 | */ | ||
| 108 | struct stmpe_keypad_platform_data { | ||
| 109 | struct matrix_keymap_data *keymap_data; | ||
| 110 | unsigned int debounce_ms; | ||
| 111 | unsigned int scan_count; | ||
| 112 | bool no_autorepeat; | ||
| 113 | }; | ||
| 114 | |||
| 115 | /** | ||
| 116 | * struct stmpe_gpio_platform_data - STMPE GPIO platform data | ||
| 117 | * @gpio_base: first gpio number assigned. A maximum of | ||
| 118 | * %STMPE_NR_GPIOS GPIOs will be allocated. | ||
| 119 | */ | ||
| 120 | struct stmpe_gpio_platform_data { | ||
| 121 | int gpio_base; | ||
| 122 | void (*setup)(struct stmpe *stmpe, unsigned gpio_base); | ||
| 123 | void (*remove)(struct stmpe *stmpe, unsigned gpio_base); | ||
| 124 | }; | ||
| 125 | |||
| 126 | /** | ||
| 127 | * struct stmpe_ts_platform_data - stmpe811 touch screen controller platform | ||
| 128 | * data | ||
| 129 | * @sample_time: ADC converstion time in number of clock. | ||
| 130 | * (0 -> 36 clocks, 1 -> 44 clocks, 2 -> 56 clocks, 3 -> 64 clocks, | ||
| 131 | * 4 -> 80 clocks, 5 -> 96 clocks, 6 -> 144 clocks), | ||
| 132 | * recommended is 4. | ||
| 133 | * @mod_12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC) | ||
| 134 | * @ref_sel: ADC reference source | ||
| 135 | * (0 -> internal reference, 1 -> external reference) | ||
| 136 | * @adc_freq: ADC Clock speed | ||
| 137 | * (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz) | ||
| 138 | * @ave_ctrl: Sample average control | ||
| 139 | * (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples) | ||
| 140 | * @touch_det_delay: Touch detect interrupt delay | ||
| 141 | * (0 -> 10 us, 1 -> 50 us, 2 -> 100 us, 3 -> 500 us, | ||
| 142 | * 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms) | ||
| 143 | * recommended is 3 | ||
| 144 | * @settling: Panel driver settling time | ||
| 145 | * (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3 -> 1 ms, | ||
| 146 | * 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms) | ||
| 147 | * recommended is 2 | ||
| 148 | * @fraction_z: Length of the fractional part in z | ||
| 149 | * (fraction_z ([0..7]) = Count of the fractional part) | ||
| 150 | * recommended is 7 | ||
| 151 | * @i_drive: current limit value of the touchscreen drivers | ||
| 152 | * (0 -> 20 mA typical 35 mA max, 1 -> 50 mA typical 80 mA max) | ||
| 153 | * | ||
| 154 | * */ | ||
| 155 | struct stmpe_ts_platform_data { | ||
| 156 | u8 sample_time; | ||
| 157 | u8 mod_12b; | ||
| 158 | u8 ref_sel; | ||
| 159 | u8 adc_freq; | ||
| 160 | u8 ave_ctrl; | ||
| 161 | u8 touch_det_delay; | ||
| 162 | u8 settling; | ||
| 163 | u8 fraction_z; | ||
| 164 | u8 i_drive; | ||
| 165 | }; | ||
| 166 | |||
| 167 | /** | ||
| 168 | * struct stmpe_platform_data - STMPE platform data | ||
| 169 | * @id: device id to distinguish between multiple STMPEs on the same board | ||
| 170 | * @blocks: bitmask of blocks to enable (use STMPE_BLOCK_*) | ||
| 171 | * @irq_trigger: IRQ trigger to use for the interrupt to the host | ||
| 172 | * @irq_invert_polarity: IRQ line is connected with reversed polarity | ||
| 173 | * @autosleep: bool to enable/disable stmpe autosleep | ||
| 174 | * @autosleep_timeout: inactivity timeout in milliseconds for autosleep | ||
| 175 | * @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or | ||
| 176 | * %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used. | ||
| 177 | * @gpio: GPIO-specific platform data | ||
| 178 | * @keypad: keypad-specific platform data | ||
| 179 | * @ts: touchscreen-specific platform data | ||
| 180 | */ | ||
| 181 | struct stmpe_platform_data { | ||
| 182 | int id; | ||
| 183 | unsigned int blocks; | ||
| 184 | int irq_base; | ||
| 185 | unsigned int irq_trigger; | ||
| 186 | bool irq_invert_polarity; | ||
| 187 | bool autosleep; | ||
| 188 | int autosleep_timeout; | ||
| 189 | |||
| 190 | struct stmpe_gpio_platform_data *gpio; | ||
| 191 | struct stmpe_keypad_platform_data *keypad; | ||
| 192 | struct stmpe_ts_platform_data *ts; | ||
| 193 | }; | ||
| 194 | |||
| 195 | #define STMPE_NR_INTERNAL_IRQS 9 | ||
| 196 | #define STMPE_INT_GPIO(x) (STMPE_NR_INTERNAL_IRQS + (x)) | ||
| 197 | |||
| 198 | #define STMPE_NR_GPIOS 24 | ||
| 199 | #define STMPE_NR_IRQS STMPE_INT_GPIO(STMPE_NR_GPIOS) | ||
| 200 | |||
| 201 | #endif | ||
diff --git a/include/linux/mfd/tps6586x.h b/include/linux/mfd/tps6586x.h new file mode 100644 index 000000000000..772b3ae640af --- /dev/null +++ b/include/linux/mfd/tps6586x.h | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | #ifndef __LINUX_MFD_TPS6586X_H | ||
| 2 | #define __LINUX_MFD_TPS6586X_H | ||
| 3 | |||
| 4 | enum { | ||
| 5 | TPS6586X_ID_SM_0, | ||
| 6 | TPS6586X_ID_SM_1, | ||
| 7 | TPS6586X_ID_SM_2, | ||
| 8 | TPS6586X_ID_LDO_0, | ||
| 9 | TPS6586X_ID_LDO_1, | ||
| 10 | TPS6586X_ID_LDO_2, | ||
| 11 | TPS6586X_ID_LDO_3, | ||
| 12 | TPS6586X_ID_LDO_4, | ||
| 13 | TPS6586X_ID_LDO_5, | ||
| 14 | TPS6586X_ID_LDO_6, | ||
| 15 | TPS6586X_ID_LDO_7, | ||
| 16 | TPS6586X_ID_LDO_8, | ||
| 17 | TPS6586X_ID_LDO_9, | ||
| 18 | TPS6586X_ID_LDO_RTC, | ||
| 19 | }; | ||
| 20 | |||
| 21 | struct tps6586x_subdev_info { | ||
| 22 | int id; | ||
| 23 | const char *name; | ||
| 24 | void *platform_data; | ||
| 25 | }; | ||
| 26 | |||
| 27 | struct tps6586x_platform_data { | ||
| 28 | int num_subdevs; | ||
| 29 | struct tps6586x_subdev_info *subdevs; | ||
| 30 | |||
| 31 | int gpio_base; | ||
| 32 | }; | ||
| 33 | |||
| 34 | /* | ||
| 35 | * NOTE: the functions below are not intended for use outside | ||
| 36 | * of the TPS6586X sub-device drivers | ||
| 37 | */ | ||
| 38 | extern int tps6586x_write(struct device *dev, int reg, uint8_t val); | ||
| 39 | extern int tps6586x_writes(struct device *dev, int reg, int len, uint8_t *val); | ||
| 40 | extern int tps6586x_read(struct device *dev, int reg, uint8_t *val); | ||
| 41 | extern int tps6586x_reads(struct device *dev, int reg, int len, uint8_t *val); | ||
| 42 | extern int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask); | ||
| 43 | extern int tps6586x_clr_bits(struct device *dev, int reg, uint8_t bit_mask); | ||
| 44 | extern int tps6586x_update(struct device *dev, int reg, uint8_t val, | ||
| 45 | uint8_t mask); | ||
| 46 | |||
| 47 | #endif /*__LINUX_MFD_TPS6586X_H */ | ||
diff --git a/include/linux/mfd/wm8994/gpio.h b/include/linux/mfd/wm8994/gpio.h index b4d4c22991e8..0c79b5ff4b5a 100644 --- a/include/linux/mfd/wm8994/gpio.h +++ b/include/linux/mfd/wm8994/gpio.h | |||
| @@ -36,6 +36,10 @@ | |||
| 36 | #define WM8994_GP_FN_WSEQ_STATUS 16 | 36 | #define WM8994_GP_FN_WSEQ_STATUS 16 |
| 37 | #define WM8994_GP_FN_FIFO_ERROR 17 | 37 | #define WM8994_GP_FN_FIFO_ERROR 17 |
| 38 | #define WM8994_GP_FN_OPCLK 18 | 38 | #define WM8994_GP_FN_OPCLK 18 |
| 39 | #define WM8994_GP_FN_THW 19 | ||
| 40 | #define WM8994_GP_FN_DCS_DONE 20 | ||
| 41 | #define WM8994_GP_FN_FLL1_OUT 21 | ||
| 42 | #define WM8994_GP_FN_FLL2_OUT 22 | ||
| 39 | 43 | ||
| 40 | #define WM8994_GPN_DIR 0x8000 /* GPN_DIR */ | 44 | #define WM8994_GPN_DIR 0x8000 /* GPN_DIR */ |
| 41 | #define WM8994_GPN_DIR_MASK 0x8000 /* GPN_DIR */ | 45 | #define WM8994_GPN_DIR_MASK 0x8000 /* GPN_DIR */ |
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h index f6c9b7dcb9fd..bafffc737903 100644 --- a/include/linux/miscdevice.h +++ b/include/linux/miscdevice.h | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #define KVM_MINOR 232 | 38 | #define KVM_MINOR 232 |
| 39 | #define BTRFS_MINOR 234 | 39 | #define BTRFS_MINOR 234 |
| 40 | #define AUTOFS_MINOR 235 | 40 | #define AUTOFS_MINOR 235 |
| 41 | #define MAPPER_CTRL_MINOR 236 | ||
| 41 | #define MISC_DYNAMIC_MINOR 255 | 42 | #define MISC_DYNAMIC_MINOR 255 |
| 42 | 43 | ||
| 43 | struct device; | 44 | struct device; |
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index d02d2c6e0cfe..6b7525099e56 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h | |||
| @@ -24,12 +24,14 @@ struct mmc_cid { | |||
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | struct mmc_csd { | 26 | struct mmc_csd { |
| 27 | unsigned char structure; | ||
| 27 | unsigned char mmca_vsn; | 28 | unsigned char mmca_vsn; |
| 28 | unsigned short cmdclass; | 29 | unsigned short cmdclass; |
| 29 | unsigned short tacc_clks; | 30 | unsigned short tacc_clks; |
| 30 | unsigned int tacc_ns; | 31 | unsigned int tacc_ns; |
| 31 | unsigned int r2w_factor; | 32 | unsigned int r2w_factor; |
| 32 | unsigned int max_dtr; | 33 | unsigned int max_dtr; |
| 34 | unsigned int erase_size; /* In sectors */ | ||
| 33 | unsigned int read_blkbits; | 35 | unsigned int read_blkbits; |
| 34 | unsigned int write_blkbits; | 36 | unsigned int write_blkbits; |
| 35 | unsigned int capacity; | 37 | unsigned int capacity; |
| @@ -41,9 +43,16 @@ struct mmc_csd { | |||
| 41 | 43 | ||
| 42 | struct mmc_ext_csd { | 44 | struct mmc_ext_csd { |
| 43 | u8 rev; | 45 | u8 rev; |
| 46 | u8 erase_group_def; | ||
| 47 | u8 sec_feature_support; | ||
| 44 | unsigned int sa_timeout; /* Units: 100ns */ | 48 | unsigned int sa_timeout; /* Units: 100ns */ |
| 45 | unsigned int hs_max_dtr; | 49 | unsigned int hs_max_dtr; |
| 46 | unsigned int sectors; | 50 | unsigned int sectors; |
| 51 | unsigned int hc_erase_size; /* In sectors */ | ||
| 52 | unsigned int hc_erase_timeout; /* In milliseconds */ | ||
| 53 | unsigned int sec_trim_mult; /* Secure trim multiplier */ | ||
| 54 | unsigned int sec_erase_mult; /* Secure erase multiplier */ | ||
| 55 | unsigned int trim_timeout; /* In milliseconds */ | ||
| 47 | }; | 56 | }; |
| 48 | 57 | ||
| 49 | struct sd_scr { | 58 | struct sd_scr { |
| @@ -53,6 +62,12 @@ struct sd_scr { | |||
| 53 | #define SD_SCR_BUS_WIDTH_4 (1<<2) | 62 | #define SD_SCR_BUS_WIDTH_4 (1<<2) |
| 54 | }; | 63 | }; |
| 55 | 64 | ||
| 65 | struct sd_ssr { | ||
| 66 | unsigned int au; /* In sectors */ | ||
| 67 | unsigned int erase_timeout; /* In milliseconds */ | ||
| 68 | unsigned int erase_offset; /* In milliseconds */ | ||
| 69 | }; | ||
| 70 | |||
| 56 | struct sd_switch_caps { | 71 | struct sd_switch_caps { |
| 57 | unsigned int hs_max_dtr; | 72 | unsigned int hs_max_dtr; |
| 58 | }; | 73 | }; |
| @@ -92,6 +107,7 @@ struct mmc_card { | |||
| 92 | #define MMC_TYPE_MMC 0 /* MMC card */ | 107 | #define MMC_TYPE_MMC 0 /* MMC card */ |
| 93 | #define MMC_TYPE_SD 1 /* SD card */ | 108 | #define MMC_TYPE_SD 1 /* SD card */ |
| 94 | #define MMC_TYPE_SDIO 2 /* SDIO card */ | 109 | #define MMC_TYPE_SDIO 2 /* SDIO card */ |
| 110 | #define MMC_TYPE_SD_COMBO 3 /* SD combo (IO+mem) card */ | ||
| 95 | unsigned int state; /* (our) card state */ | 111 | unsigned int state; /* (our) card state */ |
| 96 | #define MMC_STATE_PRESENT (1<<0) /* present in sysfs */ | 112 | #define MMC_STATE_PRESENT (1<<0) /* present in sysfs */ |
| 97 | #define MMC_STATE_READONLY (1<<1) /* card is read-only */ | 113 | #define MMC_STATE_READONLY (1<<1) /* card is read-only */ |
| @@ -101,6 +117,13 @@ struct mmc_card { | |||
| 101 | #define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */ | 117 | #define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */ |
| 102 | #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */ | 118 | #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */ |
| 103 | /* for byte mode */ | 119 | /* for byte mode */ |
| 120 | #define MMC_QUIRK_NONSTD_SDIO (1<<2) /* non-standard SDIO card attached */ | ||
| 121 | /* (missing CIA registers) */ | ||
| 122 | |||
| 123 | unsigned int erase_size; /* erase size in sectors */ | ||
| 124 | unsigned int erase_shift; /* if erase unit is power 2 */ | ||
| 125 | unsigned int pref_erase; /* in sectors */ | ||
| 126 | u8 erased_byte; /* value of erased bytes */ | ||
| 104 | 127 | ||
| 105 | u32 raw_cid[4]; /* raw card CID */ | 128 | u32 raw_cid[4]; /* raw card CID */ |
| 106 | u32 raw_csd[4]; /* raw card CSD */ | 129 | u32 raw_csd[4]; /* raw card CSD */ |
| @@ -109,6 +132,7 @@ struct mmc_card { | |||
| 109 | struct mmc_csd csd; /* card specific */ | 132 | struct mmc_csd csd; /* card specific */ |
| 110 | struct mmc_ext_csd ext_csd; /* mmc v4 extended card specific */ | 133 | struct mmc_ext_csd ext_csd; /* mmc v4 extended card specific */ |
| 111 | struct sd_scr scr; /* extra SD information */ | 134 | struct sd_scr scr; /* extra SD information */ |
| 135 | struct sd_ssr ssr; /* yet more SD information */ | ||
| 112 | struct sd_switch_caps sw_caps; /* switch (CMD6) caps */ | 136 | struct sd_switch_caps sw_caps; /* switch (CMD6) caps */ |
| 113 | 137 | ||
| 114 | unsigned int sdio_funcs; /* number of SDIO functions */ | 138 | unsigned int sdio_funcs; /* number of SDIO functions */ |
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index e4898e9eeb59..7429033acb66 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h | |||
| @@ -92,6 +92,8 @@ struct mmc_command { | |||
| 92 | * actively failing requests | 92 | * actively failing requests |
| 93 | */ | 93 | */ |
| 94 | 94 | ||
| 95 | unsigned int erase_timeout; /* in milliseconds */ | ||
| 96 | |||
| 95 | struct mmc_data *data; /* data segment associated with cmd */ | 97 | struct mmc_data *data; /* data segment associated with cmd */ |
| 96 | struct mmc_request *mrq; /* associated request */ | 98 | struct mmc_request *mrq; /* associated request */ |
| 97 | }; | 99 | }; |
| @@ -134,6 +136,23 @@ extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int); | |||
| 134 | extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *, | 136 | extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *, |
| 135 | struct mmc_command *, int); | 137 | struct mmc_command *, int); |
| 136 | 138 | ||
| 139 | #define MMC_ERASE_ARG 0x00000000 | ||
| 140 | #define MMC_SECURE_ERASE_ARG 0x80000000 | ||
| 141 | #define MMC_TRIM_ARG 0x00000001 | ||
| 142 | #define MMC_SECURE_TRIM1_ARG 0x80000001 | ||
| 143 | #define MMC_SECURE_TRIM2_ARG 0x80008000 | ||
| 144 | |||
| 145 | #define MMC_SECURE_ARGS 0x80000000 | ||
| 146 | #define MMC_TRIM_ARGS 0x00008001 | ||
| 147 | |||
| 148 | extern int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr, | ||
| 149 | unsigned int arg); | ||
| 150 | extern int mmc_can_erase(struct mmc_card *card); | ||
| 151 | extern int mmc_can_trim(struct mmc_card *card); | ||
| 152 | extern int mmc_can_secure_erase_trim(struct mmc_card *card); | ||
| 153 | extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from, | ||
| 154 | unsigned int nr); | ||
| 155 | |||
| 137 | extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *); | 156 | extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *); |
| 138 | extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int); | 157 | extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int); |
| 139 | 158 | ||
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index f65913c9f5a4..1575b52c3bfa 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h | |||
| @@ -124,6 +124,7 @@ struct mmc_host { | |||
| 124 | unsigned int f_min; | 124 | unsigned int f_min; |
| 125 | unsigned int f_max; | 125 | unsigned int f_max; |
| 126 | u32 ocr_avail; | 126 | u32 ocr_avail; |
| 127 | struct notifier_block pm_notify; | ||
| 127 | 128 | ||
| 128 | #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ | 129 | #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ |
| 129 | #define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */ | 130 | #define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */ |
| @@ -155,6 +156,7 @@ struct mmc_host { | |||
| 155 | #define MMC_CAP_DISABLE (1 << 7) /* Can the host be disabled */ | 156 | #define MMC_CAP_DISABLE (1 << 7) /* Can the host be disabled */ |
| 156 | #define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */ | 157 | #define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */ |
| 157 | #define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */ | 158 | #define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */ |
| 159 | #define MMC_CAP_ERASE (1 << 10) /* Allow erase/trim commands */ | ||
| 158 | 160 | ||
| 159 | mmc_pm_flag_t pm_caps; /* supported pm features */ | 161 | mmc_pm_flag_t pm_caps; /* supported pm features */ |
| 160 | 162 | ||
| @@ -183,6 +185,7 @@ struct mmc_host { | |||
| 183 | 185 | ||
| 184 | /* Only used with MMC_CAP_DISABLE */ | 186 | /* Only used with MMC_CAP_DISABLE */ |
| 185 | int enabled; /* host is enabled */ | 187 | int enabled; /* host is enabled */ |
| 188 | int rescan_disable; /* disable card detection */ | ||
| 186 | int nesting_cnt; /* "enable" nesting count */ | 189 | int nesting_cnt; /* "enable" nesting count */ |
| 187 | int en_dis_recurs; /* detect recursion */ | 190 | int en_dis_recurs; /* detect recursion */ |
| 188 | unsigned int disable_delay; /* disable delay in msecs */ | 191 | unsigned int disable_delay; /* disable delay in msecs */ |
| @@ -257,6 +260,7 @@ int mmc_card_can_sleep(struct mmc_host *host); | |||
| 257 | int mmc_host_enable(struct mmc_host *host); | 260 | int mmc_host_enable(struct mmc_host *host); |
| 258 | int mmc_host_disable(struct mmc_host *host); | 261 | int mmc_host_disable(struct mmc_host *host); |
| 259 | int mmc_host_lazy_disable(struct mmc_host *host); | 262 | int mmc_host_lazy_disable(struct mmc_host *host); |
| 263 | int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *); | ||
| 260 | 264 | ||
| 261 | static inline void mmc_set_disable_delay(struct mmc_host *host, | 265 | static inline void mmc_set_disable_delay(struct mmc_host *host, |
| 262 | unsigned int disable_delay) | 266 | unsigned int disable_delay) |
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 8a49cbf0376d..dd11ae51fb68 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h | |||
| @@ -251,12 +251,21 @@ struct _mmc_csd { | |||
| 251 | * EXT_CSD fields | 251 | * EXT_CSD fields |
| 252 | */ | 252 | */ |
| 253 | 253 | ||
| 254 | #define EXT_CSD_BUS_WIDTH 183 /* R/W */ | 254 | #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ |
| 255 | #define EXT_CSD_HS_TIMING 185 /* R/W */ | 255 | #define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ |
| 256 | #define EXT_CSD_CARD_TYPE 196 /* RO */ | 256 | #define EXT_CSD_BUS_WIDTH 183 /* R/W */ |
| 257 | #define EXT_CSD_REV 192 /* RO */ | 257 | #define EXT_CSD_HS_TIMING 185 /* R/W */ |
| 258 | #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ | 258 | #define EXT_CSD_REV 192 /* RO */ |
| 259 | #define EXT_CSD_S_A_TIMEOUT 217 | 259 | #define EXT_CSD_STRUCTURE 194 /* RO */ |
| 260 | #define EXT_CSD_CARD_TYPE 196 /* RO */ | ||
| 261 | #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ | ||
| 262 | #define EXT_CSD_S_A_TIMEOUT 217 /* RO */ | ||
| 263 | #define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ | ||
| 264 | #define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ | ||
| 265 | #define EXT_CSD_SEC_TRIM_MULT 229 /* RO */ | ||
| 266 | #define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ | ||
| 267 | #define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ | ||
| 268 | #define EXT_CSD_TRIM_MULT 232 /* RO */ | ||
| 260 | 269 | ||
| 261 | /* | 270 | /* |
| 262 | * EXT_CSD field definitions | 271 | * EXT_CSD field definitions |
| @@ -274,6 +283,10 @@ struct _mmc_csd { | |||
| 274 | #define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ | 283 | #define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ |
| 275 | #define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ | 284 | #define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ |
| 276 | 285 | ||
| 286 | #define EXT_CSD_SEC_ER_EN BIT(0) | ||
| 287 | #define EXT_CSD_SEC_BD_BLK_EN BIT(2) | ||
| 288 | #define EXT_CSD_SEC_GB_CL_EN BIT(4) | ||
| 289 | |||
| 277 | /* | 290 | /* |
| 278 | * MMC_SWITCH access modes | 291 | * MMC_SWITCH access modes |
| 279 | */ | 292 | */ |
diff --git a/include/linux/mmc/sd.h b/include/linux/mmc/sd.h index f310062cffb4..3fd85e088cc3 100644 --- a/include/linux/mmc/sd.h +++ b/include/linux/mmc/sd.h | |||
| @@ -21,8 +21,13 @@ | |||
| 21 | /* class 10 */ | 21 | /* class 10 */ |
| 22 | #define SD_SWITCH 6 /* adtc [31:0] See below R1 */ | 22 | #define SD_SWITCH 6 /* adtc [31:0] See below R1 */ |
| 23 | 23 | ||
| 24 | /* class 5 */ | ||
| 25 | #define SD_ERASE_WR_BLK_START 32 /* ac [31:0] data addr R1 */ | ||
| 26 | #define SD_ERASE_WR_BLK_END 33 /* ac [31:0] data addr R1 */ | ||
| 27 | |||
| 24 | /* Application commands */ | 28 | /* Application commands */ |
| 25 | #define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */ | 29 | #define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */ |
| 30 | #define SD_APP_SD_STATUS 13 /* adtc R1 */ | ||
| 26 | #define SD_APP_SEND_NUM_WR_BLKS 22 /* adtc R1 */ | 31 | #define SD_APP_SEND_NUM_WR_BLKS 22 /* adtc R1 */ |
| 27 | #define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */ | 32 | #define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */ |
| 28 | #define SD_APP_SEND_SCR 51 /* adtc R1 */ | 33 | #define SD_APP_SEND_SCR 51 /* adtc R1 */ |
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 82a9124f7d75..9d2f1837b3d8 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h | |||
| @@ -31,20 +31,23 @@ static const char __module_cat(name,__LINE__)[] \ | |||
| 31 | 31 | ||
| 32 | struct kernel_param; | 32 | struct kernel_param; |
| 33 | 33 | ||
| 34 | /* Returns 0, or -errno. arg is in kp->arg. */ | 34 | struct kernel_param_ops { |
| 35 | typedef int (*param_set_fn)(const char *val, struct kernel_param *kp); | 35 | /* Returns 0, or -errno. arg is in kp->arg. */ |
| 36 | /* Returns length written or -errno. Buffer is 4k (ie. be short!) */ | 36 | int (*set)(const char *val, const struct kernel_param *kp); |
| 37 | typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp); | 37 | /* Returns length written or -errno. Buffer is 4k (ie. be short!) */ |
| 38 | int (*get)(char *buffer, const struct kernel_param *kp); | ||
| 39 | /* Optional function to free kp->arg when module unloaded. */ | ||
| 40 | void (*free)(void *arg); | ||
| 41 | }; | ||
| 38 | 42 | ||
| 39 | /* Flag bits for kernel_param.flags */ | 43 | /* Flag bits for kernel_param.flags */ |
| 40 | #define KPARAM_ISBOOL 2 | 44 | #define KPARAM_ISBOOL 2 |
| 41 | 45 | ||
| 42 | struct kernel_param { | 46 | struct kernel_param { |
| 43 | const char *name; | 47 | const char *name; |
| 48 | const struct kernel_param_ops *ops; | ||
| 44 | u16 perm; | 49 | u16 perm; |
| 45 | u16 flags; | 50 | u16 flags; |
| 46 | param_set_fn set; | ||
| 47 | param_get_fn get; | ||
| 48 | union { | 51 | union { |
| 49 | void *arg; | 52 | void *arg; |
| 50 | const struct kparam_string *str; | 53 | const struct kparam_string *str; |
| @@ -63,12 +66,67 @@ struct kparam_array | |||
| 63 | { | 66 | { |
| 64 | unsigned int max; | 67 | unsigned int max; |
| 65 | unsigned int *num; | 68 | unsigned int *num; |
| 66 | param_set_fn set; | 69 | const struct kernel_param_ops *ops; |
| 67 | param_get_fn get; | ||
| 68 | unsigned int elemsize; | 70 | unsigned int elemsize; |
| 69 | void *elem; | 71 | void *elem; |
| 70 | }; | 72 | }; |
| 71 | 73 | ||
| 74 | /** | ||
| 75 | * module_param - typesafe helper for a module/cmdline parameter | ||
| 76 | * @value: the variable to alter, and exposed parameter name. | ||
| 77 | * @type: the type of the parameter | ||
| 78 | * @perm: visibility in sysfs. | ||
| 79 | * | ||
| 80 | * @value becomes the module parameter, or (prefixed by KBUILD_MODNAME and a | ||
| 81 | * ".") the kernel commandline parameter. Note that - is changed to _, so | ||
| 82 | * the user can use "foo-bar=1" even for variable "foo_bar". | ||
| 83 | * | ||
| 84 | * @perm is 0 if the the variable is not to appear in sysfs, or 0444 | ||
| 85 | * for world-readable, 0644 for root-writable, etc. Note that if it | ||
| 86 | * is writable, you may need to use kparam_block_sysfs_write() around | ||
| 87 | * accesses (esp. charp, which can be kfreed when it changes). | ||
| 88 | * | ||
| 89 | * The @type is simply pasted to refer to a param_ops_##type and a | ||
| 90 | * param_check_##type: for convenience many standard types are provided but | ||
| 91 | * you can create your own by defining those variables. | ||
| 92 | * | ||
| 93 | * Standard types are: | ||
| 94 | * byte, short, ushort, int, uint, long, ulong | ||
| 95 | * charp: a character pointer | ||
| 96 | * bool: a bool, values 0/1, y/n, Y/N. | ||
| 97 | * invbool: the above, only sense-reversed (N = true). | ||
| 98 | */ | ||
| 99 | #define module_param(name, type, perm) \ | ||
| 100 | module_param_named(name, name, type, perm) | ||
| 101 | |||
| 102 | /** | ||
| 103 | * module_param_named - typesafe helper for a renamed module/cmdline parameter | ||
| 104 | * @name: a valid C identifier which is the parameter name. | ||
| 105 | * @value: the actual lvalue to alter. | ||
| 106 | * @type: the type of the parameter | ||
| 107 | * @perm: visibility in sysfs. | ||
| 108 | * | ||
| 109 | * Usually it's a good idea to have variable names and user-exposed names the | ||
| 110 | * same, but that's harder if the variable must be non-static or is inside a | ||
| 111 | * structure. This allows exposure under a different name. | ||
| 112 | */ | ||
| 113 | #define module_param_named(name, value, type, perm) \ | ||
| 114 | param_check_##type(name, &(value)); \ | ||
| 115 | module_param_cb(name, ¶m_ops_##type, &value, perm); \ | ||
| 116 | __MODULE_PARM_TYPE(name, #type) | ||
| 117 | |||
| 118 | /** | ||
| 119 | * module_param_cb - general callback for a module/cmdline parameter | ||
| 120 | * @name: a valid C identifier which is the parameter name. | ||
| 121 | * @ops: the set & get operations for this parameter. | ||
| 122 | * @perm: visibility in sysfs. | ||
| 123 | * | ||
| 124 | * The ops can have NULL set or get functions. | ||
| 125 | */ | ||
| 126 | #define module_param_cb(name, ops, arg, perm) \ | ||
| 127 | __module_param_call(MODULE_PARAM_PREFIX, \ | ||
| 128 | name, ops, arg, __same_type((arg), bool *), perm) | ||
| 129 | |||
| 72 | /* On alpha, ia64 and ppc64 relocations to global data cannot go into | 130 | /* On alpha, ia64 and ppc64 relocations to global data cannot go into |
| 73 | read-only sections (which is part of respective UNIX ABI on these | 131 | read-only sections (which is part of respective UNIX ABI on these |
| 74 | platforms). So 'const' makes no sense and even causes compile failures | 132 | platforms). So 'const' makes no sense and even causes compile failures |
| @@ -80,10 +138,8 @@ struct kparam_array | |||
| 80 | #endif | 138 | #endif |
| 81 | 139 | ||
| 82 | /* This is the fundamental function for registering boot/module | 140 | /* This is the fundamental function for registering boot/module |
| 83 | parameters. perm sets the visibility in sysfs: 000 means it's | 141 | parameters. */ |
| 84 | not there, read bits mean it's readable, write bits mean it's | 142 | #define __module_param_call(prefix, name, ops, arg, isbool, perm) \ |
| 85 | writable. */ | ||
| 86 | #define __module_param_call(prefix, name, set, get, arg, isbool, perm) \ | ||
| 87 | /* Default value instead of permissions? */ \ | 143 | /* Default value instead of permissions? */ \ |
| 88 | static int __param_perm_check_##name __attribute__((unused)) = \ | 144 | static int __param_perm_check_##name __attribute__((unused)) = \ |
| 89 | BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \ | 145 | BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \ |
| @@ -92,31 +148,87 @@ struct kparam_array | |||
| 92 | static struct kernel_param __moduleparam_const __param_##name \ | 148 | static struct kernel_param __moduleparam_const __param_##name \ |
| 93 | __used \ | 149 | __used \ |
| 94 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ | 150 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ |
| 95 | = { __param_str_##name, perm, isbool ? KPARAM_ISBOOL : 0, \ | 151 | = { __param_str_##name, ops, perm, isbool ? KPARAM_ISBOOL : 0, \ |
| 96 | set, get, { arg } } | 152 | { arg } } |
| 153 | |||
| 154 | /* Obsolete - use module_param_cb() */ | ||
| 155 | #define module_param_call(name, set, get, arg, perm) \ | ||
| 156 | static struct kernel_param_ops __param_ops_##name = \ | ||
| 157 | { (void *)set, (void *)get }; \ | ||
| 158 | __module_param_call(MODULE_PARAM_PREFIX, \ | ||
| 159 | name, &__param_ops_##name, arg, \ | ||
| 160 | __same_type(arg, bool *), \ | ||
| 161 | (perm) + sizeof(__check_old_set_param(set))*0) | ||
| 162 | |||
| 163 | /* We don't get oldget: it's often a new-style param_get_uint, etc. */ | ||
| 164 | static inline int | ||
| 165 | __check_old_set_param(int (*oldset)(const char *, struct kernel_param *)) | ||
| 166 | { | ||
| 167 | return 0; | ||
| 168 | } | ||
| 97 | 169 | ||
| 98 | #define module_param_call(name, set, get, arg, perm) \ | 170 | /** |
| 99 | __module_param_call(MODULE_PARAM_PREFIX, \ | 171 | * kparam_block_sysfs_write - make sure a parameter isn't written via sysfs. |
| 100 | name, set, get, arg, \ | 172 | * @name: the name of the parameter |
| 101 | __same_type(*(arg), bool), perm) | 173 | * |
| 174 | * There's no point blocking write on a paramter that isn't writable via sysfs! | ||
| 175 | */ | ||
| 176 | #define kparam_block_sysfs_write(name) \ | ||
| 177 | do { \ | ||
| 178 | BUG_ON(!(__param_##name.perm & 0222)); \ | ||
| 179 | __kernel_param_lock(); \ | ||
| 180 | } while (0) | ||
| 102 | 181 | ||
| 103 | /* Helper functions: type is byte, short, ushort, int, uint, long, | 182 | /** |
| 104 | ulong, charp, bool or invbool, or XXX if you define param_get_XXX, | 183 | * kparam_unblock_sysfs_write - allows sysfs to write to a parameter again. |
| 105 | param_set_XXX and param_check_XXX. */ | 184 | * @name: the name of the parameter |
| 106 | #define module_param_named(name, value, type, perm) \ | 185 | */ |
| 107 | param_check_##type(name, &(value)); \ | 186 | #define kparam_unblock_sysfs_write(name) \ |
| 108 | module_param_call(name, param_set_##type, param_get_##type, &value, perm); \ | 187 | do { \ |
| 109 | __MODULE_PARM_TYPE(name, #type) | 188 | BUG_ON(!(__param_##name.perm & 0222)); \ |
| 189 | __kernel_param_unlock(); \ | ||
| 190 | } while (0) | ||
| 110 | 191 | ||
| 111 | #define module_param(name, type, perm) \ | 192 | /** |
| 112 | module_param_named(name, name, type, perm) | 193 | * kparam_block_sysfs_read - make sure a parameter isn't read via sysfs. |
| 194 | * @name: the name of the parameter | ||
| 195 | * | ||
| 196 | * This also blocks sysfs writes. | ||
| 197 | */ | ||
| 198 | #define kparam_block_sysfs_read(name) \ | ||
| 199 | do { \ | ||
| 200 | BUG_ON(!(__param_##name.perm & 0444)); \ | ||
| 201 | __kernel_param_lock(); \ | ||
| 202 | } while (0) | ||
| 203 | |||
| 204 | /** | ||
| 205 | * kparam_unblock_sysfs_read - allows sysfs to read a parameter again. | ||
| 206 | * @name: the name of the parameter | ||
| 207 | */ | ||
| 208 | #define kparam_unblock_sysfs_read(name) \ | ||
| 209 | do { \ | ||
| 210 | BUG_ON(!(__param_##name.perm & 0444)); \ | ||
| 211 | __kernel_param_unlock(); \ | ||
| 212 | } while (0) | ||
| 213 | |||
| 214 | #ifdef CONFIG_SYSFS | ||
| 215 | extern void __kernel_param_lock(void); | ||
| 216 | extern void __kernel_param_unlock(void); | ||
| 217 | #else | ||
| 218 | static inline void __kernel_param_lock(void) | ||
| 219 | { | ||
| 220 | } | ||
| 221 | static inline void __kernel_param_unlock(void) | ||
| 222 | { | ||
| 223 | } | ||
| 224 | #endif | ||
| 113 | 225 | ||
| 114 | #ifndef MODULE | 226 | #ifndef MODULE |
| 115 | /** | 227 | /** |
| 116 | * core_param - define a historical core kernel parameter. | 228 | * core_param - define a historical core kernel parameter. |
| 117 | * @name: the name of the cmdline and sysfs parameter (often the same as var) | 229 | * @name: the name of the cmdline and sysfs parameter (often the same as var) |
| 118 | * @var: the variable | 230 | * @var: the variable |
| 119 | * @type: the type (for param_set_##type and param_get_##type) | 231 | * @type: the type of the parameter |
| 120 | * @perm: visibility in sysfs | 232 | * @perm: visibility in sysfs |
| 121 | * | 233 | * |
| 122 | * core_param is just like module_param(), but cannot be modular and | 234 | * core_param is just like module_param(), but cannot be modular and |
| @@ -126,23 +238,32 @@ struct kparam_array | |||
| 126 | */ | 238 | */ |
| 127 | #define core_param(name, var, type, perm) \ | 239 | #define core_param(name, var, type, perm) \ |
| 128 | param_check_##type(name, &(var)); \ | 240 | param_check_##type(name, &(var)); \ |
| 129 | __module_param_call("", name, param_set_##type, param_get_##type, \ | 241 | __module_param_call("", name, ¶m_ops_##type, \ |
| 130 | &var, __same_type(var, bool), perm) | 242 | &var, __same_type(var, bool), perm) |
| 131 | #endif /* !MODULE */ | 243 | #endif /* !MODULE */ |
| 132 | 244 | ||
| 133 | /* Actually copy string: maxlen param is usually sizeof(string). */ | 245 | /** |
| 246 | * module_param_string - a char array parameter | ||
| 247 | * @name: the name of the parameter | ||
| 248 | * @string: the string variable | ||
| 249 | * @len: the maximum length of the string, incl. terminator | ||
| 250 | * @perm: visibility in sysfs. | ||
| 251 | * | ||
| 252 | * This actually copies the string when it's set (unlike type charp). | ||
| 253 | * @len is usually just sizeof(string). | ||
| 254 | */ | ||
| 134 | #define module_param_string(name, string, len, perm) \ | 255 | #define module_param_string(name, string, len, perm) \ |
| 135 | static const struct kparam_string __param_string_##name \ | 256 | static const struct kparam_string __param_string_##name \ |
| 136 | = { len, string }; \ | 257 | = { len, string }; \ |
| 137 | __module_param_call(MODULE_PARAM_PREFIX, name, \ | 258 | __module_param_call(MODULE_PARAM_PREFIX, name, \ |
| 138 | param_set_copystring, param_get_string, \ | 259 | ¶m_ops_string, \ |
| 139 | .str = &__param_string_##name, 0, perm); \ | 260 | .str = &__param_string_##name, 0, perm); \ |
| 140 | __MODULE_PARM_TYPE(name, "string") | 261 | __MODULE_PARM_TYPE(name, "string") |
| 141 | 262 | ||
| 142 | /* Called on module insert or kernel boot */ | 263 | /* Called on module insert or kernel boot */ |
| 143 | extern int parse_args(const char *name, | 264 | extern int parse_args(const char *name, |
| 144 | char *args, | 265 | char *args, |
| 145 | struct kernel_param *params, | 266 | const struct kernel_param *params, |
| 146 | unsigned num, | 267 | unsigned num, |
| 147 | int (*unknown)(char *param, char *val)); | 268 | int (*unknown)(char *param, char *val)); |
| 148 | 269 | ||
| @@ -162,72 +283,105 @@ static inline void destroy_params(const struct kernel_param *params, | |||
| 162 | #define __param_check(name, p, type) \ | 283 | #define __param_check(name, p, type) \ |
| 163 | static inline type *__check_##name(void) { return(p); } | 284 | static inline type *__check_##name(void) { return(p); } |
| 164 | 285 | ||
| 165 | extern int param_set_byte(const char *val, struct kernel_param *kp); | 286 | extern struct kernel_param_ops param_ops_byte; |
| 166 | extern int param_get_byte(char *buffer, struct kernel_param *kp); | 287 | extern int param_set_byte(const char *val, const struct kernel_param *kp); |
| 288 | extern int param_get_byte(char *buffer, const struct kernel_param *kp); | ||
| 167 | #define param_check_byte(name, p) __param_check(name, p, unsigned char) | 289 | #define param_check_byte(name, p) __param_check(name, p, unsigned char) |
| 168 | 290 | ||
| 169 | extern int param_set_short(const char *val, struct kernel_param *kp); | 291 | extern struct kernel_param_ops param_ops_short; |
| 170 | extern int param_get_short(char *buffer, struct kernel_param *kp); | 292 | extern int param_set_short(const char *val, const struct kernel_param *kp); |
| 293 | extern int param_get_short(char *buffer, const struct kernel_param *kp); | ||
| 171 | #define param_check_short(name, p) __param_check(name, p, short) | 294 | #define param_check_short(name, p) __param_check(name, p, short) |
| 172 | 295 | ||
| 173 | extern int param_set_ushort(const char *val, struct kernel_param *kp); | 296 | extern struct kernel_param_ops param_ops_ushort; |
| 174 | extern int param_get_ushort(char *buffer, struct kernel_param *kp); | 297 | extern int param_set_ushort(const char *val, const struct kernel_param *kp); |
| 298 | extern int param_get_ushort(char *buffer, const struct kernel_param *kp); | ||
| 175 | #define param_check_ushort(name, p) __param_check(name, p, unsigned short) | 299 | #define param_check_ushort(name, p) __param_check(name, p, unsigned short) |
| 176 | 300 | ||
| 177 | extern int param_set_int(const char *val, struct kernel_param *kp); | 301 | extern struct kernel_param_ops param_ops_int; |
| 178 | extern int param_get_int(char *buffer, struct kernel_param *kp); | 302 | extern int param_set_int(const char *val, const struct kernel_param *kp); |
| 303 | extern int param_get_int(char *buffer, const struct kernel_param *kp); | ||
| 179 | #define param_check_int(name, p) __param_check(name, p, int) | 304 | #define param_check_int(name, p) __param_check(name, p, int) |
| 180 | 305 | ||
| 181 | extern int param_set_uint(const char *val, struct kernel_param *kp); | 306 | extern struct kernel_param_ops param_ops_uint; |
| 182 | extern int param_get_uint(char *buffer, struct kernel_param *kp); | 307 | extern int param_set_uint(const char *val, const struct kernel_param *kp); |
| 308 | extern int param_get_uint(char *buffer, const struct kernel_param *kp); | ||
| 183 | #define param_check_uint(name, p) __param_check(name, p, unsigned int) | 309 | #define param_check_uint(name, p) __param_check(name, p, unsigned int) |
| 184 | 310 | ||
| 185 | extern int param_set_long(const char *val, struct kernel_param *kp); | 311 | extern struct kernel_param_ops param_ops_long; |
| 186 | extern int param_get_long(char *buffer, struct kernel_param *kp); | 312 | extern int param_set_long(const char *val, const struct kernel_param *kp); |
| 313 | extern int param_get_long(char *buffer, const struct kernel_param *kp); | ||
| 187 | #define param_check_long(name, p) __param_check(name, p, long) | 314 | #define param_check_long(name, p) __param_check(name, p, long) |
| 188 | 315 | ||
| 189 | extern int param_set_ulong(const char *val, struct kernel_param *kp); | 316 | extern struct kernel_param_ops param_ops_ulong; |
| 190 | extern int param_get_ulong(char *buffer, struct kernel_param *kp); | 317 | extern int param_set_ulong(const char *val, const struct kernel_param *kp); |
| 318 | extern int param_get_ulong(char *buffer, const struct kernel_param *kp); | ||
| 191 | #define param_check_ulong(name, p) __param_check(name, p, unsigned long) | 319 | #define param_check_ulong(name, p) __param_check(name, p, unsigned long) |
| 192 | 320 | ||
| 193 | extern int param_set_charp(const char *val, struct kernel_param *kp); | 321 | extern struct kernel_param_ops param_ops_charp; |
| 194 | extern int param_get_charp(char *buffer, struct kernel_param *kp); | 322 | extern int param_set_charp(const char *val, const struct kernel_param *kp); |
| 323 | extern int param_get_charp(char *buffer, const struct kernel_param *kp); | ||
| 195 | #define param_check_charp(name, p) __param_check(name, p, char *) | 324 | #define param_check_charp(name, p) __param_check(name, p, char *) |
| 196 | 325 | ||
| 197 | /* For historical reasons "bool" parameters can be (unsigned) "int". */ | 326 | /* For historical reasons "bool" parameters can be (unsigned) "int". */ |
| 198 | extern int param_set_bool(const char *val, struct kernel_param *kp); | 327 | extern struct kernel_param_ops param_ops_bool; |
| 199 | extern int param_get_bool(char *buffer, struct kernel_param *kp); | 328 | extern int param_set_bool(const char *val, const struct kernel_param *kp); |
| 329 | extern int param_get_bool(char *buffer, const struct kernel_param *kp); | ||
| 200 | #define param_check_bool(name, p) \ | 330 | #define param_check_bool(name, p) \ |
| 201 | static inline void __check_##name(void) \ | 331 | static inline void __check_##name(void) \ |
| 202 | { \ | 332 | { \ |
| 203 | BUILD_BUG_ON(!__same_type(*(p), bool) && \ | 333 | BUILD_BUG_ON(!__same_type((p), bool *) && \ |
| 204 | !__same_type(*(p), unsigned int) && \ | 334 | !__same_type((p), unsigned int *) && \ |
| 205 | !__same_type(*(p), int)); \ | 335 | !__same_type((p), int *)); \ |
| 206 | } | 336 | } |
| 207 | 337 | ||
| 208 | extern int param_set_invbool(const char *val, struct kernel_param *kp); | 338 | extern struct kernel_param_ops param_ops_invbool; |
| 209 | extern int param_get_invbool(char *buffer, struct kernel_param *kp); | 339 | extern int param_set_invbool(const char *val, const struct kernel_param *kp); |
| 340 | extern int param_get_invbool(char *buffer, const struct kernel_param *kp); | ||
| 210 | #define param_check_invbool(name, p) __param_check(name, p, bool) | 341 | #define param_check_invbool(name, p) __param_check(name, p, bool) |
| 211 | 342 | ||
| 212 | /* Comma-separated array: *nump is set to number they actually specified. */ | 343 | /** |
| 344 | * module_param_array - a parameter which is an array of some type | ||
| 345 | * @name: the name of the array variable | ||
| 346 | * @type: the type, as per module_param() | ||
| 347 | * @nump: optional pointer filled in with the number written | ||
| 348 | * @perm: visibility in sysfs | ||
| 349 | * | ||
| 350 | * Input and output are as comma-separated values. Commas inside values | ||
| 351 | * don't work properly (eg. an array of charp). | ||
| 352 | * | ||
| 353 | * ARRAY_SIZE(@name) is used to determine the number of elements in the | ||
| 354 | * array, so the definition must be visible. | ||
| 355 | */ | ||
| 356 | #define module_param_array(name, type, nump, perm) \ | ||
| 357 | module_param_array_named(name, name, type, nump, perm) | ||
| 358 | |||
| 359 | /** | ||
| 360 | * module_param_array_named - renamed parameter which is an array of some type | ||
| 361 | * @name: a valid C identifier which is the parameter name | ||
| 362 | * @array: the name of the array variable | ||
| 363 | * @type: the type, as per module_param() | ||
| 364 | * @nump: optional pointer filled in with the number written | ||
| 365 | * @perm: visibility in sysfs | ||
| 366 | * | ||
| 367 | * This exposes a different name than the actual variable name. See | ||
| 368 | * module_param_named() for why this might be necessary. | ||
| 369 | */ | ||
| 213 | #define module_param_array_named(name, array, type, nump, perm) \ | 370 | #define module_param_array_named(name, array, type, nump, perm) \ |
| 214 | static const struct kparam_array __param_arr_##name \ | 371 | static const struct kparam_array __param_arr_##name \ |
| 215 | = { ARRAY_SIZE(array), nump, param_set_##type, param_get_##type,\ | 372 | = { ARRAY_SIZE(array), nump, ¶m_ops_##type, \ |
| 216 | sizeof(array[0]), array }; \ | 373 | sizeof(array[0]), array }; \ |
| 217 | __module_param_call(MODULE_PARAM_PREFIX, name, \ | 374 | __module_param_call(MODULE_PARAM_PREFIX, name, \ |
| 218 | param_array_set, param_array_get, \ | 375 | ¶m_array_ops, \ |
| 219 | .arr = &__param_arr_##name, \ | 376 | .arr = &__param_arr_##name, \ |
| 220 | __same_type(array[0], bool), perm); \ | 377 | __same_type(array[0], bool), perm); \ |
| 221 | __MODULE_PARM_TYPE(name, "array of " #type) | 378 | __MODULE_PARM_TYPE(name, "array of " #type) |
| 222 | 379 | ||
| 223 | #define module_param_array(name, type, nump, perm) \ | 380 | extern struct kernel_param_ops param_array_ops; |
| 224 | module_param_array_named(name, name, type, nump, perm) | ||
| 225 | |||
| 226 | extern int param_array_set(const char *val, struct kernel_param *kp); | ||
| 227 | extern int param_array_get(char *buffer, struct kernel_param *kp); | ||
| 228 | 381 | ||
| 229 | extern int param_set_copystring(const char *val, struct kernel_param *kp); | 382 | extern struct kernel_param_ops param_ops_string; |
| 230 | extern int param_get_string(char *buffer, struct kernel_param *kp); | 383 | extern int param_set_copystring(const char *val, const struct kernel_param *); |
| 384 | extern int param_get_string(char *buffer, const struct kernel_param *kp); | ||
| 231 | 385 | ||
| 232 | /* for exporting parameters in /sys/parameters */ | 386 | /* for exporting parameters in /sys/parameters */ |
| 233 | 387 | ||
| @@ -235,13 +389,13 @@ struct module; | |||
| 235 | 389 | ||
| 236 | #if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES) | 390 | #if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES) |
| 237 | extern int module_param_sysfs_setup(struct module *mod, | 391 | extern int module_param_sysfs_setup(struct module *mod, |
| 238 | struct kernel_param *kparam, | 392 | const struct kernel_param *kparam, |
| 239 | unsigned int num_params); | 393 | unsigned int num_params); |
| 240 | 394 | ||
| 241 | extern void module_param_sysfs_remove(struct module *mod); | 395 | extern void module_param_sysfs_remove(struct module *mod); |
| 242 | #else | 396 | #else |
| 243 | static inline int module_param_sysfs_setup(struct module *mod, | 397 | static inline int module_param_sysfs_setup(struct module *mod, |
| 244 | struct kernel_param *kparam, | 398 | const struct kernel_param *kparam, |
| 245 | unsigned int num_params) | 399 | unsigned int num_params) |
| 246 | { | 400 | { |
| 247 | return 0; | 401 | return 0; |
diff --git a/include/linux/mount.h b/include/linux/mount.h index 907210bd9f9c..5e7a59408dd4 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h | |||
| @@ -27,7 +27,6 @@ struct mnt_namespace; | |||
| 27 | #define MNT_NODIRATIME 0x10 | 27 | #define MNT_NODIRATIME 0x10 |
| 28 | #define MNT_RELATIME 0x20 | 28 | #define MNT_RELATIME 0x20 |
| 29 | #define MNT_READONLY 0x40 /* does the user want this to be r/o? */ | 29 | #define MNT_READONLY 0x40 /* does the user want this to be r/o? */ |
| 30 | #define MNT_STRICTATIME 0x80 | ||
| 31 | 30 | ||
| 32 | #define MNT_SHRINKABLE 0x100 | 31 | #define MNT_SHRINKABLE 0x100 |
| 33 | #define MNT_WRITE_HOLD 0x200 | 32 | #define MNT_WRITE_HOLD 0x200 |
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index 413742c92d14..791d5109f34c 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h | |||
| @@ -122,7 +122,7 @@ static inline int netpoll_tx_running(struct net_device *dev) | |||
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #else | 124 | #else |
| 125 | static inline int netpoll_rx(struct sk_buff *skb) | 125 | static inline bool netpoll_rx(struct sk_buff *skb) |
| 126 | { | 126 | { |
| 127 | return 0; | 127 | return 0; |
| 128 | } | 128 | } |
diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 35aa44ad9f2c..835f85ecd2de 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h | |||
| @@ -1,20 +1,6 @@ | |||
| 1 | #ifndef _LINUX_OF_DEVICE_H | 1 | #ifndef _LINUX_OF_DEVICE_H |
| 2 | #define _LINUX_OF_DEVICE_H | 2 | #define _LINUX_OF_DEVICE_H |
| 3 | 3 | ||
| 4 | /* | ||
| 5 | * The of_device *was* a kind of "base class" that was a superset of | ||
| 6 | * struct device for use by devices attached to an OF node and probed | ||
| 7 | * using OF properties. However, the important bit of OF-style | ||
| 8 | * probing, namely the device node pointer, has been moved into the | ||
| 9 | * common struct device when CONFIG_OF is set to make OF-style probing | ||
| 10 | * available to all bus types. So now, just make of_device and | ||
| 11 | * platform_device equivalent so that current of_platform bus users | ||
| 12 | * can be transparently migrated over to using the platform bus. | ||
| 13 | * | ||
| 14 | * This line will go away once all references to of_device are removed | ||
| 15 | * from the kernel. | ||
| 16 | */ | ||
| 17 | #define of_device platform_device | ||
| 18 | #include <linux/platform_device.h> | 4 | #include <linux/platform_device.h> |
| 19 | #include <linux/of_platform.h> /* temporary until merge */ | 5 | #include <linux/of_platform.h> /* temporary until merge */ |
| 20 | 6 | ||
| @@ -23,8 +9,6 @@ | |||
| 23 | #include <linux/of.h> | 9 | #include <linux/of.h> |
| 24 | #include <linux/mod_devicetable.h> | 10 | #include <linux/mod_devicetable.h> |
| 25 | 11 | ||
| 26 | #define to_of_device(d) container_of(d, struct of_device, dev) | ||
| 27 | |||
| 28 | extern const struct of_device_id *of_match_device( | 12 | extern const struct of_device_id *of_match_device( |
| 29 | const struct of_device_id *matches, const struct device *dev); | 13 | const struct of_device_id *matches, const struct device *dev); |
| 30 | extern void of_device_make_bus_id(struct device *dev); | 14 | extern void of_device_make_bus_id(struct device *dev); |
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 4e6d989c06df..a68716ad38ce 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h | |||
| @@ -19,9 +19,17 @@ | |||
| 19 | #include <linux/of_device.h> | 19 | #include <linux/of_device.h> |
| 20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
| 21 | 21 | ||
| 22 | /* | 22 | /** |
| 23 | * An of_platform_driver driver is attached to a basic of_device on | 23 | * of_platform_driver - Legacy of-aware driver for platform devices. |
| 24 | * the "platform bus" (platform_bus_type). | 24 | * |
| 25 | * An of_platform_driver driver is attached to a basic platform_device on | ||
| 26 | * ether the "platform bus" (platform_bus_type), or the ibm ebus | ||
| 27 | * (ibmebus_bus_type). | ||
| 28 | * | ||
| 29 | * of_platform_driver is being phased out when used with the platform_bus_type, | ||
| 30 | * and regular platform_drivers should be used instead. When the transition | ||
| 31 | * is complete, only ibmebus will be using this structure, and the | ||
| 32 | * platform_driver member of this structure will be removed. | ||
| 25 | */ | 33 | */ |
| 26 | struct of_platform_driver | 34 | struct of_platform_driver |
| 27 | { | 35 | { |
diff --git a/include/linux/oom.h b/include/linux/oom.h index f209b683e118..5e3aa8311c5e 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h | |||
| @@ -66,6 +66,8 @@ static inline void oom_killer_enable(void) | |||
| 66 | extern unsigned long badness(struct task_struct *p, struct mem_cgroup *mem, | 66 | extern unsigned long badness(struct task_struct *p, struct mem_cgroup *mem, |
| 67 | const nodemask_t *nodemask, unsigned long uptime); | 67 | const nodemask_t *nodemask, unsigned long uptime); |
| 68 | 68 | ||
| 69 | extern struct task_struct *find_lock_task_mm(struct task_struct *p); | ||
| 70 | |||
| 69 | /* sysctls */ | 71 | /* sysctls */ |
| 70 | extern int sysctl_oom_dump_tasks; | 72 | extern int sysctl_oom_dump_tasks; |
| 71 | extern int sysctl_oom_kill_allocating_task; | 73 | extern int sysctl_oom_kill_allocating_task; |
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 78a702ce4fcb..e12cdc6d79ee 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <linux/gfp.h> | 13 | #include <linux/gfp.h> |
| 14 | #include <linux/bitops.h> | 14 | #include <linux/bitops.h> |
| 15 | #include <linux/hardirq.h> /* for in_interrupt() */ | 15 | #include <linux/hardirq.h> /* for in_interrupt() */ |
| 16 | #include <linux/hugetlb_inline.h> | ||
| 16 | 17 | ||
| 17 | /* | 18 | /* |
| 18 | * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page | 19 | * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page |
| @@ -281,10 +282,16 @@ static inline loff_t page_offset(struct page *page) | |||
| 281 | return ((loff_t)page->index) << PAGE_CACHE_SHIFT; | 282 | return ((loff_t)page->index) << PAGE_CACHE_SHIFT; |
| 282 | } | 283 | } |
| 283 | 284 | ||
| 285 | extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma, | ||
| 286 | unsigned long address); | ||
| 287 | |||
| 284 | static inline pgoff_t linear_page_index(struct vm_area_struct *vma, | 288 | static inline pgoff_t linear_page_index(struct vm_area_struct *vma, |
| 285 | unsigned long address) | 289 | unsigned long address) |
| 286 | { | 290 | { |
| 287 | pgoff_t pgoff = (address - vma->vm_start) >> PAGE_SHIFT; | 291 | pgoff_t pgoff; |
| 292 | if (unlikely(is_vm_hugetlb_page(vma))) | ||
| 293 | return linear_hugepage_index(vma, address); | ||
| 294 | pgoff = (address - vma->vm_start) >> PAGE_SHIFT; | ||
| 288 | pgoff += vma->vm_pgoff; | 295 | pgoff += vma->vm_pgoff; |
| 289 | return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT); | 296 | return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT); |
| 290 | } | 297 | } |
diff --git a/include/linux/path.h b/include/linux/path.h index 915e0c382a51..edc98dec6266 100644 --- a/include/linux/path.h +++ b/include/linux/path.h | |||
| @@ -12,4 +12,9 @@ struct path { | |||
| 12 | extern void path_get(struct path *); | 12 | extern void path_get(struct path *); |
| 13 | extern void path_put(struct path *); | 13 | extern void path_put(struct path *); |
| 14 | 14 | ||
| 15 | static inline int path_equal(const struct path *path1, const struct path *path2) | ||
| 16 | { | ||
| 17 | return path1->mnt == path2->mnt && path1->dentry == path2->dentry; | ||
| 18 | } | ||
| 19 | |||
| 15 | #endif /* _LINUX_PATH_H */ | 20 | #endif /* _LINUX_PATH_H */ |
diff --git a/include/linux/poison.h b/include/linux/poison.h index 34066ffd893d..2110a81c5e2a 100644 --- a/include/linux/poison.h +++ b/include/linux/poison.h | |||
| @@ -48,15 +48,6 @@ | |||
| 48 | #define POISON_FREE 0x6b /* for use-after-free poisoning */ | 48 | #define POISON_FREE 0x6b /* for use-after-free poisoning */ |
| 49 | #define POISON_END 0xa5 /* end-byte of poisoning */ | 49 | #define POISON_END 0xa5 /* end-byte of poisoning */ |
| 50 | 50 | ||
| 51 | /********** mm/hugetlb.c **********/ | ||
| 52 | /* | ||
| 53 | * Private mappings of hugetlb pages use this poisoned value for | ||
| 54 | * page->mapping. The core VM should not be doing anything with this mapping | ||
| 55 | * but futex requires the existence of some page->mapping value even though it | ||
| 56 | * is unused if PAGE_MAPPING_ANON is set. | ||
| 57 | */ | ||
| 58 | #define HUGETLB_POISON ((void *)(0x00300300 + POISON_POINTER_DELTA + PAGE_MAPPING_ANON)) | ||
| 59 | |||
| 60 | /********** arch/$ARCH/mm/init.c **********/ | 51 | /********** arch/$ARCH/mm/init.c **********/ |
| 61 | #define POISON_FREE_INITMEM 0xcc | 52 | #define POISON_FREE_INITMEM 0xcc |
| 62 | 53 | ||
diff --git a/include/linux/raid/pq.h b/include/linux/raid/pq.h index 1cbbd2c11aa9..2b59cc824395 100644 --- a/include/linux/raid/pq.h +++ b/include/linux/raid/pq.h | |||
| @@ -62,7 +62,9 @@ extern const char raid6_empty_zero_page[PAGE_SIZE]; | |||
| 62 | #define disable_kernel_altivec() | 62 | #define disable_kernel_altivec() |
| 63 | 63 | ||
| 64 | #define EXPORT_SYMBOL(sym) | 64 | #define EXPORT_SYMBOL(sym) |
| 65 | #define EXPORT_SYMBOL_GPL(sym) | ||
| 65 | #define MODULE_LICENSE(licence) | 66 | #define MODULE_LICENSE(licence) |
| 67 | #define MODULE_DESCRIPTION(desc) | ||
| 66 | #define subsys_initcall(x) | 68 | #define subsys_initcall(x) |
| 67 | #define module_exit(x) | 69 | #define module_exit(x) |
| 68 | #endif /* __KERNEL__ */ | 70 | #endif /* __KERNEL__ */ |
diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h new file mode 100644 index 000000000000..f509877c2ed4 --- /dev/null +++ b/include/linux/regulator/ab8500.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) ST-Ericsson SA 2010 | ||
| 3 | * | ||
| 4 | * License Terms: GNU General Public License v2 | ||
| 5 | * | ||
| 6 | * Author: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson | ||
| 7 | * | ||
| 8 | */ | ||
| 9 | |||
| 10 | #ifndef __LINUX_MFD_AB8500_REGULATOR_H | ||
| 11 | #define __LINUX_MFD_AB8500_REGULATOR_H | ||
| 12 | |||
| 13 | /* AB8500 regulators */ | ||
| 14 | #define AB8500_LDO_AUX1 0 | ||
| 15 | #define AB8500_LDO_AUX2 1 | ||
| 16 | #define AB8500_LDO_AUX3 2 | ||
| 17 | #define AB8500_LDO_INTCORE 3 | ||
| 18 | #define AB8500_LDO_TVOUT 4 | ||
| 19 | #define AB8500_LDO_AUDIO 5 | ||
| 20 | #define AB8500_LDO_ANAMIC1 6 | ||
| 21 | #define AB8500_LDO_ANAMIC2 7 | ||
| 22 | #define AB8500_LDO_DMIC 8 | ||
| 23 | #define AB8500_LDO_ANA 9 | ||
| 24 | |||
| 25 | #endif | ||
diff --git a/include/linux/rmap.h b/include/linux/rmap.h index d6661de56f30..31b2fd75dcba 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h | |||
| @@ -168,6 +168,11 @@ void page_add_new_anon_rmap(struct page *, struct vm_area_struct *, unsigned lon | |||
| 168 | void page_add_file_rmap(struct page *); | 168 | void page_add_file_rmap(struct page *); |
| 169 | void page_remove_rmap(struct page *); | 169 | void page_remove_rmap(struct page *); |
| 170 | 170 | ||
| 171 | void hugepage_add_anon_rmap(struct page *, struct vm_area_struct *, | ||
| 172 | unsigned long); | ||
| 173 | void hugepage_add_new_anon_rmap(struct page *, struct vm_area_struct *, | ||
| 174 | unsigned long); | ||
| 175 | |||
| 171 | static inline void page_dup_rmap(struct page *page) | 176 | static inline void page_dup_rmap(struct page *page) |
| 172 | { | 177 | { |
| 173 | atomic_inc(&page->_mapcount); | 178 | atomic_inc(&page->_mapcount); |
diff --git a/include/linux/s3c_adc_battery.h b/include/linux/s3c_adc_battery.h new file mode 100644 index 000000000000..dbce22faa660 --- /dev/null +++ b/include/linux/s3c_adc_battery.h | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | #ifndef _S3C_ADC_BATTERY_H | ||
| 2 | #define _S3C_ADC_BATTERY_H | ||
| 3 | |||
| 4 | struct s3c_adc_bat_thresh { | ||
| 5 | int volt; /* mV */ | ||
| 6 | int cur; /* mA */ | ||
| 7 | int level; /* percent */ | ||
| 8 | }; | ||
| 9 | |||
| 10 | struct s3c_adc_bat_pdata { | ||
| 11 | int (*init)(void); | ||
| 12 | void (*exit)(void); | ||
| 13 | void (*enable_charger)(void); | ||
| 14 | void (*disable_charger)(void); | ||
| 15 | |||
| 16 | int gpio_charge_finished; | ||
| 17 | |||
| 18 | const struct s3c_adc_bat_thresh *lut_noac; | ||
| 19 | unsigned int lut_noac_cnt; | ||
| 20 | const struct s3c_adc_bat_thresh *lut_acin; | ||
| 21 | unsigned int lut_acin_cnt; | ||
| 22 | |||
| 23 | const unsigned int volt_channel; | ||
| 24 | const unsigned int current_channel; | ||
| 25 | const unsigned int backup_volt_channel; | ||
| 26 | |||
| 27 | const unsigned int volt_mult; | ||
| 28 | const unsigned int current_mult; | ||
| 29 | const unsigned int backup_volt_mult; | ||
| 30 | const unsigned int internal_impedance; | ||
| 31 | |||
| 32 | const unsigned int backup_volt_max; | ||
| 33 | const unsigned int backup_volt_min; | ||
| 34 | }; | ||
| 35 | |||
| 36 | #endif | ||
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 8129ca2d57e3..3c2ad99fed34 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h | |||
| @@ -186,6 +186,9 @@ | |||
| 186 | #define PORT_ALTERA_JTAGUART 91 | 186 | #define PORT_ALTERA_JTAGUART 91 |
| 187 | #define PORT_ALTERA_UART 92 | 187 | #define PORT_ALTERA_UART 92 |
| 188 | 188 | ||
| 189 | /* SH-SCI */ | ||
| 190 | #define PORT_SCIFB 93 | ||
| 191 | |||
| 189 | /* MAX3107 */ | 192 | /* MAX3107 */ |
| 190 | #define PORT_MAX3107 94 | 193 | #define PORT_MAX3107 94 |
| 191 | 194 | ||
diff --git a/include/linux/sh_clk.h b/include/linux/sh_clk.h index 1636d1e2a5f1..875ce50719a9 100644 --- a/include/linux/sh_clk.h +++ b/include/linux/sh_clk.h | |||
| @@ -25,6 +25,10 @@ struct clk { | |||
| 25 | int id; | 25 | int id; |
| 26 | 26 | ||
| 27 | struct clk *parent; | 27 | struct clk *parent; |
| 28 | struct clk **parent_table; /* list of parents to */ | ||
| 29 | unsigned short parent_num; /* choose between */ | ||
| 30 | unsigned char src_shift; /* source clock field in the */ | ||
| 31 | unsigned char src_width; /* configuration register */ | ||
| 28 | struct clk_ops *ops; | 32 | struct clk_ops *ops; |
| 29 | 33 | ||
| 30 | struct list_head children; | 34 | struct list_head children; |
| @@ -138,13 +142,22 @@ int sh_clk_div4_enable_register(struct clk *clks, int nr, | |||
| 138 | int sh_clk_div4_reparent_register(struct clk *clks, int nr, | 142 | int sh_clk_div4_reparent_register(struct clk *clks, int nr, |
| 139 | struct clk_div4_table *table); | 143 | struct clk_div4_table *table); |
| 140 | 144 | ||
| 141 | #define SH_CLK_DIV6(_parent, _reg, _flags) \ | 145 | #define SH_CLK_DIV6_EXT(_parent, _reg, _flags, _parents, \ |
| 142 | { \ | 146 | _num_parents, _src_shift, _src_width) \ |
| 143 | .parent = _parent, \ | 147 | { \ |
| 144 | .enable_reg = (void __iomem *)_reg, \ | 148 | .parent = _parent, \ |
| 145 | .flags = _flags, \ | 149 | .enable_reg = (void __iomem *)_reg, \ |
| 150 | .flags = _flags, \ | ||
| 151 | .parent_table = _parents, \ | ||
| 152 | .parent_num = _num_parents, \ | ||
| 153 | .src_shift = _src_shift, \ | ||
| 154 | .src_width = _src_width, \ | ||
| 146 | } | 155 | } |
| 147 | 156 | ||
| 157 | #define SH_CLK_DIV6(_parent, _reg, _flags) \ | ||
| 158 | SH_CLK_DIV6_EXT(_parent, _reg, _flags, NULL, 0, 0, 0) | ||
| 159 | |||
| 148 | int sh_clk_div6_register(struct clk *clks, int nr); | 160 | int sh_clk_div6_register(struct clk *clks, int nr); |
| 161 | int sh_clk_div6_reparent_register(struct clk *clks, int nr); | ||
| 149 | 162 | ||
| 150 | #endif /* __SH_CLOCK_H */ | 163 | #endif /* __SH_CLOCK_H */ |
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h index 1acfa73ce2ac..791a502f6906 100644 --- a/include/linux/slab_def.h +++ b/include/linux/slab_def.h | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | 17 | ||
| 18 | #include <trace/events/kmem.h> | 18 | #include <trace/events/kmem.h> |
| 19 | 19 | ||
| 20 | #ifndef ARCH_KMALLOC_MINALIGN | ||
| 21 | /* | 20 | /* |
| 22 | * Enforce a minimum alignment for the kmalloc caches. | 21 | * Enforce a minimum alignment for the kmalloc caches. |
| 23 | * Usually, the kmalloc caches are cache_line_size() aligned, except when | 22 | * Usually, the kmalloc caches are cache_line_size() aligned, except when |
| @@ -27,6 +26,9 @@ | |||
| 27 | * ARCH_KMALLOC_MINALIGN allows that. | 26 | * ARCH_KMALLOC_MINALIGN allows that. |
| 28 | * Note that increasing this value may disable some debug features. | 27 | * Note that increasing this value may disable some debug features. |
| 29 | */ | 28 | */ |
| 29 | #ifdef ARCH_DMA_MINALIGN | ||
| 30 | #define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN | ||
| 31 | #else | ||
| 30 | #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long) | 32 | #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long) |
| 31 | #endif | 33 | #endif |
| 32 | 34 | ||
diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h index 62667f72c2ef..4382db09df4f 100644 --- a/include/linux/slob_def.h +++ b/include/linux/slob_def.h | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | #ifndef __LINUX_SLOB_DEF_H | 1 | #ifndef __LINUX_SLOB_DEF_H |
| 2 | #define __LINUX_SLOB_DEF_H | 2 | #define __LINUX_SLOB_DEF_H |
| 3 | 3 | ||
| 4 | #ifndef ARCH_KMALLOC_MINALIGN | 4 | #ifdef ARCH_DMA_MINALIGN |
| 5 | #define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN | ||
| 6 | #else | ||
| 5 | #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long) | 7 | #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long) |
| 6 | #endif | 8 | #endif |
| 7 | 9 | ||
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index 6447a723ecb1..6d14409c4d9a 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h | |||
| @@ -106,15 +106,17 @@ struct kmem_cache { | |||
| 106 | /* | 106 | /* |
| 107 | * Kmalloc subsystem. | 107 | * Kmalloc subsystem. |
| 108 | */ | 108 | */ |
| 109 | #if defined(ARCH_KMALLOC_MINALIGN) && ARCH_KMALLOC_MINALIGN > 8 | 109 | #if defined(ARCH_DMA_MINALIGN) && ARCH_DMA_MINALIGN > 8 |
| 110 | #define KMALLOC_MIN_SIZE ARCH_KMALLOC_MINALIGN | 110 | #define KMALLOC_MIN_SIZE ARCH_DMA_MINALIGN |
| 111 | #else | 111 | #else |
| 112 | #define KMALLOC_MIN_SIZE 8 | 112 | #define KMALLOC_MIN_SIZE 8 |
| 113 | #endif | 113 | #endif |
| 114 | 114 | ||
| 115 | #define KMALLOC_SHIFT_LOW ilog2(KMALLOC_MIN_SIZE) | 115 | #define KMALLOC_SHIFT_LOW ilog2(KMALLOC_MIN_SIZE) |
| 116 | 116 | ||
| 117 | #ifndef ARCH_KMALLOC_MINALIGN | 117 | #ifdef ARCH_DMA_MINALIGN |
| 118 | #define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN | ||
| 119 | #else | ||
| 118 | #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long) | 120 | #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long) |
| 119 | #endif | 121 | #endif |
| 120 | 122 | ||
diff --git a/include/linux/spi/max7301.h b/include/linux/spi/max7301.h index 34af0a3477bf..bcaa2f762cc1 100644 --- a/include/linux/spi/max7301.h +++ b/include/linux/spi/max7301.h | |||
| @@ -11,6 +11,7 @@ struct max7301 { | |||
| 11 | struct mutex lock; | 11 | struct mutex lock; |
| 12 | u8 port_config[8]; /* field 0 is unused */ | 12 | u8 port_config[8]; /* field 0 is unused */ |
| 13 | u32 out_level; /* cached output levels */ | 13 | u32 out_level; /* cached output levels */ |
| 14 | u32 input_pullup_active; | ||
| 14 | struct gpio_chip chip; | 15 | struct gpio_chip chip; |
| 15 | struct device *dev; | 16 | struct device *dev; |
| 16 | int (*write)(struct device *dev, unsigned int reg, unsigned int val); | 17 | int (*write)(struct device *dev, unsigned int reg, unsigned int val); |
| @@ -20,6 +21,13 @@ struct max7301 { | |||
| 20 | struct max7301_platform_data { | 21 | struct max7301_platform_data { |
| 21 | /* number assigned to the first GPIO */ | 22 | /* number assigned to the first GPIO */ |
| 22 | unsigned base; | 23 | unsigned base; |
| 24 | /* | ||
| 25 | * bitmask controlling the pullup configuration, | ||
| 26 | * | ||
| 27 | * _note_ the 4 lowest bits are unused, because the first 4 | ||
| 28 | * ports of the controller are not used, too. | ||
| 29 | */ | ||
| 30 | u32 input_pullup_active; | ||
| 23 | }; | 31 | }; |
| 24 | 32 | ||
| 25 | extern int __max730x_remove(struct device *dev); | 33 | extern int __max730x_remove(struct device *dev); |
diff --git a/include/linux/swap.h b/include/linux/swap.h index 91c9d3fc8513..2fee51a11b73 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
| @@ -244,8 +244,7 @@ extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, | |||
| 244 | extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, | 244 | extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, |
| 245 | gfp_t gfp_mask, bool noswap, | 245 | gfp_t gfp_mask, bool noswap, |
| 246 | unsigned int swappiness, | 246 | unsigned int swappiness, |
| 247 | struct zone *zone, | 247 | struct zone *zone); |
| 248 | int nid); | ||
| 249 | extern int __isolate_lru_page(struct page *page, int mode, int file); | 248 | extern int __isolate_lru_page(struct page *page, int mode, int file); |
| 250 | extern unsigned long shrink_all_memory(unsigned long nr_pages); | 249 | extern unsigned long shrink_all_memory(unsigned long nr_pages); |
| 251 | extern int vm_swappiness; | 250 | extern int vm_swappiness; |
diff --git a/include/linux/sysv_fs.h b/include/linux/sysv_fs.h index 96411306eec6..e47d6d90023d 100644 --- a/include/linux/sysv_fs.h +++ b/include/linux/sysv_fs.h | |||
| @@ -148,6 +148,17 @@ struct v7_super_block { | |||
| 148 | char s_fname[6]; /* file system name */ | 148 | char s_fname[6]; /* file system name */ |
| 149 | char s_fpack[6]; /* file system pack name */ | 149 | char s_fpack[6]; /* file system pack name */ |
| 150 | }; | 150 | }; |
| 151 | /* Constants to aid sanity checking */ | ||
| 152 | /* This is not a hard limit, nor enforced by v7 kernel. It's actually just | ||
| 153 | * the limit used by Seventh Edition's ls, though is high enough to assume | ||
| 154 | * that no reasonable file system would have that much entries in root | ||
| 155 | * directory. Thus, if we see anything higher, we just probably got the | ||
| 156 | * endiannes wrong. */ | ||
| 157 | #define V7_NFILES 1024 | ||
| 158 | /* The disk addresses are three-byte (despite direct block addresses being | ||
| 159 | * aligned word-wise in inode). If the most significant byte is non-zero, | ||
| 160 | * something is most likely wrong (not a filesystem, bad bytesex). */ | ||
| 161 | #define V7_MAXSIZE 0x00ffffff | ||
| 151 | 162 | ||
| 152 | /* Coherent super-block data on disk */ | 163 | /* Coherent super-block data on disk */ |
| 153 | #define COH_NICINOD 100 /* number of inode cache entries */ | 164 | #define COH_NICINOD 100 /* number of inode cache entries */ |
diff --git a/include/linux/time.h b/include/linux/time.h index cb34e35fabac..12612701b1ae 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
| @@ -38,7 +38,7 @@ extern struct timezone sys_tz; | |||
| 38 | #define NSEC_PER_MSEC 1000000L | 38 | #define NSEC_PER_MSEC 1000000L |
| 39 | #define USEC_PER_SEC 1000000L | 39 | #define USEC_PER_SEC 1000000L |
| 40 | #define NSEC_PER_SEC 1000000000L | 40 | #define NSEC_PER_SEC 1000000000L |
| 41 | #define FSEC_PER_SEC 1000000000000000L | 41 | #define FSEC_PER_SEC 1000000000000000LL |
| 42 | 42 | ||
| 43 | #define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1) | 43 | #define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1) |
| 44 | 44 | ||
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h index 814f294d4cd0..6228b5b77d35 100644 --- a/include/linux/vgaarb.h +++ b/include/linux/vgaarb.h | |||
| @@ -31,7 +31,6 @@ | |||
| 31 | #ifndef LINUX_VGA_H | 31 | #ifndef LINUX_VGA_H |
| 32 | #define LINUX_VGA_H | 32 | #define LINUX_VGA_H |
| 33 | 33 | ||
| 34 | #include <asm/vga.h> | ||
| 35 | 34 | ||
| 36 | /* Legacy VGA regions */ | 35 | /* Legacy VGA regions */ |
| 37 | #define VGA_RSRC_NONE 0x00 | 36 | #define VGA_RSRC_NONE 0x00 |
diff --git a/include/linux/virtio_9p.h b/include/linux/virtio_9p.h index 395c38a47adb..1faa80d92f05 100644 --- a/include/linux/virtio_9p.h +++ b/include/linux/virtio_9p.h | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #define _LINUX_VIRTIO_9P_H | 2 | #define _LINUX_VIRTIO_9P_H |
| 3 | /* This header is BSD licensed so anyone can use the definitions to implement | 3 | /* This header is BSD licensed so anyone can use the definitions to implement |
| 4 | * compatible drivers/servers. */ | 4 | * compatible drivers/servers. */ |
| 5 | #include <linux/types.h> | ||
| 5 | #include <linux/virtio_ids.h> | 6 | #include <linux/virtio_ids.h> |
| 6 | #include <linux/virtio_config.h> | 7 | #include <linux/virtio_config.h> |
| 7 | #include <linux/types.h> | 8 | #include <linux/types.h> |
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index de05e96e0a70..01c2145118dc 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | struct vm_area_struct; /* vma defining user mapping in mm_types.h */ | 8 | struct vm_area_struct; /* vma defining user mapping in mm_types.h */ |
| 9 | 9 | ||
| 10 | extern bool vmap_lazy_unmap; | ||
| 11 | |||
| 10 | /* bits in flags of vmalloc's vm_struct below */ | 12 | /* bits in flags of vmalloc's vm_struct below */ |
| 11 | #define VM_IOREMAP 0x00000001 /* ioremap() and friends */ | 13 | #define VM_IOREMAP 0x00000001 /* ioremap() and friends */ |
| 12 | #define VM_ALLOC 0x00000002 /* vmalloc() */ | 14 | #define VM_ALLOC 0x00000002 /* vmalloc() */ |
diff --git a/include/linux/wm97xx_batt.h b/include/linux/wm97xx_batt.h deleted file mode 100644 index a1d6419c2ff8..000000000000 --- a/include/linux/wm97xx_batt.h +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | #ifndef _LINUX_WM97XX_BAT_H | ||
| 2 | #define _LINUX_WM97XX_BAT_H | ||
| 3 | |||
| 4 | #include <linux/wm97xx.h> | ||
| 5 | |||
| 6 | #warning This file will be removed soon, use wm97xx.h instead! | ||
| 7 | |||
| 8 | #define wm97xx_batt_info wm97xx_batt_pdata | ||
| 9 | |||
| 10 | #ifdef CONFIG_BATTERY_WM97XX | ||
| 11 | void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data); | ||
| 12 | #else | ||
| 13 | static inline void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) {} | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #endif | ||
diff --git a/include/linux/writeback.h b/include/linux/writeback.h index c24eca71e80c..72a5d647a5f2 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h | |||
| @@ -124,8 +124,9 @@ struct ctl_table; | |||
| 124 | int dirty_writeback_centisecs_handler(struct ctl_table *, int, | 124 | int dirty_writeback_centisecs_handler(struct ctl_table *, int, |
| 125 | void __user *, size_t *, loff_t *); | 125 | void __user *, size_t *, loff_t *); |
| 126 | 126 | ||
| 127 | void get_dirty_limits(unsigned long *pbackground, unsigned long *pdirty, | 127 | void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty); |
| 128 | unsigned long *pbdi_dirty, struct backing_dev_info *bdi); | 128 | unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, |
| 129 | unsigned long dirty); | ||
| 129 | 130 | ||
| 130 | void page_writeback_init(void); | 131 | void page_writeback_init(void); |
| 131 | void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, | 132 | void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, |
