Error Trace
[Home]
Bug # 167
Show/hide error trace Error trace
{ 20 typedef unsigned char __u8; 23 typedef unsigned short __u16; 25 typedef int __s32; 26 typedef unsigned int __u32; 29 typedef long long __s64; 30 typedef unsigned long long __u64; 15 typedef signed char s8; 16 typedef unsigned char u8; 18 typedef short s16; 19 typedef unsigned short u16; 21 typedef int s32; 22 typedef unsigned int u32; 24 typedef long long s64; 25 typedef unsigned long long u64; 14 typedef long __kernel_long_t; 15 typedef unsigned long __kernel_ulong_t; 27 typedef int __kernel_pid_t; 48 typedef unsigned int __kernel_uid32_t; 49 typedef unsigned int __kernel_gid32_t; 71 typedef __kernel_ulong_t __kernel_size_t; 72 typedef __kernel_long_t __kernel_ssize_t; 87 typedef long long __kernel_loff_t; 88 typedef __kernel_long_t __kernel_time_t; 89 typedef __kernel_long_t __kernel_clock_t; 90 typedef int __kernel_timer_t; 91 typedef int __kernel_clockid_t; 280 struct kernel_symbol { unsigned long value; const char *name; } ; 34 struct module ; 12 typedef __u32 __kernel_dev_t; 15 typedef __kernel_dev_t dev_t; 18 typedef unsigned short umode_t; 21 typedef __kernel_pid_t pid_t; 26 typedef __kernel_clockid_t clockid_t; 29 typedef _Bool bool; 31 typedef __kernel_uid32_t uid_t; 32 typedef __kernel_gid32_t gid_t; 45 typedef __kernel_loff_t loff_t; 54 typedef __kernel_size_t size_t; 59 typedef __kernel_ssize_t ssize_t; 69 typedef __kernel_time_t time_t; 102 typedef __s32 int32_t; 108 typedef __u32 uint32_t; 133 typedef unsigned long sector_t; 134 typedef unsigned long blkcnt_t; 152 typedef u64 dma_addr_t; 157 typedef unsigned int gfp_t; 158 typedef unsigned int fmode_t; 161 typedef u64 phys_addr_t; 166 typedef phys_addr_t resource_size_t; 176 struct __anonstruct_atomic_t_6 { int counter; } ; 176 typedef struct __anonstruct_atomic_t_6 atomic_t; 181 struct __anonstruct_atomic64_t_7 { long counter; } ; 181 typedef struct __anonstruct_atomic64_t_7 atomic64_t; 182 struct list_head { struct list_head *next; struct list_head *prev; } ; 187 struct hlist_node ; 187 struct hlist_head { struct hlist_node *first; } ; 191 struct hlist_node { struct hlist_node *next; struct hlist_node **pprev; } ; 202 struct callback_head { struct callback_head *next; void (*func)(struct callback_head *); } ; 115 typedef void (*ctor_fn_t)(); 274 struct _ddebug { const char *modname; const char *function; const char *filename; const char *format; unsigned int lineno; unsigned char flags; } ; 58 struct device ; 465 struct file_operations ; 477 struct completion ; 478 struct pt_regs ; 546 struct bug_entry { int bug_addr_disp; int file_disp; unsigned short line; unsigned short flags; } ; 114 struct timespec ; 115 struct compat_timespec ; 116 struct pollfd ; 117 struct __anonstruct_futex_27 { u32 *uaddr; u32 val; u32 flags; u32 bitset; u64 time; u32 *uaddr2; } ; 117 struct __anonstruct_nanosleep_28 { clockid_t clockid; struct timespec *rmtp; struct compat_timespec *compat_rmtp; u64 expires; } ; 117 struct __anonstruct_poll_29 { struct pollfd *ufds; int nfds; int has_timeout; unsigned long tv_sec; unsigned long tv_nsec; } ; 117 union __anonunion____missing_field_name_26 { struct __anonstruct_futex_27 futex; struct __anonstruct_nanosleep_28 nanosleep; struct __anonstruct_poll_29 poll; } ; 117 struct restart_block { long int (*fn)(struct restart_block *); union __anonunion____missing_field_name_26 __annonCompField4; } ; 50 struct task_struct ; 39 struct page ; 26 struct mm_struct ; 288 struct pt_regs { unsigned long r15; unsigned long r14; unsigned long r13; unsigned long r12; unsigned long bp; unsigned long bx; unsigned long r11; unsigned long r10; unsigned long r9; unsigned long r8; unsigned long ax; unsigned long cx; unsigned long dx; unsigned long si; unsigned long di; unsigned long orig_ax; unsigned long ip; unsigned long cs; unsigned long flags; unsigned long sp; unsigned long ss; } ; 66 struct __anonstruct____missing_field_name_32 { unsigned int a; unsigned int b; } ; 66 struct __anonstruct____missing_field_name_33 { u16 limit0; u16 base0; unsigned char base1; unsigned char type; unsigned char s; unsigned char dpl; unsigned char p; unsigned char limit; unsigned char avl; unsigned char l; unsigned char d; unsigned char g; unsigned char base2; } ; 66 union __anonunion____missing_field_name_31 { struct __anonstruct____missing_field_name_32 __annonCompField5; struct __anonstruct____missing_field_name_33 __annonCompField6; } ; 66 struct desc_struct { union __anonunion____missing_field_name_31 __annonCompField7; } ; 13 typedef unsigned long pteval_t; 14 typedef unsigned long pmdval_t; 16 typedef unsigned long pgdval_t; 17 typedef unsigned long pgprotval_t; 19 struct __anonstruct_pte_t_34 { pteval_t pte; } ; 19 typedef struct __anonstruct_pte_t_34 pte_t; 21 struct pgprot { pgprotval_t pgprot; } ; 256 typedef struct pgprot pgprot_t; 258 struct __anonstruct_pgd_t_35 { pgdval_t pgd; } ; 258 typedef struct __anonstruct_pgd_t_35 pgd_t; 297 struct __anonstruct_pmd_t_37 { pmdval_t pmd; } ; 297 typedef struct __anonstruct_pmd_t_37 pmd_t; 423 typedef struct page *pgtable_t; 434 struct file ; 445 struct seq_file ; 481 struct thread_struct ; 483 struct cpumask ; 20 struct qspinlock { atomic_t val; } ; 33 typedef struct qspinlock arch_spinlock_t; 34 struct qrwlock { atomic_t cnts; arch_spinlock_t wait_lock; } ; 14 typedef struct qrwlock arch_rwlock_t; 247 struct math_emu_info { long ___orig_eip; struct pt_regs *regs; } ; 83 struct static_key { atomic_t enabled; } ; 23 typedef atomic64_t atomic_long_t; 359 struct cpumask { unsigned long bits[128U]; } ; 15 typedef struct cpumask cpumask_t; 654 typedef struct cpumask *cpumask_var_t; 22 struct tracepoint_func { void *func; void *data; int prio; } ; 28 struct tracepoint { const char *name; struct static_key key; int (*regfunc)(); void (*unregfunc)(); struct tracepoint_func *funcs; } ; 233 struct fregs_state { u32 cwd; u32 swd; u32 twd; u32 fip; u32 fcs; u32 foo; u32 fos; u32 st_space[20U]; u32 status; } ; 26 struct __anonstruct____missing_field_name_61 { u64 rip; u64 rdp; } ; 26 struct __anonstruct____missing_field_name_62 { u32 fip; u32 fcs; u32 foo; u32 fos; } ; 26 union __anonunion____missing_field_name_60 { struct __anonstruct____missing_field_name_61 __annonCompField13; struct __anonstruct____missing_field_name_62 __annonCompField14; } ; 26 union __anonunion____missing_field_name_63 { u32 padding1[12U]; u32 sw_reserved[12U]; } ; 26 struct fxregs_state { u16 cwd; u16 swd; u16 twd; u16 fop; union __anonunion____missing_field_name_60 __annonCompField15; u32 mxcsr; u32 mxcsr_mask; u32 st_space[32U]; u32 xmm_space[64U]; u32 padding[12U]; union __anonunion____missing_field_name_63 __annonCompField16; } ; 66 struct swregs_state { u32 cwd; u32 swd; u32 twd; u32 fip; u32 fcs; u32 foo; u32 fos; u32 st_space[20U]; u8 ftop; u8 changed; u8 lookahead; u8 no_update; u8 rm; u8 alimit; struct math_emu_info *info; u32 entry_eip; } ; 227 struct xstate_header { u64 xfeatures; u64 xcomp_bv; u64 reserved[6U]; } ; 233 struct xregs_state { struct fxregs_state i387; struct xstate_header header; u8 extended_state_area[0U]; } ; 254 union fpregs_state { struct fregs_state fsave; struct fxregs_state fxsave; struct swregs_state soft; struct xregs_state xsave; u8 __padding[4096U]; } ; 271 struct fpu { unsigned int last_cpu; unsigned char fpstate_active; unsigned char fpregs_active; union fpregs_state state; } ; 180 struct seq_operations ; 386 struct perf_event ; 391 struct __anonstruct_mm_segment_t_75 { unsigned long seg; } ; 391 typedef struct __anonstruct_mm_segment_t_75 mm_segment_t; 392 struct thread_struct { struct desc_struct tls_array[3U]; unsigned long sp0; unsigned long sp; unsigned short es; unsigned short ds; unsigned short fsindex; unsigned short gsindex; u32 status; unsigned long fsbase; unsigned long gsbase; struct perf_event *ptrace_bps[4U]; unsigned long debugreg6; unsigned long ptrace_dr7; unsigned long cr2; unsigned long trap_nr; unsigned long error_code; unsigned long *io_bitmap_ptr; unsigned long iopl; unsigned int io_bitmap_max; mm_segment_t addr_limit; unsigned char sig_on_uaccess_err; unsigned char uaccess_err; struct fpu fpu; } ; 48 struct thread_info { unsigned long flags; } ; 33 struct lockdep_map ; 55 struct stack_trace { unsigned int nr_entries; unsigned int max_entries; unsigned long *entries; int skip; } ; 28 struct lockdep_subclass_key { char __one_byte; } ; 53 struct lock_class_key { struct lockdep_subclass_key subkeys[8U]; } ; 59 struct lock_class { struct hlist_node hash_entry; struct list_head lock_entry; struct lockdep_subclass_key *key; unsigned int subclass; unsigned int dep_gen_id; unsigned long usage_mask; struct stack_trace usage_traces[13U]; struct list_head locks_after; struct list_head locks_before; unsigned int version; unsigned long ops; const char *name; int name_version; unsigned long contention_point[4U]; unsigned long contending_point[4U]; } ; 144 struct lockdep_map { struct lock_class_key *key; struct lock_class *class_cache[2U]; const char *name; int cpu; unsigned long ip; } ; 207 struct held_lock { u64 prev_chain_key; unsigned long acquire_ip; struct lockdep_map *instance; struct lockdep_map *nest_lock; u64 waittime_stamp; u64 holdtime_stamp; unsigned short class_idx; unsigned char irq_context; unsigned char trylock; unsigned char read; unsigned char check; unsigned char hardirqs_off; unsigned short references; unsigned int pin_count; } ; 593 struct raw_spinlock { arch_spinlock_t raw_lock; unsigned int magic; unsigned int owner_cpu; void *owner; struct lockdep_map dep_map; } ; 32 typedef struct raw_spinlock raw_spinlock_t; 33 struct __anonstruct____missing_field_name_77 { u8 __padding[24U]; struct lockdep_map dep_map; } ; 33 union __anonunion____missing_field_name_76 { struct raw_spinlock rlock; struct __anonstruct____missing_field_name_77 __annonCompField19; } ; 33 struct spinlock { union __anonunion____missing_field_name_76 __annonCompField20; } ; 76 typedef struct spinlock spinlock_t; 23 struct __anonstruct_rwlock_t_78 { arch_rwlock_t raw_lock; unsigned int magic; unsigned int owner_cpu; void *owner; struct lockdep_map dep_map; } ; 23 typedef struct __anonstruct_rwlock_t_78 rwlock_t; 416 struct seqcount { unsigned int sequence; struct lockdep_map dep_map; } ; 52 typedef struct seqcount seqcount_t; 407 struct __anonstruct_seqlock_t_93 { struct seqcount seqcount; spinlock_t lock; } ; 407 typedef struct __anonstruct_seqlock_t_93 seqlock_t; 601 struct timespec { __kernel_time_t tv_sec; long tv_nsec; } ; 7 typedef __s64 time64_t; 83 struct user_namespace ; 22 struct __anonstruct_kuid_t_94 { uid_t val; } ; 22 typedef struct __anonstruct_kuid_t_94 kuid_t; 27 struct __anonstruct_kgid_t_95 { gid_t val; } ; 27 typedef struct __anonstruct_kgid_t_95 kgid_t; 139 struct kstat { u64 ino; dev_t dev; umode_t mode; unsigned int nlink; kuid_t uid; kgid_t gid; dev_t rdev; loff_t size; struct timespec atime; struct timespec mtime; struct timespec ctime; unsigned long blksize; unsigned long long blocks; } ; 36 struct vm_area_struct ; 38 struct __wait_queue_head { spinlock_t lock; struct list_head task_list; } ; 43 typedef struct __wait_queue_head wait_queue_head_t; 97 struct __anonstruct_nodemask_t_96 { unsigned long bits[16U]; } ; 97 typedef struct __anonstruct_nodemask_t_96 nodemask_t; 249 typedef unsigned int isolate_mode_t; 13 struct optimistic_spin_queue { atomic_t tail; } ; 39 struct mutex { atomic_long_t owner; spinlock_t wait_lock; struct optimistic_spin_queue osq; struct list_head wait_list; void *magic; struct lockdep_map dep_map; } ; 70 struct mutex_waiter { struct list_head list; struct task_struct *task; void *magic; } ; 222 struct rw_semaphore ; 223 struct rw_semaphore { atomic_long_t count; struct list_head wait_list; raw_spinlock_t wait_lock; struct optimistic_spin_queue osq; struct task_struct *owner; struct lockdep_map dep_map; } ; 178 struct completion { unsigned int done; wait_queue_head_t wait; } ; 28 typedef s64 ktime_t; 1145 struct timer_list { struct hlist_node entry; unsigned long expires; void (*function)(unsigned long); unsigned long data; u32 flags; int start_pid; void *start_site; char start_comm[16U]; struct lockdep_map lockdep_map; } ; 254 struct hrtimer ; 255 enum hrtimer_restart ; 256 struct rb_node { unsigned long __rb_parent_color; struct rb_node *rb_right; struct rb_node *rb_left; } ; 41 struct rb_root { struct rb_node *rb_node; } ; 835 struct nsproxy ; 278 struct workqueue_struct ; 279 struct work_struct ; 54 struct work_struct { atomic_long_t data; struct list_head entry; void (*func)(struct work_struct *); struct lockdep_map lockdep_map; } ; 107 struct delayed_work { struct work_struct work; struct timer_list timer; struct workqueue_struct *wq; int cpu; } ; 268 struct notifier_block ; 53 struct notifier_block { int (*notifier_call)(struct notifier_block *, unsigned long, void *); struct notifier_block *next; int priority; } ; 217 struct resource ; 70 struct resource { resource_size_t start; resource_size_t end; const char *name; unsigned long flags; unsigned long desc; struct resource *parent; struct resource *sibling; struct resource *child; } ; 58 struct pm_message { int event; } ; 64 typedef struct pm_message pm_message_t; 65 struct dev_pm_ops { int (*prepare)(struct device *); void (*complete)(struct device *); int (*suspend)(struct device *); int (*resume)(struct device *); int (*freeze)(struct device *); int (*thaw)(struct device *); int (*poweroff)(struct device *); int (*restore)(struct device *); int (*suspend_late)(struct device *); int (*resume_early)(struct device *); int (*freeze_late)(struct device *); int (*thaw_early)(struct device *); int (*poweroff_late)(struct device *); int (*restore_early)(struct device *); int (*suspend_noirq)(struct device *); int (*resume_noirq)(struct device *); int (*freeze_noirq)(struct device *); int (*thaw_noirq)(struct device *); int (*poweroff_noirq)(struct device *); int (*restore_noirq)(struct device *); int (*runtime_suspend)(struct device *); int (*runtime_resume)(struct device *); int (*runtime_idle)(struct device *); } ; 320 enum rpm_status { RPM_ACTIVE = 0, RPM_RESUMING = 1, RPM_SUSPENDED = 2, RPM_SUSPENDING = 3 } ; 327 enum rpm_request { RPM_REQ_NONE = 0, RPM_REQ_IDLE = 1, RPM_REQ_SUSPEND = 2, RPM_REQ_AUTOSUSPEND = 3, RPM_REQ_RESUME = 4 } ; 335 struct wakeup_source ; 336 struct wake_irq ; 337 struct pm_domain_data ; 338 struct pm_subsys_data { spinlock_t lock; unsigned int refcount; struct list_head clock_list; struct pm_domain_data *domain_data; } ; 556 struct dev_pm_qos ; 556 struct dev_pm_info { pm_message_t power_state; unsigned char can_wakeup; unsigned char async_suspend; bool in_dpm_list; bool is_prepared; bool is_suspended; bool is_noirq_suspended; bool is_late_suspended; bool early_init; bool direct_complete; spinlock_t lock; struct list_head entry; struct completion completion; struct wakeup_source *wakeup; bool wakeup_path; bool syscore; bool no_pm_callbacks; struct timer_list suspend_timer; unsigned long timer_expires; struct work_struct work; wait_queue_head_t wait_queue; struct wake_irq *wakeirq; atomic_t usage_count; atomic_t child_count; unsigned char disable_depth; unsigned char idle_notification; unsigned char request_pending; unsigned char deferred_resume; unsigned char run_wake; unsigned char runtime_auto; bool ignore_children; unsigned char no_callbacks; unsigned char irq_safe; unsigned char use_autosuspend; unsigned char timer_autosuspends; unsigned char memalloc_noio; unsigned int links_count; enum rpm_request request; enum rpm_status runtime_status; int runtime_error; int autosuspend_delay; unsigned long last_busy; unsigned long active_jiffies; unsigned long suspended_jiffies; unsigned long accounting_timestamp; struct pm_subsys_data *subsys_data; void (*set_latency_tolerance)(struct device *, s32 ); struct dev_pm_qos *qos; } ; 618 struct dev_pm_domain { struct dev_pm_ops ops; void (*detach)(struct device *, bool ); int (*activate)(struct device *); void (*sync)(struct device *); void (*dismiss)(struct device *); } ; 38 struct ldt_struct ; 38 struct vdso_image ; 38 struct __anonstruct_mm_context_t_167 { struct ldt_struct *ldt; unsigned short ia32_compat; struct mutex lock; void *vdso; const struct vdso_image *vdso_image; atomic_t perf_rdpmc_allowed; u16 pkey_allocation_map; s16 execute_only_pkey; void *bd_addr; } ; 38 typedef struct __anonstruct_mm_context_t_167 mm_context_t; 1264 struct llist_node ; 64 struct llist_node { struct llist_node *next; } ; 37 struct cred ; 19 struct inode ; 58 struct arch_uprobe_task { unsigned long saved_scratch_register; unsigned int saved_trap_nr; unsigned int saved_tf; } ; 66 enum uprobe_task_state { UTASK_RUNNING = 0, UTASK_SSTEP = 1, UTASK_SSTEP_ACK = 2, UTASK_SSTEP_TRAPPED = 3 } ; 73 struct __anonstruct____missing_field_name_215 { struct arch_uprobe_task autask; unsigned long vaddr; } ; 73 struct __anonstruct____missing_field_name_216 { struct callback_head dup_xol_work; unsigned long dup_xol_addr; } ; 73 union __anonunion____missing_field_name_214 { struct __anonstruct____missing_field_name_215 __annonCompField35; struct __anonstruct____missing_field_name_216 __annonCompField36; } ; 73 struct uprobe ; 73 struct return_instance ; 73 struct uprobe_task { enum uprobe_task_state state; union __anonunion____missing_field_name_214 __annonCompField37; struct uprobe *active_uprobe; unsigned long xol_vaddr; struct return_instance *return_instances; unsigned int depth; } ; 95 struct return_instance { struct uprobe *uprobe; unsigned long func; unsigned long stack; unsigned long orig_ret_vaddr; bool chained; struct return_instance *next; } ; 111 struct xol_area ; 112 struct uprobes_state { struct xol_area *xol_area; } ; 151 struct address_space ; 152 struct mem_cgroup ; 153 union __anonunion____missing_field_name_217 { struct address_space *mapping; void *s_mem; atomic_t compound_mapcount; } ; 153 union __anonunion____missing_field_name_218 { unsigned long index; void *freelist; } ; 153 struct __anonstruct____missing_field_name_222 { unsigned short inuse; unsigned short objects; unsigned char frozen; } ; 153 union __anonunion____missing_field_name_221 { atomic_t _mapcount; unsigned int active; struct __anonstruct____missing_field_name_222 __annonCompField40; int units; } ; 153 struct __anonstruct____missing_field_name_220 { union __anonunion____missing_field_name_221 __annonCompField41; atomic_t _refcount; } ; 153 union __anonunion____missing_field_name_219 { unsigned long counters; struct __anonstruct____missing_field_name_220 __annonCompField42; } ; 153 struct dev_pagemap ; 153 struct __anonstruct____missing_field_name_224 { struct page *next; int pages; int pobjects; } ; 153 struct __anonstruct____missing_field_name_225 { unsigned long compound_head; unsigned int compound_dtor; unsigned int compound_order; } ; 153 struct __anonstruct____missing_field_name_226 { unsigned long __pad; pgtable_t pmd_huge_pte; } ; 153 union __anonunion____missing_field_name_223 { struct list_head lru; struct dev_pagemap *pgmap; struct __anonstruct____missing_field_name_224 __annonCompField44; struct callback_head callback_head; struct __anonstruct____missing_field_name_225 __annonCompField45; struct __anonstruct____missing_field_name_226 __annonCompField46; } ; 153 struct kmem_cache ; 153 union __anonunion____missing_field_name_227 { unsigned long private; spinlock_t *ptl; struct kmem_cache *slab_cache; } ; 153 struct page { unsigned long flags; union __anonunion____missing_field_name_217 __annonCompField38; union __anonunion____missing_field_name_218 __annonCompField39; union __anonunion____missing_field_name_219 __annonCompField43; union __anonunion____missing_field_name_223 __annonCompField47; union __anonunion____missing_field_name_227 __annonCompField48; struct mem_cgroup *mem_cgroup; } ; 197 struct page_frag { struct page *page; __u32 offset; __u32 size; } ; 282 struct userfaultfd_ctx ; 282 struct vm_userfaultfd_ctx { struct userfaultfd_ctx *ctx; } ; 289 struct __anonstruct_shared_228 { struct rb_node rb; unsigned long rb_subtree_last; } ; 289 struct anon_vma ; 289 struct vm_operations_struct ; 289 struct mempolicy ; 289 struct vm_area_struct { unsigned long vm_start; unsigned long vm_end; struct vm_area_struct *vm_next; struct vm_area_struct *vm_prev; struct rb_node vm_rb; unsigned long rb_subtree_gap; struct mm_struct *vm_mm; pgprot_t vm_page_prot; unsigned long vm_flags; struct __anonstruct_shared_228 shared; struct list_head anon_vma_chain; struct anon_vma *anon_vma; const struct vm_operations_struct *vm_ops; unsigned long vm_pgoff; struct file *vm_file; void *vm_private_data; struct mempolicy *vm_policy; struct vm_userfaultfd_ctx vm_userfaultfd_ctx; } ; 362 struct core_thread { struct task_struct *task; struct core_thread *next; } ; 367 struct core_state { atomic_t nr_threads; struct core_thread dumper; struct completion startup; } ; 381 struct task_rss_stat { int events; int count[4U]; } ; 389 struct mm_rss_stat { atomic_long_t count[4U]; } ; 394 struct kioctx_table ; 395 struct linux_binfmt ; 395 struct mmu_notifier_mm ; 395 struct mm_struct { struct vm_area_struct *mmap; struct rb_root mm_rb; u32 vmacache_seqnum; unsigned long int (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); unsigned long mmap_base; unsigned long mmap_legacy_base; unsigned long task_size; unsigned long highest_vm_end; pgd_t *pgd; atomic_t mm_users; atomic_t mm_count; atomic_long_t nr_ptes; atomic_long_t nr_pmds; int map_count; spinlock_t page_table_lock; struct rw_semaphore mmap_sem; struct list_head mmlist; unsigned long hiwater_rss; unsigned long hiwater_vm; unsigned long total_vm; unsigned long locked_vm; unsigned long pinned_vm; unsigned long data_vm; unsigned long exec_vm; unsigned long stack_vm; unsigned long def_flags; unsigned long start_code; unsigned long end_code; unsigned long start_data; unsigned long end_data; unsigned long start_brk; unsigned long brk; unsigned long start_stack; unsigned long arg_start; unsigned long arg_end; unsigned long env_start; unsigned long env_end; unsigned long saved_auxv[46U]; struct mm_rss_stat rss_stat; struct linux_binfmt *binfmt; cpumask_var_t cpu_vm_mask_var; mm_context_t context; unsigned long flags; struct core_state *core_state; spinlock_t ioctx_lock; struct kioctx_table *ioctx_table; struct task_struct *owner; struct user_namespace *user_ns; struct file *exe_file; struct mmu_notifier_mm *mmu_notifier_mm; struct cpumask cpumask_allocation; unsigned long numa_next_scan; unsigned long numa_scan_offset; int numa_scan_seq; bool tlb_flush_pending; struct uprobes_state uprobes_state; atomic_long_t hugetlb_usage; struct work_struct async_put_work; } ; 560 struct vm_fault ; 614 struct vdso_image { void *data; unsigned long size; unsigned long alt; unsigned long alt_len; long sym_vvar_start; long sym_vvar_page; long sym_hpet_page; long sym_pvclock_page; long sym_VDSO32_NOTE_MASK; long sym___kernel_sigreturn; long sym___kernel_rt_sigreturn; long sym___kernel_vsyscall; long sym_int80_landing_pad; } ; 15 typedef __u64 Elf64_Addr; 16 typedef __u16 Elf64_Half; 18 typedef __u64 Elf64_Off; 20 typedef __u32 Elf64_Word; 21 typedef __u64 Elf64_Xword; 190 struct elf64_sym { Elf64_Word st_name; unsigned char st_info; unsigned char st_other; Elf64_Half st_shndx; Elf64_Addr st_value; Elf64_Xword st_size; } ; 198 typedef struct elf64_sym Elf64_Sym; 219 struct elf64_hdr { unsigned char e_ident[16U]; Elf64_Half e_type; Elf64_Half e_machine; Elf64_Word e_version; Elf64_Addr e_entry; Elf64_Off e_phoff; Elf64_Off e_shoff; Elf64_Word e_flags; Elf64_Half e_ehsize; Elf64_Half e_phentsize; Elf64_Half e_phnum; Elf64_Half e_shentsize; Elf64_Half e_shnum; Elf64_Half e_shstrndx; } ; 235 typedef struct elf64_hdr Elf64_Ehdr; 314 struct elf64_shdr { Elf64_Word sh_name; Elf64_Word sh_type; Elf64_Xword sh_flags; Elf64_Addr sh_addr; Elf64_Off sh_offset; Elf64_Xword sh_size; Elf64_Word sh_link; Elf64_Word sh_info; Elf64_Xword sh_addralign; Elf64_Xword sh_entsize; } ; 326 typedef struct elf64_shdr Elf64_Shdr; 53 union __anonunion____missing_field_name_233 { unsigned long bitmap[1U]; struct callback_head callback_head; } ; 53 struct idr_layer { int prefix; int layer; struct idr_layer *ary[64U]; int count; union __anonunion____missing_field_name_233 __annonCompField49; } ; 40 struct idr { struct idr_layer *hint; struct idr_layer *top; int layers; int cur; spinlock_t lock; int id_free_cnt; struct idr_layer *id_free; } ; 149 struct ida_bitmap { long nr_busy; unsigned long bitmap[15U]; } ; 192 struct ida { struct idr idr; struct ida_bitmap *free_bitmap; } ; 229 struct dentry ; 230 struct iattr ; 231 struct super_block ; 232 struct file_system_type ; 233 struct kernfs_open_node ; 234 struct kernfs_iattrs ; 257 struct kernfs_root ; 257 struct kernfs_elem_dir { unsigned long subdirs; struct rb_root children; struct kernfs_root *root; } ; 85 struct kernfs_node ; 85 struct kernfs_elem_symlink { struct kernfs_node *target_kn; } ; 89 struct kernfs_ops ; 89 struct kernfs_elem_attr { const struct kernfs_ops *ops; struct kernfs_open_node *open; loff_t size; struct kernfs_node *notify_next; } ; 96 union __anonunion____missing_field_name_242 { struct kernfs_elem_dir dir; struct kernfs_elem_symlink symlink; struct kernfs_elem_attr attr; } ; 96 struct kernfs_node { atomic_t count; atomic_t active; struct lockdep_map dep_map; struct kernfs_node *parent; const char *name; struct rb_node rb; const void *ns; unsigned int hash; union __anonunion____missing_field_name_242 __annonCompField50; void *priv; unsigned short flags; umode_t mode; unsigned int ino; struct kernfs_iattrs *iattr; } ; 138 struct kernfs_syscall_ops { int (*remount_fs)(struct kernfs_root *, int *, char *); int (*show_options)(struct seq_file *, struct kernfs_root *); int (*mkdir)(struct kernfs_node *, const char *, umode_t ); int (*rmdir)(struct kernfs_node *); int (*rename)(struct kernfs_node *, struct kernfs_node *, const char *); int (*show_path)(struct seq_file *, struct kernfs_node *, struct kernfs_root *); } ; 157 struct kernfs_root { struct kernfs_node *kn; unsigned int flags; struct ida ino_ida; struct kernfs_syscall_ops *syscall_ops; struct list_head supers; wait_queue_head_t deactivate_waitq; } ; 173 struct kernfs_open_file { struct kernfs_node *kn; struct file *file; void *priv; struct mutex mutex; struct mutex prealloc_mutex; int event; struct list_head list; char *prealloc_buf; size_t atomic_write_len; bool mmapped; const struct vm_operations_struct *vm_ops; } ; 191 struct kernfs_ops { int (*seq_show)(struct seq_file *, void *); void * (*seq_start)(struct seq_file *, loff_t *); void * (*seq_next)(struct seq_file *, void *, loff_t *); void (*seq_stop)(struct seq_file *, void *); ssize_t (*read)(struct kernfs_open_file *, char *, size_t , loff_t ); size_t atomic_write_len; bool prealloc; ssize_t (*write)(struct kernfs_open_file *, char *, size_t , loff_t ); int (*mmap)(struct kernfs_open_file *, struct vm_area_struct *); struct lock_class_key lockdep_key; } ; 511 struct sock ; 512 struct kobject ; 513 enum kobj_ns_type { KOBJ_NS_TYPE_NONE = 0, KOBJ_NS_TYPE_NET = 1, KOBJ_NS_TYPES = 2 } ; 519 struct kobj_ns_type_operations { enum kobj_ns_type type; bool (*current_may_mount)(); void * (*grab_current_ns)(); const void * (*netlink_ns)(struct sock *); const void * (*initial_ns)(); void (*drop_ns)(void *); } ; 59 struct bin_attribute ; 60 struct attribute { const char *name; umode_t mode; bool ignore_lockdep; struct lock_class_key *key; struct lock_class_key skey; } ; 37 struct attribute_group { const char *name; umode_t (*is_visible)(struct kobject *, struct attribute *, int); umode_t (*is_bin_visible)(struct kobject *, struct bin_attribute *, int); struct attribute **attrs; struct bin_attribute **bin_attrs; } ; 92 struct bin_attribute { struct attribute attr; size_t size; void *private; ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t , size_t ); ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t , size_t ); int (*mmap)(struct file *, struct kobject *, struct bin_attribute *, struct vm_area_struct *); } ; 165 struct sysfs_ops { ssize_t (*show)(struct kobject *, struct attribute *, char *); ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t ); } ; 530 struct kref { atomic_t refcount; } ; 52 struct kset ; 52 struct kobj_type ; 52 struct kobject { const char *name; struct list_head entry; struct kobject *parent; struct kset *kset; struct kobj_type *ktype; struct kernfs_node *sd; struct kref kref; struct delayed_work release; unsigned char state_initialized; unsigned char state_in_sysfs; unsigned char state_add_uevent_sent; unsigned char state_remove_uevent_sent; unsigned char uevent_suppress; } ; 115 struct kobj_type { void (*release)(struct kobject *); const struct sysfs_ops *sysfs_ops; struct attribute **default_attrs; const struct kobj_ns_type_operations * (*child_ns_type)(struct kobject *); const void * (*namespace)(struct kobject *); } ; 123 struct kobj_uevent_env { char *argv[3U]; char *envp[32U]; int envp_idx; char buf[2048U]; int buflen; } ; 131 struct kset_uevent_ops { const int (*filter)(struct kset *, struct kobject *); const const char * (*name)(struct kset *, struct kobject *); const int (*uevent)(struct kset *, struct kobject *, struct kobj_uevent_env *); } ; 148 struct kset { struct list_head list; spinlock_t list_lock; struct kobject kobj; const struct kset_uevent_ops *uevent_ops; } ; 223 struct kernel_param ; 228 struct kernel_param_ops { unsigned int flags; int (*set)(const char *, const struct kernel_param *); int (*get)(char *, const struct kernel_param *); void (*free)(void *); } ; 62 struct kparam_string ; 62 struct kparam_array ; 62 union __anonunion____missing_field_name_245 { void *arg; const struct kparam_string *str; const struct kparam_array *arr; } ; 62 struct kernel_param { const char *name; struct module *mod; const struct kernel_param_ops *ops; const u16 perm; s8 level; u8 flags; union __anonunion____missing_field_name_245 __annonCompField51; } ; 83 struct kparam_string { unsigned int maxlen; char *string; } ; 89 struct kparam_array { unsigned int max; unsigned int elemsize; unsigned int *num; const struct kernel_param_ops *ops; void *elem; } ; 470 struct exception_table_entry ; 24 struct latch_tree_node { struct rb_node node[2U]; } ; 211 struct mod_arch_specific { } ; 39 struct module_param_attrs ; 39 struct module_kobject { struct kobject kobj; struct module *mod; struct kobject *drivers_dir; struct module_param_attrs *mp; struct completion *kobj_completion; } ; 50 struct module_attribute { struct attribute attr; ssize_t (*show)(struct module_attribute *, struct module_kobject *, char *); ssize_t (*store)(struct module_attribute *, struct module_kobject *, const char *, size_t ); void (*setup)(struct module *, const char *); int (*test)(struct module *); void (*free)(struct module *); } ; 277 enum module_state { MODULE_STATE_LIVE = 0, MODULE_STATE_COMING = 1, MODULE_STATE_GOING = 2, MODULE_STATE_UNFORMED = 3 } ; 284 struct mod_tree_node { struct module *mod; struct latch_tree_node node; } ; 291 struct module_layout { void *base; unsigned int size; unsigned int text_size; unsigned int ro_size; unsigned int ro_after_init_size; struct mod_tree_node mtn; } ; 307 struct mod_kallsyms { Elf64_Sym *symtab; unsigned int num_symtab; char *strtab; } ; 321 struct klp_modinfo { Elf64_Ehdr hdr; Elf64_Shdr *sechdrs; char *secstrings; unsigned int symndx; } ; 329 struct module_sect_attrs ; 329 struct module_notes_attrs ; 329 struct trace_event_call ; 329 struct trace_enum_map ; 329 struct module { enum module_state state; struct list_head list; char name[56U]; struct module_kobject mkobj; struct module_attribute *modinfo_attrs; const char *version; const char *srcversion; struct kobject *holders_dir; const struct kernel_symbol *syms; const unsigned long *crcs; unsigned int num_syms; struct mutex param_lock; struct kernel_param *kp; unsigned int num_kp; unsigned int num_gpl_syms; const struct kernel_symbol *gpl_syms; const unsigned long *gpl_crcs; const struct kernel_symbol *unused_syms; const unsigned long *unused_crcs; unsigned int num_unused_syms; unsigned int num_unused_gpl_syms; const struct kernel_symbol *unused_gpl_syms; const unsigned long *unused_gpl_crcs; bool sig_ok; bool async_probe_requested; const struct kernel_symbol *gpl_future_syms; const unsigned long *gpl_future_crcs; unsigned int num_gpl_future_syms; unsigned int num_exentries; struct exception_table_entry *extable; int (*init)(); struct module_layout core_layout; struct module_layout init_layout; struct mod_arch_specific arch; unsigned long taints; unsigned int num_bugs; struct list_head bug_list; struct bug_entry *bug_table; struct mod_kallsyms *kallsyms; struct mod_kallsyms core_kallsyms; struct module_sect_attrs *sect_attrs; struct module_notes_attrs *notes_attrs; char *args; void *percpu; unsigned int percpu_size; unsigned int num_tracepoints; const struct tracepoint **tracepoints_ptrs; unsigned int num_trace_bprintk_fmt; const char **trace_bprintk_fmt_start; struct trace_event_call **trace_events; unsigned int num_trace_events; struct trace_enum_map **trace_enums; unsigned int num_trace_enums; bool klp; bool klp_alive; struct klp_modinfo *klp_info; struct list_head source_list; struct list_head target_list; void (*exit)(); atomic_t refcnt; ctor_fn_t (**ctors)(); unsigned int num_ctors; } ; 799 struct klist_node ; 37 struct klist_node { void *n_klist; struct list_head n_node; struct kref n_ref; } ; 93 struct hlist_bl_node ; 93 struct hlist_bl_head { struct hlist_bl_node *first; } ; 36 struct hlist_bl_node { struct hlist_bl_node *next; struct hlist_bl_node **pprev; } ; 114 struct __anonstruct____missing_field_name_299 { spinlock_t lock; int count; } ; 114 union __anonunion____missing_field_name_298 { struct __anonstruct____missing_field_name_299 __annonCompField52; } ; 114 struct lockref { union __anonunion____missing_field_name_298 __annonCompField53; } ; 77 struct path ; 78 struct vfsmount ; 79 struct __anonstruct____missing_field_name_301 { u32 hash; u32 len; } ; 79 union __anonunion____missing_field_name_300 { struct __anonstruct____missing_field_name_301 __annonCompField54; u64 hash_len; } ; 79 struct qstr { union __anonunion____missing_field_name_300 __annonCompField55; const unsigned char *name; } ; 65 struct dentry_operations ; 65 union __anonunion____missing_field_name_302 { struct list_head d_lru; wait_queue_head_t *d_wait; } ; 65 union __anonunion_d_u_303 { struct hlist_node d_alias; struct hlist_bl_node d_in_lookup_hash; struct callback_head d_rcu; } ; 65 struct dentry { unsigned int d_flags; seqcount_t d_seq; struct hlist_bl_node d_hash; struct dentry *d_parent; struct qstr d_name; struct inode *d_inode; unsigned char d_iname[32U]; struct lockref d_lockref; const struct dentry_operations *d_op; struct super_block *d_sb; unsigned long d_time; void *d_fsdata; union __anonunion____missing_field_name_302 __annonCompField56; struct list_head d_child; struct list_head d_subdirs; union __anonunion_d_u_303 d_u; } ; 121 struct dentry_operations { int (*d_revalidate)(struct dentry *, unsigned int); int (*d_weak_revalidate)(struct dentry *, unsigned int); int (*d_hash)(const struct dentry *, struct qstr *); int (*d_compare)(const struct dentry *, unsigned int, const char *, const struct qstr *); int (*d_delete)(const struct dentry *); int (*d_init)(struct dentry *); void (*d_release)(struct dentry *); void (*d_prune)(struct dentry *); void (*d_iput)(struct dentry *, struct inode *); char * (*d_dname)(struct dentry *, char *, int); struct vfsmount * (*d_automount)(struct path *); int (*d_manage)(const struct path *, bool ); struct dentry * (*d_real)(struct dentry *, const struct inode *, unsigned int); } ; 592 struct path { struct vfsmount *mnt; struct dentry *dentry; } ; 19 struct shrink_control { gfp_t gfp_mask; unsigned long nr_to_scan; int nid; struct mem_cgroup *memcg; } ; 27 struct shrinker { unsigned long int (*count_objects)(struct shrinker *, struct shrink_control *); unsigned long int (*scan_objects)(struct shrinker *, struct shrink_control *); int seeks; long batch; unsigned long flags; struct list_head list; atomic_long_t *nr_deferred; } ; 80 struct list_lru_one { struct list_head list; long nr_items; } ; 32 struct list_lru_memcg { struct list_lru_one *lru[0U]; } ; 37 struct list_lru_node { spinlock_t lock; struct list_lru_one lru; struct list_lru_memcg *memcg_lrus; } ; 47 struct list_lru { struct list_lru_node *node; struct list_head list; } ; 63 union __anonunion____missing_field_name_304 { struct list_head private_list; struct callback_head callback_head; } ; 63 struct radix_tree_node { unsigned char shift; unsigned char offset; unsigned char count; unsigned char exceptional; struct radix_tree_node *parent; void *private_data; union __anonunion____missing_field_name_304 __annonCompField57; void *slots[64U]; unsigned long tags[3U][1U]; } ; 105 struct radix_tree_root { gfp_t gfp_mask; struct radix_tree_node *rnode; } ; 519 enum pid_type { PIDTYPE_PID = 0, PIDTYPE_PGID = 1, PIDTYPE_SID = 2, PIDTYPE_MAX = 3 } ; 526 struct pid_namespace ; 526 struct upid { int nr; struct pid_namespace *ns; struct hlist_node pid_chain; } ; 56 struct pid { atomic_t count; unsigned int level; struct hlist_head tasks[3U]; struct callback_head rcu; struct upid numbers[1U]; } ; 68 struct pid_link { struct hlist_node node; struct pid *pid; } ; 22 struct kernel_cap_struct { __u32 cap[2U]; } ; 25 typedef struct kernel_cap_struct kernel_cap_t; 45 struct fiemap_extent { __u64 fe_logical; __u64 fe_physical; __u64 fe_length; __u64 fe_reserved64[2U]; __u32 fe_flags; __u32 fe_reserved[3U]; } ; 38 enum migrate_mode { MIGRATE_ASYNC = 0, MIGRATE_SYNC_LIGHT = 1, MIGRATE_SYNC = 2 } ; 44 enum rcu_sync_type { RCU_SYNC = 0, RCU_SCHED_SYNC = 1, RCU_BH_SYNC = 2 } ; 50 struct rcu_sync { int gp_state; int gp_count; wait_queue_head_t gp_wait; int cb_state; struct callback_head cb_head; enum rcu_sync_type gp_type; } ; 66 struct percpu_rw_semaphore { struct rcu_sync rss; unsigned int *read_count; struct rw_semaphore rw_sem; wait_queue_head_t writer; int readers_block; } ; 144 struct delayed_call { void (*fn)(void *); void *arg; } ; 282 struct backing_dev_info ; 283 struct bdi_writeback ; 285 struct export_operations ; 288 struct kiocb ; 289 struct pipe_inode_info ; 290 struct poll_table_struct ; 291 struct kstatfs ; 292 struct swap_info_struct ; 293 struct iov_iter ; 294 struct fscrypt_info ; 295 struct fscrypt_operations ; 76 struct iattr { unsigned int ia_valid; umode_t ia_mode; kuid_t ia_uid; kgid_t ia_gid; loff_t ia_size; struct timespec ia_atime; struct timespec ia_mtime; struct timespec ia_ctime; struct file *ia_file; } ; 213 struct dquot ; 214 struct kqid ; 19 typedef __kernel_uid32_t projid_t; 23 struct __anonstruct_kprojid_t_308 { projid_t val; } ; 23 typedef struct __anonstruct_kprojid_t_308 kprojid_t; 181 enum quota_type { USRQUOTA = 0, GRPQUOTA = 1, PRJQUOTA = 2 } ; 66 typedef long long qsize_t; 67 union __anonunion____missing_field_name_309 { kuid_t uid; kgid_t gid; kprojid_t projid; } ; 67 struct kqid { union __anonunion____missing_field_name_309 __annonCompField58; enum quota_type type; } ; 194 struct mem_dqblk { qsize_t dqb_bhardlimit; qsize_t dqb_bsoftlimit; qsize_t dqb_curspace; qsize_t dqb_rsvspace; qsize_t dqb_ihardlimit; qsize_t dqb_isoftlimit; qsize_t dqb_curinodes; time64_t dqb_btime; time64_t dqb_itime; } ; 216 struct quota_format_type ; 217 struct mem_dqinfo { struct quota_format_type *dqi_format; int dqi_fmt_id; struct list_head dqi_dirty_list; unsigned long dqi_flags; unsigned int dqi_bgrace; unsigned int dqi_igrace; qsize_t dqi_max_spc_limit; qsize_t dqi_max_ino_limit; void *dqi_priv; } ; 282 struct dquot { struct hlist_node dq_hash; struct list_head dq_inuse; struct list_head dq_free; struct list_head dq_dirty; struct mutex dq_lock; atomic_t dq_count; wait_queue_head_t dq_wait_unused; struct super_block *dq_sb; struct kqid dq_id; loff_t dq_off; unsigned long dq_flags; struct mem_dqblk dq_dqb; } ; 309 struct quota_format_ops { int (*check_quota_file)(struct super_block *, int); int (*read_file_info)(struct super_block *, int); int (*write_file_info)(struct super_block *, int); int (*free_file_info)(struct super_block *, int); int (*read_dqblk)(struct dquot *); int (*commit_dqblk)(struct dquot *); int (*release_dqblk)(struct dquot *); int (*get_next_id)(struct super_block *, struct kqid *); } ; 321 struct dquot_operations { int (*write_dquot)(struct dquot *); struct dquot * (*alloc_dquot)(struct super_block *, int); void (*destroy_dquot)(struct dquot *); int (*acquire_dquot)(struct dquot *); int (*release_dquot)(struct dquot *); int (*mark_dirty)(struct dquot *); int (*write_info)(struct super_block *, int); qsize_t * (*get_reserved_space)(struct inode *); int (*get_projid)(struct inode *, kprojid_t *); int (*get_next_id)(struct super_block *, struct kqid *); } ; 338 struct qc_dqblk { int d_fieldmask; u64 d_spc_hardlimit; u64 d_spc_softlimit; u64 d_ino_hardlimit; u64 d_ino_softlimit; u64 d_space; u64 d_ino_count; s64 d_ino_timer; s64 d_spc_timer; int d_ino_warns; int d_spc_warns; u64 d_rt_spc_hardlimit; u64 d_rt_spc_softlimit; u64 d_rt_space; s64 d_rt_spc_timer; int d_rt_spc_warns; } ; 361 struct qc_type_state { unsigned int flags; unsigned int spc_timelimit; unsigned int ino_timelimit; unsigned int rt_spc_timelimit; unsigned int spc_warnlimit; unsigned int ino_warnlimit; unsigned int rt_spc_warnlimit; unsigned long long ino; blkcnt_t blocks; blkcnt_t nextents; } ; 407 struct qc_state { unsigned int s_incoredqs; struct qc_type_state s_state[3U]; } ; 418 struct qc_info { int i_fieldmask; unsigned int i_flags; unsigned int i_spc_timelimit; unsigned int i_ino_timelimit; unsigned int i_rt_spc_timelimit; unsigned int i_spc_warnlimit; unsigned int i_ino_warnlimit; unsigned int i_rt_spc_warnlimit; } ; 431 struct quotactl_ops { int (*quota_on)(struct super_block *, int, int, const struct path *); int (*quota_off)(struct super_block *, int); int (*quota_enable)(struct super_block *, unsigned int); int (*quota_disable)(struct super_block *, unsigned int); int (*quota_sync)(struct super_block *, int); int (*set_info)(struct super_block *, int, struct qc_info *); int (*get_dqblk)(struct super_block *, struct kqid , struct qc_dqblk *); int (*get_nextdqblk)(struct super_block *, struct kqid *, struct qc_dqblk *); int (*set_dqblk)(struct super_block *, struct kqid , struct qc_dqblk *); int (*get_state)(struct super_block *, struct qc_state *); int (*rm_xquota)(struct super_block *, unsigned int); } ; 447 struct quota_format_type { int qf_fmt_id; const struct quota_format_ops *qf_ops; struct module *qf_owner; struct quota_format_type *qf_next; } ; 511 struct quota_info { unsigned int flags; struct mutex dqio_mutex; struct inode *files[3U]; struct mem_dqinfo info[3U]; const struct quota_format_ops *ops[3U]; } ; 540 struct writeback_control ; 541 struct kiocb { struct file *ki_filp; loff_t ki_pos; void (*ki_complete)(struct kiocb *, long, long); void *private; int ki_flags; } ; 317 struct address_space_operations { int (*writepage)(struct page *, struct writeback_control *); int (*readpage)(struct file *, struct page *); int (*writepages)(struct address_space *, struct writeback_control *); int (*set_page_dirty)(struct page *); int (*readpages)(struct file *, struct address_space *, struct list_head *, unsigned int); int (*write_begin)(struct file *, struct address_space *, loff_t , unsigned int, unsigned int, struct page **, void **); int (*write_end)(struct file *, struct address_space *, loff_t , unsigned int, unsigned int, struct page *, void *); sector_t (*bmap)(struct address_space *, sector_t ); void (*invalidatepage)(struct page *, unsigned int, unsigned int); int (*releasepage)(struct page *, gfp_t ); void (*freepage)(struct page *); ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *); int (*migratepage)(struct address_space *, struct page *, struct page *, enum migrate_mode ); bool (*isolate_page)(struct page *, isolate_mode_t ); void (*putback_page)(struct page *); int (*launder_page)(struct page *); int (*is_partially_uptodate)(struct page *, unsigned long, unsigned long); void (*is_dirty_writeback)(struct page *, bool *, bool *); int (*error_remove_page)(struct address_space *, struct page *); int (*swap_activate)(struct swap_info_struct *, struct file *, sector_t *); void (*swap_deactivate)(struct file *); } ; 376 struct address_space { struct inode *host; struct radix_tree_root page_tree; spinlock_t tree_lock; atomic_t i_mmap_writable; struct rb_root i_mmap; struct rw_semaphore i_mmap_rwsem; unsigned long nrpages; unsigned long nrexceptional; unsigned long writeback_index; const struct address_space_operations *a_ops; unsigned long flags; spinlock_t private_lock; gfp_t gfp_mask; struct list_head private_list; void *private_data; } ; 398 struct request_queue ; 399 struct hd_struct ; 399 struct gendisk ; 399 struct block_device { dev_t bd_dev; int bd_openers; struct inode *bd_inode; struct super_block *bd_super; struct mutex bd_mutex; void *bd_claiming; void *bd_holder; int bd_holders; bool bd_write_holder; struct list_head bd_holder_disks; struct block_device *bd_contains; unsigned int bd_block_size; struct hd_struct *bd_part; unsigned int bd_part_count; int bd_invalidated; struct gendisk *bd_disk; struct request_queue *bd_queue; struct list_head bd_list; unsigned long bd_private; int bd_fsfreeze_count; struct mutex bd_fsfreeze_mutex; } ; 514 struct posix_acl ; 541 struct inode_operations ; 541 union __anonunion____missing_field_name_314 { const unsigned int i_nlink; unsigned int __i_nlink; } ; 541 union __anonunion____missing_field_name_315 { struct hlist_head i_dentry; struct callback_head i_rcu; } ; 541 struct file_lock_context ; 541 struct cdev ; 541 union __anonunion____missing_field_name_316 { struct pipe_inode_info *i_pipe; struct block_device *i_bdev; struct cdev *i_cdev; char *i_link; unsigned int i_dir_seq; } ; 541 struct inode { umode_t i_mode; unsigned short i_opflags; kuid_t i_uid; kgid_t i_gid; unsigned int i_flags; struct posix_acl *i_acl; struct posix_acl *i_default_acl; const struct inode_operations *i_op; struct super_block *i_sb; struct address_space *i_mapping; void *i_security; unsigned long i_ino; union __anonunion____missing_field_name_314 __annonCompField59; dev_t i_rdev; loff_t i_size; struct timespec i_atime; struct timespec i_mtime; struct timespec i_ctime; spinlock_t i_lock; unsigned short i_bytes; unsigned int i_blkbits; blkcnt_t i_blocks; unsigned long i_state; struct rw_semaphore i_rwsem; unsigned long dirtied_when; unsigned long dirtied_time_when; struct hlist_node i_hash; struct list_head i_io_list; struct bdi_writeback *i_wb; int i_wb_frn_winner; u16 i_wb_frn_avg_time; u16 i_wb_frn_history; struct list_head i_lru; struct list_head i_sb_list; struct list_head i_wb_list; union __anonunion____missing_field_name_315 __annonCompField60; u64 i_version; atomic_t i_count; atomic_t i_dio_count; atomic_t i_writecount; atomic_t i_readcount; const struct file_operations *i_fop; struct file_lock_context *i_flctx; struct address_space i_data; struct list_head i_devices; union __anonunion____missing_field_name_316 __annonCompField61; __u32 i_generation; __u32 i_fsnotify_mask; struct hlist_head i_fsnotify_marks; struct fscrypt_info *i_crypt_info; void *i_private; } ; 797 struct fown_struct { rwlock_t lock; struct pid *pid; enum pid_type pid_type; kuid_t uid; kuid_t euid; int signum; } ; 805 struct file_ra_state { unsigned long start; unsigned int size; unsigned int async_size; unsigned int ra_pages; unsigned int mmap_miss; loff_t prev_pos; } ; 828 union __anonunion_f_u_317 { struct llist_node fu_llist; struct callback_head fu_rcuhead; } ; 828 struct file { union __anonunion_f_u_317 f_u; struct path f_path; struct inode *f_inode; const struct file_operations *f_op; spinlock_t f_lock; atomic_long_t f_count; unsigned int f_flags; fmode_t f_mode; struct mutex f_pos_lock; loff_t f_pos; struct fown_struct f_owner; const struct cred *f_cred; struct file_ra_state f_ra; u64 f_version; void *f_security; void *private_data; struct list_head f_ep_links; struct list_head f_tfile_llink; struct address_space *f_mapping; } ; 913 typedef void *fl_owner_t; 914 struct file_lock ; 915 struct file_lock_operations { void (*fl_copy_lock)(struct file_lock *, struct file_lock *); void (*fl_release_private)(struct file_lock *); } ; 921 struct lock_manager_operations { int (*lm_compare_owner)(struct file_lock *, struct file_lock *); unsigned long int (*lm_owner_key)(struct file_lock *); fl_owner_t (*lm_get_owner)(fl_owner_t ); void (*lm_put_owner)(fl_owner_t ); void (*lm_notify)(struct file_lock *); int (*lm_grant)(struct file_lock *, int); bool (*lm_break)(struct file_lock *); int (*lm_change)(struct file_lock *, int, struct list_head *); void (*lm_setup)(struct file_lock *, void **); } ; 948 struct nlm_lockowner ; 949 struct nfs_lock_info { u32 state; struct nlm_lockowner *owner; struct list_head list; } ; 14 struct nfs4_lock_state ; 15 struct nfs4_lock_info { struct nfs4_lock_state *owner; } ; 19 struct fasync_struct ; 19 struct __anonstruct_afs_319 { struct list_head link; int state; } ; 19 union __anonunion_fl_u_318 { struct nfs_lock_info nfs_fl; struct nfs4_lock_info nfs4_fl; struct __anonstruct_afs_319 afs; } ; 19 struct file_lock { struct file_lock *fl_next; struct list_head fl_list; struct hlist_node fl_link; struct list_head fl_block; fl_owner_t fl_owner; unsigned int fl_flags; unsigned char fl_type; unsigned int fl_pid; int fl_link_cpu; struct pid *fl_nspid; wait_queue_head_t fl_wait; struct file *fl_file; loff_t fl_start; loff_t fl_end; struct fasync_struct *fl_fasync; unsigned long fl_break_time; unsigned long fl_downgrade_time; const struct file_lock_operations *fl_ops; const struct lock_manager_operations *fl_lmops; union __anonunion_fl_u_318 fl_u; } ; 1001 struct file_lock_context { spinlock_t flc_lock; struct list_head flc_flock; struct list_head flc_posix; struct list_head flc_lease; } ; 1068 struct files_struct ; 1221 struct fasync_struct { spinlock_t fa_lock; int magic; int fa_fd; struct fasync_struct *fa_next; struct file *fa_file; struct callback_head fa_rcu; } ; 1256 struct sb_writers { int frozen; wait_queue_head_t wait_unfrozen; struct percpu_rw_semaphore rw_sem[3U]; } ; 1286 struct super_operations ; 1286 struct xattr_handler ; 1286 struct mtd_info ; 1286 struct super_block { struct list_head s_list; dev_t s_dev; unsigned char s_blocksize_bits; unsigned long s_blocksize; loff_t s_maxbytes; struct file_system_type *s_type; const struct super_operations *s_op; const struct dquot_operations *dq_op; const struct quotactl_ops *s_qcop; const struct export_operations *s_export_op; unsigned long s_flags; unsigned long s_iflags; unsigned long s_magic; struct dentry *s_root; struct rw_semaphore s_umount; int s_count; atomic_t s_active; void *s_security; const struct xattr_handler **s_xattr; const struct fscrypt_operations *s_cop; struct hlist_bl_head s_anon; struct list_head s_mounts; struct block_device *s_bdev; struct backing_dev_info *s_bdi; struct mtd_info *s_mtd; struct hlist_node s_instances; unsigned int s_quota_types; struct quota_info s_dquot; struct sb_writers s_writers; char s_id[32U]; u8 s_uuid[16U]; void *s_fs_info; unsigned int s_max_links; fmode_t s_mode; u32 s_time_gran; struct mutex s_vfs_rename_mutex; char *s_subtype; char *s_options; const struct dentry_operations *s_d_op; int cleancache_poolid; struct shrinker s_shrink; atomic_long_t s_remove_count; int s_readonly_remount; struct workqueue_struct *s_dio_done_wq; struct hlist_head s_pins; struct user_namespace *s_user_ns; struct list_lru s_dentry_lru; struct list_lru s_inode_lru; struct callback_head rcu; struct work_struct destroy_work; struct mutex s_sync_lock; int s_stack_depth; spinlock_t s_inode_list_lock; struct list_head s_inodes; spinlock_t s_inode_wblist_lock; struct list_head s_inodes_wb; } ; 1570 struct fiemap_extent_info { unsigned int fi_flags; unsigned int fi_extents_mapped; unsigned int fi_extents_max; struct fiemap_extent *fi_extents_start; } ; 1583 struct dir_context ; 1608 struct dir_context { int (*actor)(struct dir_context *, const char *, int, loff_t , u64 , unsigned int); loff_t pos; } ; 1615 struct file_operations { struct module *owner; loff_t (*llseek)(struct file *, loff_t , int); ssize_t (*read)(struct file *, char *, size_t , loff_t *); ssize_t (*write)(struct file *, const char *, size_t , loff_t *); ssize_t (*read_iter)(struct kiocb *, struct iov_iter *); ssize_t (*write_iter)(struct kiocb *, struct iov_iter *); int (*iterate)(struct file *, struct dir_context *); int (*iterate_shared)(struct file *, struct dir_context *); unsigned int (*poll)(struct file *, struct poll_table_struct *); long int (*unlocked_ioctl)(struct file *, unsigned int, unsigned long); long int (*compat_ioctl)(struct file *, unsigned int, unsigned long); int (*mmap)(struct file *, struct vm_area_struct *); int (*open)(struct inode *, struct file *); int (*flush)(struct file *, fl_owner_t ); int (*release)(struct inode *, struct file *); int (*fsync)(struct file *, loff_t , loff_t , int); int (*fasync)(int, struct file *, int); int (*lock)(struct file *, int, struct file_lock *); ssize_t (*sendpage)(struct file *, struct page *, int, size_t , loff_t *, int); unsigned long int (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); int (*check_flags)(int); int (*flock)(struct file *, int, struct file_lock *); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t , unsigned int); ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t , unsigned int); int (*setlease)(struct file *, long, struct file_lock **, void **); long int (*fallocate)(struct file *, int, loff_t , loff_t ); void (*show_fdinfo)(struct seq_file *, struct file *); ssize_t (*copy_file_range)(struct file *, loff_t , struct file *, loff_t , size_t , unsigned int); int (*clone_file_range)(struct file *, loff_t , struct file *, loff_t , u64 ); ssize_t (*dedupe_file_range)(struct file *, u64 , u64 , struct file *, u64 ); } ; 1683 struct inode_operations { struct dentry * (*lookup)(struct inode *, struct dentry *, unsigned int); const char * (*get_link)(struct dentry *, struct inode *, struct delayed_call *); int (*permission)(struct inode *, int); struct posix_acl * (*get_acl)(struct inode *, int); int (*readlink)(struct dentry *, char *, int); int (*create)(struct inode *, struct dentry *, umode_t , bool ); int (*link)(struct dentry *, struct inode *, struct dentry *); int (*unlink)(struct inode *, struct dentry *); int (*symlink)(struct inode *, struct dentry *, const char *); int (*mkdir)(struct inode *, struct dentry *, umode_t ); int (*rmdir)(struct inode *, struct dentry *); int (*mknod)(struct inode *, struct dentry *, umode_t , dev_t ); int (*rename)(struct inode *, struct dentry *, struct inode *, struct dentry *, unsigned int); int (*setattr)(struct dentry *, struct iattr *); int (*getattr)(struct vfsmount *, struct dentry *, struct kstat *); ssize_t (*listxattr)(struct dentry *, char *, size_t ); int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 , u64 ); int (*update_time)(struct inode *, struct timespec *, int); int (*atomic_open)(struct inode *, struct dentry *, struct file *, unsigned int, umode_t , int *); int (*tmpfile)(struct inode *, struct dentry *, umode_t ); int (*set_acl)(struct inode *, struct posix_acl *, int); } ; 1753 struct super_operations { struct inode * (*alloc_inode)(struct super_block *); void (*destroy_inode)(struct inode *); void (*dirty_inode)(struct inode *, int); int (*write_inode)(struct inode *, struct writeback_control *); int (*drop_inode)(struct inode *); void (*evict_inode)(struct inode *); void (*put_super)(struct super_block *); int (*sync_fs)(struct super_block *, int); int (*freeze_super)(struct super_block *); int (*freeze_fs)(struct super_block *); int (*thaw_super)(struct super_block *); int (*unfreeze_fs)(struct super_block *); int (*statfs)(struct dentry *, struct kstatfs *); int (*remount_fs)(struct super_block *, int *, char *); void (*umount_begin)(struct super_block *); int (*show_options)(struct seq_file *, struct dentry *); int (*show_devname)(struct seq_file *, struct dentry *); int (*show_path)(struct seq_file *, struct dentry *); int (*show_stats)(struct seq_file *, struct dentry *); ssize_t (*quota_read)(struct super_block *, int, char *, size_t , loff_t ); ssize_t (*quota_write)(struct super_block *, int, const char *, size_t , loff_t ); struct dquot ** (*get_dquots)(struct inode *); int (*bdev_try_to_free_page)(struct super_block *, struct page *, gfp_t ); long int (*nr_cached_objects)(struct super_block *, struct shrink_control *); long int (*free_cached_objects)(struct super_block *, struct shrink_control *); } ; 1995 struct file_system_type { const char *name; int fs_flags; struct dentry * (*mount)(struct file_system_type *, int, const char *, void *); void (*kill_sb)(struct super_block *); struct module *owner; struct file_system_type *next; struct hlist_head fs_supers; struct lock_class_key s_lock_key; struct lock_class_key s_umount_key; struct lock_class_key s_vfs_rename_key; struct lock_class_key s_writers_key[3U]; struct lock_class_key i_lock_key; struct lock_class_key i_mutex_key; struct lock_class_key i_mutex_dir_key; } ; 3167 struct assoc_array_ptr ; 3167 struct assoc_array { struct assoc_array_ptr *root; unsigned long nr_leaves_on_tree; } ; 31 typedef int32_t key_serial_t; 34 typedef uint32_t key_perm_t; 35 struct key ; 36 struct user_struct ; 37 struct signal_struct ; 38 struct key_type ; 42 struct keyring_index_key { struct key_type *type; const char *description; size_t desc_len; } ; 91 union key_payload { void *rcu_data0; void *data[4U]; } ; 128 union __anonunion____missing_field_name_320 { struct list_head graveyard_link; struct rb_node serial_node; } ; 128 struct key_user ; 128 union __anonunion____missing_field_name_321 { time_t expiry; time_t revoked_at; } ; 128 struct __anonstruct____missing_field_name_323 { struct key_type *type; char *description; } ; 128 union __anonunion____missing_field_name_322 { struct keyring_index_key index_key; struct __anonstruct____missing_field_name_323 __annonCompField64; } ; 128 struct __anonstruct____missing_field_name_325 { struct list_head name_link; struct assoc_array keys; } ; 128 union __anonunion____missing_field_name_324 { union key_payload payload; struct __anonstruct____missing_field_name_325 __annonCompField66; int reject_error; } ; 128 struct key { atomic_t usage; key_serial_t serial; union __anonunion____missing_field_name_320 __annonCompField62; struct rw_semaphore sem; struct key_user *user; void *security; union __anonunion____missing_field_name_321 __annonCompField63; time_t last_used_at; kuid_t uid; kgid_t gid; key_perm_t perm; unsigned short quotalen; unsigned short datalen; unsigned long flags; union __anonunion____missing_field_name_322 __annonCompField65; union __anonunion____missing_field_name_324 __annonCompField67; int (*restrict_link)(struct key *, const struct key_type *, const union key_payload *); } ; 377 struct audit_context ; 27 struct group_info { atomic_t usage; int ngroups; kgid_t gid[0U]; } ; 85 struct cred { atomic_t usage; atomic_t subscribers; void *put_addr; unsigned int magic; kuid_t uid; kgid_t gid; kuid_t suid; kgid_t sgid; kuid_t euid; kgid_t egid; kuid_t fsuid; kgid_t fsgid; unsigned int securebits; kernel_cap_t cap_inheritable; kernel_cap_t cap_permitted; kernel_cap_t cap_effective; kernel_cap_t cap_bset; kernel_cap_t cap_ambient; unsigned char jit_keyring; struct key *session_keyring; struct key *process_keyring; struct key *thread_keyring; struct key *request_key_auth; void *security; struct user_struct *user; struct user_namespace *user_ns; struct group_info *group_info; struct callback_head rcu; } ; 368 struct seq_file { char *buf; size_t size; size_t from; size_t count; size_t pad_until; loff_t index; loff_t read_pos; u64 version; struct mutex lock; const struct seq_operations *op; int poll_event; const struct file *file; void *private; } ; 30 struct seq_operations { void * (*start)(struct seq_file *, loff_t *); void (*stop)(struct seq_file *, void *); void * (*next)(struct seq_file *, void *, loff_t *); int (*show)(struct seq_file *, void *); } ; 222 struct pinctrl ; 223 struct pinctrl_state ; 194 struct dev_pin_info { struct pinctrl *p; struct pinctrl_state *default_state; struct pinctrl_state *init_state; struct pinctrl_state *sleep_state; struct pinctrl_state *idle_state; } ; 84 struct plist_node { int prio; struct list_head prio_list; struct list_head node_list; } ; 4 typedef unsigned long cputime_t; 26 struct sem_undo_list ; 26 struct sysv_sem { struct sem_undo_list *undo_list; } ; 26 struct sysv_shm { struct list_head shm_clist; } ; 24 struct __anonstruct_sigset_t_326 { unsigned long sig[1U]; } ; 24 typedef struct __anonstruct_sigset_t_326 sigset_t; 25 struct siginfo ; 17 typedef void __signalfn_t(int); 18 typedef __signalfn_t *__sighandler_t; 20 typedef void __restorefn_t(); 21 typedef __restorefn_t *__sigrestore_t; 38 union sigval { int sival_int; void *sival_ptr; } ; 10 typedef union sigval sigval_t; 11 struct __anonstruct__kill_328 { __kernel_pid_t _pid; __kernel_uid32_t _uid; } ; 11 struct __anonstruct__timer_329 { __kernel_timer_t _tid; int _overrun; char _pad[0U]; sigval_t _sigval; int _sys_private; } ; 11 struct __anonstruct__rt_330 { __kernel_pid_t _pid; __kernel_uid32_t _uid; sigval_t _sigval; } ; 11 struct __anonstruct__sigchld_331 { __kernel_pid_t _pid; __kernel_uid32_t _uid; int _status; __kernel_clock_t _utime; __kernel_clock_t _stime; } ; 11 struct __anonstruct__addr_bnd_334 { void *_lower; void *_upper; } ; 11 union __anonunion____missing_field_name_333 { struct __anonstruct__addr_bnd_334 _addr_bnd; __u32 _pkey; } ; 11 struct __anonstruct__sigfault_332 { void *_addr; short _addr_lsb; union __anonunion____missing_field_name_333 __annonCompField68; } ; 11 struct __anonstruct__sigpoll_335 { long _band; int _fd; } ; 11 struct __anonstruct__sigsys_336 { void *_call_addr; int _syscall; unsigned int _arch; } ; 11 union __anonunion__sifields_327 { int _pad[28U]; struct __anonstruct__kill_328 _kill; struct __anonstruct__timer_329 _timer; struct __anonstruct__rt_330 _rt; struct __anonstruct__sigchld_331 _sigchld; struct __anonstruct__sigfault_332 _sigfault; struct __anonstruct__sigpoll_335 _sigpoll; struct __anonstruct__sigsys_336 _sigsys; } ; 11 struct siginfo { int si_signo; int si_errno; int si_code; union __anonunion__sifields_327 _sifields; } ; 118 typedef struct siginfo siginfo_t; 22 struct sigpending { struct list_head list; sigset_t signal; } ; 274 struct sigaction { __sighandler_t sa_handler; unsigned long sa_flags; __sigrestore_t sa_restorer; sigset_t sa_mask; } ; 288 struct k_sigaction { struct sigaction sa; } ; 43 struct seccomp_filter ; 44 struct seccomp { int mode; struct seccomp_filter *filter; } ; 40 struct rt_mutex_waiter ; 41 struct rlimit { __kernel_ulong_t rlim_cur; __kernel_ulong_t rlim_max; } ; 11 struct timerqueue_node { struct rb_node node; ktime_t expires; } ; 12 struct timerqueue_head { struct rb_root head; struct timerqueue_node *next; } ; 50 struct hrtimer_clock_base ; 51 struct hrtimer_cpu_base ; 60 enum hrtimer_restart { HRTIMER_NORESTART = 0, HRTIMER_RESTART = 1 } ; 65 struct hrtimer { struct timerqueue_node node; ktime_t _softexpires; enum hrtimer_restart (*function)(struct hrtimer *); struct hrtimer_clock_base *base; u8 state; u8 is_rel; int start_pid; void *start_site; char start_comm[16U]; } ; 125 struct hrtimer_clock_base { struct hrtimer_cpu_base *cpu_base; int index; clockid_t clockid; struct timerqueue_head active; ktime_t (*get_time)(); ktime_t offset; } ; 158 struct hrtimer_cpu_base { raw_spinlock_t lock; seqcount_t seq; struct hrtimer *running; unsigned int cpu; unsigned int active_bases; unsigned int clock_was_set_seq; bool migration_enabled; bool nohz_active; unsigned char in_hrtirq; unsigned char hres_active; unsigned char hang_detected; ktime_t expires_next; struct hrtimer *next_timer; unsigned int nr_events; unsigned int nr_retries; unsigned int nr_hangs; unsigned int max_hang_time; struct hrtimer_clock_base clock_base[4U]; } ; 12 enum kcov_mode { KCOV_MODE_DISABLED = 0, KCOV_MODE_TRACE = 1 } ; 17 struct task_io_accounting { u64 rchar; u64 wchar; u64 syscr; u64 syscw; u64 read_bytes; u64 write_bytes; u64 cancelled_write_bytes; } ; 45 struct latency_record { unsigned long backtrace[12U]; unsigned int count; unsigned long time; unsigned long max; } ; 41 struct percpu_ref ; 55 typedef void percpu_ref_func_t(struct percpu_ref *); 68 struct percpu_ref { atomic_long_t count; unsigned long percpu_count_ptr; percpu_ref_func_t *release; percpu_ref_func_t *confirm_switch; bool force_atomic; struct callback_head rcu; } ; 607 struct cgroup ; 14 struct bpf_prog ; 14 struct cgroup_bpf { struct bpf_prog *prog[3U]; struct bpf_prog *effective[3U]; } ; 44 struct cgroup_root ; 45 struct cgroup_subsys ; 46 struct cgroup_taskset ; 90 struct cgroup_file { struct kernfs_node *kn; } ; 91 struct cgroup_subsys_state { struct cgroup *cgroup; struct cgroup_subsys *ss; struct percpu_ref refcnt; struct cgroup_subsys_state *parent; struct list_head sibling; struct list_head children; int id; unsigned int flags; u64 serial_nr; atomic_t online_cnt; struct callback_head callback_head; struct work_struct destroy_work; } ; 142 struct css_set { atomic_t refcount; struct hlist_node hlist; struct list_head tasks; struct list_head mg_tasks; struct list_head cgrp_links; struct cgroup *dfl_cgrp; struct cgroup_subsys_state *subsys[13U]; struct list_head mg_preload_node; struct list_head mg_node; struct cgroup *mg_src_cgrp; struct cgroup *mg_dst_cgrp; struct css_set *mg_dst_cset; struct list_head e_cset_node[13U]; struct list_head task_iters; bool dead; struct callback_head callback_head; } ; 222 struct cgroup { struct cgroup_subsys_state self; unsigned long flags; int id; int level; int populated_cnt; struct kernfs_node *kn; struct cgroup_file procs_file; struct cgroup_file events_file; u16 subtree_control; u16 subtree_ss_mask; u16 old_subtree_control; u16 old_subtree_ss_mask; struct cgroup_subsys_state *subsys[13U]; struct cgroup_root *root; struct list_head cset_links; struct list_head e_csets[13U]; struct list_head pidlists; struct mutex pidlist_mutex; wait_queue_head_t offline_waitq; struct work_struct release_agent_work; struct cgroup_bpf bpf; int ancestor_ids[]; } ; 310 struct cgroup_root { struct kernfs_root *kf_root; unsigned int subsys_mask; int hierarchy_id; struct cgroup cgrp; int cgrp_ancestor_id_storage; atomic_t nr_cgrps; struct list_head root_list; unsigned int flags; struct idr cgroup_idr; char release_agent_path[4096U]; char name[64U]; } ; 349 struct cftype { char name[64U]; unsigned long private; size_t max_write_len; unsigned int flags; unsigned int file_offset; struct cgroup_subsys *ss; struct list_head node; struct kernfs_ops *kf_ops; u64 (*read_u64)(struct cgroup_subsys_state *, struct cftype *); s64 (*read_s64)(struct cgroup_subsys_state *, struct cftype *); int (*seq_show)(struct seq_file *, void *); void * (*seq_start)(struct seq_file *, loff_t *); void * (*seq_next)(struct seq_file *, void *, loff_t *); void (*seq_stop)(struct seq_file *, void *); int (*write_u64)(struct cgroup_subsys_state *, struct cftype *, u64 ); int (*write_s64)(struct cgroup_subsys_state *, struct cftype *, s64 ); ssize_t (*write)(struct kernfs_open_file *, char *, size_t , loff_t ); struct lock_class_key lockdep_key; } ; 434 struct cgroup_subsys { struct cgroup_subsys_state * (*css_alloc)(struct cgroup_subsys_state *); int (*css_online)(struct cgroup_subsys_state *); void (*css_offline)(struct cgroup_subsys_state *); void (*css_released)(struct cgroup_subsys_state *); void (*css_free)(struct cgroup_subsys_state *); void (*css_reset)(struct cgroup_subsys_state *); int (*can_attach)(struct cgroup_taskset *); void (*cancel_attach)(struct cgroup_taskset *); void (*attach)(struct cgroup_taskset *); void (*post_attach)(); int (*can_fork)(struct task_struct *); void (*cancel_fork)(struct task_struct *); void (*fork)(struct task_struct *); void (*exit)(struct task_struct *); void (*free)(struct task_struct *); void (*bind)(struct cgroup_subsys_state *); bool early_init; bool implicit_on_dfl; bool broken_hierarchy; bool warned_broken_hierarchy; int id; const char *name; const char *legacy_name; struct cgroup_root *root; struct idr css_idr; struct list_head cfts; struct cftype *dfl_cftypes; struct cftype *legacy_cftypes; unsigned int depends_on; } ; 128 struct futex_pi_state ; 129 struct robust_list_head ; 130 struct bio_list ; 131 struct fs_struct ; 132 struct perf_event_context ; 133 struct blk_plug ; 134 struct nameidata ; 188 struct cfs_rq ; 189 struct task_group ; 515 struct sighand_struct { atomic_t count; struct k_sigaction action[64U]; spinlock_t siglock; wait_queue_head_t signalfd_wqh; } ; 563 struct pacct_struct { int ac_flag; long ac_exitcode; unsigned long ac_mem; cputime_t ac_utime; cputime_t ac_stime; unsigned long ac_minflt; unsigned long ac_majflt; } ; 571 struct cpu_itimer { cputime_t expires; cputime_t incr; u32 error; u32 incr_error; } ; 578 struct prev_cputime { cputime_t utime; cputime_t stime; raw_spinlock_t lock; } ; 603 struct task_cputime { cputime_t utime; cputime_t stime; unsigned long long sum_exec_runtime; } ; 619 struct task_cputime_atomic { atomic64_t utime; atomic64_t stime; atomic64_t sum_exec_runtime; } ; 641 struct thread_group_cputimer { struct task_cputime_atomic cputime_atomic; bool running; bool checking_timer; } ; 686 struct autogroup ; 687 struct tty_struct ; 687 struct taskstats ; 687 struct tty_audit_buf ; 687 struct signal_struct { atomic_t sigcnt; atomic_t live; int nr_threads; struct list_head thread_head; wait_queue_head_t wait_chldexit; struct task_struct *curr_target; struct sigpending shared_pending; int group_exit_code; int notify_count; struct task_struct *group_exit_task; int group_stop_count; unsigned int flags; unsigned char is_child_subreaper; unsigned char has_child_subreaper; int posix_timer_id; struct list_head posix_timers; struct hrtimer real_timer; struct pid *leader_pid; ktime_t it_real_incr; struct cpu_itimer it[2U]; struct thread_group_cputimer cputimer; struct task_cputime cputime_expires; struct list_head cpu_timers[3U]; struct pid *tty_old_pgrp; int leader; struct tty_struct *tty; struct autogroup *autogroup; seqlock_t stats_lock; cputime_t utime; cputime_t stime; cputime_t cutime; cputime_t cstime; cputime_t gtime; cputime_t cgtime; struct prev_cputime prev_cputime; unsigned long nvcsw; unsigned long nivcsw; unsigned long cnvcsw; unsigned long cnivcsw; unsigned long min_flt; unsigned long maj_flt; unsigned long cmin_flt; unsigned long cmaj_flt; unsigned long inblock; unsigned long oublock; unsigned long cinblock; unsigned long coublock; unsigned long maxrss; unsigned long cmaxrss; struct task_io_accounting ioac; unsigned long long sum_sched_runtime; struct rlimit rlim[16U]; struct pacct_struct pacct; struct taskstats *stats; unsigned int audit_tty; struct tty_audit_buf *tty_audit_buf; bool oom_flag_origin; short oom_score_adj; short oom_score_adj_min; struct mm_struct *oom_mm; struct mutex cred_guard_mutex; } ; 863 struct user_struct { atomic_t __count; atomic_t processes; atomic_t sigpending; atomic_t inotify_watches; atomic_t inotify_devs; atomic_t fanotify_listeners; atomic_long_t epoll_watches; unsigned long mq_bytes; unsigned long locked_shm; unsigned long unix_inflight; atomic_long_t pipe_bufs; struct key *uid_keyring; struct key *session_keyring; struct hlist_node uidhash_node; kuid_t uid; atomic_long_t locked_vm; } ; 908 struct reclaim_state ; 909 struct sched_info { unsigned long pcount; unsigned long long run_delay; unsigned long long last_arrival; unsigned long long last_queued; } ; 924 struct task_delay_info { spinlock_t lock; unsigned int flags; u64 blkio_start; u64 blkio_delay; u64 swapin_delay; u32 blkio_count; u32 swapin_count; u64 freepages_start; u64 freepages_delay; u32 freepages_count; } ; 981 struct wake_q_node { struct wake_q_node *next; } ; 1226 struct io_context ; 1261 struct load_weight { unsigned long weight; u32 inv_weight; } ; 1269 struct sched_avg { u64 last_update_time; u64 load_sum; u32 util_sum; u32 period_contrib; unsigned long load_avg; unsigned long util_avg; } ; 1327 struct sched_statistics { u64 wait_start; u64 wait_max; u64 wait_count; u64 wait_sum; u64 iowait_count; u64 iowait_sum; u64 sleep_start; u64 sleep_max; s64 sum_sleep_runtime; u64 block_start; u64 block_max; u64 exec_max; u64 slice_max; u64 nr_migrations_cold; u64 nr_failed_migrations_affine; u64 nr_failed_migrations_running; u64 nr_failed_migrations_hot; u64 nr_forced_migrations; u64 nr_wakeups; u64 nr_wakeups_sync; u64 nr_wakeups_migrate; u64 nr_wakeups_local; u64 nr_wakeups_remote; u64 nr_wakeups_affine; u64 nr_wakeups_affine_attempts; u64 nr_wakeups_passive; u64 nr_wakeups_idle; } ; 1362 struct sched_entity { struct load_weight load; struct rb_node run_node; struct list_head group_node; unsigned int on_rq; u64 exec_start; u64 sum_exec_runtime; u64 vruntime; u64 prev_sum_exec_runtime; u64 nr_migrations; struct sched_statistics statistics; int depth; struct sched_entity *parent; struct cfs_rq *cfs_rq; struct cfs_rq *my_q; struct sched_avg avg; } ; 1399 struct rt_rq ; 1399 struct sched_rt_entity { struct list_head run_list; unsigned long timeout; unsigned long watchdog_stamp; unsigned int time_slice; unsigned short on_rq; unsigned short on_list; struct sched_rt_entity *back; struct sched_rt_entity *parent; struct rt_rq *rt_rq; struct rt_rq *my_q; } ; 1417 struct sched_dl_entity { struct rb_node rb_node; u64 dl_runtime; u64 dl_deadline; u64 dl_period; u64 dl_bw; s64 runtime; u64 deadline; unsigned int flags; int dl_throttled; int dl_boosted; int dl_yielded; struct hrtimer dl_timer; } ; 1481 struct tlbflush_unmap_batch { struct cpumask cpumask; bool flush_required; bool writable; } ; 1500 struct sched_class ; 1500 struct compat_robust_list_head ; 1500 struct numa_group ; 1500 struct kcov ; 1500 struct task_struct { struct thread_info thread_info; volatile long state; void *stack; atomic_t usage; unsigned int flags; unsigned int ptrace; struct llist_node wake_entry; int on_cpu; unsigned int cpu; unsigned int wakee_flips; unsigned long wakee_flip_decay_ts; struct task_struct *last_wakee; int wake_cpu; int on_rq; int prio; int static_prio; int normal_prio; unsigned int rt_priority; const struct sched_class *sched_class; struct sched_entity se; struct sched_rt_entity rt; struct task_group *sched_task_group; struct sched_dl_entity dl; struct hlist_head preempt_notifiers; unsigned int policy; int nr_cpus_allowed; cpumask_t cpus_allowed; unsigned long rcu_tasks_nvcsw; bool rcu_tasks_holdout; struct list_head rcu_tasks_holdout_list; int rcu_tasks_idle_cpu; struct sched_info sched_info; struct list_head tasks; struct plist_node pushable_tasks; struct rb_node pushable_dl_tasks; struct mm_struct *mm; struct mm_struct *active_mm; u32 vmacache_seqnum; struct vm_area_struct *vmacache[4U]; struct task_rss_stat rss_stat; int exit_state; int exit_code; int exit_signal; int pdeath_signal; unsigned long jobctl; unsigned int personality; unsigned char sched_reset_on_fork; unsigned char sched_contributes_to_load; unsigned char sched_migrated; unsigned char sched_remote_wakeup; unsigned char; unsigned char in_execve; unsigned char in_iowait; unsigned char restore_sigmask; unsigned char memcg_may_oom; unsigned char memcg_kmem_skip_account; unsigned char brk_randomized; unsigned long atomic_flags; struct restart_block restart_block; pid_t pid; pid_t tgid; struct task_struct *real_parent; struct task_struct *parent; struct list_head children; struct list_head sibling; struct task_struct *group_leader; struct list_head ptraced; struct list_head ptrace_entry; struct pid_link pids[3U]; struct list_head thread_group; struct list_head thread_node; struct completion *vfork_done; int *set_child_tid; int *clear_child_tid; cputime_t utime; cputime_t stime; cputime_t gtime; struct prev_cputime prev_cputime; unsigned long nvcsw; unsigned long nivcsw; u64 start_time; u64 real_start_time; unsigned long min_flt; unsigned long maj_flt; struct task_cputime cputime_expires; struct list_head cpu_timers[3U]; const struct cred *ptracer_cred; const struct cred *real_cred; const struct cred *cred; char comm[16U]; struct nameidata *nameidata; struct sysv_sem sysvsem; struct sysv_shm sysvshm; unsigned long last_switch_count; struct fs_struct *fs; struct files_struct *files; struct nsproxy *nsproxy; struct signal_struct *signal; struct sighand_struct *sighand; sigset_t blocked; sigset_t real_blocked; sigset_t saved_sigmask; struct sigpending pending; unsigned long sas_ss_sp; size_t sas_ss_size; unsigned int sas_ss_flags; struct callback_head *task_works; struct audit_context *audit_context; kuid_t loginuid; unsigned int sessionid; struct seccomp seccomp; u32 parent_exec_id; u32 self_exec_id; spinlock_t alloc_lock; raw_spinlock_t pi_lock; struct wake_q_node wake_q; struct rb_root pi_waiters; struct rb_node *pi_waiters_leftmost; struct rt_mutex_waiter *pi_blocked_on; struct mutex_waiter *blocked_on; unsigned int irq_events; unsigned long hardirq_enable_ip; unsigned long hardirq_disable_ip; unsigned int hardirq_enable_event; unsigned int hardirq_disable_event; int hardirqs_enabled; int hardirq_context; unsigned long softirq_disable_ip; unsigned long softirq_enable_ip; unsigned int softirq_disable_event; unsigned int softirq_enable_event; int softirqs_enabled; int softirq_context; u64 curr_chain_key; int lockdep_depth; unsigned int lockdep_recursion; struct held_lock held_locks[48U]; gfp_t lockdep_reclaim_gfp; unsigned int in_ubsan; void *journal_info; struct bio_list *bio_list; struct blk_plug *plug; struct reclaim_state *reclaim_state; struct backing_dev_info *backing_dev_info; struct io_context *io_context; unsigned long ptrace_message; siginfo_t *last_siginfo; struct task_io_accounting ioac; u64 acct_rss_mem1; u64 acct_vm_mem1; cputime_t acct_timexpd; nodemask_t mems_allowed; seqcount_t mems_allowed_seq; int cpuset_mem_spread_rotor; int cpuset_slab_spread_rotor; struct css_set *cgroups; struct list_head cg_list; int closid; struct robust_list_head *robust_list; struct compat_robust_list_head *compat_robust_list; struct list_head pi_state_list; struct futex_pi_state *pi_state_cache; struct perf_event_context *perf_event_ctxp[2U]; struct mutex perf_event_mutex; struct list_head perf_event_list; struct mempolicy *mempolicy; short il_next; short pref_node_fork; int numa_scan_seq; unsigned int numa_scan_period; unsigned int numa_scan_period_max; int numa_preferred_nid; unsigned long numa_migrate_retry; u64 node_stamp; u64 last_task_numa_placement; u64 last_sum_exec_runtime; struct callback_head numa_work; struct list_head numa_entry; struct numa_group *numa_group; unsigned long *numa_faults; unsigned long total_numa_faults; unsigned long numa_faults_locality[3U]; unsigned long numa_pages_migrated; struct tlbflush_unmap_batch tlb_ubc; struct callback_head rcu; struct pipe_inode_info *splice_pipe; struct page_frag task_frag; struct task_delay_info *delays; int make_it_fail; int nr_dirtied; int nr_dirtied_pause; unsigned long dirty_paused_when; int latency_record_count; struct latency_record latency_record[32U]; u64 timer_slack_ns; u64 default_timer_slack_ns; unsigned int kasan_depth; unsigned long trace; unsigned long trace_recursion; enum kcov_mode kcov_mode; unsigned int kcov_size; void *kcov_area; struct kcov *kcov; struct mem_cgroup *memcg_in_oom; gfp_t memcg_oom_gfp_mask; int memcg_oom_order; unsigned int memcg_nr_pages_over_high; struct uprobe_task *utask; unsigned int sequential_io; unsigned int sequential_io_avg; unsigned long task_state_change; int pagefault_disabled; struct task_struct *oom_reaper_list; atomic_t stack_refcount; struct thread_struct thread; } ; 3662 struct ratelimit_state { raw_spinlock_t lock; int interval; int burst; int printed; int missed; unsigned long begin; unsigned long flags; } ; 76 struct dma_map_ops ; 76 struct dev_archdata { struct dma_map_ops *dma_ops; void *iommu; } ; 21 struct pdev_archdata { } ; 24 struct device_private ; 25 struct device_driver ; 26 struct driver_private ; 27 struct class ; 28 struct subsys_private ; 29 struct bus_type ; 30 struct device_node ; 31 struct fwnode_handle ; 32 struct iommu_ops ; 33 struct iommu_group ; 34 struct iommu_fwspec ; 62 struct device_attribute ; 62 struct bus_type { const char *name; const char *dev_name; struct device *dev_root; struct device_attribute *dev_attrs; const struct attribute_group **bus_groups; const struct attribute_group **dev_groups; const struct attribute_group **drv_groups; int (*match)(struct device *, struct device_driver *); int (*uevent)(struct device *, struct kobj_uevent_env *); int (*probe)(struct device *); int (*remove)(struct device *); void (*shutdown)(struct device *); int (*online)(struct device *); int (*offline)(struct device *); int (*suspend)(struct device *, pm_message_t ); int (*resume)(struct device *); const struct dev_pm_ops *pm; const struct iommu_ops *iommu_ops; struct subsys_private *p; struct lock_class_key lock_key; } ; 143 struct device_type ; 202 enum probe_type { PROBE_DEFAULT_STRATEGY = 0, PROBE_PREFER_ASYNCHRONOUS = 1, PROBE_FORCE_SYNCHRONOUS = 2 } ; 208 struct of_device_id ; 208 struct acpi_device_id ; 208 struct device_driver { const char *name; struct bus_type *bus; struct module *owner; const char *mod_name; bool suppress_bind_attrs; enum probe_type probe_type; const struct of_device_id *of_match_table; const struct acpi_device_id *acpi_match_table; int (*probe)(struct device *); int (*remove)(struct device *); void (*shutdown)(struct device *); int (*suspend)(struct device *, pm_message_t ); int (*resume)(struct device *); const struct attribute_group **groups; const struct dev_pm_ops *pm; struct driver_private *p; } ; 358 struct class_attribute ; 358 struct class { const char *name; struct module *owner; struct class_attribute *class_attrs; const struct attribute_group **class_groups; const struct attribute_group **dev_groups; struct kobject *dev_kobj; int (*dev_uevent)(struct device *, struct kobj_uevent_env *); char * (*devnode)(struct device *, umode_t *); void (*class_release)(struct class *); void (*dev_release)(struct device *); int (*suspend)(struct device *, pm_message_t ); int (*resume)(struct device *); const struct kobj_ns_type_operations *ns_type; const void * (*namespace)(struct device *); const struct dev_pm_ops *pm; struct subsys_private *p; } ; 453 struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *, struct class_attribute *, char *); ssize_t (*store)(struct class *, struct class_attribute *, const char *, size_t ); } ; 523 struct device_type { const char *name; const struct attribute_group **groups; int (*uevent)(struct device *, struct kobj_uevent_env *); char * (*devnode)(struct device *, umode_t *, kuid_t *, kgid_t *); void (*release)(struct device *); const struct dev_pm_ops *pm; } ; 551 struct device_attribute { struct attribute attr; ssize_t (*show)(struct device *, struct device_attribute *, char *); ssize_t (*store)(struct device *, struct device_attribute *, const char *, size_t ); } ; 723 struct device_dma_parameters { unsigned int max_segment_size; unsigned long segment_boundary_mask; } ; 786 enum dl_dev_state { DL_DEV_NO_DRIVER = 0, DL_DEV_PROBING = 1, DL_DEV_DRIVER_BOUND = 2, DL_DEV_UNBINDING = 3 } ; 793 struct dev_links_info { struct list_head suppliers; struct list_head consumers; enum dl_dev_state status; } ; 813 struct irq_domain ; 813 struct dma_coherent_mem ; 813 struct cma ; 813 struct device { struct device *parent; struct device_private *p; struct kobject kobj; const char *init_name; const struct device_type *type; struct mutex mutex; struct bus_type *bus; struct device_driver *driver; void *platform_data; void *driver_data; struct dev_links_info links; struct dev_pm_info power; struct dev_pm_domain *pm_domain; struct irq_domain *msi_domain; struct dev_pin_info *pins; struct list_head msi_list; int numa_node; u64 *dma_mask; u64 coherent_dma_mask; unsigned long dma_pfn_offset; struct device_dma_parameters *dma_parms; struct list_head dma_pools; struct dma_coherent_mem *dma_mem; struct cma *cma_area; struct dev_archdata archdata; struct device_node *of_node; struct fwnode_handle *fwnode; dev_t devt; u32 id; spinlock_t devres_lock; struct list_head devres_head; struct klist_node knode_class; struct class *class; const struct attribute_group **groups; void (*release)(struct device *); struct iommu_group *iommu_group; struct iommu_fwspec *iommu_fwspec; bool offline_disabled; bool offline; } ; 971 struct wakeup_source { const char *name; struct list_head entry; spinlock_t lock; struct wake_irq *wakeirq; struct timer_list timer; unsigned long timer_expires; ktime_t total_time; ktime_t max_time; ktime_t last_time; ktime_t start_prevent_time; ktime_t prevent_sleep_time; unsigned long event_count; unsigned long active_count; unsigned long relax_count; unsigned long expire_count; unsigned long wakeup_count; bool active; bool autosleep_enabled; } ; 13 typedef unsigned long kernel_ulong_t; 187 struct acpi_device_id { __u8 id[9U]; kernel_ulong_t driver_data; __u32 cls; __u32 cls_msk; } ; 196 struct pnp_device_id { __u8 id[8U]; kernel_ulong_t driver_data; } ; 204 struct __anonstruct_devs_370 { __u8 id[8U]; } ; 204 struct pnp_card_device_id { __u8 id[8U]; kernel_ulong_t driver_data; struct __anonstruct_devs_370 devs[8U]; } ; 230 struct of_device_id { char name[32U]; char type[32U]; char compatible[128U]; const void *data; } ; 485 struct platform_device_id { char name[20U]; kernel_ulong_t driver_data; } ; 675 struct mfd_cell ; 677 struct platform_device { const char *name; int id; bool id_auto; struct device dev; u32 num_resources; struct resource *resource; const struct platform_device_id *id_entry; char *driver_override; struct mfd_cell *mfd_cell; struct pdev_archdata archdata; } ; 179 struct platform_driver { int (*probe)(struct platform_device *); int (*remove)(struct platform_device *); void (*shutdown)(struct platform_device *); int (*suspend)(struct platform_device *, pm_message_t ); int (*resume)(struct platform_device *); struct device_driver driver; const struct platform_device_id *id_table; bool prevent_deferred_probe; } ; 352 enum irqreturn { IRQ_NONE = 0, IRQ_HANDLED = 1, IRQ_WAKE_THREAD = 2 } ; 16 typedef enum irqreturn irqreturn_t; 423 struct proc_dir_entry ; 133 struct exception_table_entry { int insn; int fixup; int handler; } ; 506 struct tasklet_struct { struct tasklet_struct *next; unsigned long state; atomic_t count; void (*func)(unsigned long); unsigned long data; } ; 728 struct scatterlist ; 96 enum dma_data_direction { DMA_BIDIRECTIONAL = 0, DMA_TO_DEVICE = 1, DMA_FROM_DEVICE = 2, DMA_NONE = 3 } ; 273 struct vm_fault { struct vm_area_struct *vma; unsigned int flags; gfp_t gfp_mask; unsigned long pgoff; unsigned long address; pmd_t *pmd; pte_t orig_pte; struct page *cow_page; struct mem_cgroup *memcg; struct page *page; pte_t *pte; spinlock_t *ptl; pgtable_t prealloc_pte; } ; 322 struct vm_operations_struct { void (*open)(struct vm_area_struct *); void (*close)(struct vm_area_struct *); int (*mremap)(struct vm_area_struct *); int (*fault)(struct vm_area_struct *, struct vm_fault *); int (*pmd_fault)(struct vm_area_struct *, unsigned long, pmd_t *, unsigned int); void (*map_pages)(struct vm_fault *, unsigned long, unsigned long); int (*page_mkwrite)(struct vm_area_struct *, struct vm_fault *); int (*pfn_mkwrite)(struct vm_area_struct *, struct vm_fault *); int (*access)(struct vm_area_struct *, unsigned long, void *, int, int); const char * (*name)(struct vm_area_struct *); int (*set_policy)(struct vm_area_struct *, struct mempolicy *); struct mempolicy * (*get_policy)(struct vm_area_struct *, unsigned long); struct page * (*find_special_page)(struct vm_area_struct *, unsigned long); } ; 2439 struct scatterlist { unsigned long sg_magic; unsigned long page_link; unsigned int offset; unsigned int length; dma_addr_t dma_address; unsigned int dma_length; } ; 21 struct sg_table { struct scatterlist *sgl; unsigned int nents; unsigned int orig_nents; } ; 158 struct dma_map_ops { void * (*alloc)(struct device *, size_t , dma_addr_t *, gfp_t , unsigned long); void (*free)(struct device *, size_t , void *, dma_addr_t , unsigned long); int (*mmap)(struct device *, struct vm_area_struct *, void *, dma_addr_t , size_t , unsigned long); int (*get_sgtable)(struct device *, struct sg_table *, void *, dma_addr_t , size_t , unsigned long); dma_addr_t (*map_page)(struct device *, struct page *, unsigned long, size_t , enum dma_data_direction , unsigned long); void (*unmap_page)(struct device *, dma_addr_t , size_t , enum dma_data_direction , unsigned long); int (*map_sg)(struct device *, struct scatterlist *, int, enum dma_data_direction , unsigned long); void (*unmap_sg)(struct device *, struct scatterlist *, int, enum dma_data_direction , unsigned long); dma_addr_t (*map_resource)(struct device *, phys_addr_t , size_t , enum dma_data_direction , unsigned long); void (*unmap_resource)(struct device *, dma_addr_t , size_t , enum dma_data_direction , unsigned long); void (*sync_single_for_cpu)(struct device *, dma_addr_t , size_t , enum dma_data_direction ); void (*sync_single_for_device)(struct device *, dma_addr_t , size_t , enum dma_data_direction ); void (*sync_sg_for_cpu)(struct device *, struct scatterlist *, int, enum dma_data_direction ); void (*sync_sg_for_device)(struct device *, struct scatterlist *, int, enum dma_data_direction ); int (*mapping_error)(struct device *, dma_addr_t ); int (*dma_supported)(struct device *, u64 ); int (*set_dma_mask)(struct device *, u64 ); int is_phys; } ; 207 struct pnp_protocol ; 208 struct pnp_dev ; 195 struct pnp_id ; 195 struct pnp_card { struct device dev; unsigned char number; struct list_head global_list; struct list_head protocol_list; struct list_head devices; struct pnp_protocol *protocol; struct pnp_id *id; char name[50U]; unsigned char pnpver; unsigned char productver; unsigned int serial; unsigned char checksum; struct proc_dir_entry *procdir; } ; 218 struct pnp_card_driver ; 218 struct pnp_card_link { struct pnp_card *card; struct pnp_card_driver *driver; void *driver_data; pm_message_t pm_state; } ; 243 struct pnp_driver ; 243 struct pnp_dev { struct device dev; u64 dma_mask; unsigned int number; int status; struct list_head global_list; struct list_head protocol_list; struct list_head card_list; struct list_head rdev_list; struct pnp_protocol *protocol; struct pnp_card *card; struct pnp_driver *driver; struct pnp_card_link *card_link; struct pnp_id *id; int active; int capabilities; unsigned int num_dependent_sets; struct list_head resources; struct list_head options; char name[50U]; int flags; struct proc_dir_entry *procent; void *data; } ; 356 struct pnp_id { char id[8U]; struct pnp_id *next; } ; 379 struct pnp_driver { char *name; const struct pnp_device_id *id_table; unsigned int flags; int (*probe)(struct pnp_dev *, const struct pnp_device_id *); void (*remove)(struct pnp_dev *); void (*shutdown)(struct pnp_dev *); int (*suspend)(struct pnp_dev *, pm_message_t ); int (*resume)(struct pnp_dev *); struct device_driver driver; } ; 391 struct pnp_card_driver { struct list_head global_list; char *name; const struct pnp_card_device_id *id_table; unsigned int flags; int (*probe)(struct pnp_card_link *, const struct pnp_card_device_id *); void (*remove)(struct pnp_card_link *); int (*suspend)(struct pnp_card_link *, pm_message_t ); int (*resume)(struct pnp_card_link *); struct pnp_driver link; } ; 406 struct pnp_protocol { struct list_head protocol_list; char *name; int (*get)(struct pnp_dev *); int (*set)(struct pnp_dev *); int (*disable)(struct pnp_dev *); bool (*can_wakeup)(struct pnp_dev *); int (*suspend)(struct pnp_dev *, pm_message_t ); int (*resume)(struct pnp_dev *); unsigned char number; struct device dev; struct list_head cards; struct list_head devices; } ; 249 enum led_brightness { LED_OFF = 0, LED_HALF = 127, LED_FULL = 255 } ; 255 struct led_trigger ; 255 struct led_classdev { const char *name; enum led_brightness brightness; enum led_brightness max_brightness; int flags; unsigned long work_flags; void (*brightness_set)(struct led_classdev *, enum led_brightness ); int (*brightness_set_blocking)(struct led_classdev *, enum led_brightness ); enum led_brightness (*brightness_get)(struct led_classdev *); int (*blink_set)(struct led_classdev *, unsigned long *, unsigned long *); struct device *dev; const struct attribute_group **groups; struct list_head node; const char *default_trigger; unsigned long blink_delay_on; unsigned long blink_delay_off; struct timer_list blink_timer; int blink_brightness; int new_blink_brightness; void (*flash_resume)(struct led_classdev *); struct work_struct set_brightness_work; int delayed_set_value; struct rw_semaphore trigger_lock; struct led_trigger *trigger; struct list_head trig_list; void *trigger_data; bool activated; struct mutex led_access; } ; 226 struct led_trigger { const char *name; void (*activate)(struct led_classdev *); void (*deactivate)(struct led_classdev *); rwlock_t leddev_list_lock; struct list_head led_cdevs; struct list_head next_trig; } ; 172 struct fault_attr { unsigned long probability; unsigned long interval; atomic_t times; atomic_t space; unsigned long verbose; bool task_filter; unsigned long stacktrace_depth; unsigned long require_start; unsigned long require_end; unsigned long reject_start; unsigned long reject_end; unsigned long count; struct ratelimit_state ratelimit_state; struct dentry *dname; } ; 67 struct mmc_data ; 68 struct mmc_request ; 69 enum mmc_blk_status { MMC_BLK_SUCCESS = 0, MMC_BLK_PARTIAL = 1, MMC_BLK_CMD_ERR = 2, MMC_BLK_RETRY = 3, MMC_BLK_ABORT = 4, MMC_BLK_DATA_ERR = 5, MMC_BLK_ECC_ERR = 6, MMC_BLK_NOMEDIUM = 7, MMC_BLK_NEW_REQUEST = 8 } ; 81 struct mmc_command { u32 opcode; u32 arg; u32 resp[4U]; unsigned int flags; unsigned int retries; int error; unsigned int busy_timeout; bool sanitize_busy; struct mmc_data *data; struct mmc_request *mrq; } ; 120 struct mmc_data { unsigned int timeout_ns; unsigned int timeout_clks; unsigned int blksz; unsigned int blocks; int error; unsigned int flags; unsigned int bytes_xfered; struct mmc_command *stop; struct mmc_request *mrq; unsigned int sg_len; int sg_count; struct scatterlist *sg; s32 host_cookie; } ; 142 struct mmc_host ; 143 struct mmc_request { struct mmc_command *sbc; struct mmc_command *cmd; struct mmc_data *data; struct mmc_command *stop; struct completion completion; struct completion cmd_completion; void (*done)(struct mmc_request *); struct mmc_host *host; bool cap_cmd_during_tfr; } ; 158 struct mmc_card ; 159 struct mmc_async_req ; 236 struct mmc_cid { unsigned int manfid; char prod_name[8U]; unsigned char prv; unsigned int serial; unsigned short oemid; unsigned short year; unsigned char hwrev; unsigned char fwrev; unsigned char month; } ; 28 struct mmc_csd { unsigned char structure; unsigned char mmca_vsn; unsigned short cmdclass; unsigned short tacc_clks; unsigned int tacc_ns; unsigned int c_size; unsigned int r2w_factor; unsigned int max_dtr; unsigned int erase_size; unsigned int read_blkbits; unsigned int write_blkbits; unsigned int capacity; unsigned char read_partial; unsigned char read_misalign; unsigned char write_partial; unsigned char write_misalign; unsigned char dsr_imp; } ; 48 struct mmc_ext_csd { u8 rev; u8 erase_group_def; u8 sec_feature_support; u8 rel_sectors; u8 rel_param; u8 part_config; u8 cache_ctrl; u8 rst_n_function; u8 max_packed_writes; u8 max_packed_reads; u8 packed_event_en; unsigned int part_time; unsigned int sa_timeout; unsigned int generic_cmd6_time; unsigned int power_off_longtime; u8 power_off_notification; unsigned int hs_max_dtr; unsigned int hs200_max_dtr; unsigned int sectors; unsigned int hc_erase_size; unsigned int hc_erase_timeout; unsigned int sec_trim_mult; unsigned int sec_erase_mult; unsigned int trim_timeout; bool partition_setting_completed; unsigned long long enhanced_area_offset; unsigned int enhanced_area_size; unsigned int cache_size; bool hpi_en; bool hpi; unsigned int hpi_cmd; bool bkops; bool man_bkops_en; unsigned int data_sector_size; unsigned int data_tag_unit_size; unsigned int boot_ro_lock; bool boot_ro_lockable; bool ffu_capable; bool cmdq_support; unsigned int cmdq_depth; u8 fwrev[8U]; u8 raw_exception_status; u8 raw_partition_support; u8 raw_rpmb_size_mult; u8 raw_erased_mem_count; u8 strobe_support; u8 raw_ext_csd_structure; u8 raw_card_type; u8 raw_driver_strength; u8 out_of_int_time; u8 raw_pwr_cl_52_195; u8 raw_pwr_cl_26_195; u8 raw_pwr_cl_52_360; u8 raw_pwr_cl_26_360; u8 raw_s_a_timeout; u8 raw_hc_erase_gap_size; u8 raw_erase_timeout_mult; u8 raw_hc_erase_grp_size; u8 raw_sec_trim_mult; u8 raw_sec_erase_mult; u8 raw_sec_feature_support; u8 raw_trim_mult; u8 raw_pwr_cl_200_195; u8 raw_pwr_cl_200_360; u8 raw_pwr_cl_ddr_52_195; u8 raw_pwr_cl_ddr_52_360; u8 raw_pwr_cl_ddr_200_360; u8 raw_bkops_status; u8 raw_sectors[4U]; unsigned int feature_support; } ; 127 struct sd_scr { unsigned char sda_vsn; unsigned char sda_spec3; unsigned char bus_widths; unsigned char cmds; } ; 137 struct sd_ssr { unsigned int au; unsigned int erase_timeout; unsigned int erase_offset; } ; 145 struct sd_switch_caps { unsigned int hs_max_dtr; unsigned int uhs_max_dtr; unsigned int sd3_bus_mode; unsigned int sd3_drv_type; unsigned int sd3_curr_limit; } ; 176 struct sdio_cccr { unsigned int sdio_vsn; unsigned int sd_vsn; unsigned char multi_block; unsigned char low_speed; unsigned char wide_bus; unsigned char high_power; unsigned char high_speed; unsigned char disable_cd; } ; 197 struct sdio_cis { unsigned short vendor; unsigned short device; unsigned short blksize; unsigned int max_dtr; } ; 204 struct mmc_ios ; 205 struct sdio_func ; 206 struct sdio_func_tuple ; 207 struct mmc_part { unsigned int size; unsigned int part_cfg; char name[20U]; bool force_ro; unsigned int area_type; } ; 231 struct mmc_card { struct mmc_host *host; struct device dev; u32 ocr; unsigned int rca; unsigned int type; unsigned int state; unsigned int quirks; unsigned int erase_size; unsigned int erase_shift; unsigned int pref_erase; unsigned int eg_boundary; u8 erased_byte; u32 raw_cid[4U]; u32 raw_csd[4U]; u32 raw_scr[2U]; u32 raw_ssr[16U]; struct mmc_cid cid; struct mmc_csd csd; struct mmc_ext_csd ext_csd; struct sd_scr scr; struct sd_ssr ssr; struct sd_switch_caps sw_caps; unsigned int sdio_funcs; struct sdio_cccr cccr; struct sdio_cis cis; struct sdio_func *sdio_func[7U]; struct sdio_func *sdio_single_irq; unsigned int num_info; const char **info; struct sdio_func_tuple *tuples; unsigned int sd_bus_speed; unsigned int mmc_avail_type; unsigned int drive_strength; struct dentry *debugfs_root; struct mmc_part part[7U]; unsigned int nr_parts; } ; 25 typedef unsigned int mmc_pm_flag_t; 26 struct mmc_ios { unsigned int clock; unsigned short vdd; unsigned char bus_mode; unsigned char chip_select; unsigned char power_mode; unsigned char bus_width; unsigned char timing; unsigned char signal_voltage; unsigned char drv_type; bool enhanced_strobe; } ; 84 struct mmc_host_ops { void (*post_req)(struct mmc_host *, struct mmc_request *, int); void (*pre_req)(struct mmc_host *, struct mmc_request *); void (*request)(struct mmc_host *, struct mmc_request *); void (*set_ios)(struct mmc_host *, struct mmc_ios *); int (*get_ro)(struct mmc_host *); int (*get_cd)(struct mmc_host *); void (*enable_sdio_irq)(struct mmc_host *, int); void (*init_card)(struct mmc_host *, struct mmc_card *); int (*start_signal_voltage_switch)(struct mmc_host *, struct mmc_ios *); int (*card_busy)(struct mmc_host *); int (*execute_tuning)(struct mmc_host *, u32 ); int (*prepare_hs400_tuning)(struct mmc_host *, struct mmc_ios *); void (*hs400_enhanced_strobe)(struct mmc_host *, struct mmc_ios *); int (*select_drive_strength)(struct mmc_card *, unsigned int, int, int, int *); void (*hw_reset)(struct mmc_host *); void (*card_event)(struct mmc_host *); int (*multi_io_quirk)(struct mmc_card *, unsigned int, int); } ; 163 struct mmc_async_req { struct mmc_request *mrq; enum mmc_blk_status (*err_check)(struct mmc_card *, struct mmc_async_req *); } ; 177 struct mmc_slot { int cd_irq; void *handler_priv; } ; 193 struct mmc_context_info { bool is_done_rcv; bool is_new_req; bool is_waiting_last_req; wait_queue_head_t wait; } ; 207 struct regulator ; 208 struct mmc_pwrseq ; 209 struct mmc_supply { struct regulator *vmmc; struct regulator *vqmmc; } ; 215 struct mmc_bus_ops ; 215 struct mmc_host { struct device *parent; struct device class_dev; int index; const struct mmc_host_ops *ops; struct mmc_pwrseq *pwrseq; unsigned int f_min; unsigned int f_max; unsigned int f_init; u32 ocr_avail; u32 ocr_avail_sdio; u32 ocr_avail_sd; u32 ocr_avail_mmc; struct notifier_block pm_notify; u32 max_current_330; u32 max_current_300; u32 max_current_180; u32 caps; u32 caps2; mmc_pm_flag_t pm_caps; unsigned int max_seg_size; unsigned short max_segs; unsigned short unused; unsigned int max_req_size; unsigned int max_blk_size; unsigned int max_blk_count; unsigned int max_busy_timeout; spinlock_t lock; struct mmc_ios ios; unsigned char use_spi_crc; unsigned char claimed; unsigned char bus_dead; unsigned char removed; unsigned char can_retune; unsigned char doing_retune; unsigned char retune_now; unsigned char retune_paused; int rescan_disable; int rescan_entered; int need_retune; int hold_retune; unsigned int retune_period; struct timer_list retune_timer; bool trigger_card_event; struct mmc_card *card; wait_queue_head_t wq; struct task_struct *claimer; int claim_cnt; struct delayed_work detect; int detect_change; struct mmc_slot slot; const struct mmc_bus_ops *bus_ops; unsigned int bus_refs; unsigned int sdio_irqs; struct task_struct *sdio_irq_thread; bool sdio_irq_pending; atomic_t sdio_irq_thread_abort; mmc_pm_flag_t pm_flags; struct led_trigger *led; bool regulator_enabled; struct mmc_supply supply; struct dentry *debugfs_root; struct mmc_async_req *areq; struct mmc_context_info context_info; struct mmc_request *ongoing_mrq; struct fault_attr fail_mmc_request; unsigned int actual_clock; unsigned int slotno; int dsr_req; u32 dsr; unsigned long private[0U]; } ; 313 struct wbsd_host { struct mmc_host *mmc; spinlock_t lock; int flags; struct mmc_request *mrq; u8 isr; struct scatterlist *cur_sg; unsigned int num_sg; unsigned int offset; unsigned int remain; char *dma_buffer; dma_addr_t dma_addr; int firsterr; u8 clk; unsigned char bus_width; int config; u8 unlock_code; int chip_id; int base; int irq; int dma; struct tasklet_struct card_tasklet; struct tasklet_struct fifo_tasklet; struct tasklet_struct crc_tasklet; struct tasklet_struct timeout_tasklet; struct tasklet_struct finish_tasklet; struct timer_list ignore_timer; } ; 1 long int __builtin_expect(long, long); 34 extern struct module __this_module; 204 bool test_and_set_bit(long nr, volatile unsigned long *addr); 178 int printk(const char *, ...); 55 void __dynamic_pr_debug(struct _ddebug *, const char *, ...); 8 void ldv_dma_map_page(); 9 void ldv_dma_mapping_error(); 71 void warn_slowpath_null(const char *, const int); 7 extern unsigned long page_offset_base; 9 extern unsigned long vmemmap_base; 23 unsigned long int __phys_addr(unsigned long); 32 void * __memcpy(void *, const void *, size_t ); 93 void __raw_spin_lock_init(raw_spinlock_t *, const char *, struct lock_class_key *); 22 void _raw_spin_lock(raw_spinlock_t *); 30 void _raw_spin_lock_bh(raw_spinlock_t *); 34 unsigned long int _raw_spin_lock_irqsave(raw_spinlock_t *); 41 void _raw_spin_unlock(raw_spinlock_t *); 42 void _raw_spin_unlock_bh(raw_spinlock_t *); 45 void _raw_spin_unlock_irqrestore(raw_spinlock_t *, unsigned long); 289 raw_spinlock_t * spinlock_check(spinlock_t *lock); 300 void spin_lock(spinlock_t *lock); 305 void spin_lock_bh(spinlock_t *lock); 345 void spin_unlock(spinlock_t *lock); 350 void spin_unlock_bh(spinlock_t *lock); 360 void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags); 78 extern volatile unsigned long jiffies; 296 unsigned long int __msecs_to_jiffies(const unsigned int); 358 unsigned long int msecs_to_jiffies(const unsigned int m); 95 void init_timer_key(struct timer_list *, unsigned int, const char *, struct lock_class_key *); 191 int mod_timer(struct timer_list *, unsigned long); 245 int del_timer_sync(struct timer_list *); 166 extern struct resource ioport_resource; 225 struct resource * __request_region(struct resource *, resource_size_t , resource_size_t , const char *, int); 234 void __release_region(struct resource *, resource_size_t , resource_size_t ); 316 void outb(unsigned char value, int port); 316 unsigned char inb(int port); 87 const char * kobject_name(const struct kobject *kobj); 974 const char * dev_name(const struct device *dev); 1021 void * dev_get_drvdata(const struct device *dev); 1026 void dev_set_drvdata(struct device *dev, void *data); 46 void platform_device_unregister(struct platform_device *); 168 struct platform_device * platform_device_alloc(const char *, int); 176 int platform_device_add(struct platform_device *); 178 void platform_device_put(struct platform_device *); 199 int __platform_driver_register(struct platform_driver *, struct module *); 201 void platform_driver_unregister(struct platform_driver *); 211 void * platform_get_drvdata(const struct platform_device *pdev); 139 int request_threaded_irq(unsigned int, irqreturn_t (*)(int, void *), irqreturn_t (*)(int, void *), unsigned long, const char *, void *); 144 int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *), unsigned long flags, const char *name, void *dev); 158 void free_irq(unsigned int, void *); 570 void __tasklet_schedule(struct tasklet_struct *); 572 void tasklet_schedule(struct tasklet_struct *t); 578 void __tasklet_hi_schedule(struct tasklet_struct *); 580 void tasklet_hi_schedule(struct tasklet_struct *t); 620 void tasklet_kill(struct tasklet_struct *); 622 void tasklet_init(struct tasklet_struct *, void (*)(unsigned long), unsigned long); 37 void debug_dma_map_page(struct device *, struct page *, size_t , size_t , int, dma_addr_t , bool ); 42 void debug_dma_mapping_error(struct device *, dma_addr_t ); 44 void debug_dma_unmap_page(struct device *, dma_addr_t , size_t , int, bool ); 992 void * lowmem_page_address(const struct page *page); 120 struct page * sg_page(struct scatterlist *sg); 239 void * sg_virt(struct scatterlist *sg); 131 void kmemcheck_mark_initialized(void *address, unsigned int n); 136 int valid_dma_direction(int dma_direction); 28 extern struct dma_map_ops *dma_ops; 30 struct dma_map_ops * get_dma_ops(struct device *dev); 180 dma_addr_t ldv_dma_map_single_attrs_5(struct device *dev, void *ptr, size_t size, enum dma_data_direction dir, unsigned long attrs); 180 dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr, size_t size, enum dma_data_direction dir, unsigned long attrs); 203 void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr, size_t size, enum dma_data_direction dir, unsigned long attrs); 523 int ldv_dma_mapping_error_6(struct device *dev, dma_addr_t dma_addr); 523 int dma_mapping_error(struct device *dev, dma_addr_t dma_addr); 10 void __const_udelay(unsigned long); 26 struct resource * pnp_get_resource(struct pnp_dev *, unsigned long, unsigned int); 36 int pnp_resource_valid(struct resource *res); 58 resource_size_t pnp_port_start(struct pnp_dev *dev, unsigned int bar); 149 resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar); 173 resource_size_t pnp_dma(struct pnp_dev *dev, unsigned int bar); 191 int pnp_dma_valid(struct pnp_dev *dev, unsigned int bar); 479 int pnp_register_driver(struct pnp_driver *); 480 void pnp_unregister_driver(struct pnp_driver *); 400 struct mmc_host * mmc_alloc_host(int, struct device *); 401 int mmc_add_host(struct mmc_host *); 402 void mmc_remove_host(struct mmc_host *); 403 void mmc_free_host(struct mmc_host *); 406 void * mmc_priv(struct mmc_host *host); 420 void mmc_detect_change(struct mmc_host *, unsigned long); 421 void mmc_request_done(struct mmc_host *, struct mmc_request *); 154 void kfree(const void *); 330 void * __kmalloc(size_t , gfp_t ); 478 void * kmalloc(size_t size, gfp_t flags); 150 extern struct spinlock dma_spin_lock; 152 unsigned long int claim_dma_lock(); 159 void release_dma_lock(unsigned long flags); 166 void enable_dma(unsigned int dmanr); 174 void disable_dma(unsigned int dmanr); 189 void clear_dma_ff(unsigned int dmanr); 198 void set_dma_mode(unsigned int dmanr, char mode); 211 void set_dma_page(unsigned int dmanr, char pagenr); 242 void set_dma_addr(unsigned int dmanr, unsigned int a); 263 void set_dma_count(unsigned int dmanr, unsigned int count); 287 int get_dma_residue(unsigned int dmanr); 305 int request_dma(unsigned int, const char *); 306 void free_dma(unsigned int); 58 const struct pnp_device_id pnp_dev_table[3U] = { { { 'W', 'E', 'C', '0', '5', '1', '7', '\x0' }, 0UL }, { { 'W', 'E', 'C', '0', '5', '1', '8', '\x0' }, 0UL }, { { '\x0' }, 0UL } }; 64 const struct pnp_device_id __mod_pnp__pnp_dev_table_device_table[3U] = { }; 68 const int config_ports[2U] = { 46, 78 }; 69 const int unlock_codes[2U] = { 131, 135 }; 71 const int valid_ids[1U] = { 28946 }; 76 unsigned int param_nopnp = 0U; 80 unsigned int param_io = 584U; 81 unsigned int param_irq = 6U; 82 int param_dma = 2; 88 void wbsd_unlock_config(struct wbsd_host *host); 96 void wbsd_lock_config(struct wbsd_host *host); 103 void wbsd_write_config(struct wbsd_host *host, u8 reg, u8 value); 111 u8 wbsd_read_config(struct wbsd_host *host, u8 reg); 119 void wbsd_write_index(struct wbsd_host *host, u8 index, u8 value); 125 u8 wbsd_read_index(struct wbsd_host *host, u8 index); 135 void wbsd_init_device(struct wbsd_host *host); 194 void wbsd_reset(struct wbsd_host *host); 208 void wbsd_request_end(struct wbsd_host *host, struct mmc_request *mrq); 241 void wbsd_init_sg(struct wbsd_host *host, struct mmc_data *data); 253 int wbsd_next_sg(struct wbsd_host *host); 272 char * wbsd_sg_to_buffer(struct wbsd_host *host); 277 void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data); 294 void wbsd_dma_to_sg(struct wbsd_host *host, struct mmc_data *data); 315 void wbsd_get_short_reply(struct wbsd_host *host, struct mmc_command *cmd); 333 void wbsd_get_long_reply(struct wbsd_host *host, struct mmc_command *cmd); 358 void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd); 418 void wbsd_empty_fifo(struct wbsd_host *host); 480 void wbsd_fill_fifo(struct wbsd_host *host); 542 void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data); 677 void wbsd_finish_data(struct wbsd_host *host, struct mmc_data *data); 755 void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq); 851 void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios); 924 int wbsd_get_ro(struct mmc_host *mmc); 946 const struct mmc_host_ops wbsd_ops = { 0, 0, &wbsd_request, &wbsd_set_ios, &wbsd_get_ro, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 962 void wbsd_reset_ignore(unsigned long data); 987 struct mmc_data * wbsd_get_data(struct wbsd_host *host); 1004 void wbsd_tasklet_card(unsigned long param); 1053 void wbsd_tasklet_fifo(unsigned long param); 1084 void wbsd_tasklet_crc(unsigned long param); 1108 void wbsd_tasklet_timeout(unsigned long param); 1132 void wbsd_tasklet_finish(unsigned long param); 1157 irqreturn_t wbsd_irq(int irq, void *dev_id); 1199 int wbsd_alloc_mmc(struct device *dev); 1268 void wbsd_free_mmc(struct device *dev); 1291 int wbsd_scan(struct wbsd_host *host); 1347 int wbsd_request_region(struct wbsd_host *host, int base); 1360 void wbsd_release_regions(struct wbsd_host *host); 1377 void wbsd_request_dma(struct wbsd_host *host, int dma); 1439 void wbsd_release_dma(struct wbsd_host *host); 1458 int wbsd_request_irq(struct wbsd_host *host, int irq); 1488 void wbsd_release_irq(struct wbsd_host *host); 1508 int wbsd_request_resources(struct wbsd_host *host, int base, int irq, int dma); 1539 void wbsd_release_resources(struct wbsd_host *host); 1550 void wbsd_chip_config(struct wbsd_host *host); 1594 int wbsd_chip_validate(struct wbsd_host *host); 1634 void wbsd_chip_poweroff(struct wbsd_host *host); 1650 int wbsd_init(struct device *dev, int base, int irq, int dma, int pnp); 1736 void wbsd_shutdown(struct device *dev, int pnp); 1763 int wbsd_probe(struct platform_device *dev); 1769 int wbsd_remove(struct platform_device *dev); 1783 int wbsd_pnp_probe(struct pnp_dev *pnpdev, const struct pnp_device_id *dev_id); 1802 void wbsd_pnp_remove(struct pnp_dev *dev); 1815 int wbsd_platform_suspend(struct platform_device *dev, pm_message_t state); 1832 int wbsd_platform_resume(struct platform_device *dev); 1857 int wbsd_pnp_suspend(struct pnp_dev *pnp_dev, pm_message_t state); 1868 int wbsd_pnp_resume(struct pnp_dev *pnp_dev); 1911 struct platform_device *wbsd_device = 0; 1913 struct platform_driver wbsd_driver = { &wbsd_probe, &wbsd_remove, 0, &wbsd_platform_suspend, &wbsd_platform_resume, { "wbsd", 0, 0, 0, (_Bool)0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, (_Bool)0 }; 1926 struct pnp_driver wbsd_pnp_driver = { (char *)"wbsd", (const struct pnp_device_id *)(&pnp_dev_table), 0U, &wbsd_pnp_probe, &wbsd_pnp_remove, 0, &wbsd_pnp_suspend, &wbsd_pnp_resume, { 0, 0, 0, 0, (_Bool)0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; 1942 int wbsd_drv_init(); 1981 void wbsd_drv_exit(); 2035 void ldv_check_final_state(); 2038 void ldv_check_return_value(int); 2041 void ldv_check_return_value_probe(int); 2044 void ldv_initialize(); 2047 void ldv_handler_precall(); 2050 int nondet_int(); 2053 int LDV_IN_INTERRUPT = 0; 2056 void ldv_main0_sequence_infinite_withcheck_stateful(); 10 void ldv_error(); 7 bool ldv_is_err(const void *ptr); 14 void * ldv_err_ptr(long error); 21 long int ldv_ptr_err(const void *ptr); 28 bool ldv_is_err_or_null(const void *ptr); 5 int LDV_DMA_MAP_CALLS = 0; return ; } { 2058 struct mmc_host *var_group1; 2059 struct mmc_request *var_group2; 2060 struct mmc_ios *var_group3; 2061 struct platform_device *var_group4; 2062 int res_wbsd_probe_48; 2063 struct pm_message var_wbsd_platform_suspend_52_p1; 2064 struct pnp_dev *var_group5; 2065 const struct pnp_device_id *var_wbsd_pnp_probe_50_p1; 2066 int res_wbsd_pnp_probe_50; 2067 struct pm_message var_wbsd_pnp_suspend_54_p1; 2068 int var_wbsd_irq_31_p0; 2069 void *var_wbsd_irq_31_p1; 2070 unsigned long var_wbsd_reset_ignore_24_p0; 2071 int ldv_s_wbsd_driver_platform_driver; 2072 int ldv_s_wbsd_pnp_driver_pnp_driver; 2073 int tmp; 2074 int tmp___0; 2075 int tmp___1; 2678 ldv_s_wbsd_driver_platform_driver = 0; 2680 ldv_s_wbsd_pnp_driver_pnp_driver = 0; 2622 LDV_IN_INTERRUPT = 1; 2631 ldv_initialize() { /* Function call is skipped due to function is undefined */} 2665 ldv_handler_precall() { /* Function call is skipped due to function is undefined */} { 1944 int result; 1946 printk("\016wbsd: Winbond W83L51xD SD/MMC card interface driver\n") { /* Function call is skipped due to function is undefined */} 1948 printk("\016wbsd: Copyright(c) Pierre Ossman\n") { /* Function call is skipped due to function is undefined */} 1953 result = pnp_register_driver(&wbsd_pnp_driver) { /* Function call is skipped due to function is undefined */} } 2688 goto ldv_36351; 2688 tmp___1 = nondet_int() { /* Function call is skipped due to function is undefined */} 2692 goto ldv_36350; 2689 ldv_36350:; 2693 tmp___0 = nondet_int() { /* Function call is skipped due to function is undefined */} 2693 switch (tmp___0); { } 1785 int io; 1786 int irq; 1787 int dma; 1788 unsigned long long tmp; 1789 unsigned long long tmp___0; 1790 unsigned long long tmp___1; 1791 int tmp___2; 1792 struct _ddebug descriptor; 1793 long tmp___3; 1794 int tmp___4; { 60 struct resource *res; 61 struct resource *tmp; 62 int tmp___0; 61 tmp = pnp_get_resource(dev, 256UL, bar) { /* Function call is skipped due to function is undefined */} 61 res = tmp; { 38 assume(((unsigned long)res) != ((unsigned long)((struct resource *)0))); 39 return 1;; } 63 assume(tmp___0 != 0); 64 return res->start;; } 1790 io = (int)tmp; { 151 struct resource *res; 152 struct resource *tmp; 153 int tmp___0; 151 tmp = pnp_get_resource(dev, 1024UL, bar) { /* Function call is skipped due to function is undefined */} 151 res = tmp; { 38 assume(!(((unsigned long)res) != ((unsigned long)((struct resource *)0)))); 40 return 0;; } 153 assume(!(tmp___0 != 0)); 155 return 18446744073709551615ULL;; } 1791 irq = (int)tmp___0; { 193 struct resource *tmp; 194 int tmp___0; 193 tmp = pnp_get_resource(dev, 2048UL, bar) { /* Function call is skipped due to function is undefined */} { 38 assume(!(((unsigned long)res) != ((unsigned long)((struct resource *)0)))); 40 return 0;; } 193 return tmp___0;; } 1795 dma = -1; 1797 descriptor.modname = "wbsd"; 1797 descriptor.function = "wbsd_pnp_probe"; 1797 descriptor.filename = "/home/ldvuser/ldv/ref_launches/work/current--X--drivers--X--defaultlinux-4.10-rc1.tar.xz--X--331_1a--X--cpachecker/linux-4.10-rc1.tar.xz/csd_deg_dscv/16260/dscv_tempdir/dscv/ri/331_1a/drivers/mmc/host/wbsd.c"; 1797 descriptor.format = "wbsd [%s()]: PnP resources: port %3x irq %d dma %d\n"; 1797 descriptor.lineno = 1797U; 1797 descriptor.flags = 0U; 1797 tmp___3 = __builtin_expect(((long)(descriptor.flags)) & 1L, 0L) { /* Function call is skipped due to function is undefined */} 1797 __dynamic_pr_debug(&descriptor, "wbsd [%s()]: PnP resources: port %3x irq %d dma %d\n", "wbsd_pnp_probe", io, irq, dma) { /* Function call is skipped due to function is undefined */} { } 1652 struct wbsd_host *host; 1653 struct mmc_host *mmc; 1654 int ret; 1655 void *tmp; 1656 void *tmp___0; 1657 int tmp___1; 1658 unsigned long __ms; 1659 unsigned long tmp___2; 1660 const char *tmp___3; 1653 host = (struct wbsd_host *)0; 1654 mmc = (struct mmc_host *)0; { 1201 struct mmc_host *mmc; 1202 struct wbsd_host *host; 1203 void *tmp; 1204 struct lock_class_key __key; 1205 struct lock_class_key __key___0; 1207 mmc = mmc_alloc_host(496, dev) { /* Function call is skipped due to function is undefined */} { 408 return (void *)(&(host->private));; } 1211 host = (struct wbsd_host *)tmp; 1212 host->mmc = mmc; 1214 host->dma = -1; 1219 mmc->ops = &wbsd_ops; 1220 mmc->f_min = 375000U; 1221 mmc->f_max = 24000000U; 1222 mmc->ocr_avail = 3145728U; 1223 mmc->caps = 1U; { 291 return &(lock->__annonCompField20.rlock);; } 1225 __raw_spin_lock_init(&(host->lock.__annonCompField20.rlock), "&(&host->lock)->rlock", &__key) { /* Function call is skipped due to function is undefined */} 1230 init_timer_key(&(host->ignore_timer), 0U, "(&host->ignore_timer)", &__key___0) { /* Function call is skipped due to function is undefined */} 1231 host->ignore_timer.data = (unsigned long)host; 1232 host->ignore_timer.function = &wbsd_reset_ignore; 1238 mmc->max_segs = 128U; 1243 mmc->max_req_size = 65536U; 1249 mmc->max_seg_size = mmc->max_req_size; 1255 mmc->max_blk_size = 4087U; 1261 mmc->max_blk_count = mmc->max_req_size; { } 1028 dev->driver_data = data; 1029 return ;; } { 1023 void *__CPAchecker_TMP_0 = (void *)(dev->driver_data); 1023 return __CPAchecker_TMP_0;; } 1661 mmc = (struct mmc_host *)tmp; { 408 return (void *)(&(host->private));; } 1662 host = (struct wbsd_host *)tmp___0; { 1293 int i; 1294 int j; 1295 int k; 1296 int id; 1297 struct resource *tmp; 1298 unsigned char tmp___0; 1299 unsigned char tmp___1; 1300 struct _ddebug descriptor; 1301 long tmp___2; 1300 i = 0; 1300 goto ldv_36075; 1302 goto ldv_36074; 1301 ldv_36074:; 1301 tmp = __request_region(&ioport_resource, (resource_size_t )(config_ports[i]), 2ULL, "wbsd", 0) { /* Function call is skipped due to function is undefined */} 1304 j = 0; 1304 goto ldv_36072; 1306 goto ldv_36071; 1305 ldv_36071:; 1305 id = 65535; 1307 host->config = config_ports[i]; 1308 host->unlock_code = (u8 )(unlock_codes[j]); { 90 long tmp; 90 tmp = __builtin_expect((host->config) == 0, 0L) { /* Function call is skipped due to function is undefined */} 92 int __CPAchecker_TMP_0 = (int)(host->unlock_code); { 316 Ignored inline assembler code 317 return ;; } 93 int __CPAchecker_TMP_1 = (int)(host->unlock_code); { }316 Ignored inline assembler code 317 return ;; } { 316 Ignored inline assembler code 317 return ;; } { 318 unsigned char value; 316 Ignored inline assembler code 316 return value;; } 1313 id = ((int)tmp___0) << 8; { 316 Ignored inline assembler code 317 return ;; } { 318 unsigned char value; 316 Ignored inline assembler code 316 return value;; } 1316 id = ((int)tmp___1) | id; { 98 long tmp; 98 tmp = __builtin_expect((host->config) == 0, 0L) { /* Function call is skipped due to function is undefined */} { }316 Ignored inline assembler code 317 return ;; } 1320 k = 0; 1320 goto ldv_36067; 1322 goto ldv_36066; 1321 ldv_36066:; 1322 host->chip_id = id; } { } 1510 int ret; { 1349 struct resource *tmp; 1352 tmp = __request_region(&ioport_resource, (resource_size_t )base, 8ULL, "wbsd", 0) { /* Function call is skipped due to function is undefined */} 1355 host->base = base; } { } 1460 int ret; 1465 tasklet_init(&(host->card_tasklet), &wbsd_tasklet_card, (unsigned long)host) { /* Function call is skipped due to function is undefined */} 1467 tasklet_init(&(host->fifo_tasklet), &wbsd_tasklet_fifo, (unsigned long)host) { /* Function call is skipped due to function is undefined */} 1469 tasklet_init(&(host->crc_tasklet), &wbsd_tasklet_crc, (unsigned long)host) { /* Function call is skipped due to function is undefined */} 1471 tasklet_init(&(host->timeout_tasklet), &wbsd_tasklet_timeout, (unsigned long)host) { /* Function call is skipped due to function is undefined */} 1473 tasklet_init(&(host->finish_tasklet), &wbsd_tasklet_finish, (unsigned long)host) { /* Function call is skipped due to function is undefined */} { } 147 int tmp; 147 tmp = request_threaded_irq(irq, handler, (irqreturn_t (*)(int, void *))0, flags, name, dev) { /* Function call is skipped due to function is undefined */} 147 return tmp;; } | Source code 1 #ifndef _ASM_X86_IO_H
2 #define _ASM_X86_IO_H
3
4 /*
5 * This file contains the definitions for the x86 IO instructions
6 * inb/inw/inl/outb/outw/outl and the "string versions" of the same
7 * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
8 * versions of the single-IO instructions (inb_p/inw_p/..).
9 *
10 * This file is not meant to be obfuscating: it's just complicated
11 * to (a) handle it all in a way that makes gcc able to optimize it
12 * as well as possible and (b) trying to avoid writing the same thing
13 * over and over again with slight variations and possibly making a
14 * mistake somewhere.
15 */
16
17 /*
18 * Thanks to James van Artsdalen for a better timing-fix than
19 * the two short jumps: using outb's to a nonexistent port seems
20 * to guarantee better timings even on fast machines.
21 *
22 * On the other hand, I'd like to be sure of a non-existent port:
23 * I feel a bit unsafe about using 0x80 (should be safe, though)
24 *
25 * Linus
26 */
27
28 /*
29 * Bit simplified and optimized by Jan Hubicka
30 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
31 *
32 * isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added,
33 * isa_read[wl] and isa_write[wl] fixed
34 * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
35 */
36
37 #define ARCH_HAS_IOREMAP_WC
38 #define ARCH_HAS_IOREMAP_WT
39
40 #include <linux/string.h>
41 #include <linux/compiler.h>
42 #include <asm/page.h>
43 #include <asm/early_ioremap.h>
44 #include <asm/pgtable_types.h>
45
46 #define build_mmio_read(name, size, type, reg, barrier) \
47 static inline type name(const volatile void __iomem *addr) \
48 { type ret; asm volatile("mov" size " %1,%0":reg (ret) \
49 :"m" (*(volatile type __force *)addr) barrier); return ret; }
50
51 #define build_mmio_write(name, size, type, reg, barrier) \
52 static inline void name(type val, volatile void __iomem *addr) \
53 { asm volatile("mov" size " %0,%1": :reg (val), \
54 "m" (*(volatile type __force *)addr) barrier); }
55
56 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
57 build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
58 build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
59
60 build_mmio_read(__readb, "b", unsigned char, "=q", )
61 build_mmio_read(__readw, "w", unsigned short, "=r", )
62 build_mmio_read(__readl, "l", unsigned int, "=r", )
63
64 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
65 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
66 build_mmio_write(writel, "l", unsigned int, "r", :"memory")
67
68 build_mmio_write(__writeb, "b", unsigned char, "q", )
69 build_mmio_write(__writew, "w", unsigned short, "r", )
70 build_mmio_write(__writel, "l", unsigned int, "r", )
71
72 #define readb_relaxed(a) __readb(a)
73 #define readw_relaxed(a) __readw(a)
74 #define readl_relaxed(a) __readl(a)
75 #define __raw_readb __readb
76 #define __raw_readw __readw
77 #define __raw_readl __readl
78
79 #define writeb_relaxed(v, a) __writeb(v, a)
80 #define writew_relaxed(v, a) __writew(v, a)
81 #define writel_relaxed(v, a) __writel(v, a)
82 #define __raw_writeb __writeb
83 #define __raw_writew __writew
84 #define __raw_writel __writel
85
86 #define mmiowb() barrier()
87
88 #ifdef CONFIG_X86_64
89
90 build_mmio_read(readq, "q", unsigned long, "=r", :"memory")
91 build_mmio_write(writeq, "q", unsigned long, "r", :"memory")
92
93 #define readq_relaxed(a) readq(a)
94 #define writeq_relaxed(v, a) writeq(v, a)
95
96 #define __raw_readq(a) readq(a)
97 #define __raw_writeq(val, addr) writeq(val, addr)
98
99 /* Let people know that we have them */
100 #define readq readq
101 #define writeq writeq
102
103 #endif
104
105 /**
106 * virt_to_phys - map virtual addresses to physical
107 * @address: address to remap
108 *
109 * The returned physical address is the physical (CPU) mapping for
110 * the memory address given. It is only valid to use this function on
111 * addresses directly mapped or allocated via kmalloc.
112 *
113 * This function does not give bus mappings for DMA transfers. In
114 * almost all conceivable cases a device driver should not be using
115 * this function
116 */
117
118 static inline phys_addr_t virt_to_phys(volatile void *address)
119 {
120 return __pa(address);
121 }
122
123 /**
124 * phys_to_virt - map physical address to virtual
125 * @address: address to remap
126 *
127 * The returned virtual address is a current CPU mapping for
128 * the memory address given. It is only valid to use this function on
129 * addresses that have a kernel mapping
130 *
131 * This function does not handle bus mappings for DMA transfers. In
132 * almost all conceivable cases a device driver should not be using
133 * this function
134 */
135
136 static inline void *phys_to_virt(phys_addr_t address)
137 {
138 return __va(address);
139 }
140
141 /*
142 * Change "struct page" to physical address.
143 */
144 #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
145
146 /*
147 * ISA I/O bus memory addresses are 1:1 with the physical address.
148 * However, we truncate the address to unsigned int to avoid undesirable
149 * promitions in legacy drivers.
150 */
151 static inline unsigned int isa_virt_to_bus(volatile void *address)
152 {
153 return (unsigned int)virt_to_phys(address);
154 }
155 #define isa_page_to_bus(page) ((unsigned int)page_to_phys(page))
156 #define isa_bus_to_virt phys_to_virt
157
158 /*
159 * However PCI ones are not necessarily 1:1 and therefore these interfaces
160 * are forbidden in portable PCI drivers.
161 *
162 * Allow them on x86 for legacy drivers, though.
163 */
164 #define virt_to_bus virt_to_phys
165 #define bus_to_virt phys_to_virt
166
167 /**
168 * ioremap - map bus memory into CPU space
169 * @offset: bus address of the memory
170 * @size: size of the resource to map
171 *
172 * ioremap performs a platform specific sequence of operations to
173 * make bus memory CPU accessible via the readb/readw/readl/writeb/
174 * writew/writel functions and the other mmio helpers. The returned
175 * address is not guaranteed to be usable directly as a virtual
176 * address.
177 *
178 * If the area you are trying to map is a PCI BAR you should have a
179 * look at pci_iomap().
180 */
181 extern void __iomem *ioremap_nocache(resource_size_t offset, unsigned long size);
182 extern void __iomem *ioremap_uc(resource_size_t offset, unsigned long size);
183 #define ioremap_uc ioremap_uc
184
185 extern void __iomem *ioremap_cache(resource_size_t offset, unsigned long size);
186 extern void __iomem *ioremap_prot(resource_size_t offset, unsigned long size,
187 unsigned long prot_val);
188
189 /*
190 * The default ioremap() behavior is non-cached:
191 */
192 static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
193 {
194 return ioremap_nocache(offset, size);
195 }
196
197 extern void iounmap(volatile void __iomem *addr);
198
199 extern void set_iounmap_nonlazy(void);
200
201 #ifdef __KERNEL__
202
203 #include <asm-generic/iomap.h>
204
205 /*
206 * Convert a virtual cached pointer to an uncached pointer
207 */
208 #define xlate_dev_kmem_ptr(p) p
209
210 static inline void
211 memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
212 {
213 memset((void __force *)addr, val, count);
214 }
215
216 static inline void
217 memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
218 {
219 memcpy(dst, (const void __force *)src, count);
220 }
221
222 static inline void
223 memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
224 {
225 memcpy((void __force *)dst, src, count);
226 }
227
228 /*
229 * ISA space is 'always mapped' on a typical x86 system, no need to
230 * explicitly ioremap() it. The fact that the ISA IO space is mapped
231 * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
232 * are physical addresses. The following constant pointer can be
233 * used as the IO-area pointer (it can be iounmapped as well, so the
234 * analogy with PCI is quite large):
235 */
236 #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
237
238 /*
239 * Cache management
240 *
241 * This needed for two cases
242 * 1. Out of order aware processors
243 * 2. Accidentally out of order processors (PPro errata #51)
244 */
245
246 static inline void flush_write_buffers(void)
247 {
248 #if defined(CONFIG_X86_PPRO_FENCE)
249 asm volatile("lock; addl $0,0(%%esp)": : :"memory");
250 #endif
251 }
252
253 #endif /* __KERNEL__ */
254
255 extern void native_io_delay(void);
256
257 extern int io_delay_type;
258 extern void io_delay_init(void);
259
260 #if defined(CONFIG_PARAVIRT)
261 #include <asm/paravirt.h>
262 #else
263
264 static inline void slow_down_io(void)
265 {
266 native_io_delay();
267 #ifdef REALLY_SLOW_IO
268 native_io_delay();
269 native_io_delay();
270 native_io_delay();
271 #endif
272 }
273
274 #endif
275
276 #define BUILDIO(bwl, bw, type) \
277 static inline void out##bwl(unsigned type value, int port) \
278 { \
279 asm volatile("out" #bwl " %" #bw "0, %w1" \
280 : : "a"(value), "Nd"(port)); \
281 } \
282 \
283 static inline unsigned type in##bwl(int port) \
284 { \
285 unsigned type value; \
286 asm volatile("in" #bwl " %w1, %" #bw "0" \
287 : "=a"(value) : "Nd"(port)); \
288 return value; \
289 } \
290 \
291 static inline void out##bwl##_p(unsigned type value, int port) \
292 { \
293 out##bwl(value, port); \
294 slow_down_io(); \
295 } \
296 \
297 static inline unsigned type in##bwl##_p(int port) \
298 { \
299 unsigned type value = in##bwl(port); \
300 slow_down_io(); \
301 return value; \
302 } \
303 \
304 static inline void outs##bwl(int port, const void *addr, unsigned long count) \
305 { \
306 asm volatile("rep; outs" #bwl \
307 : "+S"(addr), "+c"(count) : "d"(port)); \
308 } \
309 \
310 static inline void ins##bwl(int port, void *addr, unsigned long count) \
311 { \
312 asm volatile("rep; ins" #bwl \
313 : "+D"(addr), "+c"(count) : "d"(port)); \
314 }
315
316 BUILDIO(b, b, char)
317 BUILDIO(w, w, short)
318 BUILDIO(l, , int)
319
320 extern void *xlate_dev_mem_ptr(phys_addr_t phys);
321 extern void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
322
323 extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
324 enum page_cache_mode pcm);
325 extern void __iomem *ioremap_wc(resource_size_t offset, unsigned long size);
326 extern void __iomem *ioremap_wt(resource_size_t offset, unsigned long size);
327
328 extern bool is_early_ioremap_ptep(pte_t *ptep);
329
330 #ifdef CONFIG_XEN
331 #include <xen/xen.h>
332 struct bio_vec;
333
334 extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
335 const struct bio_vec *vec2);
336
337 #define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
338 (__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \
339 (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))
340 #endif /* CONFIG_XEN */
341
342 #define IO_SPACE_LIMIT 0xffff
343
344 #ifdef CONFIG_MTRR
345 extern int __must_check arch_phys_wc_index(int handle);
346 #define arch_phys_wc_index arch_phys_wc_index
347
348 extern int __must_check arch_phys_wc_add(unsigned long base,
349 unsigned long size);
350 extern void arch_phys_wc_del(int handle);
351 #define arch_phys_wc_add arch_phys_wc_add
352 #endif
353
354 #ifdef CONFIG_X86_PAT
355 extern int arch_io_reserve_memtype_wc(resource_size_t start, resource_size_t size);
356 extern void arch_io_free_memtype_wc(resource_size_t start, resource_size_t size);
357 #define arch_io_reserve_memtype_wc arch_io_reserve_memtype_wc
358 #endif
359
360 #endif /* _ASM_X86_IO_H */ 1
2 /*
3 * linux/drivers/mmc/host/wbsd.c - Winbond W83L51xD SD/MMC driver
4 *
5 * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved.
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 (at
10 * your option) any later version.
11 *
12 *
13 * Warning!
14 *
15 * Changes to the FIFO system should be done with extreme care since
16 * the hardware is full of bugs related to the FIFO. Known issues are:
17 *
18 * - FIFO size field in FSR is always zero.
19 *
20 * - FIFO interrupts tend not to work as they should. Interrupts are
21 * triggered only for full/empty events, not for threshold values.
22 *
23 * - On APIC systems the FIFO empty interrupt is sometimes lost.
24 */
25
26 #include <linux/module.h>
27 #include <linux/moduleparam.h>
28 #include <linux/init.h>
29 #include <linux/ioport.h>
30 #include <linux/platform_device.h>
31 #include <linux/interrupt.h>
32 #include <linux/dma-mapping.h>
33 #include <linux/delay.h>
34 #include <linux/pnp.h>
35 #include <linux/highmem.h>
36 #include <linux/mmc/host.h>
37 #include <linux/scatterlist.h>
38 #include <linux/slab.h>
39
40 #include <asm/io.h>
41 #include <asm/dma.h>
42
43 #include "wbsd.h"
44
45 #define DRIVER_NAME "wbsd"
46
47 #define DBG(x...) \
48 pr_debug(DRIVER_NAME ": " x)
49 #define DBGF(f, x...) \
50 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
51
52 /*
53 * Device resources
54 */
55
56 #ifdef CONFIG_PNP
57
58 static const struct pnp_device_id pnp_dev_table[] = {
59 { "WEC0517", 0 },
60 { "WEC0518", 0 },
61 { "", 0 },
62 };
63
64 MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
65
66 #endif /* CONFIG_PNP */
67
68 static const int config_ports[] = { 0x2E, 0x4E };
69 static const int unlock_codes[] = { 0x83, 0x87 };
70
71 static const int valid_ids[] = {
72 0x7112,
73 };
74
75 #ifdef CONFIG_PNP
76 static unsigned int param_nopnp = 0;
77 #else
78 static const unsigned int param_nopnp = 1;
79 #endif
80 static unsigned int param_io = 0x248;
81 static unsigned int param_irq = 6;
82 static int param_dma = 2;
83
84 /*
85 * Basic functions
86 */
87
88 static inline void wbsd_unlock_config(struct wbsd_host *host)
89 {
90 BUG_ON(host->config == 0);
91
92 outb(host->unlock_code, host->config);
93 outb(host->unlock_code, host->config);
94 }
95
96 static inline void wbsd_lock_config(struct wbsd_host *host)
97 {
98 BUG_ON(host->config == 0);
99
100 outb(LOCK_CODE, host->config);
101 }
102
103 static inline void wbsd_write_config(struct wbsd_host *host, u8 reg, u8 value)
104 {
105 BUG_ON(host->config == 0);
106
107 outb(reg, host->config);
108 outb(value, host->config + 1);
109 }
110
111 static inline u8 wbsd_read_config(struct wbsd_host *host, u8 reg)
112 {
113 BUG_ON(host->config == 0);
114
115 outb(reg, host->config);
116 return inb(host->config + 1);
117 }
118
119 static inline void wbsd_write_index(struct wbsd_host *host, u8 index, u8 value)
120 {
121 outb(index, host->base + WBSD_IDXR);
122 outb(value, host->base + WBSD_DATAR);
123 }
124
125 static inline u8 wbsd_read_index(struct wbsd_host *host, u8 index)
126 {
127 outb(index, host->base + WBSD_IDXR);
128 return inb(host->base + WBSD_DATAR);
129 }
130
131 /*
132 * Common routines
133 */
134
135 static void wbsd_init_device(struct wbsd_host *host)
136 {
137 u8 setup, ier;
138
139 /*
140 * Reset chip (SD/MMC part) and fifo.
141 */
142 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
143 setup |= WBSD_FIFO_RESET | WBSD_SOFT_RESET;
144 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
145
146 /*
147 * Set DAT3 to input
148 */
149 setup &= ~WBSD_DAT3_H;
150 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
151 host->flags &= ~WBSD_FIGNORE_DETECT;
152
153 /*
154 * Read back default clock.
155 */
156 host->clk = wbsd_read_index(host, WBSD_IDX_CLK);
157
158 /*
159 * Power down port.
160 */
161 outb(WBSD_POWER_N, host->base + WBSD_CSR);
162
163 /*
164 * Set maximum timeout.
165 */
166 wbsd_write_index(host, WBSD_IDX_TAAC, 0x7F);
167
168 /*
169 * Test for card presence
170 */
171 if (inb(host->base + WBSD_CSR) & WBSD_CARDPRESENT)
172 host->flags |= WBSD_FCARD_PRESENT;
173 else
174 host->flags &= ~WBSD_FCARD_PRESENT;
175
176 /*
177 * Enable interesting interrupts.
178 */
179 ier = 0;
180 ier |= WBSD_EINT_CARD;
181 ier |= WBSD_EINT_FIFO_THRE;
182 ier |= WBSD_EINT_CRC;
183 ier |= WBSD_EINT_TIMEOUT;
184 ier |= WBSD_EINT_TC;
185
186 outb(ier, host->base + WBSD_EIR);
187
188 /*
189 * Clear interrupts.
190 */
191 inb(host->base + WBSD_ISR);
192 }
193
194 static void wbsd_reset(struct wbsd_host *host)
195 {
196 u8 setup;
197
198 pr_err("%s: Resetting chip\n", mmc_hostname(host->mmc));
199
200 /*
201 * Soft reset of chip (SD/MMC part).
202 */
203 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
204 setup |= WBSD_SOFT_RESET;
205 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
206 }
207
208 static void wbsd_request_end(struct wbsd_host *host, struct mmc_request *mrq)
209 {
210 unsigned long dmaflags;
211
212 if (host->dma >= 0) {
213 /*
214 * Release ISA DMA controller.
215 */
216 dmaflags = claim_dma_lock();
217 disable_dma(host->dma);
218 clear_dma_ff(host->dma);
219 release_dma_lock(dmaflags);
220
221 /*
222 * Disable DMA on host.
223 */
224 wbsd_write_index(host, WBSD_IDX_DMA, 0);
225 }
226
227 host->mrq = NULL;
228
229 /*
230 * MMC layer might call back into the driver so first unlock.
231 */
232 spin_unlock(&host->lock);
233 mmc_request_done(host->mmc, mrq);
234 spin_lock(&host->lock);
235 }
236
237 /*
238 * Scatter/gather functions
239 */
240
241 static inline void wbsd_init_sg(struct wbsd_host *host, struct mmc_data *data)
242 {
243 /*
244 * Get info. about SG list from data structure.
245 */
246 host->cur_sg = data->sg;
247 host->num_sg = data->sg_len;
248
249 host->offset = 0;
250 host->remain = host->cur_sg->length;
251 }
252
253 static inline int wbsd_next_sg(struct wbsd_host *host)
254 {
255 /*
256 * Skip to next SG entry.
257 */
258 host->cur_sg++;
259 host->num_sg--;
260
261 /*
262 * Any entries left?
263 */
264 if (host->num_sg > 0) {
265 host->offset = 0;
266 host->remain = host->cur_sg->length;
267 }
268
269 return host->num_sg;
270 }
271
272 static inline char *wbsd_sg_to_buffer(struct wbsd_host *host)
273 {
274 return sg_virt(host->cur_sg);
275 }
276
277 static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data)
278 {
279 unsigned int len, i;
280 struct scatterlist *sg;
281 char *dmabuf = host->dma_buffer;
282 char *sgbuf;
283
284 sg = data->sg;
285 len = data->sg_len;
286
287 for (i = 0; i < len; i++) {
288 sgbuf = sg_virt(&sg[i]);
289 memcpy(dmabuf, sgbuf, sg[i].length);
290 dmabuf += sg[i].length;
291 }
292 }
293
294 static inline void wbsd_dma_to_sg(struct wbsd_host *host, struct mmc_data *data)
295 {
296 unsigned int len, i;
297 struct scatterlist *sg;
298 char *dmabuf = host->dma_buffer;
299 char *sgbuf;
300
301 sg = data->sg;
302 len = data->sg_len;
303
304 for (i = 0; i < len; i++) {
305 sgbuf = sg_virt(&sg[i]);
306 memcpy(sgbuf, dmabuf, sg[i].length);
307 dmabuf += sg[i].length;
308 }
309 }
310
311 /*
312 * Command handling
313 */
314
315 static inline void wbsd_get_short_reply(struct wbsd_host *host,
316 struct mmc_command *cmd)
317 {
318 /*
319 * Correct response type?
320 */
321 if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_SHORT) {
322 cmd->error = -EILSEQ;
323 return;
324 }
325
326 cmd->resp[0] = wbsd_read_index(host, WBSD_IDX_RESP12) << 24;
327 cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP13) << 16;
328 cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP14) << 8;
329 cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP15) << 0;
330 cmd->resp[1] = wbsd_read_index(host, WBSD_IDX_RESP16) << 24;
331 }
332
333 static inline void wbsd_get_long_reply(struct wbsd_host *host,
334 struct mmc_command *cmd)
335 {
336 int i;
337
338 /*
339 * Correct response type?
340 */
341 if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_LONG) {
342 cmd->error = -EILSEQ;
343 return;
344 }
345
346 for (i = 0; i < 4; i++) {
347 cmd->resp[i] =
348 wbsd_read_index(host, WBSD_IDX_RESP1 + i * 4) << 24;
349 cmd->resp[i] |=
350 wbsd_read_index(host, WBSD_IDX_RESP2 + i * 4) << 16;
351 cmd->resp[i] |=
352 wbsd_read_index(host, WBSD_IDX_RESP3 + i * 4) << 8;
353 cmd->resp[i] |=
354 wbsd_read_index(host, WBSD_IDX_RESP4 + i * 4) << 0;
355 }
356 }
357
358 static void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd)
359 {
360 int i;
361 u8 status, isr;
362
363 /*
364 * Clear accumulated ISR. The interrupt routine
365 * will fill this one with events that occur during
366 * transfer.
367 */
368 host->isr = 0;
369
370 /*
371 * Send the command (CRC calculated by host).
372 */
373 outb(cmd->opcode, host->base + WBSD_CMDR);
374 for (i = 3; i >= 0; i--)
375 outb((cmd->arg >> (i * 8)) & 0xff, host->base + WBSD_CMDR);
376
377 cmd->error = 0;
378
379 /*
380 * Wait for the request to complete.
381 */
382 do {
383 status = wbsd_read_index(host, WBSD_IDX_STATUS);
384 } while (status & WBSD_CARDTRAFFIC);
385
386 /*
387 * Do we expect a reply?
388 */
389 if (cmd->flags & MMC_RSP_PRESENT) {
390 /*
391 * Read back status.
392 */
393 isr = host->isr;
394
395 /* Card removed? */
396 if (isr & WBSD_INT_CARD)
397 cmd->error = -ENOMEDIUM;
398 /* Timeout? */
399 else if (isr & WBSD_INT_TIMEOUT)
400 cmd->error = -ETIMEDOUT;
401 /* CRC? */
402 else if ((cmd->flags & MMC_RSP_CRC) && (isr & WBSD_INT_CRC))
403 cmd->error = -EILSEQ;
404 /* All ok */
405 else {
406 if (cmd->flags & MMC_RSP_136)
407 wbsd_get_long_reply(host, cmd);
408 else
409 wbsd_get_short_reply(host, cmd);
410 }
411 }
412 }
413
414 /*
415 * Data functions
416 */
417
418 static void wbsd_empty_fifo(struct wbsd_host *host)
419 {
420 struct mmc_data *data = host->mrq->cmd->data;
421 char *buffer;
422 int i, fsr, fifo;
423
424 /*
425 * Handle excessive data.
426 */
427 if (host->num_sg == 0)
428 return;
429
430 buffer = wbsd_sg_to_buffer(host) + host->offset;
431
432 /*
433 * Drain the fifo. This has a tendency to loop longer
434 * than the FIFO length (usually one block).
435 */
436 while (!((fsr = inb(host->base + WBSD_FSR)) & WBSD_FIFO_EMPTY)) {
437 /*
438 * The size field in the FSR is broken so we have to
439 * do some guessing.
440 */
441 if (fsr & WBSD_FIFO_FULL)
442 fifo = 16;
443 else if (fsr & WBSD_FIFO_FUTHRE)
444 fifo = 8;
445 else
446 fifo = 1;
447
448 for (i = 0; i < fifo; i++) {
449 *buffer = inb(host->base + WBSD_DFR);
450 buffer++;
451 host->offset++;
452 host->remain--;
453
454 data->bytes_xfered++;
455
456 /*
457 * End of scatter list entry?
458 */
459 if (host->remain == 0) {
460 /*
461 * Get next entry. Check if last.
462 */
463 if (!wbsd_next_sg(host))
464 return;
465
466 buffer = wbsd_sg_to_buffer(host);
467 }
468 }
469 }
470
471 /*
472 * This is a very dirty hack to solve a
473 * hardware problem. The chip doesn't trigger
474 * FIFO threshold interrupts properly.
475 */
476 if ((data->blocks * data->blksz - data->bytes_xfered) < 16)
477 tasklet_schedule(&host->fifo_tasklet);
478 }
479
480 static void wbsd_fill_fifo(struct wbsd_host *host)
481 {
482 struct mmc_data *data = host->mrq->cmd->data;
483 char *buffer;
484 int i, fsr, fifo;
485
486 /*
487 * Check that we aren't being called after the
488 * entire buffer has been transferred.
489 */
490 if (host->num_sg == 0)
491 return;
492
493 buffer = wbsd_sg_to_buffer(host) + host->offset;
494
495 /*
496 * Fill the fifo. This has a tendency to loop longer
497 * than the FIFO length (usually one block).
498 */
499 while (!((fsr = inb(host->base + WBSD_FSR)) & WBSD_FIFO_FULL)) {
500 /*
501 * The size field in the FSR is broken so we have to
502 * do some guessing.
503 */
504 if (fsr & WBSD_FIFO_EMPTY)
505 fifo = 0;
506 else if (fsr & WBSD_FIFO_EMTHRE)
507 fifo = 8;
508 else
509 fifo = 15;
510
511 for (i = 16; i > fifo; i--) {
512 outb(*buffer, host->base + WBSD_DFR);
513 buffer++;
514 host->offset++;
515 host->remain--;
516
517 data->bytes_xfered++;
518
519 /*
520 * End of scatter list entry?
521 */
522 if (host->remain == 0) {
523 /*
524 * Get next entry. Check if last.
525 */
526 if (!wbsd_next_sg(host))
527 return;
528
529 buffer = wbsd_sg_to_buffer(host);
530 }
531 }
532 }
533
534 /*
535 * The controller stops sending interrupts for
536 * 'FIFO empty' under certain conditions. So we
537 * need to be a bit more pro-active.
538 */
539 tasklet_schedule(&host->fifo_tasklet);
540 }
541
542 static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data)
543 {
544 u16 blksize;
545 u8 setup;
546 unsigned long dmaflags;
547 unsigned int size;
548
549 /*
550 * Calculate size.
551 */
552 size = data->blocks * data->blksz;
553
554 /*
555 * Check timeout values for overflow.
556 * (Yes, some cards cause this value to overflow).
557 */
558 if (data->timeout_ns > 127000000)
559 wbsd_write_index(host, WBSD_IDX_TAAC, 127);
560 else {
561 wbsd_write_index(host, WBSD_IDX_TAAC,
562 data->timeout_ns / 1000000);
563 }
564
565 if (data->timeout_clks > 255)
566 wbsd_write_index(host, WBSD_IDX_NSAC, 255);
567 else
568 wbsd_write_index(host, WBSD_IDX_NSAC, data->timeout_clks);
569
570 /*
571 * Inform the chip of how large blocks will be
572 * sent. It needs this to determine when to
573 * calculate CRC.
574 *
575 * Space for CRC must be included in the size.
576 * Two bytes are needed for each data line.
577 */
578 if (host->bus_width == MMC_BUS_WIDTH_1) {
579 blksize = data->blksz + 2;
580
581 wbsd_write_index(host, WBSD_IDX_PBSMSB, (blksize >> 4) & 0xF0);
582 wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF);
583 } else if (host->bus_width == MMC_BUS_WIDTH_4) {
584 blksize = data->blksz + 2 * 4;
585
586 wbsd_write_index(host, WBSD_IDX_PBSMSB,
587 ((blksize >> 4) & 0xF0) | WBSD_DATA_WIDTH);
588 wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF);
589 } else {
590 data->error = -EINVAL;
591 return;
592 }
593
594 /*
595 * Clear the FIFO. This is needed even for DMA
596 * transfers since the chip still uses the FIFO
597 * internally.
598 */
599 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
600 setup |= WBSD_FIFO_RESET;
601 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
602
603 /*
604 * DMA transfer?
605 */
606 if (host->dma >= 0) {
607 /*
608 * The buffer for DMA is only 64 kB.
609 */
610 BUG_ON(size > 0x10000);
611 if (size > 0x10000) {
612 data->error = -EINVAL;
613 return;
614 }
615
616 /*
617 * Transfer data from the SG list to
618 * the DMA buffer.
619 */
620 if (data->flags & MMC_DATA_WRITE)
621 wbsd_sg_to_dma(host, data);
622
623 /*
624 * Initialise the ISA DMA controller.
625 */
626 dmaflags = claim_dma_lock();
627 disable_dma(host->dma);
628 clear_dma_ff(host->dma);
629 if (data->flags & MMC_DATA_READ)
630 set_dma_mode(host->dma, DMA_MODE_READ & ~0x40);
631 else
632 set_dma_mode(host->dma, DMA_MODE_WRITE & ~0x40);
633 set_dma_addr(host->dma, host->dma_addr);
634 set_dma_count(host->dma, size);
635
636 enable_dma(host->dma);
637 release_dma_lock(dmaflags);
638
639 /*
640 * Enable DMA on the host.
641 */
642 wbsd_write_index(host, WBSD_IDX_DMA, WBSD_DMA_ENABLE);
643 } else {
644 /*
645 * This flag is used to keep printk
646 * output to a minimum.
647 */
648 host->firsterr = 1;
649
650 /*
651 * Initialise the SG list.
652 */
653 wbsd_init_sg(host, data);
654
655 /*
656 * Turn off DMA.
657 */
658 wbsd_write_index(host, WBSD_IDX_DMA, 0);
659
660 /*
661 * Set up FIFO threshold levels (and fill
662 * buffer if doing a write).
663 */
664 if (data->flags & MMC_DATA_READ) {
665 wbsd_write_index(host, WBSD_IDX_FIFOEN,
666 WBSD_FIFOEN_FULL | 8);
667 } else {
668 wbsd_write_index(host, WBSD_IDX_FIFOEN,
669 WBSD_FIFOEN_EMPTY | 8);
670 wbsd_fill_fifo(host);
671 }
672 }
673
674 data->error = 0;
675 }
676
677 static void wbsd_finish_data(struct wbsd_host *host, struct mmc_data *data)
678 {
679 unsigned long dmaflags;
680 int count;
681 u8 status;
682
683 WARN_ON(host->mrq == NULL);
684
685 /*
686 * Send a stop command if needed.
687 */
688 if (data->stop)
689 wbsd_send_command(host, data->stop);
690
691 /*
692 * Wait for the controller to leave data
693 * transfer state.
694 */
695 do {
696 status = wbsd_read_index(host, WBSD_IDX_STATUS);
697 } while (status & (WBSD_BLOCK_READ | WBSD_BLOCK_WRITE));
698
699 /*
700 * DMA transfer?
701 */
702 if (host->dma >= 0) {
703 /*
704 * Disable DMA on the host.
705 */
706 wbsd_write_index(host, WBSD_IDX_DMA, 0);
707
708 /*
709 * Turn of ISA DMA controller.
710 */
711 dmaflags = claim_dma_lock();
712 disable_dma(host->dma);
713 clear_dma_ff(host->dma);
714 count = get_dma_residue(host->dma);
715 release_dma_lock(dmaflags);
716
717 data->bytes_xfered = host->mrq->data->blocks *
718 host->mrq->data->blksz - count;
719 data->bytes_xfered -= data->bytes_xfered % data->blksz;
720
721 /*
722 * Any leftover data?
723 */
724 if (count) {
725 pr_err("%s: Incomplete DMA transfer. "
726 "%d bytes left.\n",
727 mmc_hostname(host->mmc), count);
728
729 if (!data->error)
730 data->error = -EIO;
731 } else {
732 /*
733 * Transfer data from DMA buffer to
734 * SG list.
735 */
736 if (data->flags & MMC_DATA_READ)
737 wbsd_dma_to_sg(host, data);
738 }
739
740 if (data->error) {
741 if (data->bytes_xfered)
742 data->bytes_xfered -= data->blksz;
743 }
744 }
745
746 wbsd_request_end(host, host->mrq);
747 }
748
749 /*****************************************************************************\
750 * *
751 * MMC layer callbacks *
752 * *
753 \*****************************************************************************/
754
755 static void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq)
756 {
757 struct wbsd_host *host = mmc_priv(mmc);
758 struct mmc_command *cmd;
759
760 /*
761 * Disable tasklets to avoid a deadlock.
762 */
763 spin_lock_bh(&host->lock);
764
765 BUG_ON(host->mrq != NULL);
766
767 cmd = mrq->cmd;
768
769 host->mrq = mrq;
770
771 /*
772 * Check that there is actually a card in the slot.
773 */
774 if (!(host->flags & WBSD_FCARD_PRESENT)) {
775 cmd->error = -ENOMEDIUM;
776 goto done;
777 }
778
779 if (cmd->data) {
780 /*
781 * The hardware is so delightfully stupid that it has a list
782 * of "data" commands. If a command isn't on this list, it'll
783 * just go back to the idle state and won't send any data
784 * interrupts.
785 */
786 switch (cmd->opcode) {
787 case 11:
788 case 17:
789 case 18:
790 case 20:
791 case 24:
792 case 25:
793 case 26:
794 case 27:
795 case 30:
796 case 42:
797 case 56:
798 break;
799
800 /* ACMDs. We don't keep track of state, so we just treat them
801 * like any other command. */
802 case 51:
803 break;
804
805 default:
806 #ifdef CONFIG_MMC_DEBUG
807 pr_warn("%s: Data command %d is not supported by this controller\n",
808 mmc_hostname(host->mmc), cmd->opcode);
809 #endif
810 cmd->error = -EINVAL;
811
812 goto done;
813 }
814 }
815
816 /*
817 * Does the request include data?
818 */
819 if (cmd->data) {
820 wbsd_prepare_data(host, cmd->data);
821
822 if (cmd->data->error)
823 goto done;
824 }
825
826 wbsd_send_command(host, cmd);
827
828 /*
829 * If this is a data transfer the request
830 * will be finished after the data has
831 * transferred.
832 */
833 if (cmd->data && !cmd->error) {
834 /*
835 * Dirty fix for hardware bug.
836 */
837 if (host->dma == -1)
838 tasklet_schedule(&host->fifo_tasklet);
839
840 spin_unlock_bh(&host->lock);
841
842 return;
843 }
844
845 done:
846 wbsd_request_end(host, mrq);
847
848 spin_unlock_bh(&host->lock);
849 }
850
851 static void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
852 {
853 struct wbsd_host *host = mmc_priv(mmc);
854 u8 clk, setup, pwr;
855
856 spin_lock_bh(&host->lock);
857
858 /*
859 * Reset the chip on each power off.
860 * Should clear out any weird states.
861 */
862 if (ios->power_mode == MMC_POWER_OFF)
863 wbsd_init_device(host);
864
865 if (ios->clock >= 24000000)
866 clk = WBSD_CLK_24M;
867 else if (ios->clock >= 16000000)
868 clk = WBSD_CLK_16M;
869 else if (ios->clock >= 12000000)
870 clk = WBSD_CLK_12M;
871 else
872 clk = WBSD_CLK_375K;
873
874 /*
875 * Only write to the clock register when
876 * there is an actual change.
877 */
878 if (clk != host->clk) {
879 wbsd_write_index(host, WBSD_IDX_CLK, clk);
880 host->clk = clk;
881 }
882
883 /*
884 * Power up card.
885 */
886 if (ios->power_mode != MMC_POWER_OFF) {
887 pwr = inb(host->base + WBSD_CSR);
888 pwr &= ~WBSD_POWER_N;
889 outb(pwr, host->base + WBSD_CSR);
890 }
891
892 /*
893 * MMC cards need to have pin 1 high during init.
894 * It wreaks havoc with the card detection though so
895 * that needs to be disabled.
896 */
897 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
898 if (ios->chip_select == MMC_CS_HIGH) {
899 BUG_ON(ios->bus_width != MMC_BUS_WIDTH_1);
900 setup |= WBSD_DAT3_H;
901 host->flags |= WBSD_FIGNORE_DETECT;
902 } else {
903 if (setup & WBSD_DAT3_H) {
904 setup &= ~WBSD_DAT3_H;
905
906 /*
907 * We cannot resume card detection immediately
908 * because of capacitance and delays in the chip.
909 */
910 mod_timer(&host->ignore_timer, jiffies + HZ / 100);
911 }
912 }
913 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
914
915 /*
916 * Store bus width for later. Will be used when
917 * setting up the data transfer.
918 */
919 host->bus_width = ios->bus_width;
920
921 spin_unlock_bh(&host->lock);
922 }
923
924 static int wbsd_get_ro(struct mmc_host *mmc)
925 {
926 struct wbsd_host *host = mmc_priv(mmc);
927 u8 csr;
928
929 spin_lock_bh(&host->lock);
930
931 csr = inb(host->base + WBSD_CSR);
932 csr |= WBSD_MSLED;
933 outb(csr, host->base + WBSD_CSR);
934
935 mdelay(1);
936
937 csr = inb(host->base + WBSD_CSR);
938 csr &= ~WBSD_MSLED;
939 outb(csr, host->base + WBSD_CSR);
940
941 spin_unlock_bh(&host->lock);
942
943 return !!(csr & WBSD_WRPT);
944 }
945
946 static const struct mmc_host_ops wbsd_ops = {
947 .request = wbsd_request,
948 .set_ios = wbsd_set_ios,
949 .get_ro = wbsd_get_ro,
950 };
951
952 /*****************************************************************************\
953 * *
954 * Interrupt handling *
955 * *
956 \*****************************************************************************/
957
958 /*
959 * Helper function to reset detection ignore
960 */
961
962 static void wbsd_reset_ignore(unsigned long data)
963 {
964 struct wbsd_host *host = (struct wbsd_host *)data;
965
966 BUG_ON(host == NULL);
967
968 DBG("Resetting card detection ignore\n");
969
970 spin_lock_bh(&host->lock);
971
972 host->flags &= ~WBSD_FIGNORE_DETECT;
973
974 /*
975 * Card status might have changed during the
976 * blackout.
977 */
978 tasklet_schedule(&host->card_tasklet);
979
980 spin_unlock_bh(&host->lock);
981 }
982
983 /*
984 * Tasklets
985 */
986
987 static inline struct mmc_data *wbsd_get_data(struct wbsd_host *host)
988 {
989 WARN_ON(!host->mrq);
990 if (!host->mrq)
991 return NULL;
992
993 WARN_ON(!host->mrq->cmd);
994 if (!host->mrq->cmd)
995 return NULL;
996
997 WARN_ON(!host->mrq->cmd->data);
998 if (!host->mrq->cmd->data)
999 return NULL;
1000
1001 return host->mrq->cmd->data;
1002 }
1003
1004 static void wbsd_tasklet_card(unsigned long param)
1005 {
1006 struct wbsd_host *host = (struct wbsd_host *)param;
1007 u8 csr;
1008 int delay = -1;
1009
1010 spin_lock(&host->lock);
1011
1012 if (host->flags & WBSD_FIGNORE_DETECT) {
1013 spin_unlock(&host->lock);
1014 return;
1015 }
1016
1017 csr = inb(host->base + WBSD_CSR);
1018 WARN_ON(csr == 0xff);
1019
1020 if (csr & WBSD_CARDPRESENT) {
1021 if (!(host->flags & WBSD_FCARD_PRESENT)) {
1022 DBG("Card inserted\n");
1023 host->flags |= WBSD_FCARD_PRESENT;
1024
1025 delay = 500;
1026 }
1027 } else if (host->flags & WBSD_FCARD_PRESENT) {
1028 DBG("Card removed\n");
1029 host->flags &= ~WBSD_FCARD_PRESENT;
1030
1031 if (host->mrq) {
1032 pr_err("%s: Card removed during transfer!\n",
1033 mmc_hostname(host->mmc));
1034 wbsd_reset(host);
1035
1036 host->mrq->cmd->error = -ENOMEDIUM;
1037 tasklet_schedule(&host->finish_tasklet);
1038 }
1039
1040 delay = 0;
1041 }
1042
1043 /*
1044 * Unlock first since we might get a call back.
1045 */
1046
1047 spin_unlock(&host->lock);
1048
1049 if (delay != -1)
1050 mmc_detect_change(host->mmc, msecs_to_jiffies(delay));
1051 }
1052
1053 static void wbsd_tasklet_fifo(unsigned long param)
1054 {
1055 struct wbsd_host *host = (struct wbsd_host *)param;
1056 struct mmc_data *data;
1057
1058 spin_lock(&host->lock);
1059
1060 if (!host->mrq)
1061 goto end;
1062
1063 data = wbsd_get_data(host);
1064 if (!data)
1065 goto end;
1066
1067 if (data->flags & MMC_DATA_WRITE)
1068 wbsd_fill_fifo(host);
1069 else
1070 wbsd_empty_fifo(host);
1071
1072 /*
1073 * Done?
1074 */
1075 if (host->num_sg == 0) {
1076 wbsd_write_index(host, WBSD_IDX_FIFOEN, 0);
1077 tasklet_schedule(&host->finish_tasklet);
1078 }
1079
1080 end:
1081 spin_unlock(&host->lock);
1082 }
1083
1084 static void wbsd_tasklet_crc(unsigned long param)
1085 {
1086 struct wbsd_host *host = (struct wbsd_host *)param;
1087 struct mmc_data *data;
1088
1089 spin_lock(&host->lock);
1090
1091 if (!host->mrq)
1092 goto end;
1093
1094 data = wbsd_get_data(host);
1095 if (!data)
1096 goto end;
1097
1098 DBGF("CRC error\n");
1099
1100 data->error = -EILSEQ;
1101
1102 tasklet_schedule(&host->finish_tasklet);
1103
1104 end:
1105 spin_unlock(&host->lock);
1106 }
1107
1108 static void wbsd_tasklet_timeout(unsigned long param)
1109 {
1110 struct wbsd_host *host = (struct wbsd_host *)param;
1111 struct mmc_data *data;
1112
1113 spin_lock(&host->lock);
1114
1115 if (!host->mrq)
1116 goto end;
1117
1118 data = wbsd_get_data(host);
1119 if (!data)
1120 goto end;
1121
1122 DBGF("Timeout\n");
1123
1124 data->error = -ETIMEDOUT;
1125
1126 tasklet_schedule(&host->finish_tasklet);
1127
1128 end:
1129 spin_unlock(&host->lock);
1130 }
1131
1132 static void wbsd_tasklet_finish(unsigned long param)
1133 {
1134 struct wbsd_host *host = (struct wbsd_host *)param;
1135 struct mmc_data *data;
1136
1137 spin_lock(&host->lock);
1138
1139 WARN_ON(!host->mrq);
1140 if (!host->mrq)
1141 goto end;
1142
1143 data = wbsd_get_data(host);
1144 if (!data)
1145 goto end;
1146
1147 wbsd_finish_data(host, data);
1148
1149 end:
1150 spin_unlock(&host->lock);
1151 }
1152
1153 /*
1154 * Interrupt handling
1155 */
1156
1157 static irqreturn_t wbsd_irq(int irq, void *dev_id)
1158 {
1159 struct wbsd_host *host = dev_id;
1160 int isr;
1161
1162 isr = inb(host->base + WBSD_ISR);
1163
1164 /*
1165 * Was it actually our hardware that caused the interrupt?
1166 */
1167 if (isr == 0xff || isr == 0x00)
1168 return IRQ_NONE;
1169
1170 host->isr |= isr;
1171
1172 /*
1173 * Schedule tasklets as needed.
1174 */
1175 if (isr & WBSD_INT_CARD)
1176 tasklet_schedule(&host->card_tasklet);
1177 if (isr & WBSD_INT_FIFO_THRE)
1178 tasklet_schedule(&host->fifo_tasklet);
1179 if (isr & WBSD_INT_CRC)
1180 tasklet_hi_schedule(&host->crc_tasklet);
1181 if (isr & WBSD_INT_TIMEOUT)
1182 tasklet_hi_schedule(&host->timeout_tasklet);
1183 if (isr & WBSD_INT_TC)
1184 tasklet_schedule(&host->finish_tasklet);
1185
1186 return IRQ_HANDLED;
1187 }
1188
1189 /*****************************************************************************\
1190 * *
1191 * Device initialisation and shutdown *
1192 * *
1193 \*****************************************************************************/
1194
1195 /*
1196 * Allocate/free MMC structure.
1197 */
1198
1199 static int wbsd_alloc_mmc(struct device *dev)
1200 {
1201 struct mmc_host *mmc;
1202 struct wbsd_host *host;
1203
1204 /*
1205 * Allocate MMC structure.
1206 */
1207 mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev);
1208 if (!mmc)
1209 return -ENOMEM;
1210
1211 host = mmc_priv(mmc);
1212 host->mmc = mmc;
1213
1214 host->dma = -1;
1215
1216 /*
1217 * Set host parameters.
1218 */
1219 mmc->ops = &wbsd_ops;
1220 mmc->f_min = 375000;
1221 mmc->f_max = 24000000;
1222 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
1223 mmc->caps = MMC_CAP_4_BIT_DATA;
1224
1225 spin_lock_init(&host->lock);
1226
1227 /*
1228 * Set up timers
1229 */
1230 init_timer(&host->ignore_timer);
1231 host->ignore_timer.data = (unsigned long)host;
1232 host->ignore_timer.function = wbsd_reset_ignore;
1233
1234 /*
1235 * Maximum number of segments. Worst case is one sector per segment
1236 * so this will be 64kB/512.
1237 */
1238 mmc->max_segs = 128;
1239
1240 /*
1241 * Maximum request size. Also limited by 64KiB buffer.
1242 */
1243 mmc->max_req_size = 65536;
1244
1245 /*
1246 * Maximum segment size. Could be one segment with the maximum number
1247 * of bytes.
1248 */
1249 mmc->max_seg_size = mmc->max_req_size;
1250
1251 /*
1252 * Maximum block size. We have 12 bits (= 4095) but have to subtract
1253 * space for CRC. So the maximum is 4095 - 4*2 = 4087.
1254 */
1255 mmc->max_blk_size = 4087;
1256
1257 /*
1258 * Maximum block count. There is no real limit so the maximum
1259 * request size will be the only restriction.
1260 */
1261 mmc->max_blk_count = mmc->max_req_size;
1262
1263 dev_set_drvdata(dev, mmc);
1264
1265 return 0;
1266 }
1267
1268 static void wbsd_free_mmc(struct device *dev)
1269 {
1270 struct mmc_host *mmc;
1271 struct wbsd_host *host;
1272
1273 mmc = dev_get_drvdata(dev);
1274 if (!mmc)
1275 return;
1276
1277 host = mmc_priv(mmc);
1278 BUG_ON(host == NULL);
1279
1280 del_timer_sync(&host->ignore_timer);
1281
1282 mmc_free_host(mmc);
1283
1284 dev_set_drvdata(dev, NULL);
1285 }
1286
1287 /*
1288 * Scan for known chip id:s
1289 */
1290
1291 static int wbsd_scan(struct wbsd_host *host)
1292 {
1293 int i, j, k;
1294 int id;
1295
1296 /*
1297 * Iterate through all ports, all codes to
1298 * find hardware that is in our known list.
1299 */
1300 for (i = 0; i < ARRAY_SIZE(config_ports); i++) {
1301 if (!request_region(config_ports[i], 2, DRIVER_NAME))
1302 continue;
1303
1304 for (j = 0; j < ARRAY_SIZE(unlock_codes); j++) {
1305 id = 0xFFFF;
1306
1307 host->config = config_ports[i];
1308 host->unlock_code = unlock_codes[j];
1309
1310 wbsd_unlock_config(host);
1311
1312 outb(WBSD_CONF_ID_HI, config_ports[i]);
1313 id = inb(config_ports[i] + 1) << 8;
1314
1315 outb(WBSD_CONF_ID_LO, config_ports[i]);
1316 id |= inb(config_ports[i] + 1);
1317
1318 wbsd_lock_config(host);
1319
1320 for (k = 0; k < ARRAY_SIZE(valid_ids); k++) {
1321 if (id == valid_ids[k]) {
1322 host->chip_id = id;
1323
1324 return 0;
1325 }
1326 }
1327
1328 if (id != 0xFFFF) {
1329 DBG("Unknown hardware (id %x) found at %x\n",
1330 id, config_ports[i]);
1331 }
1332 }
1333
1334 release_region(config_ports[i], 2);
1335 }
1336
1337 host->config = 0;
1338 host->unlock_code = 0;
1339
1340 return -ENODEV;
1341 }
1342
1343 /*
1344 * Allocate/free io port ranges
1345 */
1346
1347 static int wbsd_request_region(struct wbsd_host *host, int base)
1348 {
1349 if (base & 0x7)
1350 return -EINVAL;
1351
1352 if (!request_region(base, 8, DRIVER_NAME))
1353 return -EIO;
1354
1355 host->base = base;
1356
1357 return 0;
1358 }
1359
1360 static void wbsd_release_regions(struct wbsd_host *host)
1361 {
1362 if (host->base)
1363 release_region(host->base, 8);
1364
1365 host->base = 0;
1366
1367 if (host->config)
1368 release_region(host->config, 2);
1369
1370 host->config = 0;
1371 }
1372
1373 /*
1374 * Allocate/free DMA port and buffer
1375 */
1376
1377 static void wbsd_request_dma(struct wbsd_host *host, int dma)
1378 {
1379 if (dma < 0)
1380 return;
1381
1382 if (request_dma(dma, DRIVER_NAME))
1383 goto err;
1384
1385 /*
1386 * We need to allocate a special buffer in
1387 * order for ISA to be able to DMA to it.
1388 */
1389 host->dma_buffer = kmalloc(WBSD_DMA_SIZE,
1390 GFP_NOIO | GFP_DMA | __GFP_REPEAT | __GFP_NOWARN);
1391 if (!host->dma_buffer)
1392 goto free;
1393
1394 /*
1395 * Translate the address to a physical address.
1396 */
1397 host->dma_addr = dma_map_single(mmc_dev(host->mmc), host->dma_buffer,
1398 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1399 if (dma_mapping_error(mmc_dev(host->mmc), host->dma_addr))
1400 goto kfree;
1401
1402 /*
1403 * ISA DMA must be aligned on a 64k basis.
1404 */
1405 if ((host->dma_addr & 0xffff) != 0)
1406 goto unmap;
1407 /*
1408 * ISA cannot access memory above 16 MB.
1409 */
1410 else if (host->dma_addr >= 0x1000000)
1411 goto unmap;
1412
1413 host->dma = dma;
1414
1415 return;
1416
1417 unmap:
1418 /*
1419 * If we've gotten here then there is some kind of alignment bug
1420 */
1421 BUG_ON(1);
1422
1423 dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
1424 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1425 host->dma_addr = 0;
1426
1427 kfree:
1428 kfree(host->dma_buffer);
1429 host->dma_buffer = NULL;
1430
1431 free:
1432 free_dma(dma);
1433
1434 err:
1435 pr_warn(DRIVER_NAME ": Unable to allocate DMA %d - falling back on FIFO\n",
1436 dma);
1437 }
1438
1439 static void wbsd_release_dma(struct wbsd_host *host)
1440 {
1441 if (!dma_mapping_error(mmc_dev(host->mmc), host->dma_addr)) {
1442 dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
1443 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1444 }
1445 kfree(host->dma_buffer);
1446 if (host->dma >= 0)
1447 free_dma(host->dma);
1448
1449 host->dma = -1;
1450 host->dma_buffer = NULL;
1451 host->dma_addr = 0;
1452 }
1453
1454 /*
1455 * Allocate/free IRQ.
1456 */
1457
1458 static int wbsd_request_irq(struct wbsd_host *host, int irq)
1459 {
1460 int ret;
1461
1462 /*
1463 * Set up tasklets. Must be done before requesting interrupt.
1464 */
1465 tasklet_init(&host->card_tasklet, wbsd_tasklet_card,
1466 (unsigned long)host);
1467 tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo,
1468 (unsigned long)host);
1469 tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc,
1470 (unsigned long)host);
1471 tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout,
1472 (unsigned long)host);
1473 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish,
1474 (unsigned long)host);
1475
1476 /*
1477 * Allocate interrupt.
1478 */
1479 ret = request_irq(irq, wbsd_irq, IRQF_SHARED, DRIVER_NAME, host);
1480 if (ret)
1481 return ret;
1482
1483 host->irq = irq;
1484
1485 return 0;
1486 }
1487
1488 static void wbsd_release_irq(struct wbsd_host *host)
1489 {
1490 if (!host->irq)
1491 return;
1492
1493 free_irq(host->irq, host);
1494
1495 host->irq = 0;
1496
1497 tasklet_kill(&host->card_tasklet);
1498 tasklet_kill(&host->fifo_tasklet);
1499 tasklet_kill(&host->crc_tasklet);
1500 tasklet_kill(&host->timeout_tasklet);
1501 tasklet_kill(&host->finish_tasklet);
1502 }
1503
1504 /*
1505 * Allocate all resources for the host.
1506 */
1507
1508 static int wbsd_request_resources(struct wbsd_host *host,
1509 int base, int irq, int dma)
1510 {
1511 int ret;
1512
1513 /*
1514 * Allocate I/O ports.
1515 */
1516 ret = wbsd_request_region(host, base);
1517 if (ret)
1518 return ret;
1519
1520 /*
1521 * Allocate interrupt.
1522 */
1523 ret = wbsd_request_irq(host, irq);
1524 if (ret)
1525 return ret;
1526
1527 /*
1528 * Allocate DMA.
1529 */
1530 wbsd_request_dma(host, dma);
1531
1532 return 0;
1533 }
1534
1535 /*
1536 * Release all resources for the host.
1537 */
1538
1539 static void wbsd_release_resources(struct wbsd_host *host)
1540 {
1541 wbsd_release_dma(host);
1542 wbsd_release_irq(host);
1543 wbsd_release_regions(host);
1544 }
1545
1546 /*
1547 * Configure the resources the chip should use.
1548 */
1549
1550 static void wbsd_chip_config(struct wbsd_host *host)
1551 {
1552 wbsd_unlock_config(host);
1553
1554 /*
1555 * Reset the chip.
1556 */
1557 wbsd_write_config(host, WBSD_CONF_SWRST, 1);
1558 wbsd_write_config(host, WBSD_CONF_SWRST, 0);
1559
1560 /*
1561 * Select SD/MMC function.
1562 */
1563 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1564
1565 /*
1566 * Set up card detection.
1567 */
1568 wbsd_write_config(host, WBSD_CONF_PINS, WBSD_PINS_DETECT_GP11);
1569
1570 /*
1571 * Configure chip
1572 */
1573 wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8);
1574 wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff);
1575
1576 wbsd_write_config(host, WBSD_CONF_IRQ, host->irq);
1577
1578 if (host->dma >= 0)
1579 wbsd_write_config(host, WBSD_CONF_DRQ, host->dma);
1580
1581 /*
1582 * Enable and power up chip.
1583 */
1584 wbsd_write_config(host, WBSD_CONF_ENABLE, 1);
1585 wbsd_write_config(host, WBSD_CONF_POWER, 0x20);
1586
1587 wbsd_lock_config(host);
1588 }
1589
1590 /*
1591 * Check that configured resources are correct.
1592 */
1593
1594 static int wbsd_chip_validate(struct wbsd_host *host)
1595 {
1596 int base, irq, dma;
1597
1598 wbsd_unlock_config(host);
1599
1600 /*
1601 * Select SD/MMC function.
1602 */
1603 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1604
1605 /*
1606 * Read configuration.
1607 */
1608 base = wbsd_read_config(host, WBSD_CONF_PORT_HI) << 8;
1609 base |= wbsd_read_config(host, WBSD_CONF_PORT_LO);
1610
1611 irq = wbsd_read_config(host, WBSD_CONF_IRQ);
1612
1613 dma = wbsd_read_config(host, WBSD_CONF_DRQ);
1614
1615 wbsd_lock_config(host);
1616
1617 /*
1618 * Validate against given configuration.
1619 */
1620 if (base != host->base)
1621 return 0;
1622 if (irq != host->irq)
1623 return 0;
1624 if ((dma != host->dma) && (host->dma != -1))
1625 return 0;
1626
1627 return 1;
1628 }
1629
1630 /*
1631 * Powers down the SD function
1632 */
1633
1634 static void wbsd_chip_poweroff(struct wbsd_host *host)
1635 {
1636 wbsd_unlock_config(host);
1637
1638 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1639 wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
1640
1641 wbsd_lock_config(host);
1642 }
1643
1644 /*****************************************************************************\
1645 * *
1646 * Devices setup and shutdown *
1647 * *
1648 \*****************************************************************************/
1649
1650 static int wbsd_init(struct device *dev, int base, int irq, int dma,
1651 int pnp)
1652 {
1653 struct wbsd_host *host = NULL;
1654 struct mmc_host *mmc = NULL;
1655 int ret;
1656
1657 ret = wbsd_alloc_mmc(dev);
1658 if (ret)
1659 return ret;
1660
1661 mmc = dev_get_drvdata(dev);
1662 host = mmc_priv(mmc);
1663
1664 /*
1665 * Scan for hardware.
1666 */
1667 ret = wbsd_scan(host);
1668 if (ret) {
1669 if (pnp && (ret == -ENODEV)) {
1670 pr_warn(DRIVER_NAME ": Unable to confirm device presence - you may experience lock-ups\n");
1671 } else {
1672 wbsd_free_mmc(dev);
1673 return ret;
1674 }
1675 }
1676
1677 /*
1678 * Request resources.
1679 */
1680 ret = wbsd_request_resources(host, base, irq, dma);
1681 if (ret) {
1682 wbsd_release_resources(host);
1683 wbsd_free_mmc(dev);
1684 return ret;
1685 }
1686
1687 /*
1688 * See if chip needs to be configured.
1689 */
1690 if (pnp) {
1691 if ((host->config != 0) && !wbsd_chip_validate(host)) {
1692 pr_warn(DRIVER_NAME ": PnP active but chip not configured! You probably have a buggy BIOS. Configuring chip manually.\n");
1693 wbsd_chip_config(host);
1694 }
1695 } else
1696 wbsd_chip_config(host);
1697
1698 /*
1699 * Power Management stuff. No idea how this works.
1700 * Not tested.
1701 */
1702 #ifdef CONFIG_PM
1703 if (host->config) {
1704 wbsd_unlock_config(host);
1705 wbsd_write_config(host, WBSD_CONF_PME, 0xA0);
1706 wbsd_lock_config(host);
1707 }
1708 #endif
1709 /*
1710 * Allow device to initialise itself properly.
1711 */
1712 mdelay(5);
1713
1714 /*
1715 * Reset the chip into a known state.
1716 */
1717 wbsd_init_device(host);
1718
1719 mmc_add_host(mmc);
1720
1721 pr_info("%s: W83L51xD", mmc_hostname(mmc));
1722 if (host->chip_id != 0)
1723 printk(" id %x", (int)host->chip_id);
1724 printk(" at 0x%x irq %d", (int)host->base, (int)host->irq);
1725 if (host->dma >= 0)
1726 printk(" dma %d", (int)host->dma);
1727 else
1728 printk(" FIFO");
1729 if (pnp)
1730 printk(" PnP");
1731 printk("\n");
1732
1733 return 0;
1734 }
1735
1736 static void wbsd_shutdown(struct device *dev, int pnp)
1737 {
1738 struct mmc_host *mmc = dev_get_drvdata(dev);
1739 struct wbsd_host *host;
1740
1741 if (!mmc)
1742 return;
1743
1744 host = mmc_priv(mmc);
1745
1746 mmc_remove_host(mmc);
1747
1748 /*
1749 * Power down the SD/MMC function.
1750 */
1751 if (!pnp)
1752 wbsd_chip_poweroff(host);
1753
1754 wbsd_release_resources(host);
1755
1756 wbsd_free_mmc(dev);
1757 }
1758
1759 /*
1760 * Non-PnP
1761 */
1762
1763 static int wbsd_probe(struct platform_device *dev)
1764 {
1765 /* Use the module parameters for resources */
1766 return wbsd_init(&dev->dev, param_io, param_irq, param_dma, 0);
1767 }
1768
1769 static int wbsd_remove(struct platform_device *dev)
1770 {
1771 wbsd_shutdown(&dev->dev, 0);
1772
1773 return 0;
1774 }
1775
1776 /*
1777 * PnP
1778 */
1779
1780 #ifdef CONFIG_PNP
1781
1782 static int
1783 wbsd_pnp_probe(struct pnp_dev *pnpdev, const struct pnp_device_id *dev_id)
1784 {
1785 int io, irq, dma;
1786
1787 /*
1788 * Get resources from PnP layer.
1789 */
1790 io = pnp_port_start(pnpdev, 0);
1791 irq = pnp_irq(pnpdev, 0);
1792 if (pnp_dma_valid(pnpdev, 0))
1793 dma = pnp_dma(pnpdev, 0);
1794 else
1795 dma = -1;
1796
1797 DBGF("PnP resources: port %3x irq %d dma %d\n", io, irq, dma);
1798
1799 return wbsd_init(&pnpdev->dev, io, irq, dma, 1);
1800 }
1801
1802 static void wbsd_pnp_remove(struct pnp_dev *dev)
1803 {
1804 wbsd_shutdown(&dev->dev, 1);
1805 }
1806
1807 #endif /* CONFIG_PNP */
1808
1809 /*
1810 * Power management
1811 */
1812
1813 #ifdef CONFIG_PM
1814
1815 static int wbsd_platform_suspend(struct platform_device *dev,
1816 pm_message_t state)
1817 {
1818 struct mmc_host *mmc = platform_get_drvdata(dev);
1819 struct wbsd_host *host;
1820
1821 if (mmc == NULL)
1822 return 0;
1823
1824 DBGF("Suspending...\n");
1825
1826 host = mmc_priv(mmc);
1827
1828 wbsd_chip_poweroff(host);
1829 return 0;
1830 }
1831
1832 static int wbsd_platform_resume(struct platform_device *dev)
1833 {
1834 struct mmc_host *mmc = platform_get_drvdata(dev);
1835 struct wbsd_host *host;
1836
1837 if (mmc == NULL)
1838 return 0;
1839
1840 DBGF("Resuming...\n");
1841
1842 host = mmc_priv(mmc);
1843
1844 wbsd_chip_config(host);
1845
1846 /*
1847 * Allow device to initialise itself properly.
1848 */
1849 mdelay(5);
1850
1851 wbsd_init_device(host);
1852 return 0;
1853 }
1854
1855 #ifdef CONFIG_PNP
1856
1857 static int wbsd_pnp_suspend(struct pnp_dev *pnp_dev, pm_message_t state)
1858 {
1859 struct mmc_host *mmc = dev_get_drvdata(&pnp_dev->dev);
1860
1861 if (mmc == NULL)
1862 return 0;
1863
1864 DBGF("Suspending...\n");
1865 return 0;
1866 }
1867
1868 static int wbsd_pnp_resume(struct pnp_dev *pnp_dev)
1869 {
1870 struct mmc_host *mmc = dev_get_drvdata(&pnp_dev->dev);
1871 struct wbsd_host *host;
1872
1873 if (mmc == NULL)
1874 return 0;
1875
1876 DBGF("Resuming...\n");
1877
1878 host = mmc_priv(mmc);
1879
1880 /*
1881 * See if chip needs to be configured.
1882 */
1883 if (host->config != 0) {
1884 if (!wbsd_chip_validate(host)) {
1885 pr_warn(DRIVER_NAME ": PnP active but chip not configured! You probably have a buggy BIOS. Configuring chip manually.\n");
1886 wbsd_chip_config(host);
1887 }
1888 }
1889
1890 /*
1891 * Allow device to initialise itself properly.
1892 */
1893 mdelay(5);
1894
1895 wbsd_init_device(host);
1896 return 0;
1897 }
1898
1899 #endif /* CONFIG_PNP */
1900
1901 #else /* CONFIG_PM */
1902
1903 #define wbsd_platform_suspend NULL
1904 #define wbsd_platform_resume NULL
1905
1906 #define wbsd_pnp_suspend NULL
1907 #define wbsd_pnp_resume NULL
1908
1909 #endif /* CONFIG_PM */
1910
1911 static struct platform_device *wbsd_device;
1912
1913 static struct platform_driver wbsd_driver = {
1914 .probe = wbsd_probe,
1915 .remove = wbsd_remove,
1916
1917 .suspend = wbsd_platform_suspend,
1918 .resume = wbsd_platform_resume,
1919 .driver = {
1920 .name = DRIVER_NAME,
1921 },
1922 };
1923
1924 #ifdef CONFIG_PNP
1925
1926 static struct pnp_driver wbsd_pnp_driver = {
1927 .name = DRIVER_NAME,
1928 .id_table = pnp_dev_table,
1929 .probe = wbsd_pnp_probe,
1930 .remove = wbsd_pnp_remove,
1931
1932 .suspend = wbsd_pnp_suspend,
1933 .resume = wbsd_pnp_resume,
1934 };
1935
1936 #endif /* CONFIG_PNP */
1937
1938 /*
1939 * Module loading/unloading
1940 */
1941
1942 static int __init wbsd_drv_init(void)
1943 {
1944 int result;
1945
1946 pr_info(DRIVER_NAME
1947 ": Winbond W83L51xD SD/MMC card interface driver\n");
1948 pr_info(DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
1949
1950 #ifdef CONFIG_PNP
1951
1952 if (!param_nopnp) {
1953 result = pnp_register_driver(&wbsd_pnp_driver);
1954 if (result < 0)
1955 return result;
1956 }
1957 #endif /* CONFIG_PNP */
1958
1959 if (param_nopnp) {
1960 result = platform_driver_register(&wbsd_driver);
1961 if (result < 0)
1962 return result;
1963
1964 wbsd_device = platform_device_alloc(DRIVER_NAME, -1);
1965 if (!wbsd_device) {
1966 platform_driver_unregister(&wbsd_driver);
1967 return -ENOMEM;
1968 }
1969
1970 result = platform_device_add(wbsd_device);
1971 if (result) {
1972 platform_device_put(wbsd_device);
1973 platform_driver_unregister(&wbsd_driver);
1974 return result;
1975 }
1976 }
1977
1978 return 0;
1979 }
1980
1981 static void __exit wbsd_drv_exit(void)
1982 {
1983 #ifdef CONFIG_PNP
1984
1985 if (!param_nopnp)
1986 pnp_unregister_driver(&wbsd_pnp_driver);
1987
1988 #endif /* CONFIG_PNP */
1989
1990 if (param_nopnp) {
1991 platform_device_unregister(wbsd_device);
1992
1993 platform_driver_unregister(&wbsd_driver);
1994 }
1995
1996 DBG("unloaded\n");
1997 }
1998
1999 module_init(wbsd_drv_init);
2000 module_exit(wbsd_drv_exit);
2001 #ifdef CONFIG_PNP
2002 module_param_named(nopnp, param_nopnp, uint, 0444);
2003 #endif
2004 module_param_named(io, param_io, uint, 0444);
2005 module_param_named(irq, param_irq, uint, 0444);
2006 module_param_named(dma, param_dma, int, 0444);
2007
2008 MODULE_LICENSE("GPL");
2009 MODULE_AUTHOR("Pierre Ossman <pierre@ossman.eu>");
2010 MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver");
2011
2012 #ifdef CONFIG_PNP
2013 MODULE_PARM_DESC(nopnp, "Scan for device instead of relying on PNP. (default 0)");
2014 #endif
2015 MODULE_PARM_DESC(io, "I/O base to allocate. Must be 8 byte aligned. (default 0x248)");
2016 MODULE_PARM_DESC(irq, "IRQ to allocate. (default 6)");
2017 MODULE_PARM_DESC(dma, "DMA channel to allocate. -1 for no DMA. (default 2)");
2018
2019
2020
2021
2022
2023 /* LDV_COMMENT_BEGIN_MAIN */
2024 #ifdef LDV_MAIN0_sequence_infinite_withcheck_stateful
2025
2026 /*###########################################################################*/
2027
2028 /*############## Driver Environment Generator 0.2 output ####################*/
2029
2030 /*###########################################################################*/
2031
2032
2033
2034 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test if all kernel resources are correctly released by driver before driver will be unloaded. */
2035 void ldv_check_final_state(void);
2036
2037 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */
2038 void ldv_check_return_value(int res);
2039
2040 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */
2041 void ldv_check_return_value_probe(int res);
2042
2043 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */
2044 void ldv_initialize(void);
2045
2046 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */
2047 void ldv_handler_precall(void);
2048
2049 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */
2050 int nondet_int(void);
2051
2052 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */
2053 int LDV_IN_INTERRUPT;
2054
2055 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */
2056 void ldv_main0_sequence_infinite_withcheck_stateful(void) {
2057
2058
2059
2060 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */
2061 /*============================= VARIABLE DECLARATION PART =============================*/
2062 /** STRUCT: struct type: mmc_host_ops, struct name: wbsd_ops **/
2063 /* content: static void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq)*/
2064 /* LDV_COMMENT_BEGIN_PREP */
2065 #define DRIVER_NAME "wbsd"
2066 #define DBG(x...) \
2067 pr_debug(DRIVER_NAME ": " x)
2068 #define DBGF(f, x...) \
2069 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2070 #ifdef CONFIG_PNP
2071 #endif
2072 #ifdef CONFIG_PNP
2073 #else
2074 #endif
2075 /* LDV_COMMENT_END_PREP */
2076 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_request" */
2077 struct mmc_host * var_group1;
2078 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_request" */
2079 struct mmc_request * var_group2;
2080 /* LDV_COMMENT_BEGIN_PREP */
2081 #ifdef CONFIG_PM
2082 #endif
2083 #ifdef CONFIG_PNP
2084 #endif
2085 #ifdef CONFIG_PM
2086 #ifdef CONFIG_PNP
2087 #endif
2088 #else
2089 #define wbsd_platform_suspend NULL
2090 #define wbsd_platform_resume NULL
2091 #define wbsd_pnp_suspend NULL
2092 #define wbsd_pnp_resume NULL
2093 #endif
2094 #ifdef CONFIG_PNP
2095 #endif
2096 #ifdef CONFIG_PNP
2097 #endif
2098 #ifdef CONFIG_PNP
2099 #endif
2100 #ifdef CONFIG_PNP
2101 #endif
2102 #ifdef CONFIG_PNP
2103 #endif
2104 /* LDV_COMMENT_END_PREP */
2105 /* content: static void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)*/
2106 /* LDV_COMMENT_BEGIN_PREP */
2107 #define DRIVER_NAME "wbsd"
2108 #define DBG(x...) \
2109 pr_debug(DRIVER_NAME ": " x)
2110 #define DBGF(f, x...) \
2111 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2112 #ifdef CONFIG_PNP
2113 #endif
2114 #ifdef CONFIG_PNP
2115 #else
2116 #endif
2117 #ifdef CONFIG_MMC_DEBUG
2118 #endif
2119 /* LDV_COMMENT_END_PREP */
2120 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_set_ios" */
2121 struct mmc_ios * var_group3;
2122 /* LDV_COMMENT_BEGIN_PREP */
2123 #ifdef CONFIG_PM
2124 #endif
2125 #ifdef CONFIG_PNP
2126 #endif
2127 #ifdef CONFIG_PM
2128 #ifdef CONFIG_PNP
2129 #endif
2130 #else
2131 #define wbsd_platform_suspend NULL
2132 #define wbsd_platform_resume NULL
2133 #define wbsd_pnp_suspend NULL
2134 #define wbsd_pnp_resume NULL
2135 #endif
2136 #ifdef CONFIG_PNP
2137 #endif
2138 #ifdef CONFIG_PNP
2139 #endif
2140 #ifdef CONFIG_PNP
2141 #endif
2142 #ifdef CONFIG_PNP
2143 #endif
2144 #ifdef CONFIG_PNP
2145 #endif
2146 /* LDV_COMMENT_END_PREP */
2147 /* content: static int wbsd_get_ro(struct mmc_host *mmc)*/
2148 /* LDV_COMMENT_BEGIN_PREP */
2149 #define DRIVER_NAME "wbsd"
2150 #define DBG(x...) \
2151 pr_debug(DRIVER_NAME ": " x)
2152 #define DBGF(f, x...) \
2153 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2154 #ifdef CONFIG_PNP
2155 #endif
2156 #ifdef CONFIG_PNP
2157 #else
2158 #endif
2159 #ifdef CONFIG_MMC_DEBUG
2160 #endif
2161 /* LDV_COMMENT_END_PREP */
2162 /* LDV_COMMENT_BEGIN_PREP */
2163 #ifdef CONFIG_PM
2164 #endif
2165 #ifdef CONFIG_PNP
2166 #endif
2167 #ifdef CONFIG_PM
2168 #ifdef CONFIG_PNP
2169 #endif
2170 #else
2171 #define wbsd_platform_suspend NULL
2172 #define wbsd_platform_resume NULL
2173 #define wbsd_pnp_suspend NULL
2174 #define wbsd_pnp_resume NULL
2175 #endif
2176 #ifdef CONFIG_PNP
2177 #endif
2178 #ifdef CONFIG_PNP
2179 #endif
2180 #ifdef CONFIG_PNP
2181 #endif
2182 #ifdef CONFIG_PNP
2183 #endif
2184 #ifdef CONFIG_PNP
2185 #endif
2186 /* LDV_COMMENT_END_PREP */
2187
2188 /** STRUCT: struct type: platform_driver, struct name: wbsd_driver **/
2189 /* content: static int wbsd_probe(struct platform_device *dev)*/
2190 /* LDV_COMMENT_BEGIN_PREP */
2191 #define DRIVER_NAME "wbsd"
2192 #define DBG(x...) \
2193 pr_debug(DRIVER_NAME ": " x)
2194 #define DBGF(f, x...) \
2195 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2196 #ifdef CONFIG_PNP
2197 #endif
2198 #ifdef CONFIG_PNP
2199 #else
2200 #endif
2201 #ifdef CONFIG_MMC_DEBUG
2202 #endif
2203 #ifdef CONFIG_PM
2204 #endif
2205 /* LDV_COMMENT_END_PREP */
2206 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_probe" */
2207 struct platform_device * var_group4;
2208 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "wbsd_probe" */
2209 static int res_wbsd_probe_48;
2210 /* LDV_COMMENT_BEGIN_PREP */
2211 #ifdef CONFIG_PNP
2212 #endif
2213 #ifdef CONFIG_PM
2214 #ifdef CONFIG_PNP
2215 #endif
2216 #else
2217 #define wbsd_platform_suspend NULL
2218 #define wbsd_platform_resume NULL
2219 #define wbsd_pnp_suspend NULL
2220 #define wbsd_pnp_resume NULL
2221 #endif
2222 #ifdef CONFIG_PNP
2223 #endif
2224 #ifdef CONFIG_PNP
2225 #endif
2226 #ifdef CONFIG_PNP
2227 #endif
2228 #ifdef CONFIG_PNP
2229 #endif
2230 #ifdef CONFIG_PNP
2231 #endif
2232 /* LDV_COMMENT_END_PREP */
2233 /* content: static int wbsd_remove(struct platform_device *dev)*/
2234 /* LDV_COMMENT_BEGIN_PREP */
2235 #define DRIVER_NAME "wbsd"
2236 #define DBG(x...) \
2237 pr_debug(DRIVER_NAME ": " x)
2238 #define DBGF(f, x...) \
2239 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2240 #ifdef CONFIG_PNP
2241 #endif
2242 #ifdef CONFIG_PNP
2243 #else
2244 #endif
2245 #ifdef CONFIG_MMC_DEBUG
2246 #endif
2247 #ifdef CONFIG_PM
2248 #endif
2249 /* LDV_COMMENT_END_PREP */
2250 /* LDV_COMMENT_BEGIN_PREP */
2251 #ifdef CONFIG_PNP
2252 #endif
2253 #ifdef CONFIG_PM
2254 #ifdef CONFIG_PNP
2255 #endif
2256 #else
2257 #define wbsd_platform_suspend NULL
2258 #define wbsd_platform_resume NULL
2259 #define wbsd_pnp_suspend NULL
2260 #define wbsd_pnp_resume NULL
2261 #endif
2262 #ifdef CONFIG_PNP
2263 #endif
2264 #ifdef CONFIG_PNP
2265 #endif
2266 #ifdef CONFIG_PNP
2267 #endif
2268 #ifdef CONFIG_PNP
2269 #endif
2270 #ifdef CONFIG_PNP
2271 #endif
2272 /* LDV_COMMENT_END_PREP */
2273 /* content: static int wbsd_platform_suspend(struct platform_device *dev, pm_message_t state)*/
2274 /* LDV_COMMENT_BEGIN_PREP */
2275 #define DRIVER_NAME "wbsd"
2276 #define DBG(x...) \
2277 pr_debug(DRIVER_NAME ": " x)
2278 #define DBGF(f, x...) \
2279 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2280 #ifdef CONFIG_PNP
2281 #endif
2282 #ifdef CONFIG_PNP
2283 #else
2284 #endif
2285 #ifdef CONFIG_MMC_DEBUG
2286 #endif
2287 #ifdef CONFIG_PM
2288 #endif
2289 #ifdef CONFIG_PNP
2290 #endif
2291 #ifdef CONFIG_PM
2292 /* LDV_COMMENT_END_PREP */
2293 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_platform_suspend" */
2294 pm_message_t var_wbsd_platform_suspend_52_p1;
2295 /* LDV_COMMENT_BEGIN_PREP */
2296 #ifdef CONFIG_PNP
2297 #endif
2298 #else
2299 #define wbsd_platform_suspend NULL
2300 #define wbsd_platform_resume NULL
2301 #define wbsd_pnp_suspend NULL
2302 #define wbsd_pnp_resume NULL
2303 #endif
2304 #ifdef CONFIG_PNP
2305 #endif
2306 #ifdef CONFIG_PNP
2307 #endif
2308 #ifdef CONFIG_PNP
2309 #endif
2310 #ifdef CONFIG_PNP
2311 #endif
2312 #ifdef CONFIG_PNP
2313 #endif
2314 /* LDV_COMMENT_END_PREP */
2315 /* content: static int wbsd_platform_resume(struct platform_device *dev)*/
2316 /* LDV_COMMENT_BEGIN_PREP */
2317 #define DRIVER_NAME "wbsd"
2318 #define DBG(x...) \
2319 pr_debug(DRIVER_NAME ": " x)
2320 #define DBGF(f, x...) \
2321 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2322 #ifdef CONFIG_PNP
2323 #endif
2324 #ifdef CONFIG_PNP
2325 #else
2326 #endif
2327 #ifdef CONFIG_MMC_DEBUG
2328 #endif
2329 #ifdef CONFIG_PM
2330 #endif
2331 #ifdef CONFIG_PNP
2332 #endif
2333 #ifdef CONFIG_PM
2334 /* LDV_COMMENT_END_PREP */
2335 /* LDV_COMMENT_BEGIN_PREP */
2336 #ifdef CONFIG_PNP
2337 #endif
2338 #else
2339 #define wbsd_platform_suspend NULL
2340 #define wbsd_platform_resume NULL
2341 #define wbsd_pnp_suspend NULL
2342 #define wbsd_pnp_resume NULL
2343 #endif
2344 #ifdef CONFIG_PNP
2345 #endif
2346 #ifdef CONFIG_PNP
2347 #endif
2348 #ifdef CONFIG_PNP
2349 #endif
2350 #ifdef CONFIG_PNP
2351 #endif
2352 #ifdef CONFIG_PNP
2353 #endif
2354 /* LDV_COMMENT_END_PREP */
2355
2356 /** STRUCT: struct type: pnp_driver, struct name: wbsd_pnp_driver **/
2357 /* content: static int wbsd_pnp_probe(struct pnp_dev *pnpdev, const struct pnp_device_id *dev_id)*/
2358 /* LDV_COMMENT_BEGIN_PREP */
2359 #define DRIVER_NAME "wbsd"
2360 #define DBG(x...) \
2361 pr_debug(DRIVER_NAME ": " x)
2362 #define DBGF(f, x...) \
2363 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2364 #ifdef CONFIG_PNP
2365 #endif
2366 #ifdef CONFIG_PNP
2367 #else
2368 #endif
2369 #ifdef CONFIG_MMC_DEBUG
2370 #endif
2371 #ifdef CONFIG_PM
2372 #endif
2373 #ifdef CONFIG_PNP
2374 /* LDV_COMMENT_END_PREP */
2375 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_pnp_probe" */
2376 struct pnp_dev * var_group5;
2377 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_pnp_probe" */
2378 const struct pnp_device_id * var_wbsd_pnp_probe_50_p1;
2379 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "wbsd_pnp_probe" */
2380 static int res_wbsd_pnp_probe_50;
2381 /* LDV_COMMENT_BEGIN_PREP */
2382 #endif
2383 #ifdef CONFIG_PM
2384 #ifdef CONFIG_PNP
2385 #endif
2386 #else
2387 #define wbsd_platform_suspend NULL
2388 #define wbsd_platform_resume NULL
2389 #define wbsd_pnp_suspend NULL
2390 #define wbsd_pnp_resume NULL
2391 #endif
2392 #ifdef CONFIG_PNP
2393 #endif
2394 #ifdef CONFIG_PNP
2395 #endif
2396 #ifdef CONFIG_PNP
2397 #endif
2398 #ifdef CONFIG_PNP
2399 #endif
2400 #ifdef CONFIG_PNP
2401 #endif
2402 /* LDV_COMMENT_END_PREP */
2403 /* content: static void wbsd_pnp_remove(struct pnp_dev *dev)*/
2404 /* LDV_COMMENT_BEGIN_PREP */
2405 #define DRIVER_NAME "wbsd"
2406 #define DBG(x...) \
2407 pr_debug(DRIVER_NAME ": " x)
2408 #define DBGF(f, x...) \
2409 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2410 #ifdef CONFIG_PNP
2411 #endif
2412 #ifdef CONFIG_PNP
2413 #else
2414 #endif
2415 #ifdef CONFIG_MMC_DEBUG
2416 #endif
2417 #ifdef CONFIG_PM
2418 #endif
2419 #ifdef CONFIG_PNP
2420 /* LDV_COMMENT_END_PREP */
2421 /* LDV_COMMENT_BEGIN_PREP */
2422 #endif
2423 #ifdef CONFIG_PM
2424 #ifdef CONFIG_PNP
2425 #endif
2426 #else
2427 #define wbsd_platform_suspend NULL
2428 #define wbsd_platform_resume NULL
2429 #define wbsd_pnp_suspend NULL
2430 #define wbsd_pnp_resume NULL
2431 #endif
2432 #ifdef CONFIG_PNP
2433 #endif
2434 #ifdef CONFIG_PNP
2435 #endif
2436 #ifdef CONFIG_PNP
2437 #endif
2438 #ifdef CONFIG_PNP
2439 #endif
2440 #ifdef CONFIG_PNP
2441 #endif
2442 /* LDV_COMMENT_END_PREP */
2443 /* content: static int wbsd_pnp_suspend(struct pnp_dev *pnp_dev, pm_message_t state)*/
2444 /* LDV_COMMENT_BEGIN_PREP */
2445 #define DRIVER_NAME "wbsd"
2446 #define DBG(x...) \
2447 pr_debug(DRIVER_NAME ": " x)
2448 #define DBGF(f, x...) \
2449 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2450 #ifdef CONFIG_PNP
2451 #endif
2452 #ifdef CONFIG_PNP
2453 #else
2454 #endif
2455 #ifdef CONFIG_MMC_DEBUG
2456 #endif
2457 #ifdef CONFIG_PM
2458 #endif
2459 #ifdef CONFIG_PNP
2460 #endif
2461 #ifdef CONFIG_PM
2462 #ifdef CONFIG_PNP
2463 /* LDV_COMMENT_END_PREP */
2464 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_pnp_suspend" */
2465 pm_message_t var_wbsd_pnp_suspend_54_p1;
2466 /* LDV_COMMENT_BEGIN_PREP */
2467 #endif
2468 #else
2469 #define wbsd_platform_suspend NULL
2470 #define wbsd_platform_resume NULL
2471 #define wbsd_pnp_suspend NULL
2472 #define wbsd_pnp_resume NULL
2473 #endif
2474 #ifdef CONFIG_PNP
2475 #endif
2476 #ifdef CONFIG_PNP
2477 #endif
2478 #ifdef CONFIG_PNP
2479 #endif
2480 #ifdef CONFIG_PNP
2481 #endif
2482 #ifdef CONFIG_PNP
2483 #endif
2484 /* LDV_COMMENT_END_PREP */
2485 /* content: static int wbsd_pnp_resume(struct pnp_dev *pnp_dev)*/
2486 /* LDV_COMMENT_BEGIN_PREP */
2487 #define DRIVER_NAME "wbsd"
2488 #define DBG(x...) \
2489 pr_debug(DRIVER_NAME ": " x)
2490 #define DBGF(f, x...) \
2491 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2492 #ifdef CONFIG_PNP
2493 #endif
2494 #ifdef CONFIG_PNP
2495 #else
2496 #endif
2497 #ifdef CONFIG_MMC_DEBUG
2498 #endif
2499 #ifdef CONFIG_PM
2500 #endif
2501 #ifdef CONFIG_PNP
2502 #endif
2503 #ifdef CONFIG_PM
2504 #ifdef CONFIG_PNP
2505 /* LDV_COMMENT_END_PREP */
2506 /* LDV_COMMENT_BEGIN_PREP */
2507 #endif
2508 #else
2509 #define wbsd_platform_suspend NULL
2510 #define wbsd_platform_resume NULL
2511 #define wbsd_pnp_suspend NULL
2512 #define wbsd_pnp_resume NULL
2513 #endif
2514 #ifdef CONFIG_PNP
2515 #endif
2516 #ifdef CONFIG_PNP
2517 #endif
2518 #ifdef CONFIG_PNP
2519 #endif
2520 #ifdef CONFIG_PNP
2521 #endif
2522 #ifdef CONFIG_PNP
2523 #endif
2524 /* LDV_COMMENT_END_PREP */
2525
2526 /** CALLBACK SECTION request_irq **/
2527 /* content: static irqreturn_t wbsd_irq(int irq, void *dev_id)*/
2528 /* LDV_COMMENT_BEGIN_PREP */
2529 #define DRIVER_NAME "wbsd"
2530 #define DBG(x...) \
2531 pr_debug(DRIVER_NAME ": " x)
2532 #define DBGF(f, x...) \
2533 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2534 #ifdef CONFIG_PNP
2535 #endif
2536 #ifdef CONFIG_PNP
2537 #else
2538 #endif
2539 #ifdef CONFIG_MMC_DEBUG
2540 #endif
2541 /* LDV_COMMENT_END_PREP */
2542 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_irq" */
2543 int var_wbsd_irq_31_p0;
2544 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_irq" */
2545 void * var_wbsd_irq_31_p1;
2546 /* LDV_COMMENT_BEGIN_PREP */
2547 #ifdef CONFIG_PM
2548 #endif
2549 #ifdef CONFIG_PNP
2550 #endif
2551 #ifdef CONFIG_PM
2552 #ifdef CONFIG_PNP
2553 #endif
2554 #else
2555 #define wbsd_platform_suspend NULL
2556 #define wbsd_platform_resume NULL
2557 #define wbsd_pnp_suspend NULL
2558 #define wbsd_pnp_resume NULL
2559 #endif
2560 #ifdef CONFIG_PNP
2561 #endif
2562 #ifdef CONFIG_PNP
2563 #endif
2564 #ifdef CONFIG_PNP
2565 #endif
2566 #ifdef CONFIG_PNP
2567 #endif
2568 #ifdef CONFIG_PNP
2569 #endif
2570 /* LDV_COMMENT_END_PREP */
2571
2572 /** TIMER SECTION timer **/
2573 /* content: static void wbsd_reset_ignore(unsigned long data)*/
2574 /* LDV_COMMENT_BEGIN_PREP */
2575 #define DRIVER_NAME "wbsd"
2576 #define DBG(x...) \
2577 pr_debug(DRIVER_NAME ": " x)
2578 #define DBGF(f, x...) \
2579 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2580 #ifdef CONFIG_PNP
2581 #endif
2582 #ifdef CONFIG_PNP
2583 #else
2584 #endif
2585 #ifdef CONFIG_MMC_DEBUG
2586 #endif
2587 /* LDV_COMMENT_END_PREP */
2588 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_reset_ignore" */
2589 unsigned long var_wbsd_reset_ignore_24_p0;
2590 /* LDV_COMMENT_BEGIN_PREP */
2591 #ifdef CONFIG_PM
2592 #endif
2593 #ifdef CONFIG_PNP
2594 #endif
2595 #ifdef CONFIG_PM
2596 #ifdef CONFIG_PNP
2597 #endif
2598 #else
2599 #define wbsd_platform_suspend NULL
2600 #define wbsd_platform_resume NULL
2601 #define wbsd_pnp_suspend NULL
2602 #define wbsd_pnp_resume NULL
2603 #endif
2604 #ifdef CONFIG_PNP
2605 #endif
2606 #ifdef CONFIG_PNP
2607 #endif
2608 #ifdef CONFIG_PNP
2609 #endif
2610 #ifdef CONFIG_PNP
2611 #endif
2612 #ifdef CONFIG_PNP
2613 #endif
2614 /* LDV_COMMENT_END_PREP */
2615
2616
2617
2618
2619 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */
2620 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */
2621 /*============================= VARIABLE INITIALIZING PART =============================*/
2622 LDV_IN_INTERRUPT=1;
2623
2624
2625
2626
2627 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */
2628 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */
2629 /*============================= FUNCTION CALL SECTION =============================*/
2630 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */
2631 ldv_initialize();
2632
2633 /** INIT: init_type: ST_MODULE_INIT **/
2634 /* content: static int __init wbsd_drv_init(void)*/
2635 /* LDV_COMMENT_BEGIN_PREP */
2636 #define DRIVER_NAME "wbsd"
2637 #define DBG(x...) \
2638 pr_debug(DRIVER_NAME ": " x)
2639 #define DBGF(f, x...) \
2640 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2641 #ifdef CONFIG_PNP
2642 #endif
2643 #ifdef CONFIG_PNP
2644 #else
2645 #endif
2646 #ifdef CONFIG_MMC_DEBUG
2647 #endif
2648 #ifdef CONFIG_PM
2649 #endif
2650 #ifdef CONFIG_PNP
2651 #endif
2652 #ifdef CONFIG_PM
2653 #ifdef CONFIG_PNP
2654 #endif
2655 #else
2656 #define wbsd_platform_suspend NULL
2657 #define wbsd_platform_resume NULL
2658 #define wbsd_pnp_suspend NULL
2659 #define wbsd_pnp_resume NULL
2660 #endif
2661 #ifdef CONFIG_PNP
2662 #endif
2663 /* LDV_COMMENT_END_PREP */
2664 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver init function after driver loading to kernel. This function declared as "MODULE_INIT(function name)". */
2665 ldv_handler_precall();
2666 if(wbsd_drv_init())
2667 goto ldv_final;
2668 /* LDV_COMMENT_BEGIN_PREP */
2669 #ifdef CONFIG_PNP
2670 #endif
2671 #ifdef CONFIG_PNP
2672 #endif
2673 #ifdef CONFIG_PNP
2674 #endif
2675 /* LDV_COMMENT_END_PREP */
2676
2677
2678 int ldv_s_wbsd_driver_platform_driver = 0;
2679
2680 int ldv_s_wbsd_pnp_driver_pnp_driver = 0;
2681
2682
2683
2684
2685
2686
2687
2688 while( nondet_int()
2689 || !(ldv_s_wbsd_driver_platform_driver == 0)
2690 || !(ldv_s_wbsd_pnp_driver_pnp_driver == 0)
2691 ) {
2692
2693 switch(nondet_int()) {
2694
2695 case 0: {
2696
2697 /** STRUCT: struct type: mmc_host_ops, struct name: wbsd_ops **/
2698
2699
2700 /* content: static void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq)*/
2701 /* LDV_COMMENT_BEGIN_PREP */
2702 #define DRIVER_NAME "wbsd"
2703 #define DBG(x...) \
2704 pr_debug(DRIVER_NAME ": " x)
2705 #define DBGF(f, x...) \
2706 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2707 #ifdef CONFIG_PNP
2708 #endif
2709 #ifdef CONFIG_PNP
2710 #else
2711 #endif
2712 /* LDV_COMMENT_END_PREP */
2713 /* LDV_COMMENT_FUNCTION_CALL Function from field "request" from driver structure with callbacks "wbsd_ops" */
2714 ldv_handler_precall();
2715 wbsd_request( var_group1, var_group2);
2716 /* LDV_COMMENT_BEGIN_PREP */
2717 #ifdef CONFIG_PM
2718 #endif
2719 #ifdef CONFIG_PNP
2720 #endif
2721 #ifdef CONFIG_PM
2722 #ifdef CONFIG_PNP
2723 #endif
2724 #else
2725 #define wbsd_platform_suspend NULL
2726 #define wbsd_platform_resume NULL
2727 #define wbsd_pnp_suspend NULL
2728 #define wbsd_pnp_resume NULL
2729 #endif
2730 #ifdef CONFIG_PNP
2731 #endif
2732 #ifdef CONFIG_PNP
2733 #endif
2734 #ifdef CONFIG_PNP
2735 #endif
2736 #ifdef CONFIG_PNP
2737 #endif
2738 #ifdef CONFIG_PNP
2739 #endif
2740 /* LDV_COMMENT_END_PREP */
2741
2742
2743
2744
2745 }
2746
2747 break;
2748 case 1: {
2749
2750 /** STRUCT: struct type: mmc_host_ops, struct name: wbsd_ops **/
2751
2752
2753 /* content: static void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)*/
2754 /* LDV_COMMENT_BEGIN_PREP */
2755 #define DRIVER_NAME "wbsd"
2756 #define DBG(x...) \
2757 pr_debug(DRIVER_NAME ": " x)
2758 #define DBGF(f, x...) \
2759 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2760 #ifdef CONFIG_PNP
2761 #endif
2762 #ifdef CONFIG_PNP
2763 #else
2764 #endif
2765 #ifdef CONFIG_MMC_DEBUG
2766 #endif
2767 /* LDV_COMMENT_END_PREP */
2768 /* LDV_COMMENT_FUNCTION_CALL Function from field "set_ios" from driver structure with callbacks "wbsd_ops" */
2769 ldv_handler_precall();
2770 wbsd_set_ios( var_group1, var_group3);
2771 /* LDV_COMMENT_BEGIN_PREP */
2772 #ifdef CONFIG_PM
2773 #endif
2774 #ifdef CONFIG_PNP
2775 #endif
2776 #ifdef CONFIG_PM
2777 #ifdef CONFIG_PNP
2778 #endif
2779 #else
2780 #define wbsd_platform_suspend NULL
2781 #define wbsd_platform_resume NULL
2782 #define wbsd_pnp_suspend NULL
2783 #define wbsd_pnp_resume NULL
2784 #endif
2785 #ifdef CONFIG_PNP
2786 #endif
2787 #ifdef CONFIG_PNP
2788 #endif
2789 #ifdef CONFIG_PNP
2790 #endif
2791 #ifdef CONFIG_PNP
2792 #endif
2793 #ifdef CONFIG_PNP
2794 #endif
2795 /* LDV_COMMENT_END_PREP */
2796
2797
2798
2799
2800 }
2801
2802 break;
2803 case 2: {
2804
2805 /** STRUCT: struct type: mmc_host_ops, struct name: wbsd_ops **/
2806
2807
2808 /* content: static int wbsd_get_ro(struct mmc_host *mmc)*/
2809 /* LDV_COMMENT_BEGIN_PREP */
2810 #define DRIVER_NAME "wbsd"
2811 #define DBG(x...) \
2812 pr_debug(DRIVER_NAME ": " x)
2813 #define DBGF(f, x...) \
2814 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2815 #ifdef CONFIG_PNP
2816 #endif
2817 #ifdef CONFIG_PNP
2818 #else
2819 #endif
2820 #ifdef CONFIG_MMC_DEBUG
2821 #endif
2822 /* LDV_COMMENT_END_PREP */
2823 /* LDV_COMMENT_FUNCTION_CALL Function from field "get_ro" from driver structure with callbacks "wbsd_ops" */
2824 ldv_handler_precall();
2825 wbsd_get_ro( var_group1);
2826 /* LDV_COMMENT_BEGIN_PREP */
2827 #ifdef CONFIG_PM
2828 #endif
2829 #ifdef CONFIG_PNP
2830 #endif
2831 #ifdef CONFIG_PM
2832 #ifdef CONFIG_PNP
2833 #endif
2834 #else
2835 #define wbsd_platform_suspend NULL
2836 #define wbsd_platform_resume NULL
2837 #define wbsd_pnp_suspend NULL
2838 #define wbsd_pnp_resume NULL
2839 #endif
2840 #ifdef CONFIG_PNP
2841 #endif
2842 #ifdef CONFIG_PNP
2843 #endif
2844 #ifdef CONFIG_PNP
2845 #endif
2846 #ifdef CONFIG_PNP
2847 #endif
2848 #ifdef CONFIG_PNP
2849 #endif
2850 /* LDV_COMMENT_END_PREP */
2851
2852
2853
2854
2855 }
2856
2857 break;
2858 case 3: {
2859
2860 /** STRUCT: struct type: platform_driver, struct name: wbsd_driver **/
2861 if(ldv_s_wbsd_driver_platform_driver==0) {
2862
2863 /* content: static int wbsd_probe(struct platform_device *dev)*/
2864 /* LDV_COMMENT_BEGIN_PREP */
2865 #define DRIVER_NAME "wbsd"
2866 #define DBG(x...) \
2867 pr_debug(DRIVER_NAME ": " x)
2868 #define DBGF(f, x...) \
2869 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2870 #ifdef CONFIG_PNP
2871 #endif
2872 #ifdef CONFIG_PNP
2873 #else
2874 #endif
2875 #ifdef CONFIG_MMC_DEBUG
2876 #endif
2877 #ifdef CONFIG_PM
2878 #endif
2879 /* LDV_COMMENT_END_PREP */
2880 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "wbsd_driver". Standart function test for correct return result. */
2881 res_wbsd_probe_48 = wbsd_probe( var_group4);
2882 ldv_check_return_value(res_wbsd_probe_48);
2883 ldv_check_return_value_probe(res_wbsd_probe_48);
2884 if(res_wbsd_probe_48)
2885 goto ldv_module_exit;
2886 /* LDV_COMMENT_BEGIN_PREP */
2887 #ifdef CONFIG_PNP
2888 #endif
2889 #ifdef CONFIG_PM
2890 #ifdef CONFIG_PNP
2891 #endif
2892 #else
2893 #define wbsd_platform_suspend NULL
2894 #define wbsd_platform_resume NULL
2895 #define wbsd_pnp_suspend NULL
2896 #define wbsd_pnp_resume NULL
2897 #endif
2898 #ifdef CONFIG_PNP
2899 #endif
2900 #ifdef CONFIG_PNP
2901 #endif
2902 #ifdef CONFIG_PNP
2903 #endif
2904 #ifdef CONFIG_PNP
2905 #endif
2906 #ifdef CONFIG_PNP
2907 #endif
2908 /* LDV_COMMENT_END_PREP */
2909 ldv_s_wbsd_driver_platform_driver++;
2910
2911 }
2912
2913 }
2914
2915 break;
2916 case 4: {
2917
2918 /** STRUCT: struct type: platform_driver, struct name: wbsd_driver **/
2919 if(ldv_s_wbsd_driver_platform_driver==1) {
2920
2921 /* content: static int wbsd_platform_suspend(struct platform_device *dev, pm_message_t state)*/
2922 /* LDV_COMMENT_BEGIN_PREP */
2923 #define DRIVER_NAME "wbsd"
2924 #define DBG(x...) \
2925 pr_debug(DRIVER_NAME ": " x)
2926 #define DBGF(f, x...) \
2927 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2928 #ifdef CONFIG_PNP
2929 #endif
2930 #ifdef CONFIG_PNP
2931 #else
2932 #endif
2933 #ifdef CONFIG_MMC_DEBUG
2934 #endif
2935 #ifdef CONFIG_PM
2936 #endif
2937 #ifdef CONFIG_PNP
2938 #endif
2939 #ifdef CONFIG_PM
2940 /* LDV_COMMENT_END_PREP */
2941 /* LDV_COMMENT_FUNCTION_CALL Function from field "suspend" from driver structure with callbacks "wbsd_driver" */
2942 ldv_handler_precall();
2943 wbsd_platform_suspend( var_group4, var_wbsd_platform_suspend_52_p1);
2944 /* LDV_COMMENT_BEGIN_PREP */
2945 #ifdef CONFIG_PNP
2946 #endif
2947 #else
2948 #define wbsd_platform_suspend NULL
2949 #define wbsd_platform_resume NULL
2950 #define wbsd_pnp_suspend NULL
2951 #define wbsd_pnp_resume NULL
2952 #endif
2953 #ifdef CONFIG_PNP
2954 #endif
2955 #ifdef CONFIG_PNP
2956 #endif
2957 #ifdef CONFIG_PNP
2958 #endif
2959 #ifdef CONFIG_PNP
2960 #endif
2961 #ifdef CONFIG_PNP
2962 #endif
2963 /* LDV_COMMENT_END_PREP */
2964 ldv_s_wbsd_driver_platform_driver++;
2965
2966 }
2967
2968 }
2969
2970 break;
2971 case 5: {
2972
2973 /** STRUCT: struct type: platform_driver, struct name: wbsd_driver **/
2974 if(ldv_s_wbsd_driver_platform_driver==2) {
2975
2976 /* content: static int wbsd_platform_resume(struct platform_device *dev)*/
2977 /* LDV_COMMENT_BEGIN_PREP */
2978 #define DRIVER_NAME "wbsd"
2979 #define DBG(x...) \
2980 pr_debug(DRIVER_NAME ": " x)
2981 #define DBGF(f, x...) \
2982 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2983 #ifdef CONFIG_PNP
2984 #endif
2985 #ifdef CONFIG_PNP
2986 #else
2987 #endif
2988 #ifdef CONFIG_MMC_DEBUG
2989 #endif
2990 #ifdef CONFIG_PM
2991 #endif
2992 #ifdef CONFIG_PNP
2993 #endif
2994 #ifdef CONFIG_PM
2995 /* LDV_COMMENT_END_PREP */
2996 /* LDV_COMMENT_FUNCTION_CALL Function from field "resume" from driver structure with callbacks "wbsd_driver" */
2997 ldv_handler_precall();
2998 wbsd_platform_resume( var_group4);
2999 /* LDV_COMMENT_BEGIN_PREP */
3000 #ifdef CONFIG_PNP
3001 #endif
3002 #else
3003 #define wbsd_platform_suspend NULL
3004 #define wbsd_platform_resume NULL
3005 #define wbsd_pnp_suspend NULL
3006 #define wbsd_pnp_resume NULL
3007 #endif
3008 #ifdef CONFIG_PNP
3009 #endif
3010 #ifdef CONFIG_PNP
3011 #endif
3012 #ifdef CONFIG_PNP
3013 #endif
3014 #ifdef CONFIG_PNP
3015 #endif
3016 #ifdef CONFIG_PNP
3017 #endif
3018 /* LDV_COMMENT_END_PREP */
3019 ldv_s_wbsd_driver_platform_driver++;
3020
3021 }
3022
3023 }
3024
3025 break;
3026 case 6: {
3027
3028 /** STRUCT: struct type: platform_driver, struct name: wbsd_driver **/
3029 if(ldv_s_wbsd_driver_platform_driver==3) {
3030
3031 /* content: static int wbsd_remove(struct platform_device *dev)*/
3032 /* LDV_COMMENT_BEGIN_PREP */
3033 #define DRIVER_NAME "wbsd"
3034 #define DBG(x...) \
3035 pr_debug(DRIVER_NAME ": " x)
3036 #define DBGF(f, x...) \
3037 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3038 #ifdef CONFIG_PNP
3039 #endif
3040 #ifdef CONFIG_PNP
3041 #else
3042 #endif
3043 #ifdef CONFIG_MMC_DEBUG
3044 #endif
3045 #ifdef CONFIG_PM
3046 #endif
3047 /* LDV_COMMENT_END_PREP */
3048 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "wbsd_driver" */
3049 ldv_handler_precall();
3050 wbsd_remove( var_group4);
3051 /* LDV_COMMENT_BEGIN_PREP */
3052 #ifdef CONFIG_PNP
3053 #endif
3054 #ifdef CONFIG_PM
3055 #ifdef CONFIG_PNP
3056 #endif
3057 #else
3058 #define wbsd_platform_suspend NULL
3059 #define wbsd_platform_resume NULL
3060 #define wbsd_pnp_suspend NULL
3061 #define wbsd_pnp_resume NULL
3062 #endif
3063 #ifdef CONFIG_PNP
3064 #endif
3065 #ifdef CONFIG_PNP
3066 #endif
3067 #ifdef CONFIG_PNP
3068 #endif
3069 #ifdef CONFIG_PNP
3070 #endif
3071 #ifdef CONFIG_PNP
3072 #endif
3073 /* LDV_COMMENT_END_PREP */
3074 ldv_s_wbsd_driver_platform_driver=0;
3075
3076 }
3077
3078 }
3079
3080 break;
3081 case 7: {
3082
3083 /** STRUCT: struct type: pnp_driver, struct name: wbsd_pnp_driver **/
3084 if(ldv_s_wbsd_pnp_driver_pnp_driver==0) {
3085
3086 /* content: static int wbsd_pnp_probe(struct pnp_dev *pnpdev, const struct pnp_device_id *dev_id)*/
3087 /* LDV_COMMENT_BEGIN_PREP */
3088 #define DRIVER_NAME "wbsd"
3089 #define DBG(x...) \
3090 pr_debug(DRIVER_NAME ": " x)
3091 #define DBGF(f, x...) \
3092 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3093 #ifdef CONFIG_PNP
3094 #endif
3095 #ifdef CONFIG_PNP
3096 #else
3097 #endif
3098 #ifdef CONFIG_MMC_DEBUG
3099 #endif
3100 #ifdef CONFIG_PM
3101 #endif
3102 #ifdef CONFIG_PNP
3103 /* LDV_COMMENT_END_PREP */
3104 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "wbsd_pnp_driver". Standart function test for correct return result. */
3105 res_wbsd_pnp_probe_50 = wbsd_pnp_probe( var_group5, var_wbsd_pnp_probe_50_p1);
3106 ldv_check_return_value(res_wbsd_pnp_probe_50);
3107 ldv_check_return_value_probe(res_wbsd_pnp_probe_50);
3108 if(res_wbsd_pnp_probe_50)
3109 goto ldv_module_exit;
3110 /* LDV_COMMENT_BEGIN_PREP */
3111 #endif
3112 #ifdef CONFIG_PM
3113 #ifdef CONFIG_PNP
3114 #endif
3115 #else
3116 #define wbsd_platform_suspend NULL
3117 #define wbsd_platform_resume NULL
3118 #define wbsd_pnp_suspend NULL
3119 #define wbsd_pnp_resume NULL
3120 #endif
3121 #ifdef CONFIG_PNP
3122 #endif
3123 #ifdef CONFIG_PNP
3124 #endif
3125 #ifdef CONFIG_PNP
3126 #endif
3127 #ifdef CONFIG_PNP
3128 #endif
3129 #ifdef CONFIG_PNP
3130 #endif
3131 /* LDV_COMMENT_END_PREP */
3132 ldv_s_wbsd_pnp_driver_pnp_driver++;
3133
3134 }
3135
3136 }
3137
3138 break;
3139 case 8: {
3140
3141 /** STRUCT: struct type: pnp_driver, struct name: wbsd_pnp_driver **/
3142 if(ldv_s_wbsd_pnp_driver_pnp_driver==1) {
3143
3144 /* content: static void wbsd_pnp_remove(struct pnp_dev *dev)*/
3145 /* LDV_COMMENT_BEGIN_PREP */
3146 #define DRIVER_NAME "wbsd"
3147 #define DBG(x...) \
3148 pr_debug(DRIVER_NAME ": " x)
3149 #define DBGF(f, x...) \
3150 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3151 #ifdef CONFIG_PNP
3152 #endif
3153 #ifdef CONFIG_PNP
3154 #else
3155 #endif
3156 #ifdef CONFIG_MMC_DEBUG
3157 #endif
3158 #ifdef CONFIG_PM
3159 #endif
3160 #ifdef CONFIG_PNP
3161 /* LDV_COMMENT_END_PREP */
3162 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "wbsd_pnp_driver" */
3163 ldv_handler_precall();
3164 wbsd_pnp_remove( var_group5);
3165 /* LDV_COMMENT_BEGIN_PREP */
3166 #endif
3167 #ifdef CONFIG_PM
3168 #ifdef CONFIG_PNP
3169 #endif
3170 #else
3171 #define wbsd_platform_suspend NULL
3172 #define wbsd_platform_resume NULL
3173 #define wbsd_pnp_suspend NULL
3174 #define wbsd_pnp_resume NULL
3175 #endif
3176 #ifdef CONFIG_PNP
3177 #endif
3178 #ifdef CONFIG_PNP
3179 #endif
3180 #ifdef CONFIG_PNP
3181 #endif
3182 #ifdef CONFIG_PNP
3183 #endif
3184 #ifdef CONFIG_PNP
3185 #endif
3186 /* LDV_COMMENT_END_PREP */
3187 ldv_s_wbsd_pnp_driver_pnp_driver=0;
3188
3189 }
3190
3191 }
3192
3193 break;
3194 case 9: {
3195
3196 /** STRUCT: struct type: pnp_driver, struct name: wbsd_pnp_driver **/
3197
3198
3199 /* content: static int wbsd_pnp_suspend(struct pnp_dev *pnp_dev, pm_message_t state)*/
3200 /* LDV_COMMENT_BEGIN_PREP */
3201 #define DRIVER_NAME "wbsd"
3202 #define DBG(x...) \
3203 pr_debug(DRIVER_NAME ": " x)
3204 #define DBGF(f, x...) \
3205 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3206 #ifdef CONFIG_PNP
3207 #endif
3208 #ifdef CONFIG_PNP
3209 #else
3210 #endif
3211 #ifdef CONFIG_MMC_DEBUG
3212 #endif
3213 #ifdef CONFIG_PM
3214 #endif
3215 #ifdef CONFIG_PNP
3216 #endif
3217 #ifdef CONFIG_PM
3218 #ifdef CONFIG_PNP
3219 /* LDV_COMMENT_END_PREP */
3220 /* LDV_COMMENT_FUNCTION_CALL Function from field "suspend" from driver structure with callbacks "wbsd_pnp_driver" */
3221 ldv_handler_precall();
3222 wbsd_pnp_suspend( var_group5, var_wbsd_pnp_suspend_54_p1);
3223 /* LDV_COMMENT_BEGIN_PREP */
3224 #endif
3225 #else
3226 #define wbsd_platform_suspend NULL
3227 #define wbsd_platform_resume NULL
3228 #define wbsd_pnp_suspend NULL
3229 #define wbsd_pnp_resume NULL
3230 #endif
3231 #ifdef CONFIG_PNP
3232 #endif
3233 #ifdef CONFIG_PNP
3234 #endif
3235 #ifdef CONFIG_PNP
3236 #endif
3237 #ifdef CONFIG_PNP
3238 #endif
3239 #ifdef CONFIG_PNP
3240 #endif
3241 /* LDV_COMMENT_END_PREP */
3242
3243
3244
3245
3246 }
3247
3248 break;
3249 case 10: {
3250
3251 /** STRUCT: struct type: pnp_driver, struct name: wbsd_pnp_driver **/
3252
3253
3254 /* content: static int wbsd_pnp_resume(struct pnp_dev *pnp_dev)*/
3255 /* LDV_COMMENT_BEGIN_PREP */
3256 #define DRIVER_NAME "wbsd"
3257 #define DBG(x...) \
3258 pr_debug(DRIVER_NAME ": " x)
3259 #define DBGF(f, x...) \
3260 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3261 #ifdef CONFIG_PNP
3262 #endif
3263 #ifdef CONFIG_PNP
3264 #else
3265 #endif
3266 #ifdef CONFIG_MMC_DEBUG
3267 #endif
3268 #ifdef CONFIG_PM
3269 #endif
3270 #ifdef CONFIG_PNP
3271 #endif
3272 #ifdef CONFIG_PM
3273 #ifdef CONFIG_PNP
3274 /* LDV_COMMENT_END_PREP */
3275 /* LDV_COMMENT_FUNCTION_CALL Function from field "resume" from driver structure with callbacks "wbsd_pnp_driver" */
3276 ldv_handler_precall();
3277 wbsd_pnp_resume( var_group5);
3278 /* LDV_COMMENT_BEGIN_PREP */
3279 #endif
3280 #else
3281 #define wbsd_platform_suspend NULL
3282 #define wbsd_platform_resume NULL
3283 #define wbsd_pnp_suspend NULL
3284 #define wbsd_pnp_resume NULL
3285 #endif
3286 #ifdef CONFIG_PNP
3287 #endif
3288 #ifdef CONFIG_PNP
3289 #endif
3290 #ifdef CONFIG_PNP
3291 #endif
3292 #ifdef CONFIG_PNP
3293 #endif
3294 #ifdef CONFIG_PNP
3295 #endif
3296 /* LDV_COMMENT_END_PREP */
3297
3298
3299
3300
3301 }
3302
3303 break;
3304 case 11: {
3305
3306 /** CALLBACK SECTION request_irq **/
3307 LDV_IN_INTERRUPT=2;
3308
3309 /* content: static irqreturn_t wbsd_irq(int irq, void *dev_id)*/
3310 /* LDV_COMMENT_BEGIN_PREP */
3311 #define DRIVER_NAME "wbsd"
3312 #define DBG(x...) \
3313 pr_debug(DRIVER_NAME ": " x)
3314 #define DBGF(f, x...) \
3315 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3316 #ifdef CONFIG_PNP
3317 #endif
3318 #ifdef CONFIG_PNP
3319 #else
3320 #endif
3321 #ifdef CONFIG_MMC_DEBUG
3322 #endif
3323 /* LDV_COMMENT_END_PREP */
3324 /* LDV_COMMENT_FUNCTION_CALL */
3325 ldv_handler_precall();
3326 wbsd_irq( var_wbsd_irq_31_p0, var_wbsd_irq_31_p1);
3327 /* LDV_COMMENT_BEGIN_PREP */
3328 #ifdef CONFIG_PM
3329 #endif
3330 #ifdef CONFIG_PNP
3331 #endif
3332 #ifdef CONFIG_PM
3333 #ifdef CONFIG_PNP
3334 #endif
3335 #else
3336 #define wbsd_platform_suspend NULL
3337 #define wbsd_platform_resume NULL
3338 #define wbsd_pnp_suspend NULL
3339 #define wbsd_pnp_resume NULL
3340 #endif
3341 #ifdef CONFIG_PNP
3342 #endif
3343 #ifdef CONFIG_PNP
3344 #endif
3345 #ifdef CONFIG_PNP
3346 #endif
3347 #ifdef CONFIG_PNP
3348 #endif
3349 #ifdef CONFIG_PNP
3350 #endif
3351 /* LDV_COMMENT_END_PREP */
3352 LDV_IN_INTERRUPT=1;
3353
3354
3355
3356 }
3357
3358 break;
3359 case 12: {
3360
3361 /** TIMER SECTION timer **/
3362
3363
3364 /* content: static void wbsd_reset_ignore(unsigned long data)*/
3365 /* LDV_COMMENT_BEGIN_PREP */
3366 #define DRIVER_NAME "wbsd"
3367 #define DBG(x...) \
3368 pr_debug(DRIVER_NAME ": " x)
3369 #define DBGF(f, x...) \
3370 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3371 #ifdef CONFIG_PNP
3372 #endif
3373 #ifdef CONFIG_PNP
3374 #else
3375 #endif
3376 #ifdef CONFIG_MMC_DEBUG
3377 #endif
3378 /* LDV_COMMENT_END_PREP */
3379 /* LDV_COMMENT_FUNCTION_CALL */
3380 ldv_handler_precall();
3381 wbsd_reset_ignore( var_wbsd_reset_ignore_24_p0);
3382 /* LDV_COMMENT_BEGIN_PREP */
3383 #ifdef CONFIG_PM
3384 #endif
3385 #ifdef CONFIG_PNP
3386 #endif
3387 #ifdef CONFIG_PM
3388 #ifdef CONFIG_PNP
3389 #endif
3390 #else
3391 #define wbsd_platform_suspend NULL
3392 #define wbsd_platform_resume NULL
3393 #define wbsd_pnp_suspend NULL
3394 #define wbsd_pnp_resume NULL
3395 #endif
3396 #ifdef CONFIG_PNP
3397 #endif
3398 #ifdef CONFIG_PNP
3399 #endif
3400 #ifdef CONFIG_PNP
3401 #endif
3402 #ifdef CONFIG_PNP
3403 #endif
3404 #ifdef CONFIG_PNP
3405 #endif
3406 /* LDV_COMMENT_END_PREP */
3407
3408
3409
3410
3411 }
3412
3413 break;
3414 default: break;
3415
3416 }
3417
3418 }
3419
3420 ldv_module_exit:
3421
3422 /** INIT: init_type: ST_MODULE_EXIT **/
3423 /* content: static void __exit wbsd_drv_exit(void)*/
3424 /* LDV_COMMENT_BEGIN_PREP */
3425 #define DRIVER_NAME "wbsd"
3426 #define DBG(x...) \
3427 pr_debug(DRIVER_NAME ": " x)
3428 #define DBGF(f, x...) \
3429 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3430 #ifdef CONFIG_PNP
3431 #endif
3432 #ifdef CONFIG_PNP
3433 #else
3434 #endif
3435 #ifdef CONFIG_MMC_DEBUG
3436 #endif
3437 #ifdef CONFIG_PM
3438 #endif
3439 #ifdef CONFIG_PNP
3440 #endif
3441 #ifdef CONFIG_PM
3442 #ifdef CONFIG_PNP
3443 #endif
3444 #else
3445 #define wbsd_platform_suspend NULL
3446 #define wbsd_platform_resume NULL
3447 #define wbsd_pnp_suspend NULL
3448 #define wbsd_pnp_resume NULL
3449 #endif
3450 #ifdef CONFIG_PNP
3451 #endif
3452 #ifdef CONFIG_PNP
3453 #endif
3454 /* LDV_COMMENT_END_PREP */
3455 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver release function before driver will be uploaded from kernel. This function declared as "MODULE_EXIT(function name)". */
3456 ldv_handler_precall();
3457 wbsd_drv_exit();
3458 /* LDV_COMMENT_BEGIN_PREP */
3459 #ifdef CONFIG_PNP
3460 #endif
3461 #ifdef CONFIG_PNP
3462 #endif
3463 /* LDV_COMMENT_END_PREP */
3464
3465 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */
3466 ldv_final: ldv_check_final_state();
3467
3468 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */
3469 return;
3470
3471 }
3472 #endif
3473
3474 /* LDV_COMMENT_END_MAIN */ 1
2 #include <linux/kernel.h>
3 bool ldv_is_err(const void *ptr);
4 bool ldv_is_err_or_null(const void *ptr);
5 void* ldv_err_ptr(long error);
6 long ldv_ptr_err(const void *ptr);
7
8 extern void ldv_dma_map_page(void);
9 extern void ldv_dma_mapping_error(void);
10 #line 1 "/home/ldvuser/ldv/ref_launches/work/current--X--drivers--X--defaultlinux-4.10-rc1.tar.xz--X--331_1a--X--cpachecker/linux-4.10-rc1.tar.xz/csd_deg_dscv/16260/dscv_tempdir/dscv/ri/331_1a/drivers/mmc/host/wbsd.c"
11
12 /*
13 * linux/drivers/mmc/host/wbsd.c - Winbond W83L51xD SD/MMC driver
14 *
15 * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved.
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or (at
20 * your option) any later version.
21 *
22 *
23 * Warning!
24 *
25 * Changes to the FIFO system should be done with extreme care since
26 * the hardware is full of bugs related to the FIFO. Known issues are:
27 *
28 * - FIFO size field in FSR is always zero.
29 *
30 * - FIFO interrupts tend not to work as they should. Interrupts are
31 * triggered only for full/empty events, not for threshold values.
32 *
33 * - On APIC systems the FIFO empty interrupt is sometimes lost.
34 */
35
36 #include <linux/module.h>
37 #include <linux/moduleparam.h>
38 #include <linux/init.h>
39 #include <linux/ioport.h>
40 #include <linux/platform_device.h>
41 #include <linux/interrupt.h>
42 #include <linux/dma-mapping.h>
43 #include <linux/delay.h>
44 #include <linux/pnp.h>
45 #include <linux/highmem.h>
46 #include <linux/mmc/host.h>
47 #include <linux/scatterlist.h>
48 #include <linux/slab.h>
49
50 #include <asm/io.h>
51 #include <asm/dma.h>
52
53 #include "wbsd.h"
54
55 #define DRIVER_NAME "wbsd"
56
57 #define DBG(x...) \
58 pr_debug(DRIVER_NAME ": " x)
59 #define DBGF(f, x...) \
60 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
61
62 /*
63 * Device resources
64 */
65
66 #ifdef CONFIG_PNP
67
68 static const struct pnp_device_id pnp_dev_table[] = {
69 { "WEC0517", 0 },
70 { "WEC0518", 0 },
71 { "", 0 },
72 };
73
74 MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
75
76 #endif /* CONFIG_PNP */
77
78 static const int config_ports[] = { 0x2E, 0x4E };
79 static const int unlock_codes[] = { 0x83, 0x87 };
80
81 static const int valid_ids[] = {
82 0x7112,
83 };
84
85 #ifdef CONFIG_PNP
86 static unsigned int param_nopnp = 0;
87 #else
88 static const unsigned int param_nopnp = 1;
89 #endif
90 static unsigned int param_io = 0x248;
91 static unsigned int param_irq = 6;
92 static int param_dma = 2;
93
94 /*
95 * Basic functions
96 */
97
98 static inline void wbsd_unlock_config(struct wbsd_host *host)
99 {
100 BUG_ON(host->config == 0);
101
102 outb(host->unlock_code, host->config);
103 outb(host->unlock_code, host->config);
104 }
105
106 static inline void wbsd_lock_config(struct wbsd_host *host)
107 {
108 BUG_ON(host->config == 0);
109
110 outb(LOCK_CODE, host->config);
111 }
112
113 static inline void wbsd_write_config(struct wbsd_host *host, u8 reg, u8 value)
114 {
115 BUG_ON(host->config == 0);
116
117 outb(reg, host->config);
118 outb(value, host->config + 1);
119 }
120
121 static inline u8 wbsd_read_config(struct wbsd_host *host, u8 reg)
122 {
123 BUG_ON(host->config == 0);
124
125 outb(reg, host->config);
126 return inb(host->config + 1);
127 }
128
129 static inline void wbsd_write_index(struct wbsd_host *host, u8 index, u8 value)
130 {
131 outb(index, host->base + WBSD_IDXR);
132 outb(value, host->base + WBSD_DATAR);
133 }
134
135 static inline u8 wbsd_read_index(struct wbsd_host *host, u8 index)
136 {
137 outb(index, host->base + WBSD_IDXR);
138 return inb(host->base + WBSD_DATAR);
139 }
140
141 /*
142 * Common routines
143 */
144
145 static void wbsd_init_device(struct wbsd_host *host)
146 {
147 u8 setup, ier;
148
149 /*
150 * Reset chip (SD/MMC part) and fifo.
151 */
152 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
153 setup |= WBSD_FIFO_RESET | WBSD_SOFT_RESET;
154 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
155
156 /*
157 * Set DAT3 to input
158 */
159 setup &= ~WBSD_DAT3_H;
160 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
161 host->flags &= ~WBSD_FIGNORE_DETECT;
162
163 /*
164 * Read back default clock.
165 */
166 host->clk = wbsd_read_index(host, WBSD_IDX_CLK);
167
168 /*
169 * Power down port.
170 */
171 outb(WBSD_POWER_N, host->base + WBSD_CSR);
172
173 /*
174 * Set maximum timeout.
175 */
176 wbsd_write_index(host, WBSD_IDX_TAAC, 0x7F);
177
178 /*
179 * Test for card presence
180 */
181 if (inb(host->base + WBSD_CSR) & WBSD_CARDPRESENT)
182 host->flags |= WBSD_FCARD_PRESENT;
183 else
184 host->flags &= ~WBSD_FCARD_PRESENT;
185
186 /*
187 * Enable interesting interrupts.
188 */
189 ier = 0;
190 ier |= WBSD_EINT_CARD;
191 ier |= WBSD_EINT_FIFO_THRE;
192 ier |= WBSD_EINT_CRC;
193 ier |= WBSD_EINT_TIMEOUT;
194 ier |= WBSD_EINT_TC;
195
196 outb(ier, host->base + WBSD_EIR);
197
198 /*
199 * Clear interrupts.
200 */
201 inb(host->base + WBSD_ISR);
202 }
203
204 static void wbsd_reset(struct wbsd_host *host)
205 {
206 u8 setup;
207
208 pr_err("%s: Resetting chip\n", mmc_hostname(host->mmc));
209
210 /*
211 * Soft reset of chip (SD/MMC part).
212 */
213 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
214 setup |= WBSD_SOFT_RESET;
215 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
216 }
217
218 static void wbsd_request_end(struct wbsd_host *host, struct mmc_request *mrq)
219 {
220 unsigned long dmaflags;
221
222 if (host->dma >= 0) {
223 /*
224 * Release ISA DMA controller.
225 */
226 dmaflags = claim_dma_lock();
227 disable_dma(host->dma);
228 clear_dma_ff(host->dma);
229 release_dma_lock(dmaflags);
230
231 /*
232 * Disable DMA on host.
233 */
234 wbsd_write_index(host, WBSD_IDX_DMA, 0);
235 }
236
237 host->mrq = NULL;
238
239 /*
240 * MMC layer might call back into the driver so first unlock.
241 */
242 spin_unlock(&host->lock);
243 mmc_request_done(host->mmc, mrq);
244 spin_lock(&host->lock);
245 }
246
247 /*
248 * Scatter/gather functions
249 */
250
251 static inline void wbsd_init_sg(struct wbsd_host *host, struct mmc_data *data)
252 {
253 /*
254 * Get info. about SG list from data structure.
255 */
256 host->cur_sg = data->sg;
257 host->num_sg = data->sg_len;
258
259 host->offset = 0;
260 host->remain = host->cur_sg->length;
261 }
262
263 static inline int wbsd_next_sg(struct wbsd_host *host)
264 {
265 /*
266 * Skip to next SG entry.
267 */
268 host->cur_sg++;
269 host->num_sg--;
270
271 /*
272 * Any entries left?
273 */
274 if (host->num_sg > 0) {
275 host->offset = 0;
276 host->remain = host->cur_sg->length;
277 }
278
279 return host->num_sg;
280 }
281
282 static inline char *wbsd_sg_to_buffer(struct wbsd_host *host)
283 {
284 return sg_virt(host->cur_sg);
285 }
286
287 static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data)
288 {
289 unsigned int len, i;
290 struct scatterlist *sg;
291 char *dmabuf = host->dma_buffer;
292 char *sgbuf;
293
294 sg = data->sg;
295 len = data->sg_len;
296
297 for (i = 0; i < len; i++) {
298 sgbuf = sg_virt(&sg[i]);
299 memcpy(dmabuf, sgbuf, sg[i].length);
300 dmabuf += sg[i].length;
301 }
302 }
303
304 static inline void wbsd_dma_to_sg(struct wbsd_host *host, struct mmc_data *data)
305 {
306 unsigned int len, i;
307 struct scatterlist *sg;
308 char *dmabuf = host->dma_buffer;
309 char *sgbuf;
310
311 sg = data->sg;
312 len = data->sg_len;
313
314 for (i = 0; i < len; i++) {
315 sgbuf = sg_virt(&sg[i]);
316 memcpy(sgbuf, dmabuf, sg[i].length);
317 dmabuf += sg[i].length;
318 }
319 }
320
321 /*
322 * Command handling
323 */
324
325 static inline void wbsd_get_short_reply(struct wbsd_host *host,
326 struct mmc_command *cmd)
327 {
328 /*
329 * Correct response type?
330 */
331 if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_SHORT) {
332 cmd->error = -EILSEQ;
333 return;
334 }
335
336 cmd->resp[0] = wbsd_read_index(host, WBSD_IDX_RESP12) << 24;
337 cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP13) << 16;
338 cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP14) << 8;
339 cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP15) << 0;
340 cmd->resp[1] = wbsd_read_index(host, WBSD_IDX_RESP16) << 24;
341 }
342
343 static inline void wbsd_get_long_reply(struct wbsd_host *host,
344 struct mmc_command *cmd)
345 {
346 int i;
347
348 /*
349 * Correct response type?
350 */
351 if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_LONG) {
352 cmd->error = -EILSEQ;
353 return;
354 }
355
356 for (i = 0; i < 4; i++) {
357 cmd->resp[i] =
358 wbsd_read_index(host, WBSD_IDX_RESP1 + i * 4) << 24;
359 cmd->resp[i] |=
360 wbsd_read_index(host, WBSD_IDX_RESP2 + i * 4) << 16;
361 cmd->resp[i] |=
362 wbsd_read_index(host, WBSD_IDX_RESP3 + i * 4) << 8;
363 cmd->resp[i] |=
364 wbsd_read_index(host, WBSD_IDX_RESP4 + i * 4) << 0;
365 }
366 }
367
368 static void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd)
369 {
370 int i;
371 u8 status, isr;
372
373 /*
374 * Clear accumulated ISR. The interrupt routine
375 * will fill this one with events that occur during
376 * transfer.
377 */
378 host->isr = 0;
379
380 /*
381 * Send the command (CRC calculated by host).
382 */
383 outb(cmd->opcode, host->base + WBSD_CMDR);
384 for (i = 3; i >= 0; i--)
385 outb((cmd->arg >> (i * 8)) & 0xff, host->base + WBSD_CMDR);
386
387 cmd->error = 0;
388
389 /*
390 * Wait for the request to complete.
391 */
392 do {
393 status = wbsd_read_index(host, WBSD_IDX_STATUS);
394 } while (status & WBSD_CARDTRAFFIC);
395
396 /*
397 * Do we expect a reply?
398 */
399 if (cmd->flags & MMC_RSP_PRESENT) {
400 /*
401 * Read back status.
402 */
403 isr = host->isr;
404
405 /* Card removed? */
406 if (isr & WBSD_INT_CARD)
407 cmd->error = -ENOMEDIUM;
408 /* Timeout? */
409 else if (isr & WBSD_INT_TIMEOUT)
410 cmd->error = -ETIMEDOUT;
411 /* CRC? */
412 else if ((cmd->flags & MMC_RSP_CRC) && (isr & WBSD_INT_CRC))
413 cmd->error = -EILSEQ;
414 /* All ok */
415 else {
416 if (cmd->flags & MMC_RSP_136)
417 wbsd_get_long_reply(host, cmd);
418 else
419 wbsd_get_short_reply(host, cmd);
420 }
421 }
422 }
423
424 /*
425 * Data functions
426 */
427
428 static void wbsd_empty_fifo(struct wbsd_host *host)
429 {
430 struct mmc_data *data = host->mrq->cmd->data;
431 char *buffer;
432 int i, fsr, fifo;
433
434 /*
435 * Handle excessive data.
436 */
437 if (host->num_sg == 0)
438 return;
439
440 buffer = wbsd_sg_to_buffer(host) + host->offset;
441
442 /*
443 * Drain the fifo. This has a tendency to loop longer
444 * than the FIFO length (usually one block).
445 */
446 while (!((fsr = inb(host->base + WBSD_FSR)) & WBSD_FIFO_EMPTY)) {
447 /*
448 * The size field in the FSR is broken so we have to
449 * do some guessing.
450 */
451 if (fsr & WBSD_FIFO_FULL)
452 fifo = 16;
453 else if (fsr & WBSD_FIFO_FUTHRE)
454 fifo = 8;
455 else
456 fifo = 1;
457
458 for (i = 0; i < fifo; i++) {
459 *buffer = inb(host->base + WBSD_DFR);
460 buffer++;
461 host->offset++;
462 host->remain--;
463
464 data->bytes_xfered++;
465
466 /*
467 * End of scatter list entry?
468 */
469 if (host->remain == 0) {
470 /*
471 * Get next entry. Check if last.
472 */
473 if (!wbsd_next_sg(host))
474 return;
475
476 buffer = wbsd_sg_to_buffer(host);
477 }
478 }
479 }
480
481 /*
482 * This is a very dirty hack to solve a
483 * hardware problem. The chip doesn't trigger
484 * FIFO threshold interrupts properly.
485 */
486 if ((data->blocks * data->blksz - data->bytes_xfered) < 16)
487 tasklet_schedule(&host->fifo_tasklet);
488 }
489
490 static void wbsd_fill_fifo(struct wbsd_host *host)
491 {
492 struct mmc_data *data = host->mrq->cmd->data;
493 char *buffer;
494 int i, fsr, fifo;
495
496 /*
497 * Check that we aren't being called after the
498 * entire buffer has been transferred.
499 */
500 if (host->num_sg == 0)
501 return;
502
503 buffer = wbsd_sg_to_buffer(host) + host->offset;
504
505 /*
506 * Fill the fifo. This has a tendency to loop longer
507 * than the FIFO length (usually one block).
508 */
509 while (!((fsr = inb(host->base + WBSD_FSR)) & WBSD_FIFO_FULL)) {
510 /*
511 * The size field in the FSR is broken so we have to
512 * do some guessing.
513 */
514 if (fsr & WBSD_FIFO_EMPTY)
515 fifo = 0;
516 else if (fsr & WBSD_FIFO_EMTHRE)
517 fifo = 8;
518 else
519 fifo = 15;
520
521 for (i = 16; i > fifo; i--) {
522 outb(*buffer, host->base + WBSD_DFR);
523 buffer++;
524 host->offset++;
525 host->remain--;
526
527 data->bytes_xfered++;
528
529 /*
530 * End of scatter list entry?
531 */
532 if (host->remain == 0) {
533 /*
534 * Get next entry. Check if last.
535 */
536 if (!wbsd_next_sg(host))
537 return;
538
539 buffer = wbsd_sg_to_buffer(host);
540 }
541 }
542 }
543
544 /*
545 * The controller stops sending interrupts for
546 * 'FIFO empty' under certain conditions. So we
547 * need to be a bit more pro-active.
548 */
549 tasklet_schedule(&host->fifo_tasklet);
550 }
551
552 static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data)
553 {
554 u16 blksize;
555 u8 setup;
556 unsigned long dmaflags;
557 unsigned int size;
558
559 /*
560 * Calculate size.
561 */
562 size = data->blocks * data->blksz;
563
564 /*
565 * Check timeout values for overflow.
566 * (Yes, some cards cause this value to overflow).
567 */
568 if (data->timeout_ns > 127000000)
569 wbsd_write_index(host, WBSD_IDX_TAAC, 127);
570 else {
571 wbsd_write_index(host, WBSD_IDX_TAAC,
572 data->timeout_ns / 1000000);
573 }
574
575 if (data->timeout_clks > 255)
576 wbsd_write_index(host, WBSD_IDX_NSAC, 255);
577 else
578 wbsd_write_index(host, WBSD_IDX_NSAC, data->timeout_clks);
579
580 /*
581 * Inform the chip of how large blocks will be
582 * sent. It needs this to determine when to
583 * calculate CRC.
584 *
585 * Space for CRC must be included in the size.
586 * Two bytes are needed for each data line.
587 */
588 if (host->bus_width == MMC_BUS_WIDTH_1) {
589 blksize = data->blksz + 2;
590
591 wbsd_write_index(host, WBSD_IDX_PBSMSB, (blksize >> 4) & 0xF0);
592 wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF);
593 } else if (host->bus_width == MMC_BUS_WIDTH_4) {
594 blksize = data->blksz + 2 * 4;
595
596 wbsd_write_index(host, WBSD_IDX_PBSMSB,
597 ((blksize >> 4) & 0xF0) | WBSD_DATA_WIDTH);
598 wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF);
599 } else {
600 data->error = -EINVAL;
601 return;
602 }
603
604 /*
605 * Clear the FIFO. This is needed even for DMA
606 * transfers since the chip still uses the FIFO
607 * internally.
608 */
609 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
610 setup |= WBSD_FIFO_RESET;
611 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
612
613 /*
614 * DMA transfer?
615 */
616 if (host->dma >= 0) {
617 /*
618 * The buffer for DMA is only 64 kB.
619 */
620 BUG_ON(size > 0x10000);
621 if (size > 0x10000) {
622 data->error = -EINVAL;
623 return;
624 }
625
626 /*
627 * Transfer data from the SG list to
628 * the DMA buffer.
629 */
630 if (data->flags & MMC_DATA_WRITE)
631 wbsd_sg_to_dma(host, data);
632
633 /*
634 * Initialise the ISA DMA controller.
635 */
636 dmaflags = claim_dma_lock();
637 disable_dma(host->dma);
638 clear_dma_ff(host->dma);
639 if (data->flags & MMC_DATA_READ)
640 set_dma_mode(host->dma, DMA_MODE_READ & ~0x40);
641 else
642 set_dma_mode(host->dma, DMA_MODE_WRITE & ~0x40);
643 set_dma_addr(host->dma, host->dma_addr);
644 set_dma_count(host->dma, size);
645
646 enable_dma(host->dma);
647 release_dma_lock(dmaflags);
648
649 /*
650 * Enable DMA on the host.
651 */
652 wbsd_write_index(host, WBSD_IDX_DMA, WBSD_DMA_ENABLE);
653 } else {
654 /*
655 * This flag is used to keep printk
656 * output to a minimum.
657 */
658 host->firsterr = 1;
659
660 /*
661 * Initialise the SG list.
662 */
663 wbsd_init_sg(host, data);
664
665 /*
666 * Turn off DMA.
667 */
668 wbsd_write_index(host, WBSD_IDX_DMA, 0);
669
670 /*
671 * Set up FIFO threshold levels (and fill
672 * buffer if doing a write).
673 */
674 if (data->flags & MMC_DATA_READ) {
675 wbsd_write_index(host, WBSD_IDX_FIFOEN,
676 WBSD_FIFOEN_FULL | 8);
677 } else {
678 wbsd_write_index(host, WBSD_IDX_FIFOEN,
679 WBSD_FIFOEN_EMPTY | 8);
680 wbsd_fill_fifo(host);
681 }
682 }
683
684 data->error = 0;
685 }
686
687 static void wbsd_finish_data(struct wbsd_host *host, struct mmc_data *data)
688 {
689 unsigned long dmaflags;
690 int count;
691 u8 status;
692
693 WARN_ON(host->mrq == NULL);
694
695 /*
696 * Send a stop command if needed.
697 */
698 if (data->stop)
699 wbsd_send_command(host, data->stop);
700
701 /*
702 * Wait for the controller to leave data
703 * transfer state.
704 */
705 do {
706 status = wbsd_read_index(host, WBSD_IDX_STATUS);
707 } while (status & (WBSD_BLOCK_READ | WBSD_BLOCK_WRITE));
708
709 /*
710 * DMA transfer?
711 */
712 if (host->dma >= 0) {
713 /*
714 * Disable DMA on the host.
715 */
716 wbsd_write_index(host, WBSD_IDX_DMA, 0);
717
718 /*
719 * Turn of ISA DMA controller.
720 */
721 dmaflags = claim_dma_lock();
722 disable_dma(host->dma);
723 clear_dma_ff(host->dma);
724 count = get_dma_residue(host->dma);
725 release_dma_lock(dmaflags);
726
727 data->bytes_xfered = host->mrq->data->blocks *
728 host->mrq->data->blksz - count;
729 data->bytes_xfered -= data->bytes_xfered % data->blksz;
730
731 /*
732 * Any leftover data?
733 */
734 if (count) {
735 pr_err("%s: Incomplete DMA transfer. "
736 "%d bytes left.\n",
737 mmc_hostname(host->mmc), count);
738
739 if (!data->error)
740 data->error = -EIO;
741 } else {
742 /*
743 * Transfer data from DMA buffer to
744 * SG list.
745 */
746 if (data->flags & MMC_DATA_READ)
747 wbsd_dma_to_sg(host, data);
748 }
749
750 if (data->error) {
751 if (data->bytes_xfered)
752 data->bytes_xfered -= data->blksz;
753 }
754 }
755
756 wbsd_request_end(host, host->mrq);
757 }
758
759 /*****************************************************************************\
760 * *
761 * MMC layer callbacks *
762 * *
763 \*****************************************************************************/
764
765 static void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq)
766 {
767 struct wbsd_host *host = mmc_priv(mmc);
768 struct mmc_command *cmd;
769
770 /*
771 * Disable tasklets to avoid a deadlock.
772 */
773 spin_lock_bh(&host->lock);
774
775 BUG_ON(host->mrq != NULL);
776
777 cmd = mrq->cmd;
778
779 host->mrq = mrq;
780
781 /*
782 * Check that there is actually a card in the slot.
783 */
784 if (!(host->flags & WBSD_FCARD_PRESENT)) {
785 cmd->error = -ENOMEDIUM;
786 goto done;
787 }
788
789 if (cmd->data) {
790 /*
791 * The hardware is so delightfully stupid that it has a list
792 * of "data" commands. If a command isn't on this list, it'll
793 * just go back to the idle state and won't send any data
794 * interrupts.
795 */
796 switch (cmd->opcode) {
797 case 11:
798 case 17:
799 case 18:
800 case 20:
801 case 24:
802 case 25:
803 case 26:
804 case 27:
805 case 30:
806 case 42:
807 case 56:
808 break;
809
810 /* ACMDs. We don't keep track of state, so we just treat them
811 * like any other command. */
812 case 51:
813 break;
814
815 default:
816 #ifdef CONFIG_MMC_DEBUG
817 pr_warn("%s: Data command %d is not supported by this controller\n",
818 mmc_hostname(host->mmc), cmd->opcode);
819 #endif
820 cmd->error = -EINVAL;
821
822 goto done;
823 }
824 }
825
826 /*
827 * Does the request include data?
828 */
829 if (cmd->data) {
830 wbsd_prepare_data(host, cmd->data);
831
832 if (cmd->data->error)
833 goto done;
834 }
835
836 wbsd_send_command(host, cmd);
837
838 /*
839 * If this is a data transfer the request
840 * will be finished after the data has
841 * transferred.
842 */
843 if (cmd->data && !cmd->error) {
844 /*
845 * Dirty fix for hardware bug.
846 */
847 if (host->dma == -1)
848 tasklet_schedule(&host->fifo_tasklet);
849
850 spin_unlock_bh(&host->lock);
851
852 return;
853 }
854
855 done:
856 wbsd_request_end(host, mrq);
857
858 spin_unlock_bh(&host->lock);
859 }
860
861 static void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
862 {
863 struct wbsd_host *host = mmc_priv(mmc);
864 u8 clk, setup, pwr;
865
866 spin_lock_bh(&host->lock);
867
868 /*
869 * Reset the chip on each power off.
870 * Should clear out any weird states.
871 */
872 if (ios->power_mode == MMC_POWER_OFF)
873 wbsd_init_device(host);
874
875 if (ios->clock >= 24000000)
876 clk = WBSD_CLK_24M;
877 else if (ios->clock >= 16000000)
878 clk = WBSD_CLK_16M;
879 else if (ios->clock >= 12000000)
880 clk = WBSD_CLK_12M;
881 else
882 clk = WBSD_CLK_375K;
883
884 /*
885 * Only write to the clock register when
886 * there is an actual change.
887 */
888 if (clk != host->clk) {
889 wbsd_write_index(host, WBSD_IDX_CLK, clk);
890 host->clk = clk;
891 }
892
893 /*
894 * Power up card.
895 */
896 if (ios->power_mode != MMC_POWER_OFF) {
897 pwr = inb(host->base + WBSD_CSR);
898 pwr &= ~WBSD_POWER_N;
899 outb(pwr, host->base + WBSD_CSR);
900 }
901
902 /*
903 * MMC cards need to have pin 1 high during init.
904 * It wreaks havoc with the card detection though so
905 * that needs to be disabled.
906 */
907 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
908 if (ios->chip_select == MMC_CS_HIGH) {
909 BUG_ON(ios->bus_width != MMC_BUS_WIDTH_1);
910 setup |= WBSD_DAT3_H;
911 host->flags |= WBSD_FIGNORE_DETECT;
912 } else {
913 if (setup & WBSD_DAT3_H) {
914 setup &= ~WBSD_DAT3_H;
915
916 /*
917 * We cannot resume card detection immediately
918 * because of capacitance and delays in the chip.
919 */
920 mod_timer(&host->ignore_timer, jiffies + HZ / 100);
921 }
922 }
923 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
924
925 /*
926 * Store bus width for later. Will be used when
927 * setting up the data transfer.
928 */
929 host->bus_width = ios->bus_width;
930
931 spin_unlock_bh(&host->lock);
932 }
933
934 static int wbsd_get_ro(struct mmc_host *mmc)
935 {
936 struct wbsd_host *host = mmc_priv(mmc);
937 u8 csr;
938
939 spin_lock_bh(&host->lock);
940
941 csr = inb(host->base + WBSD_CSR);
942 csr |= WBSD_MSLED;
943 outb(csr, host->base + WBSD_CSR);
944
945 mdelay(1);
946
947 csr = inb(host->base + WBSD_CSR);
948 csr &= ~WBSD_MSLED;
949 outb(csr, host->base + WBSD_CSR);
950
951 spin_unlock_bh(&host->lock);
952
953 return !!(csr & WBSD_WRPT);
954 }
955
956 static const struct mmc_host_ops wbsd_ops = {
957 .request = wbsd_request,
958 .set_ios = wbsd_set_ios,
959 .get_ro = wbsd_get_ro,
960 };
961
962 /*****************************************************************************\
963 * *
964 * Interrupt handling *
965 * *
966 \*****************************************************************************/
967
968 /*
969 * Helper function to reset detection ignore
970 */
971
972 static void wbsd_reset_ignore(unsigned long data)
973 {
974 struct wbsd_host *host = (struct wbsd_host *)data;
975
976 BUG_ON(host == NULL);
977
978 DBG("Resetting card detection ignore\n");
979
980 spin_lock_bh(&host->lock);
981
982 host->flags &= ~WBSD_FIGNORE_DETECT;
983
984 /*
985 * Card status might have changed during the
986 * blackout.
987 */
988 tasklet_schedule(&host->card_tasklet);
989
990 spin_unlock_bh(&host->lock);
991 }
992
993 /*
994 * Tasklets
995 */
996
997 static inline struct mmc_data *wbsd_get_data(struct wbsd_host *host)
998 {
999 WARN_ON(!host->mrq);
1000 if (!host->mrq)
1001 return NULL;
1002
1003 WARN_ON(!host->mrq->cmd);
1004 if (!host->mrq->cmd)
1005 return NULL;
1006
1007 WARN_ON(!host->mrq->cmd->data);
1008 if (!host->mrq->cmd->data)
1009 return NULL;
1010
1011 return host->mrq->cmd->data;
1012 }
1013
1014 static void wbsd_tasklet_card(unsigned long param)
1015 {
1016 struct wbsd_host *host = (struct wbsd_host *)param;
1017 u8 csr;
1018 int delay = -1;
1019
1020 spin_lock(&host->lock);
1021
1022 if (host->flags & WBSD_FIGNORE_DETECT) {
1023 spin_unlock(&host->lock);
1024 return;
1025 }
1026
1027 csr = inb(host->base + WBSD_CSR);
1028 WARN_ON(csr == 0xff);
1029
1030 if (csr & WBSD_CARDPRESENT) {
1031 if (!(host->flags & WBSD_FCARD_PRESENT)) {
1032 DBG("Card inserted\n");
1033 host->flags |= WBSD_FCARD_PRESENT;
1034
1035 delay = 500;
1036 }
1037 } else if (host->flags & WBSD_FCARD_PRESENT) {
1038 DBG("Card removed\n");
1039 host->flags &= ~WBSD_FCARD_PRESENT;
1040
1041 if (host->mrq) {
1042 pr_err("%s: Card removed during transfer!\n",
1043 mmc_hostname(host->mmc));
1044 wbsd_reset(host);
1045
1046 host->mrq->cmd->error = -ENOMEDIUM;
1047 tasklet_schedule(&host->finish_tasklet);
1048 }
1049
1050 delay = 0;
1051 }
1052
1053 /*
1054 * Unlock first since we might get a call back.
1055 */
1056
1057 spin_unlock(&host->lock);
1058
1059 if (delay != -1)
1060 mmc_detect_change(host->mmc, msecs_to_jiffies(delay));
1061 }
1062
1063 static void wbsd_tasklet_fifo(unsigned long param)
1064 {
1065 struct wbsd_host *host = (struct wbsd_host *)param;
1066 struct mmc_data *data;
1067
1068 spin_lock(&host->lock);
1069
1070 if (!host->mrq)
1071 goto end;
1072
1073 data = wbsd_get_data(host);
1074 if (!data)
1075 goto end;
1076
1077 if (data->flags & MMC_DATA_WRITE)
1078 wbsd_fill_fifo(host);
1079 else
1080 wbsd_empty_fifo(host);
1081
1082 /*
1083 * Done?
1084 */
1085 if (host->num_sg == 0) {
1086 wbsd_write_index(host, WBSD_IDX_FIFOEN, 0);
1087 tasklet_schedule(&host->finish_tasklet);
1088 }
1089
1090 end:
1091 spin_unlock(&host->lock);
1092 }
1093
1094 static void wbsd_tasklet_crc(unsigned long param)
1095 {
1096 struct wbsd_host *host = (struct wbsd_host *)param;
1097 struct mmc_data *data;
1098
1099 spin_lock(&host->lock);
1100
1101 if (!host->mrq)
1102 goto end;
1103
1104 data = wbsd_get_data(host);
1105 if (!data)
1106 goto end;
1107
1108 DBGF("CRC error\n");
1109
1110 data->error = -EILSEQ;
1111
1112 tasklet_schedule(&host->finish_tasklet);
1113
1114 end:
1115 spin_unlock(&host->lock);
1116 }
1117
1118 static void wbsd_tasklet_timeout(unsigned long param)
1119 {
1120 struct wbsd_host *host = (struct wbsd_host *)param;
1121 struct mmc_data *data;
1122
1123 spin_lock(&host->lock);
1124
1125 if (!host->mrq)
1126 goto end;
1127
1128 data = wbsd_get_data(host);
1129 if (!data)
1130 goto end;
1131
1132 DBGF("Timeout\n");
1133
1134 data->error = -ETIMEDOUT;
1135
1136 tasklet_schedule(&host->finish_tasklet);
1137
1138 end:
1139 spin_unlock(&host->lock);
1140 }
1141
1142 static void wbsd_tasklet_finish(unsigned long param)
1143 {
1144 struct wbsd_host *host = (struct wbsd_host *)param;
1145 struct mmc_data *data;
1146
1147 spin_lock(&host->lock);
1148
1149 WARN_ON(!host->mrq);
1150 if (!host->mrq)
1151 goto end;
1152
1153 data = wbsd_get_data(host);
1154 if (!data)
1155 goto end;
1156
1157 wbsd_finish_data(host, data);
1158
1159 end:
1160 spin_unlock(&host->lock);
1161 }
1162
1163 /*
1164 * Interrupt handling
1165 */
1166
1167 static irqreturn_t wbsd_irq(int irq, void *dev_id)
1168 {
1169 struct wbsd_host *host = dev_id;
1170 int isr;
1171
1172 isr = inb(host->base + WBSD_ISR);
1173
1174 /*
1175 * Was it actually our hardware that caused the interrupt?
1176 */
1177 if (isr == 0xff || isr == 0x00)
1178 return IRQ_NONE;
1179
1180 host->isr |= isr;
1181
1182 /*
1183 * Schedule tasklets as needed.
1184 */
1185 if (isr & WBSD_INT_CARD)
1186 tasklet_schedule(&host->card_tasklet);
1187 if (isr & WBSD_INT_FIFO_THRE)
1188 tasklet_schedule(&host->fifo_tasklet);
1189 if (isr & WBSD_INT_CRC)
1190 tasklet_hi_schedule(&host->crc_tasklet);
1191 if (isr & WBSD_INT_TIMEOUT)
1192 tasklet_hi_schedule(&host->timeout_tasklet);
1193 if (isr & WBSD_INT_TC)
1194 tasklet_schedule(&host->finish_tasklet);
1195
1196 return IRQ_HANDLED;
1197 }
1198
1199 /*****************************************************************************\
1200 * *
1201 * Device initialisation and shutdown *
1202 * *
1203 \*****************************************************************************/
1204
1205 /*
1206 * Allocate/free MMC structure.
1207 */
1208
1209 static int wbsd_alloc_mmc(struct device *dev)
1210 {
1211 struct mmc_host *mmc;
1212 struct wbsd_host *host;
1213
1214 /*
1215 * Allocate MMC structure.
1216 */
1217 mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev);
1218 if (!mmc)
1219 return -ENOMEM;
1220
1221 host = mmc_priv(mmc);
1222 host->mmc = mmc;
1223
1224 host->dma = -1;
1225
1226 /*
1227 * Set host parameters.
1228 */
1229 mmc->ops = &wbsd_ops;
1230 mmc->f_min = 375000;
1231 mmc->f_max = 24000000;
1232 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
1233 mmc->caps = MMC_CAP_4_BIT_DATA;
1234
1235 spin_lock_init(&host->lock);
1236
1237 /*
1238 * Set up timers
1239 */
1240 init_timer(&host->ignore_timer);
1241 host->ignore_timer.data = (unsigned long)host;
1242 host->ignore_timer.function = wbsd_reset_ignore;
1243
1244 /*
1245 * Maximum number of segments. Worst case is one sector per segment
1246 * so this will be 64kB/512.
1247 */
1248 mmc->max_segs = 128;
1249
1250 /*
1251 * Maximum request size. Also limited by 64KiB buffer.
1252 */
1253 mmc->max_req_size = 65536;
1254
1255 /*
1256 * Maximum segment size. Could be one segment with the maximum number
1257 * of bytes.
1258 */
1259 mmc->max_seg_size = mmc->max_req_size;
1260
1261 /*
1262 * Maximum block size. We have 12 bits (= 4095) but have to subtract
1263 * space for CRC. So the maximum is 4095 - 4*2 = 4087.
1264 */
1265 mmc->max_blk_size = 4087;
1266
1267 /*
1268 * Maximum block count. There is no real limit so the maximum
1269 * request size will be the only restriction.
1270 */
1271 mmc->max_blk_count = mmc->max_req_size;
1272
1273 dev_set_drvdata(dev, mmc);
1274
1275 return 0;
1276 }
1277
1278 static void wbsd_free_mmc(struct device *dev)
1279 {
1280 struct mmc_host *mmc;
1281 struct wbsd_host *host;
1282
1283 mmc = dev_get_drvdata(dev);
1284 if (!mmc)
1285 return;
1286
1287 host = mmc_priv(mmc);
1288 BUG_ON(host == NULL);
1289
1290 del_timer_sync(&host->ignore_timer);
1291
1292 mmc_free_host(mmc);
1293
1294 dev_set_drvdata(dev, NULL);
1295 }
1296
1297 /*
1298 * Scan for known chip id:s
1299 */
1300
1301 static int wbsd_scan(struct wbsd_host *host)
1302 {
1303 int i, j, k;
1304 int id;
1305
1306 /*
1307 * Iterate through all ports, all codes to
1308 * find hardware that is in our known list.
1309 */
1310 for (i = 0; i < ARRAY_SIZE(config_ports); i++) {
1311 if (!request_region(config_ports[i], 2, DRIVER_NAME))
1312 continue;
1313
1314 for (j = 0; j < ARRAY_SIZE(unlock_codes); j++) {
1315 id = 0xFFFF;
1316
1317 host->config = config_ports[i];
1318 host->unlock_code = unlock_codes[j];
1319
1320 wbsd_unlock_config(host);
1321
1322 outb(WBSD_CONF_ID_HI, config_ports[i]);
1323 id = inb(config_ports[i] + 1) << 8;
1324
1325 outb(WBSD_CONF_ID_LO, config_ports[i]);
1326 id |= inb(config_ports[i] + 1);
1327
1328 wbsd_lock_config(host);
1329
1330 for (k = 0; k < ARRAY_SIZE(valid_ids); k++) {
1331 if (id == valid_ids[k]) {
1332 host->chip_id = id;
1333
1334 return 0;
1335 }
1336 }
1337
1338 if (id != 0xFFFF) {
1339 DBG("Unknown hardware (id %x) found at %x\n",
1340 id, config_ports[i]);
1341 }
1342 }
1343
1344 release_region(config_ports[i], 2);
1345 }
1346
1347 host->config = 0;
1348 host->unlock_code = 0;
1349
1350 return -ENODEV;
1351 }
1352
1353 /*
1354 * Allocate/free io port ranges
1355 */
1356
1357 static int wbsd_request_region(struct wbsd_host *host, int base)
1358 {
1359 if (base & 0x7)
1360 return -EINVAL;
1361
1362 if (!request_region(base, 8, DRIVER_NAME))
1363 return -EIO;
1364
1365 host->base = base;
1366
1367 return 0;
1368 }
1369
1370 static void wbsd_release_regions(struct wbsd_host *host)
1371 {
1372 if (host->base)
1373 release_region(host->base, 8);
1374
1375 host->base = 0;
1376
1377 if (host->config)
1378 release_region(host->config, 2);
1379
1380 host->config = 0;
1381 }
1382
1383 /*
1384 * Allocate/free DMA port and buffer
1385 */
1386
1387 static void wbsd_request_dma(struct wbsd_host *host, int dma)
1388 {
1389 if (dma < 0)
1390 return;
1391
1392 if (request_dma(dma, DRIVER_NAME))
1393 goto err;
1394
1395 /*
1396 * We need to allocate a special buffer in
1397 * order for ISA to be able to DMA to it.
1398 */
1399 host->dma_buffer = kmalloc(WBSD_DMA_SIZE,
1400 GFP_NOIO | GFP_DMA | __GFP_REPEAT | __GFP_NOWARN);
1401 if (!host->dma_buffer)
1402 goto free;
1403
1404 /*
1405 * Translate the address to a physical address.
1406 */
1407 host->dma_addr = dma_map_single(mmc_dev(host->mmc), host->dma_buffer,
1408 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1409 if (dma_mapping_error(mmc_dev(host->mmc), host->dma_addr))
1410 goto kfree;
1411
1412 /*
1413 * ISA DMA must be aligned on a 64k basis.
1414 */
1415 if ((host->dma_addr & 0xffff) != 0)
1416 goto unmap;
1417 /*
1418 * ISA cannot access memory above 16 MB.
1419 */
1420 else if (host->dma_addr >= 0x1000000)
1421 goto unmap;
1422
1423 host->dma = dma;
1424
1425 return;
1426
1427 unmap:
1428 /*
1429 * If we've gotten here then there is some kind of alignment bug
1430 */
1431 BUG_ON(1);
1432
1433 dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
1434 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1435 host->dma_addr = 0;
1436
1437 kfree:
1438 kfree(host->dma_buffer);
1439 host->dma_buffer = NULL;
1440
1441 free:
1442 free_dma(dma);
1443
1444 err:
1445 pr_warn(DRIVER_NAME ": Unable to allocate DMA %d - falling back on FIFO\n",
1446 dma);
1447 }
1448
1449 static void wbsd_release_dma(struct wbsd_host *host)
1450 {
1451 if (!dma_mapping_error(mmc_dev(host->mmc), host->dma_addr)) {
1452 dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
1453 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1454 }
1455 kfree(host->dma_buffer);
1456 if (host->dma >= 0)
1457 free_dma(host->dma);
1458
1459 host->dma = -1;
1460 host->dma_buffer = NULL;
1461 host->dma_addr = 0;
1462 }
1463
1464 /*
1465 * Allocate/free IRQ.
1466 */
1467
1468 static int wbsd_request_irq(struct wbsd_host *host, int irq)
1469 {
1470 int ret;
1471
1472 /*
1473 * Set up tasklets. Must be done before requesting interrupt.
1474 */
1475 tasklet_init(&host->card_tasklet, wbsd_tasklet_card,
1476 (unsigned long)host);
1477 tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo,
1478 (unsigned long)host);
1479 tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc,
1480 (unsigned long)host);
1481 tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout,
1482 (unsigned long)host);
1483 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish,
1484 (unsigned long)host);
1485
1486 /*
1487 * Allocate interrupt.
1488 */
1489 ret = request_irq(irq, wbsd_irq, IRQF_SHARED, DRIVER_NAME, host);
1490 if (ret)
1491 return ret;
1492
1493 host->irq = irq;
1494
1495 return 0;
1496 }
1497
1498 static void wbsd_release_irq(struct wbsd_host *host)
1499 {
1500 if (!host->irq)
1501 return;
1502
1503 free_irq(host->irq, host);
1504
1505 host->irq = 0;
1506
1507 tasklet_kill(&host->card_tasklet);
1508 tasklet_kill(&host->fifo_tasklet);
1509 tasklet_kill(&host->crc_tasklet);
1510 tasklet_kill(&host->timeout_tasklet);
1511 tasklet_kill(&host->finish_tasklet);
1512 }
1513
1514 /*
1515 * Allocate all resources for the host.
1516 */
1517
1518 static int wbsd_request_resources(struct wbsd_host *host,
1519 int base, int irq, int dma)
1520 {
1521 int ret;
1522
1523 /*
1524 * Allocate I/O ports.
1525 */
1526 ret = wbsd_request_region(host, base);
1527 if (ret)
1528 return ret;
1529
1530 /*
1531 * Allocate interrupt.
1532 */
1533 ret = wbsd_request_irq(host, irq);
1534 if (ret)
1535 return ret;
1536
1537 /*
1538 * Allocate DMA.
1539 */
1540 wbsd_request_dma(host, dma);
1541
1542 return 0;
1543 }
1544
1545 /*
1546 * Release all resources for the host.
1547 */
1548
1549 static void wbsd_release_resources(struct wbsd_host *host)
1550 {
1551 wbsd_release_dma(host);
1552 wbsd_release_irq(host);
1553 wbsd_release_regions(host);
1554 }
1555
1556 /*
1557 * Configure the resources the chip should use.
1558 */
1559
1560 static void wbsd_chip_config(struct wbsd_host *host)
1561 {
1562 wbsd_unlock_config(host);
1563
1564 /*
1565 * Reset the chip.
1566 */
1567 wbsd_write_config(host, WBSD_CONF_SWRST, 1);
1568 wbsd_write_config(host, WBSD_CONF_SWRST, 0);
1569
1570 /*
1571 * Select SD/MMC function.
1572 */
1573 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1574
1575 /*
1576 * Set up card detection.
1577 */
1578 wbsd_write_config(host, WBSD_CONF_PINS, WBSD_PINS_DETECT_GP11);
1579
1580 /*
1581 * Configure chip
1582 */
1583 wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8);
1584 wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff);
1585
1586 wbsd_write_config(host, WBSD_CONF_IRQ, host->irq);
1587
1588 if (host->dma >= 0)
1589 wbsd_write_config(host, WBSD_CONF_DRQ, host->dma);
1590
1591 /*
1592 * Enable and power up chip.
1593 */
1594 wbsd_write_config(host, WBSD_CONF_ENABLE, 1);
1595 wbsd_write_config(host, WBSD_CONF_POWER, 0x20);
1596
1597 wbsd_lock_config(host);
1598 }
1599
1600 /*
1601 * Check that configured resources are correct.
1602 */
1603
1604 static int wbsd_chip_validate(struct wbsd_host *host)
1605 {
1606 int base, irq, dma;
1607
1608 wbsd_unlock_config(host);
1609
1610 /*
1611 * Select SD/MMC function.
1612 */
1613 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1614
1615 /*
1616 * Read configuration.
1617 */
1618 base = wbsd_read_config(host, WBSD_CONF_PORT_HI) << 8;
1619 base |= wbsd_read_config(host, WBSD_CONF_PORT_LO);
1620
1621 irq = wbsd_read_config(host, WBSD_CONF_IRQ);
1622
1623 dma = wbsd_read_config(host, WBSD_CONF_DRQ);
1624
1625 wbsd_lock_config(host);
1626
1627 /*
1628 * Validate against given configuration.
1629 */
1630 if (base != host->base)
1631 return 0;
1632 if (irq != host->irq)
1633 return 0;
1634 if ((dma != host->dma) && (host->dma != -1))
1635 return 0;
1636
1637 return 1;
1638 }
1639
1640 /*
1641 * Powers down the SD function
1642 */
1643
1644 static void wbsd_chip_poweroff(struct wbsd_host *host)
1645 {
1646 wbsd_unlock_config(host);
1647
1648 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1649 wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
1650
1651 wbsd_lock_config(host);
1652 }
1653
1654 /*****************************************************************************\
1655 * *
1656 * Devices setup and shutdown *
1657 * *
1658 \*****************************************************************************/
1659
1660 static int wbsd_init(struct device *dev, int base, int irq, int dma,
1661 int pnp)
1662 {
1663 struct wbsd_host *host = NULL;
1664 struct mmc_host *mmc = NULL;
1665 int ret;
1666
1667 ret = wbsd_alloc_mmc(dev);
1668 if (ret)
1669 return ret;
1670
1671 mmc = dev_get_drvdata(dev);
1672 host = mmc_priv(mmc);
1673
1674 /*
1675 * Scan for hardware.
1676 */
1677 ret = wbsd_scan(host);
1678 if (ret) {
1679 if (pnp && (ret == -ENODEV)) {
1680 pr_warn(DRIVER_NAME ": Unable to confirm device presence - you may experience lock-ups\n");
1681 } else {
1682 wbsd_free_mmc(dev);
1683 return ret;
1684 }
1685 }
1686
1687 /*
1688 * Request resources.
1689 */
1690 ret = wbsd_request_resources(host, base, irq, dma);
1691 if (ret) {
1692 wbsd_release_resources(host);
1693 wbsd_free_mmc(dev);
1694 return ret;
1695 }
1696
1697 /*
1698 * See if chip needs to be configured.
1699 */
1700 if (pnp) {
1701 if ((host->config != 0) && !wbsd_chip_validate(host)) {
1702 pr_warn(DRIVER_NAME ": PnP active but chip not configured! You probably have a buggy BIOS. Configuring chip manually.\n");
1703 wbsd_chip_config(host);
1704 }
1705 } else
1706 wbsd_chip_config(host);
1707
1708 /*
1709 * Power Management stuff. No idea how this works.
1710 * Not tested.
1711 */
1712 #ifdef CONFIG_PM
1713 if (host->config) {
1714 wbsd_unlock_config(host);
1715 wbsd_write_config(host, WBSD_CONF_PME, 0xA0);
1716 wbsd_lock_config(host);
1717 }
1718 #endif
1719 /*
1720 * Allow device to initialise itself properly.
1721 */
1722 mdelay(5);
1723
1724 /*
1725 * Reset the chip into a known state.
1726 */
1727 wbsd_init_device(host);
1728
1729 mmc_add_host(mmc);
1730
1731 pr_info("%s: W83L51xD", mmc_hostname(mmc));
1732 if (host->chip_id != 0)
1733 printk(" id %x", (int)host->chip_id);
1734 printk(" at 0x%x irq %d", (int)host->base, (int)host->irq);
1735 if (host->dma >= 0)
1736 printk(" dma %d", (int)host->dma);
1737 else
1738 printk(" FIFO");
1739 if (pnp)
1740 printk(" PnP");
1741 printk("\n");
1742
1743 return 0;
1744 }
1745
1746 static void wbsd_shutdown(struct device *dev, int pnp)
1747 {
1748 struct mmc_host *mmc = dev_get_drvdata(dev);
1749 struct wbsd_host *host;
1750
1751 if (!mmc)
1752 return;
1753
1754 host = mmc_priv(mmc);
1755
1756 mmc_remove_host(mmc);
1757
1758 /*
1759 * Power down the SD/MMC function.
1760 */
1761 if (!pnp)
1762 wbsd_chip_poweroff(host);
1763
1764 wbsd_release_resources(host);
1765
1766 wbsd_free_mmc(dev);
1767 }
1768
1769 /*
1770 * Non-PnP
1771 */
1772
1773 static int wbsd_probe(struct platform_device *dev)
1774 {
1775 /* Use the module parameters for resources */
1776 return wbsd_init(&dev->dev, param_io, param_irq, param_dma, 0);
1777 }
1778
1779 static int wbsd_remove(struct platform_device *dev)
1780 {
1781 wbsd_shutdown(&dev->dev, 0);
1782
1783 return 0;
1784 }
1785
1786 /*
1787 * PnP
1788 */
1789
1790 #ifdef CONFIG_PNP
1791
1792 static int
1793 wbsd_pnp_probe(struct pnp_dev *pnpdev, const struct pnp_device_id *dev_id)
1794 {
1795 int io, irq, dma;
1796
1797 /*
1798 * Get resources from PnP layer.
1799 */
1800 io = pnp_port_start(pnpdev, 0);
1801 irq = pnp_irq(pnpdev, 0);
1802 if (pnp_dma_valid(pnpdev, 0))
1803 dma = pnp_dma(pnpdev, 0);
1804 else
1805 dma = -1;
1806
1807 DBGF("PnP resources: port %3x irq %d dma %d\n", io, irq, dma);
1808
1809 return wbsd_init(&pnpdev->dev, io, irq, dma, 1);
1810 }
1811
1812 static void wbsd_pnp_remove(struct pnp_dev *dev)
1813 {
1814 wbsd_shutdown(&dev->dev, 1);
1815 }
1816
1817 #endif /* CONFIG_PNP */
1818
1819 /*
1820 * Power management
1821 */
1822
1823 #ifdef CONFIG_PM
1824
1825 static int wbsd_platform_suspend(struct platform_device *dev,
1826 pm_message_t state)
1827 {
1828 struct mmc_host *mmc = platform_get_drvdata(dev);
1829 struct wbsd_host *host;
1830
1831 if (mmc == NULL)
1832 return 0;
1833
1834 DBGF("Suspending...\n");
1835
1836 host = mmc_priv(mmc);
1837
1838 wbsd_chip_poweroff(host);
1839 return 0;
1840 }
1841
1842 static int wbsd_platform_resume(struct platform_device *dev)
1843 {
1844 struct mmc_host *mmc = platform_get_drvdata(dev);
1845 struct wbsd_host *host;
1846
1847 if (mmc == NULL)
1848 return 0;
1849
1850 DBGF("Resuming...\n");
1851
1852 host = mmc_priv(mmc);
1853
1854 wbsd_chip_config(host);
1855
1856 /*
1857 * Allow device to initialise itself properly.
1858 */
1859 mdelay(5);
1860
1861 wbsd_init_device(host);
1862 return 0;
1863 }
1864
1865 #ifdef CONFIG_PNP
1866
1867 static int wbsd_pnp_suspend(struct pnp_dev *pnp_dev, pm_message_t state)
1868 {
1869 struct mmc_host *mmc = dev_get_drvdata(&pnp_dev->dev);
1870
1871 if (mmc == NULL)
1872 return 0;
1873
1874 DBGF("Suspending...\n");
1875 return 0;
1876 }
1877
1878 static int wbsd_pnp_resume(struct pnp_dev *pnp_dev)
1879 {
1880 struct mmc_host *mmc = dev_get_drvdata(&pnp_dev->dev);
1881 struct wbsd_host *host;
1882
1883 if (mmc == NULL)
1884 return 0;
1885
1886 DBGF("Resuming...\n");
1887
1888 host = mmc_priv(mmc);
1889
1890 /*
1891 * See if chip needs to be configured.
1892 */
1893 if (host->config != 0) {
1894 if (!wbsd_chip_validate(host)) {
1895 pr_warn(DRIVER_NAME ": PnP active but chip not configured! You probably have a buggy BIOS. Configuring chip manually.\n");
1896 wbsd_chip_config(host);
1897 }
1898 }
1899
1900 /*
1901 * Allow device to initialise itself properly.
1902 */
1903 mdelay(5);
1904
1905 wbsd_init_device(host);
1906 return 0;
1907 }
1908
1909 #endif /* CONFIG_PNP */
1910
1911 #else /* CONFIG_PM */
1912
1913 #define wbsd_platform_suspend NULL
1914 #define wbsd_platform_resume NULL
1915
1916 #define wbsd_pnp_suspend NULL
1917 #define wbsd_pnp_resume NULL
1918
1919 #endif /* CONFIG_PM */
1920
1921 static struct platform_device *wbsd_device;
1922
1923 static struct platform_driver wbsd_driver = {
1924 .probe = wbsd_probe,
1925 .remove = wbsd_remove,
1926
1927 .suspend = wbsd_platform_suspend,
1928 .resume = wbsd_platform_resume,
1929 .driver = {
1930 .name = DRIVER_NAME,
1931 },
1932 };
1933
1934 #ifdef CONFIG_PNP
1935
1936 static struct pnp_driver wbsd_pnp_driver = {
1937 .name = DRIVER_NAME,
1938 .id_table = pnp_dev_table,
1939 .probe = wbsd_pnp_probe,
1940 .remove = wbsd_pnp_remove,
1941
1942 .suspend = wbsd_pnp_suspend,
1943 .resume = wbsd_pnp_resume,
1944 };
1945
1946 #endif /* CONFIG_PNP */
1947
1948 /*
1949 * Module loading/unloading
1950 */
1951
1952 static int __init wbsd_drv_init(void)
1953 {
1954 int result;
1955
1956 pr_info(DRIVER_NAME
1957 ": Winbond W83L51xD SD/MMC card interface driver\n");
1958 pr_info(DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
1959
1960 #ifdef CONFIG_PNP
1961
1962 if (!param_nopnp) {
1963 result = pnp_register_driver(&wbsd_pnp_driver);
1964 if (result < 0)
1965 return result;
1966 }
1967 #endif /* CONFIG_PNP */
1968
1969 if (param_nopnp) {
1970 result = platform_driver_register(&wbsd_driver);
1971 if (result < 0)
1972 return result;
1973
1974 wbsd_device = platform_device_alloc(DRIVER_NAME, -1);
1975 if (!wbsd_device) {
1976 platform_driver_unregister(&wbsd_driver);
1977 return -ENOMEM;
1978 }
1979
1980 result = platform_device_add(wbsd_device);
1981 if (result) {
1982 platform_device_put(wbsd_device);
1983 platform_driver_unregister(&wbsd_driver);
1984 return result;
1985 }
1986 }
1987
1988 return 0;
1989 }
1990
1991 static void __exit wbsd_drv_exit(void)
1992 {
1993 #ifdef CONFIG_PNP
1994
1995 if (!param_nopnp)
1996 pnp_unregister_driver(&wbsd_pnp_driver);
1997
1998 #endif /* CONFIG_PNP */
1999
2000 if (param_nopnp) {
2001 platform_device_unregister(wbsd_device);
2002
2003 platform_driver_unregister(&wbsd_driver);
2004 }
2005
2006 DBG("unloaded\n");
2007 }
2008
2009 module_init(wbsd_drv_init);
2010 module_exit(wbsd_drv_exit);
2011 #ifdef CONFIG_PNP
2012 module_param_named(nopnp, param_nopnp, uint, 0444);
2013 #endif
2014 module_param_named(io, param_io, uint, 0444);
2015 module_param_named(irq, param_irq, uint, 0444);
2016 module_param_named(dma, param_dma, int, 0444);
2017
2018 MODULE_LICENSE("GPL");
2019 MODULE_AUTHOR("Pierre Ossman <pierre@ossman.eu>");
2020 MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver");
2021
2022 #ifdef CONFIG_PNP
2023 MODULE_PARM_DESC(nopnp, "Scan for device instead of relying on PNP. (default 0)");
2024 #endif
2025 MODULE_PARM_DESC(io, "I/O base to allocate. Must be 8 byte aligned. (default 0x248)");
2026 MODULE_PARM_DESC(irq, "IRQ to allocate. (default 6)");
2027 MODULE_PARM_DESC(dma, "DMA channel to allocate. -1 for no DMA. (default 2)");
2028
2029
2030
2031
2032
2033 /* LDV_COMMENT_BEGIN_MAIN */
2034 #ifdef LDV_MAIN0_sequence_infinite_withcheck_stateful
2035
2036 /*###########################################################################*/
2037
2038 /*############## Driver Environment Generator 0.2 output ####################*/
2039
2040 /*###########################################################################*/
2041
2042
2043
2044 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test if all kernel resources are correctly released by driver before driver will be unloaded. */
2045 void ldv_check_final_state(void);
2046
2047 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */
2048 void ldv_check_return_value(int res);
2049
2050 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */
2051 void ldv_check_return_value_probe(int res);
2052
2053 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */
2054 void ldv_initialize(void);
2055
2056 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */
2057 void ldv_handler_precall(void);
2058
2059 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */
2060 int nondet_int(void);
2061
2062 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */
2063 int LDV_IN_INTERRUPT;
2064
2065 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */
2066 void ldv_main0_sequence_infinite_withcheck_stateful(void) {
2067
2068
2069
2070 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */
2071 /*============================= VARIABLE DECLARATION PART =============================*/
2072 /** STRUCT: struct type: mmc_host_ops, struct name: wbsd_ops **/
2073 /* content: static void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq)*/
2074 /* LDV_COMMENT_BEGIN_PREP */
2075 #define DRIVER_NAME "wbsd"
2076 #define DBG(x...) \
2077 pr_debug(DRIVER_NAME ": " x)
2078 #define DBGF(f, x...) \
2079 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2080 #ifdef CONFIG_PNP
2081 #endif
2082 #ifdef CONFIG_PNP
2083 #else
2084 #endif
2085 /* LDV_COMMENT_END_PREP */
2086 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_request" */
2087 struct mmc_host * var_group1;
2088 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_request" */
2089 struct mmc_request * var_group2;
2090 /* LDV_COMMENT_BEGIN_PREP */
2091 #ifdef CONFIG_PM
2092 #endif
2093 #ifdef CONFIG_PNP
2094 #endif
2095 #ifdef CONFIG_PM
2096 #ifdef CONFIG_PNP
2097 #endif
2098 #else
2099 #define wbsd_platform_suspend NULL
2100 #define wbsd_platform_resume NULL
2101 #define wbsd_pnp_suspend NULL
2102 #define wbsd_pnp_resume NULL
2103 #endif
2104 #ifdef CONFIG_PNP
2105 #endif
2106 #ifdef CONFIG_PNP
2107 #endif
2108 #ifdef CONFIG_PNP
2109 #endif
2110 #ifdef CONFIG_PNP
2111 #endif
2112 #ifdef CONFIG_PNP
2113 #endif
2114 /* LDV_COMMENT_END_PREP */
2115 /* content: static void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)*/
2116 /* LDV_COMMENT_BEGIN_PREP */
2117 #define DRIVER_NAME "wbsd"
2118 #define DBG(x...) \
2119 pr_debug(DRIVER_NAME ": " x)
2120 #define DBGF(f, x...) \
2121 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2122 #ifdef CONFIG_PNP
2123 #endif
2124 #ifdef CONFIG_PNP
2125 #else
2126 #endif
2127 #ifdef CONFIG_MMC_DEBUG
2128 #endif
2129 /* LDV_COMMENT_END_PREP */
2130 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_set_ios" */
2131 struct mmc_ios * var_group3;
2132 /* LDV_COMMENT_BEGIN_PREP */
2133 #ifdef CONFIG_PM
2134 #endif
2135 #ifdef CONFIG_PNP
2136 #endif
2137 #ifdef CONFIG_PM
2138 #ifdef CONFIG_PNP
2139 #endif
2140 #else
2141 #define wbsd_platform_suspend NULL
2142 #define wbsd_platform_resume NULL
2143 #define wbsd_pnp_suspend NULL
2144 #define wbsd_pnp_resume NULL
2145 #endif
2146 #ifdef CONFIG_PNP
2147 #endif
2148 #ifdef CONFIG_PNP
2149 #endif
2150 #ifdef CONFIG_PNP
2151 #endif
2152 #ifdef CONFIG_PNP
2153 #endif
2154 #ifdef CONFIG_PNP
2155 #endif
2156 /* LDV_COMMENT_END_PREP */
2157 /* content: static int wbsd_get_ro(struct mmc_host *mmc)*/
2158 /* LDV_COMMENT_BEGIN_PREP */
2159 #define DRIVER_NAME "wbsd"
2160 #define DBG(x...) \
2161 pr_debug(DRIVER_NAME ": " x)
2162 #define DBGF(f, x...) \
2163 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2164 #ifdef CONFIG_PNP
2165 #endif
2166 #ifdef CONFIG_PNP
2167 #else
2168 #endif
2169 #ifdef CONFIG_MMC_DEBUG
2170 #endif
2171 /* LDV_COMMENT_END_PREP */
2172 /* LDV_COMMENT_BEGIN_PREP */
2173 #ifdef CONFIG_PM
2174 #endif
2175 #ifdef CONFIG_PNP
2176 #endif
2177 #ifdef CONFIG_PM
2178 #ifdef CONFIG_PNP
2179 #endif
2180 #else
2181 #define wbsd_platform_suspend NULL
2182 #define wbsd_platform_resume NULL
2183 #define wbsd_pnp_suspend NULL
2184 #define wbsd_pnp_resume NULL
2185 #endif
2186 #ifdef CONFIG_PNP
2187 #endif
2188 #ifdef CONFIG_PNP
2189 #endif
2190 #ifdef CONFIG_PNP
2191 #endif
2192 #ifdef CONFIG_PNP
2193 #endif
2194 #ifdef CONFIG_PNP
2195 #endif
2196 /* LDV_COMMENT_END_PREP */
2197
2198 /** STRUCT: struct type: platform_driver, struct name: wbsd_driver **/
2199 /* content: static int wbsd_probe(struct platform_device *dev)*/
2200 /* LDV_COMMENT_BEGIN_PREP */
2201 #define DRIVER_NAME "wbsd"
2202 #define DBG(x...) \
2203 pr_debug(DRIVER_NAME ": " x)
2204 #define DBGF(f, x...) \
2205 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2206 #ifdef CONFIG_PNP
2207 #endif
2208 #ifdef CONFIG_PNP
2209 #else
2210 #endif
2211 #ifdef CONFIG_MMC_DEBUG
2212 #endif
2213 #ifdef CONFIG_PM
2214 #endif
2215 /* LDV_COMMENT_END_PREP */
2216 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_probe" */
2217 struct platform_device * var_group4;
2218 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "wbsd_probe" */
2219 static int res_wbsd_probe_48;
2220 /* LDV_COMMENT_BEGIN_PREP */
2221 #ifdef CONFIG_PNP
2222 #endif
2223 #ifdef CONFIG_PM
2224 #ifdef CONFIG_PNP
2225 #endif
2226 #else
2227 #define wbsd_platform_suspend NULL
2228 #define wbsd_platform_resume NULL
2229 #define wbsd_pnp_suspend NULL
2230 #define wbsd_pnp_resume NULL
2231 #endif
2232 #ifdef CONFIG_PNP
2233 #endif
2234 #ifdef CONFIG_PNP
2235 #endif
2236 #ifdef CONFIG_PNP
2237 #endif
2238 #ifdef CONFIG_PNP
2239 #endif
2240 #ifdef CONFIG_PNP
2241 #endif
2242 /* LDV_COMMENT_END_PREP */
2243 /* content: static int wbsd_remove(struct platform_device *dev)*/
2244 /* LDV_COMMENT_BEGIN_PREP */
2245 #define DRIVER_NAME "wbsd"
2246 #define DBG(x...) \
2247 pr_debug(DRIVER_NAME ": " x)
2248 #define DBGF(f, x...) \
2249 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2250 #ifdef CONFIG_PNP
2251 #endif
2252 #ifdef CONFIG_PNP
2253 #else
2254 #endif
2255 #ifdef CONFIG_MMC_DEBUG
2256 #endif
2257 #ifdef CONFIG_PM
2258 #endif
2259 /* LDV_COMMENT_END_PREP */
2260 /* LDV_COMMENT_BEGIN_PREP */
2261 #ifdef CONFIG_PNP
2262 #endif
2263 #ifdef CONFIG_PM
2264 #ifdef CONFIG_PNP
2265 #endif
2266 #else
2267 #define wbsd_platform_suspend NULL
2268 #define wbsd_platform_resume NULL
2269 #define wbsd_pnp_suspend NULL
2270 #define wbsd_pnp_resume NULL
2271 #endif
2272 #ifdef CONFIG_PNP
2273 #endif
2274 #ifdef CONFIG_PNP
2275 #endif
2276 #ifdef CONFIG_PNP
2277 #endif
2278 #ifdef CONFIG_PNP
2279 #endif
2280 #ifdef CONFIG_PNP
2281 #endif
2282 /* LDV_COMMENT_END_PREP */
2283 /* content: static int wbsd_platform_suspend(struct platform_device *dev, pm_message_t state)*/
2284 /* LDV_COMMENT_BEGIN_PREP */
2285 #define DRIVER_NAME "wbsd"
2286 #define DBG(x...) \
2287 pr_debug(DRIVER_NAME ": " x)
2288 #define DBGF(f, x...) \
2289 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2290 #ifdef CONFIG_PNP
2291 #endif
2292 #ifdef CONFIG_PNP
2293 #else
2294 #endif
2295 #ifdef CONFIG_MMC_DEBUG
2296 #endif
2297 #ifdef CONFIG_PM
2298 #endif
2299 #ifdef CONFIG_PNP
2300 #endif
2301 #ifdef CONFIG_PM
2302 /* LDV_COMMENT_END_PREP */
2303 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_platform_suspend" */
2304 pm_message_t var_wbsd_platform_suspend_52_p1;
2305 /* LDV_COMMENT_BEGIN_PREP */
2306 #ifdef CONFIG_PNP
2307 #endif
2308 #else
2309 #define wbsd_platform_suspend NULL
2310 #define wbsd_platform_resume NULL
2311 #define wbsd_pnp_suspend NULL
2312 #define wbsd_pnp_resume NULL
2313 #endif
2314 #ifdef CONFIG_PNP
2315 #endif
2316 #ifdef CONFIG_PNP
2317 #endif
2318 #ifdef CONFIG_PNP
2319 #endif
2320 #ifdef CONFIG_PNP
2321 #endif
2322 #ifdef CONFIG_PNP
2323 #endif
2324 /* LDV_COMMENT_END_PREP */
2325 /* content: static int wbsd_platform_resume(struct platform_device *dev)*/
2326 /* LDV_COMMENT_BEGIN_PREP */
2327 #define DRIVER_NAME "wbsd"
2328 #define DBG(x...) \
2329 pr_debug(DRIVER_NAME ": " x)
2330 #define DBGF(f, x...) \
2331 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2332 #ifdef CONFIG_PNP
2333 #endif
2334 #ifdef CONFIG_PNP
2335 #else
2336 #endif
2337 #ifdef CONFIG_MMC_DEBUG
2338 #endif
2339 #ifdef CONFIG_PM
2340 #endif
2341 #ifdef CONFIG_PNP
2342 #endif
2343 #ifdef CONFIG_PM
2344 /* LDV_COMMENT_END_PREP */
2345 /* LDV_COMMENT_BEGIN_PREP */
2346 #ifdef CONFIG_PNP
2347 #endif
2348 #else
2349 #define wbsd_platform_suspend NULL
2350 #define wbsd_platform_resume NULL
2351 #define wbsd_pnp_suspend NULL
2352 #define wbsd_pnp_resume NULL
2353 #endif
2354 #ifdef CONFIG_PNP
2355 #endif
2356 #ifdef CONFIG_PNP
2357 #endif
2358 #ifdef CONFIG_PNP
2359 #endif
2360 #ifdef CONFIG_PNP
2361 #endif
2362 #ifdef CONFIG_PNP
2363 #endif
2364 /* LDV_COMMENT_END_PREP */
2365
2366 /** STRUCT: struct type: pnp_driver, struct name: wbsd_pnp_driver **/
2367 /* content: static int wbsd_pnp_probe(struct pnp_dev *pnpdev, const struct pnp_device_id *dev_id)*/
2368 /* LDV_COMMENT_BEGIN_PREP */
2369 #define DRIVER_NAME "wbsd"
2370 #define DBG(x...) \
2371 pr_debug(DRIVER_NAME ": " x)
2372 #define DBGF(f, x...) \
2373 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2374 #ifdef CONFIG_PNP
2375 #endif
2376 #ifdef CONFIG_PNP
2377 #else
2378 #endif
2379 #ifdef CONFIG_MMC_DEBUG
2380 #endif
2381 #ifdef CONFIG_PM
2382 #endif
2383 #ifdef CONFIG_PNP
2384 /* LDV_COMMENT_END_PREP */
2385 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_pnp_probe" */
2386 struct pnp_dev * var_group5;
2387 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_pnp_probe" */
2388 const struct pnp_device_id * var_wbsd_pnp_probe_50_p1;
2389 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "wbsd_pnp_probe" */
2390 static int res_wbsd_pnp_probe_50;
2391 /* LDV_COMMENT_BEGIN_PREP */
2392 #endif
2393 #ifdef CONFIG_PM
2394 #ifdef CONFIG_PNP
2395 #endif
2396 #else
2397 #define wbsd_platform_suspend NULL
2398 #define wbsd_platform_resume NULL
2399 #define wbsd_pnp_suspend NULL
2400 #define wbsd_pnp_resume NULL
2401 #endif
2402 #ifdef CONFIG_PNP
2403 #endif
2404 #ifdef CONFIG_PNP
2405 #endif
2406 #ifdef CONFIG_PNP
2407 #endif
2408 #ifdef CONFIG_PNP
2409 #endif
2410 #ifdef CONFIG_PNP
2411 #endif
2412 /* LDV_COMMENT_END_PREP */
2413 /* content: static void wbsd_pnp_remove(struct pnp_dev *dev)*/
2414 /* LDV_COMMENT_BEGIN_PREP */
2415 #define DRIVER_NAME "wbsd"
2416 #define DBG(x...) \
2417 pr_debug(DRIVER_NAME ": " x)
2418 #define DBGF(f, x...) \
2419 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2420 #ifdef CONFIG_PNP
2421 #endif
2422 #ifdef CONFIG_PNP
2423 #else
2424 #endif
2425 #ifdef CONFIG_MMC_DEBUG
2426 #endif
2427 #ifdef CONFIG_PM
2428 #endif
2429 #ifdef CONFIG_PNP
2430 /* LDV_COMMENT_END_PREP */
2431 /* LDV_COMMENT_BEGIN_PREP */
2432 #endif
2433 #ifdef CONFIG_PM
2434 #ifdef CONFIG_PNP
2435 #endif
2436 #else
2437 #define wbsd_platform_suspend NULL
2438 #define wbsd_platform_resume NULL
2439 #define wbsd_pnp_suspend NULL
2440 #define wbsd_pnp_resume NULL
2441 #endif
2442 #ifdef CONFIG_PNP
2443 #endif
2444 #ifdef CONFIG_PNP
2445 #endif
2446 #ifdef CONFIG_PNP
2447 #endif
2448 #ifdef CONFIG_PNP
2449 #endif
2450 #ifdef CONFIG_PNP
2451 #endif
2452 /* LDV_COMMENT_END_PREP */
2453 /* content: static int wbsd_pnp_suspend(struct pnp_dev *pnp_dev, pm_message_t state)*/
2454 /* LDV_COMMENT_BEGIN_PREP */
2455 #define DRIVER_NAME "wbsd"
2456 #define DBG(x...) \
2457 pr_debug(DRIVER_NAME ": " x)
2458 #define DBGF(f, x...) \
2459 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2460 #ifdef CONFIG_PNP
2461 #endif
2462 #ifdef CONFIG_PNP
2463 #else
2464 #endif
2465 #ifdef CONFIG_MMC_DEBUG
2466 #endif
2467 #ifdef CONFIG_PM
2468 #endif
2469 #ifdef CONFIG_PNP
2470 #endif
2471 #ifdef CONFIG_PM
2472 #ifdef CONFIG_PNP
2473 /* LDV_COMMENT_END_PREP */
2474 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_pnp_suspend" */
2475 pm_message_t var_wbsd_pnp_suspend_54_p1;
2476 /* LDV_COMMENT_BEGIN_PREP */
2477 #endif
2478 #else
2479 #define wbsd_platform_suspend NULL
2480 #define wbsd_platform_resume NULL
2481 #define wbsd_pnp_suspend NULL
2482 #define wbsd_pnp_resume NULL
2483 #endif
2484 #ifdef CONFIG_PNP
2485 #endif
2486 #ifdef CONFIG_PNP
2487 #endif
2488 #ifdef CONFIG_PNP
2489 #endif
2490 #ifdef CONFIG_PNP
2491 #endif
2492 #ifdef CONFIG_PNP
2493 #endif
2494 /* LDV_COMMENT_END_PREP */
2495 /* content: static int wbsd_pnp_resume(struct pnp_dev *pnp_dev)*/
2496 /* LDV_COMMENT_BEGIN_PREP */
2497 #define DRIVER_NAME "wbsd"
2498 #define DBG(x...) \
2499 pr_debug(DRIVER_NAME ": " x)
2500 #define DBGF(f, x...) \
2501 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2502 #ifdef CONFIG_PNP
2503 #endif
2504 #ifdef CONFIG_PNP
2505 #else
2506 #endif
2507 #ifdef CONFIG_MMC_DEBUG
2508 #endif
2509 #ifdef CONFIG_PM
2510 #endif
2511 #ifdef CONFIG_PNP
2512 #endif
2513 #ifdef CONFIG_PM
2514 #ifdef CONFIG_PNP
2515 /* LDV_COMMENT_END_PREP */
2516 /* LDV_COMMENT_BEGIN_PREP */
2517 #endif
2518 #else
2519 #define wbsd_platform_suspend NULL
2520 #define wbsd_platform_resume NULL
2521 #define wbsd_pnp_suspend NULL
2522 #define wbsd_pnp_resume NULL
2523 #endif
2524 #ifdef CONFIG_PNP
2525 #endif
2526 #ifdef CONFIG_PNP
2527 #endif
2528 #ifdef CONFIG_PNP
2529 #endif
2530 #ifdef CONFIG_PNP
2531 #endif
2532 #ifdef CONFIG_PNP
2533 #endif
2534 /* LDV_COMMENT_END_PREP */
2535
2536 /** CALLBACK SECTION request_irq **/
2537 /* content: static irqreturn_t wbsd_irq(int irq, void *dev_id)*/
2538 /* LDV_COMMENT_BEGIN_PREP */
2539 #define DRIVER_NAME "wbsd"
2540 #define DBG(x...) \
2541 pr_debug(DRIVER_NAME ": " x)
2542 #define DBGF(f, x...) \
2543 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2544 #ifdef CONFIG_PNP
2545 #endif
2546 #ifdef CONFIG_PNP
2547 #else
2548 #endif
2549 #ifdef CONFIG_MMC_DEBUG
2550 #endif
2551 /* LDV_COMMENT_END_PREP */
2552 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_irq" */
2553 int var_wbsd_irq_31_p0;
2554 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_irq" */
2555 void * var_wbsd_irq_31_p1;
2556 /* LDV_COMMENT_BEGIN_PREP */
2557 #ifdef CONFIG_PM
2558 #endif
2559 #ifdef CONFIG_PNP
2560 #endif
2561 #ifdef CONFIG_PM
2562 #ifdef CONFIG_PNP
2563 #endif
2564 #else
2565 #define wbsd_platform_suspend NULL
2566 #define wbsd_platform_resume NULL
2567 #define wbsd_pnp_suspend NULL
2568 #define wbsd_pnp_resume NULL
2569 #endif
2570 #ifdef CONFIG_PNP
2571 #endif
2572 #ifdef CONFIG_PNP
2573 #endif
2574 #ifdef CONFIG_PNP
2575 #endif
2576 #ifdef CONFIG_PNP
2577 #endif
2578 #ifdef CONFIG_PNP
2579 #endif
2580 /* LDV_COMMENT_END_PREP */
2581
2582 /** TIMER SECTION timer **/
2583 /* content: static void wbsd_reset_ignore(unsigned long data)*/
2584 /* LDV_COMMENT_BEGIN_PREP */
2585 #define DRIVER_NAME "wbsd"
2586 #define DBG(x...) \
2587 pr_debug(DRIVER_NAME ": " x)
2588 #define DBGF(f, x...) \
2589 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2590 #ifdef CONFIG_PNP
2591 #endif
2592 #ifdef CONFIG_PNP
2593 #else
2594 #endif
2595 #ifdef CONFIG_MMC_DEBUG
2596 #endif
2597 /* LDV_COMMENT_END_PREP */
2598 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "wbsd_reset_ignore" */
2599 unsigned long var_wbsd_reset_ignore_24_p0;
2600 /* LDV_COMMENT_BEGIN_PREP */
2601 #ifdef CONFIG_PM
2602 #endif
2603 #ifdef CONFIG_PNP
2604 #endif
2605 #ifdef CONFIG_PM
2606 #ifdef CONFIG_PNP
2607 #endif
2608 #else
2609 #define wbsd_platform_suspend NULL
2610 #define wbsd_platform_resume NULL
2611 #define wbsd_pnp_suspend NULL
2612 #define wbsd_pnp_resume NULL
2613 #endif
2614 #ifdef CONFIG_PNP
2615 #endif
2616 #ifdef CONFIG_PNP
2617 #endif
2618 #ifdef CONFIG_PNP
2619 #endif
2620 #ifdef CONFIG_PNP
2621 #endif
2622 #ifdef CONFIG_PNP
2623 #endif
2624 /* LDV_COMMENT_END_PREP */
2625
2626
2627
2628
2629 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */
2630 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */
2631 /*============================= VARIABLE INITIALIZING PART =============================*/
2632 LDV_IN_INTERRUPT=1;
2633
2634
2635
2636
2637 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */
2638 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */
2639 /*============================= FUNCTION CALL SECTION =============================*/
2640 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */
2641 ldv_initialize();
2642
2643 /** INIT: init_type: ST_MODULE_INIT **/
2644 /* content: static int __init wbsd_drv_init(void)*/
2645 /* LDV_COMMENT_BEGIN_PREP */
2646 #define DRIVER_NAME "wbsd"
2647 #define DBG(x...) \
2648 pr_debug(DRIVER_NAME ": " x)
2649 #define DBGF(f, x...) \
2650 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2651 #ifdef CONFIG_PNP
2652 #endif
2653 #ifdef CONFIG_PNP
2654 #else
2655 #endif
2656 #ifdef CONFIG_MMC_DEBUG
2657 #endif
2658 #ifdef CONFIG_PM
2659 #endif
2660 #ifdef CONFIG_PNP
2661 #endif
2662 #ifdef CONFIG_PM
2663 #ifdef CONFIG_PNP
2664 #endif
2665 #else
2666 #define wbsd_platform_suspend NULL
2667 #define wbsd_platform_resume NULL
2668 #define wbsd_pnp_suspend NULL
2669 #define wbsd_pnp_resume NULL
2670 #endif
2671 #ifdef CONFIG_PNP
2672 #endif
2673 /* LDV_COMMENT_END_PREP */
2674 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver init function after driver loading to kernel. This function declared as "MODULE_INIT(function name)". */
2675 ldv_handler_precall();
2676 if(wbsd_drv_init())
2677 goto ldv_final;
2678 /* LDV_COMMENT_BEGIN_PREP */
2679 #ifdef CONFIG_PNP
2680 #endif
2681 #ifdef CONFIG_PNP
2682 #endif
2683 #ifdef CONFIG_PNP
2684 #endif
2685 /* LDV_COMMENT_END_PREP */
2686
2687
2688 int ldv_s_wbsd_driver_platform_driver = 0;
2689
2690 int ldv_s_wbsd_pnp_driver_pnp_driver = 0;
2691
2692
2693
2694
2695
2696
2697
2698 while( nondet_int()
2699 || !(ldv_s_wbsd_driver_platform_driver == 0)
2700 || !(ldv_s_wbsd_pnp_driver_pnp_driver == 0)
2701 ) {
2702
2703 switch(nondet_int()) {
2704
2705 case 0: {
2706
2707 /** STRUCT: struct type: mmc_host_ops, struct name: wbsd_ops **/
2708
2709
2710 /* content: static void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq)*/
2711 /* LDV_COMMENT_BEGIN_PREP */
2712 #define DRIVER_NAME "wbsd"
2713 #define DBG(x...) \
2714 pr_debug(DRIVER_NAME ": " x)
2715 #define DBGF(f, x...) \
2716 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2717 #ifdef CONFIG_PNP
2718 #endif
2719 #ifdef CONFIG_PNP
2720 #else
2721 #endif
2722 /* LDV_COMMENT_END_PREP */
2723 /* LDV_COMMENT_FUNCTION_CALL Function from field "request" from driver structure with callbacks "wbsd_ops" */
2724 ldv_handler_precall();
2725 wbsd_request( var_group1, var_group2);
2726 /* LDV_COMMENT_BEGIN_PREP */
2727 #ifdef CONFIG_PM
2728 #endif
2729 #ifdef CONFIG_PNP
2730 #endif
2731 #ifdef CONFIG_PM
2732 #ifdef CONFIG_PNP
2733 #endif
2734 #else
2735 #define wbsd_platform_suspend NULL
2736 #define wbsd_platform_resume NULL
2737 #define wbsd_pnp_suspend NULL
2738 #define wbsd_pnp_resume NULL
2739 #endif
2740 #ifdef CONFIG_PNP
2741 #endif
2742 #ifdef CONFIG_PNP
2743 #endif
2744 #ifdef CONFIG_PNP
2745 #endif
2746 #ifdef CONFIG_PNP
2747 #endif
2748 #ifdef CONFIG_PNP
2749 #endif
2750 /* LDV_COMMENT_END_PREP */
2751
2752
2753
2754
2755 }
2756
2757 break;
2758 case 1: {
2759
2760 /** STRUCT: struct type: mmc_host_ops, struct name: wbsd_ops **/
2761
2762
2763 /* content: static void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)*/
2764 /* LDV_COMMENT_BEGIN_PREP */
2765 #define DRIVER_NAME "wbsd"
2766 #define DBG(x...) \
2767 pr_debug(DRIVER_NAME ": " x)
2768 #define DBGF(f, x...) \
2769 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2770 #ifdef CONFIG_PNP
2771 #endif
2772 #ifdef CONFIG_PNP
2773 #else
2774 #endif
2775 #ifdef CONFIG_MMC_DEBUG
2776 #endif
2777 /* LDV_COMMENT_END_PREP */
2778 /* LDV_COMMENT_FUNCTION_CALL Function from field "set_ios" from driver structure with callbacks "wbsd_ops" */
2779 ldv_handler_precall();
2780 wbsd_set_ios( var_group1, var_group3);
2781 /* LDV_COMMENT_BEGIN_PREP */
2782 #ifdef CONFIG_PM
2783 #endif
2784 #ifdef CONFIG_PNP
2785 #endif
2786 #ifdef CONFIG_PM
2787 #ifdef CONFIG_PNP
2788 #endif
2789 #else
2790 #define wbsd_platform_suspend NULL
2791 #define wbsd_platform_resume NULL
2792 #define wbsd_pnp_suspend NULL
2793 #define wbsd_pnp_resume NULL
2794 #endif
2795 #ifdef CONFIG_PNP
2796 #endif
2797 #ifdef CONFIG_PNP
2798 #endif
2799 #ifdef CONFIG_PNP
2800 #endif
2801 #ifdef CONFIG_PNP
2802 #endif
2803 #ifdef CONFIG_PNP
2804 #endif
2805 /* LDV_COMMENT_END_PREP */
2806
2807
2808
2809
2810 }
2811
2812 break;
2813 case 2: {
2814
2815 /** STRUCT: struct type: mmc_host_ops, struct name: wbsd_ops **/
2816
2817
2818 /* content: static int wbsd_get_ro(struct mmc_host *mmc)*/
2819 /* LDV_COMMENT_BEGIN_PREP */
2820 #define DRIVER_NAME "wbsd"
2821 #define DBG(x...) \
2822 pr_debug(DRIVER_NAME ": " x)
2823 #define DBGF(f, x...) \
2824 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2825 #ifdef CONFIG_PNP
2826 #endif
2827 #ifdef CONFIG_PNP
2828 #else
2829 #endif
2830 #ifdef CONFIG_MMC_DEBUG
2831 #endif
2832 /* LDV_COMMENT_END_PREP */
2833 /* LDV_COMMENT_FUNCTION_CALL Function from field "get_ro" from driver structure with callbacks "wbsd_ops" */
2834 ldv_handler_precall();
2835 wbsd_get_ro( var_group1);
2836 /* LDV_COMMENT_BEGIN_PREP */
2837 #ifdef CONFIG_PM
2838 #endif
2839 #ifdef CONFIG_PNP
2840 #endif
2841 #ifdef CONFIG_PM
2842 #ifdef CONFIG_PNP
2843 #endif
2844 #else
2845 #define wbsd_platform_suspend NULL
2846 #define wbsd_platform_resume NULL
2847 #define wbsd_pnp_suspend NULL
2848 #define wbsd_pnp_resume NULL
2849 #endif
2850 #ifdef CONFIG_PNP
2851 #endif
2852 #ifdef CONFIG_PNP
2853 #endif
2854 #ifdef CONFIG_PNP
2855 #endif
2856 #ifdef CONFIG_PNP
2857 #endif
2858 #ifdef CONFIG_PNP
2859 #endif
2860 /* LDV_COMMENT_END_PREP */
2861
2862
2863
2864
2865 }
2866
2867 break;
2868 case 3: {
2869
2870 /** STRUCT: struct type: platform_driver, struct name: wbsd_driver **/
2871 if(ldv_s_wbsd_driver_platform_driver==0) {
2872
2873 /* content: static int wbsd_probe(struct platform_device *dev)*/
2874 /* LDV_COMMENT_BEGIN_PREP */
2875 #define DRIVER_NAME "wbsd"
2876 #define DBG(x...) \
2877 pr_debug(DRIVER_NAME ": " x)
2878 #define DBGF(f, x...) \
2879 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2880 #ifdef CONFIG_PNP
2881 #endif
2882 #ifdef CONFIG_PNP
2883 #else
2884 #endif
2885 #ifdef CONFIG_MMC_DEBUG
2886 #endif
2887 #ifdef CONFIG_PM
2888 #endif
2889 /* LDV_COMMENT_END_PREP */
2890 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "wbsd_driver". Standart function test for correct return result. */
2891 res_wbsd_probe_48 = wbsd_probe( var_group4);
2892 ldv_check_return_value(res_wbsd_probe_48);
2893 ldv_check_return_value_probe(res_wbsd_probe_48);
2894 if(res_wbsd_probe_48)
2895 goto ldv_module_exit;
2896 /* LDV_COMMENT_BEGIN_PREP */
2897 #ifdef CONFIG_PNP
2898 #endif
2899 #ifdef CONFIG_PM
2900 #ifdef CONFIG_PNP
2901 #endif
2902 #else
2903 #define wbsd_platform_suspend NULL
2904 #define wbsd_platform_resume NULL
2905 #define wbsd_pnp_suspend NULL
2906 #define wbsd_pnp_resume NULL
2907 #endif
2908 #ifdef CONFIG_PNP
2909 #endif
2910 #ifdef CONFIG_PNP
2911 #endif
2912 #ifdef CONFIG_PNP
2913 #endif
2914 #ifdef CONFIG_PNP
2915 #endif
2916 #ifdef CONFIG_PNP
2917 #endif
2918 /* LDV_COMMENT_END_PREP */
2919 ldv_s_wbsd_driver_platform_driver++;
2920
2921 }
2922
2923 }
2924
2925 break;
2926 case 4: {
2927
2928 /** STRUCT: struct type: platform_driver, struct name: wbsd_driver **/
2929 if(ldv_s_wbsd_driver_platform_driver==1) {
2930
2931 /* content: static int wbsd_platform_suspend(struct platform_device *dev, pm_message_t state)*/
2932 /* LDV_COMMENT_BEGIN_PREP */
2933 #define DRIVER_NAME "wbsd"
2934 #define DBG(x...) \
2935 pr_debug(DRIVER_NAME ": " x)
2936 #define DBGF(f, x...) \
2937 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2938 #ifdef CONFIG_PNP
2939 #endif
2940 #ifdef CONFIG_PNP
2941 #else
2942 #endif
2943 #ifdef CONFIG_MMC_DEBUG
2944 #endif
2945 #ifdef CONFIG_PM
2946 #endif
2947 #ifdef CONFIG_PNP
2948 #endif
2949 #ifdef CONFIG_PM
2950 /* LDV_COMMENT_END_PREP */
2951 /* LDV_COMMENT_FUNCTION_CALL Function from field "suspend" from driver structure with callbacks "wbsd_driver" */
2952 ldv_handler_precall();
2953 wbsd_platform_suspend( var_group4, var_wbsd_platform_suspend_52_p1);
2954 /* LDV_COMMENT_BEGIN_PREP */
2955 #ifdef CONFIG_PNP
2956 #endif
2957 #else
2958 #define wbsd_platform_suspend NULL
2959 #define wbsd_platform_resume NULL
2960 #define wbsd_pnp_suspend NULL
2961 #define wbsd_pnp_resume NULL
2962 #endif
2963 #ifdef CONFIG_PNP
2964 #endif
2965 #ifdef CONFIG_PNP
2966 #endif
2967 #ifdef CONFIG_PNP
2968 #endif
2969 #ifdef CONFIG_PNP
2970 #endif
2971 #ifdef CONFIG_PNP
2972 #endif
2973 /* LDV_COMMENT_END_PREP */
2974 ldv_s_wbsd_driver_platform_driver++;
2975
2976 }
2977
2978 }
2979
2980 break;
2981 case 5: {
2982
2983 /** STRUCT: struct type: platform_driver, struct name: wbsd_driver **/
2984 if(ldv_s_wbsd_driver_platform_driver==2) {
2985
2986 /* content: static int wbsd_platform_resume(struct platform_device *dev)*/
2987 /* LDV_COMMENT_BEGIN_PREP */
2988 #define DRIVER_NAME "wbsd"
2989 #define DBG(x...) \
2990 pr_debug(DRIVER_NAME ": " x)
2991 #define DBGF(f, x...) \
2992 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
2993 #ifdef CONFIG_PNP
2994 #endif
2995 #ifdef CONFIG_PNP
2996 #else
2997 #endif
2998 #ifdef CONFIG_MMC_DEBUG
2999 #endif
3000 #ifdef CONFIG_PM
3001 #endif
3002 #ifdef CONFIG_PNP
3003 #endif
3004 #ifdef CONFIG_PM
3005 /* LDV_COMMENT_END_PREP */
3006 /* LDV_COMMENT_FUNCTION_CALL Function from field "resume" from driver structure with callbacks "wbsd_driver" */
3007 ldv_handler_precall();
3008 wbsd_platform_resume( var_group4);
3009 /* LDV_COMMENT_BEGIN_PREP */
3010 #ifdef CONFIG_PNP
3011 #endif
3012 #else
3013 #define wbsd_platform_suspend NULL
3014 #define wbsd_platform_resume NULL
3015 #define wbsd_pnp_suspend NULL
3016 #define wbsd_pnp_resume NULL
3017 #endif
3018 #ifdef CONFIG_PNP
3019 #endif
3020 #ifdef CONFIG_PNP
3021 #endif
3022 #ifdef CONFIG_PNP
3023 #endif
3024 #ifdef CONFIG_PNP
3025 #endif
3026 #ifdef CONFIG_PNP
3027 #endif
3028 /* LDV_COMMENT_END_PREP */
3029 ldv_s_wbsd_driver_platform_driver++;
3030
3031 }
3032
3033 }
3034
3035 break;
3036 case 6: {
3037
3038 /** STRUCT: struct type: platform_driver, struct name: wbsd_driver **/
3039 if(ldv_s_wbsd_driver_platform_driver==3) {
3040
3041 /* content: static int wbsd_remove(struct platform_device *dev)*/
3042 /* LDV_COMMENT_BEGIN_PREP */
3043 #define DRIVER_NAME "wbsd"
3044 #define DBG(x...) \
3045 pr_debug(DRIVER_NAME ": " x)
3046 #define DBGF(f, x...) \
3047 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3048 #ifdef CONFIG_PNP
3049 #endif
3050 #ifdef CONFIG_PNP
3051 #else
3052 #endif
3053 #ifdef CONFIG_MMC_DEBUG
3054 #endif
3055 #ifdef CONFIG_PM
3056 #endif
3057 /* LDV_COMMENT_END_PREP */
3058 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "wbsd_driver" */
3059 ldv_handler_precall();
3060 wbsd_remove( var_group4);
3061 /* LDV_COMMENT_BEGIN_PREP */
3062 #ifdef CONFIG_PNP
3063 #endif
3064 #ifdef CONFIG_PM
3065 #ifdef CONFIG_PNP
3066 #endif
3067 #else
3068 #define wbsd_platform_suspend NULL
3069 #define wbsd_platform_resume NULL
3070 #define wbsd_pnp_suspend NULL
3071 #define wbsd_pnp_resume NULL
3072 #endif
3073 #ifdef CONFIG_PNP
3074 #endif
3075 #ifdef CONFIG_PNP
3076 #endif
3077 #ifdef CONFIG_PNP
3078 #endif
3079 #ifdef CONFIG_PNP
3080 #endif
3081 #ifdef CONFIG_PNP
3082 #endif
3083 /* LDV_COMMENT_END_PREP */
3084 ldv_s_wbsd_driver_platform_driver=0;
3085
3086 }
3087
3088 }
3089
3090 break;
3091 case 7: {
3092
3093 /** STRUCT: struct type: pnp_driver, struct name: wbsd_pnp_driver **/
3094 if(ldv_s_wbsd_pnp_driver_pnp_driver==0) {
3095
3096 /* content: static int wbsd_pnp_probe(struct pnp_dev *pnpdev, const struct pnp_device_id *dev_id)*/
3097 /* LDV_COMMENT_BEGIN_PREP */
3098 #define DRIVER_NAME "wbsd"
3099 #define DBG(x...) \
3100 pr_debug(DRIVER_NAME ": " x)
3101 #define DBGF(f, x...) \
3102 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3103 #ifdef CONFIG_PNP
3104 #endif
3105 #ifdef CONFIG_PNP
3106 #else
3107 #endif
3108 #ifdef CONFIG_MMC_DEBUG
3109 #endif
3110 #ifdef CONFIG_PM
3111 #endif
3112 #ifdef CONFIG_PNP
3113 /* LDV_COMMENT_END_PREP */
3114 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "wbsd_pnp_driver". Standart function test for correct return result. */
3115 res_wbsd_pnp_probe_50 = wbsd_pnp_probe( var_group5, var_wbsd_pnp_probe_50_p1);
3116 ldv_check_return_value(res_wbsd_pnp_probe_50);
3117 ldv_check_return_value_probe(res_wbsd_pnp_probe_50);
3118 if(res_wbsd_pnp_probe_50)
3119 goto ldv_module_exit;
3120 /* LDV_COMMENT_BEGIN_PREP */
3121 #endif
3122 #ifdef CONFIG_PM
3123 #ifdef CONFIG_PNP
3124 #endif
3125 #else
3126 #define wbsd_platform_suspend NULL
3127 #define wbsd_platform_resume NULL
3128 #define wbsd_pnp_suspend NULL
3129 #define wbsd_pnp_resume NULL
3130 #endif
3131 #ifdef CONFIG_PNP
3132 #endif
3133 #ifdef CONFIG_PNP
3134 #endif
3135 #ifdef CONFIG_PNP
3136 #endif
3137 #ifdef CONFIG_PNP
3138 #endif
3139 #ifdef CONFIG_PNP
3140 #endif
3141 /* LDV_COMMENT_END_PREP */
3142 ldv_s_wbsd_pnp_driver_pnp_driver++;
3143
3144 }
3145
3146 }
3147
3148 break;
3149 case 8: {
3150
3151 /** STRUCT: struct type: pnp_driver, struct name: wbsd_pnp_driver **/
3152 if(ldv_s_wbsd_pnp_driver_pnp_driver==1) {
3153
3154 /* content: static void wbsd_pnp_remove(struct pnp_dev *dev)*/
3155 /* LDV_COMMENT_BEGIN_PREP */
3156 #define DRIVER_NAME "wbsd"
3157 #define DBG(x...) \
3158 pr_debug(DRIVER_NAME ": " x)
3159 #define DBGF(f, x...) \
3160 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3161 #ifdef CONFIG_PNP
3162 #endif
3163 #ifdef CONFIG_PNP
3164 #else
3165 #endif
3166 #ifdef CONFIG_MMC_DEBUG
3167 #endif
3168 #ifdef CONFIG_PM
3169 #endif
3170 #ifdef CONFIG_PNP
3171 /* LDV_COMMENT_END_PREP */
3172 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "wbsd_pnp_driver" */
3173 ldv_handler_precall();
3174 wbsd_pnp_remove( var_group5);
3175 /* LDV_COMMENT_BEGIN_PREP */
3176 #endif
3177 #ifdef CONFIG_PM
3178 #ifdef CONFIG_PNP
3179 #endif
3180 #else
3181 #define wbsd_platform_suspend NULL
3182 #define wbsd_platform_resume NULL
3183 #define wbsd_pnp_suspend NULL
3184 #define wbsd_pnp_resume NULL
3185 #endif
3186 #ifdef CONFIG_PNP
3187 #endif
3188 #ifdef CONFIG_PNP
3189 #endif
3190 #ifdef CONFIG_PNP
3191 #endif
3192 #ifdef CONFIG_PNP
3193 #endif
3194 #ifdef CONFIG_PNP
3195 #endif
3196 /* LDV_COMMENT_END_PREP */
3197 ldv_s_wbsd_pnp_driver_pnp_driver=0;
3198
3199 }
3200
3201 }
3202
3203 break;
3204 case 9: {
3205
3206 /** STRUCT: struct type: pnp_driver, struct name: wbsd_pnp_driver **/
3207
3208
3209 /* content: static int wbsd_pnp_suspend(struct pnp_dev *pnp_dev, pm_message_t state)*/
3210 /* LDV_COMMENT_BEGIN_PREP */
3211 #define DRIVER_NAME "wbsd"
3212 #define DBG(x...) \
3213 pr_debug(DRIVER_NAME ": " x)
3214 #define DBGF(f, x...) \
3215 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3216 #ifdef CONFIG_PNP
3217 #endif
3218 #ifdef CONFIG_PNP
3219 #else
3220 #endif
3221 #ifdef CONFIG_MMC_DEBUG
3222 #endif
3223 #ifdef CONFIG_PM
3224 #endif
3225 #ifdef CONFIG_PNP
3226 #endif
3227 #ifdef CONFIG_PM
3228 #ifdef CONFIG_PNP
3229 /* LDV_COMMENT_END_PREP */
3230 /* LDV_COMMENT_FUNCTION_CALL Function from field "suspend" from driver structure with callbacks "wbsd_pnp_driver" */
3231 ldv_handler_precall();
3232 wbsd_pnp_suspend( var_group5, var_wbsd_pnp_suspend_54_p1);
3233 /* LDV_COMMENT_BEGIN_PREP */
3234 #endif
3235 #else
3236 #define wbsd_platform_suspend NULL
3237 #define wbsd_platform_resume NULL
3238 #define wbsd_pnp_suspend NULL
3239 #define wbsd_pnp_resume NULL
3240 #endif
3241 #ifdef CONFIG_PNP
3242 #endif
3243 #ifdef CONFIG_PNP
3244 #endif
3245 #ifdef CONFIG_PNP
3246 #endif
3247 #ifdef CONFIG_PNP
3248 #endif
3249 #ifdef CONFIG_PNP
3250 #endif
3251 /* LDV_COMMENT_END_PREP */
3252
3253
3254
3255
3256 }
3257
3258 break;
3259 case 10: {
3260
3261 /** STRUCT: struct type: pnp_driver, struct name: wbsd_pnp_driver **/
3262
3263
3264 /* content: static int wbsd_pnp_resume(struct pnp_dev *pnp_dev)*/
3265 /* LDV_COMMENT_BEGIN_PREP */
3266 #define DRIVER_NAME "wbsd"
3267 #define DBG(x...) \
3268 pr_debug(DRIVER_NAME ": " x)
3269 #define DBGF(f, x...) \
3270 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3271 #ifdef CONFIG_PNP
3272 #endif
3273 #ifdef CONFIG_PNP
3274 #else
3275 #endif
3276 #ifdef CONFIG_MMC_DEBUG
3277 #endif
3278 #ifdef CONFIG_PM
3279 #endif
3280 #ifdef CONFIG_PNP
3281 #endif
3282 #ifdef CONFIG_PM
3283 #ifdef CONFIG_PNP
3284 /* LDV_COMMENT_END_PREP */
3285 /* LDV_COMMENT_FUNCTION_CALL Function from field "resume" from driver structure with callbacks "wbsd_pnp_driver" */
3286 ldv_handler_precall();
3287 wbsd_pnp_resume( var_group5);
3288 /* LDV_COMMENT_BEGIN_PREP */
3289 #endif
3290 #else
3291 #define wbsd_platform_suspend NULL
3292 #define wbsd_platform_resume NULL
3293 #define wbsd_pnp_suspend NULL
3294 #define wbsd_pnp_resume NULL
3295 #endif
3296 #ifdef CONFIG_PNP
3297 #endif
3298 #ifdef CONFIG_PNP
3299 #endif
3300 #ifdef CONFIG_PNP
3301 #endif
3302 #ifdef CONFIG_PNP
3303 #endif
3304 #ifdef CONFIG_PNP
3305 #endif
3306 /* LDV_COMMENT_END_PREP */
3307
3308
3309
3310
3311 }
3312
3313 break;
3314 case 11: {
3315
3316 /** CALLBACK SECTION request_irq **/
3317 LDV_IN_INTERRUPT=2;
3318
3319 /* content: static irqreturn_t wbsd_irq(int irq, void *dev_id)*/
3320 /* LDV_COMMENT_BEGIN_PREP */
3321 #define DRIVER_NAME "wbsd"
3322 #define DBG(x...) \
3323 pr_debug(DRIVER_NAME ": " x)
3324 #define DBGF(f, x...) \
3325 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3326 #ifdef CONFIG_PNP
3327 #endif
3328 #ifdef CONFIG_PNP
3329 #else
3330 #endif
3331 #ifdef CONFIG_MMC_DEBUG
3332 #endif
3333 /* LDV_COMMENT_END_PREP */
3334 /* LDV_COMMENT_FUNCTION_CALL */
3335 ldv_handler_precall();
3336 wbsd_irq( var_wbsd_irq_31_p0, var_wbsd_irq_31_p1);
3337 /* LDV_COMMENT_BEGIN_PREP */
3338 #ifdef CONFIG_PM
3339 #endif
3340 #ifdef CONFIG_PNP
3341 #endif
3342 #ifdef CONFIG_PM
3343 #ifdef CONFIG_PNP
3344 #endif
3345 #else
3346 #define wbsd_platform_suspend NULL
3347 #define wbsd_platform_resume NULL
3348 #define wbsd_pnp_suspend NULL
3349 #define wbsd_pnp_resume NULL
3350 #endif
3351 #ifdef CONFIG_PNP
3352 #endif
3353 #ifdef CONFIG_PNP
3354 #endif
3355 #ifdef CONFIG_PNP
3356 #endif
3357 #ifdef CONFIG_PNP
3358 #endif
3359 #ifdef CONFIG_PNP
3360 #endif
3361 /* LDV_COMMENT_END_PREP */
3362 LDV_IN_INTERRUPT=1;
3363
3364
3365
3366 }
3367
3368 break;
3369 case 12: {
3370
3371 /** TIMER SECTION timer **/
3372
3373
3374 /* content: static void wbsd_reset_ignore(unsigned long data)*/
3375 /* LDV_COMMENT_BEGIN_PREP */
3376 #define DRIVER_NAME "wbsd"
3377 #define DBG(x...) \
3378 pr_debug(DRIVER_NAME ": " x)
3379 #define DBGF(f, x...) \
3380 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3381 #ifdef CONFIG_PNP
3382 #endif
3383 #ifdef CONFIG_PNP
3384 #else
3385 #endif
3386 #ifdef CONFIG_MMC_DEBUG
3387 #endif
3388 /* LDV_COMMENT_END_PREP */
3389 /* LDV_COMMENT_FUNCTION_CALL */
3390 ldv_handler_precall();
3391 wbsd_reset_ignore( var_wbsd_reset_ignore_24_p0);
3392 /* LDV_COMMENT_BEGIN_PREP */
3393 #ifdef CONFIG_PM
3394 #endif
3395 #ifdef CONFIG_PNP
3396 #endif
3397 #ifdef CONFIG_PM
3398 #ifdef CONFIG_PNP
3399 #endif
3400 #else
3401 #define wbsd_platform_suspend NULL
3402 #define wbsd_platform_resume NULL
3403 #define wbsd_pnp_suspend NULL
3404 #define wbsd_pnp_resume NULL
3405 #endif
3406 #ifdef CONFIG_PNP
3407 #endif
3408 #ifdef CONFIG_PNP
3409 #endif
3410 #ifdef CONFIG_PNP
3411 #endif
3412 #ifdef CONFIG_PNP
3413 #endif
3414 #ifdef CONFIG_PNP
3415 #endif
3416 /* LDV_COMMENT_END_PREP */
3417
3418
3419
3420
3421 }
3422
3423 break;
3424 default: break;
3425
3426 }
3427
3428 }
3429
3430 ldv_module_exit:
3431
3432 /** INIT: init_type: ST_MODULE_EXIT **/
3433 /* content: static void __exit wbsd_drv_exit(void)*/
3434 /* LDV_COMMENT_BEGIN_PREP */
3435 #define DRIVER_NAME "wbsd"
3436 #define DBG(x...) \
3437 pr_debug(DRIVER_NAME ": " x)
3438 #define DBGF(f, x...) \
3439 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
3440 #ifdef CONFIG_PNP
3441 #endif
3442 #ifdef CONFIG_PNP
3443 #else
3444 #endif
3445 #ifdef CONFIG_MMC_DEBUG
3446 #endif
3447 #ifdef CONFIG_PM
3448 #endif
3449 #ifdef CONFIG_PNP
3450 #endif
3451 #ifdef CONFIG_PM
3452 #ifdef CONFIG_PNP
3453 #endif
3454 #else
3455 #define wbsd_platform_suspend NULL
3456 #define wbsd_platform_resume NULL
3457 #define wbsd_pnp_suspend NULL
3458 #define wbsd_pnp_resume NULL
3459 #endif
3460 #ifdef CONFIG_PNP
3461 #endif
3462 #ifdef CONFIG_PNP
3463 #endif
3464 /* LDV_COMMENT_END_PREP */
3465 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver release function before driver will be uploaded from kernel. This function declared as "MODULE_EXIT(function name)". */
3466 ldv_handler_precall();
3467 wbsd_drv_exit();
3468 /* LDV_COMMENT_BEGIN_PREP */
3469 #ifdef CONFIG_PNP
3470 #endif
3471 #ifdef CONFIG_PNP
3472 #endif
3473 /* LDV_COMMENT_END_PREP */
3474
3475 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */
3476 ldv_final: ldv_check_final_state();
3477
3478 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */
3479 return;
3480
3481 }
3482 #endif
3483
3484 /* LDV_COMMENT_END_MAIN */
3485
3486 #line 10 "/home/ldvuser/ldv/ref_launches/work/current--X--drivers--X--defaultlinux-4.10-rc1.tar.xz--X--331_1a--X--cpachecker/linux-4.10-rc1.tar.xz/csd_deg_dscv/16260/dscv_tempdir/dscv/ri/331_1a/drivers/mmc/host/wbsd.o.c.prepared" 1
2 #include <verifier/rcv.h>
3 #include <kernel-model/ERR.inc>
4
5 int LDV_DMA_MAP_CALLS = 0;
6
7 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_dma_map_page') maps page */
8 void ldv_dma_map_page(void) {
9 /* LDV_COMMENT_ASSERT Check that previos dma_mapping call was checked */
10 ldv_assert(LDV_DMA_MAP_CALLS == 0);
11 /* LDV_COMMENT_CHANGE_STATE Increase dma_mapping counter */
12 LDV_DMA_MAP_CALLS++;
13 }
14
15 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_dma_mapping_error') unmaps page */
16 void ldv_dma_mapping_error(void) {
17 /* LDV_COMMENT_ASSERT No dma_mapping calls to verify */
18 ldv_assert(LDV_DMA_MAP_CALLS != 0);
19 /* LDV_COMMENT_CHANGE_STATE Check that previos dma_mapping call was checked */
20 LDV_DMA_MAP_CALLS--;
21 }
22
23 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_check_final_state') Check that all module reference counters have their initial values at the end */
24 void ldv_check_final_state(void) {
25 /* LDV_COMMENT_ASSERT All incremented module reference counters should be decremented before module unloading*/
26 ldv_assert(LDV_DMA_MAP_CALLS == 0);
27 } 1 #ifndef _LDV_RCV_H_
2 #define _LDV_RCV_H_
3
4 /* If expr evaluates to zero, ldv_assert() causes a program to reach the error
5 label like the standard assert(). */
6 #define ldv_assert(expr) ((expr) ? 0 : ldv_error())
7
8 /* The error label wrapper. It is used because of some static verifiers (like
9 BLAST) don't accept multiple error labels through a program. */
10 static inline void ldv_error(void)
11 {
12 LDV_ERROR: goto LDV_ERROR;
13 }
14
15 /* If expr evaluates to zero, ldv_assume() causes an infinite loop that is
16 avoided by verifiers. */
17 #define ldv_assume(expr) ((expr) ? 0 : ldv_stop())
18
19 /* Infinite loop, that causes verifiers to skip such paths. */
20 static inline void ldv_stop(void) {
21 LDV_STOP: goto LDV_STOP;
22 }
23
24 /* Special nondeterministic functions. */
25 int ldv_undef_int(void);
26 void *ldv_undef_ptr(void);
27 unsigned long ldv_undef_ulong(void);
28 long ldv_undef_long(void);
29 /* Return nondeterministic negative integer number. */
30 static inline int ldv_undef_int_negative(void)
31 {
32 int ret = ldv_undef_int();
33
34 ldv_assume(ret < 0);
35
36 return ret;
37 }
38 /* Return nondeterministic nonpositive integer number. */
39 static inline int ldv_undef_int_nonpositive(void)
40 {
41 int ret = ldv_undef_int();
42
43 ldv_assume(ret <= 0);
44
45 return ret;
46 }
47
48 /* Add explicit model for __builin_expect GCC function. Without the model a
49 return value will be treated as nondetermined by verifiers. */
50 static inline long __builtin_expect(long exp, long c)
51 {
52 return exp;
53 }
54
55 /* This function causes the program to exit abnormally. GCC implements this
56 function by using a target-dependent mechanism (such as intentionally executing
57 an illegal instruction) or by calling abort. The mechanism used may vary from
58 release to release so you should not rely on any particular implementation.
59 http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */
60 static inline void __builtin_trap(void)
61 {
62 ldv_assert(0);
63 }
64
65 /* The constant is for simulating an error of ldv_undef_ptr() function. */
66 #define LDV_PTR_MAX 2012
67
68 #endif /* _LDV_RCV_H_ */ 1 /*
2 * device.h - generic, centralized driver model
3 *
4 * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
5 * Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de>
6 * Copyright (c) 2008-2009 Novell Inc.
7 *
8 * This file is released under the GPLv2
9 *
10 * See Documentation/driver-model/ for more information.
11 */
12
13 #ifndef _DEVICE_H_
14 #define _DEVICE_H_
15
16 #include <linux/ioport.h>
17 #include <linux/kobject.h>
18 #include <linux/klist.h>
19 #include <linux/list.h>
20 #include <linux/lockdep.h>
21 #include <linux/compiler.h>
22 #include <linux/types.h>
23 #include <linux/mutex.h>
24 #include <linux/pinctrl/devinfo.h>
25 #include <linux/pm.h>
26 #include <linux/atomic.h>
27 #include <linux/ratelimit.h>
28 #include <linux/uidgid.h>
29 #include <linux/gfp.h>
30 #include <asm/device.h>
31
32 struct device;
33 struct device_private;
34 struct device_driver;
35 struct driver_private;
36 struct module;
37 struct class;
38 struct subsys_private;
39 struct bus_type;
40 struct device_node;
41 struct fwnode_handle;
42 struct iommu_ops;
43 struct iommu_group;
44 struct iommu_fwspec;
45
46 struct bus_attribute {
47 struct attribute attr;
48 ssize_t (*show)(struct bus_type *bus, char *buf);
49 ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count);
50 };
51
52 #define BUS_ATTR(_name, _mode, _show, _store) \
53 struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)
54 #define BUS_ATTR_RW(_name) \
55 struct bus_attribute bus_attr_##_name = __ATTR_RW(_name)
56 #define BUS_ATTR_RO(_name) \
57 struct bus_attribute bus_attr_##_name = __ATTR_RO(_name)
58
59 extern int __must_check bus_create_file(struct bus_type *,
60 struct bus_attribute *);
61 extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
62
63 /**
64 * struct bus_type - The bus type of the device
65 *
66 * @name: The name of the bus.
67 * @dev_name: Used for subsystems to enumerate devices like ("foo%u", dev->id).
68 * @dev_root: Default device to use as the parent.
69 * @dev_attrs: Default attributes of the devices on the bus.
70 * @bus_groups: Default attributes of the bus.
71 * @dev_groups: Default attributes of the devices on the bus.
72 * @drv_groups: Default attributes of the device drivers on the bus.
73 * @match: Called, perhaps multiple times, whenever a new device or driver
74 * is added for this bus. It should return a positive value if the
75 * given device can be handled by the given driver and zero
76 * otherwise. It may also return error code if determining that
77 * the driver supports the device is not possible. In case of
78 * -EPROBE_DEFER it will queue the device for deferred probing.
79 * @uevent: Called when a device is added, removed, or a few other things
80 * that generate uevents to add the environment variables.
81 * @probe: Called when a new device or driver add to this bus, and callback
82 * the specific driver's probe to initial the matched device.
83 * @remove: Called when a device removed from this bus.
84 * @shutdown: Called at shut-down time to quiesce the device.
85 *
86 * @online: Called to put the device back online (after offlining it).
87 * @offline: Called to put the device offline for hot-removal. May fail.
88 *
89 * @suspend: Called when a device on this bus wants to go to sleep mode.
90 * @resume: Called to bring a device on this bus out of sleep mode.
91 * @pm: Power management operations of this bus, callback the specific
92 * device driver's pm-ops.
93 * @iommu_ops: IOMMU specific operations for this bus, used to attach IOMMU
94 * driver implementations to a bus and allow the driver to do
95 * bus-specific setup
96 * @p: The private data of the driver core, only the driver core can
97 * touch this.
98 * @lock_key: Lock class key for use by the lock validator
99 *
100 * A bus is a channel between the processor and one or more devices. For the
101 * purposes of the device model, all devices are connected via a bus, even if
102 * it is an internal, virtual, "platform" bus. Buses can plug into each other.
103 * A USB controller is usually a PCI device, for example. The device model
104 * represents the actual connections between buses and the devices they control.
105 * A bus is represented by the bus_type structure. It contains the name, the
106 * default attributes, the bus' methods, PM operations, and the driver core's
107 * private data.
108 */
109 struct bus_type {
110 const char *name;
111 const char *dev_name;
112 struct device *dev_root;
113 struct device_attribute *dev_attrs; /* use dev_groups instead */
114 const struct attribute_group **bus_groups;
115 const struct attribute_group **dev_groups;
116 const struct attribute_group **drv_groups;
117
118 int (*match)(struct device *dev, struct device_driver *drv);
119 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
120 int (*probe)(struct device *dev);
121 int (*remove)(struct device *dev);
122 void (*shutdown)(struct device *dev);
123
124 int (*online)(struct device *dev);
125 int (*offline)(struct device *dev);
126
127 int (*suspend)(struct device *dev, pm_message_t state);
128 int (*resume)(struct device *dev);
129
130 const struct dev_pm_ops *pm;
131
132 const struct iommu_ops *iommu_ops;
133
134 struct subsys_private *p;
135 struct lock_class_key lock_key;
136 };
137
138 extern int __must_check bus_register(struct bus_type *bus);
139
140 extern void bus_unregister(struct bus_type *bus);
141
142 extern int __must_check bus_rescan_devices(struct bus_type *bus);
143
144 /* iterator helpers for buses */
145 struct subsys_dev_iter {
146 struct klist_iter ki;
147 const struct device_type *type;
148 };
149 void subsys_dev_iter_init(struct subsys_dev_iter *iter,
150 struct bus_type *subsys,
151 struct device *start,
152 const struct device_type *type);
153 struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
154 void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
155
156 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
157 int (*fn)(struct device *dev, void *data));
158 struct device *bus_find_device(struct bus_type *bus, struct device *start,
159 void *data,
160 int (*match)(struct device *dev, void *data));
161 struct device *bus_find_device_by_name(struct bus_type *bus,
162 struct device *start,
163 const char *name);
164 struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
165 struct device *hint);
166 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
167 void *data, int (*fn)(struct device_driver *, void *));
168 void bus_sort_breadthfirst(struct bus_type *bus,
169 int (*compare)(const struct device *a,
170 const struct device *b));
171 /*
172 * Bus notifiers: Get notified of addition/removal of devices
173 * and binding/unbinding of drivers to devices.
174 * In the long run, it should be a replacement for the platform
175 * notify hooks.
176 */
177 struct notifier_block;
178
179 extern int bus_register_notifier(struct bus_type *bus,
180 struct notifier_block *nb);
181 extern int bus_unregister_notifier(struct bus_type *bus,
182 struct notifier_block *nb);
183
184 /* All 4 notifers below get called with the target struct device *
185 * as an argument. Note that those functions are likely to be called
186 * with the device lock held in the core, so be careful.
187 */
188 #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */
189 #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device to be removed */
190 #define BUS_NOTIFY_REMOVED_DEVICE 0x00000003 /* device removed */
191 #define BUS_NOTIFY_BIND_DRIVER 0x00000004 /* driver about to be
192 bound */
193 #define BUS_NOTIFY_BOUND_DRIVER 0x00000005 /* driver bound to device */
194 #define BUS_NOTIFY_UNBIND_DRIVER 0x00000006 /* driver about to be
195 unbound */
196 #define BUS_NOTIFY_UNBOUND_DRIVER 0x00000007 /* driver is unbound
197 from the device */
198 #define BUS_NOTIFY_DRIVER_NOT_BOUND 0x00000008 /* driver fails to be bound */
199
200 extern struct kset *bus_get_kset(struct bus_type *bus);
201 extern struct klist *bus_get_device_klist(struct bus_type *bus);
202
203 /**
204 * enum probe_type - device driver probe type to try
205 * Device drivers may opt in for special handling of their
206 * respective probe routines. This tells the core what to
207 * expect and prefer.
208 *
209 * @PROBE_DEFAULT_STRATEGY: Used by drivers that work equally well
210 * whether probed synchronously or asynchronously.
211 * @PROBE_PREFER_ASYNCHRONOUS: Drivers for "slow" devices which
212 * probing order is not essential for booting the system may
213 * opt into executing their probes asynchronously.
214 * @PROBE_FORCE_SYNCHRONOUS: Use this to annotate drivers that need
215 * their probe routines to run synchronously with driver and
216 * device registration (with the exception of -EPROBE_DEFER
217 * handling - re-probing always ends up being done asynchronously).
218 *
219 * Note that the end goal is to switch the kernel to use asynchronous
220 * probing by default, so annotating drivers with
221 * %PROBE_PREFER_ASYNCHRONOUS is a temporary measure that allows us
222 * to speed up boot process while we are validating the rest of the
223 * drivers.
224 */
225 enum probe_type {
226 PROBE_DEFAULT_STRATEGY,
227 PROBE_PREFER_ASYNCHRONOUS,
228 PROBE_FORCE_SYNCHRONOUS,
229 };
230
231 /**
232 * struct device_driver - The basic device driver structure
233 * @name: Name of the device driver.
234 * @bus: The bus which the device of this driver belongs to.
235 * @owner: The module owner.
236 * @mod_name: Used for built-in modules.
237 * @suppress_bind_attrs: Disables bind/unbind via sysfs.
238 * @probe_type: Type of the probe (synchronous or asynchronous) to use.
239 * @of_match_table: The open firmware table.
240 * @acpi_match_table: The ACPI match table.
241 * @probe: Called to query the existence of a specific device,
242 * whether this driver can work with it, and bind the driver
243 * to a specific device.
244 * @remove: Called when the device is removed from the system to
245 * unbind a device from this driver.
246 * @shutdown: Called at shut-down time to quiesce the device.
247 * @suspend: Called to put the device to sleep mode. Usually to a
248 * low power state.
249 * @resume: Called to bring a device from sleep mode.
250 * @groups: Default attributes that get created by the driver core
251 * automatically.
252 * @pm: Power management operations of the device which matched
253 * this driver.
254 * @p: Driver core's private data, no one other than the driver
255 * core can touch this.
256 *
257 * The device driver-model tracks all of the drivers known to the system.
258 * The main reason for this tracking is to enable the driver core to match
259 * up drivers with new devices. Once drivers are known objects within the
260 * system, however, a number of other things become possible. Device drivers
261 * can export information and configuration variables that are independent
262 * of any specific device.
263 */
264 struct device_driver {
265 const char *name;
266 struct bus_type *bus;
267
268 struct module *owner;
269 const char *mod_name; /* used for built-in modules */
270
271 bool suppress_bind_attrs; /* disables bind/unbind via sysfs */
272 enum probe_type probe_type;
273
274 const struct of_device_id *of_match_table;
275 const struct acpi_device_id *acpi_match_table;
276
277 int (*probe) (struct device *dev);
278 int (*remove) (struct device *dev);
279 void (*shutdown) (struct device *dev);
280 int (*suspend) (struct device *dev, pm_message_t state);
281 int (*resume) (struct device *dev);
282 const struct attribute_group **groups;
283
284 const struct dev_pm_ops *pm;
285
286 struct driver_private *p;
287 };
288
289
290 extern int __must_check driver_register(struct device_driver *drv);
291 extern void driver_unregister(struct device_driver *drv);
292
293 extern struct device_driver *driver_find(const char *name,
294 struct bus_type *bus);
295 extern int driver_probe_done(void);
296 extern void wait_for_device_probe(void);
297
298
299 /* sysfs interface for exporting driver attributes */
300
301 struct driver_attribute {
302 struct attribute attr;
303 ssize_t (*show)(struct device_driver *driver, char *buf);
304 ssize_t (*store)(struct device_driver *driver, const char *buf,
305 size_t count);
306 };
307
308 #define DRIVER_ATTR(_name, _mode, _show, _store) \
309 struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
310 #define DRIVER_ATTR_RW(_name) \
311 struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
312 #define DRIVER_ATTR_RO(_name) \
313 struct driver_attribute driver_attr_##_name = __ATTR_RO(_name)
314 #define DRIVER_ATTR_WO(_name) \
315 struct driver_attribute driver_attr_##_name = __ATTR_WO(_name)
316
317 extern int __must_check driver_create_file(struct device_driver *driver,
318 const struct driver_attribute *attr);
319 extern void driver_remove_file(struct device_driver *driver,
320 const struct driver_attribute *attr);
321
322 extern int __must_check driver_for_each_device(struct device_driver *drv,
323 struct device *start,
324 void *data,
325 int (*fn)(struct device *dev,
326 void *));
327 struct device *driver_find_device(struct device_driver *drv,
328 struct device *start, void *data,
329 int (*match)(struct device *dev, void *data));
330
331 /**
332 * struct subsys_interface - interfaces to device functions
333 * @name: name of the device function
334 * @subsys: subsytem of the devices to attach to
335 * @node: the list of functions registered at the subsystem
336 * @add_dev: device hookup to device function handler
337 * @remove_dev: device hookup to device function handler
338 *
339 * Simple interfaces attached to a subsystem. Multiple interfaces can
340 * attach to a subsystem and its devices. Unlike drivers, they do not
341 * exclusively claim or control devices. Interfaces usually represent
342 * a specific functionality of a subsystem/class of devices.
343 */
344 struct subsys_interface {
345 const char *name;
346 struct bus_type *subsys;
347 struct list_head node;
348 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
349 void (*remove_dev)(struct device *dev, struct subsys_interface *sif);
350 };
351
352 int subsys_interface_register(struct subsys_interface *sif);
353 void subsys_interface_unregister(struct subsys_interface *sif);
354
355 int subsys_system_register(struct bus_type *subsys,
356 const struct attribute_group **groups);
357 int subsys_virtual_register(struct bus_type *subsys,
358 const struct attribute_group **groups);
359
360 /**
361 * struct class - device classes
362 * @name: Name of the class.
363 * @owner: The module owner.
364 * @class_attrs: Default attributes of this class.
365 * @class_groups: Default attributes of this class.
366 * @dev_groups: Default attributes of the devices that belong to the class.
367 * @dev_kobj: The kobject that represents this class and links it into the hierarchy.
368 * @dev_uevent: Called when a device is added, removed from this class, or a
369 * few other things that generate uevents to add the environment
370 * variables.
371 * @devnode: Callback to provide the devtmpfs.
372 * @class_release: Called to release this class.
373 * @dev_release: Called to release the device.
374 * @suspend: Used to put the device to sleep mode, usually to a low power
375 * state.
376 * @resume: Used to bring the device from the sleep mode.
377 * @ns_type: Callbacks so sysfs can detemine namespaces.
378 * @namespace: Namespace of the device belongs to this class.
379 * @pm: The default device power management operations of this class.
380 * @p: The private data of the driver core, no one other than the
381 * driver core can touch this.
382 *
383 * A class is a higher-level view of a device that abstracts out low-level
384 * implementation details. Drivers may see a SCSI disk or an ATA disk, but,
385 * at the class level, they are all simply disks. Classes allow user space
386 * to work with devices based on what they do, rather than how they are
387 * connected or how they work.
388 */
389 struct class {
390 const char *name;
391 struct module *owner;
392
393 struct class_attribute *class_attrs;
394 const struct attribute_group **class_groups;
395 const struct attribute_group **dev_groups;
396 struct kobject *dev_kobj;
397
398 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
399 char *(*devnode)(struct device *dev, umode_t *mode);
400
401 void (*class_release)(struct class *class);
402 void (*dev_release)(struct device *dev);
403
404 int (*suspend)(struct device *dev, pm_message_t state);
405 int (*resume)(struct device *dev);
406
407 const struct kobj_ns_type_operations *ns_type;
408 const void *(*namespace)(struct device *dev);
409
410 const struct dev_pm_ops *pm;
411
412 struct subsys_private *p;
413 };
414
415 struct class_dev_iter {
416 struct klist_iter ki;
417 const struct device_type *type;
418 };
419
420 extern struct kobject *sysfs_dev_block_kobj;
421 extern struct kobject *sysfs_dev_char_kobj;
422 extern int __must_check __class_register(struct class *class,
423 struct lock_class_key *key);
424 extern void class_unregister(struct class *class);
425
426 /* This is a #define to keep the compiler from merging different
427 * instances of the __key variable */
428 #define class_register(class) \
429 ({ \
430 static struct lock_class_key __key; \
431 __class_register(class, &__key); \
432 })
433
434 struct class_compat;
435 struct class_compat *class_compat_register(const char *name);
436 void class_compat_unregister(struct class_compat *cls);
437 int class_compat_create_link(struct class_compat *cls, struct device *dev,
438 struct device *device_link);
439 void class_compat_remove_link(struct class_compat *cls, struct device *dev,
440 struct device *device_link);
441
442 extern void class_dev_iter_init(struct class_dev_iter *iter,
443 struct class *class,
444 struct device *start,
445 const struct device_type *type);
446 extern struct device *class_dev_iter_next(struct class_dev_iter *iter);
447 extern void class_dev_iter_exit(struct class_dev_iter *iter);
448
449 extern int class_for_each_device(struct class *class, struct device *start,
450 void *data,
451 int (*fn)(struct device *dev, void *data));
452 extern struct device *class_find_device(struct class *class,
453 struct device *start, const void *data,
454 int (*match)(struct device *, const void *));
455
456 struct class_attribute {
457 struct attribute attr;
458 ssize_t (*show)(struct class *class, struct class_attribute *attr,
459 char *buf);
460 ssize_t (*store)(struct class *class, struct class_attribute *attr,
461 const char *buf, size_t count);
462 };
463
464 #define CLASS_ATTR(_name, _mode, _show, _store) \
465 struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store)
466 #define CLASS_ATTR_RW(_name) \
467 struct class_attribute class_attr_##_name = __ATTR_RW(_name)
468 #define CLASS_ATTR_RO(_name) \
469 struct class_attribute class_attr_##_name = __ATTR_RO(_name)
470 #define CLASS_ATTR_WO(_name) \
471 struct class_attribute class_attr_##_name = __ATTR_WO(_name)
472
473 extern int __must_check class_create_file_ns(struct class *class,
474 const struct class_attribute *attr,
475 const void *ns);
476 extern void class_remove_file_ns(struct class *class,
477 const struct class_attribute *attr,
478 const void *ns);
479
480 static inline int __must_check class_create_file(struct class *class,
481 const struct class_attribute *attr)
482 {
483 return class_create_file_ns(class, attr, NULL);
484 }
485
486 static inline void class_remove_file(struct class *class,
487 const struct class_attribute *attr)
488 {
489 return class_remove_file_ns(class, attr, NULL);
490 }
491
492 /* Simple class attribute that is just a static string */
493 struct class_attribute_string {
494 struct class_attribute attr;
495 char *str;
496 };
497
498 /* Currently read-only only */
499 #define _CLASS_ATTR_STRING(_name, _mode, _str) \
500 { __ATTR(_name, _mode, show_class_attr_string, NULL), _str }
501 #define CLASS_ATTR_STRING(_name, _mode, _str) \
502 struct class_attribute_string class_attr_##_name = \
503 _CLASS_ATTR_STRING(_name, _mode, _str)
504
505 extern ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr,
506 char *buf);
507
508 struct class_interface {
509 struct list_head node;
510 struct class *class;
511
512 int (*add_dev) (struct device *, struct class_interface *);
513 void (*remove_dev) (struct device *, struct class_interface *);
514 };
515
516 extern int __must_check class_interface_register(struct class_interface *);
517 extern void class_interface_unregister(struct class_interface *);
518
519 extern struct class * __must_check __class_create(struct module *owner,
520 const char *name,
521 struct lock_class_key *key);
522 extern void class_destroy(struct class *cls);
523
524 /* This is a #define to keep the compiler from merging different
525 * instances of the __key variable */
526 #define class_create(owner, name) \
527 ({ \
528 static struct lock_class_key __key; \
529 __class_create(owner, name, &__key); \
530 })
531
532 /*
533 * The type of device, "struct device" is embedded in. A class
534 * or bus can contain devices of different types
535 * like "partitions" and "disks", "mouse" and "event".
536 * This identifies the device type and carries type-specific
537 * information, equivalent to the kobj_type of a kobject.
538 * If "name" is specified, the uevent will contain it in
539 * the DEVTYPE variable.
540 */
541 struct device_type {
542 const char *name;
543 const struct attribute_group **groups;
544 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
545 char *(*devnode)(struct device *dev, umode_t *mode,
546 kuid_t *uid, kgid_t *gid);
547 void (*release)(struct device *dev);
548
549 const struct dev_pm_ops *pm;
550 };
551
552 /* interface for exporting device attributes */
553 struct device_attribute {
554 struct attribute attr;
555 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
556 char *buf);
557 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
558 const char *buf, size_t count);
559 };
560
561 struct dev_ext_attribute {
562 struct device_attribute attr;
563 void *var;
564 };
565
566 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
567 char *buf);
568 ssize_t device_store_ulong(struct device *dev, struct device_attribute *attr,
569 const char *buf, size_t count);
570 ssize_t device_show_int(struct device *dev, struct device_attribute *attr,
571 char *buf);
572 ssize_t device_store_int(struct device *dev, struct device_attribute *attr,
573 const char *buf, size_t count);
574 ssize_t device_show_bool(struct device *dev, struct device_attribute *attr,
575 char *buf);
576 ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
577 const char *buf, size_t count);
578
579 #define DEVICE_ATTR(_name, _mode, _show, _store) \
580 struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
581 #define DEVICE_ATTR_RW(_name) \
582 struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
583 #define DEVICE_ATTR_RO(_name) \
584 struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
585 #define DEVICE_ATTR_WO(_name) \
586 struct device_attribute dev_attr_##_name = __ATTR_WO(_name)
587 #define DEVICE_ULONG_ATTR(_name, _mode, _var) \
588 struct dev_ext_attribute dev_attr_##_name = \
589 { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) }
590 #define DEVICE_INT_ATTR(_name, _mode, _var) \
591 struct dev_ext_attribute dev_attr_##_name = \
592 { __ATTR(_name, _mode, device_show_int, device_store_int), &(_var) }
593 #define DEVICE_BOOL_ATTR(_name, _mode, _var) \
594 struct dev_ext_attribute dev_attr_##_name = \
595 { __ATTR(_name, _mode, device_show_bool, device_store_bool), &(_var) }
596 #define DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \
597 struct device_attribute dev_attr_##_name = \
598 __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store)
599
600 extern int device_create_file(struct device *device,
601 const struct device_attribute *entry);
602 extern void device_remove_file(struct device *dev,
603 const struct device_attribute *attr);
604 extern bool device_remove_file_self(struct device *dev,
605 const struct device_attribute *attr);
606 extern int __must_check device_create_bin_file(struct device *dev,
607 const struct bin_attribute *attr);
608 extern void device_remove_bin_file(struct device *dev,
609 const struct bin_attribute *attr);
610
611 /* device resource management */
612 typedef void (*dr_release_t)(struct device *dev, void *res);
613 typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
614
615 #ifdef CONFIG_DEBUG_DEVRES
616 extern void *__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
617 int nid, const char *name) __malloc;
618 #define devres_alloc(release, size, gfp) \
619 __devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release)
620 #define devres_alloc_node(release, size, gfp, nid) \
621 __devres_alloc_node(release, size, gfp, nid, #release)
622 #else
623 extern void *devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
624 int nid) __malloc;
625 static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
626 {
627 return devres_alloc_node(release, size, gfp, NUMA_NO_NODE);
628 }
629 #endif
630
631 extern void devres_for_each_res(struct device *dev, dr_release_t release,
632 dr_match_t match, void *match_data,
633 void (*fn)(struct device *, void *, void *),
634 void *data);
635 extern void devres_free(void *res);
636 extern void devres_add(struct device *dev, void *res);
637 extern void *devres_find(struct device *dev, dr_release_t release,
638 dr_match_t match, void *match_data);
639 extern void *devres_get(struct device *dev, void *new_res,
640 dr_match_t match, void *match_data);
641 extern void *devres_remove(struct device *dev, dr_release_t release,
642 dr_match_t match, void *match_data);
643 extern int devres_destroy(struct device *dev, dr_release_t release,
644 dr_match_t match, void *match_data);
645 extern int devres_release(struct device *dev, dr_release_t release,
646 dr_match_t match, void *match_data);
647
648 /* devres group */
649 extern void * __must_check devres_open_group(struct device *dev, void *id,
650 gfp_t gfp);
651 extern void devres_close_group(struct device *dev, void *id);
652 extern void devres_remove_group(struct device *dev, void *id);
653 extern int devres_release_group(struct device *dev, void *id);
654
655 /* managed devm_k.alloc/kfree for device drivers */
656 extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __malloc;
657 extern __printf(3, 0)
658 char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
659 va_list ap) __malloc;
660 extern __printf(3, 4)
661 char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...) __malloc;
662 static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
663 {
664 return devm_kmalloc(dev, size, gfp | __GFP_ZERO);
665 }
666 static inline void *devm_kmalloc_array(struct device *dev,
667 size_t n, size_t size, gfp_t flags)
668 {
669 if (size != 0 && n > SIZE_MAX / size)
670 return NULL;
671 return devm_kmalloc(dev, n * size, flags);
672 }
673 static inline void *devm_kcalloc(struct device *dev,
674 size_t n, size_t size, gfp_t flags)
675 {
676 return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
677 }
678 extern void devm_kfree(struct device *dev, void *p);
679 extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc;
680 extern void *devm_kmemdup(struct device *dev, const void *src, size_t len,
681 gfp_t gfp);
682
683 extern unsigned long devm_get_free_pages(struct device *dev,
684 gfp_t gfp_mask, unsigned int order);
685 extern void devm_free_pages(struct device *dev, unsigned long addr);
686
687 void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
688
689 /* allows to add/remove a custom action to devres stack */
690 int devm_add_action(struct device *dev, void (*action)(void *), void *data);
691 void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
692
693 static inline int devm_add_action_or_reset(struct device *dev,
694 void (*action)(void *), void *data)
695 {
696 int ret;
697
698 ret = devm_add_action(dev, action, data);
699 if (ret)
700 action(data);
701
702 return ret;
703 }
704
705 /**
706 * devm_alloc_percpu - Resource-managed alloc_percpu
707 * @dev: Device to allocate per-cpu memory for
708 * @type: Type to allocate per-cpu memory for
709 *
710 * Managed alloc_percpu. Per-cpu memory allocated with this function is
711 * automatically freed on driver detach.
712 *
713 * RETURNS:
714 * Pointer to allocated memory on success, NULL on failure.
715 */
716 #define devm_alloc_percpu(dev, type) \
717 ((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), \
718 __alignof__(type)))
719
720 void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
721 size_t align);
722 void devm_free_percpu(struct device *dev, void __percpu *pdata);
723
724 struct device_dma_parameters {
725 /*
726 * a low level driver may set these to teach IOMMU code about
727 * sg limitations.
728 */
729 unsigned int max_segment_size;
730 unsigned long segment_boundary_mask;
731 };
732
733 /**
734 * enum device_link_state - Device link states.
735 * @DL_STATE_NONE: The presence of the drivers is not being tracked.
736 * @DL_STATE_DORMANT: None of the supplier/consumer drivers is present.
737 * @DL_STATE_AVAILABLE: The supplier driver is present, but the consumer is not.
738 * @DL_STATE_CONSUMER_PROBE: The consumer is probing (supplier driver present).
739 * @DL_STATE_ACTIVE: Both the supplier and consumer drivers are present.
740 * @DL_STATE_SUPPLIER_UNBIND: The supplier driver is unbinding.
741 */
742 enum device_link_state {
743 DL_STATE_NONE = -1,
744 DL_STATE_DORMANT = 0,
745 DL_STATE_AVAILABLE,
746 DL_STATE_CONSUMER_PROBE,
747 DL_STATE_ACTIVE,
748 DL_STATE_SUPPLIER_UNBIND,
749 };
750
751 /*
752 * Device link flags.
753 *
754 * STATELESS: The core won't track the presence of supplier/consumer drivers.
755 * AUTOREMOVE: Remove this link automatically on consumer driver unbind.
756 * PM_RUNTIME: If set, the runtime PM framework will use this link.
757 * RPM_ACTIVE: Run pm_runtime_get_sync() on the supplier during link creation.
758 */
759 #define DL_FLAG_STATELESS BIT(0)
760 #define DL_FLAG_AUTOREMOVE BIT(1)
761 #define DL_FLAG_PM_RUNTIME BIT(2)
762 #define DL_FLAG_RPM_ACTIVE BIT(3)
763
764 /**
765 * struct device_link - Device link representation.
766 * @supplier: The device on the supplier end of the link.
767 * @s_node: Hook to the supplier device's list of links to consumers.
768 * @consumer: The device on the consumer end of the link.
769 * @c_node: Hook to the consumer device's list of links to suppliers.
770 * @status: The state of the link (with respect to the presence of drivers).
771 * @flags: Link flags.
772 * @rpm_active: Whether or not the consumer device is runtime-PM-active.
773 * @rcu_head: An RCU head to use for deferred execution of SRCU callbacks.
774 */
775 struct device_link {
776 struct device *supplier;
777 struct list_head s_node;
778 struct device *consumer;
779 struct list_head c_node;
780 enum device_link_state status;
781 u32 flags;
782 bool rpm_active;
783 #ifdef CONFIG_SRCU
784 struct rcu_head rcu_head;
785 #endif
786 };
787
788 /**
789 * enum dl_dev_state - Device driver presence tracking information.
790 * @DL_DEV_NO_DRIVER: There is no driver attached to the device.
791 * @DL_DEV_PROBING: A driver is probing.
792 * @DL_DEV_DRIVER_BOUND: The driver has been bound to the device.
793 * @DL_DEV_UNBINDING: The driver is unbinding from the device.
794 */
795 enum dl_dev_state {
796 DL_DEV_NO_DRIVER = 0,
797 DL_DEV_PROBING,
798 DL_DEV_DRIVER_BOUND,
799 DL_DEV_UNBINDING,
800 };
801
802 /**
803 * struct dev_links_info - Device data related to device links.
804 * @suppliers: List of links to supplier devices.
805 * @consumers: List of links to consumer devices.
806 * @status: Driver status information.
807 */
808 struct dev_links_info {
809 struct list_head suppliers;
810 struct list_head consumers;
811 enum dl_dev_state status;
812 };
813
814 /**
815 * struct device - The basic device structure
816 * @parent: The device's "parent" device, the device to which it is attached.
817 * In most cases, a parent device is some sort of bus or host
818 * controller. If parent is NULL, the device, is a top-level device,
819 * which is not usually what you want.
820 * @p: Holds the private data of the driver core portions of the device.
821 * See the comment of the struct device_private for detail.
822 * @kobj: A top-level, abstract class from which other classes are derived.
823 * @init_name: Initial name of the device.
824 * @type: The type of device.
825 * This identifies the device type and carries type-specific
826 * information.
827 * @mutex: Mutex to synchronize calls to its driver.
828 * @bus: Type of bus device is on.
829 * @driver: Which driver has allocated this
830 * @platform_data: Platform data specific to the device.
831 * Example: For devices on custom boards, as typical of embedded
832 * and SOC based hardware, Linux often uses platform_data to point
833 * to board-specific structures describing devices and how they
834 * are wired. That can include what ports are available, chip
835 * variants, which GPIO pins act in what additional roles, and so
836 * on. This shrinks the "Board Support Packages" (BSPs) and
837 * minimizes board-specific #ifdefs in drivers.
838 * @driver_data: Private pointer for driver specific info.
839 * @links: Links to suppliers and consumers of this device.
840 * @power: For device power management.
841 * See Documentation/power/admin-guide/devices.rst for details.
842 * @pm_domain: Provide callbacks that are executed during system suspend,
843 * hibernation, system resume and during runtime PM transitions
844 * along with subsystem-level and driver-level callbacks.
845 * @pins: For device pin management.
846 * See Documentation/pinctrl.txt for details.
847 * @msi_list: Hosts MSI descriptors
848 * @msi_domain: The generic MSI domain this device is using.
849 * @numa_node: NUMA node this device is close to.
850 * @dma_mask: Dma mask (if dma'ble device).
851 * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all
852 * hardware supports 64-bit addresses for consistent allocations
853 * such descriptors.
854 * @dma_pfn_offset: offset of DMA memory range relatively of RAM
855 * @dma_parms: A low level driver may set these to teach IOMMU code about
856 * segment limitations.
857 * @dma_pools: Dma pools (if dma'ble device).
858 * @dma_mem: Internal for coherent mem override.
859 * @cma_area: Contiguous memory area for dma allocations
860 * @archdata: For arch-specific additions.
861 * @of_node: Associated device tree node.
862 * @fwnode: Associated device node supplied by platform firmware.
863 * @devt: For creating the sysfs "dev".
864 * @id: device instance
865 * @devres_lock: Spinlock to protect the resource of the device.
866 * @devres_head: The resources list of the device.
867 * @knode_class: The node used to add the device to the class list.
868 * @class: The class of the device.
869 * @groups: Optional attribute groups.
870 * @release: Callback to free the device after all references have
871 * gone away. This should be set by the allocator of the
872 * device (i.e. the bus driver that discovered the device).
873 * @iommu_group: IOMMU group the device belongs to.
874 * @iommu_fwspec: IOMMU-specific properties supplied by firmware.
875 *
876 * @offline_disabled: If set, the device is permanently online.
877 * @offline: Set after successful invocation of bus type's .offline().
878 *
879 * At the lowest level, every device in a Linux system is represented by an
880 * instance of struct device. The device structure contains the information
881 * that the device model core needs to model the system. Most subsystems,
882 * however, track additional information about the devices they host. As a
883 * result, it is rare for devices to be represented by bare device structures;
884 * instead, that structure, like kobject structures, is usually embedded within
885 * a higher-level representation of the device.
886 */
887 struct device {
888 struct device *parent;
889
890 struct device_private *p;
891
892 struct kobject kobj;
893 const char *init_name; /* initial name of the device */
894 const struct device_type *type;
895
896 struct mutex mutex; /* mutex to synchronize calls to
897 * its driver.
898 */
899
900 struct bus_type *bus; /* type of bus device is on */
901 struct device_driver *driver; /* which driver has allocated this
902 device */
903 void *platform_data; /* Platform specific data, device
904 core doesn't touch it */
905 void *driver_data; /* Driver data, set and get with
906 dev_set/get_drvdata */
907 struct dev_links_info links;
908 struct dev_pm_info power;
909 struct dev_pm_domain *pm_domain;
910
911 #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
912 struct irq_domain *msi_domain;
913 #endif
914 #ifdef CONFIG_PINCTRL
915 struct dev_pin_info *pins;
916 #endif
917 #ifdef CONFIG_GENERIC_MSI_IRQ
918 struct list_head msi_list;
919 #endif
920
921 #ifdef CONFIG_NUMA
922 int numa_node; /* NUMA node this device is close to */
923 #endif
924 u64 *dma_mask; /* dma mask (if dma'able device) */
925 u64 coherent_dma_mask;/* Like dma_mask, but for
926 alloc_coherent mappings as
927 not all hardware supports
928 64 bit addresses for consistent
929 allocations such descriptors. */
930 unsigned long dma_pfn_offset;
931
932 struct device_dma_parameters *dma_parms;
933
934 struct list_head dma_pools; /* dma pools (if dma'ble) */
935
936 struct dma_coherent_mem *dma_mem; /* internal for coherent mem
937 override */
938 #ifdef CONFIG_DMA_CMA
939 struct cma *cma_area; /* contiguous memory area for dma
940 allocations */
941 #endif
942 /* arch specific additions */
943 struct dev_archdata archdata;
944
945 struct device_node *of_node; /* associated device tree node */
946 struct fwnode_handle *fwnode; /* firmware device node */
947
948 dev_t devt; /* dev_t, creates the sysfs "dev" */
949 u32 id; /* device instance */
950
951 spinlock_t devres_lock;
952 struct list_head devres_head;
953
954 struct klist_node knode_class;
955 struct class *class;
956 const struct attribute_group **groups; /* optional groups */
957
958 void (*release)(struct device *dev);
959 struct iommu_group *iommu_group;
960 struct iommu_fwspec *iommu_fwspec;
961
962 bool offline_disabled:1;
963 bool offline:1;
964 };
965
966 static inline struct device *kobj_to_dev(struct kobject *kobj)
967 {
968 return container_of(kobj, struct device, kobj);
969 }
970
971 /* Get the wakeup routines, which depend on struct device */
972 #include <linux/pm_wakeup.h>
973
974 static inline const char *dev_name(const struct device *dev)
975 {
976 /* Use the init name until the kobject becomes available */
977 if (dev->init_name)
978 return dev->init_name;
979
980 return kobject_name(&dev->kobj);
981 }
982
983 extern __printf(2, 3)
984 int dev_set_name(struct device *dev, const char *name, ...);
985
986 #ifdef CONFIG_NUMA
987 static inline int dev_to_node(struct device *dev)
988 {
989 return dev->numa_node;
990 }
991 static inline void set_dev_node(struct device *dev, int node)
992 {
993 dev->numa_node = node;
994 }
995 #else
996 static inline int dev_to_node(struct device *dev)
997 {
998 return -1;
999 }
1000 static inline void set_dev_node(struct device *dev, int node)
1001 {
1002 }
1003 #endif
1004
1005 static inline struct irq_domain *dev_get_msi_domain(const struct device *dev)
1006 {
1007 #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
1008 return dev->msi_domain;
1009 #else
1010 return NULL;
1011 #endif
1012 }
1013
1014 static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d)
1015 {
1016 #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
1017 dev->msi_domain = d;
1018 #endif
1019 }
1020
1021 static inline void *dev_get_drvdata(const struct device *dev)
1022 {
1023 return dev->driver_data;
1024 }
1025
1026 static inline void dev_set_drvdata(struct device *dev, void *data)
1027 {
1028 dev->driver_data = data;
1029 }
1030
1031 static inline struct pm_subsys_data *dev_to_psd(struct device *dev)
1032 {
1033 return dev ? dev->power.subsys_data : NULL;
1034 }
1035
1036 static inline unsigned int dev_get_uevent_suppress(const struct device *dev)
1037 {
1038 return dev->kobj.uevent_suppress;
1039 }
1040
1041 static inline void dev_set_uevent_suppress(struct device *dev, int val)
1042 {
1043 dev->kobj.uevent_suppress = val;
1044 }
1045
1046 static inline int device_is_registered(struct device *dev)
1047 {
1048 return dev->kobj.state_in_sysfs;
1049 }
1050
1051 static inline void device_enable_async_suspend(struct device *dev)
1052 {
1053 if (!dev->power.is_prepared)
1054 dev->power.async_suspend = true;
1055 }
1056
1057 static inline void device_disable_async_suspend(struct device *dev)
1058 {
1059 if (!dev->power.is_prepared)
1060 dev->power.async_suspend = false;
1061 }
1062
1063 static inline bool device_async_suspend_enabled(struct device *dev)
1064 {
1065 return !!dev->power.async_suspend;
1066 }
1067
1068 static inline void dev_pm_syscore_device(struct device *dev, bool val)
1069 {
1070 #ifdef CONFIG_PM_SLEEP
1071 dev->power.syscore = val;
1072 #endif
1073 }
1074
1075 static inline void device_lock(struct device *dev)
1076 {
1077 mutex_lock(&dev->mutex);
1078 }
1079
1080 static inline int device_lock_interruptible(struct device *dev)
1081 {
1082 return mutex_lock_interruptible(&dev->mutex);
1083 }
1084
1085 static inline int device_trylock(struct device *dev)
1086 {
1087 return mutex_trylock(&dev->mutex);
1088 }
1089
1090 static inline void device_unlock(struct device *dev)
1091 {
1092 mutex_unlock(&dev->mutex);
1093 }
1094
1095 static inline void device_lock_assert(struct device *dev)
1096 {
1097 lockdep_assert_held(&dev->mutex);
1098 }
1099
1100 static inline struct device_node *dev_of_node(struct device *dev)
1101 {
1102 if (!IS_ENABLED(CONFIG_OF))
1103 return NULL;
1104 return dev->of_node;
1105 }
1106
1107 void driver_init(void);
1108
1109 /*
1110 * High level routines for use by the bus drivers
1111 */
1112 extern int __must_check device_register(struct device *dev);
1113 extern void device_unregister(struct device *dev);
1114 extern void device_initialize(struct device *dev);
1115 extern int __must_check device_add(struct device *dev);
1116 extern void device_del(struct device *dev);
1117 extern int device_for_each_child(struct device *dev, void *data,
1118 int (*fn)(struct device *dev, void *data));
1119 extern int device_for_each_child_reverse(struct device *dev, void *data,
1120 int (*fn)(struct device *dev, void *data));
1121 extern struct device *device_find_child(struct device *dev, void *data,
1122 int (*match)(struct device *dev, void *data));
1123 extern int device_rename(struct device *dev, const char *new_name);
1124 extern int device_move(struct device *dev, struct device *new_parent,
1125 enum dpm_order dpm_order);
1126 extern const char *device_get_devnode(struct device *dev,
1127 umode_t *mode, kuid_t *uid, kgid_t *gid,
1128 const char **tmp);
1129
1130 static inline bool device_supports_offline(struct device *dev)
1131 {
1132 return dev->bus && dev->bus->offline && dev->bus->online;
1133 }
1134
1135 extern void lock_device_hotplug(void);
1136 extern void unlock_device_hotplug(void);
1137 extern int lock_device_hotplug_sysfs(void);
1138 extern int device_offline(struct device *dev);
1139 extern int device_online(struct device *dev);
1140 extern void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1141 extern void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1142
1143 /*
1144 * Root device objects for grouping under /sys/devices
1145 */
1146 extern struct device *__root_device_register(const char *name,
1147 struct module *owner);
1148
1149 /* This is a macro to avoid include problems with THIS_MODULE */
1150 #define root_device_register(name) \
1151 __root_device_register(name, THIS_MODULE)
1152
1153 extern void root_device_unregister(struct device *root);
1154
1155 static inline void *dev_get_platdata(const struct device *dev)
1156 {
1157 return dev->platform_data;
1158 }
1159
1160 /*
1161 * Manual binding of a device to driver. See drivers/base/bus.c
1162 * for information on use.
1163 */
1164 extern int __must_check device_bind_driver(struct device *dev);
1165 extern void device_release_driver(struct device *dev);
1166 extern int __must_check device_attach(struct device *dev);
1167 extern int __must_check driver_attach(struct device_driver *drv);
1168 extern void device_initial_probe(struct device *dev);
1169 extern int __must_check device_reprobe(struct device *dev);
1170
1171 extern bool device_is_bound(struct device *dev);
1172
1173 /*
1174 * Easy functions for dynamically creating devices on the fly
1175 */
1176 extern __printf(5, 0)
1177 struct device *device_create_vargs(struct class *cls, struct device *parent,
1178 dev_t devt, void *drvdata,
1179 const char *fmt, va_list vargs);
1180 extern __printf(5, 6)
1181 struct device *device_create(struct class *cls, struct device *parent,
1182 dev_t devt, void *drvdata,
1183 const char *fmt, ...);
1184 extern __printf(6, 7)
1185 struct device *device_create_with_groups(struct class *cls,
1186 struct device *parent, dev_t devt, void *drvdata,
1187 const struct attribute_group **groups,
1188 const char *fmt, ...);
1189 extern void device_destroy(struct class *cls, dev_t devt);
1190
1191 /*
1192 * Platform "fixup" functions - allow the platform to have their say
1193 * about devices and actions that the general device layer doesn't
1194 * know about.
1195 */
1196 /* Notify platform of device discovery */
1197 extern int (*platform_notify)(struct device *dev);
1198
1199 extern int (*platform_notify_remove)(struct device *dev);
1200
1201
1202 /*
1203 * get_device - atomically increment the reference count for the device.
1204 *
1205 */
1206 extern struct device *get_device(struct device *dev);
1207 extern void put_device(struct device *dev);
1208
1209 #ifdef CONFIG_DEVTMPFS
1210 extern int devtmpfs_create_node(struct device *dev);
1211 extern int devtmpfs_delete_node(struct device *dev);
1212 extern int devtmpfs_mount(const char *mntdir);
1213 #else
1214 static inline int devtmpfs_create_node(struct device *dev) { return 0; }
1215 static inline int devtmpfs_delete_node(struct device *dev) { return 0; }
1216 static inline int devtmpfs_mount(const char *mountpoint) { return 0; }
1217 #endif
1218
1219 /* drivers/base/power/shutdown.c */
1220 extern void device_shutdown(void);
1221
1222 /* debugging and troubleshooting/diagnostic helpers. */
1223 extern const char *dev_driver_string(const struct device *dev);
1224
1225 /* Device links interface. */
1226 struct device_link *device_link_add(struct device *consumer,
1227 struct device *supplier, u32 flags);
1228 void device_link_del(struct device_link *link);
1229
1230 #ifdef CONFIG_PRINTK
1231
1232 extern __printf(3, 0)
1233 int dev_vprintk_emit(int level, const struct device *dev,
1234 const char *fmt, va_list args);
1235 extern __printf(3, 4)
1236 int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...);
1237
1238 extern __printf(3, 4)
1239 void dev_printk(const char *level, const struct device *dev,
1240 const char *fmt, ...);
1241 extern __printf(2, 3)
1242 void dev_emerg(const struct device *dev, const char *fmt, ...);
1243 extern __printf(2, 3)
1244 void dev_alert(const struct device *dev, const char *fmt, ...);
1245 extern __printf(2, 3)
1246 void dev_crit(const struct device *dev, const char *fmt, ...);
1247 extern __printf(2, 3)
1248 void dev_err(const struct device *dev, const char *fmt, ...);
1249 extern __printf(2, 3)
1250 void dev_warn(const struct device *dev, const char *fmt, ...);
1251 extern __printf(2, 3)
1252 void dev_notice(const struct device *dev, const char *fmt, ...);
1253 extern __printf(2, 3)
1254 void _dev_info(const struct device *dev, const char *fmt, ...);
1255
1256 #else
1257
1258 static inline __printf(3, 0)
1259 int dev_vprintk_emit(int level, const struct device *dev,
1260 const char *fmt, va_list args)
1261 { return 0; }
1262 static inline __printf(3, 4)
1263 int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...)
1264 { return 0; }
1265
1266 static inline void __dev_printk(const char *level, const struct device *dev,
1267 struct va_format *vaf)
1268 {}
1269 static inline __printf(3, 4)
1270 void dev_printk(const char *level, const struct device *dev,
1271 const char *fmt, ...)
1272 {}
1273
1274 static inline __printf(2, 3)
1275 void dev_emerg(const struct device *dev, const char *fmt, ...)
1276 {}
1277 static inline __printf(2, 3)
1278 void dev_crit(const struct device *dev, const char *fmt, ...)
1279 {}
1280 static inline __printf(2, 3)
1281 void dev_alert(const struct device *dev, const char *fmt, ...)
1282 {}
1283 static inline __printf(2, 3)
1284 void dev_err(const struct device *dev, const char *fmt, ...)
1285 {}
1286 static inline __printf(2, 3)
1287 void dev_warn(const struct device *dev, const char *fmt, ...)
1288 {}
1289 static inline __printf(2, 3)
1290 void dev_notice(const struct device *dev, const char *fmt, ...)
1291 {}
1292 static inline __printf(2, 3)
1293 void _dev_info(const struct device *dev, const char *fmt, ...)
1294 {}
1295
1296 #endif
1297
1298 /*
1299 * Stupid hackaround for existing uses of non-printk uses dev_info
1300 *
1301 * Note that the definition of dev_info below is actually _dev_info
1302 * and a macro is used to avoid redefining dev_info
1303 */
1304
1305 #define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
1306
1307 #if defined(CONFIG_DYNAMIC_DEBUG)
1308 #define dev_dbg(dev, format, ...) \
1309 do { \
1310 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
1311 } while (0)
1312 #elif defined(DEBUG)
1313 #define dev_dbg(dev, format, arg...) \
1314 dev_printk(KERN_DEBUG, dev, format, ##arg)
1315 #else
1316 #define dev_dbg(dev, format, arg...) \
1317 ({ \
1318 if (0) \
1319 dev_printk(KERN_DEBUG, dev, format, ##arg); \
1320 })
1321 #endif
1322
1323 #ifdef CONFIG_PRINTK
1324 #define dev_level_once(dev_level, dev, fmt, ...) \
1325 do { \
1326 static bool __print_once __read_mostly; \
1327 \
1328 if (!__print_once) { \
1329 __print_once = true; \
1330 dev_level(dev, fmt, ##__VA_ARGS__); \
1331 } \
1332 } while (0)
1333 #else
1334 #define dev_level_once(dev_level, dev, fmt, ...) \
1335 do { \
1336 if (0) \
1337 dev_level(dev, fmt, ##__VA_ARGS__); \
1338 } while (0)
1339 #endif
1340
1341 #define dev_emerg_once(dev, fmt, ...) \
1342 dev_level_once(dev_emerg, dev, fmt, ##__VA_ARGS__)
1343 #define dev_alert_once(dev, fmt, ...) \
1344 dev_level_once(dev_alert, dev, fmt, ##__VA_ARGS__)
1345 #define dev_crit_once(dev, fmt, ...) \
1346 dev_level_once(dev_crit, dev, fmt, ##__VA_ARGS__)
1347 #define dev_err_once(dev, fmt, ...) \
1348 dev_level_once(dev_err, dev, fmt, ##__VA_ARGS__)
1349 #define dev_warn_once(dev, fmt, ...) \
1350 dev_level_once(dev_warn, dev, fmt, ##__VA_ARGS__)
1351 #define dev_notice_once(dev, fmt, ...) \
1352 dev_level_once(dev_notice, dev, fmt, ##__VA_ARGS__)
1353 #define dev_info_once(dev, fmt, ...) \
1354 dev_level_once(dev_info, dev, fmt, ##__VA_ARGS__)
1355 #define dev_dbg_once(dev, fmt, ...) \
1356 dev_level_once(dev_dbg, dev, fmt, ##__VA_ARGS__)
1357
1358 #define dev_level_ratelimited(dev_level, dev, fmt, ...) \
1359 do { \
1360 static DEFINE_RATELIMIT_STATE(_rs, \
1361 DEFAULT_RATELIMIT_INTERVAL, \
1362 DEFAULT_RATELIMIT_BURST); \
1363 if (__ratelimit(&_rs)) \
1364 dev_level(dev, fmt, ##__VA_ARGS__); \
1365 } while (0)
1366
1367 #define dev_emerg_ratelimited(dev, fmt, ...) \
1368 dev_level_ratelimited(dev_emerg, dev, fmt, ##__VA_ARGS__)
1369 #define dev_alert_ratelimited(dev, fmt, ...) \
1370 dev_level_ratelimited(dev_alert, dev, fmt, ##__VA_ARGS__)
1371 #define dev_crit_ratelimited(dev, fmt, ...) \
1372 dev_level_ratelimited(dev_crit, dev, fmt, ##__VA_ARGS__)
1373 #define dev_err_ratelimited(dev, fmt, ...) \
1374 dev_level_ratelimited(dev_err, dev, fmt, ##__VA_ARGS__)
1375 #define dev_warn_ratelimited(dev, fmt, ...) \
1376 dev_level_ratelimited(dev_warn, dev, fmt, ##__VA_ARGS__)
1377 #define dev_notice_ratelimited(dev, fmt, ...) \
1378 dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__)
1379 #define dev_info_ratelimited(dev, fmt, ...) \
1380 dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__)
1381 #if defined(CONFIG_DYNAMIC_DEBUG)
1382 /* descriptor check is first to prevent flooding with "callbacks suppressed" */
1383 #define dev_dbg_ratelimited(dev, fmt, ...) \
1384 do { \
1385 static DEFINE_RATELIMIT_STATE(_rs, \
1386 DEFAULT_RATELIMIT_INTERVAL, \
1387 DEFAULT_RATELIMIT_BURST); \
1388 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
1389 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
1390 __ratelimit(&_rs)) \
1391 __dynamic_dev_dbg(&descriptor, dev, fmt, \
1392 ##__VA_ARGS__); \
1393 } while (0)
1394 #elif defined(DEBUG)
1395 #define dev_dbg_ratelimited(dev, fmt, ...) \
1396 do { \
1397 static DEFINE_RATELIMIT_STATE(_rs, \
1398 DEFAULT_RATELIMIT_INTERVAL, \
1399 DEFAULT_RATELIMIT_BURST); \
1400 if (__ratelimit(&_rs)) \
1401 dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
1402 } while (0)
1403 #else
1404 #define dev_dbg_ratelimited(dev, fmt, ...) \
1405 do { \
1406 if (0) \
1407 dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
1408 } while (0)
1409 #endif
1410
1411 #ifdef VERBOSE_DEBUG
1412 #define dev_vdbg dev_dbg
1413 #else
1414 #define dev_vdbg(dev, format, arg...) \
1415 ({ \
1416 if (0) \
1417 dev_printk(KERN_DEBUG, dev, format, ##arg); \
1418 })
1419 #endif
1420
1421 /*
1422 * dev_WARN*() acts like dev_printk(), but with the key difference of
1423 * using WARN/WARN_ONCE to include file/line information and a backtrace.
1424 */
1425 #define dev_WARN(dev, format, arg...) \
1426 WARN(1, "%s %s: " format, dev_driver_string(dev), dev_name(dev), ## arg);
1427
1428 #define dev_WARN_ONCE(dev, condition, format, arg...) \
1429 WARN_ONCE(condition, "%s %s: " format, \
1430 dev_driver_string(dev), dev_name(dev), ## arg)
1431
1432 /* Create alias, so I can be autoloaded. */
1433 #define MODULE_ALIAS_CHARDEV(major,minor) \
1434 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
1435 #define MODULE_ALIAS_CHARDEV_MAJOR(major) \
1436 MODULE_ALIAS("char-major-" __stringify(major) "-*")
1437
1438 #ifdef CONFIG_SYSFS_DEPRECATED
1439 extern long sysfs_deprecated;
1440 #else
1441 #define sysfs_deprecated 0
1442 #endif
1443
1444 /**
1445 * module_driver() - Helper macro for drivers that don't do anything
1446 * special in module init/exit. This eliminates a lot of boilerplate.
1447 * Each module may only use this macro once, and calling it replaces
1448 * module_init() and module_exit().
1449 *
1450 * @__driver: driver name
1451 * @__register: register function for this driver type
1452 * @__unregister: unregister function for this driver type
1453 * @...: Additional arguments to be passed to __register and __unregister.
1454 *
1455 * Use this macro to construct bus specific macros for registering
1456 * drivers, and do not use it on its own.
1457 */
1458 #define module_driver(__driver, __register, __unregister, ...) \
1459 static int __init __driver##_init(void) \
1460 { \
1461 return __register(&(__driver) , ##__VA_ARGS__); \
1462 } \
1463 module_init(__driver##_init); \
1464 static void __exit __driver##_exit(void) \
1465 { \
1466 __unregister(&(__driver) , ##__VA_ARGS__); \
1467 } \
1468 module_exit(__driver##_exit);
1469
1470 /**
1471 * builtin_driver() - Helper macro for drivers that don't do anything
1472 * special in init and have no exit. This eliminates some boilerplate.
1473 * Each driver may only use this macro once, and calling it replaces
1474 * device_initcall (or in some cases, the legacy __initcall). This is
1475 * meant to be a direct parallel of module_driver() above but without
1476 * the __exit stuff that is not used for builtin cases.
1477 *
1478 * @__driver: driver name
1479 * @__register: register function for this driver type
1480 * @...: Additional arguments to be passed to __register
1481 *
1482 * Use this macro to construct bus specific macros for registering
1483 * drivers, and do not use it on its own.
1484 */
1485 #define builtin_driver(__driver, __register, ...) \
1486 static int __init __driver##_init(void) \
1487 { \
1488 return __register(&(__driver) , ##__VA_ARGS__); \
1489 } \
1490 device_initcall(__driver##_init);
1491
1492 #endif /* _DEVICE_H_ */ 1 /* interrupt.h */
2 #ifndef _LINUX_INTERRUPT_H
3 #define _LINUX_INTERRUPT_H
4
5 #include <linux/kernel.h>
6 #include <linux/linkage.h>
7 #include <linux/bitops.h>
8 #include <linux/preempt.h>
9 #include <linux/cpumask.h>
10 #include <linux/irqreturn.h>
11 #include <linux/irqnr.h>
12 #include <linux/hardirq.h>
13 #include <linux/irqflags.h>
14 #include <linux/hrtimer.h>
15 #include <linux/kref.h>
16 #include <linux/workqueue.h>
17
18 #include <linux/atomic.h>
19 #include <asm/ptrace.h>
20 #include <asm/irq.h>
21
22 /*
23 * These correspond to the IORESOURCE_IRQ_* defines in
24 * linux/ioport.h to select the interrupt line behaviour. When
25 * requesting an interrupt without specifying a IRQF_TRIGGER, the
26 * setting should be assumed to be "as already configured", which
27 * may be as per machine or firmware initialisation.
28 */
29 #define IRQF_TRIGGER_NONE 0x00000000
30 #define IRQF_TRIGGER_RISING 0x00000001
31 #define IRQF_TRIGGER_FALLING 0x00000002
32 #define IRQF_TRIGGER_HIGH 0x00000004
33 #define IRQF_TRIGGER_LOW 0x00000008
34 #define IRQF_TRIGGER_MASK (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \
35 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)
36 #define IRQF_TRIGGER_PROBE 0x00000010
37
38 /*
39 * These flags used only by the kernel as part of the
40 * irq handling routines.
41 *
42 * IRQF_SHARED - allow sharing the irq among several devices
43 * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur
44 * IRQF_TIMER - Flag to mark this interrupt as timer interrupt
45 * IRQF_PERCPU - Interrupt is per cpu
46 * IRQF_NOBALANCING - Flag to exclude this interrupt from irq balancing
47 * IRQF_IRQPOLL - Interrupt is used for polling (only the interrupt that is
48 * registered first in an shared interrupt is considered for
49 * performance reasons)
50 * IRQF_ONESHOT - Interrupt is not reenabled after the hardirq handler finished.
51 * Used by threaded interrupts which need to keep the
52 * irq line disabled until the threaded handler has been run.
53 * IRQF_NO_SUSPEND - Do not disable this IRQ during suspend. Does not guarantee
54 * that this interrupt will wake the system from a suspended
55 * state. See Documentation/power/suspend-and-interrupts.txt
56 * IRQF_FORCE_RESUME - Force enable it on resume even if IRQF_NO_SUSPEND is set
57 * IRQF_NO_THREAD - Interrupt cannot be threaded
58 * IRQF_EARLY_RESUME - Resume IRQ early during syscore instead of at device
59 * resume time.
60 * IRQF_COND_SUSPEND - If the IRQ is shared with a NO_SUSPEND user, execute this
61 * interrupt handler after suspending interrupts. For system
62 * wakeup devices users need to implement wakeup detection in
63 * their interrupt handlers.
64 */
65 #define IRQF_SHARED 0x00000080
66 #define IRQF_PROBE_SHARED 0x00000100
67 #define __IRQF_TIMER 0x00000200
68 #define IRQF_PERCPU 0x00000400
69 #define IRQF_NOBALANCING 0x00000800
70 #define IRQF_IRQPOLL 0x00001000
71 #define IRQF_ONESHOT 0x00002000
72 #define IRQF_NO_SUSPEND 0x00004000
73 #define IRQF_FORCE_RESUME 0x00008000
74 #define IRQF_NO_THREAD 0x00010000
75 #define IRQF_EARLY_RESUME 0x00020000
76 #define IRQF_COND_SUSPEND 0x00040000
77
78 #define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
79
80 /*
81 * These values can be returned by request_any_context_irq() and
82 * describe the context the interrupt will be run in.
83 *
84 * IRQC_IS_HARDIRQ - interrupt runs in hardirq context
85 * IRQC_IS_NESTED - interrupt runs in a nested threaded context
86 */
87 enum {
88 IRQC_IS_HARDIRQ = 0,
89 IRQC_IS_NESTED,
90 };
91
92 typedef irqreturn_t (*irq_handler_t)(int, void *);
93
94 /**
95 * struct irqaction - per interrupt action descriptor
96 * @handler: interrupt handler function
97 * @name: name of the device
98 * @dev_id: cookie to identify the device
99 * @percpu_dev_id: cookie to identify the device
100 * @next: pointer to the next irqaction for shared interrupts
101 * @irq: interrupt number
102 * @flags: flags (see IRQF_* above)
103 * @thread_fn: interrupt handler function for threaded interrupts
104 * @thread: thread pointer for threaded interrupts
105 * @secondary: pointer to secondary irqaction (force threading)
106 * @thread_flags: flags related to @thread
107 * @thread_mask: bitmask for keeping track of @thread activity
108 * @dir: pointer to the proc/irq/NN/name entry
109 */
110 struct irqaction {
111 irq_handler_t handler;
112 void *dev_id;
113 void __percpu *percpu_dev_id;
114 struct irqaction *next;
115 irq_handler_t thread_fn;
116 struct task_struct *thread;
117 struct irqaction *secondary;
118 unsigned int irq;
119 unsigned int flags;
120 unsigned long thread_flags;
121 unsigned long thread_mask;
122 const char *name;
123 struct proc_dir_entry *dir;
124 } ____cacheline_internodealigned_in_smp;
125
126 extern irqreturn_t no_action(int cpl, void *dev_id);
127
128 /*
129 * If a (PCI) device interrupt is not connected we set dev->irq to
130 * IRQ_NOTCONNECTED. This causes request_irq() to fail with -ENOTCONN, so we
131 * can distingiush that case from other error returns.
132 *
133 * 0x80000000 is guaranteed to be outside the available range of interrupts
134 * and easy to distinguish from other possible incorrect values.
135 */
136 #define IRQ_NOTCONNECTED (1U << 31)
137
138 extern int __must_check
139 request_threaded_irq(unsigned int irq, irq_handler_t handler,
140 irq_handler_t thread_fn,
141 unsigned long flags, const char *name, void *dev);
142
143 static inline int __must_check
144 request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
145 const char *name, void *dev)
146 {
147 return request_threaded_irq(irq, handler, NULL, flags, name, dev);
148 }
149
150 extern int __must_check
151 request_any_context_irq(unsigned int irq, irq_handler_t handler,
152 unsigned long flags, const char *name, void *dev_id);
153
154 extern int __must_check
155 request_percpu_irq(unsigned int irq, irq_handler_t handler,
156 const char *devname, void __percpu *percpu_dev_id);
157
158 extern void free_irq(unsigned int, void *);
159 extern void free_percpu_irq(unsigned int, void __percpu *);
160
161 struct device;
162
163 extern int __must_check
164 devm_request_threaded_irq(struct device *dev, unsigned int irq,
165 irq_handler_t handler, irq_handler_t thread_fn,
166 unsigned long irqflags, const char *devname,
167 void *dev_id);
168
169 static inline int __must_check
170 devm_request_irq(struct device *dev, unsigned int irq, irq_handler_t handler,
171 unsigned long irqflags, const char *devname, void *dev_id)
172 {
173 return devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
174 devname, dev_id);
175 }
176
177 extern int __must_check
178 devm_request_any_context_irq(struct device *dev, unsigned int irq,
179 irq_handler_t handler, unsigned long irqflags,
180 const char *devname, void *dev_id);
181
182 extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
183
184 /*
185 * On lockdep we dont want to enable hardirqs in hardirq
186 * context. Use local_irq_enable_in_hardirq() to annotate
187 * kernel code that has to do this nevertheless (pretty much
188 * the only valid case is for old/broken hardware that is
189 * insanely slow).
190 *
191 * NOTE: in theory this might break fragile code that relies
192 * on hardirq delivery - in practice we dont seem to have such
193 * places left. So the only effect should be slightly increased
194 * irqs-off latencies.
195 */
196 #ifdef CONFIG_LOCKDEP
197 # define local_irq_enable_in_hardirq() do { } while (0)
198 #else
199 # define local_irq_enable_in_hardirq() local_irq_enable()
200 #endif
201
202 extern void disable_irq_nosync(unsigned int irq);
203 extern bool disable_hardirq(unsigned int irq);
204 extern void disable_irq(unsigned int irq);
205 extern void disable_percpu_irq(unsigned int irq);
206 extern void enable_irq(unsigned int irq);
207 extern void enable_percpu_irq(unsigned int irq, unsigned int type);
208 extern bool irq_percpu_is_enabled(unsigned int irq);
209 extern void irq_wake_thread(unsigned int irq, void *dev_id);
210
211 /* The following three functions are for the core kernel use only. */
212 extern void suspend_device_irqs(void);
213 extern void resume_device_irqs(void);
214
215 /**
216 * struct irq_affinity_notify - context for notification of IRQ affinity changes
217 * @irq: Interrupt to which notification applies
218 * @kref: Reference count, for internal use
219 * @work: Work item, for internal use
220 * @notify: Function to be called on change. This will be
221 * called in process context.
222 * @release: Function to be called on release. This will be
223 * called in process context. Once registered, the
224 * structure must only be freed when this function is
225 * called or later.
226 */
227 struct irq_affinity_notify {
228 unsigned int irq;
229 struct kref kref;
230 struct work_struct work;
231 void (*notify)(struct irq_affinity_notify *, const cpumask_t *mask);
232 void (*release)(struct kref *ref);
233 };
234
235 /**
236 * struct irq_affinity - Description for automatic irq affinity assignements
237 * @pre_vectors: Don't apply affinity to @pre_vectors at beginning of
238 * the MSI(-X) vector space
239 * @post_vectors: Don't apply affinity to @post_vectors at end of
240 * the MSI(-X) vector space
241 */
242 struct irq_affinity {
243 int pre_vectors;
244 int post_vectors;
245 };
246
247 #if defined(CONFIG_SMP)
248
249 extern cpumask_var_t irq_default_affinity;
250
251 /* Internal implementation. Use the helpers below */
252 extern int __irq_set_affinity(unsigned int irq, const struct cpumask *cpumask,
253 bool force);
254
255 /**
256 * irq_set_affinity - Set the irq affinity of a given irq
257 * @irq: Interrupt to set affinity
258 * @cpumask: cpumask
259 *
260 * Fails if cpumask does not contain an online CPU
261 */
262 static inline int
263 irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
264 {
265 return __irq_set_affinity(irq, cpumask, false);
266 }
267
268 /**
269 * irq_force_affinity - Force the irq affinity of a given irq
270 * @irq: Interrupt to set affinity
271 * @cpumask: cpumask
272 *
273 * Same as irq_set_affinity, but without checking the mask against
274 * online cpus.
275 *
276 * Solely for low level cpu hotplug code, where we need to make per
277 * cpu interrupts affine before the cpu becomes online.
278 */
279 static inline int
280 irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
281 {
282 return __irq_set_affinity(irq, cpumask, true);
283 }
284
285 extern int irq_can_set_affinity(unsigned int irq);
286 extern int irq_select_affinity(unsigned int irq);
287
288 extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
289
290 extern int
291 irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
292
293 struct cpumask *irq_create_affinity_masks(int nvec, const struct irq_affinity *affd);
294 int irq_calc_affinity_vectors(int maxvec, const struct irq_affinity *affd);
295
296 #else /* CONFIG_SMP */
297
298 static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
299 {
300 return -EINVAL;
301 }
302
303 static inline int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
304 {
305 return 0;
306 }
307
308 static inline int irq_can_set_affinity(unsigned int irq)
309 {
310 return 0;
311 }
312
313 static inline int irq_select_affinity(unsigned int irq) { return 0; }
314
315 static inline int irq_set_affinity_hint(unsigned int irq,
316 const struct cpumask *m)
317 {
318 return -EINVAL;
319 }
320
321 static inline int
322 irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
323 {
324 return 0;
325 }
326
327 static inline struct cpumask *
328 irq_create_affinity_masks(int nvec, const struct irq_affinity *affd)
329 {
330 return NULL;
331 }
332
333 static inline int
334 irq_calc_affinity_vectors(int maxvec, const struct irq_affinity *affd)
335 {
336 return maxvec;
337 }
338
339 #endif /* CONFIG_SMP */
340
341 /*
342 * Special lockdep variants of irq disabling/enabling.
343 * These should be used for locking constructs that
344 * know that a particular irq context which is disabled,
345 * and which is the only irq-context user of a lock,
346 * that it's safe to take the lock in the irq-disabled
347 * section without disabling hardirqs.
348 *
349 * On !CONFIG_LOCKDEP they are equivalent to the normal
350 * irq disable/enable methods.
351 */
352 static inline void disable_irq_nosync_lockdep(unsigned int irq)
353 {
354 disable_irq_nosync(irq);
355 #ifdef CONFIG_LOCKDEP
356 local_irq_disable();
357 #endif
358 }
359
360 static inline void disable_irq_nosync_lockdep_irqsave(unsigned int irq, unsigned long *flags)
361 {
362 disable_irq_nosync(irq);
363 #ifdef CONFIG_LOCKDEP
364 local_irq_save(*flags);
365 #endif
366 }
367
368 static inline void disable_irq_lockdep(unsigned int irq)
369 {
370 disable_irq(irq);
371 #ifdef CONFIG_LOCKDEP
372 local_irq_disable();
373 #endif
374 }
375
376 static inline void enable_irq_lockdep(unsigned int irq)
377 {
378 #ifdef CONFIG_LOCKDEP
379 local_irq_enable();
380 #endif
381 enable_irq(irq);
382 }
383
384 static inline void enable_irq_lockdep_irqrestore(unsigned int irq, unsigned long *flags)
385 {
386 #ifdef CONFIG_LOCKDEP
387 local_irq_restore(*flags);
388 #endif
389 enable_irq(irq);
390 }
391
392 /* IRQ wakeup (PM) control: */
393 extern int irq_set_irq_wake(unsigned int irq, unsigned int on);
394
395 static inline int enable_irq_wake(unsigned int irq)
396 {
397 return irq_set_irq_wake(irq, 1);
398 }
399
400 static inline int disable_irq_wake(unsigned int irq)
401 {
402 return irq_set_irq_wake(irq, 0);
403 }
404
405 /*
406 * irq_get_irqchip_state/irq_set_irqchip_state specific flags
407 */
408 enum irqchip_irq_state {
409 IRQCHIP_STATE_PENDING, /* Is interrupt pending? */
410 IRQCHIP_STATE_ACTIVE, /* Is interrupt in progress? */
411 IRQCHIP_STATE_MASKED, /* Is interrupt masked? */
412 IRQCHIP_STATE_LINE_LEVEL, /* Is IRQ line high? */
413 };
414
415 extern int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
416 bool *state);
417 extern int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
418 bool state);
419
420 #ifdef CONFIG_IRQ_FORCED_THREADING
421 extern bool force_irqthreads;
422 #else
423 #define force_irqthreads (0)
424 #endif
425
426 #ifndef __ARCH_SET_SOFTIRQ_PENDING
427 #define set_softirq_pending(x) (local_softirq_pending() = (x))
428 #define or_softirq_pending(x) (local_softirq_pending() |= (x))
429 #endif
430
431 /* Some architectures might implement lazy enabling/disabling of
432 * interrupts. In some cases, such as stop_machine, we might want
433 * to ensure that after a local_irq_disable(), interrupts have
434 * really been disabled in hardware. Such architectures need to
435 * implement the following hook.
436 */
437 #ifndef hard_irq_disable
438 #define hard_irq_disable() do { } while(0)
439 #endif
440
441 /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
442 frequency threaded job scheduling. For almost all the purposes
443 tasklets are more than enough. F.e. all serial device BHs et
444 al. should be converted to tasklets, not to softirqs.
445 */
446
447 enum
448 {
449 HI_SOFTIRQ=0,
450 TIMER_SOFTIRQ,
451 NET_TX_SOFTIRQ,
452 NET_RX_SOFTIRQ,
453 BLOCK_SOFTIRQ,
454 IRQ_POLL_SOFTIRQ,
455 TASKLET_SOFTIRQ,
456 SCHED_SOFTIRQ,
457 HRTIMER_SOFTIRQ, /* Unused, but kept as tools rely on the
458 numbering. Sigh! */
459 RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
460
461 NR_SOFTIRQS
462 };
463
464 #define SOFTIRQ_STOP_IDLE_MASK (~(1 << RCU_SOFTIRQ))
465
466 /* map softirq index to softirq name. update 'softirq_to_name' in
467 * kernel/softirq.c when adding a new softirq.
468 */
469 extern const char * const softirq_to_name[NR_SOFTIRQS];
470
471 /* softirq mask and active fields moved to irq_cpustat_t in
472 * asm/hardirq.h to get better cache usage. KAO
473 */
474
475 struct softirq_action
476 {
477 void (*action)(struct softirq_action *);
478 };
479
480 asmlinkage void do_softirq(void);
481 asmlinkage void __do_softirq(void);
482
483 #ifdef __ARCH_HAS_DO_SOFTIRQ
484 void do_softirq_own_stack(void);
485 #else
486 static inline void do_softirq_own_stack(void)
487 {
488 __do_softirq();
489 }
490 #endif
491
492 extern void open_softirq(int nr, void (*action)(struct softirq_action *));
493 extern void softirq_init(void);
494 extern void __raise_softirq_irqoff(unsigned int nr);
495
496 extern void raise_softirq_irqoff(unsigned int nr);
497 extern void raise_softirq(unsigned int nr);
498
499 DECLARE_PER_CPU(struct task_struct *, ksoftirqd);
500
501 static inline struct task_struct *this_cpu_ksoftirqd(void)
502 {
503 return this_cpu_read(ksoftirqd);
504 }
505
506 /* Tasklets --- multithreaded analogue of BHs.
507
508 Main feature differing them of generic softirqs: tasklet
509 is running only on one CPU simultaneously.
510
511 Main feature differing them of BHs: different tasklets
512 may be run simultaneously on different CPUs.
513
514 Properties:
515 * If tasklet_schedule() is called, then tasklet is guaranteed
516 to be executed on some cpu at least once after this.
517 * If the tasklet is already scheduled, but its execution is still not
518 started, it will be executed only once.
519 * If this tasklet is already running on another CPU (or schedule is called
520 from tasklet itself), it is rescheduled for later.
521 * Tasklet is strictly serialized wrt itself, but not
522 wrt another tasklets. If client needs some intertask synchronization,
523 he makes it with spinlocks.
524 */
525
526 struct tasklet_struct
527 {
528 struct tasklet_struct *next;
529 unsigned long state;
530 atomic_t count;
531 void (*func)(unsigned long);
532 unsigned long data;
533 };
534
535 #define DECLARE_TASKLET(name, func, data) \
536 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
537
538 #define DECLARE_TASKLET_DISABLED(name, func, data) \
539 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
540
541
542 enum
543 {
544 TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
545 TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
546 };
547
548 #ifdef CONFIG_SMP
549 static inline int tasklet_trylock(struct tasklet_struct *t)
550 {
551 return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
552 }
553
554 static inline void tasklet_unlock(struct tasklet_struct *t)
555 {
556 smp_mb__before_atomic();
557 clear_bit(TASKLET_STATE_RUN, &(t)->state);
558 }
559
560 static inline void tasklet_unlock_wait(struct tasklet_struct *t)
561 {
562 while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
563 }
564 #else
565 #define tasklet_trylock(t) 1
566 #define tasklet_unlock_wait(t) do { } while (0)
567 #define tasklet_unlock(t) do { } while (0)
568 #endif
569
570 extern void __tasklet_schedule(struct tasklet_struct *t);
571
572 static inline void tasklet_schedule(struct tasklet_struct *t)
573 {
574 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
575 __tasklet_schedule(t);
576 }
577
578 extern void __tasklet_hi_schedule(struct tasklet_struct *t);
579
580 static inline void tasklet_hi_schedule(struct tasklet_struct *t)
581 {
582 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
583 __tasklet_hi_schedule(t);
584 }
585
586 extern void __tasklet_hi_schedule_first(struct tasklet_struct *t);
587
588 /*
589 * This version avoids touching any other tasklets. Needed for kmemcheck
590 * in order not to take any page faults while enqueueing this tasklet;
591 * consider VERY carefully whether you really need this or
592 * tasklet_hi_schedule()...
593 */
594 static inline void tasklet_hi_schedule_first(struct tasklet_struct *t)
595 {
596 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
597 __tasklet_hi_schedule_first(t);
598 }
599
600
601 static inline void tasklet_disable_nosync(struct tasklet_struct *t)
602 {
603 atomic_inc(&t->count);
604 smp_mb__after_atomic();
605 }
606
607 static inline void tasklet_disable(struct tasklet_struct *t)
608 {
609 tasklet_disable_nosync(t);
610 tasklet_unlock_wait(t);
611 smp_mb();
612 }
613
614 static inline void tasklet_enable(struct tasklet_struct *t)
615 {
616 smp_mb__before_atomic();
617 atomic_dec(&t->count);
618 }
619
620 extern void tasklet_kill(struct tasklet_struct *t);
621 extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
622 extern void tasklet_init(struct tasklet_struct *t,
623 void (*func)(unsigned long), unsigned long data);
624
625 struct tasklet_hrtimer {
626 struct hrtimer timer;
627 struct tasklet_struct tasklet;
628 enum hrtimer_restart (*function)(struct hrtimer *);
629 };
630
631 extern void
632 tasklet_hrtimer_init(struct tasklet_hrtimer *ttimer,
633 enum hrtimer_restart (*function)(struct hrtimer *),
634 clockid_t which_clock, enum hrtimer_mode mode);
635
636 static inline
637 void tasklet_hrtimer_start(struct tasklet_hrtimer *ttimer, ktime_t time,
638 const enum hrtimer_mode mode)
639 {
640 hrtimer_start(&ttimer->timer, time, mode);
641 }
642
643 static inline
644 void tasklet_hrtimer_cancel(struct tasklet_hrtimer *ttimer)
645 {
646 hrtimer_cancel(&ttimer->timer);
647 tasklet_kill(&ttimer->tasklet);
648 }
649
650 /*
651 * Autoprobing for irqs:
652 *
653 * probe_irq_on() and probe_irq_off() provide robust primitives
654 * for accurate IRQ probing during kernel initialization. They are
655 * reasonably simple to use, are not "fooled" by spurious interrupts,
656 * and, unlike other attempts at IRQ probing, they do not get hung on
657 * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
658 *
659 * For reasonably foolproof probing, use them as follows:
660 *
661 * 1. clear and/or mask the device's internal interrupt.
662 * 2. sti();
663 * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
664 * 4. enable the device and cause it to trigger an interrupt.
665 * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
666 * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
667 * 7. service the device to clear its pending interrupt.
668 * 8. loop again if paranoia is required.
669 *
670 * probe_irq_on() returns a mask of allocated irq's.
671 *
672 * probe_irq_off() takes the mask as a parameter,
673 * and returns the irq number which occurred,
674 * or zero if none occurred, or a negative irq number
675 * if more than one irq occurred.
676 */
677
678 #if !defined(CONFIG_GENERIC_IRQ_PROBE)
679 static inline unsigned long probe_irq_on(void)
680 {
681 return 0;
682 }
683 static inline int probe_irq_off(unsigned long val)
684 {
685 return 0;
686 }
687 static inline unsigned int probe_irq_mask(unsigned long val)
688 {
689 return 0;
690 }
691 #else
692 extern unsigned long probe_irq_on(void); /* returns 0 on failure */
693 extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
694 extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
695 #endif
696
697 #ifdef CONFIG_PROC_FS
698 /* Initialize /proc/irq/ */
699 extern void init_irq_proc(void);
700 #else
701 static inline void init_irq_proc(void)
702 {
703 }
704 #endif
705
706 struct seq_file;
707 int show_interrupts(struct seq_file *p, void *v);
708 int arch_show_interrupts(struct seq_file *p, int prec);
709
710 extern int early_irq_init(void);
711 extern int arch_probe_nr_irqs(void);
712 extern int arch_early_irq_init(void);
713
714 #if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN)
715 /*
716 * We want to know which function is an entrypoint of a hardirq or a softirq.
717 */
718 #define __irq_entry __attribute__((__section__(".irqentry.text")))
719 #define __softirq_entry \
720 __attribute__((__section__(".softirqentry.text")))
721
722 /* Limits of hardirq entrypoints */
723 extern char __irqentry_text_start[];
724 extern char __irqentry_text_end[];
725 /* Limits of softirq entrypoints */
726 extern char __softirqentry_text_start[];
727 extern char __softirqentry_text_end[];
728
729 #else
730 #define __irq_entry
731 #define __softirq_entry
732 #endif
733
734 #endif 1 /*
2 * linux/include/linux/mmc/host.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Host driver specific definitions.
9 */
10 #ifndef LINUX_MMC_HOST_H
11 #define LINUX_MMC_HOST_H
12
13 #include <linux/leds.h>
14 #include <linux/mutex.h>
15 #include <linux/timer.h>
16 #include <linux/sched.h>
17 #include <linux/device.h>
18 #include <linux/fault-inject.h>
19
20 #include <linux/mmc/core.h>
21 #include <linux/mmc/card.h>
22 #include <linux/mmc/mmc.h>
23 #include <linux/mmc/pm.h>
24
25 struct mmc_ios {
26 unsigned int clock; /* clock rate */
27 unsigned short vdd;
28
29 /* vdd stores the bit number of the selected voltage range from below. */
30
31 unsigned char bus_mode; /* command output mode */
32
33 #define MMC_BUSMODE_OPENDRAIN 1
34 #define MMC_BUSMODE_PUSHPULL 2
35
36 unsigned char chip_select; /* SPI chip select */
37
38 #define MMC_CS_DONTCARE 0
39 #define MMC_CS_HIGH 1
40 #define MMC_CS_LOW 2
41
42 unsigned char power_mode; /* power supply mode */
43
44 #define MMC_POWER_OFF 0
45 #define MMC_POWER_UP 1
46 #define MMC_POWER_ON 2
47 #define MMC_POWER_UNDEFINED 3
48
49 unsigned char bus_width; /* data bus width */
50
51 #define MMC_BUS_WIDTH_1 0
52 #define MMC_BUS_WIDTH_4 2
53 #define MMC_BUS_WIDTH_8 3
54
55 unsigned char timing; /* timing specification used */
56
57 #define MMC_TIMING_LEGACY 0
58 #define MMC_TIMING_MMC_HS 1
59 #define MMC_TIMING_SD_HS 2
60 #define MMC_TIMING_UHS_SDR12 3
61 #define MMC_TIMING_UHS_SDR25 4
62 #define MMC_TIMING_UHS_SDR50 5
63 #define MMC_TIMING_UHS_SDR104 6
64 #define MMC_TIMING_UHS_DDR50 7
65 #define MMC_TIMING_MMC_DDR52 8
66 #define MMC_TIMING_MMC_HS200 9
67 #define MMC_TIMING_MMC_HS400 10
68
69 unsigned char signal_voltage; /* signalling voltage (1.8V or 3.3V) */
70
71 #define MMC_SIGNAL_VOLTAGE_330 0
72 #define MMC_SIGNAL_VOLTAGE_180 1
73 #define MMC_SIGNAL_VOLTAGE_120 2
74
75 unsigned char drv_type; /* driver type (A, B, C, D) */
76
77 #define MMC_SET_DRIVER_TYPE_B 0
78 #define MMC_SET_DRIVER_TYPE_A 1
79 #define MMC_SET_DRIVER_TYPE_C 2
80 #define MMC_SET_DRIVER_TYPE_D 3
81
82 bool enhanced_strobe; /* hs400es selection */
83 };
84
85 struct mmc_host_ops {
86 /*
87 * It is optional for the host to implement pre_req and post_req in
88 * order to support double buffering of requests (prepare one
89 * request while another request is active).
90 * pre_req() must always be followed by a post_req().
91 * To undo a call made to pre_req(), call post_req() with
92 * a nonzero err condition.
93 */
94 void (*post_req)(struct mmc_host *host, struct mmc_request *req,
95 int err);
96 void (*pre_req)(struct mmc_host *host, struct mmc_request *req);
97 void (*request)(struct mmc_host *host, struct mmc_request *req);
98
99 /*
100 * Avoid calling the next three functions too often or in a "fast
101 * path", since underlaying controller might implement them in an
102 * expensive and/or slow way. Also note that these functions might
103 * sleep, so don't call them in the atomic contexts!
104 */
105
106 /*
107 * Notes to the set_ios callback:
108 * ios->clock might be 0. For some controllers, setting 0Hz
109 * as any other frequency works. However, some controllers
110 * explicitly need to disable the clock. Otherwise e.g. voltage
111 * switching might fail because the SDCLK is not really quiet.
112 */
113 void (*set_ios)(struct mmc_host *host, struct mmc_ios *ios);
114
115 /*
116 * Return values for the get_ro callback should be:
117 * 0 for a read/write card
118 * 1 for a read-only card
119 * -ENOSYS when not supported (equal to NULL callback)
120 * or a negative errno value when something bad happened
121 */
122 int (*get_ro)(struct mmc_host *host);
123
124 /*
125 * Return values for the get_cd callback should be:
126 * 0 for a absent card
127 * 1 for a present card
128 * -ENOSYS when not supported (equal to NULL callback)
129 * or a negative errno value when something bad happened
130 */
131 int (*get_cd)(struct mmc_host *host);
132
133 void (*enable_sdio_irq)(struct mmc_host *host, int enable);
134
135 /* optional callback for HC quirks */
136 void (*init_card)(struct mmc_host *host, struct mmc_card *card);
137
138 int (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios);
139
140 /* Check if the card is pulling dat[0:3] low */
141 int (*card_busy)(struct mmc_host *host);
142
143 /* The tuning command opcode value is different for SD and eMMC cards */
144 int (*execute_tuning)(struct mmc_host *host, u32 opcode);
145
146 /* Prepare HS400 target operating frequency depending host driver */
147 int (*prepare_hs400_tuning)(struct mmc_host *host, struct mmc_ios *ios);
148 /* Prepare enhanced strobe depending host driver */
149 void (*hs400_enhanced_strobe)(struct mmc_host *host,
150 struct mmc_ios *ios);
151 int (*select_drive_strength)(struct mmc_card *card,
152 unsigned int max_dtr, int host_drv,
153 int card_drv, int *drv_type);
154 void (*hw_reset)(struct mmc_host *host);
155 void (*card_event)(struct mmc_host *host);
156
157 /*
158 * Optional callback to support controllers with HW issues for multiple
159 * I/O. Returns the number of supported blocks for the request.
160 */
161 int (*multi_io_quirk)(struct mmc_card *card,
162 unsigned int direction, int blk_size);
163 };
164
165 struct mmc_card;
166 struct device;
167
168 struct mmc_async_req {
169 /* active mmc request */
170 struct mmc_request *mrq;
171 /*
172 * Check error status of completed mmc request.
173 * Returns 0 if success otherwise non zero.
174 */
175 enum mmc_blk_status (*err_check)(struct mmc_card *, struct mmc_async_req *);
176 };
177
178 /**
179 * struct mmc_slot - MMC slot functions
180 *
181 * @cd_irq: MMC/SD-card slot hotplug detection IRQ or -EINVAL
182 * @handler_priv: MMC/SD-card slot context
183 *
184 * Some MMC/SD host controllers implement slot-functions like card and
185 * write-protect detection natively. However, a large number of controllers
186 * leave these functions to the CPU. This struct provides a hook to attach
187 * such slot-function drivers.
188 */
189 struct mmc_slot {
190 int cd_irq;
191 void *handler_priv;
192 };
193
194 /**
195 * mmc_context_info - synchronization details for mmc context
196 * @is_done_rcv wake up reason was done request
197 * @is_new_req wake up reason was new request
198 * @is_waiting_last_req mmc context waiting for single running request
199 * @wait wait queue
200 */
201 struct mmc_context_info {
202 bool is_done_rcv;
203 bool is_new_req;
204 bool is_waiting_last_req;
205 wait_queue_head_t wait;
206 };
207
208 struct regulator;
209 struct mmc_pwrseq;
210
211 struct mmc_supply {
212 struct regulator *vmmc; /* Card power supply */
213 struct regulator *vqmmc; /* Optional Vccq supply */
214 };
215
216 struct mmc_host {
217 struct device *parent;
218 struct device class_dev;
219 int index;
220 const struct mmc_host_ops *ops;
221 struct mmc_pwrseq *pwrseq;
222 unsigned int f_min;
223 unsigned int f_max;
224 unsigned int f_init;
225 u32 ocr_avail;
226 u32 ocr_avail_sdio; /* SDIO-specific OCR */
227 u32 ocr_avail_sd; /* SD-specific OCR */
228 u32 ocr_avail_mmc; /* MMC-specific OCR */
229 #ifdef CONFIG_PM_SLEEP
230 struct notifier_block pm_notify;
231 #endif
232 u32 max_current_330;
233 u32 max_current_300;
234 u32 max_current_180;
235
236 #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */
237 #define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */
238 #define MMC_VDD_21_22 0x00000200 /* VDD voltage 2.1 ~ 2.2 */
239 #define MMC_VDD_22_23 0x00000400 /* VDD voltage 2.2 ~ 2.3 */
240 #define MMC_VDD_23_24 0x00000800 /* VDD voltage 2.3 ~ 2.4 */
241 #define MMC_VDD_24_25 0x00001000 /* VDD voltage 2.4 ~ 2.5 */
242 #define MMC_VDD_25_26 0x00002000 /* VDD voltage 2.5 ~ 2.6 */
243 #define MMC_VDD_26_27 0x00004000 /* VDD voltage 2.6 ~ 2.7 */
244 #define MMC_VDD_27_28 0x00008000 /* VDD voltage 2.7 ~ 2.8 */
245 #define MMC_VDD_28_29 0x00010000 /* VDD voltage 2.8 ~ 2.9 */
246 #define MMC_VDD_29_30 0x00020000 /* VDD voltage 2.9 ~ 3.0 */
247 #define MMC_VDD_30_31 0x00040000 /* VDD voltage 3.0 ~ 3.1 */
248 #define MMC_VDD_31_32 0x00080000 /* VDD voltage 3.1 ~ 3.2 */
249 #define MMC_VDD_32_33 0x00100000 /* VDD voltage 3.2 ~ 3.3 */
250 #define MMC_VDD_33_34 0x00200000 /* VDD voltage 3.3 ~ 3.4 */
251 #define MMC_VDD_34_35 0x00400000 /* VDD voltage 3.4 ~ 3.5 */
252 #define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */
253
254 u32 caps; /* Host capabilities */
255
256 #define MMC_CAP_4_BIT_DATA (1 << 0) /* Can the host do 4 bit transfers */
257 #define MMC_CAP_MMC_HIGHSPEED (1 << 1) /* Can do MMC high-speed timing */
258 #define MMC_CAP_SD_HIGHSPEED (1 << 2) /* Can do SD high-speed timing */
259 #define MMC_CAP_SDIO_IRQ (1 << 3) /* Can signal pending SDIO IRQs */
260 #define MMC_CAP_SPI (1 << 4) /* Talks only SPI protocols */
261 #define MMC_CAP_NEEDS_POLL (1 << 5) /* Needs polling for card-detection */
262 #define MMC_CAP_8_BIT_DATA (1 << 6) /* Can the host do 8 bit transfers */
263 #define MMC_CAP_AGGRESSIVE_PM (1 << 7) /* Suspend (e)MMC/SD at idle */
264 #define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */
265 #define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */
266 #define MMC_CAP_ERASE (1 << 10) /* Allow erase/trim commands */
267 #define MMC_CAP_1_8V_DDR (1 << 11) /* can support */
268 /* DDR mode at 1.8V */
269 #define MMC_CAP_1_2V_DDR (1 << 12) /* can support */
270 /* DDR mode at 1.2V */
271 #define MMC_CAP_POWER_OFF_CARD (1 << 13) /* Can power off after boot */
272 #define MMC_CAP_BUS_WIDTH_TEST (1 << 14) /* CMD14/CMD19 bus width ok */
273 #define MMC_CAP_UHS_SDR12 (1 << 15) /* Host supports UHS SDR12 mode */
274 #define MMC_CAP_UHS_SDR25 (1 << 16) /* Host supports UHS SDR25 mode */
275 #define MMC_CAP_UHS_SDR50 (1 << 17) /* Host supports UHS SDR50 mode */
276 #define MMC_CAP_UHS_SDR104 (1 << 18) /* Host supports UHS SDR104 mode */
277 #define MMC_CAP_UHS_DDR50 (1 << 19) /* Host supports UHS DDR50 mode */
278 #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */
279 #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */
280 #define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */
281 #define MMC_CAP_CMD_DURING_TFR (1 << 29) /* Commands during data transfer */
282 #define MMC_CAP_CMD23 (1 << 30) /* CMD23 supported. */
283 #define MMC_CAP_HW_RESET (1 << 31) /* Hardware reset */
284
285 u32 caps2; /* More host capabilities */
286
287 #define MMC_CAP2_BOOTPART_NOACC (1 << 0) /* Boot partition no access */
288 #define MMC_CAP2_FULL_PWR_CYCLE (1 << 2) /* Can do full power cycle */
289 #define MMC_CAP2_HS200_1_8V_SDR (1 << 5) /* can support */
290 #define MMC_CAP2_HS200_1_2V_SDR (1 << 6) /* can support */
291 #define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \
292 MMC_CAP2_HS200_1_2V_SDR)
293 #define MMC_CAP2_HC_ERASE_SZ (1 << 9) /* High-capacity erase size */
294 #define MMC_CAP2_CD_ACTIVE_HIGH (1 << 10) /* Card-detect signal active high */
295 #define MMC_CAP2_RO_ACTIVE_HIGH (1 << 11) /* Write-protect signal active high */
296 #define MMC_CAP2_PACKED_RD (1 << 12) /* Allow packed read */
297 #define MMC_CAP2_PACKED_WR (1 << 13) /* Allow packed write */
298 #define MMC_CAP2_PACKED_CMD (MMC_CAP2_PACKED_RD | \
299 MMC_CAP2_PACKED_WR)
300 #define MMC_CAP2_NO_PRESCAN_POWERUP (1 << 14) /* Don't power up before scan */
301 #define MMC_CAP2_HS400_1_8V (1 << 15) /* Can support HS400 1.8V */
302 #define MMC_CAP2_HS400_1_2V (1 << 16) /* Can support HS400 1.2V */
303 #define MMC_CAP2_HS400 (MMC_CAP2_HS400_1_8V | \
304 MMC_CAP2_HS400_1_2V)
305 #define MMC_CAP2_HSX00_1_2V (MMC_CAP2_HS200_1_2V_SDR | MMC_CAP2_HS400_1_2V)
306 #define MMC_CAP2_SDIO_IRQ_NOTHREAD (1 << 17)
307 #define MMC_CAP2_NO_WRITE_PROTECT (1 << 18) /* No physical write protect pin, assume that card is always read-write */
308 #define MMC_CAP2_NO_SDIO (1 << 19) /* Do not send SDIO commands during initialization */
309 #define MMC_CAP2_HS400_ES (1 << 20) /* Host supports enhanced strobe */
310 #define MMC_CAP2_NO_SD (1 << 21) /* Do not send SD commands during initialization */
311 #define MMC_CAP2_NO_MMC (1 << 22) /* Do not send (e)MMC commands during initialization */
312
313 mmc_pm_flag_t pm_caps; /* supported pm features */
314
315 /* host specific block data */
316 unsigned int max_seg_size; /* see blk_queue_max_segment_size */
317 unsigned short max_segs; /* see blk_queue_max_segments */
318 unsigned short unused;
319 unsigned int max_req_size; /* maximum number of bytes in one req */
320 unsigned int max_blk_size; /* maximum size of one mmc block */
321 unsigned int max_blk_count; /* maximum number of blocks in one req */
322 unsigned int max_busy_timeout; /* max busy timeout in ms */
323
324 /* private data */
325 spinlock_t lock; /* lock for claim and bus ops */
326
327 struct mmc_ios ios; /* current io bus settings */
328
329 /* group bitfields together to minimize padding */
330 unsigned int use_spi_crc:1;
331 unsigned int claimed:1; /* host exclusively claimed */
332 unsigned int bus_dead:1; /* bus has been released */
333 #ifdef CONFIG_MMC_DEBUG
334 unsigned int removed:1; /* host is being removed */
335 #endif
336 unsigned int can_retune:1; /* re-tuning can be used */
337 unsigned int doing_retune:1; /* re-tuning in progress */
338 unsigned int retune_now:1; /* do re-tuning at next req */
339 unsigned int retune_paused:1; /* re-tuning is temporarily disabled */
340
341 int rescan_disable; /* disable card detection */
342 int rescan_entered; /* used with nonremovable devices */
343
344 int need_retune; /* re-tuning is needed */
345 int hold_retune; /* hold off re-tuning */
346 unsigned int retune_period; /* re-tuning period in secs */
347 struct timer_list retune_timer; /* for periodic re-tuning */
348
349 bool trigger_card_event; /* card_event necessary */
350
351 struct mmc_card *card; /* device attached to this host */
352
353 wait_queue_head_t wq;
354 struct task_struct *claimer; /* task that has host claimed */
355 int claim_cnt; /* "claim" nesting count */
356
357 struct delayed_work detect;
358 int detect_change; /* card detect flag */
359 struct mmc_slot slot;
360
361 const struct mmc_bus_ops *bus_ops; /* current bus driver */
362 unsigned int bus_refs; /* reference counter */
363
364 unsigned int sdio_irqs;
365 struct task_struct *sdio_irq_thread;
366 bool sdio_irq_pending;
367 atomic_t sdio_irq_thread_abort;
368
369 mmc_pm_flag_t pm_flags; /* requested pm features */
370
371 struct led_trigger *led; /* activity led */
372
373 #ifdef CONFIG_REGULATOR
374 bool regulator_enabled; /* regulator state */
375 #endif
376 struct mmc_supply supply;
377
378 struct dentry *debugfs_root;
379
380 struct mmc_async_req *areq; /* active async req */
381 struct mmc_context_info context_info; /* async synchronization info */
382
383 /* Ongoing data transfer that allows commands during transfer */
384 struct mmc_request *ongoing_mrq;
385
386 #ifdef CONFIG_FAIL_MMC_REQUEST
387 struct fault_attr fail_mmc_request;
388 #endif
389
390 unsigned int actual_clock; /* Actual HC clock rate */
391
392 unsigned int slotno; /* used for sdio acpi binding */
393
394 int dsr_req; /* DSR value is valid */
395 u32 dsr; /* optional driver stage (DSR) value */
396
397 unsigned long private[0] ____cacheline_aligned;
398 };
399
400 struct mmc_host *mmc_alloc_host(int extra, struct device *);
401 int mmc_add_host(struct mmc_host *);
402 void mmc_remove_host(struct mmc_host *);
403 void mmc_free_host(struct mmc_host *);
404 int mmc_of_parse(struct mmc_host *host);
405
406 static inline void *mmc_priv(struct mmc_host *host)
407 {
408 return (void *)host->private;
409 }
410
411 #define mmc_host_is_spi(host) ((host)->caps & MMC_CAP_SPI)
412
413 #define mmc_dev(x) ((x)->parent)
414 #define mmc_classdev(x) (&(x)->class_dev)
415 #define mmc_hostname(x) (dev_name(&(x)->class_dev))
416
417 int mmc_power_save_host(struct mmc_host *host);
418 int mmc_power_restore_host(struct mmc_host *host);
419
420 void mmc_detect_change(struct mmc_host *, unsigned long delay);
421 void mmc_request_done(struct mmc_host *, struct mmc_request *);
422 void mmc_command_done(struct mmc_host *host, struct mmc_request *mrq);
423
424 static inline void mmc_signal_sdio_irq(struct mmc_host *host)
425 {
426 host->ops->enable_sdio_irq(host, 0);
427 host->sdio_irq_pending = true;
428 if (host->sdio_irq_thread)
429 wake_up_process(host->sdio_irq_thread);
430 }
431
432 void sdio_run_irqs(struct mmc_host *host);
433
434 #ifdef CONFIG_REGULATOR
435 int mmc_regulator_get_ocrmask(struct regulator *supply);
436 int mmc_regulator_set_ocr(struct mmc_host *mmc,
437 struct regulator *supply,
438 unsigned short vdd_bit);
439 int mmc_regulator_set_vqmmc(struct mmc_host *mmc, struct mmc_ios *ios);
440 #else
441 static inline int mmc_regulator_get_ocrmask(struct regulator *supply)
442 {
443 return 0;
444 }
445
446 static inline int mmc_regulator_set_ocr(struct mmc_host *mmc,
447 struct regulator *supply,
448 unsigned short vdd_bit)
449 {
450 return 0;
451 }
452
453 static inline int mmc_regulator_set_vqmmc(struct mmc_host *mmc,
454 struct mmc_ios *ios)
455 {
456 return -EINVAL;
457 }
458 #endif
459
460 int mmc_regulator_get_supply(struct mmc_host *mmc);
461
462 static inline int mmc_card_is_removable(struct mmc_host *host)
463 {
464 return !(host->caps & MMC_CAP_NONREMOVABLE);
465 }
466
467 static inline int mmc_card_keep_power(struct mmc_host *host)
468 {
469 return host->pm_flags & MMC_PM_KEEP_POWER;
470 }
471
472 static inline int mmc_card_wake_sdio_irq(struct mmc_host *host)
473 {
474 return host->pm_flags & MMC_PM_WAKE_SDIO_IRQ;
475 }
476
477 static inline int mmc_host_cmd23(struct mmc_host *host)
478 {
479 return host->caps & MMC_CAP_CMD23;
480 }
481
482 static inline int mmc_boot_partition_access(struct mmc_host *host)
483 {
484 return !(host->caps2 & MMC_CAP2_BOOTPART_NOACC);
485 }
486
487 static inline int mmc_host_uhs(struct mmc_host *host)
488 {
489 return host->caps &
490 (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
491 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 |
492 MMC_CAP_UHS_DDR50);
493 }
494
495 static inline int mmc_card_hs(struct mmc_card *card)
496 {
497 return card->host->ios.timing == MMC_TIMING_SD_HS ||
498 card->host->ios.timing == MMC_TIMING_MMC_HS;
499 }
500
501 static inline int mmc_card_uhs(struct mmc_card *card)
502 {
503 return card->host->ios.timing >= MMC_TIMING_UHS_SDR12 &&
504 card->host->ios.timing <= MMC_TIMING_UHS_DDR50;
505 }
506
507 static inline bool mmc_card_hs200(struct mmc_card *card)
508 {
509 return card->host->ios.timing == MMC_TIMING_MMC_HS200;
510 }
511
512 static inline bool mmc_card_ddr52(struct mmc_card *card)
513 {
514 return card->host->ios.timing == MMC_TIMING_MMC_DDR52;
515 }
516
517 static inline bool mmc_card_hs400(struct mmc_card *card)
518 {
519 return card->host->ios.timing == MMC_TIMING_MMC_HS400;
520 }
521
522 static inline bool mmc_card_hs400es(struct mmc_card *card)
523 {
524 return card->host->ios.enhanced_strobe;
525 }
526
527 void mmc_retune_timer_stop(struct mmc_host *host);
528
529 static inline void mmc_retune_needed(struct mmc_host *host)
530 {
531 if (host->can_retune)
532 host->need_retune = 1;
533 }
534
535 static inline void mmc_retune_recheck(struct mmc_host *host)
536 {
537 if (host->hold_retune <= 1)
538 host->retune_now = 1;
539 }
540
541 static inline bool mmc_can_retune(struct mmc_host *host)
542 {
543 return host->can_retune == 1;
544 }
545
546 void mmc_retune_pause(struct mmc_host *host);
547 void mmc_retune_unpause(struct mmc_host *host);
548
549 #endif /* LINUX_MMC_HOST_H */ 1 /*
2 * Linux Plug and Play Support
3 * Copyright by Adam Belay <ambx1@neo.rr.com>
4 * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
5 * Bjorn Helgaas <bjorn.helgaas@hp.com>
6 */
7
8 #ifndef _LINUX_PNP_H
9 #define _LINUX_PNP_H
10
11 #include <linux/device.h>
12 #include <linux/list.h>
13 #include <linux/errno.h>
14 #include <linux/mod_devicetable.h>
15 #include <linux/console.h>
16
17 #define PNP_NAME_LEN 50
18
19 struct pnp_protocol;
20 struct pnp_dev;
21
22 /*
23 * Resource Management
24 */
25 #ifdef CONFIG_PNP
26 struct resource *pnp_get_resource(struct pnp_dev *dev, unsigned long type,
27 unsigned int num);
28 #else
29 static inline struct resource *pnp_get_resource(struct pnp_dev *dev,
30 unsigned long type, unsigned int num)
31 {
32 return NULL;
33 }
34 #endif
35
36 static inline int pnp_resource_valid(struct resource *res)
37 {
38 if (res)
39 return 1;
40 return 0;
41 }
42
43 static inline int pnp_resource_enabled(struct resource *res)
44 {
45 if (res && !(res->flags & IORESOURCE_DISABLED))
46 return 1;
47 return 0;
48 }
49
50 static inline resource_size_t pnp_resource_len(struct resource *res)
51 {
52 if (res->start == 0 && res->end == 0)
53 return 0;
54 return resource_size(res);
55 }
56
57
58 static inline resource_size_t pnp_port_start(struct pnp_dev *dev,
59 unsigned int bar)
60 {
61 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
62
63 if (pnp_resource_valid(res))
64 return res->start;
65 return 0;
66 }
67
68 static inline resource_size_t pnp_port_end(struct pnp_dev *dev,
69 unsigned int bar)
70 {
71 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
72
73 if (pnp_resource_valid(res))
74 return res->end;
75 return 0;
76 }
77
78 static inline unsigned long pnp_port_flags(struct pnp_dev *dev,
79 unsigned int bar)
80 {
81 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
82
83 if (pnp_resource_valid(res))
84 return res->flags;
85 return IORESOURCE_IO | IORESOURCE_AUTO;
86 }
87
88 static inline int pnp_port_valid(struct pnp_dev *dev, unsigned int bar)
89 {
90 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IO, bar));
91 }
92
93 static inline resource_size_t pnp_port_len(struct pnp_dev *dev,
94 unsigned int bar)
95 {
96 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
97
98 if (pnp_resource_valid(res))
99 return pnp_resource_len(res);
100 return 0;
101 }
102
103
104 static inline resource_size_t pnp_mem_start(struct pnp_dev *dev,
105 unsigned int bar)
106 {
107 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
108
109 if (pnp_resource_valid(res))
110 return res->start;
111 return 0;
112 }
113
114 static inline resource_size_t pnp_mem_end(struct pnp_dev *dev,
115 unsigned int bar)
116 {
117 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
118
119 if (pnp_resource_valid(res))
120 return res->end;
121 return 0;
122 }
123
124 static inline unsigned long pnp_mem_flags(struct pnp_dev *dev, unsigned int bar)
125 {
126 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
127
128 if (pnp_resource_valid(res))
129 return res->flags;
130 return IORESOURCE_MEM | IORESOURCE_AUTO;
131 }
132
133 static inline int pnp_mem_valid(struct pnp_dev *dev, unsigned int bar)
134 {
135 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_MEM, bar));
136 }
137
138 static inline resource_size_t pnp_mem_len(struct pnp_dev *dev,
139 unsigned int bar)
140 {
141 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
142
143 if (pnp_resource_valid(res))
144 return pnp_resource_len(res);
145 return 0;
146 }
147
148
149 static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar)
150 {
151 struct resource *res = pnp_get_resource(dev, IORESOURCE_IRQ, bar);
152
153 if (pnp_resource_valid(res))
154 return res->start;
155 return -1;
156 }
157
158 static inline unsigned long pnp_irq_flags(struct pnp_dev *dev, unsigned int bar)
159 {
160 struct resource *res = pnp_get_resource(dev, IORESOURCE_IRQ, bar);
161
162 if (pnp_resource_valid(res))
163 return res->flags;
164 return IORESOURCE_IRQ | IORESOURCE_AUTO;
165 }
166
167 static inline int pnp_irq_valid(struct pnp_dev *dev, unsigned int bar)
168 {
169 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IRQ, bar));
170 }
171
172
173 static inline resource_size_t pnp_dma(struct pnp_dev *dev, unsigned int bar)
174 {
175 struct resource *res = pnp_get_resource(dev, IORESOURCE_DMA, bar);
176
177 if (pnp_resource_valid(res))
178 return res->start;
179 return -1;
180 }
181
182 static inline unsigned long pnp_dma_flags(struct pnp_dev *dev, unsigned int bar)
183 {
184 struct resource *res = pnp_get_resource(dev, IORESOURCE_DMA, bar);
185
186 if (pnp_resource_valid(res))
187 return res->flags;
188 return IORESOURCE_DMA | IORESOURCE_AUTO;
189 }
190
191 static inline int pnp_dma_valid(struct pnp_dev *dev, unsigned int bar)
192 {
193 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_DMA, bar));
194 }
195
196
197 /*
198 * Device Management
199 */
200
201 struct pnp_card {
202 struct device dev; /* Driver Model device interface */
203 unsigned char number; /* used as an index, must be unique */
204 struct list_head global_list; /* node in global list of cards */
205 struct list_head protocol_list; /* node in protocol's list of cards */
206 struct list_head devices; /* devices attached to the card */
207
208 struct pnp_protocol *protocol;
209 struct pnp_id *id; /* contains supported EISA IDs */
210
211 char name[PNP_NAME_LEN]; /* contains a human-readable name */
212 unsigned char pnpver; /* Plug & Play version */
213 unsigned char productver; /* product version */
214 unsigned int serial; /* serial number */
215 unsigned char checksum; /* if zero - checksum passed */
216 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/isapnp */
217 };
218
219 #define global_to_pnp_card(n) list_entry(n, struct pnp_card, global_list)
220 #define protocol_to_pnp_card(n) list_entry(n, struct pnp_card, protocol_list)
221 #define to_pnp_card(n) container_of(n, struct pnp_card, dev)
222 #define pnp_for_each_card(card) \
223 for((card) = global_to_pnp_card(pnp_cards.next); \
224 (card) != global_to_pnp_card(&pnp_cards); \
225 (card) = global_to_pnp_card((card)->global_list.next))
226
227 struct pnp_card_link {
228 struct pnp_card *card;
229 struct pnp_card_driver *driver;
230 void *driver_data;
231 pm_message_t pm_state;
232 };
233
234 static inline void *pnp_get_card_drvdata(struct pnp_card_link *pcard)
235 {
236 return pcard->driver_data;
237 }
238
239 static inline void pnp_set_card_drvdata(struct pnp_card_link *pcard, void *data)
240 {
241 pcard->driver_data = data;
242 }
243
244 struct pnp_dev {
245 struct device dev; /* Driver Model device interface */
246 u64 dma_mask;
247 unsigned int number; /* used as an index, must be unique */
248 int status;
249
250 struct list_head global_list; /* node in global list of devices */
251 struct list_head protocol_list; /* node in list of device's protocol */
252 struct list_head card_list; /* node in card's list of devices */
253 struct list_head rdev_list; /* node in cards list of requested devices */
254
255 struct pnp_protocol *protocol;
256 struct pnp_card *card; /* card the device is attached to, none if NULL */
257 struct pnp_driver *driver;
258 struct pnp_card_link *card_link;
259
260 struct pnp_id *id; /* supported EISA IDs */
261
262 int active;
263 int capabilities;
264 unsigned int num_dependent_sets;
265 struct list_head resources;
266 struct list_head options;
267
268 char name[PNP_NAME_LEN]; /* contains a human-readable name */
269 int flags; /* used by protocols */
270 struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */
271 void *data;
272 };
273
274 #define global_to_pnp_dev(n) list_entry(n, struct pnp_dev, global_list)
275 #define card_to_pnp_dev(n) list_entry(n, struct pnp_dev, card_list)
276 #define protocol_to_pnp_dev(n) list_entry(n, struct pnp_dev, protocol_list)
277 #define to_pnp_dev(n) container_of(n, struct pnp_dev, dev)
278 #define pnp_for_each_dev(dev) \
279 for((dev) = global_to_pnp_dev(pnp_global.next); \
280 (dev) != global_to_pnp_dev(&pnp_global); \
281 (dev) = global_to_pnp_dev((dev)->global_list.next))
282 #define card_for_each_dev(card,dev) \
283 for((dev) = card_to_pnp_dev((card)->devices.next); \
284 (dev) != card_to_pnp_dev(&(card)->devices); \
285 (dev) = card_to_pnp_dev((dev)->card_list.next))
286 #define pnp_dev_name(dev) (dev)->name
287
288 static inline void *pnp_get_drvdata(struct pnp_dev *pdev)
289 {
290 return dev_get_drvdata(&pdev->dev);
291 }
292
293 static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
294 {
295 dev_set_drvdata(&pdev->dev, data);
296 }
297
298 struct pnp_fixup {
299 char id[7];
300 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
301 };
302
303 /* config parameters */
304 #define PNP_CONFIG_NORMAL 0x0001
305 #define PNP_CONFIG_FORCE 0x0002 /* disables validity checking */
306
307 /* capabilities */
308 #define PNP_READ 0x0001
309 #define PNP_WRITE 0x0002
310 #define PNP_DISABLE 0x0004
311 #define PNP_CONFIGURABLE 0x0008
312 #define PNP_REMOVABLE 0x0010
313 #define PNP_CONSOLE 0x0020
314
315 #define pnp_can_read(dev) (((dev)->protocol->get) && \
316 ((dev)->capabilities & PNP_READ))
317 #define pnp_can_write(dev) (((dev)->protocol->set) && \
318 ((dev)->capabilities & PNP_WRITE))
319 #define pnp_can_disable(dev) (((dev)->protocol->disable) && \
320 ((dev)->capabilities & PNP_DISABLE) && \
321 (!((dev)->capabilities & PNP_CONSOLE) || \
322 console_suspend_enabled))
323 #define pnp_can_configure(dev) ((!(dev)->active) && \
324 ((dev)->capabilities & PNP_CONFIGURABLE))
325 #define pnp_can_suspend(dev) (((dev)->protocol->suspend) && \
326 (!((dev)->capabilities & PNP_CONSOLE) || \
327 console_suspend_enabled))
328
329
330 #ifdef CONFIG_ISAPNP
331 extern struct pnp_protocol isapnp_protocol;
332 #define pnp_device_is_isapnp(dev) ((dev)->protocol == (&isapnp_protocol))
333 #else
334 #define pnp_device_is_isapnp(dev) 0
335 #endif
336 extern struct mutex pnp_res_mutex;
337
338 #ifdef CONFIG_PNPBIOS
339 extern struct pnp_protocol pnpbios_protocol;
340 extern bool arch_pnpbios_disabled(void);
341 #define pnp_device_is_pnpbios(dev) ((dev)->protocol == (&pnpbios_protocol))
342 #else
343 #define pnp_device_is_pnpbios(dev) 0
344 #define arch_pnpbios_disabled() false
345 #endif
346
347 #ifdef CONFIG_PNPACPI
348 extern struct pnp_protocol pnpacpi_protocol;
349
350 static inline struct acpi_device *pnp_acpi_device(struct pnp_dev *dev)
351 {
352 if (dev->protocol == &pnpacpi_protocol)
353 return dev->data;
354 return NULL;
355 }
356 #else
357 #define pnp_acpi_device(dev) 0
358 #endif
359
360 /* status */
361 #define PNP_READY 0x0000
362 #define PNP_ATTACHED 0x0001
363 #define PNP_BUSY 0x0002
364 #define PNP_FAULTY 0x0004
365
366 /* isapnp specific macros */
367
368 #define isapnp_card_number(dev) ((dev)->card ? (dev)->card->number : -1)
369 #define isapnp_csn_number(dev) ((dev)->number)
370
371 /*
372 * Driver Management
373 */
374
375 struct pnp_id {
376 char id[PNP_ID_LEN];
377 struct pnp_id *next;
378 };
379
380 struct pnp_driver {
381 char *name;
382 const struct pnp_device_id *id_table;
383 unsigned int flags;
384 int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id);
385 void (*remove) (struct pnp_dev *dev);
386 void (*shutdown) (struct pnp_dev *dev);
387 int (*suspend) (struct pnp_dev *dev, pm_message_t state);
388 int (*resume) (struct pnp_dev *dev);
389 struct device_driver driver;
390 };
391
392 #define to_pnp_driver(drv) container_of(drv, struct pnp_driver, driver)
393
394 struct pnp_card_driver {
395 struct list_head global_list;
396 char *name;
397 const struct pnp_card_device_id *id_table;
398 unsigned int flags;
399 int (*probe) (struct pnp_card_link *card,
400 const struct pnp_card_device_id *card_id);
401 void (*remove) (struct pnp_card_link *card);
402 int (*suspend) (struct pnp_card_link *card, pm_message_t state);
403 int (*resume) (struct pnp_card_link *card);
404 struct pnp_driver link;
405 };
406
407 #define to_pnp_card_driver(drv) container_of(drv, struct pnp_card_driver, link)
408
409 /* pnp driver flags */
410 #define PNP_DRIVER_RES_DO_NOT_CHANGE 0x0001 /* do not change the state of the device */
411 #define PNP_DRIVER_RES_DISABLE 0x0003 /* ensure the device is disabled */
412
413 /*
414 * Protocol Management
415 */
416
417 struct pnp_protocol {
418 struct list_head protocol_list;
419 char *name;
420
421 /* resource control functions */
422 int (*get) (struct pnp_dev *dev);
423 int (*set) (struct pnp_dev *dev);
424 int (*disable) (struct pnp_dev *dev);
425
426 /* protocol specific suspend/resume */
427 bool (*can_wakeup) (struct pnp_dev *dev);
428 int (*suspend) (struct pnp_dev * dev, pm_message_t state);
429 int (*resume) (struct pnp_dev * dev);
430
431 /* used by pnp layer only (look but don't touch) */
432 unsigned char number; /* protocol number */
433 struct device dev; /* link to driver model */
434 struct list_head cards;
435 struct list_head devices;
436 };
437
438 #define to_pnp_protocol(n) list_entry(n, struct pnp_protocol, protocol_list)
439 #define protocol_for_each_card(protocol,card) \
440 for((card) = protocol_to_pnp_card((protocol)->cards.next); \
441 (card) != protocol_to_pnp_card(&(protocol)->cards); \
442 (card) = protocol_to_pnp_card((card)->protocol_list.next))
443 #define protocol_for_each_dev(protocol,dev) \
444 for((dev) = protocol_to_pnp_dev((protocol)->devices.next); \
445 (dev) != protocol_to_pnp_dev(&(protocol)->devices); \
446 (dev) = protocol_to_pnp_dev((dev)->protocol_list.next))
447
448 extern struct bus_type pnp_bus_type;
449
450 #if defined(CONFIG_PNP)
451
452 /* device management */
453 int pnp_device_attach(struct pnp_dev *pnp_dev);
454 void pnp_device_detach(struct pnp_dev *pnp_dev);
455 extern struct list_head pnp_global;
456 extern int pnp_platform_devices;
457
458 /* multidevice card support */
459 struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
460 const char *id, struct pnp_dev *from);
461 void pnp_release_card_device(struct pnp_dev *dev);
462 int pnp_register_card_driver(struct pnp_card_driver *drv);
463 void pnp_unregister_card_driver(struct pnp_card_driver *drv);
464 extern struct list_head pnp_cards;
465
466 /* resource management */
467 int pnp_possible_config(struct pnp_dev *dev, int type, resource_size_t base,
468 resource_size_t size);
469 int pnp_auto_config_dev(struct pnp_dev *dev);
470 int pnp_start_dev(struct pnp_dev *dev);
471 int pnp_stop_dev(struct pnp_dev *dev);
472 int pnp_activate_dev(struct pnp_dev *dev);
473 int pnp_disable_dev(struct pnp_dev *dev);
474 int pnp_range_reserved(resource_size_t start, resource_size_t end);
475
476 /* protocol helpers */
477 int pnp_is_active(struct pnp_dev *dev);
478 int compare_pnp_id(struct pnp_id *pos, const char *id);
479 int pnp_register_driver(struct pnp_driver *drv);
480 void pnp_unregister_driver(struct pnp_driver *drv);
481
482 #else
483
484 /* device management */
485 static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
486 static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { }
487
488 #define pnp_platform_devices 0
489
490 /* multidevice card support */
491 static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; }
492 static inline void pnp_release_card_device(struct pnp_dev *dev) { }
493 static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; }
494 static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { }
495
496 /* resource management */
497 static inline int pnp_possible_config(struct pnp_dev *dev, int type,
498 resource_size_t base,
499 resource_size_t size) { return 0; }
500 static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
501 static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
502 static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
503 static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
504 static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
505 static inline int pnp_range_reserved(resource_size_t start, resource_size_t end) { return 0;}
506
507 /* protocol helpers */
508 static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
509 static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; }
510 static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
511 static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
512
513 #endif /* CONFIG_PNP */
514
515 /**
516 * module_pnp_driver() - Helper macro for registering a PnP driver
517 * @__pnp_driver: pnp_driver struct
518 *
519 * Helper macro for PnP drivers which do not do anything special in module
520 * init/exit. This eliminates a lot of boilerplate. Each module may only
521 * use this macro once, and calling it replaces module_init() and module_exit()
522 */
523 #define module_pnp_driver(__pnp_driver) \
524 module_driver(__pnp_driver, pnp_register_driver, \
525 pnp_unregister_driver)
526
527 #endif /* _LINUX_PNP_H */ 1 #ifndef __LINUX_SPINLOCK_H
2 #define __LINUX_SPINLOCK_H
3
4 /*
5 * include/linux/spinlock.h - generic spinlock/rwlock declarations
6 *
7 * here's the role of the various spinlock/rwlock related include files:
8 *
9 * on SMP builds:
10 *
11 * asm/spinlock_types.h: contains the arch_spinlock_t/arch_rwlock_t and the
12 * initializers
13 *
14 * linux/spinlock_types.h:
15 * defines the generic type and initializers
16 *
17 * asm/spinlock.h: contains the arch_spin_*()/etc. lowlevel
18 * implementations, mostly inline assembly code
19 *
20 * (also included on UP-debug builds:)
21 *
22 * linux/spinlock_api_smp.h:
23 * contains the prototypes for the _spin_*() APIs.
24 *
25 * linux/spinlock.h: builds the final spin_*() APIs.
26 *
27 * on UP builds:
28 *
29 * linux/spinlock_type_up.h:
30 * contains the generic, simplified UP spinlock type.
31 * (which is an empty structure on non-debug builds)
32 *
33 * linux/spinlock_types.h:
34 * defines the generic type and initializers
35 *
36 * linux/spinlock_up.h:
37 * contains the arch_spin_*()/etc. version of UP
38 * builds. (which are NOPs on non-debug, non-preempt
39 * builds)
40 *
41 * (included on UP-non-debug builds:)
42 *
43 * linux/spinlock_api_up.h:
44 * builds the _spin_*() APIs.
45 *
46 * linux/spinlock.h: builds the final spin_*() APIs.
47 */
48
49 #include <linux/typecheck.h>
50 #include <linux/preempt.h>
51 #include <linux/linkage.h>
52 #include <linux/compiler.h>
53 #include <linux/irqflags.h>
54 #include <linux/thread_info.h>
55 #include <linux/kernel.h>
56 #include <linux/stringify.h>
57 #include <linux/bottom_half.h>
58 #include <asm/barrier.h>
59
60
61 /*
62 * Must define these before including other files, inline functions need them
63 */
64 #define LOCK_SECTION_NAME ".text..lock."KBUILD_BASENAME
65
66 #define LOCK_SECTION_START(extra) \
67 ".subsection 1\n\t" \
68 extra \
69 ".ifndef " LOCK_SECTION_NAME "\n\t" \
70 LOCK_SECTION_NAME ":\n\t" \
71 ".endif\n"
72
73 #define LOCK_SECTION_END \
74 ".previous\n\t"
75
76 #define __lockfunc __attribute__((section(".spinlock.text")))
77
78 /*
79 * Pull the arch_spinlock_t and arch_rwlock_t definitions:
80 */
81 #include <linux/spinlock_types.h>
82
83 /*
84 * Pull the arch_spin*() functions/declarations (UP-nondebug doesn't need them):
85 */
86 #ifdef CONFIG_SMP
87 # include <asm/spinlock.h>
88 #else
89 # include <linux/spinlock_up.h>
90 #endif
91
92 #ifdef CONFIG_DEBUG_SPINLOCK
93 extern void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name,
94 struct lock_class_key *key);
95 # define raw_spin_lock_init(lock) \
96 do { \
97 static struct lock_class_key __key; \
98 \
99 __raw_spin_lock_init((lock), #lock, &__key); \
100 } while (0)
101
102 #else
103 # define raw_spin_lock_init(lock) \
104 do { *(lock) = __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0)
105 #endif
106
107 #define raw_spin_is_locked(lock) arch_spin_is_locked(&(lock)->raw_lock)
108
109 #ifdef CONFIG_GENERIC_LOCKBREAK
110 #define raw_spin_is_contended(lock) ((lock)->break_lock)
111 #else
112
113 #ifdef arch_spin_is_contended
114 #define raw_spin_is_contended(lock) arch_spin_is_contended(&(lock)->raw_lock)
115 #else
116 #define raw_spin_is_contended(lock) (((void)(lock), 0))
117 #endif /*arch_spin_is_contended*/
118 #endif
119
120 /*
121 * Despite its name it doesn't necessarily has to be a full barrier.
122 * It should only guarantee that a STORE before the critical section
123 * can not be reordered with LOADs and STOREs inside this section.
124 * spin_lock() is the one-way barrier, this LOAD can not escape out
125 * of the region. So the default implementation simply ensures that
126 * a STORE can not move into the critical section, smp_wmb() should
127 * serialize it with another STORE done by spin_lock().
128 */
129 #ifndef smp_mb__before_spinlock
130 #define smp_mb__before_spinlock() smp_wmb()
131 #endif
132
133 /**
134 * raw_spin_unlock_wait - wait until the spinlock gets unlocked
135 * @lock: the spinlock in question.
136 */
137 #define raw_spin_unlock_wait(lock) arch_spin_unlock_wait(&(lock)->raw_lock)
138
139 #ifdef CONFIG_DEBUG_SPINLOCK
140 extern void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock);
141 #define do_raw_spin_lock_flags(lock, flags) do_raw_spin_lock(lock)
142 extern int do_raw_spin_trylock(raw_spinlock_t *lock);
143 extern void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock);
144 #else
145 static inline void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock)
146 {
147 __acquire(lock);
148 arch_spin_lock(&lock->raw_lock);
149 }
150
151 static inline void
152 do_raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long *flags) __acquires(lock)
153 {
154 __acquire(lock);
155 arch_spin_lock_flags(&lock->raw_lock, *flags);
156 }
157
158 static inline int do_raw_spin_trylock(raw_spinlock_t *lock)
159 {
160 return arch_spin_trylock(&(lock)->raw_lock);
161 }
162
163 static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock)
164 {
165 arch_spin_unlock(&lock->raw_lock);
166 __release(lock);
167 }
168 #endif
169
170 /*
171 * Define the various spin_lock methods. Note we define these
172 * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The
173 * various methods are defined as nops in the case they are not
174 * required.
175 */
176 #define raw_spin_trylock(lock) __cond_lock(lock, _raw_spin_trylock(lock))
177
178 #define raw_spin_lock(lock) _raw_spin_lock(lock)
179
180 #ifdef CONFIG_DEBUG_LOCK_ALLOC
181 # define raw_spin_lock_nested(lock, subclass) \
182 _raw_spin_lock_nested(lock, subclass)
183 # define raw_spin_lock_bh_nested(lock, subclass) \
184 _raw_spin_lock_bh_nested(lock, subclass)
185
186 # define raw_spin_lock_nest_lock(lock, nest_lock) \
187 do { \
188 typecheck(struct lockdep_map *, &(nest_lock)->dep_map);\
189 _raw_spin_lock_nest_lock(lock, &(nest_lock)->dep_map); \
190 } while (0)
191 #else
192 /*
193 * Always evaluate the 'subclass' argument to avoid that the compiler
194 * warns about set-but-not-used variables when building with
195 * CONFIG_DEBUG_LOCK_ALLOC=n and with W=1.
196 */
197 # define raw_spin_lock_nested(lock, subclass) \
198 _raw_spin_lock(((void)(subclass), (lock)))
199 # define raw_spin_lock_nest_lock(lock, nest_lock) _raw_spin_lock(lock)
200 # define raw_spin_lock_bh_nested(lock, subclass) _raw_spin_lock_bh(lock)
201 #endif
202
203 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
204
205 #define raw_spin_lock_irqsave(lock, flags) \
206 do { \
207 typecheck(unsigned long, flags); \
208 flags = _raw_spin_lock_irqsave(lock); \
209 } while (0)
210
211 #ifdef CONFIG_DEBUG_LOCK_ALLOC
212 #define raw_spin_lock_irqsave_nested(lock, flags, subclass) \
213 do { \
214 typecheck(unsigned long, flags); \
215 flags = _raw_spin_lock_irqsave_nested(lock, subclass); \
216 } while (0)
217 #else
218 #define raw_spin_lock_irqsave_nested(lock, flags, subclass) \
219 do { \
220 typecheck(unsigned long, flags); \
221 flags = _raw_spin_lock_irqsave(lock); \
222 } while (0)
223 #endif
224
225 #else
226
227 #define raw_spin_lock_irqsave(lock, flags) \
228 do { \
229 typecheck(unsigned long, flags); \
230 _raw_spin_lock_irqsave(lock, flags); \
231 } while (0)
232
233 #define raw_spin_lock_irqsave_nested(lock, flags, subclass) \
234 raw_spin_lock_irqsave(lock, flags)
235
236 #endif
237
238 #define raw_spin_lock_irq(lock) _raw_spin_lock_irq(lock)
239 #define raw_spin_lock_bh(lock) _raw_spin_lock_bh(lock)
240 #define raw_spin_unlock(lock) _raw_spin_unlock(lock)
241 #define raw_spin_unlock_irq(lock) _raw_spin_unlock_irq(lock)
242
243 #define raw_spin_unlock_irqrestore(lock, flags) \
244 do { \
245 typecheck(unsigned long, flags); \
246 _raw_spin_unlock_irqrestore(lock, flags); \
247 } while (0)
248 #define raw_spin_unlock_bh(lock) _raw_spin_unlock_bh(lock)
249
250 #define raw_spin_trylock_bh(lock) \
251 __cond_lock(lock, _raw_spin_trylock_bh(lock))
252
253 #define raw_spin_trylock_irq(lock) \
254 ({ \
255 local_irq_disable(); \
256 raw_spin_trylock(lock) ? \
257 1 : ({ local_irq_enable(); 0; }); \
258 })
259
260 #define raw_spin_trylock_irqsave(lock, flags) \
261 ({ \
262 local_irq_save(flags); \
263 raw_spin_trylock(lock) ? \
264 1 : ({ local_irq_restore(flags); 0; }); \
265 })
266
267 /**
268 * raw_spin_can_lock - would raw_spin_trylock() succeed?
269 * @lock: the spinlock in question.
270 */
271 #define raw_spin_can_lock(lock) (!raw_spin_is_locked(lock))
272
273 /* Include rwlock functions */
274 #include <linux/rwlock.h>
275
276 /*
277 * Pull the _spin_*()/_read_*()/_write_*() functions/declarations:
278 */
279 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
280 # include <linux/spinlock_api_smp.h>
281 #else
282 # include <linux/spinlock_api_up.h>
283 #endif
284
285 /*
286 * Map the spin_lock functions to the raw variants for PREEMPT_RT=n
287 */
288
289 static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
290 {
291 return &lock->rlock;
292 }
293
294 #define spin_lock_init(_lock) \
295 do { \
296 spinlock_check(_lock); \
297 raw_spin_lock_init(&(_lock)->rlock); \
298 } while (0)
299
300 static __always_inline void spin_lock(spinlock_t *lock)
301 {
302 raw_spin_lock(&lock->rlock);
303 }
304
305 static __always_inline void spin_lock_bh(spinlock_t *lock)
306 {
307 raw_spin_lock_bh(&lock->rlock);
308 }
309
310 static __always_inline int spin_trylock(spinlock_t *lock)
311 {
312 return raw_spin_trylock(&lock->rlock);
313 }
314
315 #define spin_lock_nested(lock, subclass) \
316 do { \
317 raw_spin_lock_nested(spinlock_check(lock), subclass); \
318 } while (0)
319
320 #define spin_lock_bh_nested(lock, subclass) \
321 do { \
322 raw_spin_lock_bh_nested(spinlock_check(lock), subclass);\
323 } while (0)
324
325 #define spin_lock_nest_lock(lock, nest_lock) \
326 do { \
327 raw_spin_lock_nest_lock(spinlock_check(lock), nest_lock); \
328 } while (0)
329
330 static __always_inline void spin_lock_irq(spinlock_t *lock)
331 {
332 raw_spin_lock_irq(&lock->rlock);
333 }
334
335 #define spin_lock_irqsave(lock, flags) \
336 do { \
337 raw_spin_lock_irqsave(spinlock_check(lock), flags); \
338 } while (0)
339
340 #define spin_lock_irqsave_nested(lock, flags, subclass) \
341 do { \
342 raw_spin_lock_irqsave_nested(spinlock_check(lock), flags, subclass); \
343 } while (0)
344
345 static __always_inline void spin_unlock(spinlock_t *lock)
346 {
347 raw_spin_unlock(&lock->rlock);
348 }
349
350 static __always_inline void spin_unlock_bh(spinlock_t *lock)
351 {
352 raw_spin_unlock_bh(&lock->rlock);
353 }
354
355 static __always_inline void spin_unlock_irq(spinlock_t *lock)
356 {
357 raw_spin_unlock_irq(&lock->rlock);
358 }
359
360 static __always_inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
361 {
362 raw_spin_unlock_irqrestore(&lock->rlock, flags);
363 }
364
365 static __always_inline int spin_trylock_bh(spinlock_t *lock)
366 {
367 return raw_spin_trylock_bh(&lock->rlock);
368 }
369
370 static __always_inline int spin_trylock_irq(spinlock_t *lock)
371 {
372 return raw_spin_trylock_irq(&lock->rlock);
373 }
374
375 #define spin_trylock_irqsave(lock, flags) \
376 ({ \
377 raw_spin_trylock_irqsave(spinlock_check(lock), flags); \
378 })
379
380 static __always_inline void spin_unlock_wait(spinlock_t *lock)
381 {
382 raw_spin_unlock_wait(&lock->rlock);
383 }
384
385 static __always_inline int spin_is_locked(spinlock_t *lock)
386 {
387 return raw_spin_is_locked(&lock->rlock);
388 }
389
390 static __always_inline int spin_is_contended(spinlock_t *lock)
391 {
392 return raw_spin_is_contended(&lock->rlock);
393 }
394
395 static __always_inline int spin_can_lock(spinlock_t *lock)
396 {
397 return raw_spin_can_lock(&lock->rlock);
398 }
399
400 #define assert_spin_locked(lock) assert_raw_spin_locked(&(lock)->rlock)
401
402 /*
403 * Pull the atomic_t declaration:
404 * (asm-mips/atomic.h needs above definitions)
405 */
406 #include <linux/atomic.h>
407 /**
408 * atomic_dec_and_lock - lock on reaching reference count zero
409 * @atomic: the atomic counter
410 * @lock: the spinlock in question
411 *
412 * Decrements @atomic by 1. If the result is 0, returns true and locks
413 * @lock. Returns false for all other cases.
414 */
415 extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
416 #define atomic_dec_and_lock(atomic, lock) \
417 __cond_lock(lock, _atomic_dec_and_lock(atomic, lock))
418
419 #endif /* __LINUX_SPINLOCK_H */ |
Here is an explanation of a rule violation arisen while checking your driver against a corresponding kernel.
Note that it may be false positive, i.e. there isn't a real error indeed. Please analyze a given error trace and related source code to understand whether there is an error in your driver.
Error trace column contains a path on which the given rule is violated. You can expand/collapse some entity classes by clicking on corresponding checkboxes in a main menu or in an advanced Others menu. Also you can expand/collapse each particular entity by clicking on +/-. In hovering on some entities you can see some tips. Also the error trace is bound with related source code. Line numbers may be shown as links on the left. You can click on them to open corresponding lines in source code.
Source code column contains a content of files related with the error trace. There is source code of your driver (note that there are some LDV modifications at the end), kernel headers and rule model. Tabs show a currently opened file and other available files. In hovering on them you can see full file names. On clicking a corresponding file content will be shown.
Kernel | Module | Rule | Verifier | Verdict | Status | Timestamp | Bug report |
linux-4.10-rc1.tar.xz | drivers/mmc/host/wbsd.ko | 331_1a | CPAchecker | Bug | Fixed | 2017-01-14 01:54:59 | L0263 |
Comment
Reported: 14 Jan 2016
[Home]