Error Trace

[Home]

Bug # 172

Show/hide error trace
Error trace
Function bodies
Blocks
  • Others...
    Function bodies without model function calls
    Initialization function calls
    Initialization function bodies
    Entry point
    Entry point body
    Function calls
    Skipped function calls
    Formal parameter names
    Declarations
    Assumes
    Assume conditions
    Returns
    Return values
    DEG initialization
    DEG function calls
    Model function calls
    Model function bodies
    Model asserts
    Model state changes
    Model function function calls
    Model function function bodies
    Model returns
    Model others
    Identation
    Line numbers
    Expand signs
-__CPAchecker_initialize()
{
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;
83 typedef unsigned char u_char;
86 typedef unsigned long u_long;
102 typedef __s32 int32_t;
106 typedef __u8 uint8_t;
108 typedef __u32 uint32_t;
111 typedef __u64 uint64_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)();
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;
22 struct bio_vec ;
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 clk ;
15 struct device_node ;
552 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 ;
287 struct iovec ;
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; } ;
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 fwnode_handle ;
31 struct iommu_ops ;
32 struct iommu_group ;
33 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; } ;
1440 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); } ;
1322 struct kvec ;
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; } ;
143 struct iovec { void *iov_base; __kernel_size_t iov_len; } ;
21 struct kvec { void *iov_base; size_t iov_len; } ;
29 union __anonunion____missing_field_name_384 { const struct iovec *iov; const struct kvec *kvec; const struct bio_vec *bvec; struct pipe_inode_info *pipe; } ;
29 union __anonunion____missing_field_name_385 { unsigned long nr_segs; int idx; } ;
29 struct iov_iter { int type; size_t iov_offset; size_t count; union __anonunion____missing_field_name_384 __annonCompField79; union __anonunion____missing_field_name_385 __annonCompField80; } ;
143 struct otp_info { __u32 start; __u32 length; __u32 locked; } ;
239 struct mtd_ecc_stats { __u32 corrected; __u32 failed; __u32 badblocks; __u32 bbtblocks; } ;
283 struct erase_info { struct mtd_info *mtd; uint64_t addr; uint64_t len; uint64_t fail_addr; u_long time; u_long retries; unsigned int dev; unsigned int cell; void (*callback)(struct erase_info *); u_long priv; u_char state; struct erase_info *next; } ;
59 struct mtd_erase_region_info { uint64_t offset; uint32_t erasesize; uint32_t numblocks; unsigned long *lockmap; } ;
66 struct mtd_oob_ops { unsigned int mode; size_t len; size_t retlen; size_t ooblen; size_t oobretlen; uint32_t ooboffs; uint8_t *datbuf; uint8_t *oobbuf; } ;
96 struct mtd_oob_region { u32 offset; u32 length; } ;
113 struct mtd_ooblayout_ops { int (*ecc)(struct mtd_info *, int, struct mtd_oob_region *); int (*free)(struct mtd_info *, int, struct mtd_oob_region *); } ;
128 struct mtd_pairing_info { int pair; int group; } ;
164 struct mtd_pairing_scheme { int ngroups; int (*get_info)(struct mtd_info *, int, struct mtd_pairing_info *); int (*get_wunit)(struct mtd_info *, const struct mtd_pairing_info *); } ;
204 struct mtd_info { u_char type; uint32_t flags; uint64_t size; uint32_t erasesize; uint32_t writesize; uint32_t writebufsize; uint32_t oobsize; uint32_t oobavail; unsigned int erasesize_shift; unsigned int writesize_shift; unsigned int erasesize_mask; unsigned int writesize_mask; unsigned int bitflip_threshold; const char *name; int index; const struct mtd_ooblayout_ops *ooblayout; const struct mtd_pairing_scheme *pairing; unsigned int ecc_step_size; unsigned int ecc_strength; int numeraseregions; struct mtd_erase_region_info *eraseregions; int (*_erase)(struct mtd_info *, struct erase_info *); int (*_point)(struct mtd_info *, loff_t , size_t , size_t *, void **, resource_size_t *); int (*_unpoint)(struct mtd_info *, loff_t , size_t ); unsigned long int (*_get_unmapped_area)(struct mtd_info *, unsigned long, unsigned long, unsigned long); int (*_read)(struct mtd_info *, loff_t , size_t , size_t *, u_char *); int (*_write)(struct mtd_info *, loff_t , size_t , size_t *, const u_char *); int (*_panic_write)(struct mtd_info *, loff_t , size_t , size_t *, const u_char *); int (*_read_oob)(struct mtd_info *, loff_t , struct mtd_oob_ops *); int (*_write_oob)(struct mtd_info *, loff_t , struct mtd_oob_ops *); int (*_get_fact_prot_info)(struct mtd_info *, size_t , size_t *, struct otp_info *); int (*_read_fact_prot_reg)(struct mtd_info *, loff_t , size_t , size_t *, u_char *); int (*_get_user_prot_info)(struct mtd_info *, size_t , size_t *, struct otp_info *); int (*_read_user_prot_reg)(struct mtd_info *, loff_t , size_t , size_t *, u_char *); int (*_write_user_prot_reg)(struct mtd_info *, loff_t , size_t , size_t *, u_char *); int (*_lock_user_prot_reg)(struct mtd_info *, loff_t , size_t ); int (*_writev)(struct mtd_info *, const struct kvec *, unsigned long, loff_t , size_t *); void (*_sync)(struct mtd_info *); int (*_lock)(struct mtd_info *, loff_t , uint64_t ); int (*_unlock)(struct mtd_info *, loff_t , uint64_t ); int (*_is_locked)(struct mtd_info *, loff_t , uint64_t ); int (*_block_isreserved)(struct mtd_info *, loff_t ); int (*_block_isbad)(struct mtd_info *, loff_t ); int (*_block_markbad)(struct mtd_info *, loff_t ); int (*_suspend)(struct mtd_info *); void (*_resume)(struct mtd_info *); void (*_reboot)(struct mtd_info *); int (*_get_device)(struct mtd_info *); void (*_put_device)(struct mtd_info *); struct backing_dev_info *backing_dev_info; struct notifier_block reboot_notifier; struct mtd_ecc_stats ecc_stats; int subpage_sft; void *priv; struct module *owner; struct device dev; int usecount; } ;
521 struct mtd_partition ;
522 struct mtd_part_parser_data ;
133 struct exception_table_entry { int insn; int fixup; int handler; } ;
389 enum read_mode { SPI_NOR_NORMAL = 0, SPI_NOR_FAST = 1, SPI_NOR_DUAL = 2, SPI_NOR_QUAD = 3 } ;
396 enum spi_nor_ops { SPI_NOR_OPS_READ = 0, SPI_NOR_OPS_WRITE = 1, SPI_NOR_OPS_ERASE = 2, SPI_NOR_OPS_LOCK = 3, SPI_NOR_OPS_UNLOCK = 4 } ;
409 struct spi_nor { struct mtd_info mtd; struct mutex lock; struct device *dev; u32 page_size; u8 addr_width; u8 erase_opcode; u8 read_opcode; u8 read_dummy; u8 program_opcode; enum read_mode flash_read; bool sst_write_second; u32 flags; u8 cmd_buf[8U]; int (*prepare)(struct spi_nor *, enum spi_nor_ops ); void (*unprepare)(struct spi_nor *, enum spi_nor_ops ); int (*read_reg)(struct spi_nor *, u8 , u8 *, int); int (*write_reg)(struct spi_nor *, u8 , u8 *, int); ssize_t (*read)(struct spi_nor *, loff_t , size_t , u_char *); ssize_t (*write)(struct spi_nor *, loff_t , size_t , const u_char *); int (*erase)(struct spi_nor *, loff_t ); int (*flash_lock)(struct spi_nor *, loff_t , uint64_t ); int (*flash_unlock)(struct spi_nor *, loff_t , uint64_t ); int (*flash_is_locked)(struct spi_nor *, loff_t , uint64_t ); void *priv; } ;
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; } ;
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 enum fwnode_type { FWNODE_INVALID = 0, FWNODE_OF = 1, FWNODE_ACPI = 2, FWNODE_ACPI_DATA = 3, FWNODE_ACPI_STATIC = 4, FWNODE_PDATA = 5, FWNODE_IRQCHIP = 6 } ;
685 struct fwnode_handle { enum fwnode_type type; struct fwnode_handle *secondary; } ;
32 typedef u32 phandle;
34 struct property { char *name; int length; void *value; struct property *next; unsigned long _flags; unsigned int unique_id; struct bin_attribute attr; } ;
44 struct device_node { const char *name; const char *type; phandle phandle; const char *full_name; struct fwnode_handle fwnode; struct property *properties; struct property *deadprops; struct device_node *parent; struct device_node *child; struct device_node *sibling; struct kobject kobj; unsigned long _flags; void *data; } ;
1290 struct mfd_cell ;
1291 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; } ;
652 enum hifmc_iftype { IF_TYPE_STD = 0, IF_TYPE_DUAL = 1, IF_TYPE_DIO = 2, IF_TYPE_QUAD = 3, IF_TYPE_QIO = 4 } ;
660 struct hifmc_host ;
660 struct hifmc_priv { u32 chipselect; u32 clkrate; struct hifmc_host *host; } ;
100 struct hifmc_host { struct device *dev; struct mutex lock; void *regbase; void *iobase; struct clk *clk; void *buffer; dma_addr_t dma_buffer; struct spi_nor *nor[2U]; u32 num_chip; } ;
1 long int __builtin_expect(long, long);
3 bool ldv_is_err(const void *ptr);
6 long int ldv_ptr_err(const void *ptr);
32 void * __memcpy(void *, const void *, size_t );
32 long int PTR_ERR(const void *ptr);
41 bool IS_ERR(const void *ptr);
88 void mutex_destroy(struct mutex *);
130 void __mutex_init(struct mutex *, const char *, struct lock_class_key *);
152 void mutex_lock_nested(struct mutex *, unsigned int);
188 void mutex_unlock(struct mutex *);
109 int ktime_compare(const ktime_t cmp1, const ktime_t cmp2);
193 ktime_t ktime_add_us(const ktime_t kt, const u64 usec);
184 ktime_t ktime_get();
58 unsigned int readl(const volatile void *addr);
66 void writel(unsigned int val, volatile void *addr);
217 void memcpy_fromio(void *dst, const volatile void *src, size_t count);
223 void memcpy_toio(volatile void *dst, const void *src, size_t count);
11 void ldv_clk_disable_clk(struct clk *clk);
12 int ldv_clk_enable_clk();
13 void ldv_clk_disable_clk_of_hifmc_host(struct clk *clk);
14 int ldv_clk_enable_clk_of_hifmc_host();
250 struct clk * devm_clk_get(struct device *, const char *);
282 int ldv_clk_enable_5(struct clk *clk);
298 void ldv_clk_disable_6(struct clk *clk);
364 int clk_set_rate(struct clk *, unsigned long);
525 int ldv_clk_prepare_enable_7(struct clk *clk);
540 void ldv_clk_disable_unprepare_8(struct clk *clk);
656 void * devm_kmalloc(struct device *, size_t , gfp_t );
662 void * devm_kzalloc(struct device *dev, size_t size, gfp_t gfp);
687 void * devm_ioremap_resource(struct device *, struct resource *);
1021 void * dev_get_drvdata(const struct device *dev);
1026 void dev_set_drvdata(struct device *dev, void *data);
1248 void dev_err(const struct device *, const char *, ...);
1250 void dev_warn(const struct device *, const char *, ...);
28 extern struct dma_map_ops *dma_ops;
30 struct dma_map_ops * get_dma_ops(struct device *dev);
46 int dma_supported(struct device *, u64 );
551 int dma_set_mask(struct device *dev, u64 mask);
575 int dma_set_coherent_mask(struct device *dev, u64 mask);
590 int dma_set_mask_and_coherent(struct device *dev, u64 mask);
714 void * dmam_alloc_coherent(struct device *, size_t , dma_addr_t *, gfp_t );
384 void mtd_set_of_node(struct mtd_info *mtd, struct device_node *np);
527 int mtd_device_parse_register(struct mtd_info *, const const char **, struct mtd_part_parser_data *, const struct mtd_partition *, int);
534 int mtd_device_unregister(struct mtd_info *);
189 void spi_nor_set_flash_node(struct spi_nor *nor, struct device_node *np);
214 int spi_nor_scan(struct spi_nor *, const char *, enum read_mode );
275 struct device_node * of_get_next_available_child(const struct device_node *, struct device_node *);
300 int of_property_read_variable_u32_array(const struct device_node *, const char *, u32 *, size_t , size_t );
463 int of_property_read_u32_array(const struct device_node *np, const char *propname, u32 *out_values, size_t sz);
1038 int of_property_read_u32(const struct device_node *np, const char *propname, u32 *out_value);
56 struct resource * platform_get_resource_byname(struct platform_device *, unsigned int, const char *);
211 void * platform_get_drvdata(const struct platform_device *pdev);
216 void platform_set_drvdata(struct platform_device *pdev, void *data);
116 int wait_op_finish(struct hifmc_host *host);
124 int get_if_type(enum read_mode flash_read);
145 void hisi_spi_nor_init(struct hifmc_host *host);
155 int hisi_spi_nor_prep(struct spi_nor *nor, enum spi_nor_ops ops);
178 void hisi_spi_nor_unprep(struct spi_nor *nor, enum spi_nor_ops ops);
187 int hisi_spi_nor_op_reg(struct spi_nor *nor, u8 opcode, int len, u8 optype);
210 int hisi_spi_nor_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
225 int hisi_spi_nor_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
237 int hisi_spi_nor_dma_transfer(struct spi_nor *nor, loff_t start_off, dma_addr_t dma_buf, size_t len, u8 op_type);
273 ssize_t hisi_spi_nor_read(struct spi_nor *nor, loff_t from, size_t len, u_char *read_buf);
296 ssize_t hisi_spi_nor_write(struct spi_nor *nor, loff_t to, size_t len, const u_char *write_buf);
322 int hisi_spi_nor_register(struct device_node *np, struct hifmc_host *host);
381 void hisi_spi_nor_unregister_all(struct hifmc_host *host);
389 int hisi_spi_nor_register_all(struct hifmc_host *host);
413 int hisi_spi_nor_probe(struct platform_device *pdev);
463 int hisi_spi_nor_remove(struct platform_device *pdev);
477 const struct of_device_id __mod_of__hisi_spi_nor_dt_ids_device_table[2U] = { };
508 void ldv_check_final_state();
511 void ldv_check_return_value(int);
514 void ldv_check_return_value_probe(int);
517 void ldv_initialize();
520 void ldv_handler_precall();
523 int nondet_int();
526 int LDV_IN_INTERRUPT = 0;
529 void ldv_main0_sequence_infinite_withcheck_stateful();
10 void ldv_error();
25 int ldv_undef_int();
14 void * ldv_err_ptr(long error);
28 bool ldv_is_err_or_null(const void *ptr);
9 int ldv_counter_clk = 0;
34 int ldv_counter_clk_of_hifmc_host = 0;
return ;
}
-entry_point
{
531 struct platform_device *var_group1;
532 int res_hisi_spi_nor_probe_14;
533 int ldv_s_hisi_spi_nor_driver_platform_driver;
534 int tmp;
535 int tmp___0;
673 ldv_s_hisi_spi_nor_driver_platform_driver = 0;
663 LDV_IN_INTERRUPT = 1;
672 ldv_initialize() { /* Function call is skipped due to function is undefined */}
676 goto ldv_36041;
676 tmp___0 = nondet_int() { /* Function call is skipped due to function is undefined */}
676 assume(tmp___0 != 0);
679 goto ldv_36040;
677 ldv_36040:;
680 tmp = nondet_int() { /* Function call is skipped due to function is undefined */}
680 switch (tmp);
681 assume(tmp == 0);
685 assume(ldv_s_hisi_spi_nor_driver_platform_driver == 0);
746 -hisi_spi_nor_probe(var_group1)
{
415 struct device *dev;
416 struct resource *res;
417 struct hifmc_host *host;
418 int ret;
419 void *tmp;
420 long tmp___0;
421 _Bool tmp___1;
422 long tmp___2;
423 _Bool tmp___3;
424 long tmp___4;
425 _Bool tmp___5;
426 struct lock_class_key __key;
415 dev = &(pdev->dev);
420 -devm_kzalloc(dev, 232UL, 37748928U)
{
664 void *tmp;
664 tmp = devm_kmalloc(dev, size, gfp | 32768U) { /* Function call is skipped due to function is undefined */}
664 return tmp;;
}
420 host = (struct hifmc_host *)tmp;
421 assume(!(((unsigned long)host) == ((unsigned long)((struct hifmc_host *)0))));
424 -platform_set_drvdata(pdev, (void *)host)
{
219 -dev_set_drvdata(&(pdev->dev), data)
{
1028 dev->driver_data = data;
1029 return ;;
}
220 return ;;
}
425 host->dev = dev;
427 res = platform_get_resource_byname(pdev, 512U, "control") { /* Function call is skipped due to function is undefined */}
428 host->regbase = devm_ioremap_resource(dev, res) { /* Function call is skipped due to function is undefined */}
429 const void *__CPAchecker_TMP_0 = (const void *)(host->regbase);
429 -IS_ERR(__CPAchecker_TMP_0)
{
30 _Bool tmp;
31 -ldv_is_err(ptr)
{
10 return ((unsigned long)ptr) > 2012UL;;
}
31 return tmp;;
}
429 assume(((int)tmp___1) == 0);
432 res = platform_get_resource_byname(pdev, 512U, "memory") { /* Function call is skipped due to function is undefined */}
433 host->iobase = devm_ioremap_resource(dev, res) { /* Function call is skipped due to function is undefined */}
434 const void *__CPAchecker_TMP_2 = (const void *)(host->iobase);
434 -IS_ERR(__CPAchecker_TMP_2)
{
30 _Bool tmp;
31 -ldv_is_err(ptr)
{
10 return ((unsigned long)ptr) > 2012UL;;
}
31 return tmp;;
}
434 assume(((int)tmp___3) == 0);
437 host->clk = devm_clk_get(dev, (const char *)0) { /* Function call is skipped due to function is undefined */}
438 const void *__CPAchecker_TMP_4 = (const void *)(host->clk);
438 -IS_ERR(__CPAchecker_TMP_4)
{
30 _Bool tmp;
31 -ldv_is_err(ptr)
{
10 return ((unsigned long)ptr) > 2012UL;;
}
31 return tmp;;
}
438 assume(((int)tmp___5) == 0);
441 -dma_set_mask_and_coherent(dev, 4294967295ULL)
{
592 int rc;
593 int tmp;
592 -dma_set_mask(dev, mask)
{
553 struct dma_map_ops *ops;
554 struct dma_map_ops *tmp;
555 int tmp___0;
556 int tmp___1;
553 -get_dma_ops(dev)
{
32 long tmp;
35 tmp = __builtin_expect(((unsigned long)dev) == ((unsigned long)((struct device *)0)), 0L) { /* Function call is skipped due to function is undefined */}
35 assume(!(tmp != 0L));
35 assume(!(((unsigned long)(dev->archdata.dma_ops)) == ((unsigned long)((struct dma_map_ops *)0))));
38 return dev->archdata.dma_ops;;
}
553 ops = tmp;
555 unsigned long __CPAchecker_TMP_0 = (unsigned long)(ops->set_dma_mask);
555 assume(!(__CPAchecker_TMP_0 != ((unsigned long)((int (*)(struct device *, u64 ))0))));
558 unsigned long __CPAchecker_TMP_1 = (unsigned long)(dev->dma_mask);
558 assume(!(__CPAchecker_TMP_1 == ((unsigned long)((u64 *)0ULL))));
558 tmp___1 = dma_supported(dev, mask) { /* Function call is skipped due to function is undefined */}
558 assume(!(tmp___1 == 0));
560 *(dev->dma_mask) = mask;
561 return 0;;
}
592 rc = tmp;
593 assume(rc == 0);
594 -dma_set_coherent_mask(dev, mask)
{
577 int tmp;
577 tmp = dma_supported(dev, mask) { /* Function call is skipped due to function is undefined */}
577 assume(!(tmp == 0));
579 dev->coherent_dma_mask = mask;
580 return 0;;
}
595 return rc;;
}
442 assume(!(ret != 0));
447 host->buffer = dmam_alloc_coherent(dev, 4096UL, &(host->dma_buffer), 37748928U) { /* Function call is skipped due to function is undefined */}
449 unsigned long __CPAchecker_TMP_6 = (unsigned long)(host->buffer);
449 assume(!(__CPAchecker_TMP_6 == ((unsigned long)((void *)0))));
452 __mutex_init(&(host->lock), "&host->lock", &__key) { /* Function call is skipped due to function is undefined */}
453 -ldv_clk_prepare_enable_7(host->clk)
{
54 int tmp;
55 -ldv_clk_enable_clk_of_hifmc_host()
{
48 int retval;
49 int tmp;
48 tmp = ldv_undef_int() { /* Function call is skipped due to function is undefined */}
48 retval = tmp;
49 assume(!(retval == 0));
54 return retval;;
}
55 return tmp;;
}
454 -hisi_spi_nor_init(host)
{
147 unsigned int reg;
149 reg = 1647U;
152 volatile void *__CPAchecker_TMP_0 = (volatile void *)(host->regbase);
152 -writel(reg, __CPAchecker_TMP_0 + 8U)
{
66 Ignored inline assembler code
67 return ;;
}
153 return ;;
}
455 -hisi_spi_nor_register_all(host)
{
391 struct device *dev;
392 struct device_node *np;
393 int ret;
391 dev = host->dev;
395 const struct device_node *__CPAchecker_TMP_0 = (const struct device_node *)(dev->of_node);
395 np = of_get_next_available_child(__CPAchecker_TMP_0, (struct device_node *)0) { /* Function call is skipped due to function is undefined */}
395 goto ldv_35982;
395 assume(!(((unsigned long)np) != ((unsigned long)((struct device_node *)0))));
401 ldv_35980:;
406 return 0;;
}
456 assume(!(ret != 0));
459 -ldv_clk_disable_unprepare_8(host->clk)
{
61 -ldv_clk_disable_clk_of_hifmc_host(clk)
{
40 assume(ldv_counter_clk_of_hifmc_host != 1);
40 -ldv_error()
{
15 LDV_ERROR:;
}
}
}
}
}
Source code
1 #ifndef _ASM_X86_DMA_MAPPING_H 2 #define _ASM_X86_DMA_MAPPING_H 3 4 /* 5 * IOMMU interface. See Documentation/DMA-API-HOWTO.txt and 6 * Documentation/DMA-API.txt for documentation. 7 */ 8 9 #include <linux/kmemcheck.h> 10 #include <linux/scatterlist.h> 11 #include <linux/dma-debug.h> 12 #include <asm/io.h> 13 #include <asm/swiotlb.h> 14 #include <linux/dma-contiguous.h> 15 16 #ifdef CONFIG_ISA 17 # define ISA_DMA_BIT_MASK DMA_BIT_MASK(24) 18 #else 19 # define ISA_DMA_BIT_MASK DMA_BIT_MASK(32) 20 #endif 21 22 #define DMA_ERROR_CODE 0 23 24 extern int iommu_merge; 25 extern struct device x86_dma_fallback_dev; 26 extern int panic_on_overflow; 27 28 extern struct dma_map_ops *dma_ops; 29 30 static inline struct dma_map_ops *get_dma_ops(struct device *dev) 31 { 32 #ifndef CONFIG_X86_DEV_DMA_OPS 33 return dma_ops; 34 #else 35 if (unlikely(!dev) || !dev->archdata.dma_ops) 36 return dma_ops; 37 else 38 return dev->archdata.dma_ops; 39 #endif 40 } 41 42 bool arch_dma_alloc_attrs(struct device **dev, gfp_t *gfp); 43 #define arch_dma_alloc_attrs arch_dma_alloc_attrs 44 45 #define HAVE_ARCH_DMA_SUPPORTED 1 46 extern int dma_supported(struct device *hwdev, u64 mask); 47 48 extern void *dma_generic_alloc_coherent(struct device *dev, size_t size, 49 dma_addr_t *dma_addr, gfp_t flag, 50 unsigned long attrs); 51 52 extern void dma_generic_free_coherent(struct device *dev, size_t size, 53 void *vaddr, dma_addr_t dma_addr, 54 unsigned long attrs); 55 56 #ifdef CONFIG_X86_DMA_REMAP /* Platform code defines bridge-specific code */ 57 extern bool dma_capable(struct device *dev, dma_addr_t addr, size_t size); 58 extern dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr); 59 extern phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr); 60 #else 61 62 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) 63 { 64 if (!dev->dma_mask) 65 return 0; 66 67 return addr + size - 1 <= *dev->dma_mask; 68 } 69 70 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) 71 { 72 return paddr; 73 } 74 75 static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) 76 { 77 return daddr; 78 } 79 #endif /* CONFIG_X86_DMA_REMAP */ 80 81 static inline void 82 dma_cache_sync(struct device *dev, void *vaddr, size_t size, 83 enum dma_data_direction dir) 84 { 85 flush_write_buffers(); 86 } 87 88 static inline unsigned long dma_alloc_coherent_mask(struct device *dev, 89 gfp_t gfp) 90 { 91 unsigned long dma_mask = 0; 92 93 dma_mask = dev->coherent_dma_mask; 94 if (!dma_mask) 95 dma_mask = (gfp & GFP_DMA) ? DMA_BIT_MASK(24) : DMA_BIT_MASK(32); 96 97 return dma_mask; 98 } 99 100 static inline gfp_t dma_alloc_coherent_gfp_flags(struct device *dev, gfp_t gfp) 101 { 102 unsigned long dma_mask = dma_alloc_coherent_mask(dev, gfp); 103 104 if (dma_mask <= DMA_BIT_MASK(24)) 105 gfp |= GFP_DMA; 106 #ifdef CONFIG_X86_64 107 if (dma_mask <= DMA_BIT_MASK(32) && !(gfp & GFP_DMA)) 108 gfp |= GFP_DMA32; 109 #endif 110 return gfp; 111 } 112 113 #endif
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 * HiSilicon SPI Nor Flash Controller Driver 4 * 5 * Copyright (c) 2015-2016 HiSilicon Technologies Co., Ltd. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #include <linux/bitops.h> 21 #include <linux/clk.h> 22 #include <linux/dma-mapping.h> 23 #include <linux/iopoll.h> 24 #include <linux/module.h> 25 #include <linux/mtd/mtd.h> 26 #include <linux/mtd/spi-nor.h> 27 #include <linux/of.h> 28 #include <linux/platform_device.h> 29 #include <linux/slab.h> 30 31 /* Hardware register offsets and field definitions */ 32 #define FMC_CFG 0x00 33 #define FMC_CFG_OP_MODE_MASK BIT_MASK(0) 34 #define FMC_CFG_OP_MODE_BOOT 0 35 #define FMC_CFG_OP_MODE_NORMAL 1 36 #define FMC_CFG_FLASH_SEL(type) (((type) & 0x3) << 1) 37 #define FMC_CFG_FLASH_SEL_MASK 0x6 38 #define FMC_ECC_TYPE(type) (((type) & 0x7) << 5) 39 #define FMC_ECC_TYPE_MASK GENMASK(7, 5) 40 #define SPI_NOR_ADDR_MODE_MASK BIT_MASK(10) 41 #define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10) 42 #define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10) 43 #define FMC_GLOBAL_CFG 0x04 44 #define FMC_GLOBAL_CFG_WP_ENABLE BIT(6) 45 #define FMC_SPI_TIMING_CFG 0x08 46 #define TIMING_CFG_TCSH(nr) (((nr) & 0xf) << 8) 47 #define TIMING_CFG_TCSS(nr) (((nr) & 0xf) << 4) 48 #define TIMING_CFG_TSHSL(nr) ((nr) & 0xf) 49 #define CS_HOLD_TIME 0x6 50 #define CS_SETUP_TIME 0x6 51 #define CS_DESELECT_TIME 0xf 52 #define FMC_INT 0x18 53 #define FMC_INT_OP_DONE BIT(0) 54 #define FMC_INT_CLR 0x20 55 #define FMC_CMD 0x24 56 #define FMC_CMD_CMD1(cmd) ((cmd) & 0xff) 57 #define FMC_ADDRL 0x2c 58 #define FMC_OP_CFG 0x30 59 #define OP_CFG_FM_CS(cs) ((cs) << 11) 60 #define OP_CFG_MEM_IF_TYPE(type) (((type) & 0x7) << 7) 61 #define OP_CFG_ADDR_NUM(addr) (((addr) & 0x7) << 4) 62 #define OP_CFG_DUMMY_NUM(dummy) ((dummy) & 0xf) 63 #define FMC_DATA_NUM 0x38 64 #define FMC_DATA_NUM_CNT(cnt) ((cnt) & GENMASK(13, 0)) 65 #define FMC_OP 0x3c 66 #define FMC_OP_DUMMY_EN BIT(8) 67 #define FMC_OP_CMD1_EN BIT(7) 68 #define FMC_OP_ADDR_EN BIT(6) 69 #define FMC_OP_WRITE_DATA_EN BIT(5) 70 #define FMC_OP_READ_DATA_EN BIT(2) 71 #define FMC_OP_READ_STATUS_EN BIT(1) 72 #define FMC_OP_REG_OP_START BIT(0) 73 #define FMC_DMA_LEN 0x40 74 #define FMC_DMA_LEN_SET(len) ((len) & GENMASK(27, 0)) 75 #define FMC_DMA_SADDR_D0 0x4c 76 #define HIFMC_DMA_MAX_LEN (4096) 77 #define HIFMC_DMA_MASK (HIFMC_DMA_MAX_LEN - 1) 78 #define FMC_OP_DMA 0x68 79 #define OP_CTRL_RD_OPCODE(code) (((code) & 0xff) << 16) 80 #define OP_CTRL_WR_OPCODE(code) (((code) & 0xff) << 8) 81 #define OP_CTRL_RW_OP(op) ((op) << 1) 82 #define OP_CTRL_DMA_OP_READY BIT(0) 83 #define FMC_OP_READ 0x0 84 #define FMC_OP_WRITE 0x1 85 #define FMC_WAIT_TIMEOUT 1000000 86 87 enum hifmc_iftype { 88 IF_TYPE_STD, 89 IF_TYPE_DUAL, 90 IF_TYPE_DIO, 91 IF_TYPE_QUAD, 92 IF_TYPE_QIO, 93 }; 94 95 struct hifmc_priv { 96 u32 chipselect; 97 u32 clkrate; 98 struct hifmc_host *host; 99 }; 100 101 #define HIFMC_MAX_CHIP_NUM 2 102 struct hifmc_host { 103 struct device *dev; 104 struct mutex lock; 105 106 void __iomem *regbase; 107 void __iomem *iobase; 108 struct clk *clk; 109 void *buffer; 110 dma_addr_t dma_buffer; 111 112 struct spi_nor *nor[HIFMC_MAX_CHIP_NUM]; 113 u32 num_chip; 114 }; 115 116 static inline int wait_op_finish(struct hifmc_host *host) 117 { 118 u32 reg; 119 120 return readl_poll_timeout(host->regbase + FMC_INT, reg, 121 (reg & FMC_INT_OP_DONE), 0, FMC_WAIT_TIMEOUT); 122 } 123 124 static int get_if_type(enum read_mode flash_read) 125 { 126 enum hifmc_iftype if_type; 127 128 switch (flash_read) { 129 case SPI_NOR_DUAL: 130 if_type = IF_TYPE_DUAL; 131 break; 132 case SPI_NOR_QUAD: 133 if_type = IF_TYPE_QUAD; 134 break; 135 case SPI_NOR_NORMAL: 136 case SPI_NOR_FAST: 137 default: 138 if_type = IF_TYPE_STD; 139 break; 140 } 141 142 return if_type; 143 } 144 145 static void hisi_spi_nor_init(struct hifmc_host *host) 146 { 147 u32 reg; 148 149 reg = TIMING_CFG_TCSH(CS_HOLD_TIME) 150 | TIMING_CFG_TCSS(CS_SETUP_TIME) 151 | TIMING_CFG_TSHSL(CS_DESELECT_TIME); 152 writel(reg, host->regbase + FMC_SPI_TIMING_CFG); 153 } 154 155 static int hisi_spi_nor_prep(struct spi_nor *nor, enum spi_nor_ops ops) 156 { 157 struct hifmc_priv *priv = nor->priv; 158 struct hifmc_host *host = priv->host; 159 int ret; 160 161 mutex_lock(&host->lock); 162 163 ret = clk_set_rate(host->clk, priv->clkrate); 164 if (ret) 165 goto out; 166 167 ret = clk_prepare_enable(host->clk); 168 if (ret) 169 goto out; 170 171 return 0; 172 173 out: 174 mutex_unlock(&host->lock); 175 return ret; 176 } 177 178 static void hisi_spi_nor_unprep(struct spi_nor *nor, enum spi_nor_ops ops) 179 { 180 struct hifmc_priv *priv = nor->priv; 181 struct hifmc_host *host = priv->host; 182 183 clk_disable_unprepare(host->clk); 184 mutex_unlock(&host->lock); 185 } 186 187 static int hisi_spi_nor_op_reg(struct spi_nor *nor, 188 u8 opcode, int len, u8 optype) 189 { 190 struct hifmc_priv *priv = nor->priv; 191 struct hifmc_host *host = priv->host; 192 u32 reg; 193 194 reg = FMC_CMD_CMD1(opcode); 195 writel(reg, host->regbase + FMC_CMD); 196 197 reg = FMC_DATA_NUM_CNT(len); 198 writel(reg, host->regbase + FMC_DATA_NUM); 199 200 reg = OP_CFG_FM_CS(priv->chipselect); 201 writel(reg, host->regbase + FMC_OP_CFG); 202 203 writel(0xff, host->regbase + FMC_INT_CLR); 204 reg = FMC_OP_CMD1_EN | FMC_OP_REG_OP_START | optype; 205 writel(reg, host->regbase + FMC_OP); 206 207 return wait_op_finish(host); 208 } 209 210 static int hisi_spi_nor_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, 211 int len) 212 { 213 struct hifmc_priv *priv = nor->priv; 214 struct hifmc_host *host = priv->host; 215 int ret; 216 217 ret = hisi_spi_nor_op_reg(nor, opcode, len, FMC_OP_READ_DATA_EN); 218 if (ret) 219 return ret; 220 221 memcpy_fromio(buf, host->iobase, len); 222 return 0; 223 } 224 225 static int hisi_spi_nor_write_reg(struct spi_nor *nor, u8 opcode, 226 u8 *buf, int len) 227 { 228 struct hifmc_priv *priv = nor->priv; 229 struct hifmc_host *host = priv->host; 230 231 if (len) 232 memcpy_toio(host->iobase, buf, len); 233 234 return hisi_spi_nor_op_reg(nor, opcode, len, FMC_OP_WRITE_DATA_EN); 235 } 236 237 static int hisi_spi_nor_dma_transfer(struct spi_nor *nor, loff_t start_off, 238 dma_addr_t dma_buf, size_t len, u8 op_type) 239 { 240 struct hifmc_priv *priv = nor->priv; 241 struct hifmc_host *host = priv->host; 242 u8 if_type = 0; 243 u32 reg; 244 245 reg = readl(host->regbase + FMC_CFG); 246 reg &= ~(FMC_CFG_OP_MODE_MASK | SPI_NOR_ADDR_MODE_MASK); 247 reg |= FMC_CFG_OP_MODE_NORMAL; 248 reg |= (nor->addr_width == 4) ? SPI_NOR_ADDR_MODE_4BYTES 249 : SPI_NOR_ADDR_MODE_3BYTES; 250 writel(reg, host->regbase + FMC_CFG); 251 252 writel(start_off, host->regbase + FMC_ADDRL); 253 writel(dma_buf, host->regbase + FMC_DMA_SADDR_D0); 254 writel(FMC_DMA_LEN_SET(len), host->regbase + FMC_DMA_LEN); 255 256 reg = OP_CFG_FM_CS(priv->chipselect); 257 if_type = get_if_type(nor->flash_read); 258 reg |= OP_CFG_MEM_IF_TYPE(if_type); 259 if (op_type == FMC_OP_READ) 260 reg |= OP_CFG_DUMMY_NUM(nor->read_dummy >> 3); 261 writel(reg, host->regbase + FMC_OP_CFG); 262 263 writel(0xff, host->regbase + FMC_INT_CLR); 264 reg = OP_CTRL_RW_OP(op_type) | OP_CTRL_DMA_OP_READY; 265 reg |= (op_type == FMC_OP_READ) 266 ? OP_CTRL_RD_OPCODE(nor->read_opcode) 267 : OP_CTRL_WR_OPCODE(nor->program_opcode); 268 writel(reg, host->regbase + FMC_OP_DMA); 269 270 return wait_op_finish(host); 271 } 272 273 static ssize_t hisi_spi_nor_read(struct spi_nor *nor, loff_t from, size_t len, 274 u_char *read_buf) 275 { 276 struct hifmc_priv *priv = nor->priv; 277 struct hifmc_host *host = priv->host; 278 size_t offset; 279 int ret; 280 281 for (offset = 0; offset < len; offset += HIFMC_DMA_MAX_LEN) { 282 size_t trans = min_t(size_t, HIFMC_DMA_MAX_LEN, len - offset); 283 284 ret = hisi_spi_nor_dma_transfer(nor, 285 from + offset, host->dma_buffer, trans, FMC_OP_READ); 286 if (ret) { 287 dev_warn(nor->dev, "DMA read timeout\n"); 288 return ret; 289 } 290 memcpy(read_buf + offset, host->buffer, trans); 291 } 292 293 return len; 294 } 295 296 static ssize_t hisi_spi_nor_write(struct spi_nor *nor, loff_t to, 297 size_t len, const u_char *write_buf) 298 { 299 struct hifmc_priv *priv = nor->priv; 300 struct hifmc_host *host = priv->host; 301 size_t offset; 302 int ret; 303 304 for (offset = 0; offset < len; offset += HIFMC_DMA_MAX_LEN) { 305 size_t trans = min_t(size_t, HIFMC_DMA_MAX_LEN, len - offset); 306 307 memcpy(host->buffer, write_buf + offset, trans); 308 ret = hisi_spi_nor_dma_transfer(nor, 309 to + offset, host->dma_buffer, trans, FMC_OP_WRITE); 310 if (ret) { 311 dev_warn(nor->dev, "DMA write timeout\n"); 312 return ret; 313 } 314 } 315 316 return len; 317 } 318 319 /** 320 * Get spi flash device information and register it as a mtd device. 321 */ 322 static int hisi_spi_nor_register(struct device_node *np, 323 struct hifmc_host *host) 324 { 325 struct device *dev = host->dev; 326 struct spi_nor *nor; 327 struct hifmc_priv *priv; 328 struct mtd_info *mtd; 329 int ret; 330 331 nor = devm_kzalloc(dev, sizeof(*nor), GFP_KERNEL); 332 if (!nor) 333 return -ENOMEM; 334 335 nor->dev = dev; 336 spi_nor_set_flash_node(nor, np); 337 338 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 339 if (!priv) 340 return -ENOMEM; 341 342 ret = of_property_read_u32(np, "reg", &priv->chipselect); 343 if (ret) { 344 dev_err(dev, "There's no reg property for %s\n", 345 np->full_name); 346 return ret; 347 } 348 349 ret = of_property_read_u32(np, "spi-max-frequency", 350 &priv->clkrate); 351 if (ret) { 352 dev_err(dev, "There's no spi-max-frequency property for %s\n", 353 np->full_name); 354 return ret; 355 } 356 priv->host = host; 357 nor->priv = priv; 358 359 nor->prepare = hisi_spi_nor_prep; 360 nor->unprepare = hisi_spi_nor_unprep; 361 nor->read_reg = hisi_spi_nor_read_reg; 362 nor->write_reg = hisi_spi_nor_write_reg; 363 nor->read = hisi_spi_nor_read; 364 nor->write = hisi_spi_nor_write; 365 nor->erase = NULL; 366 ret = spi_nor_scan(nor, NULL, SPI_NOR_QUAD); 367 if (ret) 368 return ret; 369 370 mtd = &nor->mtd; 371 mtd->name = np->name; 372 ret = mtd_device_register(mtd, NULL, 0); 373 if (ret) 374 return ret; 375 376 host->nor[host->num_chip] = nor; 377 host->num_chip++; 378 return 0; 379 } 380 381 static void hisi_spi_nor_unregister_all(struct hifmc_host *host) 382 { 383 int i; 384 385 for (i = 0; i < host->num_chip; i++) 386 mtd_device_unregister(&host->nor[i]->mtd); 387 } 388 389 static int hisi_spi_nor_register_all(struct hifmc_host *host) 390 { 391 struct device *dev = host->dev; 392 struct device_node *np; 393 int ret; 394 395 for_each_available_child_of_node(dev->of_node, np) { 396 ret = hisi_spi_nor_register(np, host); 397 if (ret) 398 goto fail; 399 400 if (host->num_chip == HIFMC_MAX_CHIP_NUM) { 401 dev_warn(dev, "Flash device number exceeds the maximum chipselect number\n"); 402 break; 403 } 404 } 405 406 return 0; 407 408 fail: 409 hisi_spi_nor_unregister_all(host); 410 return ret; 411 } 412 413 static int hisi_spi_nor_probe(struct platform_device *pdev) 414 { 415 struct device *dev = &pdev->dev; 416 struct resource *res; 417 struct hifmc_host *host; 418 int ret; 419 420 host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); 421 if (!host) 422 return -ENOMEM; 423 424 platform_set_drvdata(pdev, host); 425 host->dev = dev; 426 427 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "control"); 428 host->regbase = devm_ioremap_resource(dev, res); 429 if (IS_ERR(host->regbase)) 430 return PTR_ERR(host->regbase); 431 432 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "memory"); 433 host->iobase = devm_ioremap_resource(dev, res); 434 if (IS_ERR(host->iobase)) 435 return PTR_ERR(host->iobase); 436 437 host->clk = devm_clk_get(dev, NULL); 438 if (IS_ERR(host->clk)) 439 return PTR_ERR(host->clk); 440 441 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); 442 if (ret) { 443 dev_warn(dev, "Unable to set dma mask\n"); 444 return ret; 445 } 446 447 host->buffer = dmam_alloc_coherent(dev, HIFMC_DMA_MAX_LEN, 448 &host->dma_buffer, GFP_KERNEL); 449 if (!host->buffer) 450 return -ENOMEM; 451 452 mutex_init(&host->lock); 453 clk_prepare_enable(host->clk); 454 hisi_spi_nor_init(host); 455 ret = hisi_spi_nor_register_all(host); 456 if (ret) 457 mutex_destroy(&host->lock); 458 459 clk_disable_unprepare(host->clk); 460 return ret; 461 } 462 463 static int hisi_spi_nor_remove(struct platform_device *pdev) 464 { 465 struct hifmc_host *host = platform_get_drvdata(pdev); 466 467 hisi_spi_nor_unregister_all(host); 468 mutex_destroy(&host->lock); 469 clk_disable_unprepare(host->clk); 470 return 0; 471 } 472 473 static const struct of_device_id hisi_spi_nor_dt_ids[] = { 474 { .compatible = "hisilicon,fmc-spi-nor"}, 475 { /* sentinel */ } 476 }; 477 MODULE_DEVICE_TABLE(of, hisi_spi_nor_dt_ids); 478 479 static struct platform_driver hisi_spi_nor_driver = { 480 .driver = { 481 .name = "hisi-sfc", 482 .of_match_table = hisi_spi_nor_dt_ids, 483 }, 484 .probe = hisi_spi_nor_probe, 485 .remove = hisi_spi_nor_remove, 486 }; 487 module_platform_driver(hisi_spi_nor_driver); 488 489 MODULE_LICENSE("GPL v2"); 490 MODULE_DESCRIPTION("HiSilicon SPI Nor Flash Controller Driver"); 491 492 493 494 495 496 /* LDV_COMMENT_BEGIN_MAIN */ 497 #ifdef LDV_MAIN0_sequence_infinite_withcheck_stateful 498 499 /*###########################################################################*/ 500 501 /*############## Driver Environment Generator 0.2 output ####################*/ 502 503 /*###########################################################################*/ 504 505 506 507 /* 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. */ 508 void ldv_check_final_state(void); 509 510 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */ 511 void ldv_check_return_value(int res); 512 513 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */ 514 void ldv_check_return_value_probe(int res); 515 516 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */ 517 void ldv_initialize(void); 518 519 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */ 520 void ldv_handler_precall(void); 521 522 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */ 523 int nondet_int(void); 524 525 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */ 526 int LDV_IN_INTERRUPT; 527 528 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */ 529 void ldv_main0_sequence_infinite_withcheck_stateful(void) { 530 531 532 533 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */ 534 /*============================= VARIABLE DECLARATION PART =============================*/ 535 /** STRUCT: struct type: platform_driver, struct name: hisi_spi_nor_driver **/ 536 /* content: static int hisi_spi_nor_probe(struct platform_device *pdev)*/ 537 /* LDV_COMMENT_BEGIN_PREP */ 538 #define FMC_CFG 0x00 539 #define FMC_CFG_OP_MODE_MASK BIT_MASK(0) 540 #define FMC_CFG_OP_MODE_BOOT 0 541 #define FMC_CFG_OP_MODE_NORMAL 1 542 #define FMC_CFG_FLASH_SEL(type) (((type) & 0x3) << 1) 543 #define FMC_CFG_FLASH_SEL_MASK 0x6 544 #define FMC_ECC_TYPE(type) (((type) & 0x7) << 5) 545 #define FMC_ECC_TYPE_MASK GENMASK(7, 5) 546 #define SPI_NOR_ADDR_MODE_MASK BIT_MASK(10) 547 #define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10) 548 #define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10) 549 #define FMC_GLOBAL_CFG 0x04 550 #define FMC_GLOBAL_CFG_WP_ENABLE BIT(6) 551 #define FMC_SPI_TIMING_CFG 0x08 552 #define TIMING_CFG_TCSH(nr) (((nr) & 0xf) << 8) 553 #define TIMING_CFG_TCSS(nr) (((nr) & 0xf) << 4) 554 #define TIMING_CFG_TSHSL(nr) ((nr) & 0xf) 555 #define CS_HOLD_TIME 0x6 556 #define CS_SETUP_TIME 0x6 557 #define CS_DESELECT_TIME 0xf 558 #define FMC_INT 0x18 559 #define FMC_INT_OP_DONE BIT(0) 560 #define FMC_INT_CLR 0x20 561 #define FMC_CMD 0x24 562 #define FMC_CMD_CMD1(cmd) ((cmd) & 0xff) 563 #define FMC_ADDRL 0x2c 564 #define FMC_OP_CFG 0x30 565 #define OP_CFG_FM_CS(cs) ((cs) << 11) 566 #define OP_CFG_MEM_IF_TYPE(type) (((type) & 0x7) << 7) 567 #define OP_CFG_ADDR_NUM(addr) (((addr) & 0x7) << 4) 568 #define OP_CFG_DUMMY_NUM(dummy) ((dummy) & 0xf) 569 #define FMC_DATA_NUM 0x38 570 #define FMC_DATA_NUM_CNT(cnt) ((cnt) & GENMASK(13, 0)) 571 #define FMC_OP 0x3c 572 #define FMC_OP_DUMMY_EN BIT(8) 573 #define FMC_OP_CMD1_EN BIT(7) 574 #define FMC_OP_ADDR_EN BIT(6) 575 #define FMC_OP_WRITE_DATA_EN BIT(5) 576 #define FMC_OP_READ_DATA_EN BIT(2) 577 #define FMC_OP_READ_STATUS_EN BIT(1) 578 #define FMC_OP_REG_OP_START BIT(0) 579 #define FMC_DMA_LEN 0x40 580 #define FMC_DMA_LEN_SET(len) ((len) & GENMASK(27, 0)) 581 #define FMC_DMA_SADDR_D0 0x4c 582 #define HIFMC_DMA_MAX_LEN (4096) 583 #define HIFMC_DMA_MASK (HIFMC_DMA_MAX_LEN - 1) 584 #define FMC_OP_DMA 0x68 585 #define OP_CTRL_RD_OPCODE(code) (((code) & 0xff) << 16) 586 #define OP_CTRL_WR_OPCODE(code) (((code) & 0xff) << 8) 587 #define OP_CTRL_RW_OP(op) ((op) << 1) 588 #define OP_CTRL_DMA_OP_READY BIT(0) 589 #define FMC_OP_READ 0x0 590 #define FMC_OP_WRITE 0x1 591 #define FMC_WAIT_TIMEOUT 1000000 592 #define HIFMC_MAX_CHIP_NUM 2 593 /* LDV_COMMENT_END_PREP */ 594 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "hisi_spi_nor_probe" */ 595 struct platform_device * var_group1; 596 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "hisi_spi_nor_probe" */ 597 static int res_hisi_spi_nor_probe_14; 598 /* content: static int hisi_spi_nor_remove(struct platform_device *pdev)*/ 599 /* LDV_COMMENT_BEGIN_PREP */ 600 #define FMC_CFG 0x00 601 #define FMC_CFG_OP_MODE_MASK BIT_MASK(0) 602 #define FMC_CFG_OP_MODE_BOOT 0 603 #define FMC_CFG_OP_MODE_NORMAL 1 604 #define FMC_CFG_FLASH_SEL(type) (((type) & 0x3) << 1) 605 #define FMC_CFG_FLASH_SEL_MASK 0x6 606 #define FMC_ECC_TYPE(type) (((type) & 0x7) << 5) 607 #define FMC_ECC_TYPE_MASK GENMASK(7, 5) 608 #define SPI_NOR_ADDR_MODE_MASK BIT_MASK(10) 609 #define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10) 610 #define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10) 611 #define FMC_GLOBAL_CFG 0x04 612 #define FMC_GLOBAL_CFG_WP_ENABLE BIT(6) 613 #define FMC_SPI_TIMING_CFG 0x08 614 #define TIMING_CFG_TCSH(nr) (((nr) & 0xf) << 8) 615 #define TIMING_CFG_TCSS(nr) (((nr) & 0xf) << 4) 616 #define TIMING_CFG_TSHSL(nr) ((nr) & 0xf) 617 #define CS_HOLD_TIME 0x6 618 #define CS_SETUP_TIME 0x6 619 #define CS_DESELECT_TIME 0xf 620 #define FMC_INT 0x18 621 #define FMC_INT_OP_DONE BIT(0) 622 #define FMC_INT_CLR 0x20 623 #define FMC_CMD 0x24 624 #define FMC_CMD_CMD1(cmd) ((cmd) & 0xff) 625 #define FMC_ADDRL 0x2c 626 #define FMC_OP_CFG 0x30 627 #define OP_CFG_FM_CS(cs) ((cs) << 11) 628 #define OP_CFG_MEM_IF_TYPE(type) (((type) & 0x7) << 7) 629 #define OP_CFG_ADDR_NUM(addr) (((addr) & 0x7) << 4) 630 #define OP_CFG_DUMMY_NUM(dummy) ((dummy) & 0xf) 631 #define FMC_DATA_NUM 0x38 632 #define FMC_DATA_NUM_CNT(cnt) ((cnt) & GENMASK(13, 0)) 633 #define FMC_OP 0x3c 634 #define FMC_OP_DUMMY_EN BIT(8) 635 #define FMC_OP_CMD1_EN BIT(7) 636 #define FMC_OP_ADDR_EN BIT(6) 637 #define FMC_OP_WRITE_DATA_EN BIT(5) 638 #define FMC_OP_READ_DATA_EN BIT(2) 639 #define FMC_OP_READ_STATUS_EN BIT(1) 640 #define FMC_OP_REG_OP_START BIT(0) 641 #define FMC_DMA_LEN 0x40 642 #define FMC_DMA_LEN_SET(len) ((len) & GENMASK(27, 0)) 643 #define FMC_DMA_SADDR_D0 0x4c 644 #define HIFMC_DMA_MAX_LEN (4096) 645 #define HIFMC_DMA_MASK (HIFMC_DMA_MAX_LEN - 1) 646 #define FMC_OP_DMA 0x68 647 #define OP_CTRL_RD_OPCODE(code) (((code) & 0xff) << 16) 648 #define OP_CTRL_WR_OPCODE(code) (((code) & 0xff) << 8) 649 #define OP_CTRL_RW_OP(op) ((op) << 1) 650 #define OP_CTRL_DMA_OP_READY BIT(0) 651 #define FMC_OP_READ 0x0 652 #define FMC_OP_WRITE 0x1 653 #define FMC_WAIT_TIMEOUT 1000000 654 #define HIFMC_MAX_CHIP_NUM 2 655 /* LDV_COMMENT_END_PREP */ 656 657 658 659 660 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */ 661 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */ 662 /*============================= VARIABLE INITIALIZING PART =============================*/ 663 LDV_IN_INTERRUPT=1; 664 665 666 667 668 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */ 669 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */ 670 /*============================= FUNCTION CALL SECTION =============================*/ 671 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */ 672 ldv_initialize(); 673 int ldv_s_hisi_spi_nor_driver_platform_driver = 0; 674 675 676 while( nondet_int() 677 || !(ldv_s_hisi_spi_nor_driver_platform_driver == 0) 678 ) { 679 680 switch(nondet_int()) { 681 682 case 0: { 683 684 /** STRUCT: struct type: platform_driver, struct name: hisi_spi_nor_driver **/ 685 if(ldv_s_hisi_spi_nor_driver_platform_driver==0) { 686 687 /* content: static int hisi_spi_nor_probe(struct platform_device *pdev)*/ 688 /* LDV_COMMENT_BEGIN_PREP */ 689 #define FMC_CFG 0x00 690 #define FMC_CFG_OP_MODE_MASK BIT_MASK(0) 691 #define FMC_CFG_OP_MODE_BOOT 0 692 #define FMC_CFG_OP_MODE_NORMAL 1 693 #define FMC_CFG_FLASH_SEL(type) (((type) & 0x3) << 1) 694 #define FMC_CFG_FLASH_SEL_MASK 0x6 695 #define FMC_ECC_TYPE(type) (((type) & 0x7) << 5) 696 #define FMC_ECC_TYPE_MASK GENMASK(7, 5) 697 #define SPI_NOR_ADDR_MODE_MASK BIT_MASK(10) 698 #define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10) 699 #define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10) 700 #define FMC_GLOBAL_CFG 0x04 701 #define FMC_GLOBAL_CFG_WP_ENABLE BIT(6) 702 #define FMC_SPI_TIMING_CFG 0x08 703 #define TIMING_CFG_TCSH(nr) (((nr) & 0xf) << 8) 704 #define TIMING_CFG_TCSS(nr) (((nr) & 0xf) << 4) 705 #define TIMING_CFG_TSHSL(nr) ((nr) & 0xf) 706 #define CS_HOLD_TIME 0x6 707 #define CS_SETUP_TIME 0x6 708 #define CS_DESELECT_TIME 0xf 709 #define FMC_INT 0x18 710 #define FMC_INT_OP_DONE BIT(0) 711 #define FMC_INT_CLR 0x20 712 #define FMC_CMD 0x24 713 #define FMC_CMD_CMD1(cmd) ((cmd) & 0xff) 714 #define FMC_ADDRL 0x2c 715 #define FMC_OP_CFG 0x30 716 #define OP_CFG_FM_CS(cs) ((cs) << 11) 717 #define OP_CFG_MEM_IF_TYPE(type) (((type) & 0x7) << 7) 718 #define OP_CFG_ADDR_NUM(addr) (((addr) & 0x7) << 4) 719 #define OP_CFG_DUMMY_NUM(dummy) ((dummy) & 0xf) 720 #define FMC_DATA_NUM 0x38 721 #define FMC_DATA_NUM_CNT(cnt) ((cnt) & GENMASK(13, 0)) 722 #define FMC_OP 0x3c 723 #define FMC_OP_DUMMY_EN BIT(8) 724 #define FMC_OP_CMD1_EN BIT(7) 725 #define FMC_OP_ADDR_EN BIT(6) 726 #define FMC_OP_WRITE_DATA_EN BIT(5) 727 #define FMC_OP_READ_DATA_EN BIT(2) 728 #define FMC_OP_READ_STATUS_EN BIT(1) 729 #define FMC_OP_REG_OP_START BIT(0) 730 #define FMC_DMA_LEN 0x40 731 #define FMC_DMA_LEN_SET(len) ((len) & GENMASK(27, 0)) 732 #define FMC_DMA_SADDR_D0 0x4c 733 #define HIFMC_DMA_MAX_LEN (4096) 734 #define HIFMC_DMA_MASK (HIFMC_DMA_MAX_LEN - 1) 735 #define FMC_OP_DMA 0x68 736 #define OP_CTRL_RD_OPCODE(code) (((code) & 0xff) << 16) 737 #define OP_CTRL_WR_OPCODE(code) (((code) & 0xff) << 8) 738 #define OP_CTRL_RW_OP(op) ((op) << 1) 739 #define OP_CTRL_DMA_OP_READY BIT(0) 740 #define FMC_OP_READ 0x0 741 #define FMC_OP_WRITE 0x1 742 #define FMC_WAIT_TIMEOUT 1000000 743 #define HIFMC_MAX_CHIP_NUM 2 744 /* LDV_COMMENT_END_PREP */ 745 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "hisi_spi_nor_driver". Standart function test for correct return result. */ 746 res_hisi_spi_nor_probe_14 = hisi_spi_nor_probe( var_group1); 747 ldv_check_return_value(res_hisi_spi_nor_probe_14); 748 ldv_check_return_value_probe(res_hisi_spi_nor_probe_14); 749 if(res_hisi_spi_nor_probe_14) 750 goto ldv_module_exit; 751 ldv_s_hisi_spi_nor_driver_platform_driver++; 752 753 } 754 755 } 756 757 break; 758 case 1: { 759 760 /** STRUCT: struct type: platform_driver, struct name: hisi_spi_nor_driver **/ 761 if(ldv_s_hisi_spi_nor_driver_platform_driver==1) { 762 763 /* content: static int hisi_spi_nor_remove(struct platform_device *pdev)*/ 764 /* LDV_COMMENT_BEGIN_PREP */ 765 #define FMC_CFG 0x00 766 #define FMC_CFG_OP_MODE_MASK BIT_MASK(0) 767 #define FMC_CFG_OP_MODE_BOOT 0 768 #define FMC_CFG_OP_MODE_NORMAL 1 769 #define FMC_CFG_FLASH_SEL(type) (((type) & 0x3) << 1) 770 #define FMC_CFG_FLASH_SEL_MASK 0x6 771 #define FMC_ECC_TYPE(type) (((type) & 0x7) << 5) 772 #define FMC_ECC_TYPE_MASK GENMASK(7, 5) 773 #define SPI_NOR_ADDR_MODE_MASK BIT_MASK(10) 774 #define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10) 775 #define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10) 776 #define FMC_GLOBAL_CFG 0x04 777 #define FMC_GLOBAL_CFG_WP_ENABLE BIT(6) 778 #define FMC_SPI_TIMING_CFG 0x08 779 #define TIMING_CFG_TCSH(nr) (((nr) & 0xf) << 8) 780 #define TIMING_CFG_TCSS(nr) (((nr) & 0xf) << 4) 781 #define TIMING_CFG_TSHSL(nr) ((nr) & 0xf) 782 #define CS_HOLD_TIME 0x6 783 #define CS_SETUP_TIME 0x6 784 #define CS_DESELECT_TIME 0xf 785 #define FMC_INT 0x18 786 #define FMC_INT_OP_DONE BIT(0) 787 #define FMC_INT_CLR 0x20 788 #define FMC_CMD 0x24 789 #define FMC_CMD_CMD1(cmd) ((cmd) & 0xff) 790 #define FMC_ADDRL 0x2c 791 #define FMC_OP_CFG 0x30 792 #define OP_CFG_FM_CS(cs) ((cs) << 11) 793 #define OP_CFG_MEM_IF_TYPE(type) (((type) & 0x7) << 7) 794 #define OP_CFG_ADDR_NUM(addr) (((addr) & 0x7) << 4) 795 #define OP_CFG_DUMMY_NUM(dummy) ((dummy) & 0xf) 796 #define FMC_DATA_NUM 0x38 797 #define FMC_DATA_NUM_CNT(cnt) ((cnt) & GENMASK(13, 0)) 798 #define FMC_OP 0x3c 799 #define FMC_OP_DUMMY_EN BIT(8) 800 #define FMC_OP_CMD1_EN BIT(7) 801 #define FMC_OP_ADDR_EN BIT(6) 802 #define FMC_OP_WRITE_DATA_EN BIT(5) 803 #define FMC_OP_READ_DATA_EN BIT(2) 804 #define FMC_OP_READ_STATUS_EN BIT(1) 805 #define FMC_OP_REG_OP_START BIT(0) 806 #define FMC_DMA_LEN 0x40 807 #define FMC_DMA_LEN_SET(len) ((len) & GENMASK(27, 0)) 808 #define FMC_DMA_SADDR_D0 0x4c 809 #define HIFMC_DMA_MAX_LEN (4096) 810 #define HIFMC_DMA_MASK (HIFMC_DMA_MAX_LEN - 1) 811 #define FMC_OP_DMA 0x68 812 #define OP_CTRL_RD_OPCODE(code) (((code) & 0xff) << 16) 813 #define OP_CTRL_WR_OPCODE(code) (((code) & 0xff) << 8) 814 #define OP_CTRL_RW_OP(op) ((op) << 1) 815 #define OP_CTRL_DMA_OP_READY BIT(0) 816 #define FMC_OP_READ 0x0 817 #define FMC_OP_WRITE 0x1 818 #define FMC_WAIT_TIMEOUT 1000000 819 #define HIFMC_MAX_CHIP_NUM 2 820 /* LDV_COMMENT_END_PREP */ 821 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "hisi_spi_nor_driver" */ 822 ldv_handler_precall(); 823 hisi_spi_nor_remove( var_group1); 824 ldv_s_hisi_spi_nor_driver_platform_driver=0; 825 826 } 827 828 } 829 830 break; 831 default: break; 832 833 } 834 835 } 836 837 ldv_module_exit: 838 839 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */ 840 ldv_final: ldv_check_final_state(); 841 842 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */ 843 return; 844 845 } 846 #endif 847 848 /* 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 #include <linux/module.h> 9 struct clk; 10 11 extern void ldv_clk_disable_clk(struct clk *clk); 12 extern int ldv_clk_enable_clk(void); 13 extern void ldv_clk_disable_clk_of_hifmc_host(struct clk *clk); 14 extern int ldv_clk_enable_clk_of_hifmc_host(void); 15 #line 1 "/home/ldvuser/ldv/ref_launches/work/current--X--drivers--X--defaultlinux-4.10-rc1.tar.xz--X--322_7a--X--cpachecker/linux-4.10-rc1.tar.xz/csd_deg_dscv/15584/dscv_tempdir/dscv/ri/322_7a/drivers/mtd/spi-nor/hisi-sfc.c" 16 17 /* 18 * HiSilicon SPI Nor Flash Controller Driver 19 * 20 * Copyright (c) 2015-2016 HiSilicon Technologies Co., Ltd. 21 * 22 * This program is free software; you can redistribute it and/or modify 23 * it under the terms of the GNU General Public License as published by 24 * the Free Software Foundation; either version 2 of the License, or 25 * (at your option) any later version. 26 * 27 * This program is distributed in the hope that it will be useful, 28 * but WITHOUT ANY WARRANTY; without even the implied warranty of 29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 * GNU General Public License for more details. 31 * 32 * You should have received a copy of the GNU General Public License 33 * along with this program. If not, see <http://www.gnu.org/licenses/>. 34 */ 35 #include <linux/bitops.h> 36 #include <linux/clk.h> 37 #include <linux/dma-mapping.h> 38 #include <linux/iopoll.h> 39 #include <linux/module.h> 40 #include <linux/mtd/mtd.h> 41 #include <linux/mtd/spi-nor.h> 42 #include <linux/of.h> 43 #include <linux/platform_device.h> 44 #include <linux/slab.h> 45 46 /* Hardware register offsets and field definitions */ 47 #define FMC_CFG 0x00 48 #define FMC_CFG_OP_MODE_MASK BIT_MASK(0) 49 #define FMC_CFG_OP_MODE_BOOT 0 50 #define FMC_CFG_OP_MODE_NORMAL 1 51 #define FMC_CFG_FLASH_SEL(type) (((type) & 0x3) << 1) 52 #define FMC_CFG_FLASH_SEL_MASK 0x6 53 #define FMC_ECC_TYPE(type) (((type) & 0x7) << 5) 54 #define FMC_ECC_TYPE_MASK GENMASK(7, 5) 55 #define SPI_NOR_ADDR_MODE_MASK BIT_MASK(10) 56 #define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10) 57 #define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10) 58 #define FMC_GLOBAL_CFG 0x04 59 #define FMC_GLOBAL_CFG_WP_ENABLE BIT(6) 60 #define FMC_SPI_TIMING_CFG 0x08 61 #define TIMING_CFG_TCSH(nr) (((nr) & 0xf) << 8) 62 #define TIMING_CFG_TCSS(nr) (((nr) & 0xf) << 4) 63 #define TIMING_CFG_TSHSL(nr) ((nr) & 0xf) 64 #define CS_HOLD_TIME 0x6 65 #define CS_SETUP_TIME 0x6 66 #define CS_DESELECT_TIME 0xf 67 #define FMC_INT 0x18 68 #define FMC_INT_OP_DONE BIT(0) 69 #define FMC_INT_CLR 0x20 70 #define FMC_CMD 0x24 71 #define FMC_CMD_CMD1(cmd) ((cmd) & 0xff) 72 #define FMC_ADDRL 0x2c 73 #define FMC_OP_CFG 0x30 74 #define OP_CFG_FM_CS(cs) ((cs) << 11) 75 #define OP_CFG_MEM_IF_TYPE(type) (((type) & 0x7) << 7) 76 #define OP_CFG_ADDR_NUM(addr) (((addr) & 0x7) << 4) 77 #define OP_CFG_DUMMY_NUM(dummy) ((dummy) & 0xf) 78 #define FMC_DATA_NUM 0x38 79 #define FMC_DATA_NUM_CNT(cnt) ((cnt) & GENMASK(13, 0)) 80 #define FMC_OP 0x3c 81 #define FMC_OP_DUMMY_EN BIT(8) 82 #define FMC_OP_CMD1_EN BIT(7) 83 #define FMC_OP_ADDR_EN BIT(6) 84 #define FMC_OP_WRITE_DATA_EN BIT(5) 85 #define FMC_OP_READ_DATA_EN BIT(2) 86 #define FMC_OP_READ_STATUS_EN BIT(1) 87 #define FMC_OP_REG_OP_START BIT(0) 88 #define FMC_DMA_LEN 0x40 89 #define FMC_DMA_LEN_SET(len) ((len) & GENMASK(27, 0)) 90 #define FMC_DMA_SADDR_D0 0x4c 91 #define HIFMC_DMA_MAX_LEN (4096) 92 #define HIFMC_DMA_MASK (HIFMC_DMA_MAX_LEN - 1) 93 #define FMC_OP_DMA 0x68 94 #define OP_CTRL_RD_OPCODE(code) (((code) & 0xff) << 16) 95 #define OP_CTRL_WR_OPCODE(code) (((code) & 0xff) << 8) 96 #define OP_CTRL_RW_OP(op) ((op) << 1) 97 #define OP_CTRL_DMA_OP_READY BIT(0) 98 #define FMC_OP_READ 0x0 99 #define FMC_OP_WRITE 0x1 100 #define FMC_WAIT_TIMEOUT 1000000 101 102 enum hifmc_iftype { 103 IF_TYPE_STD, 104 IF_TYPE_DUAL, 105 IF_TYPE_DIO, 106 IF_TYPE_QUAD, 107 IF_TYPE_QIO, 108 }; 109 110 struct hifmc_priv { 111 u32 chipselect; 112 u32 clkrate; 113 struct hifmc_host *host; 114 }; 115 116 #define HIFMC_MAX_CHIP_NUM 2 117 struct hifmc_host { 118 struct device *dev; 119 struct mutex lock; 120 121 void __iomem *regbase; 122 void __iomem *iobase; 123 struct clk *clk; 124 void *buffer; 125 dma_addr_t dma_buffer; 126 127 struct spi_nor *nor[HIFMC_MAX_CHIP_NUM]; 128 u32 num_chip; 129 }; 130 131 static inline int wait_op_finish(struct hifmc_host *host) 132 { 133 u32 reg; 134 135 return readl_poll_timeout(host->regbase + FMC_INT, reg, 136 (reg & FMC_INT_OP_DONE), 0, FMC_WAIT_TIMEOUT); 137 } 138 139 static int get_if_type(enum read_mode flash_read) 140 { 141 enum hifmc_iftype if_type; 142 143 switch (flash_read) { 144 case SPI_NOR_DUAL: 145 if_type = IF_TYPE_DUAL; 146 break; 147 case SPI_NOR_QUAD: 148 if_type = IF_TYPE_QUAD; 149 break; 150 case SPI_NOR_NORMAL: 151 case SPI_NOR_FAST: 152 default: 153 if_type = IF_TYPE_STD; 154 break; 155 } 156 157 return if_type; 158 } 159 160 static void hisi_spi_nor_init(struct hifmc_host *host) 161 { 162 u32 reg; 163 164 reg = TIMING_CFG_TCSH(CS_HOLD_TIME) 165 | TIMING_CFG_TCSS(CS_SETUP_TIME) 166 | TIMING_CFG_TSHSL(CS_DESELECT_TIME); 167 writel(reg, host->regbase + FMC_SPI_TIMING_CFG); 168 } 169 170 static int hisi_spi_nor_prep(struct spi_nor *nor, enum spi_nor_ops ops) 171 { 172 struct hifmc_priv *priv = nor->priv; 173 struct hifmc_host *host = priv->host; 174 int ret; 175 176 mutex_lock(&host->lock); 177 178 ret = clk_set_rate(host->clk, priv->clkrate); 179 if (ret) 180 goto out; 181 182 ret = clk_prepare_enable(host->clk); 183 if (ret) 184 goto out; 185 186 return 0; 187 188 out: 189 mutex_unlock(&host->lock); 190 return ret; 191 } 192 193 static void hisi_spi_nor_unprep(struct spi_nor *nor, enum spi_nor_ops ops) 194 { 195 struct hifmc_priv *priv = nor->priv; 196 struct hifmc_host *host = priv->host; 197 198 clk_disable_unprepare(host->clk); 199 mutex_unlock(&host->lock); 200 } 201 202 static int hisi_spi_nor_op_reg(struct spi_nor *nor, 203 u8 opcode, int len, u8 optype) 204 { 205 struct hifmc_priv *priv = nor->priv; 206 struct hifmc_host *host = priv->host; 207 u32 reg; 208 209 reg = FMC_CMD_CMD1(opcode); 210 writel(reg, host->regbase + FMC_CMD); 211 212 reg = FMC_DATA_NUM_CNT(len); 213 writel(reg, host->regbase + FMC_DATA_NUM); 214 215 reg = OP_CFG_FM_CS(priv->chipselect); 216 writel(reg, host->regbase + FMC_OP_CFG); 217 218 writel(0xff, host->regbase + FMC_INT_CLR); 219 reg = FMC_OP_CMD1_EN | FMC_OP_REG_OP_START | optype; 220 writel(reg, host->regbase + FMC_OP); 221 222 return wait_op_finish(host); 223 } 224 225 static int hisi_spi_nor_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, 226 int len) 227 { 228 struct hifmc_priv *priv = nor->priv; 229 struct hifmc_host *host = priv->host; 230 int ret; 231 232 ret = hisi_spi_nor_op_reg(nor, opcode, len, FMC_OP_READ_DATA_EN); 233 if (ret) 234 return ret; 235 236 memcpy_fromio(buf, host->iobase, len); 237 return 0; 238 } 239 240 static int hisi_spi_nor_write_reg(struct spi_nor *nor, u8 opcode, 241 u8 *buf, int len) 242 { 243 struct hifmc_priv *priv = nor->priv; 244 struct hifmc_host *host = priv->host; 245 246 if (len) 247 memcpy_toio(host->iobase, buf, len); 248 249 return hisi_spi_nor_op_reg(nor, opcode, len, FMC_OP_WRITE_DATA_EN); 250 } 251 252 static int hisi_spi_nor_dma_transfer(struct spi_nor *nor, loff_t start_off, 253 dma_addr_t dma_buf, size_t len, u8 op_type) 254 { 255 struct hifmc_priv *priv = nor->priv; 256 struct hifmc_host *host = priv->host; 257 u8 if_type = 0; 258 u32 reg; 259 260 reg = readl(host->regbase + FMC_CFG); 261 reg &= ~(FMC_CFG_OP_MODE_MASK | SPI_NOR_ADDR_MODE_MASK); 262 reg |= FMC_CFG_OP_MODE_NORMAL; 263 reg |= (nor->addr_width == 4) ? SPI_NOR_ADDR_MODE_4BYTES 264 : SPI_NOR_ADDR_MODE_3BYTES; 265 writel(reg, host->regbase + FMC_CFG); 266 267 writel(start_off, host->regbase + FMC_ADDRL); 268 writel(dma_buf, host->regbase + FMC_DMA_SADDR_D0); 269 writel(FMC_DMA_LEN_SET(len), host->regbase + FMC_DMA_LEN); 270 271 reg = OP_CFG_FM_CS(priv->chipselect); 272 if_type = get_if_type(nor->flash_read); 273 reg |= OP_CFG_MEM_IF_TYPE(if_type); 274 if (op_type == FMC_OP_READ) 275 reg |= OP_CFG_DUMMY_NUM(nor->read_dummy >> 3); 276 writel(reg, host->regbase + FMC_OP_CFG); 277 278 writel(0xff, host->regbase + FMC_INT_CLR); 279 reg = OP_CTRL_RW_OP(op_type) | OP_CTRL_DMA_OP_READY; 280 reg |= (op_type == FMC_OP_READ) 281 ? OP_CTRL_RD_OPCODE(nor->read_opcode) 282 : OP_CTRL_WR_OPCODE(nor->program_opcode); 283 writel(reg, host->regbase + FMC_OP_DMA); 284 285 return wait_op_finish(host); 286 } 287 288 static ssize_t hisi_spi_nor_read(struct spi_nor *nor, loff_t from, size_t len, 289 u_char *read_buf) 290 { 291 struct hifmc_priv *priv = nor->priv; 292 struct hifmc_host *host = priv->host; 293 size_t offset; 294 int ret; 295 296 for (offset = 0; offset < len; offset += HIFMC_DMA_MAX_LEN) { 297 size_t trans = min_t(size_t, HIFMC_DMA_MAX_LEN, len - offset); 298 299 ret = hisi_spi_nor_dma_transfer(nor, 300 from + offset, host->dma_buffer, trans, FMC_OP_READ); 301 if (ret) { 302 dev_warn(nor->dev, "DMA read timeout\n"); 303 return ret; 304 } 305 memcpy(read_buf + offset, host->buffer, trans); 306 } 307 308 return len; 309 } 310 311 static ssize_t hisi_spi_nor_write(struct spi_nor *nor, loff_t to, 312 size_t len, const u_char *write_buf) 313 { 314 struct hifmc_priv *priv = nor->priv; 315 struct hifmc_host *host = priv->host; 316 size_t offset; 317 int ret; 318 319 for (offset = 0; offset < len; offset += HIFMC_DMA_MAX_LEN) { 320 size_t trans = min_t(size_t, HIFMC_DMA_MAX_LEN, len - offset); 321 322 memcpy(host->buffer, write_buf + offset, trans); 323 ret = hisi_spi_nor_dma_transfer(nor, 324 to + offset, host->dma_buffer, trans, FMC_OP_WRITE); 325 if (ret) { 326 dev_warn(nor->dev, "DMA write timeout\n"); 327 return ret; 328 } 329 } 330 331 return len; 332 } 333 334 /** 335 * Get spi flash device information and register it as a mtd device. 336 */ 337 static int hisi_spi_nor_register(struct device_node *np, 338 struct hifmc_host *host) 339 { 340 struct device *dev = host->dev; 341 struct spi_nor *nor; 342 struct hifmc_priv *priv; 343 struct mtd_info *mtd; 344 int ret; 345 346 nor = devm_kzalloc(dev, sizeof(*nor), GFP_KERNEL); 347 if (!nor) 348 return -ENOMEM; 349 350 nor->dev = dev; 351 spi_nor_set_flash_node(nor, np); 352 353 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 354 if (!priv) 355 return -ENOMEM; 356 357 ret = of_property_read_u32(np, "reg", &priv->chipselect); 358 if (ret) { 359 dev_err(dev, "There's no reg property for %s\n", 360 np->full_name); 361 return ret; 362 } 363 364 ret = of_property_read_u32(np, "spi-max-frequency", 365 &priv->clkrate); 366 if (ret) { 367 dev_err(dev, "There's no spi-max-frequency property for %s\n", 368 np->full_name); 369 return ret; 370 } 371 priv->host = host; 372 nor->priv = priv; 373 374 nor->prepare = hisi_spi_nor_prep; 375 nor->unprepare = hisi_spi_nor_unprep; 376 nor->read_reg = hisi_spi_nor_read_reg; 377 nor->write_reg = hisi_spi_nor_write_reg; 378 nor->read = hisi_spi_nor_read; 379 nor->write = hisi_spi_nor_write; 380 nor->erase = NULL; 381 ret = spi_nor_scan(nor, NULL, SPI_NOR_QUAD); 382 if (ret) 383 return ret; 384 385 mtd = &nor->mtd; 386 mtd->name = np->name; 387 ret = mtd_device_register(mtd, NULL, 0); 388 if (ret) 389 return ret; 390 391 host->nor[host->num_chip] = nor; 392 host->num_chip++; 393 return 0; 394 } 395 396 static void hisi_spi_nor_unregister_all(struct hifmc_host *host) 397 { 398 int i; 399 400 for (i = 0; i < host->num_chip; i++) 401 mtd_device_unregister(&host->nor[i]->mtd); 402 } 403 404 static int hisi_spi_nor_register_all(struct hifmc_host *host) 405 { 406 struct device *dev = host->dev; 407 struct device_node *np; 408 int ret; 409 410 for_each_available_child_of_node(dev->of_node, np) { 411 ret = hisi_spi_nor_register(np, host); 412 if (ret) 413 goto fail; 414 415 if (host->num_chip == HIFMC_MAX_CHIP_NUM) { 416 dev_warn(dev, "Flash device number exceeds the maximum chipselect number\n"); 417 break; 418 } 419 } 420 421 return 0; 422 423 fail: 424 hisi_spi_nor_unregister_all(host); 425 return ret; 426 } 427 428 static int hisi_spi_nor_probe(struct platform_device *pdev) 429 { 430 struct device *dev = &pdev->dev; 431 struct resource *res; 432 struct hifmc_host *host; 433 int ret; 434 435 host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); 436 if (!host) 437 return -ENOMEM; 438 439 platform_set_drvdata(pdev, host); 440 host->dev = dev; 441 442 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "control"); 443 host->regbase = devm_ioremap_resource(dev, res); 444 if (IS_ERR(host->regbase)) 445 return PTR_ERR(host->regbase); 446 447 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "memory"); 448 host->iobase = devm_ioremap_resource(dev, res); 449 if (IS_ERR(host->iobase)) 450 return PTR_ERR(host->iobase); 451 452 host->clk = devm_clk_get(dev, NULL); 453 if (IS_ERR(host->clk)) 454 return PTR_ERR(host->clk); 455 456 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); 457 if (ret) { 458 dev_warn(dev, "Unable to set dma mask\n"); 459 return ret; 460 } 461 462 host->buffer = dmam_alloc_coherent(dev, HIFMC_DMA_MAX_LEN, 463 &host->dma_buffer, GFP_KERNEL); 464 if (!host->buffer) 465 return -ENOMEM; 466 467 mutex_init(&host->lock); 468 clk_prepare_enable(host->clk); 469 hisi_spi_nor_init(host); 470 ret = hisi_spi_nor_register_all(host); 471 if (ret) 472 mutex_destroy(&host->lock); 473 474 clk_disable_unprepare(host->clk); 475 return ret; 476 } 477 478 static int hisi_spi_nor_remove(struct platform_device *pdev) 479 { 480 struct hifmc_host *host = platform_get_drvdata(pdev); 481 482 hisi_spi_nor_unregister_all(host); 483 mutex_destroy(&host->lock); 484 clk_disable_unprepare(host->clk); 485 return 0; 486 } 487 488 static const struct of_device_id hisi_spi_nor_dt_ids[] = { 489 { .compatible = "hisilicon,fmc-spi-nor"}, 490 { /* sentinel */ } 491 }; 492 MODULE_DEVICE_TABLE(of, hisi_spi_nor_dt_ids); 493 494 static struct platform_driver hisi_spi_nor_driver = { 495 .driver = { 496 .name = "hisi-sfc", 497 .of_match_table = hisi_spi_nor_dt_ids, 498 }, 499 .probe = hisi_spi_nor_probe, 500 .remove = hisi_spi_nor_remove, 501 }; 502 module_platform_driver(hisi_spi_nor_driver); 503 504 MODULE_LICENSE("GPL v2"); 505 MODULE_DESCRIPTION("HiSilicon SPI Nor Flash Controller Driver"); 506 507 508 509 510 511 /* LDV_COMMENT_BEGIN_MAIN */ 512 #ifdef LDV_MAIN0_sequence_infinite_withcheck_stateful 513 514 /*###########################################################################*/ 515 516 /*############## Driver Environment Generator 0.2 output ####################*/ 517 518 /*###########################################################################*/ 519 520 521 522 /* 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. */ 523 void ldv_check_final_state(void); 524 525 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */ 526 void ldv_check_return_value(int res); 527 528 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */ 529 void ldv_check_return_value_probe(int res); 530 531 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */ 532 void ldv_initialize(void); 533 534 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */ 535 void ldv_handler_precall(void); 536 537 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */ 538 int nondet_int(void); 539 540 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */ 541 int LDV_IN_INTERRUPT; 542 543 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */ 544 void ldv_main0_sequence_infinite_withcheck_stateful(void) { 545 546 547 548 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */ 549 /*============================= VARIABLE DECLARATION PART =============================*/ 550 /** STRUCT: struct type: platform_driver, struct name: hisi_spi_nor_driver **/ 551 /* content: static int hisi_spi_nor_probe(struct platform_device *pdev)*/ 552 /* LDV_COMMENT_BEGIN_PREP */ 553 #define FMC_CFG 0x00 554 #define FMC_CFG_OP_MODE_MASK BIT_MASK(0) 555 #define FMC_CFG_OP_MODE_BOOT 0 556 #define FMC_CFG_OP_MODE_NORMAL 1 557 #define FMC_CFG_FLASH_SEL(type) (((type) & 0x3) << 1) 558 #define FMC_CFG_FLASH_SEL_MASK 0x6 559 #define FMC_ECC_TYPE(type) (((type) & 0x7) << 5) 560 #define FMC_ECC_TYPE_MASK GENMASK(7, 5) 561 #define SPI_NOR_ADDR_MODE_MASK BIT_MASK(10) 562 #define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10) 563 #define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10) 564 #define FMC_GLOBAL_CFG 0x04 565 #define FMC_GLOBAL_CFG_WP_ENABLE BIT(6) 566 #define FMC_SPI_TIMING_CFG 0x08 567 #define TIMING_CFG_TCSH(nr) (((nr) & 0xf) << 8) 568 #define TIMING_CFG_TCSS(nr) (((nr) & 0xf) << 4) 569 #define TIMING_CFG_TSHSL(nr) ((nr) & 0xf) 570 #define CS_HOLD_TIME 0x6 571 #define CS_SETUP_TIME 0x6 572 #define CS_DESELECT_TIME 0xf 573 #define FMC_INT 0x18 574 #define FMC_INT_OP_DONE BIT(0) 575 #define FMC_INT_CLR 0x20 576 #define FMC_CMD 0x24 577 #define FMC_CMD_CMD1(cmd) ((cmd) & 0xff) 578 #define FMC_ADDRL 0x2c 579 #define FMC_OP_CFG 0x30 580 #define OP_CFG_FM_CS(cs) ((cs) << 11) 581 #define OP_CFG_MEM_IF_TYPE(type) (((type) & 0x7) << 7) 582 #define OP_CFG_ADDR_NUM(addr) (((addr) & 0x7) << 4) 583 #define OP_CFG_DUMMY_NUM(dummy) ((dummy) & 0xf) 584 #define FMC_DATA_NUM 0x38 585 #define FMC_DATA_NUM_CNT(cnt) ((cnt) & GENMASK(13, 0)) 586 #define FMC_OP 0x3c 587 #define FMC_OP_DUMMY_EN BIT(8) 588 #define FMC_OP_CMD1_EN BIT(7) 589 #define FMC_OP_ADDR_EN BIT(6) 590 #define FMC_OP_WRITE_DATA_EN BIT(5) 591 #define FMC_OP_READ_DATA_EN BIT(2) 592 #define FMC_OP_READ_STATUS_EN BIT(1) 593 #define FMC_OP_REG_OP_START BIT(0) 594 #define FMC_DMA_LEN 0x40 595 #define FMC_DMA_LEN_SET(len) ((len) & GENMASK(27, 0)) 596 #define FMC_DMA_SADDR_D0 0x4c 597 #define HIFMC_DMA_MAX_LEN (4096) 598 #define HIFMC_DMA_MASK (HIFMC_DMA_MAX_LEN - 1) 599 #define FMC_OP_DMA 0x68 600 #define OP_CTRL_RD_OPCODE(code) (((code) & 0xff) << 16) 601 #define OP_CTRL_WR_OPCODE(code) (((code) & 0xff) << 8) 602 #define OP_CTRL_RW_OP(op) ((op) << 1) 603 #define OP_CTRL_DMA_OP_READY BIT(0) 604 #define FMC_OP_READ 0x0 605 #define FMC_OP_WRITE 0x1 606 #define FMC_WAIT_TIMEOUT 1000000 607 #define HIFMC_MAX_CHIP_NUM 2 608 /* LDV_COMMENT_END_PREP */ 609 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "hisi_spi_nor_probe" */ 610 struct platform_device * var_group1; 611 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "hisi_spi_nor_probe" */ 612 static int res_hisi_spi_nor_probe_14; 613 /* content: static int hisi_spi_nor_remove(struct platform_device *pdev)*/ 614 /* LDV_COMMENT_BEGIN_PREP */ 615 #define FMC_CFG 0x00 616 #define FMC_CFG_OP_MODE_MASK BIT_MASK(0) 617 #define FMC_CFG_OP_MODE_BOOT 0 618 #define FMC_CFG_OP_MODE_NORMAL 1 619 #define FMC_CFG_FLASH_SEL(type) (((type) & 0x3) << 1) 620 #define FMC_CFG_FLASH_SEL_MASK 0x6 621 #define FMC_ECC_TYPE(type) (((type) & 0x7) << 5) 622 #define FMC_ECC_TYPE_MASK GENMASK(7, 5) 623 #define SPI_NOR_ADDR_MODE_MASK BIT_MASK(10) 624 #define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10) 625 #define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10) 626 #define FMC_GLOBAL_CFG 0x04 627 #define FMC_GLOBAL_CFG_WP_ENABLE BIT(6) 628 #define FMC_SPI_TIMING_CFG 0x08 629 #define TIMING_CFG_TCSH(nr) (((nr) & 0xf) << 8) 630 #define TIMING_CFG_TCSS(nr) (((nr) & 0xf) << 4) 631 #define TIMING_CFG_TSHSL(nr) ((nr) & 0xf) 632 #define CS_HOLD_TIME 0x6 633 #define CS_SETUP_TIME 0x6 634 #define CS_DESELECT_TIME 0xf 635 #define FMC_INT 0x18 636 #define FMC_INT_OP_DONE BIT(0) 637 #define FMC_INT_CLR 0x20 638 #define FMC_CMD 0x24 639 #define FMC_CMD_CMD1(cmd) ((cmd) & 0xff) 640 #define FMC_ADDRL 0x2c 641 #define FMC_OP_CFG 0x30 642 #define OP_CFG_FM_CS(cs) ((cs) << 11) 643 #define OP_CFG_MEM_IF_TYPE(type) (((type) & 0x7) << 7) 644 #define OP_CFG_ADDR_NUM(addr) (((addr) & 0x7) << 4) 645 #define OP_CFG_DUMMY_NUM(dummy) ((dummy) & 0xf) 646 #define FMC_DATA_NUM 0x38 647 #define FMC_DATA_NUM_CNT(cnt) ((cnt) & GENMASK(13, 0)) 648 #define FMC_OP 0x3c 649 #define FMC_OP_DUMMY_EN BIT(8) 650 #define FMC_OP_CMD1_EN BIT(7) 651 #define FMC_OP_ADDR_EN BIT(6) 652 #define FMC_OP_WRITE_DATA_EN BIT(5) 653 #define FMC_OP_READ_DATA_EN BIT(2) 654 #define FMC_OP_READ_STATUS_EN BIT(1) 655 #define FMC_OP_REG_OP_START BIT(0) 656 #define FMC_DMA_LEN 0x40 657 #define FMC_DMA_LEN_SET(len) ((len) & GENMASK(27, 0)) 658 #define FMC_DMA_SADDR_D0 0x4c 659 #define HIFMC_DMA_MAX_LEN (4096) 660 #define HIFMC_DMA_MASK (HIFMC_DMA_MAX_LEN - 1) 661 #define FMC_OP_DMA 0x68 662 #define OP_CTRL_RD_OPCODE(code) (((code) & 0xff) << 16) 663 #define OP_CTRL_WR_OPCODE(code) (((code) & 0xff) << 8) 664 #define OP_CTRL_RW_OP(op) ((op) << 1) 665 #define OP_CTRL_DMA_OP_READY BIT(0) 666 #define FMC_OP_READ 0x0 667 #define FMC_OP_WRITE 0x1 668 #define FMC_WAIT_TIMEOUT 1000000 669 #define HIFMC_MAX_CHIP_NUM 2 670 /* LDV_COMMENT_END_PREP */ 671 672 673 674 675 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */ 676 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */ 677 /*============================= VARIABLE INITIALIZING PART =============================*/ 678 LDV_IN_INTERRUPT=1; 679 680 681 682 683 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */ 684 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */ 685 /*============================= FUNCTION CALL SECTION =============================*/ 686 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */ 687 ldv_initialize(); 688 int ldv_s_hisi_spi_nor_driver_platform_driver = 0; 689 690 691 while( nondet_int() 692 || !(ldv_s_hisi_spi_nor_driver_platform_driver == 0) 693 ) { 694 695 switch(nondet_int()) { 696 697 case 0: { 698 699 /** STRUCT: struct type: platform_driver, struct name: hisi_spi_nor_driver **/ 700 if(ldv_s_hisi_spi_nor_driver_platform_driver==0) { 701 702 /* content: static int hisi_spi_nor_probe(struct platform_device *pdev)*/ 703 /* LDV_COMMENT_BEGIN_PREP */ 704 #define FMC_CFG 0x00 705 #define FMC_CFG_OP_MODE_MASK BIT_MASK(0) 706 #define FMC_CFG_OP_MODE_BOOT 0 707 #define FMC_CFG_OP_MODE_NORMAL 1 708 #define FMC_CFG_FLASH_SEL(type) (((type) & 0x3) << 1) 709 #define FMC_CFG_FLASH_SEL_MASK 0x6 710 #define FMC_ECC_TYPE(type) (((type) & 0x7) << 5) 711 #define FMC_ECC_TYPE_MASK GENMASK(7, 5) 712 #define SPI_NOR_ADDR_MODE_MASK BIT_MASK(10) 713 #define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10) 714 #define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10) 715 #define FMC_GLOBAL_CFG 0x04 716 #define FMC_GLOBAL_CFG_WP_ENABLE BIT(6) 717 #define FMC_SPI_TIMING_CFG 0x08 718 #define TIMING_CFG_TCSH(nr) (((nr) & 0xf) << 8) 719 #define TIMING_CFG_TCSS(nr) (((nr) & 0xf) << 4) 720 #define TIMING_CFG_TSHSL(nr) ((nr) & 0xf) 721 #define CS_HOLD_TIME 0x6 722 #define CS_SETUP_TIME 0x6 723 #define CS_DESELECT_TIME 0xf 724 #define FMC_INT 0x18 725 #define FMC_INT_OP_DONE BIT(0) 726 #define FMC_INT_CLR 0x20 727 #define FMC_CMD 0x24 728 #define FMC_CMD_CMD1(cmd) ((cmd) & 0xff) 729 #define FMC_ADDRL 0x2c 730 #define FMC_OP_CFG 0x30 731 #define OP_CFG_FM_CS(cs) ((cs) << 11) 732 #define OP_CFG_MEM_IF_TYPE(type) (((type) & 0x7) << 7) 733 #define OP_CFG_ADDR_NUM(addr) (((addr) & 0x7) << 4) 734 #define OP_CFG_DUMMY_NUM(dummy) ((dummy) & 0xf) 735 #define FMC_DATA_NUM 0x38 736 #define FMC_DATA_NUM_CNT(cnt) ((cnt) & GENMASK(13, 0)) 737 #define FMC_OP 0x3c 738 #define FMC_OP_DUMMY_EN BIT(8) 739 #define FMC_OP_CMD1_EN BIT(7) 740 #define FMC_OP_ADDR_EN BIT(6) 741 #define FMC_OP_WRITE_DATA_EN BIT(5) 742 #define FMC_OP_READ_DATA_EN BIT(2) 743 #define FMC_OP_READ_STATUS_EN BIT(1) 744 #define FMC_OP_REG_OP_START BIT(0) 745 #define FMC_DMA_LEN 0x40 746 #define FMC_DMA_LEN_SET(len) ((len) & GENMASK(27, 0)) 747 #define FMC_DMA_SADDR_D0 0x4c 748 #define HIFMC_DMA_MAX_LEN (4096) 749 #define HIFMC_DMA_MASK (HIFMC_DMA_MAX_LEN - 1) 750 #define FMC_OP_DMA 0x68 751 #define OP_CTRL_RD_OPCODE(code) (((code) & 0xff) << 16) 752 #define OP_CTRL_WR_OPCODE(code) (((code) & 0xff) << 8) 753 #define OP_CTRL_RW_OP(op) ((op) << 1) 754 #define OP_CTRL_DMA_OP_READY BIT(0) 755 #define FMC_OP_READ 0x0 756 #define FMC_OP_WRITE 0x1 757 #define FMC_WAIT_TIMEOUT 1000000 758 #define HIFMC_MAX_CHIP_NUM 2 759 /* LDV_COMMENT_END_PREP */ 760 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "hisi_spi_nor_driver". Standart function test for correct return result. */ 761 res_hisi_spi_nor_probe_14 = hisi_spi_nor_probe( var_group1); 762 ldv_check_return_value(res_hisi_spi_nor_probe_14); 763 ldv_check_return_value_probe(res_hisi_spi_nor_probe_14); 764 if(res_hisi_spi_nor_probe_14) 765 goto ldv_module_exit; 766 ldv_s_hisi_spi_nor_driver_platform_driver++; 767 768 } 769 770 } 771 772 break; 773 case 1: { 774 775 /** STRUCT: struct type: platform_driver, struct name: hisi_spi_nor_driver **/ 776 if(ldv_s_hisi_spi_nor_driver_platform_driver==1) { 777 778 /* content: static int hisi_spi_nor_remove(struct platform_device *pdev)*/ 779 /* LDV_COMMENT_BEGIN_PREP */ 780 #define FMC_CFG 0x00 781 #define FMC_CFG_OP_MODE_MASK BIT_MASK(0) 782 #define FMC_CFG_OP_MODE_BOOT 0 783 #define FMC_CFG_OP_MODE_NORMAL 1 784 #define FMC_CFG_FLASH_SEL(type) (((type) & 0x3) << 1) 785 #define FMC_CFG_FLASH_SEL_MASK 0x6 786 #define FMC_ECC_TYPE(type) (((type) & 0x7) << 5) 787 #define FMC_ECC_TYPE_MASK GENMASK(7, 5) 788 #define SPI_NOR_ADDR_MODE_MASK BIT_MASK(10) 789 #define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10) 790 #define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10) 791 #define FMC_GLOBAL_CFG 0x04 792 #define FMC_GLOBAL_CFG_WP_ENABLE BIT(6) 793 #define FMC_SPI_TIMING_CFG 0x08 794 #define TIMING_CFG_TCSH(nr) (((nr) & 0xf) << 8) 795 #define TIMING_CFG_TCSS(nr) (((nr) & 0xf) << 4) 796 #define TIMING_CFG_TSHSL(nr) ((nr) & 0xf) 797 #define CS_HOLD_TIME 0x6 798 #define CS_SETUP_TIME 0x6 799 #define CS_DESELECT_TIME 0xf 800 #define FMC_INT 0x18 801 #define FMC_INT_OP_DONE BIT(0) 802 #define FMC_INT_CLR 0x20 803 #define FMC_CMD 0x24 804 #define FMC_CMD_CMD1(cmd) ((cmd) & 0xff) 805 #define FMC_ADDRL 0x2c 806 #define FMC_OP_CFG 0x30 807 #define OP_CFG_FM_CS(cs) ((cs) << 11) 808 #define OP_CFG_MEM_IF_TYPE(type) (((type) & 0x7) << 7) 809 #define OP_CFG_ADDR_NUM(addr) (((addr) & 0x7) << 4) 810 #define OP_CFG_DUMMY_NUM(dummy) ((dummy) & 0xf) 811 #define FMC_DATA_NUM 0x38 812 #define FMC_DATA_NUM_CNT(cnt) ((cnt) & GENMASK(13, 0)) 813 #define FMC_OP 0x3c 814 #define FMC_OP_DUMMY_EN BIT(8) 815 #define FMC_OP_CMD1_EN BIT(7) 816 #define FMC_OP_ADDR_EN BIT(6) 817 #define FMC_OP_WRITE_DATA_EN BIT(5) 818 #define FMC_OP_READ_DATA_EN BIT(2) 819 #define FMC_OP_READ_STATUS_EN BIT(1) 820 #define FMC_OP_REG_OP_START BIT(0) 821 #define FMC_DMA_LEN 0x40 822 #define FMC_DMA_LEN_SET(len) ((len) & GENMASK(27, 0)) 823 #define FMC_DMA_SADDR_D0 0x4c 824 #define HIFMC_DMA_MAX_LEN (4096) 825 #define HIFMC_DMA_MASK (HIFMC_DMA_MAX_LEN - 1) 826 #define FMC_OP_DMA 0x68 827 #define OP_CTRL_RD_OPCODE(code) (((code) & 0xff) << 16) 828 #define OP_CTRL_WR_OPCODE(code) (((code) & 0xff) << 8) 829 #define OP_CTRL_RW_OP(op) ((op) << 1) 830 #define OP_CTRL_DMA_OP_READY BIT(0) 831 #define FMC_OP_READ 0x0 832 #define FMC_OP_WRITE 0x1 833 #define FMC_WAIT_TIMEOUT 1000000 834 #define HIFMC_MAX_CHIP_NUM 2 835 /* LDV_COMMENT_END_PREP */ 836 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "hisi_spi_nor_driver" */ 837 ldv_handler_precall(); 838 hisi_spi_nor_remove( var_group1); 839 ldv_s_hisi_spi_nor_driver_platform_driver=0; 840 841 } 842 843 } 844 845 break; 846 default: break; 847 848 } 849 850 } 851 852 ldv_module_exit: 853 854 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */ 855 ldv_final: ldv_check_final_state(); 856 857 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */ 858 return; 859 860 } 861 #endif 862 863 /* LDV_COMMENT_END_MAIN */ 864 865 #line 15 "/home/ldvuser/ldv/ref_launches/work/current--X--drivers--X--defaultlinux-4.10-rc1.tar.xz--X--322_7a--X--cpachecker/linux-4.10-rc1.tar.xz/csd_deg_dscv/15584/dscv_tempdir/dscv/ri/322_7a/drivers/mtd/spi-nor/hisi-sfc.o.c.prepared"
1 2 #include <verifier/rcv.h> 3 #include <kernel-model/ERR.inc> 4 5 struct clk; 6 7 8 /* LDV_COMMENT_CHANGE_STATE Initialize counter to zero. */ 9 int ldv_counter_clk = 0; 10 11 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_clk_disable_clk') Release. */ 12 void ldv_clk_disable_clk(struct clk *clk) 13 { 14 /* LDV_COMMENT_ASSERT The clk must be freed only once. */ 15 ldv_assert(ldv_counter_clk==1); 16 /* LDV_COMMENT_CHANGE_STATE Increase counter. */ 17 ldv_counter_clk = 0; 18 } 19 20 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_clk_enable_clk') Reset counter. */ 21 int ldv_clk_enable_clk(void) 22 { 23 int retval = ldv_undef_int(); 24 if (!retval) 25 { 26 /* LDV_COMMENT_CHANGE_STATE Increase counter. */ 27 ldv_counter_clk = 1; 28 } 29 return retval; 30 } 31 32 33 /* LDV_COMMENT_CHANGE_STATE Initialize counter to zero. */ 34 int ldv_counter_clk_of_hifmc_host = 0; 35 36 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_clk_disable_clk_of_hifmc_host') Release. */ 37 void ldv_clk_disable_clk_of_hifmc_host(struct clk *clk) 38 { 39 /* LDV_COMMENT_ASSERT The clk must be freed only once. */ 40 ldv_assert(ldv_counter_clk_of_hifmc_host==1); 41 /* LDV_COMMENT_CHANGE_STATE Increase counter. */ 42 ldv_counter_clk_of_hifmc_host = 0; 43 } 44 45 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_clk_enable_clk_of_hifmc_host') Reset counter. */ 46 int ldv_clk_enable_clk_of_hifmc_host(void) 47 { 48 int retval = ldv_undef_int(); 49 if (!retval) 50 { 51 /* LDV_COMMENT_CHANGE_STATE Increase counter. */ 52 ldv_counter_clk_of_hifmc_host = 1; 53 } 54 return retval; 55 }
1 #ifndef _LDV_ERR_ 2 #define _LDV_ERR_ 3 4 #include <linux/kernel.h> 5 6 /* LDV_COMMENT_MODEL_FUNCTION_DEFENITION(name='ldv_is_err') This function return result of checking if pointer is impossible. */ 7 bool ldv_is_err(const void *ptr) 8 { 9 /*LDV_COMMENT_RETURN Return value of function ldv_is_err_val().*/ 10 return ((unsigned long)ptr > LDV_PTR_MAX); 11 } 12 13 /* LDV_COMMENT_MODEL_FUNCTION_DEFENITION(name='ldv_err_ptr') This function return pointer. */ 14 void* ldv_err_ptr(long error) 15 { 16 /*LDV_COMMENT_RETURN Return error pointer.*/ 17 return (void *)(LDV_PTR_MAX - error); 18 } 19 20 /* LDV_COMMENT_MODEL_FUNCTION_DEFENITION(name='ldv_ptr_err') This function return error if pointer is impossible. */ 21 long ldv_ptr_err(const void *ptr) 22 { 23 /*LDV_COMMENT_RETURN Return error code.*/ 24 return (long)(LDV_PTR_MAX - (unsigned long)ptr); 25 } 26 27 /* LDV_COMMENT_MODEL_FUNCTION_DEFENITION(name='ldv_is_err_or_null') This function check if pointer is impossible or null. */ 28 bool ldv_is_err_or_null(const void *ptr) 29 { 30 /*LDV_COMMENT_RETURN Return 0 if pointer is possible and not zero, and 1 in other cases*/ 31 return !ptr || ldv_is_err((unsigned long)ptr); 32 } 33 34 #endif /* _LDV_ERR_ */
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 #ifndef _LINUX_DMA_MAPPING_H 2 #define _LINUX_DMA_MAPPING_H 3 4 #include <linux/sizes.h> 5 #include <linux/string.h> 6 #include <linux/device.h> 7 #include <linux/err.h> 8 #include <linux/dma-debug.h> 9 #include <linux/dma-direction.h> 10 #include <linux/scatterlist.h> 11 #include <linux/kmemcheck.h> 12 #include <linux/bug.h> 13 14 /** 15 * List of possible attributes associated with a DMA mapping. The semantics 16 * of each attribute should be defined in Documentation/DMA-attributes.txt. 17 * 18 * DMA_ATTR_WRITE_BARRIER: DMA to a memory region with this attribute 19 * forces all pending DMA writes to complete. 20 */ 21 #define DMA_ATTR_WRITE_BARRIER (1UL << 0) 22 /* 23 * DMA_ATTR_WEAK_ORDERING: Specifies that reads and writes to the mapping 24 * may be weakly ordered, that is that reads and writes may pass each other. 25 */ 26 #define DMA_ATTR_WEAK_ORDERING (1UL << 1) 27 /* 28 * DMA_ATTR_WRITE_COMBINE: Specifies that writes to the mapping may be 29 * buffered to improve performance. 30 */ 31 #define DMA_ATTR_WRITE_COMBINE (1UL << 2) 32 /* 33 * DMA_ATTR_NON_CONSISTENT: Lets the platform to choose to return either 34 * consistent or non-consistent memory as it sees fit. 35 */ 36 #define DMA_ATTR_NON_CONSISTENT (1UL << 3) 37 /* 38 * DMA_ATTR_NO_KERNEL_MAPPING: Lets the platform to avoid creating a kernel 39 * virtual mapping for the allocated buffer. 40 */ 41 #define DMA_ATTR_NO_KERNEL_MAPPING (1UL << 4) 42 /* 43 * DMA_ATTR_SKIP_CPU_SYNC: Allows platform code to skip synchronization of 44 * the CPU cache for the given buffer assuming that it has been already 45 * transferred to 'device' domain. 46 */ 47 #define DMA_ATTR_SKIP_CPU_SYNC (1UL << 5) 48 /* 49 * DMA_ATTR_FORCE_CONTIGUOUS: Forces contiguous allocation of the buffer 50 * in physical memory. 51 */ 52 #define DMA_ATTR_FORCE_CONTIGUOUS (1UL << 6) 53 /* 54 * DMA_ATTR_ALLOC_SINGLE_PAGES: This is a hint to the DMA-mapping subsystem 55 * that it's probably not worth the time to try to allocate memory to in a way 56 * that gives better TLB efficiency. 57 */ 58 #define DMA_ATTR_ALLOC_SINGLE_PAGES (1UL << 7) 59 /* 60 * DMA_ATTR_NO_WARN: This tells the DMA-mapping subsystem to suppress 61 * allocation failure reports (similarly to __GFP_NOWARN). 62 */ 63 #define DMA_ATTR_NO_WARN (1UL << 8) 64 65 /* 66 * A dma_addr_t can hold any valid DMA or bus address for the platform. 67 * It can be given to a device to use as a DMA source or target. A CPU cannot 68 * reference a dma_addr_t directly because there may be translation between 69 * its physical address space and the bus address space. 70 */ 71 struct dma_map_ops { 72 void* (*alloc)(struct device *dev, size_t size, 73 dma_addr_t *dma_handle, gfp_t gfp, 74 unsigned long attrs); 75 void (*free)(struct device *dev, size_t size, 76 void *vaddr, dma_addr_t dma_handle, 77 unsigned long attrs); 78 int (*mmap)(struct device *, struct vm_area_struct *, 79 void *, dma_addr_t, size_t, 80 unsigned long attrs); 81 82 int (*get_sgtable)(struct device *dev, struct sg_table *sgt, void *, 83 dma_addr_t, size_t, unsigned long attrs); 84 85 dma_addr_t (*map_page)(struct device *dev, struct page *page, 86 unsigned long offset, size_t size, 87 enum dma_data_direction dir, 88 unsigned long attrs); 89 void (*unmap_page)(struct device *dev, dma_addr_t dma_handle, 90 size_t size, enum dma_data_direction dir, 91 unsigned long attrs); 92 /* 93 * map_sg returns 0 on error and a value > 0 on success. 94 * It should never return a value < 0. 95 */ 96 int (*map_sg)(struct device *dev, struct scatterlist *sg, 97 int nents, enum dma_data_direction dir, 98 unsigned long attrs); 99 void (*unmap_sg)(struct device *dev, 100 struct scatterlist *sg, int nents, 101 enum dma_data_direction dir, 102 unsigned long attrs); 103 dma_addr_t (*map_resource)(struct device *dev, phys_addr_t phys_addr, 104 size_t size, enum dma_data_direction dir, 105 unsigned long attrs); 106 void (*unmap_resource)(struct device *dev, dma_addr_t dma_handle, 107 size_t size, enum dma_data_direction dir, 108 unsigned long attrs); 109 void (*sync_single_for_cpu)(struct device *dev, 110 dma_addr_t dma_handle, size_t size, 111 enum dma_data_direction dir); 112 void (*sync_single_for_device)(struct device *dev, 113 dma_addr_t dma_handle, size_t size, 114 enum dma_data_direction dir); 115 void (*sync_sg_for_cpu)(struct device *dev, 116 struct scatterlist *sg, int nents, 117 enum dma_data_direction dir); 118 void (*sync_sg_for_device)(struct device *dev, 119 struct scatterlist *sg, int nents, 120 enum dma_data_direction dir); 121 int (*mapping_error)(struct device *dev, dma_addr_t dma_addr); 122 int (*dma_supported)(struct device *dev, u64 mask); 123 int (*set_dma_mask)(struct device *dev, u64 mask); 124 #ifdef ARCH_HAS_DMA_GET_REQUIRED_MASK 125 u64 (*get_required_mask)(struct device *dev); 126 #endif 127 int is_phys; 128 }; 129 130 extern struct dma_map_ops dma_noop_ops; 131 132 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) 133 134 #define DMA_MASK_NONE 0x0ULL 135 136 static inline int valid_dma_direction(int dma_direction) 137 { 138 return ((dma_direction == DMA_BIDIRECTIONAL) || 139 (dma_direction == DMA_TO_DEVICE) || 140 (dma_direction == DMA_FROM_DEVICE)); 141 } 142 143 static inline int is_device_dma_capable(struct device *dev) 144 { 145 return dev->dma_mask != NULL && *dev->dma_mask != DMA_MASK_NONE; 146 } 147 148 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT 149 /* 150 * These three functions are only for dma allocator. 151 * Don't use them in device drivers. 152 */ 153 int dma_alloc_from_coherent(struct device *dev, ssize_t size, 154 dma_addr_t *dma_handle, void **ret); 155 int dma_release_from_coherent(struct device *dev, int order, void *vaddr); 156 157 int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma, 158 void *cpu_addr, size_t size, int *ret); 159 #else 160 #define dma_alloc_from_coherent(dev, size, handle, ret) (0) 161 #define dma_release_from_coherent(dev, order, vaddr) (0) 162 #define dma_mmap_from_coherent(dev, vma, vaddr, order, ret) (0) 163 #endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */ 164 165 #ifdef CONFIG_HAS_DMA 166 #include <asm/dma-mapping.h> 167 #else 168 /* 169 * Define the dma api to allow compilation but not linking of 170 * dma dependent code. Code that depends on the dma-mapping 171 * API needs to set 'depends on HAS_DMA' in its Kconfig 172 */ 173 extern struct dma_map_ops bad_dma_ops; 174 static inline struct dma_map_ops *get_dma_ops(struct device *dev) 175 { 176 return &bad_dma_ops; 177 } 178 #endif 179 180 static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr, 181 size_t size, 182 enum dma_data_direction dir, 183 unsigned long attrs) 184 { 185 struct dma_map_ops *ops = get_dma_ops(dev); 186 dma_addr_t addr; 187 188 kmemcheck_mark_initialized(ptr, size); 189 BUG_ON(!valid_dma_direction(dir)); 190 addr = ops->map_page(dev, virt_to_page(ptr), 191 offset_in_page(ptr), size, 192 dir, attrs); 193 debug_dma_map_page(dev, virt_to_page(ptr), 194 offset_in_page(ptr), size, 195 dir, addr, true); 196 return addr; 197 } 198 199 static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr, 200 size_t size, 201 enum dma_data_direction dir, 202 unsigned long attrs) 203 { 204 struct dma_map_ops *ops = get_dma_ops(dev); 205 206 BUG_ON(!valid_dma_direction(dir)); 207 if (ops->unmap_page) 208 ops->unmap_page(dev, addr, size, dir, attrs); 209 debug_dma_unmap_page(dev, addr, size, dir, true); 210 } 211 212 /* 213 * dma_maps_sg_attrs returns 0 on error and > 0 on success. 214 * It should never return a value < 0. 215 */ 216 static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, 217 int nents, enum dma_data_direction dir, 218 unsigned long attrs) 219 { 220 struct dma_map_ops *ops = get_dma_ops(dev); 221 int i, ents; 222 struct scatterlist *s; 223 224 for_each_sg(sg, s, nents, i) 225 kmemcheck_mark_initialized(sg_virt(s), s->length); 226 BUG_ON(!valid_dma_direction(dir)); 227 ents = ops->map_sg(dev, sg, nents, dir, attrs); 228 BUG_ON(ents < 0); 229 debug_dma_map_sg(dev, sg, nents, ents, dir); 230 231 return ents; 232 } 233 234 static inline void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg, 235 int nents, enum dma_data_direction dir, 236 unsigned long attrs) 237 { 238 struct dma_map_ops *ops = get_dma_ops(dev); 239 240 BUG_ON(!valid_dma_direction(dir)); 241 debug_dma_unmap_sg(dev, sg, nents, dir); 242 if (ops->unmap_sg) 243 ops->unmap_sg(dev, sg, nents, dir, attrs); 244 } 245 246 static inline dma_addr_t dma_map_page_attrs(struct device *dev, 247 struct page *page, 248 size_t offset, size_t size, 249 enum dma_data_direction dir, 250 unsigned long attrs) 251 { 252 struct dma_map_ops *ops = get_dma_ops(dev); 253 dma_addr_t addr; 254 255 kmemcheck_mark_initialized(page_address(page) + offset, size); 256 BUG_ON(!valid_dma_direction(dir)); 257 addr = ops->map_page(dev, page, offset, size, dir, attrs); 258 debug_dma_map_page(dev, page, offset, size, dir, addr, false); 259 260 return addr; 261 } 262 263 static inline void dma_unmap_page_attrs(struct device *dev, 264 dma_addr_t addr, size_t size, 265 enum dma_data_direction dir, 266 unsigned long attrs) 267 { 268 struct dma_map_ops *ops = get_dma_ops(dev); 269 270 BUG_ON(!valid_dma_direction(dir)); 271 if (ops->unmap_page) 272 ops->unmap_page(dev, addr, size, dir, attrs); 273 debug_dma_unmap_page(dev, addr, size, dir, false); 274 } 275 276 static inline dma_addr_t dma_map_resource(struct device *dev, 277 phys_addr_t phys_addr, 278 size_t size, 279 enum dma_data_direction dir, 280 unsigned long attrs) 281 { 282 struct dma_map_ops *ops = get_dma_ops(dev); 283 dma_addr_t addr; 284 285 BUG_ON(!valid_dma_direction(dir)); 286 287 /* Don't allow RAM to be mapped */ 288 BUG_ON(pfn_valid(PHYS_PFN(phys_addr))); 289 290 addr = phys_addr; 291 if (ops->map_resource) 292 addr = ops->map_resource(dev, phys_addr, size, dir, attrs); 293 294 debug_dma_map_resource(dev, phys_addr, size, dir, addr); 295 296 return addr; 297 } 298 299 static inline void dma_unmap_resource(struct device *dev, dma_addr_t addr, 300 size_t size, enum dma_data_direction dir, 301 unsigned long attrs) 302 { 303 struct dma_map_ops *ops = get_dma_ops(dev); 304 305 BUG_ON(!valid_dma_direction(dir)); 306 if (ops->unmap_resource) 307 ops->unmap_resource(dev, addr, size, dir, attrs); 308 debug_dma_unmap_resource(dev, addr, size, dir); 309 } 310 311 static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr, 312 size_t size, 313 enum dma_data_direction dir) 314 { 315 struct dma_map_ops *ops = get_dma_ops(dev); 316 317 BUG_ON(!valid_dma_direction(dir)); 318 if (ops->sync_single_for_cpu) 319 ops->sync_single_for_cpu(dev, addr, size, dir); 320 debug_dma_sync_single_for_cpu(dev, addr, size, dir); 321 } 322 323 static inline void dma_sync_single_for_device(struct device *dev, 324 dma_addr_t addr, size_t size, 325 enum dma_data_direction dir) 326 { 327 struct dma_map_ops *ops = get_dma_ops(dev); 328 329 BUG_ON(!valid_dma_direction(dir)); 330 if (ops->sync_single_for_device) 331 ops->sync_single_for_device(dev, addr, size, dir); 332 debug_dma_sync_single_for_device(dev, addr, size, dir); 333 } 334 335 static inline void dma_sync_single_range_for_cpu(struct device *dev, 336 dma_addr_t addr, 337 unsigned long offset, 338 size_t size, 339 enum dma_data_direction dir) 340 { 341 const struct dma_map_ops *ops = get_dma_ops(dev); 342 343 BUG_ON(!valid_dma_direction(dir)); 344 if (ops->sync_single_for_cpu) 345 ops->sync_single_for_cpu(dev, addr + offset, size, dir); 346 debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir); 347 } 348 349 static inline void dma_sync_single_range_for_device(struct device *dev, 350 dma_addr_t addr, 351 unsigned long offset, 352 size_t size, 353 enum dma_data_direction dir) 354 { 355 const struct dma_map_ops *ops = get_dma_ops(dev); 356 357 BUG_ON(!valid_dma_direction(dir)); 358 if (ops->sync_single_for_device) 359 ops->sync_single_for_device(dev, addr + offset, size, dir); 360 debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir); 361 } 362 363 static inline void 364 dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, 365 int nelems, enum dma_data_direction dir) 366 { 367 struct dma_map_ops *ops = get_dma_ops(dev); 368 369 BUG_ON(!valid_dma_direction(dir)); 370 if (ops->sync_sg_for_cpu) 371 ops->sync_sg_for_cpu(dev, sg, nelems, dir); 372 debug_dma_sync_sg_for_cpu(dev, sg, nelems, dir); 373 } 374 375 static inline void 376 dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, 377 int nelems, enum dma_data_direction dir) 378 { 379 struct dma_map_ops *ops = get_dma_ops(dev); 380 381 BUG_ON(!valid_dma_direction(dir)); 382 if (ops->sync_sg_for_device) 383 ops->sync_sg_for_device(dev, sg, nelems, dir); 384 debug_dma_sync_sg_for_device(dev, sg, nelems, dir); 385 386 } 387 388 #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0) 389 #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0) 390 #define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, 0) 391 #define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, 0) 392 #define dma_map_page(d, p, o, s, r) dma_map_page_attrs(d, p, o, s, r, 0) 393 #define dma_unmap_page(d, a, s, r) dma_unmap_page_attrs(d, a, s, r, 0) 394 395 extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma, 396 void *cpu_addr, dma_addr_t dma_addr, size_t size); 397 398 void *dma_common_contiguous_remap(struct page *page, size_t size, 399 unsigned long vm_flags, 400 pgprot_t prot, const void *caller); 401 402 void *dma_common_pages_remap(struct page **pages, size_t size, 403 unsigned long vm_flags, pgprot_t prot, 404 const void *caller); 405 void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags); 406 407 /** 408 * dma_mmap_attrs - map a coherent DMA allocation into user space 409 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices 410 * @vma: vm_area_struct describing requested user mapping 411 * @cpu_addr: kernel CPU-view address returned from dma_alloc_attrs 412 * @handle: device-view address returned from dma_alloc_attrs 413 * @size: size of memory originally requested in dma_alloc_attrs 414 * @attrs: attributes of mapping properties requested in dma_alloc_attrs 415 * 416 * Map a coherent DMA buffer previously allocated by dma_alloc_attrs 417 * into user space. The coherent DMA buffer must not be freed by the 418 * driver until the user space mapping has been released. 419 */ 420 static inline int 421 dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, 422 dma_addr_t dma_addr, size_t size, unsigned long attrs) 423 { 424 struct dma_map_ops *ops = get_dma_ops(dev); 425 BUG_ON(!ops); 426 if (ops->mmap) 427 return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs); 428 return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size); 429 } 430 431 #define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, 0) 432 433 int 434 dma_common_get_sgtable(struct device *dev, struct sg_table *sgt, 435 void *cpu_addr, dma_addr_t dma_addr, size_t size); 436 437 static inline int 438 dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt, void *cpu_addr, 439 dma_addr_t dma_addr, size_t size, 440 unsigned long attrs) 441 { 442 struct dma_map_ops *ops = get_dma_ops(dev); 443 BUG_ON(!ops); 444 if (ops->get_sgtable) 445 return ops->get_sgtable(dev, sgt, cpu_addr, dma_addr, size, 446 attrs); 447 return dma_common_get_sgtable(dev, sgt, cpu_addr, dma_addr, size); 448 } 449 450 #define dma_get_sgtable(d, t, v, h, s) dma_get_sgtable_attrs(d, t, v, h, s, 0) 451 452 #ifndef arch_dma_alloc_attrs 453 #define arch_dma_alloc_attrs(dev, flag) (true) 454 #endif 455 456 static inline void *dma_alloc_attrs(struct device *dev, size_t size, 457 dma_addr_t *dma_handle, gfp_t flag, 458 unsigned long attrs) 459 { 460 struct dma_map_ops *ops = get_dma_ops(dev); 461 void *cpu_addr; 462 463 BUG_ON(!ops); 464 465 if (dma_alloc_from_coherent(dev, size, dma_handle, &cpu_addr)) 466 return cpu_addr; 467 468 if (!arch_dma_alloc_attrs(&dev, &flag)) 469 return NULL; 470 if (!ops->alloc) 471 return NULL; 472 473 cpu_addr = ops->alloc(dev, size, dma_handle, flag, attrs); 474 debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr); 475 return cpu_addr; 476 } 477 478 static inline void dma_free_attrs(struct device *dev, size_t size, 479 void *cpu_addr, dma_addr_t dma_handle, 480 unsigned long attrs) 481 { 482 struct dma_map_ops *ops = get_dma_ops(dev); 483 484 BUG_ON(!ops); 485 WARN_ON(irqs_disabled()); 486 487 if (dma_release_from_coherent(dev, get_order(size), cpu_addr)) 488 return; 489 490 if (!ops->free || !cpu_addr) 491 return; 492 493 debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); 494 ops->free(dev, size, cpu_addr, dma_handle, attrs); 495 } 496 497 static inline void *dma_alloc_coherent(struct device *dev, size_t size, 498 dma_addr_t *dma_handle, gfp_t flag) 499 { 500 return dma_alloc_attrs(dev, size, dma_handle, flag, 0); 501 } 502 503 static inline void dma_free_coherent(struct device *dev, size_t size, 504 void *cpu_addr, dma_addr_t dma_handle) 505 { 506 return dma_free_attrs(dev, size, cpu_addr, dma_handle, 0); 507 } 508 509 static inline void *dma_alloc_noncoherent(struct device *dev, size_t size, 510 dma_addr_t *dma_handle, gfp_t gfp) 511 { 512 return dma_alloc_attrs(dev, size, dma_handle, gfp, 513 DMA_ATTR_NON_CONSISTENT); 514 } 515 516 static inline void dma_free_noncoherent(struct device *dev, size_t size, 517 void *cpu_addr, dma_addr_t dma_handle) 518 { 519 dma_free_attrs(dev, size, cpu_addr, dma_handle, 520 DMA_ATTR_NON_CONSISTENT); 521 } 522 523 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 524 { 525 debug_dma_mapping_error(dev, dma_addr); 526 527 if (get_dma_ops(dev)->mapping_error) 528 return get_dma_ops(dev)->mapping_error(dev, dma_addr); 529 530 #ifdef DMA_ERROR_CODE 531 return dma_addr == DMA_ERROR_CODE; 532 #else 533 return 0; 534 #endif 535 } 536 537 #ifndef HAVE_ARCH_DMA_SUPPORTED 538 static inline int dma_supported(struct device *dev, u64 mask) 539 { 540 struct dma_map_ops *ops = get_dma_ops(dev); 541 542 if (!ops) 543 return 0; 544 if (!ops->dma_supported) 545 return 1; 546 return ops->dma_supported(dev, mask); 547 } 548 #endif 549 550 #ifndef HAVE_ARCH_DMA_SET_MASK 551 static inline int dma_set_mask(struct device *dev, u64 mask) 552 { 553 struct dma_map_ops *ops = get_dma_ops(dev); 554 555 if (ops->set_dma_mask) 556 return ops->set_dma_mask(dev, mask); 557 558 if (!dev->dma_mask || !dma_supported(dev, mask)) 559 return -EIO; 560 *dev->dma_mask = mask; 561 return 0; 562 } 563 #endif 564 565 static inline u64 dma_get_mask(struct device *dev) 566 { 567 if (dev && dev->dma_mask && *dev->dma_mask) 568 return *dev->dma_mask; 569 return DMA_BIT_MASK(32); 570 } 571 572 #ifdef CONFIG_ARCH_HAS_DMA_SET_COHERENT_MASK 573 int dma_set_coherent_mask(struct device *dev, u64 mask); 574 #else 575 static inline int dma_set_coherent_mask(struct device *dev, u64 mask) 576 { 577 if (!dma_supported(dev, mask)) 578 return -EIO; 579 dev->coherent_dma_mask = mask; 580 return 0; 581 } 582 #endif 583 584 /* 585 * Set both the DMA mask and the coherent DMA mask to the same thing. 586 * Note that we don't check the return value from dma_set_coherent_mask() 587 * as the DMA API guarantees that the coherent DMA mask can be set to 588 * the same or smaller than the streaming DMA mask. 589 */ 590 static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask) 591 { 592 int rc = dma_set_mask(dev, mask); 593 if (rc == 0) 594 dma_set_coherent_mask(dev, mask); 595 return rc; 596 } 597 598 /* 599 * Similar to the above, except it deals with the case where the device 600 * does not have dev->dma_mask appropriately setup. 601 */ 602 static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask) 603 { 604 dev->dma_mask = &dev->coherent_dma_mask; 605 return dma_set_mask_and_coherent(dev, mask); 606 } 607 608 extern u64 dma_get_required_mask(struct device *dev); 609 610 #ifndef arch_setup_dma_ops 611 static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, 612 u64 size, const struct iommu_ops *iommu, 613 bool coherent) { } 614 #endif 615 616 #ifndef arch_teardown_dma_ops 617 static inline void arch_teardown_dma_ops(struct device *dev) { } 618 #endif 619 620 static inline unsigned int dma_get_max_seg_size(struct device *dev) 621 { 622 if (dev->dma_parms && dev->dma_parms->max_segment_size) 623 return dev->dma_parms->max_segment_size; 624 return SZ_64K; 625 } 626 627 static inline unsigned int dma_set_max_seg_size(struct device *dev, 628 unsigned int size) 629 { 630 if (dev->dma_parms) { 631 dev->dma_parms->max_segment_size = size; 632 return 0; 633 } 634 return -EIO; 635 } 636 637 static inline unsigned long dma_get_seg_boundary(struct device *dev) 638 { 639 if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) 640 return dev->dma_parms->segment_boundary_mask; 641 return DMA_BIT_MASK(32); 642 } 643 644 static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) 645 { 646 if (dev->dma_parms) { 647 dev->dma_parms->segment_boundary_mask = mask; 648 return 0; 649 } 650 return -EIO; 651 } 652 653 #ifndef dma_max_pfn 654 static inline unsigned long dma_max_pfn(struct device *dev) 655 { 656 return *dev->dma_mask >> PAGE_SHIFT; 657 } 658 #endif 659 660 static inline void *dma_zalloc_coherent(struct device *dev, size_t size, 661 dma_addr_t *dma_handle, gfp_t flag) 662 { 663 void *ret = dma_alloc_coherent(dev, size, dma_handle, 664 flag | __GFP_ZERO); 665 return ret; 666 } 667 668 #ifdef CONFIG_HAS_DMA 669 static inline int dma_get_cache_alignment(void) 670 { 671 #ifdef ARCH_DMA_MINALIGN 672 return ARCH_DMA_MINALIGN; 673 #endif 674 return 1; 675 } 676 #endif 677 678 /* flags for the coherent memory api */ 679 #define DMA_MEMORY_MAP 0x01 680 #define DMA_MEMORY_IO 0x02 681 #define DMA_MEMORY_INCLUDES_CHILDREN 0x04 682 #define DMA_MEMORY_EXCLUSIVE 0x08 683 684 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT 685 int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, 686 dma_addr_t device_addr, size_t size, int flags); 687 void dma_release_declared_memory(struct device *dev); 688 void *dma_mark_declared_memory_occupied(struct device *dev, 689 dma_addr_t device_addr, size_t size); 690 #else 691 static inline int 692 dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, 693 dma_addr_t device_addr, size_t size, int flags) 694 { 695 return 0; 696 } 697 698 static inline void 699 dma_release_declared_memory(struct device *dev) 700 { 701 } 702 703 static inline void * 704 dma_mark_declared_memory_occupied(struct device *dev, 705 dma_addr_t device_addr, size_t size) 706 { 707 return ERR_PTR(-EBUSY); 708 } 709 #endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */ 710 711 /* 712 * Managed DMA API 713 */ 714 extern void *dmam_alloc_coherent(struct device *dev, size_t size, 715 dma_addr_t *dma_handle, gfp_t gfp); 716 extern void dmam_free_coherent(struct device *dev, size_t size, void *vaddr, 717 dma_addr_t dma_handle); 718 extern void *dmam_alloc_noncoherent(struct device *dev, size_t size, 719 dma_addr_t *dma_handle, gfp_t gfp); 720 extern void dmam_free_noncoherent(struct device *dev, size_t size, void *vaddr, 721 dma_addr_t dma_handle); 722 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT 723 extern int dmam_declare_coherent_memory(struct device *dev, 724 phys_addr_t phys_addr, 725 dma_addr_t device_addr, size_t size, 726 int flags); 727 extern void dmam_release_declared_memory(struct device *dev); 728 #else /* CONFIG_HAVE_GENERIC_DMA_COHERENT */ 729 static inline int dmam_declare_coherent_memory(struct device *dev, 730 phys_addr_t phys_addr, dma_addr_t device_addr, 731 size_t size, gfp_t gfp) 732 { 733 return 0; 734 } 735 736 static inline void dmam_release_declared_memory(struct device *dev) 737 { 738 } 739 #endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */ 740 741 static inline void *dma_alloc_wc(struct device *dev, size_t size, 742 dma_addr_t *dma_addr, gfp_t gfp) 743 { 744 return dma_alloc_attrs(dev, size, dma_addr, gfp, 745 DMA_ATTR_WRITE_COMBINE); 746 } 747 #ifndef dma_alloc_writecombine 748 #define dma_alloc_writecombine dma_alloc_wc 749 #endif 750 751 static inline void dma_free_wc(struct device *dev, size_t size, 752 void *cpu_addr, dma_addr_t dma_addr) 753 { 754 return dma_free_attrs(dev, size, cpu_addr, dma_addr, 755 DMA_ATTR_WRITE_COMBINE); 756 } 757 #ifndef dma_free_writecombine 758 #define dma_free_writecombine dma_free_wc 759 #endif 760 761 static inline int dma_mmap_wc(struct device *dev, 762 struct vm_area_struct *vma, 763 void *cpu_addr, dma_addr_t dma_addr, 764 size_t size) 765 { 766 return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, 767 DMA_ATTR_WRITE_COMBINE); 768 } 769 #ifndef dma_mmap_writecombine 770 #define dma_mmap_writecombine dma_mmap_wc 771 #endif 772 773 #if defined(CONFIG_NEED_DMA_MAP_STATE) || defined(CONFIG_DMA_API_DEBUG) 774 #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME 775 #define DEFINE_DMA_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME 776 #define dma_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME) 777 #define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL)) 778 #define dma_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME) 779 #define dma_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL)) 780 #else 781 #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME) 782 #define DEFINE_DMA_UNMAP_LEN(LEN_NAME) 783 #define dma_unmap_addr(PTR, ADDR_NAME) (0) 784 #define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0) 785 #define dma_unmap_len(PTR, LEN_NAME) (0) 786 #define dma_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) 787 #endif 788 789 #endif
1 /* 2 * platform_device.h - generic, centralized driver model 3 * 4 * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org> 5 * 6 * This file is released under the GPLv2 7 * 8 * See Documentation/driver-model/ for more information. 9 */ 10 11 #ifndef _PLATFORM_DEVICE_H_ 12 #define _PLATFORM_DEVICE_H_ 13 14 #include <linux/device.h> 15 #include <linux/mod_devicetable.h> 16 17 #define PLATFORM_DEVID_NONE (-1) 18 #define PLATFORM_DEVID_AUTO (-2) 19 20 struct mfd_cell; 21 struct property_entry; 22 23 struct platform_device { 24 const char *name; 25 int id; 26 bool id_auto; 27 struct device dev; 28 u32 num_resources; 29 struct resource *resource; 30 31 const struct platform_device_id *id_entry; 32 char *driver_override; /* Driver name to force a match */ 33 34 /* MFD cell pointer */ 35 struct mfd_cell *mfd_cell; 36 37 /* arch specific additions */ 38 struct pdev_archdata archdata; 39 }; 40 41 #define platform_get_device_id(pdev) ((pdev)->id_entry) 42 43 #define to_platform_device(x) container_of((x), struct platform_device, dev) 44 45 extern int platform_device_register(struct platform_device *); 46 extern void platform_device_unregister(struct platform_device *); 47 48 extern struct bus_type platform_bus_type; 49 extern struct device platform_bus; 50 51 extern void arch_setup_pdev_archdata(struct platform_device *); 52 extern struct resource *platform_get_resource(struct platform_device *, 53 unsigned int, unsigned int); 54 extern int platform_get_irq(struct platform_device *, unsigned int); 55 extern int platform_irq_count(struct platform_device *); 56 extern struct resource *platform_get_resource_byname(struct platform_device *, 57 unsigned int, 58 const char *); 59 extern int platform_get_irq_byname(struct platform_device *, const char *); 60 extern int platform_add_devices(struct platform_device **, int); 61 62 struct platform_device_info { 63 struct device *parent; 64 struct fwnode_handle *fwnode; 65 66 const char *name; 67 int id; 68 69 const struct resource *res; 70 unsigned int num_res; 71 72 const void *data; 73 size_t size_data; 74 u64 dma_mask; 75 76 struct property_entry *properties; 77 }; 78 extern struct platform_device *platform_device_register_full( 79 const struct platform_device_info *pdevinfo); 80 81 /** 82 * platform_device_register_resndata - add a platform-level device with 83 * resources and platform-specific data 84 * 85 * @parent: parent device for the device we're adding 86 * @name: base name of the device we're adding 87 * @id: instance id 88 * @res: set of resources that needs to be allocated for the device 89 * @num: number of resources 90 * @data: platform specific data for this platform device 91 * @size: size of platform specific data 92 * 93 * Returns &struct platform_device pointer on success, or ERR_PTR() on error. 94 */ 95 static inline struct platform_device *platform_device_register_resndata( 96 struct device *parent, const char *name, int id, 97 const struct resource *res, unsigned int num, 98 const void *data, size_t size) { 99 100 struct platform_device_info pdevinfo = { 101 .parent = parent, 102 .name = name, 103 .id = id, 104 .res = res, 105 .num_res = num, 106 .data = data, 107 .size_data = size, 108 .dma_mask = 0, 109 }; 110 111 return platform_device_register_full(&pdevinfo); 112 } 113 114 /** 115 * platform_device_register_simple - add a platform-level device and its resources 116 * @name: base name of the device we're adding 117 * @id: instance id 118 * @res: set of resources that needs to be allocated for the device 119 * @num: number of resources 120 * 121 * This function creates a simple platform device that requires minimal 122 * resource and memory management. Canned release function freeing memory 123 * allocated for the device allows drivers using such devices to be 124 * unloaded without waiting for the last reference to the device to be 125 * dropped. 126 * 127 * This interface is primarily intended for use with legacy drivers which 128 * probe hardware directly. Because such drivers create sysfs device nodes 129 * themselves, rather than letting system infrastructure handle such device 130 * enumeration tasks, they don't fully conform to the Linux driver model. 131 * In particular, when such drivers are built as modules, they can't be 132 * "hotplugged". 133 * 134 * Returns &struct platform_device pointer on success, or ERR_PTR() on error. 135 */ 136 static inline struct platform_device *platform_device_register_simple( 137 const char *name, int id, 138 const struct resource *res, unsigned int num) 139 { 140 return platform_device_register_resndata(NULL, name, id, 141 res, num, NULL, 0); 142 } 143 144 /** 145 * platform_device_register_data - add a platform-level device with platform-specific data 146 * @parent: parent device for the device we're adding 147 * @name: base name of the device we're adding 148 * @id: instance id 149 * @data: platform specific data for this platform device 150 * @size: size of platform specific data 151 * 152 * This function creates a simple platform device that requires minimal 153 * resource and memory management. Canned release function freeing memory 154 * allocated for the device allows drivers using such devices to be 155 * unloaded without waiting for the last reference to the device to be 156 * dropped. 157 * 158 * Returns &struct platform_device pointer on success, or ERR_PTR() on error. 159 */ 160 static inline struct platform_device *platform_device_register_data( 161 struct device *parent, const char *name, int id, 162 const void *data, size_t size) 163 { 164 return platform_device_register_resndata(parent, name, id, 165 NULL, 0, data, size); 166 } 167 168 extern struct platform_device *platform_device_alloc(const char *name, int id); 169 extern int platform_device_add_resources(struct platform_device *pdev, 170 const struct resource *res, 171 unsigned int num); 172 extern int platform_device_add_data(struct platform_device *pdev, 173 const void *data, size_t size); 174 extern int platform_device_add_properties(struct platform_device *pdev, 175 struct property_entry *properties); 176 extern int platform_device_add(struct platform_device *pdev); 177 extern void platform_device_del(struct platform_device *pdev); 178 extern void platform_device_put(struct platform_device *pdev); 179 180 struct platform_driver { 181 int (*probe)(struct platform_device *); 182 int (*remove)(struct platform_device *); 183 void (*shutdown)(struct platform_device *); 184 int (*suspend)(struct platform_device *, pm_message_t state); 185 int (*resume)(struct platform_device *); 186 struct device_driver driver; 187 const struct platform_device_id *id_table; 188 bool prevent_deferred_probe; 189 }; 190 191 #define to_platform_driver(drv) (container_of((drv), struct platform_driver, \ 192 driver)) 193 194 /* 195 * use a macro to avoid include chaining to get THIS_MODULE 196 */ 197 #define platform_driver_register(drv) \ 198 __platform_driver_register(drv, THIS_MODULE) 199 extern int __platform_driver_register(struct platform_driver *, 200 struct module *); 201 extern void platform_driver_unregister(struct platform_driver *); 202 203 /* non-hotpluggable platform devices may use this so that probe() and 204 * its support may live in __init sections, conserving runtime memory. 205 */ 206 #define platform_driver_probe(drv, probe) \ 207 __platform_driver_probe(drv, probe, THIS_MODULE) 208 extern int __platform_driver_probe(struct platform_driver *driver, 209 int (*probe)(struct platform_device *), struct module *module); 210 211 static inline void *platform_get_drvdata(const struct platform_device *pdev) 212 { 213 return dev_get_drvdata(&pdev->dev); 214 } 215 216 static inline void platform_set_drvdata(struct platform_device *pdev, 217 void *data) 218 { 219 dev_set_drvdata(&pdev->dev, data); 220 } 221 222 /* module_platform_driver() - Helper macro for drivers that don't do 223 * anything special in module init/exit. This eliminates a lot of 224 * boilerplate. Each module may only use this macro once, and 225 * calling it replaces module_init() and module_exit() 226 */ 227 #define module_platform_driver(__platform_driver) \ 228 module_driver(__platform_driver, platform_driver_register, \ 229 platform_driver_unregister) 230 231 /* builtin_platform_driver() - Helper macro for builtin drivers that 232 * don't do anything special in driver init. This eliminates some 233 * boilerplate. Each driver may only use this macro once, and 234 * calling it replaces device_initcall(). Note this is meant to be 235 * a parallel of module_platform_driver() above, but w/o _exit stuff. 236 */ 237 #define builtin_platform_driver(__platform_driver) \ 238 builtin_driver(__platform_driver, platform_driver_register) 239 240 /* module_platform_driver_probe() - Helper macro for drivers that don't do 241 * anything special in module init/exit. This eliminates a lot of 242 * boilerplate. Each module may only use this macro once, and 243 * calling it replaces module_init() and module_exit() 244 */ 245 #define module_platform_driver_probe(__platform_driver, __platform_probe) \ 246 static int __init __platform_driver##_init(void) \ 247 { \ 248 return platform_driver_probe(&(__platform_driver), \ 249 __platform_probe); \ 250 } \ 251 module_init(__platform_driver##_init); \ 252 static void __exit __platform_driver##_exit(void) \ 253 { \ 254 platform_driver_unregister(&(__platform_driver)); \ 255 } \ 256 module_exit(__platform_driver##_exit); 257 258 /* builtin_platform_driver_probe() - Helper macro for drivers that don't do 259 * anything special in device init. This eliminates some boilerplate. Each 260 * driver may only use this macro once, and using it replaces device_initcall. 261 * This is meant to be a parallel of module_platform_driver_probe above, but 262 * without the __exit parts. 263 */ 264 #define builtin_platform_driver_probe(__platform_driver, __platform_probe) \ 265 static int __init __platform_driver##_init(void) \ 266 { \ 267 return platform_driver_probe(&(__platform_driver), \ 268 __platform_probe); \ 269 } \ 270 device_initcall(__platform_driver##_init); \ 271 272 #define platform_create_bundle(driver, probe, res, n_res, data, size) \ 273 __platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE) 274 extern struct platform_device *__platform_create_bundle( 275 struct platform_driver *driver, int (*probe)(struct platform_device *), 276 struct resource *res, unsigned int n_res, 277 const void *data, size_t size, struct module *module); 278 279 int __platform_register_drivers(struct platform_driver * const *drivers, 280 unsigned int count, struct module *owner); 281 void platform_unregister_drivers(struct platform_driver * const *drivers, 282 unsigned int count); 283 284 #define platform_register_drivers(drivers, count) \ 285 __platform_register_drivers(drivers, count, THIS_MODULE) 286 287 /* early platform driver interface */ 288 struct early_platform_driver { 289 const char *class_str; 290 struct platform_driver *pdrv; 291 struct list_head list; 292 int requested_id; 293 char *buffer; 294 int bufsize; 295 }; 296 297 #define EARLY_PLATFORM_ID_UNSET -2 298 #define EARLY_PLATFORM_ID_ERROR -3 299 300 extern int early_platform_driver_register(struct early_platform_driver *epdrv, 301 char *buf); 302 extern void early_platform_add_devices(struct platform_device **devs, int num); 303 304 static inline int is_early_platform_device(struct platform_device *pdev) 305 { 306 return !pdev->dev.driver; 307 } 308 309 extern void early_platform_driver_register_all(char *class_str); 310 extern int early_platform_driver_probe(char *class_str, 311 int nr_probe, int user_only); 312 extern void early_platform_cleanup(void); 313 314 #define early_platform_init(class_string, platdrv) \ 315 early_platform_init_buffer(class_string, platdrv, NULL, 0) 316 317 #ifndef MODULE 318 #define early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \ 319 static __initdata struct early_platform_driver early_driver = { \ 320 .class_str = class_string, \ 321 .buffer = buf, \ 322 .bufsize = bufsiz, \ 323 .pdrv = platdrv, \ 324 .requested_id = EARLY_PLATFORM_ID_UNSET, \ 325 }; \ 326 static int __init early_platform_driver_setup_func(char *buffer) \ 327 { \ 328 return early_platform_driver_register(&early_driver, buffer); \ 329 } \ 330 early_param(class_string, early_platform_driver_setup_func) 331 #else /* MODULE */ 332 #define early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \ 333 static inline char *early_platform_driver_setup_func(void) \ 334 { \ 335 return bufsiz ? buf : NULL; \ 336 } 337 #endif /* MODULE */ 338 339 #ifdef CONFIG_SUSPEND 340 extern int platform_pm_suspend(struct device *dev); 341 extern int platform_pm_resume(struct device *dev); 342 #else 343 #define platform_pm_suspend NULL 344 #define platform_pm_resume NULL 345 #endif 346 347 #ifdef CONFIG_HIBERNATE_CALLBACKS 348 extern int platform_pm_freeze(struct device *dev); 349 extern int platform_pm_thaw(struct device *dev); 350 extern int platform_pm_poweroff(struct device *dev); 351 extern int platform_pm_restore(struct device *dev); 352 #else 353 #define platform_pm_freeze NULL 354 #define platform_pm_thaw NULL 355 #define platform_pm_poweroff NULL 356 #define platform_pm_restore NULL 357 #endif 358 359 #ifdef CONFIG_PM_SLEEP 360 #define USE_PLATFORM_PM_SLEEP_OPS \ 361 .suspend = platform_pm_suspend, \ 362 .resume = platform_pm_resume, \ 363 .freeze = platform_pm_freeze, \ 364 .thaw = platform_pm_thaw, \ 365 .poweroff = platform_pm_poweroff, \ 366 .restore = platform_pm_restore, 367 #else 368 #define USE_PLATFORM_PM_SLEEP_OPS 369 #endif 370 371 #endif /* _PLATFORM_DEVICE_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/mtd/spi-nor/hisi-sfc.ko 322_7a CPAchecker Bug Fixed 2017-02-18 01:11:16 L0267

Comment

Reported: 18 Feb 2017

[Home]