Error Trace

[Home]

Bug # 11

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()
{
33 struct module ;
19 typedef signed char __s8;
20 typedef unsigned char __u8;
22 typedef short __s16;
23 typedef unsigned short __u16;
25 typedef int __s32;
26 typedef unsigned int __u32;
30 typedef unsigned long long __u64;
16 typedef unsigned char u8;
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;
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;
90 typedef unsigned short ushort;
91 typedef unsigned int uint;
92 typedef unsigned long ulong;
102 typedef __s32 int32_t;
108 typedef __u32 uint32_t;
133 typedef unsigned long sector_t;
134 typedef unsigned long blkcnt_t;
147 typedef u64 dma_addr_t;
158 typedef unsigned int gfp_t;
159 typedef unsigned int fmode_t;
160 typedef unsigned int oom_flags_t;
163 typedef u64 phys_addr_t;
168 typedef phys_addr_t resource_size_t;
178 struct __anonstruct_atomic_t_6 { int counter; } ;
178 typedef struct __anonstruct_atomic_t_6 atomic_t;
183 struct __anonstruct_atomic64_t_7 { long counter; } ;
183 typedef struct __anonstruct_atomic64_t_7 atomic64_t;
184 struct list_head { struct list_head *next; struct list_head *prev; } ;
189 struct hlist_node ;
189 struct hlist_head { struct hlist_node *first; } ;
193 struct hlist_node { struct hlist_node *next; struct hlist_node **pprev; } ;
204 struct callback_head { struct callback_head *next; void (*func)(struct callback_head *); } ;
65 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; } ;
59 struct __anonstruct_ldv_1016_9 { unsigned int a; unsigned int b; } ;
59 struct __anonstruct_ldv_1031_10 { 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; } ;
59 union __anonunion_ldv_1032_8 { struct __anonstruct_ldv_1016_9 ldv_1016; struct __anonstruct_ldv_1031_10 ldv_1031; } ;
59 struct desc_struct { union __anonunion_ldv_1032_8 ldv_1032; } ;
12 typedef unsigned long pteval_t;
15 typedef unsigned long pgdval_t;
16 typedef unsigned long pgprotval_t;
18 struct __anonstruct_pte_t_11 { pteval_t pte; } ;
18 typedef struct __anonstruct_pte_t_11 pte_t;
20 struct pgprot { pgprotval_t pgprot; } ;
242 typedef struct pgprot pgprot_t;
244 struct __anonstruct_pgd_t_12 { pgdval_t pgd; } ;
244 typedef struct __anonstruct_pgd_t_12 pgd_t;
332 struct page ;
332 typedef struct page *pgtable_t;
340 struct file ;
353 struct seq_file ;
390 struct thread_struct ;
392 struct mm_struct ;
393 struct task_struct ;
394 struct cpumask ;
327 struct arch_spinlock ;
18 typedef u16 __ticket_t;
19 typedef u32 __ticketpair_t;
20 struct __raw_tickets { __ticket_t head; __ticket_t tail; } ;
32 union __anonunion_ldv_1452_15 { __ticketpair_t head_tail; struct __raw_tickets tickets; } ;
32 struct arch_spinlock { union __anonunion_ldv_1452_15 ldv_1452; } ;
33 typedef struct arch_spinlock arch_spinlock_t;
34 struct qrwlock { atomic_t cnts; arch_spinlock_t lock; } ;
14 typedef struct qrwlock arch_rwlock_t;
48 struct device ;
400 struct file_operations ;
412 struct completion ;
416 struct pid ;
22 struct kernel_cap_struct { __u32 cap[2U]; } ;
25 typedef struct kernel_cap_struct kernel_cap_t;
33 struct inode ;
34 struct dentry ;
35 struct user_namespace ;
102 struct timespec ;
127 struct kernel_vm86_regs { struct pt_regs pt; unsigned short es; unsigned short __esh; unsigned short ds; unsigned short __dsh; unsigned short fs; unsigned short __fsh; unsigned short gs; unsigned short __gsh; } ;
79 union __anonunion_ldv_3124_21 { struct pt_regs *regs; struct kernel_vm86_regs *vm86; } ;
79 struct math_emu_info { long ___orig_eip; union __anonunion_ldv_3124_21 ldv_3124; } ;
306 struct cpumask { unsigned long bits[128U]; } ;
14 typedef struct cpumask cpumask_t;
671 typedef struct cpumask *cpumask_var_t;
162 struct seq_operations ;
294 struct i387_fsave_struct { u32 cwd; u32 swd; u32 twd; u32 fip; u32 fcs; u32 foo; u32 fos; u32 st_space[20U]; u32 status; } ;
312 struct __anonstruct_ldv_5431_26 { u64 rip; u64 rdp; } ;
312 struct __anonstruct_ldv_5437_27 { u32 fip; u32 fcs; u32 foo; u32 fos; } ;
312 union __anonunion_ldv_5438_25 { struct __anonstruct_ldv_5431_26 ldv_5431; struct __anonstruct_ldv_5437_27 ldv_5437; } ;
312 union __anonunion_ldv_5447_28 { u32 padding1[12U]; u32 sw_reserved[12U]; } ;
312 struct i387_fxsave_struct { u16 cwd; u16 swd; u16 twd; u16 fop; union __anonunion_ldv_5438_25 ldv_5438; u32 mxcsr; u32 mxcsr_mask; u32 st_space[32U]; u32 xmm_space[64U]; u32 padding[12U]; union __anonunion_ldv_5447_28 ldv_5447; } ;
346 struct i387_soft_struct { 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; } ;
367 struct ymmh_struct { u32 ymmh_space[64U]; } ;
372 struct lwp_struct { u8 reserved[128U]; } ;
377 struct bndregs_struct { u64 bndregs[8U]; } ;
381 struct bndcsr_struct { u64 cfg_reg_u; u64 status_reg; } ;
386 struct xsave_hdr_struct { u64 xstate_bv; u64 reserved1[2U]; u64 reserved2[5U]; } ;
392 struct xsave_struct { struct i387_fxsave_struct i387; struct xsave_hdr_struct xsave_hdr; struct ymmh_struct ymmh; struct lwp_struct lwp; struct bndregs_struct bndregs; struct bndcsr_struct bndcsr; } ;
401 union thread_xstate { struct i387_fsave_struct fsave; struct i387_fxsave_struct fxsave; struct i387_soft_struct soft; struct xsave_struct xsave; } ;
409 struct fpu { unsigned int last_cpu; unsigned int has_fpu; union thread_xstate *state; } ;
465 struct kmem_cache ;
466 struct perf_event ;
467 struct thread_struct { struct desc_struct tls_array[3U]; unsigned long sp0; unsigned long sp; unsigned long usersp; unsigned short es; unsigned short ds; unsigned short fsindex; unsigned short gsindex; unsigned long fs; unsigned long gs; struct perf_event *ptrace_bps[4U]; unsigned long debugreg6; unsigned long ptrace_dr7; unsigned long cr2; unsigned long trap_nr; unsigned long error_code; struct fpu fpu; unsigned long *io_bitmap_ptr; unsigned long iopl; unsigned int io_bitmap_max; unsigned char fpu_counter; } ;
23 typedef atomic64_t atomic_long_t;
35 struct lockdep_map ;
55 struct stack_trace { unsigned int nr_entries; unsigned int max_entries; unsigned long *entries; int skip; } ;
26 struct lockdep_subclass_key { char __one_byte; } ;
53 struct lock_class_key { struct lockdep_subclass_key subkeys[8U]; } ;
59 struct lock_class { struct list_head 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; } ;
205 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; } ;
530 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_ldv_6488_32 { u8 __padding[24U]; struct lockdep_map dep_map; } ;
33 union __anonunion_ldv_6489_31 { struct raw_spinlock rlock; struct __anonstruct_ldv_6488_32 ldv_6488; } ;
33 struct spinlock { union __anonunion_ldv_6489_31 ldv_6489; } ;
76 typedef struct spinlock spinlock_t;
23 struct __anonstruct_rwlock_t_33 { 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_33 rwlock_t;
412 struct seqcount { unsigned int sequence; struct lockdep_map dep_map; } ;
51 typedef struct seqcount seqcount_t;
433 struct timespec { __kernel_time_t tv_sec; long tv_nsec; } ;
84 struct plist_node { int prio; struct list_head prio_list; struct list_head node_list; } ;
299 struct rb_node { unsigned long __rb_parent_color; struct rb_node *rb_right; struct rb_node *rb_left; } ;
40 struct rb_root { struct rb_node *rb_node; } ;
98 struct __anonstruct_nodemask_t_35 { unsigned long bits[16U]; } ;
98 typedef struct __anonstruct_nodemask_t_35 nodemask_t;
522 struct optimistic_spin_queue ;
523 struct rw_semaphore ;
524 struct rw_semaphore { long count; raw_spinlock_t wait_lock; struct list_head wait_list; struct task_struct *owner; struct optimistic_spin_queue *osq; struct lockdep_map dep_map; } ;
12 struct __wait_queue ;
12 typedef struct __wait_queue wait_queue_t;
15 struct __wait_queue { unsigned int flags; void *private; int (*func)(wait_queue_t *, unsigned int, int, void *); struct list_head task_list; } ;
34 struct __wait_queue_head { spinlock_t lock; struct list_head task_list; } ;
39 typedef struct __wait_queue_head wait_queue_head_t;
920 struct completion { unsigned int done; wait_queue_head_t wait; } ;
113 struct vm_area_struct ;
59 struct mutex { atomic_t count; spinlock_t wait_lock; struct list_head wait_list; struct task_struct *owner; const char *name; void *magic; struct lockdep_map dep_map; } ;
68 struct mutex_waiter { struct list_head list; struct task_struct *task; void *magic; } ;
10 struct llist_node ;
10 struct llist_head { struct llist_node *first; } ;
64 struct llist_node { struct llist_node *next; } ;
72 struct resource { resource_size_t start; resource_size_t end; const char *name; unsigned long flags; struct resource *parent; struct resource *sibling; struct resource *child; } ;
172 struct pci_dev ;
167 union ktime { s64 tv64; } ;
59 typedef union ktime ktime_t;
412 struct tvec_base ;
413 struct timer_list { struct list_head entry; unsigned long expires; struct tvec_base *base; void (*function)(unsigned long); unsigned long data; int slack; int start_pid; void *start_site; char start_comm[16U]; struct lockdep_map lockdep_map; } ;
254 struct hrtimer ;
255 enum hrtimer_restart ;
266 struct workqueue_struct ;
267 struct work_struct ;
53 struct work_struct { atomic_long_t data; struct list_head entry; void (*func)(struct work_struct *); struct lockdep_map lockdep_map; } ;
106 struct delayed_work { struct work_struct work; struct timer_list timer; struct workqueue_struct *wq; int cpu; } ;
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 ;
546 struct pm_subsys_data { spinlock_t lock; unsigned int refcount; struct list_head clock_list; } ;
553 struct dev_pm_qos ;
553 struct dev_pm_info { pm_message_t power_state; unsigned char can_wakeup; unsigned char async_suspend; bool is_prepared; bool is_suspended; bool is_noirq_suspended; bool is_late_suspended; bool ignore_children; 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; struct timer_list suspend_timer; unsigned long timer_expires; struct work_struct work; wait_queue_head_t wait_queue; 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; unsigned char no_callbacks; unsigned char irq_safe; unsigned char use_autosuspend; unsigned char timer_autosuspends; unsigned char memalloc_noio; 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; } ;
614 struct dev_pm_domain { struct dev_pm_ops ops; } ;
133 struct pci_bus ;
22 struct __anonstruct_mm_context_t_100 { void *ldt; int size; unsigned short ia32_compat; struct mutex lock; void *vdso; } ;
22 typedef struct __anonstruct_mm_context_t_100 mm_context_t;
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_ldv_12237_132 { struct arch_uprobe_task autask; unsigned long vaddr; } ;
73 struct __anonstruct_ldv_12241_133 { struct callback_head dup_xol_work; unsigned long dup_xol_addr; } ;
73 union __anonunion_ldv_12242_131 { struct __anonstruct_ldv_12237_132 ldv_12237; struct __anonstruct_ldv_12241_133 ldv_12241; } ;
73 struct uprobe ;
73 struct return_instance ;
73 struct uprobe_task { enum uprobe_task_state state; union __anonunion_ldv_12242_131 ldv_12242; struct uprobe *active_uprobe; unsigned long xol_vaddr; struct return_instance *return_instances; unsigned int depth; } ;
94 struct xol_area ;
95 struct uprobes_state { struct xol_area *xol_area; } ;
133 struct address_space ;
134 union __anonunion_ldv_12351_134 { struct address_space *mapping; void *s_mem; } ;
134 union __anonunion_ldv_12357_136 { unsigned long index; void *freelist; bool pfmemalloc; } ;
134 struct __anonstruct_ldv_12367_140 { unsigned short inuse; unsigned short objects; unsigned char frozen; } ;
134 union __anonunion_ldv_12369_139 { atomic_t _mapcount; struct __anonstruct_ldv_12367_140 ldv_12367; int units; } ;
134 struct __anonstruct_ldv_12371_138 { union __anonunion_ldv_12369_139 ldv_12369; atomic_t _count; } ;
134 union __anonunion_ldv_12373_137 { unsigned long counters; struct __anonstruct_ldv_12371_138 ldv_12371; unsigned int active; } ;
134 struct __anonstruct_ldv_12374_135 { union __anonunion_ldv_12357_136 ldv_12357; union __anonunion_ldv_12373_137 ldv_12373; } ;
134 struct __anonstruct_ldv_12381_142 { struct page *next; int pages; int pobjects; } ;
134 struct slab ;
134 union __anonunion_ldv_12386_141 { struct list_head lru; struct __anonstruct_ldv_12381_142 ldv_12381; struct slab *slab_page; struct callback_head callback_head; pgtable_t pmd_huge_pte; } ;
134 union __anonunion_ldv_12392_143 { unsigned long private; spinlock_t *ptl; struct kmem_cache *slab_cache; struct page *first_page; } ;
134 struct page { unsigned long flags; union __anonunion_ldv_12351_134 ldv_12351; struct __anonstruct_ldv_12374_135 ldv_12374; union __anonunion_ldv_12386_141 ldv_12386; union __anonunion_ldv_12392_143 ldv_12392; unsigned long debug_flags; } ;
187 struct page_frag { struct page *page; __u32 offset; __u32 size; } ;
239 struct __anonstruct_linear_145 { struct rb_node rb; unsigned long rb_subtree_last; } ;
239 union __anonunion_shared_144 { struct __anonstruct_linear_145 linear; struct list_head nonlinear; } ;
239 struct anon_vma ;
239 struct vm_operations_struct ;
239 struct mempolicy ;
239 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; union __anonunion_shared_144 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; } ;
311 struct core_thread { struct task_struct *task; struct core_thread *next; } ;
317 struct core_state { atomic_t nr_threads; struct core_thread dumper; struct completion startup; } ;
330 struct task_rss_stat { int events; int count[3U]; } ;
338 struct mm_rss_stat { atomic_long_t count[3U]; } ;
343 struct kioctx_table ;
344 struct linux_binfmt ;
344 struct mmu_notifier_mm ;
344 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; 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 shared_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 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; } ;
4 typedef unsigned long cputime_t;
22 struct __anonstruct_kuid_t_146 { uid_t val; } ;
22 typedef struct __anonstruct_kuid_t_146 kuid_t;
27 struct __anonstruct_kgid_t_147 { gid_t val; } ;
27 typedef struct __anonstruct_kgid_t_147 kgid_t;
25 struct sem_undo_list ;
25 struct sysv_sem { struct sem_undo_list *undo_list; } ;
24 struct __anonstruct_sigset_t_148 { unsigned long sig[1U]; } ;
24 typedef struct __anonstruct_sigset_t_148 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;
34 union sigval { int sival_int; void *sival_ptr; } ;
10 typedef union sigval sigval_t;
11 struct __anonstruct__kill_150 { __kernel_pid_t _pid; __kernel_uid32_t _uid; } ;
11 struct __anonstruct__timer_151 { __kernel_timer_t _tid; int _overrun; char _pad[0U]; sigval_t _sigval; int _sys_private; } ;
11 struct __anonstruct__rt_152 { __kernel_pid_t _pid; __kernel_uid32_t _uid; sigval_t _sigval; } ;
11 struct __anonstruct__sigchld_153 { __kernel_pid_t _pid; __kernel_uid32_t _uid; int _status; __kernel_clock_t _utime; __kernel_clock_t _stime; } ;
11 struct __anonstruct__sigfault_154 { void *_addr; short _addr_lsb; } ;
11 struct __anonstruct__sigpoll_155 { long _band; int _fd; } ;
11 struct __anonstruct__sigsys_156 { void *_call_addr; int _syscall; unsigned int _arch; } ;
11 union __anonunion__sifields_149 { int _pad[28U]; struct __anonstruct__kill_150 _kill; struct __anonstruct__timer_151 _timer; struct __anonstruct__rt_152 _rt; struct __anonstruct__sigchld_153 _sigchld; struct __anonstruct__sigfault_154 _sigfault; struct __anonstruct__sigpoll_155 _sigpoll; struct __anonstruct__sigsys_156 _sigsys; } ;
11 struct siginfo { int si_signo; int si_errno; int si_code; union __anonunion__sifields_149 _sifields; } ;
109 typedef struct siginfo siginfo_t;
11 struct user_struct ;
21 struct sigpending { struct list_head list; sigset_t signal; } ;
246 struct sigaction { __sighandler_t sa_handler; unsigned long sa_flags; __sigrestore_t sa_restorer; sigset_t sa_mask; } ;
260 struct k_sigaction { struct sigaction sa; } ;
459 enum pid_type { PIDTYPE_PID = 0, PIDTYPE_PGID = 1, PIDTYPE_SID = 2, PIDTYPE_MAX = 3 } ;
466 struct pid_namespace ;
466 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; } ;
195 struct percpu_counter { raw_spinlock_t lock; s64 count; struct list_head list; s32 *counters; } ;
46 struct seccomp_filter ;
47 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; unsigned long state; int start_pid; void *start_site; char start_comm[16U]; } ;
132 struct hrtimer_clock_base { struct hrtimer_cpu_base *cpu_base; int index; clockid_t clockid; struct timerqueue_head active; ktime_t resolution; ktime_t (*get_time)(); ktime_t softirq_time; ktime_t offset; } ;
163 struct hrtimer_cpu_base { raw_spinlock_t lock; unsigned int active_bases; unsigned int clock_was_set; ktime_t expires_next; int hres_active; int hang_detected; unsigned long nr_events; unsigned long nr_retries; unsigned long nr_hangs; ktime_t max_hang_time; struct hrtimer_clock_base clock_base[4U]; } ;
463 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; } ;
835 struct nsproxy ;
193 struct assoc_array_ptr ;
193 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 signal_struct ;
37 struct cred ;
38 struct key_type ;
42 struct keyring_index_key { struct key_type *type; const char *description; size_t desc_len; } ;
123 union __anonunion_ldv_15357_161 { struct list_head graveyard_link; struct rb_node serial_node; } ;
123 struct key_user ;
123 union __anonunion_ldv_15365_162 { time_t expiry; time_t revoked_at; } ;
123 struct __anonstruct_ldv_15378_164 { struct key_type *type; char *description; } ;
123 union __anonunion_ldv_15379_163 { struct keyring_index_key index_key; struct __anonstruct_ldv_15378_164 ldv_15378; } ;
123 union __anonunion_type_data_165 { struct list_head link; unsigned long x[2U]; void *p[2U]; int reject_error; } ;
123 union __anonunion_payload_167 { unsigned long value; void *rcudata; void *data; void *data2[2U]; } ;
123 union __anonunion_ldv_15394_166 { union __anonunion_payload_167 payload; struct assoc_array keys; } ;
123 struct key { atomic_t usage; key_serial_t serial; union __anonunion_ldv_15357_161 ldv_15357; struct rw_semaphore sem; struct key_user *user; void *security; union __anonunion_ldv_15365_162 ldv_15365; 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_ldv_15379_163 ldv_15379; union __anonunion_type_data_165 type_data; union __anonunion_ldv_15394_166 ldv_15394; } ;
356 struct audit_context ;
27 struct group_info { atomic_t usage; int ngroups; int nblocks; kgid_t small_block[32U]; kgid_t *blocks[0U]; } ;
78 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; 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; } ;
125 struct futex_pi_state ;
126 struct robust_list_head ;
127 struct bio_list ;
128 struct fs_struct ;
129 struct perf_event_context ;
130 struct blk_plug ;
180 struct cfs_rq ;
181 struct task_group ;
426 struct sighand_struct { atomic_t count; struct k_sigaction action[64U]; spinlock_t siglock; wait_queue_head_t signalfd_wqh; } ;
465 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; } ;
473 struct cpu_itimer { cputime_t expires; cputime_t incr; u32 error; u32 incr_error; } ;
480 struct cputime { cputime_t utime; cputime_t stime; } ;
492 struct task_cputime { cputime_t utime; cputime_t stime; unsigned long long sum_exec_runtime; } ;
512 struct thread_group_cputimer { struct task_cputime cputime; int running; raw_spinlock_t lock; } ;
554 struct autogroup ;
555 struct tty_struct ;
555 struct taskstats ;
555 struct tty_audit_buf ;
555 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; cputime_t utime; cputime_t stime; cputime_t cutime; cputime_t cstime; cputime_t gtime; cputime_t cgtime; struct 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; unsigned int audit_tty_log_passwd; struct tty_audit_buf *tty_audit_buf; struct rw_semaphore group_rwsem; oom_flags_t oom_flags; short oom_score_adj; short oom_score_adj_min; struct mutex cred_guard_mutex; } ;
735 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; struct key *uid_keyring; struct key *session_keyring; struct hlist_node uidhash_node; kuid_t uid; atomic_long_t locked_vm; } ;
778 struct backing_dev_info ;
779 struct reclaim_state ;
780 struct sched_info { unsigned long pcount; unsigned long long run_delay; unsigned long long last_arrival; unsigned long long last_queued; } ;
794 struct task_delay_info { spinlock_t lock; unsigned int flags; struct timespec blkio_start; struct timespec blkio_end; u64 blkio_delay; u64 swapin_delay; u32 blkio_count; u32 swapin_count; struct timespec freepages_start; struct timespec freepages_end; u64 freepages_delay; u32 freepages_count; } ;
1026 struct io_context ;
1060 struct pipe_inode_info ;
1062 struct load_weight { unsigned long weight; u32 inv_weight; } ;
1069 struct sched_avg { u32 runnable_avg_sum; u32 runnable_avg_period; u64 last_runnable_update; s64 decay_count; unsigned long load_avg_contrib; } ;
1081 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; } ;
1116 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; } ;
1148 struct rt_rq ;
1148 struct sched_rt_entity { struct list_head run_list; unsigned long timeout; unsigned long watchdog_stamp; unsigned int time_slice; struct sched_rt_entity *back; struct sched_rt_entity *parent; struct rt_rq *rt_rq; struct rt_rq *my_q; } ;
1164 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_new; int dl_boosted; int dl_yielded; struct hrtimer dl_timer; } ;
1222 struct mem_cgroup ;
1222 struct memcg_batch_info { int do_batch; struct mem_cgroup *memcg; unsigned long nr_pages; unsigned long memsw_nr_pages; } ;
1643 struct memcg_oom_info { struct mem_cgroup *memcg; gfp_t gfp_mask; int order; unsigned char may_oom; } ;
1650 struct sched_class ;
1650 struct files_struct ;
1650 struct css_set ;
1650 struct compat_robust_list_head ;
1650 struct numa_group ;
1650 struct task_struct { volatile long state; void *stack; atomic_t usage; unsigned int flags; unsigned int ptrace; struct llist_node wake_entry; int on_cpu; struct task_struct *last_wakee; unsigned long wakee_flips; unsigned long wakee_flip_decay_ts; 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; 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; unsigned char brk_randomized; 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 int jobctl; unsigned int personality; unsigned char in_execve; unsigned char in_iowait; unsigned char no_new_privs; unsigned char sched_reset_on_fork; unsigned char sched_contributes_to_load; 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 utimescaled; cputime_t stimescaled; cputime_t gtime; struct cputime prev_cputime; unsigned long nvcsw; unsigned long nivcsw; struct timespec start_time; struct timespec 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 *real_cred; const struct cred *cred; char comm[16U]; int link_count; int total_link_count; struct sysv_sem sysvsem; unsigned long last_switch_count; struct thread_struct thread; 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; int (*notifier)(void *); void *notifier_data; sigset_t *notifier_mask; 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 rb_root pi_waiters; struct rb_node *pi_waiters_leftmost; struct rt_mutex_waiter *pi_blocked_on; struct task_struct *pi_top_task; 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; 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; 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_memory; unsigned long total_numa_faults; unsigned long *numa_faults_buffer_memory; unsigned long *numa_faults_cpu; unsigned long *numa_faults_buffer_cpu; unsigned long numa_faults_locality[2U]; unsigned long numa_pages_migrated; 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]; unsigned long timer_slack_ns; unsigned long default_timer_slack_ns; unsigned long trace; unsigned long trace_recursion; struct memcg_batch_info memcg_batch; unsigned int memcg_kmem_skip_account; struct memcg_oom_info memcg_oom; struct uprobe_task *utask; unsigned int sequential_io; unsigned int sequential_io_avg; } ;
2998 enum irqreturn { IRQ_NONE = 0, IRQ_HANDLED = 1, IRQ_WAKE_THREAD = 2 } ;
16 typedef enum irqreturn irqreturn_t;
359 struct proc_dir_entry ;
61 struct kref { atomic_t refcount; } ;
450 struct tasklet_struct { struct tasklet_struct *next; unsigned long state; atomic_t count; void (*func)(unsigned long); unsigned long data; } ;
91 struct serial_icounter_struct { int cts; int dsr; int rng; int dcd; int rx; int tx; int frame; int overrun; int parity; int brk; int buf_overrun; int reserved[9U]; } ;
13 typedef unsigned long kernel_ulong_t;
14 struct pci_device_id { __u32 vendor; __u32 device; __u32 subvendor; __u32 subdevice; __u32 class; __u32 class_mask; kernel_ulong_t driver_data; } ;
186 struct acpi_device_id { __u8 id[9U]; kernel_ulong_t driver_data; } ;
219 struct of_device_id { char name[32U]; char type[32U]; char compatible[128U]; const void *data; } ;
628 union __anonunion_ldv_19277_174 { unsigned long bitmap[4U]; struct callback_head callback_head; } ;
628 struct idr_layer { int prefix; int layer; struct idr_layer *ary[256U]; int count; union __anonunion_ldv_19277_174 ldv_19277; } ;
41 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; } ;
124 struct ida_bitmap { long nr_busy; unsigned long bitmap[15U]; } ;
153 struct ida { struct idr idr; struct ida_bitmap *free_bitmap; } ;
185 struct iattr ;
186 struct super_block ;
187 struct file_system_type ;
188 struct kernfs_open_node ;
189 struct kernfs_iattrs ;
212 struct kernfs_root ;
212 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; } ;
95 union __anonunion_ldv_19420_175 { struct kernfs_elem_dir dir; struct kernfs_elem_symlink symlink; struct kernfs_elem_attr attr; } ;
95 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_ldv_19420_175 ldv_19420; void *priv; unsigned short flags; umode_t mode; unsigned int ino; struct kernfs_iattrs *iattr; } ;
137 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 *); } ;
154 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; } ;
170 struct kernfs_open_file { struct kernfs_node *kn; struct file *file; void *priv; struct mutex mutex; int event; struct list_head list; size_t atomic_write_len; bool mmapped; const struct vm_operations_struct *vm_ops; } ;
186 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; 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; } ;
462 struct sock ;
463 struct kobject ;
464 enum kobj_ns_type { KOBJ_NS_TYPE_NONE = 0, KOBJ_NS_TYPE_NET = 1, KOBJ_NS_TYPES = 2 } ;
470 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 *); } ;
135 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 bin_attribute ;
37 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); struct attribute **attrs; struct bin_attribute **bin_attrs; } ;
67 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 *); } ;
131 struct sysfs_ops { ssize_t (*show)(struct kobject *, struct attribute *, char *); ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t ); } ;
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; } ;
114 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 *); } ;
122 struct kobj_uevent_env { char *argv[3U]; char *envp[32U]; int envp_idx; char buf[2048U]; int buflen; } ;
130 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 *); } ;
147 struct kset { struct list_head list; spinlock_t list_lock; struct kobject kobj; const struct kset_uevent_ops *uevent_ops; } ;
222 struct klist_node ;
37 struct klist_node { void *n_klist; struct list_head n_node; struct kref n_ref; } ;
67 struct path ;
68 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; struct user_namespace *user_ns; void *private; } ;
35 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 *); } ;
196 struct pinctrl ;
197 struct pinctrl_state ;
194 struct dev_pin_info { struct pinctrl *p; struct pinctrl_state *default_state; struct pinctrl_state *sleep_state; struct pinctrl_state *idle_state; } ;
42 struct dma_map_ops ;
42 struct dev_archdata { struct dma_map_ops *dma_ops; void *iommu; } ;
14 struct device_private ;
15 struct device_driver ;
16 struct driver_private ;
17 struct class ;
18 struct subsys_private ;
19 struct bus_type ;
20 struct device_node ;
21 struct iommu_ops ;
22 struct iommu_group ;
60 struct device_attribute ;
60 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; struct iommu_ops *iommu_ops; struct subsys_private *p; struct lock_class_key lock_key; } ;
138 struct device_type ;
195 struct device_driver { const char *name; struct bus_type *bus; struct module *owner; const char *mod_name; bool suppress_bind_attrs; 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; } ;
321 struct class_attribute ;
321 struct class { const char *name; struct module *owner; struct class_attribute *class_attrs; 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; } ;
414 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 ); } ;
482 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; } ;
510 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 ); } ;
640 struct device_dma_parameters { unsigned int max_segment_size; unsigned long segment_boundary_mask; } ;
649 struct acpi_device ;
650 struct acpi_dev_node { struct acpi_device *companion; } ;
656 struct dma_coherent_mem ;
656 struct cma ;
656 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_pm_info power; struct dev_pm_domain *pm_domain; struct dev_pin_info *pins; 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 acpi_dev_node acpi_node; 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; bool offline_disabled; bool offline; } ;
803 struct wakeup_source { const char *name; struct list_head entry; spinlock_t lock; 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; } ;
1198 struct hotplug_slot ;
1198 struct pci_slot { struct pci_bus *bus; struct list_head list; struct hotplug_slot *hotplug; unsigned char number; struct kobject kobj; } ;
109 typedef int pci_power_t;
136 typedef unsigned int pci_channel_state_t;
137 enum pci_channel_state { pci_channel_io_normal = 1, pci_channel_io_frozen = 2, pci_channel_io_perm_failure = 3 } ;
162 typedef unsigned short pci_dev_flags_t;
185 typedef unsigned short pci_bus_flags_t;
242 struct pcie_link_state ;
243 struct pci_vpd ;
244 struct pci_sriov ;
245 struct pci_ats ;
246 struct pci_driver ;
246 union __anonunion_ldv_21410_176 { struct pci_sriov *sriov; struct pci_dev *physfn; } ;
246 struct pci_dev { struct list_head bus_list; struct pci_bus *bus; struct pci_bus *subordinate; void *sysdata; struct proc_dir_entry *procent; struct pci_slot *slot; unsigned int devfn; unsigned short vendor; unsigned short device; unsigned short subsystem_vendor; unsigned short subsystem_device; unsigned int class; u8 revision; u8 hdr_type; u8 pcie_cap; u8 msi_cap; u8 msix_cap; unsigned char pcie_mpss; u8 rom_base_reg; u8 pin; u16 pcie_flags_reg; u8 dma_alias_devfn; struct pci_driver *driver; u64 dma_mask; struct device_dma_parameters dma_parms; pci_power_t current_state; u8 pm_cap; unsigned char pme_support; unsigned char pme_interrupt; unsigned char pme_poll; unsigned char d1_support; unsigned char d2_support; unsigned char no_d1d2; unsigned char no_d3cold; unsigned char d3cold_allowed; unsigned char mmio_always_on; unsigned char wakeup_prepared; unsigned char runtime_d3cold; unsigned int d3_delay; unsigned int d3cold_delay; struct pcie_link_state *link_state; pci_channel_state_t error_state; struct device dev; int cfg_size; unsigned int irq; struct resource resource[17U]; bool match_driver; unsigned char transparent; unsigned char multifunction; unsigned char is_added; unsigned char is_busmaster; unsigned char no_msi; unsigned char block_cfg_access; unsigned char broken_parity_status; unsigned char irq_reroute_variant; unsigned char msi_enabled; unsigned char msix_enabled; unsigned char ari_enabled; unsigned char is_managed; unsigned char needs_freset; unsigned char state_saved; unsigned char is_physfn; unsigned char is_virtfn; unsigned char reset_fn; unsigned char is_hotplug_bridge; unsigned char __aer_firmware_first_valid; unsigned char __aer_firmware_first; unsigned char broken_intx_masking; unsigned char io_window_1k; pci_dev_flags_t dev_flags; atomic_t enable_cnt; u32 saved_config_space[16U]; struct hlist_head saved_cap_space; struct bin_attribute *rom_attr; int rom_attr_enabled; struct bin_attribute *res_attr[17U]; struct bin_attribute *res_attr_wc[17U]; struct list_head msi_list; const struct attribute_group **msi_irq_groups; struct pci_vpd *vpd; union __anonunion_ldv_21410_176 ldv_21410; struct pci_ats *ats; phys_addr_t rom; size_t romlen; char *driver_override; } ;
436 struct pci_ops ;
436 struct msi_chip ;
436 struct pci_bus { struct list_head node; struct pci_bus *parent; struct list_head children; struct list_head devices; struct pci_dev *self; struct list_head slots; struct resource *resource[4U]; struct list_head resources; struct resource busn_res; struct pci_ops *ops; struct msi_chip *msi; void *sysdata; struct proc_dir_entry *procdir; unsigned char number; unsigned char primary; unsigned char max_bus_speed; unsigned char cur_bus_speed; char name[48U]; unsigned short bridge_ctl; pci_bus_flags_t bus_flags; struct device *bridge; struct device dev; struct bin_attribute *legacy_io; struct bin_attribute *legacy_mem; unsigned char is_added; } ;
553 struct pci_ops { int (*read)(struct pci_bus *, unsigned int, int, int, u32 *); int (*write)(struct pci_bus *, unsigned int, int, int, u32 ); } ;
574 struct pci_dynids { spinlock_t lock; struct list_head list; } ;
588 typedef unsigned int pci_ers_result_t;
598 struct pci_error_handlers { pci_ers_result_t (*error_detected)(struct pci_dev *, enum pci_channel_state ); pci_ers_result_t (*mmio_enabled)(struct pci_dev *); pci_ers_result_t (*link_reset)(struct pci_dev *); pci_ers_result_t (*slot_reset)(struct pci_dev *); void (*reset_notify)(struct pci_dev *, bool ); void (*resume)(struct pci_dev *); } ;
631 struct pci_driver { struct list_head node; const char *name; const struct pci_device_id *id_table; int (*probe)(struct pci_dev *, const struct pci_device_id *); void (*remove)(struct pci_dev *); int (*suspend)(struct pci_dev *, pm_message_t ); int (*suspend_late)(struct pci_dev *, pm_message_t ); int (*resume_early)(struct pci_dev *); int (*resume)(struct pci_dev *); void (*shutdown)(struct pci_dev *); int (*sriov_configure)(struct pci_dev *, int); const struct pci_error_handlers *err_handler; struct device_driver driver; struct pci_dynids dynids; } ;
1153 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; } ;
93 struct shrink_control { gfp_t gfp_mask; unsigned long nr_to_scan; nodemask_t nodes_to_scan; int nid; } ;
26 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; } ;
71 struct file_ra_state ;
72 struct writeback_control ;
188 struct vm_fault { unsigned int flags; unsigned long pgoff; void *virtual_address; struct page *page; unsigned long max_pgoff; pte_t *pte; } ;
221 struct vm_operations_struct { void (*open)(struct vm_area_struct *); void (*close)(struct vm_area_struct *); int (*fault)(struct vm_area_struct *, struct vm_fault *); void (*map_pages)(struct vm_area_struct *, struct vm_fault *); int (*page_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); int (*migrate)(struct vm_area_struct *, const nodemask_t *, const nodemask_t *, unsigned long); int (*remap_pages)(struct vm_area_struct *, unsigned long, unsigned long, unsigned long); } ;
368 struct kmem_cache_cpu { void **freelist; unsigned long tid; struct page *page; struct page *partial; unsigned int stat[26U]; } ;
48 struct kmem_cache_order_objects { unsigned long x; } ;
58 struct memcg_cache_params ;
58 struct kmem_cache_node ;
58 struct kmem_cache { struct kmem_cache_cpu *cpu_slab; unsigned long flags; unsigned long min_partial; int size; int object_size; int offset; int cpu_partial; struct kmem_cache_order_objects oo; struct kmem_cache_order_objects max; struct kmem_cache_order_objects min; gfp_t allocflags; int refcount; void (*ctor)(void *); int inuse; int align; int reserved; const char *name; struct list_head list; struct kobject kobj; struct memcg_cache_params *memcg_params; int max_attr_size; struct kset *memcg_kset; int remote_node_defrag_ratio; struct kmem_cache_node *node[1024U]; } ;
501 struct __anonstruct_ldv_25430_178 { struct callback_head callback_head; struct kmem_cache *memcg_caches[0U]; } ;
501 struct __anonstruct_ldv_25436_179 { struct mem_cgroup *memcg; struct list_head list; struct kmem_cache *root_cache; atomic_t nr_pages; } ;
501 union __anonunion_ldv_25437_177 { struct __anonstruct_ldv_25430_178 ldv_25430; struct __anonstruct_ldv_25436_179 ldv_25436; } ;
501 struct memcg_cache_params { bool is_root_cache; union __anonunion_ldv_25437_177 ldv_25437; } ;
34 struct dma_attrs { unsigned long flags[1U]; } ;
70 enum dma_data_direction { DMA_BIDIRECTIONAL = 0, DMA_TO_DEVICE = 1, DMA_FROM_DEVICE = 2, DMA_NONE = 3 } ;
77 struct sg_table { struct scatterlist *sgl; unsigned int nents; unsigned int orig_nents; } ;
351 struct dma_map_ops { void * (*alloc)(struct device *, size_t , dma_addr_t *, gfp_t , struct dma_attrs *); void (*free)(struct device *, size_t , void *, dma_addr_t , struct dma_attrs *); int (*mmap)(struct device *, struct vm_area_struct *, void *, dma_addr_t , size_t , struct dma_attrs *); int (*get_sgtable)(struct device *, struct sg_table *, void *, dma_addr_t , size_t , struct dma_attrs *); dma_addr_t (*map_page)(struct device *, struct page *, unsigned long, size_t , enum dma_data_direction , struct dma_attrs *); void (*unmap_page)(struct device *, dma_addr_t , size_t , enum dma_data_direction , struct dma_attrs *); int (*map_sg)(struct device *, struct scatterlist *, int, enum dma_data_direction , struct dma_attrs *); void (*unmap_sg)(struct device *, struct scatterlist *, int, enum dma_data_direction , struct dma_attrs *); 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; } ;
91 struct hlist_bl_node ;
91 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_ldv_26890_181 { spinlock_t lock; unsigned int count; } ;
114 union __anonunion_ldv_26891_180 { struct __anonstruct_ldv_26890_181 ldv_26890; } ;
114 struct lockref { union __anonunion_ldv_26891_180 ldv_26891; } ;
49 struct nameidata ;
50 struct vfsmount ;
51 struct __anonstruct_ldv_26914_183 { u32 hash; u32 len; } ;
51 union __anonunion_ldv_26916_182 { struct __anonstruct_ldv_26914_183 ldv_26914; u64 hash_len; } ;
51 struct qstr { union __anonunion_ldv_26916_182 ldv_26916; const unsigned char *name; } ;
90 struct dentry_operations ;
90 union __anonunion_d_u_184 { struct list_head d_child; struct callback_head d_rcu; } ;
90 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; struct list_head d_lru; union __anonunion_d_u_184 d_u; struct list_head d_subdirs; struct hlist_node d_alias; } ;
142 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 *, const struct dentry *, unsigned int, const char *, const struct qstr *); int (*d_delete)(const 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)(struct dentry *, bool ); } ;
477 struct path { struct vfsmount *mnt; struct dentry *dentry; } ;
27 struct list_lru_node { spinlock_t lock; struct list_head list; long nr_items; } ;
30 struct list_lru { struct list_lru_node *node; nodemask_t active_nodes; } ;
58 struct __anonstruct_ldv_27277_186 { struct radix_tree_node *parent; void *private_data; } ;
58 union __anonunion_ldv_27279_185 { struct __anonstruct_ldv_27277_186 ldv_27277; struct callback_head callback_head; } ;
58 struct radix_tree_node { unsigned int path; unsigned int count; union __anonunion_ldv_27279_185 ldv_27279; struct list_head private_list; void *slots[64U]; unsigned long tags[3U][1U]; } ;
105 struct radix_tree_root { unsigned int height; gfp_t gfp_mask; struct radix_tree_node *rnode; } ;
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 } ;
30 struct block_device ;
59 struct export_operations ;
61 struct iovec ;
62 struct kiocb ;
63 struct poll_table_struct ;
64 struct kstatfs ;
65 struct swap_info_struct ;
66 struct iov_iter ;
69 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; } ;
253 struct fs_disk_quota { __s8 d_version; __s8 d_flags; __u16 d_fieldmask; __u32 d_id; __u64 d_blk_hardlimit; __u64 d_blk_softlimit; __u64 d_ino_hardlimit; __u64 d_ino_softlimit; __u64 d_bcount; __u64 d_icount; __s32 d_itimer; __s32 d_btimer; __u16 d_iwarns; __u16 d_bwarns; __s32 d_padding2; __u64 d_rtb_hardlimit; __u64 d_rtb_softlimit; __u64 d_rtbcount; __s32 d_rtbtimer; __u16 d_rtbwarns; __s16 d_padding3; char d_padding4[8U]; } ;
76 struct fs_qfilestat { __u64 qfs_ino; __u64 qfs_nblks; __u32 qfs_nextents; } ;
151 typedef struct fs_qfilestat fs_qfilestat_t;
152 struct fs_quota_stat { __s8 qs_version; __u16 qs_flags; __s8 qs_pad; fs_qfilestat_t qs_uquota; fs_qfilestat_t qs_gquota; __u32 qs_incoredqs; __s32 qs_btimelimit; __s32 qs_itimelimit; __s32 qs_rtbtimelimit; __u16 qs_bwarnlimit; __u16 qs_iwarnlimit; } ;
166 struct fs_qfilestatv { __u64 qfs_ino; __u64 qfs_nblks; __u32 qfs_nextents; __u32 qfs_pad; } ;
196 struct fs_quota_statv { __s8 qs_version; __u8 qs_pad1; __u16 qs_flags; __u32 qs_incoredqs; struct fs_qfilestatv qs_uquota; struct fs_qfilestatv qs_gquota; struct fs_qfilestatv qs_pquota; __s32 qs_btimelimit; __s32 qs_itimelimit; __s32 qs_rtbtimelimit; __u16 qs_bwarnlimit; __u16 qs_iwarnlimit; __u64 qs_pad2[8U]; } ;
212 struct dquot ;
19 typedef __kernel_uid32_t projid_t;
23 struct __anonstruct_kprojid_t_187 { projid_t val; } ;
23 typedef struct __anonstruct_kprojid_t_187 kprojid_t;
119 struct if_dqinfo { __u64 dqi_bgrace; __u64 dqi_igrace; __u32 dqi_flags; __u32 dqi_valid; } ;
152 enum quota_type { USRQUOTA = 0, GRPQUOTA = 1, PRJQUOTA = 2 } ;
60 typedef long long qsize_t;
61 union __anonunion_ldv_27808_188 { kuid_t uid; kgid_t gid; kprojid_t projid; } ;
61 struct kqid { union __anonunion_ldv_27808_188 ldv_27808; enum quota_type type; } ;
178 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; time_t dqb_btime; time_t dqb_itime; } ;
200 struct quota_format_type ;
201 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_maxblimit; qsize_t dqi_maxilimit; void *dqi_priv; } ;
264 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; } ;
291 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 *); } ;
302 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 *); } ;
316 struct quotactl_ops { int (*quota_on)(struct super_block *, int, int, struct path *); int (*quota_on_meta)(struct super_block *, int, int); int (*quota_off)(struct super_block *, int); int (*quota_sync)(struct super_block *, int); int (*get_info)(struct super_block *, int, struct if_dqinfo *); int (*set_info)(struct super_block *, int, struct if_dqinfo *); int (*get_dqblk)(struct super_block *, struct kqid , struct fs_disk_quota *); int (*set_dqblk)(struct super_block *, struct kqid , struct fs_disk_quota *); int (*get_xstate)(struct super_block *, struct fs_quota_stat *); int (*set_xstate)(struct super_block *, unsigned int, int); int (*get_xstatev)(struct super_block *, struct fs_quota_statv *); int (*rm_xquota)(struct super_block *, unsigned int); } ;
334 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; } ;
380 struct quota_info { unsigned int flags; struct mutex dqio_mutex; struct mutex dqonoff_mutex; struct rw_semaphore dqptr_sem; struct inode *files[2U]; struct mem_dqinfo info[2U]; const struct quota_format_ops *ops[2U]; } ;
323 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)(int, struct kiocb *, struct iov_iter *, loff_t ); int (*get_xip_mem)(struct address_space *, unsigned long, int, void **, unsigned long *); int (*migratepage)(struct address_space *, struct page *, struct page *, enum migrate_mode ); 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 *); } ;
382 struct address_space { struct inode *host; struct radix_tree_root page_tree; spinlock_t tree_lock; unsigned int i_mmap_writable; struct rb_root i_mmap; struct list_head i_mmap_nonlinear; struct mutex i_mmap_mutex; unsigned long nrpages; unsigned long nrshadows; unsigned long writeback_index; const struct address_space_operations *a_ops; unsigned long flags; struct backing_dev_info *backing_dev_info; spinlock_t private_lock; struct list_head private_list; void *private_data; } ;
405 struct request_queue ;
406 struct hd_struct ;
406 struct gendisk ;
406 struct block_device { dev_t bd_dev; int bd_openers; struct inode *bd_inode; struct super_block *bd_super; struct mutex bd_mutex; struct list_head bd_inodes; 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; } ;
478 struct posix_acl ;
479 struct inode_operations ;
479 union __anonunion_ldv_28222_191 { const unsigned int i_nlink; unsigned int __i_nlink; } ;
479 union __anonunion_ldv_28242_192 { struct hlist_head i_dentry; struct callback_head i_rcu; } ;
479 struct file_lock ;
479 struct cdev ;
479 union __anonunion_ldv_28259_193 { struct pipe_inode_info *i_pipe; struct block_device *i_bdev; struct cdev *i_cdev; } ;
479 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_ldv_28222_191 ldv_28222; 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 mutex i_mutex; unsigned long dirtied_when; struct hlist_node i_hash; struct list_head i_wb_list; struct list_head i_lru; struct list_head i_sb_list; union __anonunion_ldv_28242_192 ldv_28242; 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 *i_flock; struct address_space i_data; struct dquot *i_dquot[2U]; struct list_head i_devices; union __anonunion_ldv_28259_193 ldv_28259; __u32 i_generation; __u32 i_fsnotify_mask; struct hlist_head i_fsnotify_marks; void *i_private; } ;
715 struct fown_struct { rwlock_t lock; struct pid *pid; enum pid_type pid_type; kuid_t uid; kuid_t euid; int signum; } ;
723 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; } ;
746 union __anonunion_f_u_194 { struct llist_node fu_llist; struct callback_head fu_rcuhead; } ;
746 struct file { union __anonunion_f_u_194 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; } ;
836 typedef struct files_struct *fl_owner_t;
837 struct file_lock_operations { void (*fl_copy_lock)(struct file_lock *, struct file_lock *); void (*fl_release_private)(struct file_lock *); } ;
842 struct lock_manager_operations { int (*lm_compare_owner)(struct file_lock *, struct file_lock *); unsigned long int (*lm_owner_key)(struct file_lock *); void (*lm_notify)(struct file_lock *); int (*lm_grant)(struct file_lock *, struct file_lock *, int); void (*lm_break)(struct file_lock *); int (*lm_change)(struct file_lock **, int); } ;
860 struct nlm_lockowner ;
861 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_196 { struct list_head link; int state; } ;
19 union __anonunion_fl_u_195 { struct nfs_lock_info nfs_fl; struct nfs4_lock_info nfs4_fl; struct __anonstruct_afs_196 afs; } ;
19 struct file_lock { struct file_lock *fl_next; 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_195 fl_u; } ;
963 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; } ;
1157 struct sb_writers { struct percpu_counter counter[3U]; wait_queue_head_t wait; int frozen; wait_queue_head_t wait_unfrozen; struct lockdep_map lock_map[3U]; } ;
1173 struct super_operations ;
1173 struct xattr_handler ;
1173 struct mtd_info ;
1173 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_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; struct list_head s_inodes; 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; 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 list_lru s_dentry_lru; struct list_lru s_inode_lru; struct callback_head rcu; } ;
1403 struct fiemap_extent_info { unsigned int fi_flags; unsigned int fi_extents_mapped; unsigned int fi_extents_max; struct fiemap_extent *fi_extents_start; } ;
1441 struct dir_context { int (*actor)(void *, const char *, int, loff_t , u64 , unsigned int); loff_t pos; } ;
1446 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 (*aio_read)(struct kiocb *, const struct iovec *, unsigned long, loff_t ); ssize_t (*aio_write)(struct kiocb *, const struct iovec *, unsigned long, 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 *); 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 (*aio_fsync)(struct kiocb *, 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 **); long int (*fallocate)(struct file *, int, loff_t , loff_t ); int (*show_fdinfo)(struct seq_file *, struct file *); } ;
1488 struct inode_operations { struct dentry * (*lookup)(struct inode *, struct dentry *, unsigned int); void * (*follow_link)(struct dentry *, struct nameidata *); int (*permission)(struct inode *, int); struct posix_acl * (*get_acl)(struct inode *, int); int (*readlink)(struct dentry *, char *, int); void (*put_link)(struct dentry *, struct nameidata *, void *); 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 *); int (*rename2)(struct inode *, struct dentry *, struct inode *, struct dentry *, unsigned int); int (*setattr)(struct dentry *, struct iattr *); int (*getattr)(struct vfsmount *, struct dentry *, struct kstat *); int (*setxattr)(struct dentry *, const char *, const void *, size_t , int); ssize_t (*getxattr)(struct dentry *, const char *, void *, size_t ); ssize_t (*listxattr)(struct dentry *, char *, size_t ); int (*removexattr)(struct dentry *, const char *); 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); } ;
1535 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_fs)(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 ); int (*bdev_try_to_free_page)(struct super_block *, struct page *, gfp_t ); long int (*nr_cached_objects)(struct super_block *, int); long int (*free_cached_objects)(struct super_block *, long, int); } ;
1749 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; } ;
6 typedef unsigned char cc_t;
7 typedef unsigned int speed_t;
8 typedef unsigned int tcflag_t;
30 struct ktermios { tcflag_t c_iflag; tcflag_t c_oflag; tcflag_t c_cflag; tcflag_t c_lflag; cc_t c_line; cc_t c_cc[19U]; speed_t c_ispeed; speed_t c_ospeed; } ;
41 struct winsize { unsigned short ws_row; unsigned short ws_col; unsigned short ws_xpixel; unsigned short ws_ypixel; } ;
93 struct termiox { __u16 x_hflag; __u16 x_cflag; __u16 x_rflag[5U]; __u16 x_sflag; } ;
16 struct cdev { struct kobject kobj; struct module *owner; const struct file_operations *ops; struct list_head list; dev_t dev; unsigned int count; } ;
34 struct tty_driver ;
35 struct tty_operations { struct tty_struct * (*lookup)(struct tty_driver *, struct inode *, int); int (*install)(struct tty_driver *, struct tty_struct *); void (*remove)(struct tty_driver *, struct tty_struct *); int (*open)(struct tty_struct *, struct file *); void (*close)(struct tty_struct *, struct file *); void (*shutdown)(struct tty_struct *); void (*cleanup)(struct tty_struct *); int (*write)(struct tty_struct *, const unsigned char *, int); int (*put_char)(struct tty_struct *, unsigned char); void (*flush_chars)(struct tty_struct *); int (*write_room)(struct tty_struct *); int (*chars_in_buffer)(struct tty_struct *); int (*ioctl)(struct tty_struct *, unsigned int, unsigned long); long int (*compat_ioctl)(struct tty_struct *, unsigned int, unsigned long); void (*set_termios)(struct tty_struct *, struct ktermios *); void (*throttle)(struct tty_struct *); void (*unthrottle)(struct tty_struct *); void (*stop)(struct tty_struct *); void (*start)(struct tty_struct *); void (*hangup)(struct tty_struct *); int (*break_ctl)(struct tty_struct *, int); void (*flush_buffer)(struct tty_struct *); void (*set_ldisc)(struct tty_struct *); void (*wait_until_sent)(struct tty_struct *, int); void (*send_xchar)(struct tty_struct *, char); int (*tiocmget)(struct tty_struct *); int (*tiocmset)(struct tty_struct *, unsigned int, unsigned int); int (*resize)(struct tty_struct *, struct winsize *); int (*set_termiox)(struct tty_struct *, struct termiox *); int (*get_icount)(struct tty_struct *, struct serial_icounter_struct *); int (*poll_init)(struct tty_driver *, int, char *); int (*poll_get_char)(struct tty_driver *, int); void (*poll_put_char)(struct tty_driver *, int, char); const struct file_operations *proc_fops; } ;
289 struct tty_port ;
289 struct tty_driver { int magic; struct kref kref; struct cdev *cdevs; struct module *owner; const char *driver_name; const char *name; int name_base; int major; int minor_start; unsigned int num; short type; short subtype; struct ktermios init_termios; unsigned long flags; struct proc_dir_entry *proc_entry; struct tty_driver *other; struct tty_struct **ttys; struct tty_port **ports; struct ktermios **termios; void *driver_state; const struct tty_operations *ops; struct list_head tty_drivers; } ;
356 struct ld_semaphore { long count; raw_spinlock_t wait_lock; unsigned int wait_readers; struct list_head read_wait; struct list_head write_wait; struct lockdep_map dep_map; } ;
170 struct tty_ldisc_ops { int magic; char *name; int num; int flags; int (*open)(struct tty_struct *); void (*close)(struct tty_struct *); void (*flush_buffer)(struct tty_struct *); ssize_t (*chars_in_buffer)(struct tty_struct *); ssize_t (*read)(struct tty_struct *, struct file *, unsigned char *, size_t ); ssize_t (*write)(struct tty_struct *, struct file *, const unsigned char *, size_t ); int (*ioctl)(struct tty_struct *, struct file *, unsigned int, unsigned long); long int (*compat_ioctl)(struct tty_struct *, struct file *, unsigned int, unsigned long); void (*set_termios)(struct tty_struct *, struct ktermios *); unsigned int (*poll)(struct tty_struct *, struct file *, struct poll_table_struct *); int (*hangup)(struct tty_struct *); void (*receive_buf)(struct tty_struct *, const unsigned char *, char *, int); void (*write_wakeup)(struct tty_struct *); void (*dcd_change)(struct tty_struct *, unsigned int); void (*fasync)(struct tty_struct *, int); int (*receive_buf2)(struct tty_struct *, const unsigned char *, char *, int); struct module *owner; int refcount; } ;
220 struct tty_ldisc { struct tty_ldisc_ops *ops; struct tty_struct *tty; } ;
225 union __anonunion_ldv_30687_197 { struct tty_buffer *next; struct llist_node free; } ;
225 struct tty_buffer { union __anonunion_ldv_30687_197 ldv_30687; int used; int size; int commit; int read; int flags; unsigned long data[0U]; } ;
59 struct tty_bufhead { struct tty_buffer *head; struct work_struct work; struct mutex lock; atomic_t priority; struct tty_buffer sentinel; struct llist_head free; atomic_t mem_used; int mem_limit; struct tty_buffer *tail; } ;
71 struct tty_port_operations { int (*carrier_raised)(struct tty_port *); void (*dtr_rts)(struct tty_port *, int); void (*shutdown)(struct tty_port *); int (*activate)(struct tty_port *, struct tty_struct *); void (*destruct)(struct tty_port *); } ;
197 struct tty_port { struct tty_bufhead buf; struct tty_struct *tty; struct tty_struct *itty; const struct tty_port_operations *ops; spinlock_t lock; int blocked_open; int count; wait_queue_head_t open_wait; wait_queue_head_t close_wait; wait_queue_head_t delta_msr_wait; unsigned long flags; unsigned char console; unsigned char low_latency; struct mutex mutex; struct mutex buf_mutex; unsigned char *xmit_buf; unsigned int close_delay; unsigned int closing_wait; int drain_delay; struct kref kref; } ;
222 struct tty_struct { int magic; struct kref kref; struct device *dev; struct tty_driver *driver; const struct tty_operations *ops; int index; struct ld_semaphore ldisc_sem; struct tty_ldisc *ldisc; struct mutex atomic_write_lock; struct mutex legacy_mutex; struct mutex throttle_mutex; struct rw_semaphore termios_rwsem; struct mutex winsize_mutex; spinlock_t ctrl_lock; struct ktermios termios; struct ktermios termios_locked; struct termiox *termiox; char name[64U]; struct pid *pgrp; struct pid *session; unsigned long flags; int count; struct winsize winsize; unsigned char stopped; unsigned char hw_stopped; unsigned char flow_stopped; unsigned char packet; unsigned char ctrl_status; unsigned int receive_room; int flow_change; struct tty_struct *link; struct fasync_struct *fasync; int alt_speed; wait_queue_head_t write_wait; wait_queue_head_t read_wait; struct work_struct hangup_work; void *disc_data; void *driver_data; struct list_head tty_files; unsigned char closing; unsigned char *write_buf; int write_cnt; struct work_struct SAK_work; struct tty_port *port; } ;
34 typedef unsigned char uchar;
104 struct digi_t { unsigned short digi_flags; unsigned short digi_maxcps; unsigned short digi_maxchar; unsigned short digi_bufsize; unsigned char digi_onlen; unsigned char digi_offlen; char digi_onstr[28U]; char digi_offstr[28U]; char digi_term[10U]; } ;
330 struct dgnc_board ;
331 struct channel_t ;
332 struct un_t ;
57 struct board_ops { void (*tasklet)(unsigned long); irqreturn_t (*intr)(int, void *); void (*uart_init)(struct channel_t *); void (*uart_off)(struct channel_t *); int (*drain)(struct tty_struct *, uint ); void (*param)(struct tty_struct *); void (*vpd)(struct dgnc_board *); void (*assert_modem_signals)(struct channel_t *); void (*flush_uart_write)(struct channel_t *); void (*flush_uart_read)(struct channel_t *); void (*disable_receiver)(struct channel_t *); void (*enable_receiver)(struct channel_t *); void (*send_break)(struct channel_t *, int); void (*send_start_character)(struct channel_t *); void (*send_stop_character)(struct channel_t *); void (*copy_data_from_queue_to_uart)(struct channel_t *); uint (*get_uart_bytes_left)(struct channel_t *); void (*send_immediate_char)(struct channel_t *, unsigned char); } ;
275 struct dgnc_proc_entry ;
275 struct dgnc_board { int magic; int boardnum; int type; char *name; struct pci_dev *pdev; unsigned long bd_flags; u16 vendor; u16 device; u16 subvendor; u16 subdevice; uchar rev; uint pci_bus; uint pci_slot; uint maxports; uchar dvid; uchar vpd[128U]; uchar serial_num[20U]; spinlock_t bd_lock; spinlock_t bd_intr_lock; uint state; wait_queue_head_t state_wait; struct tasklet_struct helper_tasklet; uint nasync; uint irq; ulong intr_count; ulong intr_modem; ulong intr_tx; ulong intr_rx; ulong membase; ulong membase_end; u8 *re_map_membase; ulong iobase; ulong iobase_end; uint bd_uart_offset; struct channel_t *channels[8U]; struct tty_driver SerialDriver; char SerialName[200U]; struct tty_driver PrintDriver; char PrintName[200U]; uint dgnc_Major_Serial_Registered; uint dgnc_Major_TransparentPrint_Registered; uint dgnc_Serial_Major; uint dgnc_TransparentPrint_Major; uint TtyRefCnt; char *flipbuf; u16 dpatype; u16 dpastatus; char *msgbuf_head; char *msgbuf; uint bd_dividend; struct board_ops *bd_ops; struct proc_dir_entry *proc_entry_pointer; struct dgnc_proc_entry *dgnc_board_table; } ;
368 struct un_t { int magic; struct channel_t *un_ch; ulong un_time; uint un_type; uint un_open_count; struct tty_struct *un_tty; uint un_flags; wait_queue_head_t un_flags_wait; uint un_dev; struct device *un_sysfs; } ;
405 struct neo_uart_struct ;
405 struct cls_uart_struct ;
405 struct channel_t { int magic; struct dgnc_board *ch_bd; struct digi_t ch_digi; struct un_t ch_tun; struct un_t ch_pun; spinlock_t ch_lock; wait_queue_head_t ch_flags_wait; uint ch_portnum; uint ch_open_count; uint ch_flags; ulong ch_close_delay; ulong ch_cpstime; tcflag_t ch_c_iflag; tcflag_t ch_c_cflag; tcflag_t ch_c_oflag; tcflag_t ch_c_lflag; uchar ch_stopc; uchar ch_startc; uint ch_old_baud; uint ch_custom_speed; uint ch_wopen; uchar ch_mostat; uchar ch_mistat; struct neo_uart_struct *ch_neo_uart; struct cls_uart_struct *ch_cls_uart; uchar ch_cached_lsr; uchar *ch_rqueue; ushort ch_r_head; ushort ch_r_tail; uchar *ch_equeue; ushort ch_e_head; ushort ch_e_tail; uchar *ch_wqueue; ushort ch_w_head; ushort ch_w_tail; ulong ch_rxcount; ulong ch_txcount; uchar ch_r_tlevel; uchar ch_t_tlevel; uchar ch_r_watermark; ulong ch_stop_sending_break; uint ch_stops_sent; ulong ch_err_parity; ulong ch_err_frame; ulong ch_err_break; ulong ch_err_overrun; ulong ch_xon_sends; ulong ch_xoff_sends; ulong ch_intr_modem; ulong ch_intr_tx; ulong ch_intr_rx; struct proc_dir_entry *proc_entry_pointer; struct dgnc_proc_entry *dgnc_channel_table; uint ch_sniff_in; uint ch_sniff_out; char *ch_sniff_buf; ulong ch_sniff_flags; wait_queue_head_t ch_sniff_wait; } ;
562 struct cls_uart_struct { u8 txrx; u8 ier; u8 isr_fcr; u8 lcr; u8 mcr; u8 lsr; u8 msr; u8 spr; } ;
95 struct kernel_symbol { unsigned long value; const char *name; } ;
18 typedef short s16;
142 typedef void (*ctor_fn_t)();
527 struct bug_entry { int bug_addr_disp; int file_disp; unsigned short line; unsigned short flags; } ;
103 struct compat_timespec ;
104 struct __anonstruct_futex_17 { u32 *uaddr; u32 val; u32 flags; u32 bitset; u64 time; u32 *uaddr2; } ;
104 struct __anonstruct_nanosleep_18 { clockid_t clockid; struct timespec *rmtp; struct compat_timespec *compat_rmtp; u64 expires; } ;
104 struct pollfd ;
104 struct __anonstruct_poll_19 { struct pollfd *ufds; int nfds; int has_timeout; unsigned long tv_sec; unsigned long tv_nsec; } ;
104 union __anonunion_ldv_2866_16 { struct __anonstruct_futex_17 futex; struct __anonstruct_nanosleep_18 nanosleep; struct __anonstruct_poll_19 poll; } ;
104 struct restart_block { long int (*fn)(struct restart_block *); union __anonunion_ldv_2866_16 ldv_2866; } ;
26 struct exec_domain ;
26 struct map_segment ;
26 struct exec_domain { const char *name; void (*handler)(int, struct pt_regs *); unsigned char pers_low; unsigned char pers_high; unsigned long *signal_map; unsigned long *signal_invmap; struct map_segment *err_map; struct map_segment *socktype_map; struct map_segment *sockopt_map; struct map_segment *af_map; struct module *module; struct exec_domain *next; } ;
617 struct __anonstruct_mm_segment_t_29 { unsigned long seg; } ;
617 typedef struct __anonstruct_mm_segment_t_29 mm_segment_t;
131 struct thread_info { struct task_struct *task; struct exec_domain *exec_domain; __u32 flags; __u32 status; __u32 cpu; int saved_preempt_count; mm_segment_t addr_limit; struct restart_block restart_block; void *sysenter_return; unsigned char sig_on_uaccess_error; unsigned char uaccess_err; } ;
15 typedef __u64 Elf64_Addr;
16 typedef __u16 Elf64_Half;
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;
222 struct kernel_param ;
227 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 *); } ;
58 struct kparam_string ;
58 struct kparam_array ;
58 union __anonunion_ldv_15326_155 { void *arg; const struct kparam_string *str; const struct kparam_array *arr; } ;
58 struct kernel_param { const char *name; const struct kernel_param_ops *ops; u16 perm; s16 level; union __anonunion_ldv_15326_155 ldv_15326; } ;
70 struct kparam_string { unsigned int maxlen; char *string; } ;
76 struct kparam_array { unsigned int max; unsigned int elemsize; unsigned int *num; const struct kernel_param_ops *ops; void *elem; } ;
461 struct mod_arch_specific { } ;
36 struct module_param_attrs ;
36 struct module_kobject { struct kobject kobj; struct module *mod; struct kobject *drivers_dir; struct module_param_attrs *mp; struct completion *kobj_completion; } ;
46 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 *); } ;
72 struct exception_table_entry ;
205 enum module_state { MODULE_STATE_LIVE = 0, MODULE_STATE_COMING = 1, MODULE_STATE_GOING = 2, MODULE_STATE_UNFORMED = 3 } ;
212 struct module_ref { unsigned long incs; unsigned long decs; } ;
226 struct module_sect_attrs ;
226 struct module_notes_attrs ;
226 struct tracepoint ;
226 struct ftrace_event_call ;
226 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 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; 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)(); void *module_init; void *module_core; unsigned int init_size; unsigned int core_size; unsigned int init_text_size; unsigned int core_text_size; unsigned int init_ro_size; unsigned int core_ro_size; struct mod_arch_specific arch; unsigned int taints; unsigned int num_bugs; struct list_head bug_list; struct bug_entry *bug_table; Elf64_Sym *symtab; Elf64_Sym *core_symtab; unsigned int num_symtab; unsigned int core_num_syms; char *strtab; char *core_strtab; 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 ftrace_event_call **trace_events; unsigned int num_trace_events; struct list_head source_list; struct list_head target_list; void (*exit)(); struct module_ref *refptr; ctor_fn_t (**ctors)(); unsigned int num_ctors; } ;
62 struct exception_table_entry { int insn; int fixup; } ;
88 struct neo_uart_struct { u8 txrx; u8 ier; u8 isr_fcr; u8 lcr; u8 mcr; u8 lsr; u8 msr; u8 spr; u8 fctr; u8 efr; u8 tfifo; u8 rfifo; u8 xoffchar1; u8 xoffchar2; u8 xonchar1; u8 xonchar2; u8 reserved1[255U]; u8 txrxburst[64U]; u8 reserved2[63U]; u8 rxburst_with_errors[64U]; } ;
169 struct board_id { uchar *name; uint maxports; unsigned int is_pci_express; } ;
233 struct digi_dinfo { unsigned int dinfo_nboards; char dinfo_reserved[12U]; char dinfo_version[16U]; } ;
243 struct digi_info { unsigned int info_bdnum; unsigned int info_ioport; unsigned int info_physaddr; unsigned int info_physsize; unsigned int info_memsize; unsigned short info_bdtype; unsigned short info_nports; char info_bdstate; char info_reserved[7U]; } ;
30 struct ni_info { int board; int channel; int dtr; int rts; int cts; int dsr; int ri; int dcd; int curtx; int currx; unsigned short iflag; unsigned short oflag; unsigned short cflag; unsigned short lflag; unsigned int mstat; unsigned char hflow; unsigned char xmit_stopped; unsigned char recv_stopped; unsigned int baud; } ;
40 typedef __kernel_long_t __kernel_suseconds_t;
13 struct timeval { __kernel_time_t tv_sec; __kernel_suseconds_t tv_usec; } ;
428 struct semaphore { raw_spinlock_t lock; unsigned int count; struct list_head wait_list; } ;
310 struct digi_getbuffer { unsigned long tIn; unsigned long tOut; unsigned long rxbuf; unsigned long txbuf; unsigned long txdone; } ;
320 struct digi_getcounter { unsigned long norun; unsigned long noflow; unsigned long nframe; unsigned long nparity; unsigned long nbreak; unsigned long rbytes; unsigned long tbytes; } ;
260 struct driver_attribute { struct attribute attr; ssize_t (*show)(struct device_driver *, char *); ssize_t (*store)(struct device_driver *, const char *, size_t ); } ;
204 int test_and_set_bit(long nr, volatile unsigned long *addr);
139 int printk(const char *, ...);
24 void INIT_LIST_HEAD(struct list_head *list);
32 unsigned long int _raw_spin_lock_irqsave(raw_spinlock_t *);
43 void _raw_spin_unlock_irqrestore(raw_spinlock_t *, unsigned long);
290 raw_spinlock_t * spinlock_check(spinlock_t *lock);
356 void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags);
77 extern volatile unsigned long jiffies;
823 long int prepare_to_wait_event(wait_queue_head_t *, wait_queue_t *, int);
824 void finish_wait(wait_queue_head_t *, wait_queue_t *);
54 unsigned char readb(const volatile void *addr);
62 void writeb(unsigned char val, volatile void *addr);
175 void * ioremap_nocache(resource_size_t , unsigned long);
183 void * ioremap(resource_size_t offset, unsigned long size);
188 void iounmap(volatile void *);
381 void schedule();
514 void __tasklet_schedule(struct tasklet_struct *);
516 void tasklet_schedule(struct tasklet_struct *t);
10 void __const_udelay(unsigned long);
87 struct board_ops dgnc_cls_ops;
35 void dgnc_input(struct channel_t *ch);
36 void dgnc_carrier(struct channel_t *ch);
37 void dgnc_wakeup_writes(struct channel_t *ch);
38 void dgnc_check_queue_flow_control(struct channel_t *ch);
40 void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int len);
66 void cls_parse_isr(struct dgnc_board *brd, uint port);
67 void cls_clear_break(struct channel_t *ch, int force);
68 void cls_set_cts_flow_control(struct channel_t *ch);
69 void cls_set_rts_flow_control(struct channel_t *ch);
70 void cls_set_ixon_flow_control(struct channel_t *ch);
71 void cls_set_ixoff_flow_control(struct channel_t *ch);
72 void cls_set_no_output_flow_control(struct channel_t *ch);
73 void cls_set_no_input_flow_control(struct channel_t *ch);
74 void cls_parse_modem(struct channel_t *ch, uchar signals);
75 void cls_tasklet(unsigned long data);
76 void cls_vpd(struct dgnc_board *brd);
77 void cls_uart_init(struct channel_t *ch);
78 void cls_uart_off(struct channel_t *ch);
79 int cls_drain(struct tty_struct *tty, uint seconds);
80 void cls_param(struct tty_struct *tty);
81 void cls_assert_modem_signals(struct channel_t *ch);
82 void cls_flush_uart_write(struct channel_t *ch);
83 void cls_flush_uart_read(struct channel_t *ch);
84 void cls_disable_receiver(struct channel_t *ch);
85 void cls_enable_receiver(struct channel_t *ch);
86 void cls_send_break(struct channel_t *ch, int msecs);
87 void cls_send_start_character(struct channel_t *ch);
88 void cls_send_stop_character(struct channel_t *ch);
89 void cls_copy_data_from_uart_to_queue(struct channel_t *ch);
90 void cls_copy_data_from_queue_to_uart(struct channel_t *ch);
91 uint cls_get_uart_bytes_left(struct channel_t *ch);
92 void cls_send_immediate_char(struct channel_t *ch, unsigned char c);
93 irqreturn_t cls_intr(int irq, void *voidbrd);
95 struct board_ops dgnc_cls_ops = { &cls_tasklet, &cls_intr, &cls_uart_init, &cls_uart_off, &cls_drain, &cls_param, &cls_vpd, &cls_assert_modem_signals, &cls_flush_uart_write, &cls_flush_uart_read, &cls_disable_receiver, &cls_enable_receiver, &cls_send_break, &cls_send_start_character, &cls_send_stop_character, &cls_copy_data_from_queue_to_uart, &cls_get_uart_bytes_left, &cls_send_immediate_char };
1472 void ldv_check_final_state();
1481 void ldv_initialize();
1484 void ldv_handler_precall();
1487 int nondet_int();
1490 int LDV_IN_INTERRUPT = 0;
1493 void ldv_main0_sequence_infinite_withcheck_stateful();
1 long int __builtin_expect(long exp, long c);
33 extern struct module __this_module;
314 int variable_test_bit(long nr, const volatile unsigned long *addr);
11 void * ldv_create_class();
13 void ldv_unregister_class();
88 void __bad_percpu_size();
10 extern struct task_struct *current_task;
12 struct task_struct * get_current();
89 int test_ti_thread_flag(struct thread_info *ti, int flag);
93 void __raw_spin_lock_init(raw_spinlock_t *, const char *, struct lock_class_key *);
68 void __init_waitqueue_head(wait_queue_head_t *, const char *, struct lock_class_key *);
144 void __wake_up(wait_queue_head_t *, unsigned int, int, void *);
94 void init_timer_key(struct timer_list *, unsigned int, const char *, struct lock_class_key *);
240 void add_timer(struct timer_list *);
245 int del_timer_sync(struct timer_list *);
309 void outb(unsigned char value, int port);
481 void class_destroy(struct class *);
484 void ldv_class_destroy_9(struct class *ldv_func_arg1);
979 struct device * device_create(struct class *, struct device *, dev_t , void *, const char *, ...);
987 void device_destroy(struct class *, dev_t );
1042 int dev_err(const struct device *, const char *, ...);
842 int pci_bus_read_config_byte(struct pci_bus *, unsigned int, int, u8 *);
844 int pci_bus_read_config_word(struct pci_bus *, unsigned int, int, u16 *);
856 int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val);
860 int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val);
924 int pci_enable_device(struct pci_dev *);
1107 int __pci_register_driver(struct pci_driver *, struct module *, const char *);
1116 void pci_unregister_driver(struct pci_driver *);
144 void kfree(const void *);
315 void * __kmalloc(size_t , gfp_t );
445 void * kmalloc(size_t size, gfp_t flags);
637 void * kzalloc(size_t size, gfp_t flags);
377 long int schedule_timeout(long);
2662 int test_tsk_thread_flag(struct task_struct *tsk, int flag);
2688 int signal_pending(struct task_struct *p);
2140 int __register_chrdev(unsigned int, unsigned int, unsigned int, const char *, const struct file_operations *);
2143 void __unregister_chrdev(unsigned int, unsigned int, unsigned int, const char *);
2148 int register_chrdev(unsigned int major, const char *name, const struct file_operations *fops);
2154 void unregister_chrdev(unsigned int major, const char *name);
123 int request_threaded_irq(unsigned int, irqreturn_t (*)(int, void *), irqreturn_t (*)(int, void *), unsigned long, const char *, void *);
128 int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *), unsigned long flags, const char *name, void *dev);
142 void free_irq(unsigned int, void *);
570 void tasklet_kill(struct tasklet_struct *);
572 void tasklet_init(struct tasklet_struct *, void (*)(unsigned long), unsigned long);
35 void dgnc_create_ports_sysfiles(struct dgnc_board *bd);
36 void dgnc_remove_ports_sysfiles(struct dgnc_board *bd);
38 void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver___0);
39 void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver___0);
544 int dgnc_ms_sleep(ulong ms);
545 char * dgnc_ioctl_name(int cmd);
550 int dgnc_driver_state;
551 uint dgnc_Major = 0U;
552 int dgnc_debug = 0;
553 int dgnc_rawreadok = 0;
554 int dgnc_poll_tick;
555 int dgnc_trcbuf_size = 0;
556 spinlock_t dgnc_global_lock;
557 uint dgnc_NumBoards = 0U;
558 struct dgnc_board *dgnc_Board[20U] = { };
559 ulong dgnc_poll_counter = 0UL;
560 char *dgnc_state_text[3U];
561 char *dgnc_driver_state_text[2U];
27 int dgnc_mgmt_open(struct inode *inode, struct file *file);
28 int dgnc_mgmt_close(struct inode *inode, struct file *file);
29 long int dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
27 int dgnc_tty_register(struct dgnc_board *brd);
29 int dgnc_tty_preinit();
30 int dgnc_tty_init(struct dgnc_board *brd);
32 void dgnc_tty_post_uninit();
33 void dgnc_tty_uninit(struct dgnc_board *brd);
155 struct board_ops dgnc_neo_ops;
79 int debug = 0;
80 int rawreadok = 1;
81 int trcbuf_size = 1048576;
88 int dgnc_start();
89 int dgnc_finalize_board_init(struct dgnc_board *brd);
90 void dgnc_init_globals();
91 int dgnc_found_board(struct pci_dev *pdev, int id);
92 void dgnc_cleanup_board(struct dgnc_board *brd);
93 void dgnc_poll_handler(ulong dummy);
94 int dgnc_init_pci();
95 int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
96 void dgnc_remove_one(struct pci_dev *dev);
97 int dgnc_probe1(struct pci_dev *pdev, int card_type);
98 void dgnc_do_remap(struct dgnc_board *brd);
101 int dgnc_init_module();
102 void dgnc_cleanup_module();
111 const struct file_operations dgnc_BoardFops = { &__this_module, 0, 0, 0, 0, 0, 0, 0, 0, 0, &dgnc_mgmt_ioctl, 0, 0, &dgnc_mgmt_open, 0, &dgnc_mgmt_close, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
125 spinlock_t dgnc_global_lock = { { { { { 0U } }, 3735899821U, 4294967295U, (void *)-1, { 0, { 0, 0 }, "dgnc_global_lock", 0, 0UL } } } };
126 int dgnc_driver_state = 0;
129 int dgnc_poll_tick = 20;
134 uint dgnc_Major_Control_Registered = 0U;
135 uint dgnc_driver_start = 0U;
137 struct class *dgnc_class = 0;
142 spinlock_t dgnc_poll_lock = { { { { { 0U } }, 3735899821U, 4294967295U, (void *)-1, { 0, { 0, 0 }, "dgnc_poll_lock", 0, 0UL } } } };
143 ulong dgnc_poll_time = 0UL;
144 uint dgnc_poll_stop = 0U;
145 struct timer_list dgnc_poll_timer = { };
148 struct pci_device_id dgnc_pci_tbl[18U] = { { 4431U, 40U, 4294967295U, 4294967295U, 0U, 0U, 0UL }, { 4431U, 208U, 4294967295U, 4294967295U, 0U, 0U, 1UL }, { 4431U, 41U, 4294967295U, 4294967295U, 0U, 0U, 2UL }, { 4431U, 209U, 4294967295U, 4294967295U, 0U, 0U, 3UL }, { 4431U, 176U, 4294967295U, 4294967295U, 0U, 0U, 4UL }, { 4431U, 177U, 4294967295U, 4294967295U, 0U, 0U, 5UL }, { 4431U, 200U, 4294967295U, 4294967295U, 0U, 0U, 6UL }, { 4431U, 201U, 4294967295U, 4294967295U, 0U, 0U, 7UL }, { 4431U, 202U, 4294967295U, 4294967295U, 0U, 0U, 8UL }, { 4431U, 203U, 4294967295U, 4294967295U, 0U, 0U, 9UL }, { 4431U, 204U, 4294967295U, 4294967295U, 0U, 0U, 10UL }, { 4431U, 205U, 4294967295U, 4294967295U, 0U, 0U, 11UL }, { 4431U, 206U, 4294967295U, 4294967295U, 0U, 0U, 12UL }, { 4431U, 240U, 4294967295U, 4294967295U, 0U, 0U, 13UL }, { 4431U, 241U, 4294967295U, 4294967295U, 0U, 0U, 14UL }, { 4431U, 242U, 4294967295U, 4294967295U, 0U, 0U, 15UL }, { 4431U, 243U, 4294967295U, 4294967295U, 0U, 0U, 16UL }, { 0U, 0U, 0U, 0U, 0U, 0U, 0UL } };
168 const struct pci_device_id __mod_pci__dgnc_pci_tbl_device_table = { };
176 struct board_id dgnc_Ids[18U] = { { (uchar *)"ClassicBoard 4 PCI", 4U, 0U }, { (uchar *)"ClassicBoard 4 422 PCI", 4U, 0U }, { (uchar *)"ClassicBoard 8 PCI", 8U, 0U }, { (uchar *)"ClassicBoard 8 422 PCI", 8U, 0U }, { (uchar *)"Neo 4 PCI", 4U, 0U }, { (uchar *)"Neo 8 PCI", 8U, 0U }, { (uchar *)"Neo 2 - DB9 Universal PCI", 2U, 0U }, { (uchar *)"Neo 2 - DB9 Universal PCI - Powered Ring Indicator", 2U, 0U }, { (uchar *)"Neo 2 - RJ45 Universal PCI", 2U, 0U }, { (uchar *)"Neo 2 - RJ45 Universal PCI - Powered Ring Indicator", 2U, 0U }, { (uchar *)"Neo 1 422 PCI", 1U, 0U }, { (uchar *)"Neo 1 422/485 PCI", 1U, 0U }, { (uchar *)"Neo 2 422/485 PCI", 2U, 0U }, { (uchar *)"Neo 8 PCI Express", 8U, 1U }, { (uchar *)"Neo 4 PCI Express", 4U, 1U }, { (uchar *)"Neo 4 PCI Express RJ45", 4U, 1U }, { (uchar *)"Neo 8 PCI Express RJ45", 8U, 1U }, { (uchar *)0U, 0U, 0U } };
197 struct pci_driver dgnc_driver = { { 0, 0 }, "dgnc", (const struct pci_device_id *)(&dgnc_pci_tbl), &dgnc_init_one, &dgnc_remove_one, 0, 0, 0, 0, 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { { { { { { 0U } }, 0U, 0U, 0, { 0, { 0, 0 }, 0, 0, 0UL } } } }, { 0, 0 } } };
205 char *dgnc_state_text[3U] = { (char *)"Board Failed", (char *)"Board Found", (char *)"Board READY" };
211 char *dgnc_driver_state_text[2U] = { (char *)"Driver Initialized", (char *)"Driver Ready." };
975 void ldv_check_return_value(int);
978 void ldv_check_return_value_probe(int);
993 void ldv_main1_sequence_infinite_withcheck_stateful();
1 unsigned long int __builtin_object_size(void *, int);
230 void might_fault();
388 int sprintf(char *, const char *, ...);
55 void * memset(void *, int, size_t );
645 unsigned long int _copy_from_user(void *, const void *, unsigned int);
647 unsigned long int _copy_to_user(void *, const void *, unsigned int);
667 void __copy_from_user_overflow();
672 void __copy_to_user_overflow();
688 unsigned long int copy_from_user(void *to, const void *from, unsigned long n);
723 unsigned long int copy_to_user(void *to, const void *from, unsigned long n);
704 unsigned int iminor(const struct inode *inode);
74 int dgnc_mgmt_in_use[8U] = { };
1 void * __builtin_memcpy(void *, const void *, unsigned long);
23 char * strncpy(char *, const char *, __kernel_size_t );
56 unsigned int readl(const volatile void *addr);
210 void memcpy_fromio(void *dst, const volatile void *src, size_t count);
216 void memcpy_toio(volatile void *dst, const void *src, size_t count);
66 void neo_parse_lsr(struct dgnc_board *brd, uint port);
67 void neo_parse_isr(struct dgnc_board *brd, uint port);
68 void neo_copy_data_from_uart_to_queue(struct channel_t *ch);
69 void neo_clear_break(struct channel_t *ch, int force);
70 void neo_set_cts_flow_control(struct channel_t *ch);
71 void neo_set_rts_flow_control(struct channel_t *ch);
72 void neo_set_ixon_flow_control(struct channel_t *ch);
73 void neo_set_ixoff_flow_control(struct channel_t *ch);
74 void neo_set_no_output_flow_control(struct channel_t *ch);
75 void neo_set_no_input_flow_control(struct channel_t *ch);
76 void neo_set_new_start_stop_chars(struct channel_t *ch);
77 void neo_parse_modem(struct channel_t *ch, uchar signals);
78 void neo_tasklet(unsigned long data);
79 void neo_vpd(struct dgnc_board *brd);
80 void neo_uart_init(struct channel_t *ch);
81 void neo_uart_off(struct channel_t *ch);
82 int neo_drain(struct tty_struct *tty, uint seconds);
83 void neo_param(struct tty_struct *tty);
84 void neo_assert_modem_signals(struct channel_t *ch);
85 void neo_flush_uart_write(struct channel_t *ch);
86 void neo_flush_uart_read(struct channel_t *ch);
87 void neo_disable_receiver(struct channel_t *ch);
88 void neo_enable_receiver(struct channel_t *ch);
89 void neo_send_break(struct channel_t *ch, int msecs);
90 void neo_send_start_character(struct channel_t *ch);
91 void neo_send_stop_character(struct channel_t *ch);
92 void neo_copy_data_from_queue_to_uart(struct channel_t *ch);
93 uint neo_get_uart_bytes_left(struct channel_t *ch);
94 void neo_send_immediate_char(struct channel_t *ch, unsigned char c);
95 irqreturn_t neo_intr(int irq, void *voidbrd);
98 struct board_ops dgnc_neo_ops = { &neo_tasklet, &neo_intr, &neo_uart_init, &neo_uart_off, &neo_drain, &neo_param, &neo_vpd, &neo_assert_modem_signals, &neo_flush_uart_write, &neo_flush_uart_read, &neo_disable_receiver, &neo_enable_receiver, &neo_send_break, &neo_send_start_character, &neo_send_stop_character, &neo_copy_data_from_queue_to_uart, &neo_get_uart_bytes_left, &neo_send_immediate_char };
119 uint dgnc_offset_table[8U] = { 1U, 2U, 4U, 8U, 16U, 32U, 64U, 128U };
130 void neo_pci_posting_flush(struct dgnc_board *bd);
1892 unsigned int neo_read_eeprom(unsigned char *base, unsigned int address);
2001 void ldv_main3_sequence_infinite_withcheck_stateful();
79 void vfree(const void *);
41 void dgnc_tracer_free();
62 char *dgnc_trcbuf = 0;
391 int snprintf(char *, size_t , const char *, ...);
186 int list_empty(const struct list_head *head);
12 struct task_struct * get_current___0();
34 void * __memcpy(void *, const void *, size_t );
61 size_t strlen(const char *);
37 void atomic_set(atomic_t *v, int i);
156 void do_gettimeofday(struct timeval *);
101 int waitqueue_active(wait_queue_head_t *q);
32 void kref_init(struct kref *kref);
40 int down_interruptible(struct semaphore *);
44 void up(struct semaphore *);
329 void tty_set_operations(struct tty_driver *, const struct tty_operations *);
50 unsigned char * char_buf_ptr(struct tty_buffer *b, int ofs);
55 char * flag_buf_ptr(struct tty_buffer *b, int ofs);
344 dev_t tty_devnum(struct tty_struct *);
399 int tty_check_change(struct tty_struct *);
402 int tty_register_driver(struct tty_driver *);
403 int tty_unregister_driver(struct tty_driver *);
404 struct device * tty_register_device(struct tty_driver *, unsigned int, struct device *);
410 void tty_unregister_device(struct tty_driver *, unsigned int);
429 void tty_hangup(struct tty_struct *);
432 int tty_hung_up_p(struct file *);
466 struct tty_ldisc * tty_ldisc_ref(struct tty_struct *);
467 void tty_ldisc_deref(struct tty_ldisc *);
473 void tty_ldisc_flush(struct tty_struct *);
6 int tty_buffer_request_room(struct tty_port *, size_t );
7 int tty_insert_flip_string_flags(struct tty_port *, const unsigned char *, const char *, size_t );
9 int tty_insert_flip_string_fixed_flag(struct tty_port *, const unsigned char *, char, size_t );
13 void tty_flip_buffer_push(struct tty_port *);
16 int tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag);
32 int tty_insert_flip_string(struct tty_port *port, const unsigned char *chars, size_t size);
44 void dgnc_create_tty_sysfs(struct un_t *un, struct device *c);
45 void dgnc_remove_tty_sysfs(struct device *c);
89 struct dgnc_board *dgnc_BoardsByMajor[256U] = { };
90 uchar *dgnc_TmpWriteBuf = (uchar *)0U;
91 struct semaphore dgnc_TmpWriteSem = { { { { 0U } }, 3735899821U, 4294967295U, (void *)-1, { 0, { 0, 0 }, "(dgnc_TmpWriteSem).lock", 0, 0UL } }, 1U, { &(dgnc_TmpWriteSem.wait_list), &(dgnc_TmpWriteSem.wait_list) } };
96 struct digi_t dgnc_digi_init = { 128U, 100U, 50U, 100U, 4U, 4U, { '\x1b', '[', '5', 'i', '\x0' }, { '\x1b', '[', '4', 'i', '\x0' }, { 'a', 'n', 's', 'i', '\x0' } };
116 struct ktermios DgncDefaultTermios = { 1280U, 5U, 3261U, 35387U, 0U, { '\x3', '\x1c', '', '\x15', '\x4', '\x0' }, 0U, 0U };
128 int dgnc_tty_open(struct tty_struct *tty, struct file *file);
129 void dgnc_tty_close(struct tty_struct *tty, struct file *file);
130 int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch);
131 int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
132 int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t *retinfo);
133 int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t *new_info);
134 int dgnc_tty_write_room(struct tty_struct *tty);
135 int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c);
136 int dgnc_tty_chars_in_buffer(struct tty_struct *tty);
137 void dgnc_tty_start(struct tty_struct *tty);
138 void dgnc_tty_stop(struct tty_struct *tty);
139 void dgnc_tty_throttle(struct tty_struct *tty);
140 void dgnc_tty_unthrottle(struct tty_struct *tty);
141 void dgnc_tty_flush_chars(struct tty_struct *tty);
142 void dgnc_tty_flush_buffer(struct tty_struct *tty);
143 void dgnc_tty_hangup(struct tty_struct *tty);
144 int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int *value);
145 int dgnc_get_modem_info(struct channel_t *ch, unsigned int *value);
146 int dgnc_tty_tiocmget(struct tty_struct *tty);
147 int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear);
148 int dgnc_tty_send_break(struct tty_struct *tty, int msec);
149 void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout);
150 int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count);
151 void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios);
152 void dgnc_tty_send_xchar(struct tty_struct *tty, char c);
155 const struct tty_operations dgnc_tty_ops = { 0, 0, 0, &dgnc_tty_open, &dgnc_tty_close, 0, 0, &dgnc_tty_write, &dgnc_tty_put_char, &dgnc_tty_flush_chars, &dgnc_tty_write_room, &dgnc_tty_chars_in_buffer, &dgnc_tty_ioctl, 0, &dgnc_tty_set_termios, &dgnc_tty_throttle, &dgnc_tty_unthrottle, &dgnc_tty_stop, &dgnc_tty_start, &dgnc_tty_hangup, &dgnc_tty_send_break, &dgnc_tty_flush_buffer, 0, &dgnc_tty_wait_until_sent, &dgnc_tty_send_xchar, &dgnc_tty_tiocmget, &dgnc_tty_tiocmset, 0, 0, 0, 0, 0, 0, 0 };
614 void dgnc_wmove(struct channel_t *ch, char *buf, uint n);
974 void dgnc_set_custom_speed(struct channel_t *ch, uint newrate);
1838 int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available);
2428 int dgnc_get_mstat(struct channel_t *ch);
3505 void ldv_main5_sequence_infinite_withcheck_stateful();
403 int sscanf(const char *, const char *, ...);
221 int sysfs_create_group(struct kobject *, const struct attribute_group *);
227 void sysfs_remove_group(struct kobject *, const struct attribute_group *);
280 int driver_create_file(struct device_driver *, const struct driver_attribute *);
282 void driver_remove_file(struct device_driver *, const struct driver_attribute *);
559 int device_create_file(struct device *, const struct device_attribute *);
561 void device_remove_file(struct device *, const struct device_attribute *);
837 void * dev_get_drvdata(const struct device *dev);
842 void dev_set_drvdata(struct device *dev, void *data);
66 ssize_t dgnc_driver_version_show(struct device_driver *ddp, char *buf);
70 struct driver_attribute driver_attr_version = { { "version", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_driver_version_show, (ssize_t (*)(struct device_driver *, const char *, size_t ))0 };
73 ssize_t dgnc_driver_boards_show(struct device_driver *ddp, char *buf);
77 struct driver_attribute driver_attr_boards = { { "boards", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_driver_boards_show, (ssize_t (*)(struct device_driver *, const char *, size_t ))0 };
80 ssize_t dgnc_driver_maxboards_show(struct device_driver *ddp, char *buf);
84 struct driver_attribute driver_attr_maxboards = { { "maxboards", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_driver_maxboards_show, (ssize_t (*)(struct device_driver *, const char *, size_t ))0 };
87 ssize_t dgnc_driver_pollcounter_show(struct device_driver *ddp, char *buf);
91 struct driver_attribute driver_attr_pollcounter = { { "pollcounter", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_driver_pollcounter_show, (ssize_t (*)(struct device_driver *, const char *, size_t ))0 };
94 ssize_t dgnc_driver_state_show(struct device_driver *ddp, char *buf);
98 struct driver_attribute driver_attr_state = { { "state", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_driver_state_show, (ssize_t (*)(struct device_driver *, const char *, size_t ))0 };
101 ssize_t dgnc_driver_debug_show(struct device_driver *ddp, char *buf);
106 ssize_t dgnc_driver_debug_store(struct device_driver *ddp, const char *buf, size_t count);
111 struct driver_attribute driver_attr_debug = { { "debug", 384U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_driver_debug_show, &dgnc_driver_debug_store };
114 ssize_t dgnc_driver_rawreadok_show(struct device_driver *ddp, char *buf);
119 ssize_t dgnc_driver_rawreadok_store(struct device_driver *ddp, const char *buf, size_t count);
124 struct driver_attribute driver_attr_rawreadok = { { "rawreadok", 384U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_driver_rawreadok_show, &dgnc_driver_rawreadok_store };
127 ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf);
132 ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count);
137 struct driver_attribute driver_attr_pollrate = { { "pollrate", 384U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_driver_pollrate_show, &dgnc_driver_pollrate_store };
185 ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, char *buf);
203 struct device_attribute dev_attr_vpd = { { "vpd", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_vpd_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
205 ssize_t dgnc_serial_number_show(struct device *p, struct device_attribute *attr, char *buf);
219 struct device_attribute dev_attr_serial_number = { { "serial_number", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_serial_number_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
222 ssize_t dgnc_ports_state_show(struct device *p, struct device_attribute *attr, char *buf);
237 struct device_attribute dev_attr_ports_state = { { "ports_state", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_ports_state_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
240 ssize_t dgnc_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf);
254 struct device_attribute dev_attr_ports_baud = { { "ports_baud", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_ports_baud_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
257 ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf);
282 struct device_attribute dev_attr_ports_msignals = { { "ports_msignals", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_ports_msignals_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
285 ssize_t dgnc_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf);
299 struct device_attribute dev_attr_ports_iflag = { { "ports_iflag", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_ports_iflag_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
302 ssize_t dgnc_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf);
316 struct device_attribute dev_attr_ports_cflag = { { "ports_cflag", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_ports_cflag_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
319 ssize_t dgnc_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf);
333 struct device_attribute dev_attr_ports_oflag = { { "ports_oflag", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_ports_oflag_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
336 ssize_t dgnc_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf);
350 struct device_attribute dev_attr_ports_lflag = { { "ports_lflag", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_ports_lflag_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
353 ssize_t dgnc_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf);
367 struct device_attribute dev_attr_ports_digi_flag = { { "ports_digi_flag", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_ports_digi_flag_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
370 ssize_t dgnc_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf);
384 struct device_attribute dev_attr_ports_rxcount = { { "ports_rxcount", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_ports_rxcount_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
387 ssize_t dgnc_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf);
401 struct device_attribute dev_attr_ports_txcount = { { "ports_txcount", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_ports_txcount_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
448 ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *attr, char *buf);
470 struct device_attribute dev_attr_state = { { "state", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_state_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
473 ssize_t dgnc_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf);
495 struct device_attribute dev_attr_baud = { { "baud", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_baud_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
498 ssize_t dgnc_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf);
529 struct device_attribute dev_attr_msignals = { { "msignals", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_msignals_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
532 ssize_t dgnc_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf);
554 struct device_attribute dev_attr_iflag = { { "iflag", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_iflag_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
557 ssize_t dgnc_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf);
579 struct device_attribute dev_attr_cflag = { { "cflag", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_cflag_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
582 ssize_t dgnc_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf);
604 struct device_attribute dev_attr_oflag = { { "oflag", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_oflag_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
607 ssize_t dgnc_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf);
629 struct device_attribute dev_attr_lflag = { { "lflag", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_lflag_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
632 ssize_t dgnc_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf);
654 struct device_attribute dev_attr_digi_flag = { { "digi_flag", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_digi_flag_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
657 ssize_t dgnc_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf);
679 struct device_attribute dev_attr_rxcount = { { "rxcount", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_rxcount_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
682 ssize_t dgnc_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf);
704 struct device_attribute dev_attr_txcount = { { "txcount", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_txcount_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
707 ssize_t dgnc_tty_name_show(struct device *d, struct device_attribute *attr, char *buf);
731 struct device_attribute dev_attr_custom_name = { { "custom_name", 256U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &dgnc_tty_name_show, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 };
734 struct attribute *dgnc_sysfs_tty_entries[12U] = { &(dev_attr_state.attr), &(dev_attr_baud.attr), &(dev_attr_msignals.attr), &(dev_attr_iflag.attr), &(dev_attr_cflag.attr), &(dev_attr_oflag.attr), &(dev_attr_lflag.attr), &(dev_attr_digi_flag.attr), &(dev_attr_rxcount.attr), &(dev_attr_txcount.attr), &(dev_attr_custom_name.attr), (struct attribute *)0 };
750 struct attribute_group dgnc_tty_attribute_group = { (const char *)0, 0, (struct attribute **)(&dgnc_sysfs_tty_entries), 0 };
815 void ldv_main6_sequence_infinite_withcheck_stateful();
10 void ldv_error();
20 void ldv_stop();
25 int ldv_undef_int();
26 void * ldv_undef_ptr();
38 int ldv_undef_int_nonpositive();
59 void __builtin_trap();
7 bool ldv_is_err(const void *ptr);
14 void * ldv_err_ptr(long error);
21 long int ldv_ptr_err(const void *ptr);
28 bool ldv_is_err_or_null(const void *ptr);
28 int ldv_usb_gadget_class = 0;
31 int ldv_usb_gadget_chrdev = 0;
34 int ldv_usb_gadget = 0;
61 int ldv_register_class();
95 int ldv_register_chrdev_region();
118 void ldv_unregister_chrdev_region();
129 int ldv_register_usb_gadget();
150 void ldv_unregister_usb_gadget();
return ;
}
-entry_point
{
995 struct pci_dev *var_group1;
996 const struct pci_device_id *var_dgnc_init_one_3_p1;
997 int res_dgnc_init_one_3;
998 int ldv_s_dgnc_driver_pci_driver;
999 int tmp;
1000 int tmp___0;
1001 int tmp___1;
1047 ldv_s_dgnc_driver_pci_driver = 0;
1025 LDV_IN_INTERRUPT = 1;
1034 ldv_initialize() { /* Function call is skipped due to function is undefined */}
1040 ldv_handler_precall() { /* Function call is skipped due to function is undefined */}
1041 -dgnc_init_module()
{
232 int rc;
232 rc = 0;
234 printk("dgnc: ") { /* Function call is skipped due to function is undefined */}
234 printk("%s, Digi International Part Number %s\n", (char *)"dgnc-1.3-16", (char *)"40002369_F") { /* Function call is skipped due to function is undefined */}
239 -dgnc_start()
{
274 int rc;
275 unsigned long flags;
276 void *tmp;
277 raw_spinlock_t *tmp___0;
278 struct lock_class_key __key;
274 rc = 0;
277 assume(dgnc_driver_start == 0U);
279 dgnc_driver_start = 1U;
282 -dgnc_init_globals()
{
869 int i;
870 struct lock_class_key __key;
869 i = 0;
871 dgnc_rawreadok = rawreadok;
872 dgnc_trcbuf_size = trcbuf_size;
873 dgnc_debug = debug;
875 i = 0;
875 goto ldv_32484;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(i <= 19);
877 goto ldv_32483;
876 ldv_32483:;
876 dgnc_Board[i] = (struct dgnc_board *)0;
875 i = i + 1;
876 ldv_32484:;
875 assume(!(i <= 19));
878 init_timer_key(&dgnc_poll_timer, 0U, "(&dgnc_poll_timer)", &__key) { /* Function call is skipped due to function is undefined */}
880 return ;;
}
284 dgnc_NumBoards = 0U;
286 printk("dgnc: ") { /* Function call is skipped due to function is undefined */}
286 printk("For the tools package or updated drivers please visit http://www.digi.com\n") { /* Function call is skipped due to function is undefined */}
293 assume(dgnc_Major_Control_Registered == 0U);
297 -register_chrdev(0U, "dgnc", &dgnc_BoardFops)
{
2150 int tmp;
2151 tmp = __register_chrdev(major, 0U, 256U, name, fops) { /* Function call is skipped due to function is undefined */}
2151 return tmp;;
}
298 assume(!(rc <= 0));
303 dgnc_Major = (uint )rc;
305 -ldv_create_class()
{
40 void *is_got;
43 is_got = ldv_undef_ptr() { /* Function call is skipped due to function is undefined */}
46 assume(!(((unsigned long)is_got) <= 2012UL));
57 return is_got;;
}
305 dgnc_class = (struct class *)tmp;
306 device_create(dgnc_class, (struct device *)0, dgnc_Major << 20, (void *)0, "dgnc_mgmt") { /* Function call is skipped due to function is undefined */}
309 dgnc_Major_Control_Registered = 1U;
315 -dgnc_tty_preinit()
{
191 void *tmp;
201 -kmalloc(4100UL, 208U)
{
447 void *tmp___2;
462 tmp___2 = __kmalloc(size, flags) { /* Function call is skipped due to function is undefined */}
462 return tmp___2;;
}
201 dgnc_TmpWriteBuf = (uchar *)tmp;
203 assume(!(((unsigned long)dgnc_TmpWriteBuf) == 0UL));
208 return 0;;
}
317 assume(!(rc < 0));
323 -spinlock_check(&dgnc_poll_lock)
{
292 return &(lock->ldv_6489.rlock);;
}
323 flags = _raw_spin_lock_irqsave(tmp___0) { /* Function call is skipped due to function is undefined */}
324 init_timer_key(&dgnc_poll_timer, 0U, "(&dgnc_poll_timer)", &__key) { /* Function call is skipped due to function is undefined */}
325 dgnc_poll_timer.function = &dgnc_poll_handler;
326 dgnc_poll_timer.data = 0UL;
327 dgnc_poll_time = ((unsigned long)((dgnc_poll_tick * 250) / 1000)) + ((unsigned long)jiffies);
328 dgnc_poll_timer.expires = dgnc_poll_time;
329 -spin_unlock_irqrestore(&dgnc_poll_lock, flags)
{
358 _raw_spin_unlock_irqrestore(&(lock->ldv_6489.rlock), flags) { /* Function call is skipped due to function is undefined */}
359 return ;;
}
331 add_timer(&dgnc_poll_timer) { /* Function call is skipped due to function is undefined */}
333 dgnc_driver_state = 1;
336 return rc;;
}
241 assume(!(rc < 0));
247 -dgnc_init_pci()
{
344 int tmp;
344 tmp = __pci_register_driver(&dgnc_driver, &__this_module, "dgnc") { /* Function call is skipped due to function is undefined */}
344 return tmp;;
}
252 assume(rc < 0);
254 assume(!(dgnc_NumBoards != 0U));
257 printk("\fWARNING: dgnc driver load failed. No Digi Neo or Classic boards found.\n") { /* Function call is skipped due to function is undefined */}
259 -dgnc_cleanup_module()
{
386 int i;
387 ulong lock_flags;
388 raw_spinlock_t *tmp;
389 -spinlock_check(&dgnc_poll_lock)
{
292 return &(lock->ldv_6489.rlock);;
}
389 lock_flags = _raw_spin_lock_irqsave(tmp) { /* Function call is skipped due to function is undefined */}
390 dgnc_poll_stop = 1U;
391 -spin_unlock_irqrestore(&dgnc_poll_lock, lock_flags)
{
358 _raw_spin_unlock_irqrestore(&(lock->ldv_6489.rlock), flags) { /* Function call is skipped due to function is undefined */}
359 return ;;
}
394 del_timer_sync(&dgnc_poll_timer) { /* Function call is skipped due to function is undefined */}
396 -dgnc_remove_driver_sysfiles(&dgnc_driver)
{
161 struct device_driver *driverfs;
161 driverfs = &(dgnc_driver___0->driver);
162 driver_remove_file(driverfs, (const struct driver_attribute *)(&driver_attr_version)) { /* Function call is skipped due to function is undefined */}
163 driver_remove_file(driverfs, (const struct driver_attribute *)(&driver_attr_boards)) { /* Function call is skipped due to function is undefined */}
164 driver_remove_file(driverfs, (const struct driver_attribute *)(&driver_attr_maxboards)) { /* Function call is skipped due to function is undefined */}
165 driver_remove_file(driverfs, (const struct driver_attribute *)(&driver_attr_debug)) { /* Function call is skipped due to function is undefined */}
166 driver_remove_file(driverfs, (const struct driver_attribute *)(&driver_attr_rawreadok)) { /* Function call is skipped due to function is undefined */}
167 driver_remove_file(driverfs, (const struct driver_attribute *)(&driver_attr_pollrate)) { /* Function call is skipped due to function is undefined */}
168 driver_remove_file(driverfs, (const struct driver_attribute *)(&driver_attr_pollcounter)) { /* Function call is skipped due to function is undefined */}
169 driver_remove_file(driverfs, (const struct driver_attribute *)(&driver_attr_state)) { /* Function call is skipped due to function is undefined */}
170 return ;;
}
398 assume(dgnc_Major_Control_Registered != 0U);
399 device_destroy(dgnc_class, dgnc_Major << 20) { /* Function call is skipped due to function is undefined */}
400 -ldv_class_destroy_9(dgnc_class)
{
1151 class_destroy(ldv_func_arg1) { /* Function call is skipped due to function is undefined */}
1153 -ldv_unregister_class()
{
87 assume(ldv_usb_gadget == 0);
89 assume(!(ldv_usb_gadget_class == 1));
89 -ldv_error()
{
15 LDV_ERROR:;
12 goto LDV_ERROR;
}
}
}
}
}
}
Source code
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 9 // Provide model function prototypes before their usage. 10 11 void *ldv_create_class(void); 12 int ldv_register_class(void); 13 void ldv_unregister_class(void); 14 15 int ldv_register_chrdev_region(void); 16 void ldv_unregister_chrdev_region(void); 17 18 int ldv_register_usb_gadget(void); 19 void ldv_unregister_usb_gadget(void); 20 21 /* 22 * Copyright 2003 Digi International (www.digi.com) 23 * Scott H Kilau <Scott_Kilau at digi dot com> 24 * 25 * This program is free software; you can redistribute it and/or modify 26 * it under the terms of the GNU General Public License as published by 27 * the Free Software Foundation; either version 2, or (at your option) 28 * any later version. 29 * 30 * This program is distributed in the hope that it will be useful, 31 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the 32 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 33 * PURPOSE. See the GNU General Public License for more details. 34 * 35 * You should have received a copy of the GNU General Public License 36 * along with this program; if not, write to the Free Software 37 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 38 * 39 * 40 * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! 41 * 42 * This is shared code between Digi's CVS archive and the 43 * Linux Kernel sources. 44 * Changing the source just for reformatting needlessly breaks 45 * our CVS diff history. 46 * 47 * Send any bug fixes/changes to: Eng.Linux at digi dot com. 48 * Thank you. 49 * 50 */ 51 52 53 #include <linux/kernel.h> 54 #include <linux/module.h> 55 #include <linux/pci.h> 56 #include <linux/slab.h> 57 #include <linux/sched.h> 58 #include "dgnc_driver.h" 59 #include "dgnc_pci.h" 60 #include "dpacompat.h" 61 #include "dgnc_mgmt.h" 62 #include "dgnc_tty.h" 63 #include "dgnc_trace.h" 64 #include "dgnc_cls.h" 65 #include "dgnc_neo.h" 66 #include "dgnc_sysfs.h" 67 68 MODULE_LICENSE("GPL"); 69 MODULE_AUTHOR("Digi International, http://www.digi.com"); 70 MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI based product line"); 71 MODULE_SUPPORTED_DEVICE("dgnc"); 72 73 /* 74 * insmod command line overrideable parameters 75 * 76 * NOTE: we use a set of macros to create the variables, which allows 77 * us to specify the variable type, name, initial value, and description. 78 */ 79 PARM_INT(debug, 0x00, 0644, "Driver debugging level"); 80 PARM_INT(rawreadok, 1, 0644, "Bypass flip buffers on input"); 81 PARM_INT(trcbuf_size, 0x100000, 0644, "Debugging trace buffer size."); 82 83 /************************************************************************** 84 * 85 * protos for this file 86 * 87 */ 88 static int dgnc_start(void); 89 static int dgnc_finalize_board_init(struct dgnc_board *brd); 90 static void dgnc_init_globals(void); 91 static int dgnc_found_board(struct pci_dev *pdev, int id); 92 static void dgnc_cleanup_board(struct dgnc_board *brd); 93 static void dgnc_poll_handler(ulong dummy); 94 static int dgnc_init_pci(void); 95 static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 96 static void dgnc_remove_one(struct pci_dev *dev); 97 static int dgnc_probe1(struct pci_dev *pdev, int card_type); 98 static void dgnc_do_remap(struct dgnc_board *brd); 99 100 /* Driver load/unload functions */ 101 int dgnc_init_module(void); 102 void dgnc_cleanup_module(void); 103 104 module_init(dgnc_init_module); 105 module_exit(dgnc_cleanup_module); 106 107 108 /* 109 * File operations permitted on Control/Management major. 110 */ 111 static const struct file_operations dgnc_BoardFops = 112 { 113 .owner = THIS_MODULE, 114 .unlocked_ioctl = dgnc_mgmt_ioctl, 115 .open = dgnc_mgmt_open, 116 .release = dgnc_mgmt_close 117 }; 118 119 120 /* 121 * Globals 122 */ 123 uint dgnc_NumBoards; 124 struct dgnc_board *dgnc_Board[MAXBOARDS]; 125 DEFINE_SPINLOCK(dgnc_global_lock); 126 int dgnc_driver_state = DRIVER_INITIALIZED; 127 ulong dgnc_poll_counter; 128 uint dgnc_Major; 129 int dgnc_poll_tick = 20; /* Poll interval - 20 ms */ 130 131 /* 132 * Static vars. 133 */ 134 static uint dgnc_Major_Control_Registered = FALSE; 135 static uint dgnc_driver_start = FALSE; 136 137 static struct class *dgnc_class; 138 139 /* 140 * Poller stuff 141 */ 142 static DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */ 143 static ulong dgnc_poll_time; /* Time of next poll */ 144 static uint dgnc_poll_stop; /* Used to tell poller to stop */ 145 static struct timer_list dgnc_poll_timer; 146 147 148 static struct pci_device_id dgnc_pci_tbl[] = { 149 { DIGI_VID, PCI_DEVICE_CLASSIC_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 150 { DIGI_VID, PCI_DEVICE_CLASSIC_4_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 151 { DIGI_VID, PCI_DEVICE_CLASSIC_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, 152 { DIGI_VID, PCI_DEVICE_CLASSIC_8_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 }, 153 { DIGI_VID, PCI_DEVICE_NEO_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, 154 { DIGI_VID, PCI_DEVICE_NEO_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 }, 155 { DIGI_VID, PCI_DEVICE_NEO_2DB9_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 }, 156 { DIGI_VID, PCI_DEVICE_NEO_2DB9PRI_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 }, 157 { DIGI_VID, PCI_DEVICE_NEO_2RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 }, 158 { DIGI_VID, PCI_DEVICE_NEO_2RJ45PRI_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 }, 159 { DIGI_VID, PCI_DEVICE_NEO_1_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 }, 160 { DIGI_VID, PCI_DEVICE_NEO_1_422_485_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 }, 161 { DIGI_VID, PCI_DEVICE_NEO_2_422_485_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 }, 162 { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 }, 163 { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 }, 164 { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_4RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 }, 165 { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_8RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 }, 166 {0,} /* 0 terminated list. */ 167 }; 168 MODULE_DEVICE_TABLE(pci, dgnc_pci_tbl); 169 170 struct board_id { 171 uchar *name; 172 uint maxports; 173 unsigned int is_pci_express; 174 }; 175 176 static struct board_id dgnc_Ids[] = { 177 { PCI_DEVICE_CLASSIC_4_PCI_NAME, 4, 0 }, 178 { PCI_DEVICE_CLASSIC_4_422_PCI_NAME, 4, 0 }, 179 { PCI_DEVICE_CLASSIC_8_PCI_NAME, 8, 0 }, 180 { PCI_DEVICE_CLASSIC_8_422_PCI_NAME, 8, 0 }, 181 { PCI_DEVICE_NEO_4_PCI_NAME, 4, 0 }, 182 { PCI_DEVICE_NEO_8_PCI_NAME, 8, 0 }, 183 { PCI_DEVICE_NEO_2DB9_PCI_NAME, 2, 0 }, 184 { PCI_DEVICE_NEO_2DB9PRI_PCI_NAME, 2, 0 }, 185 { PCI_DEVICE_NEO_2RJ45_PCI_NAME, 2, 0 }, 186 { PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME, 2, 0 }, 187 { PCI_DEVICE_NEO_1_422_PCI_NAME, 1, 0 }, 188 { PCI_DEVICE_NEO_1_422_485_PCI_NAME, 1, 0 }, 189 { PCI_DEVICE_NEO_2_422_485_PCI_NAME, 2, 0 }, 190 { PCI_DEVICE_NEO_EXPRESS_8_PCI_NAME, 8, 1 }, 191 { PCI_DEVICE_NEO_EXPRESS_4_PCI_NAME, 4, 1 }, 192 { PCI_DEVICE_NEO_EXPRESS_4RJ45_PCI_NAME, 4, 1 }, 193 { PCI_DEVICE_NEO_EXPRESS_8RJ45_PCI_NAME, 8, 1 }, 194 { NULL, 0, 0 } 195 }; 196 197 static struct pci_driver dgnc_driver = { 198 .name = "dgnc", 199 .probe = dgnc_init_one, 200 .id_table = dgnc_pci_tbl, 201 .remove = dgnc_remove_one, 202 }; 203 204 205 char *dgnc_state_text[] = { 206 "Board Failed", 207 "Board Found", 208 "Board READY", 209 }; 210 211 char *dgnc_driver_state_text[] = { 212 "Driver Initialized", 213 "Driver Ready." 214 }; 215 216 217 218 /************************************************************************ 219 * 220 * Driver load/unload functions 221 * 222 ************************************************************************/ 223 224 225 /* 226 * init_module() 227 * 228 * Module load. This is where it all starts. 229 */ 230 int dgnc_init_module(void) 231 { 232 int rc = 0; 233 234 APR(("%s, Digi International Part Number %s\n", DG_NAME, DG_PART)); 235 236 /* 237 * Initialize global stuff 238 */ 239 rc = dgnc_start(); 240 241 if (rc < 0) 242 return rc; 243 244 /* 245 * Find and configure all the cards 246 */ 247 rc = dgnc_init_pci(); 248 249 /* 250 * If something went wrong in the scan, bail out of driver. 251 */ 252 if (rc < 0) { 253 /* Only unregister the pci driver if it was actually registered. */ 254 if (dgnc_NumBoards) 255 pci_unregister_driver(&dgnc_driver); 256 else 257 pr_warn("WARNING: dgnc driver load failed. No Digi Neo or Classic boards found.\n"); 258 259 dgnc_cleanup_module(); 260 } else { 261 dgnc_create_driver_sysfiles(&dgnc_driver); 262 } 263 264 DPR_INIT(("Finished init_module. Returning %d\n", rc)); 265 return rc; 266 } 267 268 269 /* 270 * Start of driver. 271 */ 272 static int dgnc_start(void) 273 { 274 int rc = 0; 275 unsigned long flags; 276 277 if (dgnc_driver_start == FALSE) { 278 279 dgnc_driver_start = TRUE; 280 281 /* make sure that the globals are init'd before we do anything else */ 282 dgnc_init_globals(); 283 284 dgnc_NumBoards = 0; 285 286 APR(("For the tools package or updated drivers please visit http://www.digi.com\n")); 287 288 /* 289 * Register our base character device into the kernel. 290 * This allows the download daemon to connect to the downld device 291 * before any of the boards are init'ed. 292 */ 293 if (!dgnc_Major_Control_Registered) { 294 /* 295 * Register management/dpa devices 296 */ 297 rc = register_chrdev(0, "dgnc", &dgnc_BoardFops); 298 if (rc <= 0) { 299 APR(("Can't register dgnc driver device (%d)\n", rc)); 300 rc = -ENXIO; 301 return rc; 302 } 303 dgnc_Major = rc; 304 305 dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt"); 306 device_create(dgnc_class, NULL, 307 MKDEV(dgnc_Major, 0), 308 NULL, "dgnc_mgmt"); 309 dgnc_Major_Control_Registered = TRUE; 310 } 311 312 /* 313 * Init any global tty stuff. 314 */ 315 rc = dgnc_tty_preinit(); 316 317 if (rc < 0) { 318 APR(("tty preinit - not enough memory (%d)\n", rc)); 319 return rc; 320 } 321 322 /* Start the poller */ 323 DGNC_LOCK(dgnc_poll_lock, flags); 324 init_timer(&dgnc_poll_timer); 325 dgnc_poll_timer.function = dgnc_poll_handler; 326 dgnc_poll_timer.data = 0; 327 dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick); 328 dgnc_poll_timer.expires = dgnc_poll_time; 329 DGNC_UNLOCK(dgnc_poll_lock, flags); 330 331 add_timer(&dgnc_poll_timer); 332 333 dgnc_driver_state = DRIVER_READY; 334 } 335 336 return rc; 337 } 338 339 /* 340 * Register pci driver, and return how many boards we have. 341 */ 342 static int dgnc_init_pci(void) 343 { 344 return pci_register_driver(&dgnc_driver); 345 } 346 347 348 /* returns count (>= 0), or negative on error */ 349 static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 350 { 351 int rc; 352 353 /* wake up and enable device */ 354 rc = pci_enable_device(pdev); 355 356 if (rc < 0) { 357 rc = -EIO; 358 } else { 359 rc = dgnc_probe1(pdev, ent->driver_data); 360 if (rc == 0) { 361 dgnc_NumBoards++; 362 DPR_INIT(("Incrementing numboards to %d\n", dgnc_NumBoards)); 363 } 364 } 365 return rc; 366 } 367 368 static int dgnc_probe1(struct pci_dev *pdev, int card_type) 369 { 370 return dgnc_found_board(pdev, card_type); 371 } 372 373 374 static void dgnc_remove_one(struct pci_dev *dev) 375 { 376 /* Do Nothing */ 377 } 378 379 /* 380 * dgnc_cleanup_module() 381 * 382 * Module unload. This is where it all ends. 383 */ 384 void dgnc_cleanup_module(void) 385 { 386 int i; 387 ulong lock_flags; 388 389 DGNC_LOCK(dgnc_poll_lock, lock_flags); 390 dgnc_poll_stop = 1; 391 DGNC_UNLOCK(dgnc_poll_lock, lock_flags); 392 393 /* Turn off poller right away. */ 394 del_timer_sync(&dgnc_poll_timer); 395 396 dgnc_remove_driver_sysfiles(&dgnc_driver); 397 398 if (dgnc_Major_Control_Registered) { 399 device_destroy(dgnc_class, MKDEV(dgnc_Major, 0)); 400 class_destroy(dgnc_class); 401 unregister_chrdev(dgnc_Major, "dgnc"); 402 } 403 404 for (i = 0; i < dgnc_NumBoards; ++i) { 405 dgnc_remove_ports_sysfiles(dgnc_Board[i]); 406 dgnc_tty_uninit(dgnc_Board[i]); 407 dgnc_cleanup_board(dgnc_Board[i]); 408 } 409 410 dgnc_tty_post_uninit(); 411 412 #if defined(DGNC_TRACER) 413 /* last thing, make sure we release the tracebuffer */ 414 dgnc_tracer_free(); 415 #endif 416 if (dgnc_NumBoards) 417 pci_unregister_driver(&dgnc_driver); 418 } 419 420 421 /* 422 * dgnc_cleanup_board() 423 * 424 * Free all the memory associated with a board 425 */ 426 static void dgnc_cleanup_board(struct dgnc_board *brd) 427 { 428 int i = 0; 429 430 if(!brd || brd->magic != DGNC_BOARD_MAGIC) 431 return; 432 433 switch (brd->device) { 434 case PCI_DEVICE_CLASSIC_4_DID: 435 case PCI_DEVICE_CLASSIC_8_DID: 436 case PCI_DEVICE_CLASSIC_4_422_DID: 437 case PCI_DEVICE_CLASSIC_8_422_DID: 438 439 /* Tell card not to interrupt anymore. */ 440 outb(0, brd->iobase + 0x4c); 441 break; 442 443 default: 444 break; 445 } 446 447 if (brd->irq) 448 free_irq(brd->irq, brd); 449 450 tasklet_kill(&brd->helper_tasklet); 451 452 if (brd->re_map_membase) { 453 iounmap(brd->re_map_membase); 454 brd->re_map_membase = NULL; 455 } 456 457 if (brd->msgbuf_head) { 458 unsigned long flags; 459 460 DGNC_LOCK(dgnc_global_lock, flags); 461 brd->msgbuf = NULL; 462 printk("%s", brd->msgbuf_head); 463 kfree(brd->msgbuf_head); 464 brd->msgbuf_head = NULL; 465 DGNC_UNLOCK(dgnc_global_lock, flags); 466 } 467 468 /* Free all allocated channels structs */ 469 for (i = 0; i < MAXPORTS ; i++) { 470 if (brd->channels[i]) { 471 kfree(brd->channels[i]->ch_rqueue); 472 kfree(brd->channels[i]->ch_equeue); 473 kfree(brd->channels[i]->ch_wqueue); 474 kfree(brd->channels[i]); 475 brd->channels[i] = NULL; 476 } 477 } 478 479 kfree(brd->flipbuf); 480 481 dgnc_Board[brd->boardnum] = NULL; 482 483 kfree(brd); 484 } 485 486 487 /* 488 * dgnc_found_board() 489 * 490 * A board has been found, init it. 491 */ 492 static int dgnc_found_board(struct pci_dev *pdev, int id) 493 { 494 struct dgnc_board *brd; 495 unsigned int pci_irq; 496 int i = 0; 497 int rc = 0; 498 unsigned long flags; 499 500 /* get the board structure and prep it */ 501 brd = dgnc_Board[dgnc_NumBoards] = 502 kzalloc(sizeof(*brd), GFP_KERNEL); 503 if (!brd) 504 return -ENOMEM; 505 506 /* make a temporary message buffer for the boot messages */ 507 brd->msgbuf = brd->msgbuf_head = 508 kzalloc(sizeof(u8) * 8192, GFP_KERNEL); 509 if (!brd->msgbuf) { 510 kfree(brd); 511 return -ENOMEM; 512 } 513 514 /* store the info for the board we've found */ 515 brd->magic = DGNC_BOARD_MAGIC; 516 brd->boardnum = dgnc_NumBoards; 517 brd->vendor = dgnc_pci_tbl[id].vendor; 518 brd->device = dgnc_pci_tbl[id].device; 519 brd->pdev = pdev; 520 brd->pci_bus = pdev->bus->number; 521 brd->pci_slot = PCI_SLOT(pdev->devfn); 522 brd->name = dgnc_Ids[id].name; 523 brd->maxports = dgnc_Ids[id].maxports; 524 if (dgnc_Ids[i].is_pci_express) 525 brd->bd_flags |= BD_IS_PCI_EXPRESS; 526 brd->dpastatus = BD_NOFEP; 527 init_waitqueue_head(&brd->state_wait); 528 529 DGNC_SPINLOCK_INIT(brd->bd_lock); 530 DGNC_SPINLOCK_INIT(brd->bd_intr_lock); 531 532 brd->state = BOARD_FOUND; 533 534 for (i = 0; i < MAXPORTS; i++) 535 brd->channels[i] = NULL; 536 537 /* store which card & revision we have */ 538 pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor); 539 pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &brd->subdevice); 540 pci_read_config_byte(pdev, PCI_REVISION_ID, &brd->rev); 541 542 pci_irq = pdev->irq; 543 brd->irq = pci_irq; 544 545 546 switch(brd->device) { 547 548 case PCI_DEVICE_CLASSIC_4_DID: 549 case PCI_DEVICE_CLASSIC_8_DID: 550 case PCI_DEVICE_CLASSIC_4_422_DID: 551 case PCI_DEVICE_CLASSIC_8_422_DID: 552 553 brd->dpatype = T_CLASSIC | T_PCIBUS; 554 555 DPR_INIT(("dgnc_found_board - Classic.\n")); 556 557 /* 558 * For PCI ClassicBoards 559 * PCI Local Address (i.e. "resource" number) space 560 * 0 PLX Memory Mapped Config 561 * 1 PLX I/O Mapped Config 562 * 2 I/O Mapped UARTs and Status 563 * 3 Memory Mapped VPD 564 * 4 Memory Mapped UARTs and Status 565 */ 566 567 568 /* get the PCI Base Address Registers */ 569 brd->membase = pci_resource_start(pdev, 4); 570 571 if (!brd->membase) { 572 APR(("card has no PCI IO resources, failing board.\n")); 573 return -ENODEV; 574 } 575 576 brd->membase_end = pci_resource_end(pdev, 4); 577 578 if (brd->membase & 1) 579 brd->membase &= ~3; 580 else 581 brd->membase &= ~15; 582 583 brd->iobase = pci_resource_start(pdev, 1); 584 brd->iobase_end = pci_resource_end(pdev, 1); 585 brd->iobase = ((unsigned int) (brd->iobase)) & 0xFFFE; 586 587 /* Assign the board_ops struct */ 588 brd->bd_ops = &dgnc_cls_ops; 589 590 brd->bd_uart_offset = 0x8; 591 brd->bd_dividend = 921600; 592 593 dgnc_do_remap(brd); 594 595 /* Get and store the board VPD, if it exists */ 596 brd->bd_ops->vpd(brd); 597 598 /* 599 * Enable Local Interrupt 1 (0x1), 600 * Local Interrupt 1 Polarity Active high (0x2), 601 * Enable PCI interrupt (0x40) 602 */ 603 outb(0x43, brd->iobase + 0x4c); 604 605 break; 606 607 608 case PCI_DEVICE_NEO_4_DID: 609 case PCI_DEVICE_NEO_8_DID: 610 case PCI_DEVICE_NEO_2DB9_DID: 611 case PCI_DEVICE_NEO_2DB9PRI_DID: 612 case PCI_DEVICE_NEO_2RJ45_DID: 613 case PCI_DEVICE_NEO_2RJ45PRI_DID: 614 case PCI_DEVICE_NEO_1_422_DID: 615 case PCI_DEVICE_NEO_1_422_485_DID: 616 case PCI_DEVICE_NEO_2_422_485_DID: 617 case PCI_DEVICE_NEO_EXPRESS_8_DID: 618 case PCI_DEVICE_NEO_EXPRESS_4_DID: 619 case PCI_DEVICE_NEO_EXPRESS_4RJ45_DID: 620 case PCI_DEVICE_NEO_EXPRESS_8RJ45_DID: 621 622 /* 623 * This chip is set up 100% when we get to it. 624 * No need to enable global interrupts or anything. 625 */ 626 if (brd->bd_flags & BD_IS_PCI_EXPRESS) 627 brd->dpatype = T_NEO_EXPRESS | T_PCIBUS; 628 else 629 brd->dpatype = T_NEO | T_PCIBUS; 630 631 DPR_INIT(("dgnc_found_board - NEO.\n")); 632 633 /* get the PCI Base Address Registers */ 634 brd->membase = pci_resource_start(pdev, 0); 635 brd->membase_end = pci_resource_end(pdev, 0); 636 637 if (brd->membase & 1) 638 brd->membase &= ~3; 639 else 640 brd->membase &= ~15; 641 642 /* Assign the board_ops struct */ 643 brd->bd_ops = &dgnc_neo_ops; 644 645 brd->bd_uart_offset = 0x200; 646 brd->bd_dividend = 921600; 647 648 dgnc_do_remap(brd); 649 650 if (brd->re_map_membase) { 651 652 /* After remap is complete, we need to read and store the dvid */ 653 brd->dvid = readb(brd->re_map_membase + 0x8D); 654 655 /* Get and store the board VPD, if it exists */ 656 brd->bd_ops->vpd(brd); 657 } 658 break; 659 660 default: 661 APR(("Did not find any compatible Neo or Classic PCI boards in system.\n")); 662 return -ENXIO; 663 664 } 665 666 /* 667 * Do tty device initialization. 668 */ 669 670 rc = dgnc_tty_register(brd); 671 if (rc < 0) { 672 dgnc_tty_uninit(brd); 673 APR(("Can't register tty devices (%d)\n", rc)); 674 brd->state = BOARD_FAILED; 675 brd->dpastatus = BD_NOFEP; 676 goto failed; 677 } 678 679 rc = dgnc_finalize_board_init(brd); 680 if (rc < 0) { 681 APR(("Can't finalize board init (%d)\n", rc)); 682 brd->state = BOARD_FAILED; 683 brd->dpastatus = BD_NOFEP; 684 685 goto failed; 686 } 687 688 rc = dgnc_tty_init(brd); 689 if (rc < 0) { 690 dgnc_tty_uninit(brd); 691 APR(("Can't init tty devices (%d)\n", rc)); 692 brd->state = BOARD_FAILED; 693 brd->dpastatus = BD_NOFEP; 694 695 goto failed; 696 } 697 698 brd->state = BOARD_READY; 699 brd->dpastatus = BD_RUNNING; 700 701 dgnc_create_ports_sysfiles(brd); 702 703 /* init our poll helper tasklet */ 704 tasklet_init(&brd->helper_tasklet, brd->bd_ops->tasklet, (unsigned long) brd); 705 706 DPR_INIT(("dgnc_scan(%d) - printing out the msgbuf\n", i)); 707 DGNC_LOCK(dgnc_global_lock, flags); 708 brd->msgbuf = NULL; 709 printk("%s", brd->msgbuf_head); 710 kfree(brd->msgbuf_head); 711 brd->msgbuf_head = NULL; 712 DGNC_UNLOCK(dgnc_global_lock, flags); 713 714 /* 715 * allocate flip buffer for board. 716 * 717 * Okay to malloc with GFP_KERNEL, we are not at interrupt 718 * context, and there are no locks held. 719 */ 720 brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL); 721 722 wake_up_interruptible(&brd->state_wait); 723 724 return 0; 725 726 failed: 727 728 return -ENXIO; 729 730 } 731 732 733 static int dgnc_finalize_board_init(struct dgnc_board *brd) { 734 int rc = 0; 735 736 DPR_INIT(("dgnc_finalize_board_init() - start\n")); 737 738 if (!brd || brd->magic != DGNC_BOARD_MAGIC) 739 return -ENODEV; 740 741 DPR_INIT(("dgnc_finalize_board_init() - start #2\n")); 742 743 if (brd->irq) { 744 rc = request_irq(brd->irq, brd->bd_ops->intr, 745 IRQF_SHARED, "DGNC", brd); 746 747 if (rc) { 748 dev_err(&brd->pdev->dev, 749 "Failed to hook IRQ %d\n", brd->irq); 750 brd->state = BOARD_FAILED; 751 brd->dpastatus = BD_NOFEP; 752 rc = -ENODEV; 753 } else { 754 DPR_INIT(("Requested and received usage of IRQ %d\n", 755 brd->irq)); 756 } 757 } 758 return rc; 759 } 760 761 /* 762 * Remap PCI memory. 763 */ 764 static void dgnc_do_remap(struct dgnc_board *brd) 765 { 766 767 if (!brd || brd->magic != DGNC_BOARD_MAGIC) 768 return; 769 770 brd->re_map_membase = ioremap(brd->membase, 0x1000); 771 772 DPR_INIT(("remapped mem: 0x%p\n", brd->re_map_membase)); 773 } 774 775 776 /***************************************************************************** 777 * 778 * Function: 779 * 780 * dgnc_poll_handler 781 * 782 * Author: 783 * 784 * Scott H Kilau 785 * 786 * Parameters: 787 * 788 * dummy -- ignored 789 * 790 * Return Values: 791 * 792 * none 793 * 794 * Description: 795 * 796 * As each timer expires, it determines (a) whether the "transmit" 797 * waiter needs to be woken up, and (b) whether the poller needs to 798 * be rescheduled. 799 * 800 ******************************************************************************/ 801 802 static void dgnc_poll_handler(ulong dummy) 803 { 804 struct dgnc_board *brd; 805 unsigned long lock_flags; 806 int i; 807 unsigned long new_time; 808 809 dgnc_poll_counter++; 810 811 /* 812 * Do not start the board state machine until 813 * driver tells us its up and running, and has 814 * everything it needs. 815 */ 816 if (dgnc_driver_state != DRIVER_READY) 817 goto schedule_poller; 818 819 /* Go thru each board, kicking off a tasklet for each if needed */ 820 for (i = 0; i < dgnc_NumBoards; i++) { 821 brd = dgnc_Board[i]; 822 823 DGNC_LOCK(brd->bd_lock, lock_flags); 824 825 /* If board is in a failed state, don't bother scheduling a tasklet */ 826 if (brd->state == BOARD_FAILED) { 827 DGNC_UNLOCK(brd->bd_lock, lock_flags); 828 continue; 829 } 830 831 /* Schedule a poll helper task */ 832 tasklet_schedule(&brd->helper_tasklet); 833 834 DGNC_UNLOCK(brd->bd_lock, lock_flags); 835 } 836 837 schedule_poller: 838 839 /* 840 * Schedule ourself back at the nominal wakeup interval. 841 */ 842 DGNC_LOCK(dgnc_poll_lock, lock_flags); 843 dgnc_poll_time += dgnc_jiffies_from_ms(dgnc_poll_tick); 844 845 new_time = dgnc_poll_time - jiffies; 846 847 if ((ulong) new_time >= 2 * dgnc_poll_tick) 848 dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick); 849 850 init_timer(&dgnc_poll_timer); 851 dgnc_poll_timer.function = dgnc_poll_handler; 852 dgnc_poll_timer.data = 0; 853 dgnc_poll_timer.expires = dgnc_poll_time; 854 DGNC_UNLOCK(dgnc_poll_lock, lock_flags); 855 856 if (!dgnc_poll_stop) 857 add_timer(&dgnc_poll_timer); 858 } 859 860 /* 861 * dgnc_init_globals() 862 * 863 * This is where we initialize the globals from the static insmod 864 * configuration variables. These are declared near the head of 865 * this file. 866 */ 867 static void dgnc_init_globals(void) 868 { 869 int i = 0; 870 871 dgnc_rawreadok = rawreadok; 872 dgnc_trcbuf_size = trcbuf_size; 873 dgnc_debug = debug; 874 875 for (i = 0; i < MAXBOARDS; i++) 876 dgnc_Board[i] = NULL; 877 878 init_timer(&dgnc_poll_timer); 879 } 880 881 882 /************************************************************************ 883 * 884 * Utility functions 885 * 886 ************************************************************************/ 887 888 /* 889 * dgnc_ms_sleep() 890 * 891 * Put the driver to sleep for x ms's 892 * 893 * Returns 0 if timed out, !0 (showing signal) if interrupted by a signal. 894 */ 895 int dgnc_ms_sleep(ulong ms) 896 { 897 current->state = TASK_INTERRUPTIBLE; 898 schedule_timeout((ms * HZ) / 1000); 899 return signal_pending(current); 900 } 901 902 903 904 /* 905 * dgnc_ioctl_name() : Returns a text version of each ioctl value. 906 */ 907 char *dgnc_ioctl_name(int cmd) 908 { 909 switch(cmd) { 910 911 case TCGETA: return "TCGETA"; 912 case TCGETS: return "TCGETS"; 913 case TCSETA: return "TCSETA"; 914 case TCSETS: return "TCSETS"; 915 case TCSETAW: return "TCSETAW"; 916 case TCSETSW: return "TCSETSW"; 917 case TCSETAF: return "TCSETAF"; 918 case TCSETSF: return "TCSETSF"; 919 case TCSBRK: return "TCSBRK"; 920 case TCXONC: return "TCXONC"; 921 case TCFLSH: return "TCFLSH"; 922 case TIOCGSID: return "TIOCGSID"; 923 924 case TIOCGETD: return "TIOCGETD"; 925 case TIOCSETD: return "TIOCSETD"; 926 case TIOCGWINSZ: return "TIOCGWINSZ"; 927 case TIOCSWINSZ: return "TIOCSWINSZ"; 928 929 case TIOCMGET: return "TIOCMGET"; 930 case TIOCMSET: return "TIOCMSET"; 931 case TIOCMBIS: return "TIOCMBIS"; 932 case TIOCMBIC: return "TIOCMBIC"; 933 934 /* from digi.h */ 935 case DIGI_SETA: return "DIGI_SETA"; 936 case DIGI_SETAW: return "DIGI_SETAW"; 937 case DIGI_SETAF: return "DIGI_SETAF"; 938 case DIGI_SETFLOW: return "DIGI_SETFLOW"; 939 case DIGI_SETAFLOW: return "DIGI_SETAFLOW"; 940 case DIGI_GETFLOW: return "DIGI_GETFLOW"; 941 case DIGI_GETAFLOW: return "DIGI_GETAFLOW"; 942 case DIGI_GETA: return "DIGI_GETA"; 943 case DIGI_GEDELAY: return "DIGI_GEDELAY"; 944 case DIGI_SEDELAY: return "DIGI_SEDELAY"; 945 case DIGI_GETCUSTOMBAUD: return "DIGI_GETCUSTOMBAUD"; 946 case DIGI_SETCUSTOMBAUD: return "DIGI_SETCUSTOMBAUD"; 947 case TIOCMODG: return "TIOCMODG"; 948 case TIOCMODS: return "TIOCMODS"; 949 case TIOCSDTR: return "TIOCSDTR"; 950 case TIOCCDTR: return "TIOCCDTR"; 951 952 default: return "unknown"; 953 } 954 } 955 956 957 958 959 960 /* LDV_COMMENT_BEGIN_MAIN */ 961 #ifdef LDV_MAIN1_sequence_infinite_withcheck_stateful 962 963 /*###########################################################################*/ 964 965 /*############## Driver Environment Generator 0.2 output ####################*/ 966 967 /*###########################################################################*/ 968 969 970 971 /* 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. */ 972 void ldv_check_final_state(void); 973 974 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */ 975 void ldv_check_return_value(int res); 976 977 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */ 978 void ldv_check_return_value_probe(int res); 979 980 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */ 981 void ldv_initialize(void); 982 983 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */ 984 void ldv_handler_precall(void); 985 986 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */ 987 int nondet_int(void); 988 989 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */ 990 int LDV_IN_INTERRUPT; 991 992 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */ 993 void ldv_main1_sequence_infinite_withcheck_stateful(void) { 994 995 996 997 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */ 998 /*============================= VARIABLE DECLARATION PART =============================*/ 999 /** STRUCT: struct type: pci_driver, struct name: dgnc_driver **/ 1000 /* content: static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)*/ 1001 /* LDV_COMMENT_END_PREP */ 1002 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_init_one" */ 1003 struct pci_dev * var_group1; 1004 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_init_one" */ 1005 const struct pci_device_id * var_dgnc_init_one_3_p1; 1006 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "dgnc_init_one" */ 1007 static int res_dgnc_init_one_3; 1008 /* LDV_COMMENT_BEGIN_PREP */ 1009 #if defined(DGNC_TRACER) 1010 #endif 1011 /* LDV_COMMENT_END_PREP */ 1012 /* content: static void dgnc_remove_one(struct pci_dev *dev)*/ 1013 /* LDV_COMMENT_END_PREP */ 1014 /* LDV_COMMENT_BEGIN_PREP */ 1015 #if defined(DGNC_TRACER) 1016 #endif 1017 /* LDV_COMMENT_END_PREP */ 1018 1019 1020 1021 1022 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */ 1023 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */ 1024 /*============================= VARIABLE INITIALIZING PART =============================*/ 1025 LDV_IN_INTERRUPT=1; 1026 1027 1028 1029 1030 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */ 1031 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */ 1032 /*============================= FUNCTION CALL SECTION =============================*/ 1033 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */ 1034 ldv_initialize(); 1035 1036 /** INIT: init_type: ST_MODULE_INIT **/ 1037 /* content: int dgnc_init_module(void)*/ 1038 /* LDV_COMMENT_END_PREP */ 1039 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver init function after driver loading to kernel. This function declared as "MODULE_INIT(function name)". */ 1040 ldv_handler_precall(); 1041 if(dgnc_init_module()) 1042 goto ldv_final; 1043 /* LDV_COMMENT_BEGIN_PREP */ 1044 #if defined(DGNC_TRACER) 1045 #endif 1046 /* LDV_COMMENT_END_PREP */ 1047 int ldv_s_dgnc_driver_pci_driver = 0; 1048 1049 1050 while( nondet_int() 1051 || !(ldv_s_dgnc_driver_pci_driver == 0) 1052 ) { 1053 1054 switch(nondet_int()) { 1055 1056 case 0: { 1057 1058 /** STRUCT: struct type: pci_driver, struct name: dgnc_driver **/ 1059 if(ldv_s_dgnc_driver_pci_driver==0) { 1060 1061 /* content: static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)*/ 1062 /* LDV_COMMENT_END_PREP */ 1063 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "dgnc_driver". Standart function test for correct return result. */ 1064 res_dgnc_init_one_3 = dgnc_init_one( var_group1, var_dgnc_init_one_3_p1); 1065 ldv_check_return_value(res_dgnc_init_one_3); 1066 ldv_check_return_value_probe(res_dgnc_init_one_3); 1067 if(res_dgnc_init_one_3) 1068 goto ldv_module_exit; 1069 /* LDV_COMMENT_BEGIN_PREP */ 1070 #if defined(DGNC_TRACER) 1071 #endif 1072 /* LDV_COMMENT_END_PREP */ 1073 ldv_s_dgnc_driver_pci_driver++; 1074 1075 } 1076 1077 } 1078 1079 break; 1080 case 1: { 1081 1082 /** STRUCT: struct type: pci_driver, struct name: dgnc_driver **/ 1083 if(ldv_s_dgnc_driver_pci_driver==1) { 1084 1085 /* content: static void dgnc_remove_one(struct pci_dev *dev)*/ 1086 /* LDV_COMMENT_END_PREP */ 1087 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "dgnc_driver" */ 1088 ldv_handler_precall(); 1089 dgnc_remove_one( var_group1); 1090 /* LDV_COMMENT_BEGIN_PREP */ 1091 #if defined(DGNC_TRACER) 1092 #endif 1093 /* LDV_COMMENT_END_PREP */ 1094 ldv_s_dgnc_driver_pci_driver=0; 1095 1096 } 1097 1098 } 1099 1100 break; 1101 default: break; 1102 1103 } 1104 1105 } 1106 1107 ldv_module_exit: 1108 1109 /** INIT: init_type: ST_MODULE_EXIT **/ 1110 /* content: void dgnc_cleanup_module(void)*/ 1111 /* LDV_COMMENT_END_PREP */ 1112 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver release function before driver will be uploaded from kernel. This function declared as "MODULE_EXIT(function name)". */ 1113 ldv_handler_precall(); 1114 dgnc_cleanup_module(); 1115 1116 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */ 1117 ldv_final: ldv_check_final_state(); 1118 1119 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */ 1120 return; 1121 1122 } 1123 #endif 1124 1125 /* 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 9 // Provide model function prototypes before their usage. 10 11 void *ldv_create_class(void); 12 int ldv_register_class(void); 13 void ldv_unregister_class(void); 14 15 int ldv_register_chrdev_region(void); 16 void ldv_unregister_chrdev_region(void); 17 18 int ldv_register_usb_gadget(void); 19 void ldv_unregister_usb_gadget(void); 20 21 /* 22 * Copyright 2004 Digi International (www.digi.com) 23 * Scott H Kilau <Scott_Kilau at digi dot com> 24 * 25 * This program is free software; you can redistribute it and/or modify 26 * it under the terms of the GNU General Public License as published by 27 * the Free Software Foundation; either version 2, or (at your option) 28 * any later version. 29 * 30 * This program is distributed in the hope that it will be useful, 31 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the 32 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 33 * PURPOSE. See the GNU General Public License for more details. 34 * 35 * You should have received a copy of the GNU General Public License 36 * along with this program; if not, write to the Free Software 37 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 38 * 39 * 40 * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! 41 * 42 * This is shared code between Digi's CVS archive and the 43 * Linux Kernel sources. 44 * Changing the source just for reformatting needlessly breaks 45 * our CVS diff history. 46 * 47 * Send any bug fixes/changes to: Eng.Linux at digi dot com. 48 * Thank you. 49 * 50 */ 51 52 53 #include <linux/kernel.h> 54 #include <linux/module.h> 55 #include <linux/ctype.h> 56 #include <linux/string.h> 57 #include <linux/serial_reg.h> 58 #include <linux/device.h> 59 #include <linux/pci.h> 60 #include <linux/kdev_t.h> 61 62 #include "dgnc_driver.h" 63 #include "dgnc_mgmt.h" 64 65 66 static ssize_t dgnc_driver_version_show(struct device_driver *ddp, char *buf) 67 { 68 return snprintf(buf, PAGE_SIZE, "%s\n", DG_PART); 69 } 70 static DRIVER_ATTR(version, S_IRUSR, dgnc_driver_version_show, NULL); 71 72 73 static ssize_t dgnc_driver_boards_show(struct device_driver *ddp, char *buf) 74 { 75 return snprintf(buf, PAGE_SIZE, "%d\n", dgnc_NumBoards); 76 } 77 static DRIVER_ATTR(boards, S_IRUSR, dgnc_driver_boards_show, NULL); 78 79 80 static ssize_t dgnc_driver_maxboards_show(struct device_driver *ddp, char *buf) 81 { 82 return snprintf(buf, PAGE_SIZE, "%d\n", MAXBOARDS); 83 } 84 static DRIVER_ATTR(maxboards, S_IRUSR, dgnc_driver_maxboards_show, NULL); 85 86 87 static ssize_t dgnc_driver_pollcounter_show(struct device_driver *ddp, char *buf) 88 { 89 return snprintf(buf, PAGE_SIZE, "%ld\n", dgnc_poll_counter); 90 } 91 static DRIVER_ATTR(pollcounter, S_IRUSR, dgnc_driver_pollcounter_show, NULL); 92 93 94 static ssize_t dgnc_driver_state_show(struct device_driver *ddp, char *buf) 95 { 96 return snprintf(buf, PAGE_SIZE, "%s\n", dgnc_driver_state_text[dgnc_driver_state]); 97 } 98 static DRIVER_ATTR(state, S_IRUSR, dgnc_driver_state_show, NULL); 99 100 101 static ssize_t dgnc_driver_debug_show(struct device_driver *ddp, char *buf) 102 { 103 return snprintf(buf, PAGE_SIZE, "0x%x\n", dgnc_debug); 104 } 105 106 static ssize_t dgnc_driver_debug_store(struct device_driver *ddp, const char *buf, size_t count) 107 { 108 sscanf(buf, "0x%x\n", &dgnc_debug); 109 return count; 110 } 111 static DRIVER_ATTR(debug, (S_IRUSR | S_IWUSR), dgnc_driver_debug_show, dgnc_driver_debug_store); 112 113 114 static ssize_t dgnc_driver_rawreadok_show(struct device_driver *ddp, char *buf) 115 { 116 return snprintf(buf, PAGE_SIZE, "0x%x\n", dgnc_rawreadok); 117 } 118 119 static ssize_t dgnc_driver_rawreadok_store(struct device_driver *ddp, const char *buf, size_t count) 120 { 121 sscanf(buf, "0x%x\n", &dgnc_rawreadok); 122 return count; 123 } 124 static DRIVER_ATTR(rawreadok, (S_IRUSR | S_IWUSR), dgnc_driver_rawreadok_show, dgnc_driver_rawreadok_store); 125 126 127 static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf) 128 { 129 return snprintf(buf, PAGE_SIZE, "%dms\n", dgnc_poll_tick); 130 } 131 132 static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count) 133 { 134 sscanf(buf, "%d\n", &dgnc_poll_tick); 135 return count; 136 } 137 static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgnc_driver_pollrate_show, dgnc_driver_pollrate_store); 138 139 140 void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver) 141 { 142 int rc = 0; 143 struct device_driver *driverfs = &dgnc_driver->driver; 144 145 rc |= driver_create_file(driverfs, &driver_attr_version); 146 rc |= driver_create_file(driverfs, &driver_attr_boards); 147 rc |= driver_create_file(driverfs, &driver_attr_maxboards); 148 rc |= driver_create_file(driverfs, &driver_attr_debug); 149 rc |= driver_create_file(driverfs, &driver_attr_rawreadok); 150 rc |= driver_create_file(driverfs, &driver_attr_pollrate); 151 rc |= driver_create_file(driverfs, &driver_attr_pollcounter); 152 rc |= driver_create_file(driverfs, &driver_attr_state); 153 if (rc) { 154 printk(KERN_ERR "DGNC: sysfs driver_create_file failed!\n"); 155 } 156 } 157 158 159 void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) 160 { 161 struct device_driver *driverfs = &dgnc_driver->driver; 162 driver_remove_file(driverfs, &driver_attr_version); 163 driver_remove_file(driverfs, &driver_attr_boards); 164 driver_remove_file(driverfs, &driver_attr_maxboards); 165 driver_remove_file(driverfs, &driver_attr_debug); 166 driver_remove_file(driverfs, &driver_attr_rawreadok); 167 driver_remove_file(driverfs, &driver_attr_pollrate); 168 driver_remove_file(driverfs, &driver_attr_pollcounter); 169 driver_remove_file(driverfs, &driver_attr_state); 170 } 171 172 173 #define DGNC_VERIFY_BOARD(p, bd) \ 174 if (!p) \ 175 return 0; \ 176 \ 177 bd = dev_get_drvdata(p); \ 178 if (!bd || bd->magic != DGNC_BOARD_MAGIC) \ 179 return 0; \ 180 if (bd->state != BOARD_READY) \ 181 return 0; \ 182 183 184 185 static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, char *buf) 186 { 187 struct dgnc_board *bd; 188 int count = 0; 189 int i = 0; 190 191 DGNC_VERIFY_BOARD(p, bd); 192 193 count += sprintf(buf + count, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F"); 194 for (i = 0; i < 0x40 * 2; i++) { 195 if (!(i % 16)) 196 count += sprintf(buf + count, "\n%04X ", i * 2); 197 count += sprintf(buf + count, "%02X ", bd->vpd[i]); 198 } 199 count += sprintf(buf + count, "\n"); 200 201 return count; 202 } 203 static DEVICE_ATTR(vpd, S_IRUSR, dgnc_vpd_show, NULL); 204 205 static ssize_t dgnc_serial_number_show(struct device *p, struct device_attribute *attr, char *buf) 206 { 207 struct dgnc_board *bd; 208 int count = 0; 209 210 DGNC_VERIFY_BOARD(p, bd); 211 212 if (bd->serial_num[0] == '\0') 213 count += sprintf(buf + count, "<UNKNOWN>\n"); 214 else 215 count += sprintf(buf + count, "%s\n", bd->serial_num); 216 217 return count; 218 } 219 static DEVICE_ATTR(serial_number, S_IRUSR, dgnc_serial_number_show, NULL); 220 221 222 static ssize_t dgnc_ports_state_show(struct device *p, struct device_attribute *attr, char *buf) 223 { 224 struct dgnc_board *bd; 225 int count = 0; 226 int i = 0; 227 228 DGNC_VERIFY_BOARD(p, bd); 229 230 for (i = 0; i < bd->nasync; i++) { 231 count += snprintf(buf + count, PAGE_SIZE - count, 232 "%d %s\n", bd->channels[i]->ch_portnum, 233 bd->channels[i]->ch_open_count ? "Open" : "Closed"); 234 } 235 return count; 236 } 237 static DEVICE_ATTR(ports_state, S_IRUSR, dgnc_ports_state_show, NULL); 238 239 240 static ssize_t dgnc_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf) 241 { 242 struct dgnc_board *bd; 243 int count = 0; 244 int i = 0; 245 246 DGNC_VERIFY_BOARD(p, bd); 247 248 for (i = 0; i < bd->nasync; i++) { 249 count += snprintf(buf + count, PAGE_SIZE - count, 250 "%d %d\n", bd->channels[i]->ch_portnum, bd->channels[i]->ch_old_baud); 251 } 252 return count; 253 } 254 static DEVICE_ATTR(ports_baud, S_IRUSR, dgnc_ports_baud_show, NULL); 255 256 257 static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf) 258 { 259 struct dgnc_board *bd; 260 int count = 0; 261 int i = 0; 262 263 DGNC_VERIFY_BOARD(p, bd); 264 265 for (i = 0; i < bd->nasync; i++) { 266 if (bd->channels[i]->ch_open_count) { 267 count += snprintf(buf + count, PAGE_SIZE - count, 268 "%d %s %s %s %s %s %s\n", bd->channels[i]->ch_portnum, 269 (bd->channels[i]->ch_mostat & UART_MCR_RTS) ? "RTS" : "", 270 (bd->channels[i]->ch_mistat & UART_MSR_CTS) ? "CTS" : "", 271 (bd->channels[i]->ch_mostat & UART_MCR_DTR) ? "DTR" : "", 272 (bd->channels[i]->ch_mistat & UART_MSR_DSR) ? "DSR" : "", 273 (bd->channels[i]->ch_mistat & UART_MSR_DCD) ? "DCD" : "", 274 (bd->channels[i]->ch_mistat & UART_MSR_RI) ? "RI" : ""); 275 } else { 276 count += snprintf(buf + count, PAGE_SIZE - count, 277 "%d\n", bd->channels[i]->ch_portnum); 278 } 279 } 280 return count; 281 } 282 static DEVICE_ATTR(ports_msignals, S_IRUSR, dgnc_ports_msignals_show, NULL); 283 284 285 static ssize_t dgnc_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf) 286 { 287 struct dgnc_board *bd; 288 int count = 0; 289 int i = 0; 290 291 DGNC_VERIFY_BOARD(p, bd); 292 293 for (i = 0; i < bd->nasync; i++) { 294 count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", 295 bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_iflag); 296 } 297 return count; 298 } 299 static DEVICE_ATTR(ports_iflag, S_IRUSR, dgnc_ports_iflag_show, NULL); 300 301 302 static ssize_t dgnc_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf) 303 { 304 struct dgnc_board *bd; 305 int count = 0; 306 int i = 0; 307 308 DGNC_VERIFY_BOARD(p, bd); 309 310 for (i = 0; i < bd->nasync; i++) { 311 count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", 312 bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_cflag); 313 } 314 return count; 315 } 316 static DEVICE_ATTR(ports_cflag, S_IRUSR, dgnc_ports_cflag_show, NULL); 317 318 319 static ssize_t dgnc_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf) 320 { 321 struct dgnc_board *bd; 322 int count = 0; 323 int i = 0; 324 325 DGNC_VERIFY_BOARD(p, bd); 326 327 for (i = 0; i < bd->nasync; i++) { 328 count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", 329 bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_oflag); 330 } 331 return count; 332 } 333 static DEVICE_ATTR(ports_oflag, S_IRUSR, dgnc_ports_oflag_show, NULL); 334 335 336 static ssize_t dgnc_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf) 337 { 338 struct dgnc_board *bd; 339 int count = 0; 340 int i = 0; 341 342 DGNC_VERIFY_BOARD(p, bd); 343 344 for (i = 0; i < bd->nasync; i++) { 345 count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", 346 bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_lflag); 347 } 348 return count; 349 } 350 static DEVICE_ATTR(ports_lflag, S_IRUSR, dgnc_ports_lflag_show, NULL); 351 352 353 static ssize_t dgnc_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf) 354 { 355 struct dgnc_board *bd; 356 int count = 0; 357 int i = 0; 358 359 DGNC_VERIFY_BOARD(p, bd); 360 361 for (i = 0; i < bd->nasync; i++) { 362 count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", 363 bd->channels[i]->ch_portnum, bd->channels[i]->ch_digi.digi_flags); 364 } 365 return count; 366 } 367 static DEVICE_ATTR(ports_digi_flag, S_IRUSR, dgnc_ports_digi_flag_show, NULL); 368 369 370 static ssize_t dgnc_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf) 371 { 372 struct dgnc_board *bd; 373 int count = 0; 374 int i = 0; 375 376 DGNC_VERIFY_BOARD(p, bd); 377 378 for (i = 0; i < bd->nasync; i++) { 379 count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", 380 bd->channels[i]->ch_portnum, bd->channels[i]->ch_rxcount); 381 } 382 return count; 383 } 384 static DEVICE_ATTR(ports_rxcount, S_IRUSR, dgnc_ports_rxcount_show, NULL); 385 386 387 static ssize_t dgnc_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf) 388 { 389 struct dgnc_board *bd; 390 int count = 0; 391 int i = 0; 392 393 DGNC_VERIFY_BOARD(p, bd); 394 395 for (i = 0; i < bd->nasync; i++) { 396 count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", 397 bd->channels[i]->ch_portnum, bd->channels[i]->ch_txcount); 398 } 399 return count; 400 } 401 static DEVICE_ATTR(ports_txcount, S_IRUSR, dgnc_ports_txcount_show, NULL); 402 403 404 /* this function creates the sys files that will export each signal status 405 * to sysfs each value will be put in a separate filename 406 */ 407 void dgnc_create_ports_sysfiles(struct dgnc_board *bd) 408 { 409 int rc = 0; 410 411 dev_set_drvdata(&bd->pdev->dev, bd); 412 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_state); 413 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_baud); 414 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_msignals); 415 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_iflag); 416 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_cflag); 417 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_oflag); 418 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_lflag); 419 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); 420 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); 421 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount); 422 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_vpd); 423 rc |= device_create_file(&(bd->pdev->dev), &dev_attr_serial_number); 424 if (rc) { 425 printk(KERN_ERR "DGNC: sysfs device_create_file failed!\n"); 426 } 427 } 428 429 430 /* removes all the sys files created for that port */ 431 void dgnc_remove_ports_sysfiles(struct dgnc_board *bd) 432 { 433 device_remove_file(&(bd->pdev->dev), &dev_attr_ports_state); 434 device_remove_file(&(bd->pdev->dev), &dev_attr_ports_baud); 435 device_remove_file(&(bd->pdev->dev), &dev_attr_ports_msignals); 436 device_remove_file(&(bd->pdev->dev), &dev_attr_ports_iflag); 437 device_remove_file(&(bd->pdev->dev), &dev_attr_ports_cflag); 438 device_remove_file(&(bd->pdev->dev), &dev_attr_ports_oflag); 439 device_remove_file(&(bd->pdev->dev), &dev_attr_ports_lflag); 440 device_remove_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); 441 device_remove_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); 442 device_remove_file(&(bd->pdev->dev), &dev_attr_ports_txcount); 443 device_remove_file(&(bd->pdev->dev), &dev_attr_vpd); 444 device_remove_file(&(bd->pdev->dev), &dev_attr_serial_number); 445 } 446 447 448 static ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *attr, char *buf) 449 { 450 struct dgnc_board *bd; 451 struct channel_t *ch; 452 struct un_t *un; 453 454 if (!d) 455 return 0; 456 un = dev_get_drvdata(d); 457 if (!un || un->magic != DGNC_UNIT_MAGIC) 458 return 0; 459 ch = un->un_ch; 460 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 461 return 0; 462 bd = ch->ch_bd; 463 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 464 return 0; 465 if (bd->state != BOARD_READY) 466 return 0; 467 468 return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? "Open" : "Closed"); 469 } 470 static DEVICE_ATTR(state, S_IRUSR, dgnc_tty_state_show, NULL); 471 472 473 static ssize_t dgnc_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf) 474 { 475 struct dgnc_board *bd; 476 struct channel_t *ch; 477 struct un_t *un; 478 479 if (!d) 480 return 0; 481 un = dev_get_drvdata(d); 482 if (!un || un->magic != DGNC_UNIT_MAGIC) 483 return 0; 484 ch = un->un_ch; 485 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 486 return 0; 487 bd = ch->ch_bd; 488 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 489 return 0; 490 if (bd->state != BOARD_READY) 491 return 0; 492 493 return snprintf(buf, PAGE_SIZE, "%d\n", ch->ch_old_baud); 494 } 495 static DEVICE_ATTR(baud, S_IRUSR, dgnc_tty_baud_show, NULL); 496 497 498 static ssize_t dgnc_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf) 499 { 500 struct dgnc_board *bd; 501 struct channel_t *ch; 502 struct un_t *un; 503 504 if (!d) 505 return 0; 506 un = dev_get_drvdata(d); 507 if (!un || un->magic != DGNC_UNIT_MAGIC) 508 return 0; 509 ch = un->un_ch; 510 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 511 return 0; 512 bd = ch->ch_bd; 513 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 514 return 0; 515 if (bd->state != BOARD_READY) 516 return 0; 517 518 if (ch->ch_open_count) { 519 return snprintf(buf, PAGE_SIZE, "%s %s %s %s %s %s\n", 520 (ch->ch_mostat & UART_MCR_RTS) ? "RTS" : "", 521 (ch->ch_mistat & UART_MSR_CTS) ? "CTS" : "", 522 (ch->ch_mostat & UART_MCR_DTR) ? "DTR" : "", 523 (ch->ch_mistat & UART_MSR_DSR) ? "DSR" : "", 524 (ch->ch_mistat & UART_MSR_DCD) ? "DCD" : "", 525 (ch->ch_mistat & UART_MSR_RI) ? "RI" : ""); 526 } 527 return 0; 528 } 529 static DEVICE_ATTR(msignals, S_IRUSR, dgnc_tty_msignals_show, NULL); 530 531 532 static ssize_t dgnc_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf) 533 { 534 struct dgnc_board *bd; 535 struct channel_t *ch; 536 struct un_t *un; 537 538 if (!d) 539 return 0; 540 un = dev_get_drvdata(d); 541 if (!un || un->magic != DGNC_UNIT_MAGIC) 542 return 0; 543 ch = un->un_ch; 544 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 545 return 0; 546 bd = ch->ch_bd; 547 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 548 return 0; 549 if (bd->state != BOARD_READY) 550 return 0; 551 552 return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_iflag); 553 } 554 static DEVICE_ATTR(iflag, S_IRUSR, dgnc_tty_iflag_show, NULL); 555 556 557 static ssize_t dgnc_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf) 558 { 559 struct dgnc_board *bd; 560 struct channel_t *ch; 561 struct un_t *un; 562 563 if (!d) 564 return 0; 565 un = dev_get_drvdata(d); 566 if (!un || un->magic != DGNC_UNIT_MAGIC) 567 return 0; 568 ch = un->un_ch; 569 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 570 return 0; 571 bd = ch->ch_bd; 572 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 573 return 0; 574 if (bd->state != BOARD_READY) 575 return 0; 576 577 return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_cflag); 578 } 579 static DEVICE_ATTR(cflag, S_IRUSR, dgnc_tty_cflag_show, NULL); 580 581 582 static ssize_t dgnc_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf) 583 { 584 struct dgnc_board *bd; 585 struct channel_t *ch; 586 struct un_t *un; 587 588 if (!d) 589 return 0; 590 un = dev_get_drvdata(d); 591 if (!un || un->magic != DGNC_UNIT_MAGIC) 592 return 0; 593 ch = un->un_ch; 594 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 595 return 0; 596 bd = ch->ch_bd; 597 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 598 return 0; 599 if (bd->state != BOARD_READY) 600 return 0; 601 602 return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_oflag); 603 } 604 static DEVICE_ATTR(oflag, S_IRUSR, dgnc_tty_oflag_show, NULL); 605 606 607 static ssize_t dgnc_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf) 608 { 609 struct dgnc_board *bd; 610 struct channel_t *ch; 611 struct un_t *un; 612 613 if (!d) 614 return 0; 615 un = dev_get_drvdata(d); 616 if (!un || un->magic != DGNC_UNIT_MAGIC) 617 return 0; 618 ch = un->un_ch; 619 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 620 return 0; 621 bd = ch->ch_bd; 622 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 623 return 0; 624 if (bd->state != BOARD_READY) 625 return 0; 626 627 return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_lflag); 628 } 629 static DEVICE_ATTR(lflag, S_IRUSR, dgnc_tty_lflag_show, NULL); 630 631 632 static ssize_t dgnc_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf) 633 { 634 struct dgnc_board *bd; 635 struct channel_t *ch; 636 struct un_t *un; 637 638 if (!d) 639 return 0; 640 un = dev_get_drvdata(d); 641 if (!un || un->magic != DGNC_UNIT_MAGIC) 642 return 0; 643 ch = un->un_ch; 644 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 645 return 0; 646 bd = ch->ch_bd; 647 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 648 return 0; 649 if (bd->state != BOARD_READY) 650 return 0; 651 652 return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_digi.digi_flags); 653 } 654 static DEVICE_ATTR(digi_flag, S_IRUSR, dgnc_tty_digi_flag_show, NULL); 655 656 657 static ssize_t dgnc_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf) 658 { 659 struct dgnc_board *bd; 660 struct channel_t *ch; 661 struct un_t *un; 662 663 if (!d) 664 return 0; 665 un = dev_get_drvdata(d); 666 if (!un || un->magic != DGNC_UNIT_MAGIC) 667 return 0; 668 ch = un->un_ch; 669 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 670 return 0; 671 bd = ch->ch_bd; 672 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 673 return 0; 674 if (bd->state != BOARD_READY) 675 return 0; 676 677 return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_rxcount); 678 } 679 static DEVICE_ATTR(rxcount, S_IRUSR, dgnc_tty_rxcount_show, NULL); 680 681 682 static ssize_t dgnc_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf) 683 { 684 struct dgnc_board *bd; 685 struct channel_t *ch; 686 struct un_t *un; 687 688 if (!d) 689 return 0; 690 un = dev_get_drvdata(d); 691 if (!un || un->magic != DGNC_UNIT_MAGIC) 692 return 0; 693 ch = un->un_ch; 694 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 695 return 0; 696 bd = ch->ch_bd; 697 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 698 return 0; 699 if (bd->state != BOARD_READY) 700 return 0; 701 702 return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_txcount); 703 } 704 static DEVICE_ATTR(txcount, S_IRUSR, dgnc_tty_txcount_show, NULL); 705 706 707 static ssize_t dgnc_tty_name_show(struct device *d, struct device_attribute *attr, char *buf) 708 { 709 struct dgnc_board *bd; 710 struct channel_t *ch; 711 struct un_t *un; 712 713 if (!d) 714 return 0; 715 un = dev_get_drvdata(d); 716 if (!un || un->magic != DGNC_UNIT_MAGIC) 717 return 0; 718 ch = un->un_ch; 719 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 720 return 0; 721 bd = ch->ch_bd; 722 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 723 return 0; 724 if (bd->state != BOARD_READY) 725 return 0; 726 727 return snprintf(buf, PAGE_SIZE, "%sn%d%c\n", 728 (un->un_type == DGNC_PRINT) ? "pr" : "tty", 729 bd->boardnum + 1, 'a' + ch->ch_portnum); 730 } 731 static DEVICE_ATTR(custom_name, S_IRUSR, dgnc_tty_name_show, NULL); 732 733 734 static struct attribute *dgnc_sysfs_tty_entries[] = { 735 &dev_attr_state.attr, 736 &dev_attr_baud.attr, 737 &dev_attr_msignals.attr, 738 &dev_attr_iflag.attr, 739 &dev_attr_cflag.attr, 740 &dev_attr_oflag.attr, 741 &dev_attr_lflag.attr, 742 &dev_attr_digi_flag.attr, 743 &dev_attr_rxcount.attr, 744 &dev_attr_txcount.attr, 745 &dev_attr_custom_name.attr, 746 NULL 747 }; 748 749 750 static struct attribute_group dgnc_tty_attribute_group = { 751 .name = NULL, 752 .attrs = dgnc_sysfs_tty_entries, 753 }; 754 755 756 void dgnc_create_tty_sysfs(struct un_t *un, struct device *c) 757 { 758 int ret; 759 760 ret = sysfs_create_group(&c->kobj, &dgnc_tty_attribute_group); 761 if (ret) { 762 dev_err(c, "dgnc: failed to create sysfs tty device attributes.\n"); 763 sysfs_remove_group(&c->kobj, &dgnc_tty_attribute_group); 764 return; 765 } 766 767 dev_set_drvdata(c, un); 768 769 } 770 771 772 void dgnc_remove_tty_sysfs(struct device *c) 773 { 774 sysfs_remove_group(&c->kobj, &dgnc_tty_attribute_group); 775 } 776 777 778 779 780 781 782 /* LDV_COMMENT_BEGIN_MAIN */ 783 #ifdef LDV_MAIN6_sequence_infinite_withcheck_stateful 784 785 /*###########################################################################*/ 786 787 /*############## Driver Environment Generator 0.2 output ####################*/ 788 789 /*###########################################################################*/ 790 791 792 793 /* 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. */ 794 void ldv_check_final_state(void); 795 796 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */ 797 void ldv_check_return_value(int res); 798 799 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */ 800 void ldv_check_return_value_probe(int res); 801 802 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */ 803 void ldv_initialize(void); 804 805 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */ 806 void ldv_handler_precall(void); 807 808 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */ 809 int nondet_int(void); 810 811 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */ 812 int LDV_IN_INTERRUPT; 813 814 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */ 815 void ldv_main6_sequence_infinite_withcheck_stateful(void) { 816 817 818 819 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */ 820 /*============================= VARIABLE DECLARATION PART =============================*/ 821 822 823 824 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */ 825 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */ 826 /*============================= VARIABLE INITIALIZING PART =============================*/ 827 LDV_IN_INTERRUPT=1; 828 829 830 831 832 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */ 833 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */ 834 /*============================= FUNCTION CALL SECTION =============================*/ 835 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */ 836 ldv_initialize(); 837 838 while( nondet_int() 839 ) { 840 841 switch(nondet_int()) { 842 843 default: break; 844 845 } 846 847 } 848 849 ldv_module_exit: 850 851 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */ 852 ldv_final: ldv_check_final_state(); 853 854 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */ 855 return; 856 857 } 858 #endif 859 860 /* 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 9 // Provide model function prototypes before their usage. 10 11 void *ldv_create_class(void); 12 int ldv_register_class(void); 13 void ldv_unregister_class(void); 14 15 int ldv_register_chrdev_region(void); 16 void ldv_unregister_chrdev_region(void); 17 18 int ldv_register_usb_gadget(void); 19 void ldv_unregister_usb_gadget(void); 20 21 /* 22 * Copyright 2003 Digi International (www.digi.com) 23 * Scott H Kilau <Scott_Kilau at digi dot com> 24 * 25 * This program is free software; you can redistribute it and/or modify 26 * it under the terms of the GNU General Public License as published by 27 * the Free Software Foundation; either version 2, or (at your option) 28 * any later version. 29 * 30 * This program is distributed in the hope that it will be useful, 31 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the 32 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 33 * PURPOSE. See the GNU General Public License for more details. 34 * 35 * You should have received a copy of the GNU General Public License 36 * along with this program; if not, write to the Free Software 37 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 38 * 39 * 40 * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! 41 * 42 * This is shared code between Digi's CVS archive and the 43 * Linux Kernel sources. 44 * Changing the source just for reformatting needlessly breaks 45 * our CVS diff history. 46 * 47 * Send any bug fixes/changes to: Eng.Linux at digi dot com. 48 * Thank you. 49 */ 50 51 /************************************************************************ 52 * 53 * This file implements the tty driver functionality for the 54 * Neo and ClassicBoard PCI based product lines. 55 * 56 ************************************************************************ 57 * 58 */ 59 60 #include <linux/kernel.h> 61 #include <linux/sched.h> /* For jiffies, task states */ 62 #include <linux/interrupt.h> /* For tasklet and interrupt structs/defines */ 63 #include <linux/module.h> 64 #include <linux/ctype.h> 65 #include <linux/tty.h> 66 #include <linux/tty_flip.h> 67 #include <linux/serial_reg.h> 68 #include <linux/slab.h> 69 #include <linux/delay.h> /* For udelay */ 70 #include <asm/uaccess.h> /* For copy_from_user/copy_to_user */ 71 #include <linux/pci.h> 72 73 #include "dgnc_driver.h" 74 #include "dgnc_tty.h" 75 #include "dgnc_types.h" 76 #include "dgnc_trace.h" 77 #include "dgnc_neo.h" 78 #include "dgnc_cls.h" 79 #include "dpacompat.h" 80 #include "dgnc_sysfs.h" 81 82 #define init_MUTEX(sem) sema_init(sem, 1) 83 #define DECLARE_MUTEX(name) \ 84 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 85 86 /* 87 * internal variables 88 */ 89 static struct dgnc_board *dgnc_BoardsByMajor[256]; 90 static uchar *dgnc_TmpWriteBuf = NULL; 91 static DECLARE_MUTEX(dgnc_TmpWriteSem); 92 93 /* 94 * Default transparent print information. 95 */ 96 static struct digi_t dgnc_digi_init = { 97 .digi_flags = DIGI_COOK, /* Flags */ 98 .digi_maxcps = 100, /* Max CPS */ 99 .digi_maxchar = 50, /* Max chars in print queue */ 100 .digi_bufsize = 100, /* Printer buffer size */ 101 .digi_onlen = 4, /* size of printer on string */ 102 .digi_offlen = 4, /* size of printer off string */ 103 .digi_onstr = "\033[5i", /* ANSI printer on string ] */ 104 .digi_offstr = "\033[4i", /* ANSI printer off string ] */ 105 .digi_term = "ansi" /* default terminal type */ 106 }; 107 108 109 /* 110 * Define a local default termios struct. All ports will be created 111 * with this termios initially. 112 * 113 * This defines a raw port at 9600 baud, 8 data bits, no parity, 114 * 1 stop bit. 115 */ 116 static struct ktermios DgncDefaultTermios = 117 { 118 .c_iflag = (DEFAULT_IFLAGS), /* iflags */ 119 .c_oflag = (DEFAULT_OFLAGS), /* oflags */ 120 .c_cflag = (DEFAULT_CFLAGS), /* cflags */ 121 .c_lflag = (DEFAULT_LFLAGS), /* lflags */ 122 .c_cc = INIT_C_CC, 123 .c_line = 0, 124 }; 125 126 127 /* Our function prototypes */ 128 static int dgnc_tty_open(struct tty_struct *tty, struct file *file); 129 static void dgnc_tty_close(struct tty_struct *tty, struct file *file); 130 static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch); 131 static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); 132 static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo); 133 static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info); 134 static int dgnc_tty_write_room(struct tty_struct *tty); 135 static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c); 136 static int dgnc_tty_chars_in_buffer(struct tty_struct *tty); 137 static void dgnc_tty_start(struct tty_struct *tty); 138 static void dgnc_tty_stop(struct tty_struct *tty); 139 static void dgnc_tty_throttle(struct tty_struct *tty); 140 static void dgnc_tty_unthrottle(struct tty_struct *tty); 141 static void dgnc_tty_flush_chars(struct tty_struct *tty); 142 static void dgnc_tty_flush_buffer(struct tty_struct *tty); 143 static void dgnc_tty_hangup(struct tty_struct *tty); 144 static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value); 145 static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user *value); 146 static int dgnc_tty_tiocmget(struct tty_struct *tty); 147 static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear); 148 static int dgnc_tty_send_break(struct tty_struct *tty, int msec); 149 static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout); 150 static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count); 151 static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios); 152 static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch); 153 154 155 static const struct tty_operations dgnc_tty_ops = { 156 .open = dgnc_tty_open, 157 .close = dgnc_tty_close, 158 .write = dgnc_tty_write, 159 .write_room = dgnc_tty_write_room, 160 .flush_buffer = dgnc_tty_flush_buffer, 161 .chars_in_buffer = dgnc_tty_chars_in_buffer, 162 .flush_chars = dgnc_tty_flush_chars, 163 .ioctl = dgnc_tty_ioctl, 164 .set_termios = dgnc_tty_set_termios, 165 .stop = dgnc_tty_stop, 166 .start = dgnc_tty_start, 167 .throttle = dgnc_tty_throttle, 168 .unthrottle = dgnc_tty_unthrottle, 169 .hangup = dgnc_tty_hangup, 170 .put_char = dgnc_tty_put_char, 171 .tiocmget = dgnc_tty_tiocmget, 172 .tiocmset = dgnc_tty_tiocmset, 173 .break_ctl = dgnc_tty_send_break, 174 .wait_until_sent = dgnc_tty_wait_until_sent, 175 .send_xchar = dgnc_tty_send_xchar 176 }; 177 178 /************************************************************************ 179 * 180 * TTY Initialization/Cleanup Functions 181 * 182 ************************************************************************/ 183 184 /* 185 * dgnc_tty_preinit() 186 * 187 * Initialize any global tty related data before we download any boards. 188 */ 189 int dgnc_tty_preinit(void) 190 { 191 /* 192 * Allocate a buffer for doing the copy from user space to 193 * kernel space in dgnc_write(). We only use one buffer and 194 * control access to it with a semaphore. If we are paging, we 195 * are already in trouble so one buffer won't hurt much anyway. 196 * 197 * We are okay to sleep in the malloc, as this routine 198 * is only called during module load, (not in interrupt context), 199 * and with no locks held. 200 */ 201 dgnc_TmpWriteBuf = kmalloc(WRITEBUFLEN, GFP_KERNEL); 202 203 if (!dgnc_TmpWriteBuf) { 204 DPR_INIT(("unable to allocate tmp write buf")); 205 return -ENOMEM; 206 } 207 208 return 0; 209 } 210 211 212 /* 213 * dgnc_tty_register() 214 * 215 * Init the tty subsystem for this board. 216 */ 217 int dgnc_tty_register(struct dgnc_board *brd) 218 { 219 int rc = 0; 220 221 DPR_INIT(("tty_register start\n")); 222 223 memset(&brd->SerialDriver, 0, sizeof(brd->SerialDriver)); 224 memset(&brd->PrintDriver, 0, sizeof(brd->PrintDriver)); 225 226 brd->SerialDriver.magic = TTY_DRIVER_MAGIC; 227 228 snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum); 229 230 brd->SerialDriver.name = brd->SerialName; 231 brd->SerialDriver.name_base = 0; 232 brd->SerialDriver.major = 0; 233 brd->SerialDriver.minor_start = 0; 234 brd->SerialDriver.num = brd->maxports; 235 brd->SerialDriver.type = TTY_DRIVER_TYPE_SERIAL; 236 brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL; 237 brd->SerialDriver.init_termios = DgncDefaultTermios; 238 brd->SerialDriver.driver_name = DRVSTR; 239 brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); 240 241 /* 242 * The kernel wants space to store pointers to 243 * tty_struct's and termios's. 244 */ 245 brd->SerialDriver.ttys = kzalloc(brd->maxports * sizeof(*brd->SerialDriver.ttys), GFP_KERNEL); 246 if (!brd->SerialDriver.ttys) 247 return -ENOMEM; 248 249 kref_init(&brd->SerialDriver.kref); 250 brd->SerialDriver.termios = kzalloc(brd->maxports * sizeof(*brd->SerialDriver.termios), GFP_KERNEL); 251 if (!brd->SerialDriver.termios) 252 return -ENOMEM; 253 254 /* 255 * Entry points for driver. Called by the kernel from 256 * tty_io.c and n_tty.c. 257 */ 258 tty_set_operations(&brd->SerialDriver, &dgnc_tty_ops); 259 260 if (!brd->dgnc_Major_Serial_Registered) { 261 /* Register tty devices */ 262 rc = tty_register_driver(&brd->SerialDriver); 263 if (rc < 0) { 264 APR(("Can't register tty device (%d)\n", rc)); 265 return rc; 266 } 267 brd->dgnc_Major_Serial_Registered = TRUE; 268 } 269 270 /* 271 * If we're doing transparent print, we have to do all of the above 272 * again, separately so we don't get the LD confused about what major 273 * we are when we get into the dgnc_tty_open() routine. 274 */ 275 brd->PrintDriver.magic = TTY_DRIVER_MAGIC; 276 snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum); 277 278 brd->PrintDriver.name = brd->PrintName; 279 brd->PrintDriver.name_base = 0; 280 brd->PrintDriver.major = brd->SerialDriver.major; 281 brd->PrintDriver.minor_start = 0x80; 282 brd->PrintDriver.num = brd->maxports; 283 brd->PrintDriver.type = TTY_DRIVER_TYPE_SERIAL; 284 brd->PrintDriver.subtype = SERIAL_TYPE_NORMAL; 285 brd->PrintDriver.init_termios = DgncDefaultTermios; 286 brd->PrintDriver.driver_name = DRVSTR; 287 brd->PrintDriver.flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); 288 289 /* 290 * The kernel wants space to store pointers to 291 * tty_struct's and termios's. Must be separated from 292 * the Serial Driver so we don't get confused 293 */ 294 brd->PrintDriver.ttys = kzalloc(brd->maxports * sizeof(*brd->PrintDriver.ttys), GFP_KERNEL); 295 if (!brd->PrintDriver.ttys) 296 return -ENOMEM; 297 kref_init(&brd->PrintDriver.kref); 298 brd->PrintDriver.termios = kzalloc(brd->maxports * sizeof(*brd->PrintDriver.termios), GFP_KERNEL); 299 if (!brd->PrintDriver.termios) 300 return -ENOMEM; 301 302 /* 303 * Entry points for driver. Called by the kernel from 304 * tty_io.c and n_tty.c. 305 */ 306 tty_set_operations(&brd->PrintDriver, &dgnc_tty_ops); 307 308 if (!brd->dgnc_Major_TransparentPrint_Registered) { 309 /* Register Transparent Print devices */ 310 rc = tty_register_driver(&brd->PrintDriver); 311 if (rc < 0) { 312 APR(("Can't register Transparent Print device (%d)\n", rc)); 313 return rc; 314 } 315 brd->dgnc_Major_TransparentPrint_Registered = TRUE; 316 } 317 318 dgnc_BoardsByMajor[brd->SerialDriver.major] = brd; 319 brd->dgnc_Serial_Major = brd->SerialDriver.major; 320 brd->dgnc_TransparentPrint_Major = brd->PrintDriver.major; 321 322 DPR_INIT(("DGNC REGISTER TTY: MAJOR: %d\n", brd->SerialDriver.major)); 323 324 return rc; 325 } 326 327 328 /* 329 * dgnc_tty_init() 330 * 331 * Init the tty subsystem. Called once per board after board has been 332 * downloaded and init'ed. 333 */ 334 int dgnc_tty_init(struct dgnc_board *brd) 335 { 336 int i; 337 void __iomem *vaddr; 338 struct channel_t *ch; 339 340 if (!brd) 341 return -ENXIO; 342 343 DPR_INIT(("dgnc_tty_init start\n")); 344 345 /* 346 * Initialize board structure elements. 347 */ 348 349 vaddr = brd->re_map_membase; 350 351 brd->nasync = brd->maxports; 352 353 /* 354 * Allocate channel memory that might not have been allocated 355 * when the driver was first loaded. 356 */ 357 for (i = 0; i < brd->nasync; i++) { 358 if (!brd->channels[i]) { 359 360 /* 361 * Okay to malloc with GFP_KERNEL, we are not at 362 * interrupt context, and there are no locks held. 363 */ 364 brd->channels[i] = kzalloc(sizeof(*brd->channels[i]), GFP_KERNEL); 365 if (!brd->channels[i]) { 366 DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n", 367 __FILE__, __LINE__)); 368 } 369 } 370 } 371 372 ch = brd->channels[0]; 373 vaddr = brd->re_map_membase; 374 375 /* Set up channel variables */ 376 for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) { 377 378 if (!brd->channels[i]) 379 continue; 380 381 DGNC_SPINLOCK_INIT(ch->ch_lock); 382 383 /* Store all our magic numbers */ 384 ch->magic = DGNC_CHANNEL_MAGIC; 385 ch->ch_tun.magic = DGNC_UNIT_MAGIC; 386 ch->ch_tun.un_ch = ch; 387 ch->ch_tun.un_type = DGNC_SERIAL; 388 ch->ch_tun.un_dev = i; 389 390 ch->ch_pun.magic = DGNC_UNIT_MAGIC; 391 ch->ch_pun.un_ch = ch; 392 ch->ch_pun.un_type = DGNC_PRINT; 393 ch->ch_pun.un_dev = i + 128; 394 395 if (brd->bd_uart_offset == 0x200) 396 ch->ch_neo_uart = vaddr + (brd->bd_uart_offset * i); 397 else 398 ch->ch_cls_uart = vaddr + (brd->bd_uart_offset * i); 399 400 ch->ch_bd = brd; 401 ch->ch_portnum = i; 402 ch->ch_digi = dgnc_digi_init; 403 404 /* .25 second delay */ 405 ch->ch_close_delay = 250; 406 407 init_waitqueue_head(&ch->ch_flags_wait); 408 init_waitqueue_head(&ch->ch_tun.un_flags_wait); 409 init_waitqueue_head(&ch->ch_pun.un_flags_wait); 410 init_waitqueue_head(&ch->ch_sniff_wait); 411 412 { 413 struct device *classp; 414 classp = tty_register_device(&brd->SerialDriver, i, 415 &(ch->ch_bd->pdev->dev)); 416 ch->ch_tun.un_sysfs = classp; 417 dgnc_create_tty_sysfs(&ch->ch_tun, classp); 418 419 classp = tty_register_device(&brd->PrintDriver, i, 420 &(ch->ch_bd->pdev->dev)); 421 ch->ch_pun.un_sysfs = classp; 422 dgnc_create_tty_sysfs(&ch->ch_pun, classp); 423 } 424 425 } 426 427 DPR_INIT(("dgnc_tty_init finish\n")); 428 429 return 0; 430 } 431 432 433 /* 434 * dgnc_tty_post_uninit() 435 * 436 * UnInitialize any global tty related data. 437 */ 438 void dgnc_tty_post_uninit(void) 439 { 440 if (dgnc_TmpWriteBuf) { 441 kfree(dgnc_TmpWriteBuf); 442 dgnc_TmpWriteBuf = NULL; 443 } 444 } 445 446 447 /* 448 * dgnc_tty_uninit() 449 * 450 * Uninitialize the TTY portion of this driver. Free all memory and 451 * resources. 452 */ 453 void dgnc_tty_uninit(struct dgnc_board *brd) 454 { 455 int i = 0; 456 457 if (brd->dgnc_Major_Serial_Registered) { 458 dgnc_BoardsByMajor[brd->SerialDriver.major] = NULL; 459 brd->dgnc_Serial_Major = 0; 460 for (i = 0; i < brd->nasync; i++) { 461 dgnc_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs); 462 tty_unregister_device(&brd->SerialDriver, i); 463 } 464 tty_unregister_driver(&brd->SerialDriver); 465 brd->dgnc_Major_Serial_Registered = FALSE; 466 } 467 468 if (brd->dgnc_Major_TransparentPrint_Registered) { 469 dgnc_BoardsByMajor[brd->PrintDriver.major] = NULL; 470 brd->dgnc_TransparentPrint_Major = 0; 471 for (i = 0; i < brd->nasync; i++) { 472 dgnc_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs); 473 tty_unregister_device(&brd->PrintDriver, i); 474 } 475 tty_unregister_driver(&brd->PrintDriver); 476 brd->dgnc_Major_TransparentPrint_Registered = FALSE; 477 } 478 479 if (brd->SerialDriver.ttys) { 480 kfree(brd->SerialDriver.ttys); 481 brd->SerialDriver.ttys = NULL; 482 } 483 if (brd->PrintDriver.ttys) { 484 kfree(brd->PrintDriver.ttys); 485 brd->PrintDriver.ttys = NULL; 486 } 487 } 488 489 490 #define TMPBUFLEN (1024) 491 492 /* 493 * dgnc_sniff - Dump data out to the "sniff" buffer if the 494 * proc sniff file is opened... 495 */ 496 void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int len) 497 { 498 struct timeval tv; 499 int n; 500 int r; 501 int nbuf; 502 int i; 503 int tmpbuflen; 504 char tmpbuf[TMPBUFLEN]; 505 char *p = tmpbuf; 506 int too_much_data; 507 508 /* Leave if sniff not open */ 509 if (!(ch->ch_sniff_flags & SNIFF_OPEN)) 510 return; 511 512 do_gettimeofday(&tv); 513 514 /* Create our header for data dump */ 515 p += sprintf(p, "<%ld %ld><%s><", tv.tv_sec, tv.tv_usec, text); 516 tmpbuflen = p - tmpbuf; 517 518 do { 519 too_much_data = 0; 520 521 for (i = 0; i < len && tmpbuflen < (TMPBUFLEN - 4); i++) { 522 p += sprintf(p, "%02x ", *buf); 523 buf++; 524 tmpbuflen = p - tmpbuf; 525 } 526 527 if (tmpbuflen < (TMPBUFLEN - 4)) { 528 if (i > 0) 529 p += sprintf(p - 1, "%s\n", ">"); 530 else 531 p += sprintf(p, "%s\n", ">"); 532 } else { 533 too_much_data = 1; 534 len -= i; 535 } 536 537 nbuf = strlen(tmpbuf); 538 p = tmpbuf; 539 540 /* 541 * Loop while data remains. 542 */ 543 while (nbuf > 0 && ch->ch_sniff_buf) { 544 /* 545 * Determine the amount of available space left in the 546 * buffer. If there's none, wait until some appears. 547 */ 548 n = (ch->ch_sniff_out - ch->ch_sniff_in - 1) & SNIFF_MASK; 549 550 /* 551 * If there is no space left to write to in our sniff buffer, 552 * we have no choice but to drop the data. 553 * We *cannot* sleep here waiting for space, because this 554 * function was probably called by the interrupt/timer routines! 555 */ 556 if (n == 0) 557 return; 558 559 /* 560 * Copy as much data as will fit. 561 */ 562 563 if (n > nbuf) 564 n = nbuf; 565 566 r = SNIFF_MAX - ch->ch_sniff_in; 567 568 if (r <= n) { 569 memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, r); 570 571 n -= r; 572 ch->ch_sniff_in = 0; 573 p += r; 574 nbuf -= r; 575 } 576 577 memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, n); 578 579 ch->ch_sniff_in += n; 580 p += n; 581 nbuf -= n; 582 583 /* 584 * Wakeup any thread waiting for data 585 */ 586 if (ch->ch_sniff_flags & SNIFF_WAIT_DATA) { 587 ch->ch_sniff_flags &= ~SNIFF_WAIT_DATA; 588 wake_up_interruptible(&ch->ch_sniff_wait); 589 } 590 } 591 592 /* 593 * If the user sent us too much data to push into our tmpbuf, 594 * we need to keep looping around on all the data. 595 */ 596 if (too_much_data) { 597 p = tmpbuf; 598 tmpbuflen = 0; 599 } 600 601 } while (too_much_data); 602 } 603 604 605 /*======================================================================= 606 * 607 * dgnc_wmove - Write data to transmit queue. 608 * 609 * ch - Pointer to channel structure. 610 * buf - Poiter to characters to be moved. 611 * n - Number of characters to move. 612 * 613 *=======================================================================*/ 614 static void dgnc_wmove(struct channel_t *ch, char *buf, uint n) 615 { 616 int remain; 617 uint head; 618 619 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 620 return; 621 622 head = ch->ch_w_head & WQUEUEMASK; 623 624 /* 625 * If the write wraps over the top of the circular buffer, 626 * move the portion up to the wrap point, and reset the 627 * pointers to the bottom. 628 */ 629 remain = WQUEUESIZE - head; 630 631 if (n >= remain) { 632 n -= remain; 633 memcpy(ch->ch_wqueue + head, buf, remain); 634 head = 0; 635 buf += remain; 636 } 637 638 if (n > 0) { 639 /* 640 * Move rest of data. 641 */ 642 remain = n; 643 memcpy(ch->ch_wqueue + head, buf, remain); 644 head += remain; 645 } 646 647 head &= WQUEUEMASK; 648 ch->ch_w_head = head; 649 } 650 651 652 653 654 /*======================================================================= 655 * 656 * dgnc_input - Process received data. 657 * 658 * ch - Pointer to channel structure. 659 * 660 *=======================================================================*/ 661 void dgnc_input(struct channel_t *ch) 662 { 663 struct dgnc_board *bd; 664 struct tty_struct *tp; 665 struct tty_ldisc *ld; 666 uint rmask; 667 ushort head; 668 ushort tail; 669 int data_len; 670 ulong lock_flags; 671 int flip_len; 672 int len = 0; 673 int n = 0; 674 int s = 0; 675 int i = 0; 676 677 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 678 return; 679 680 tp = ch->ch_tun.un_tty; 681 682 bd = ch->ch_bd; 683 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 684 return; 685 686 DGNC_LOCK(ch->ch_lock, lock_flags); 687 688 /* 689 * Figure the number of characters in the buffer. 690 * Exit immediately if none. 691 */ 692 rmask = RQUEUEMASK; 693 head = ch->ch_r_head & rmask; 694 tail = ch->ch_r_tail & rmask; 695 data_len = (head - tail) & rmask; 696 697 if (data_len == 0) { 698 DGNC_UNLOCK(ch->ch_lock, lock_flags); 699 return; 700 } 701 702 DPR_READ(("dgnc_input start\n")); 703 704 /* 705 * If the device is not open, or CREAD is off, 706 * flush input data and return immediately. 707 */ 708 if (!tp || (tp->magic != TTY_MAGIC) || !(ch->ch_tun.un_flags & UN_ISOPEN) || 709 !(tp->termios.c_cflag & CREAD) || (ch->ch_tun.un_flags & UN_CLOSING)) { 710 711 DPR_READ(("input. dropping %d bytes on port %d...\n", data_len, ch->ch_portnum)); 712 DPR_READ(("input. tp: %p tp->magic: %x MAGIC:%x ch flags: %x\n", 713 tp, tp ? tp->magic : 0, TTY_MAGIC, ch->ch_tun.un_flags)); 714 715 ch->ch_r_head = tail; 716 717 /* Force queue flow control to be released, if needed */ 718 dgnc_check_queue_flow_control(ch); 719 720 DGNC_UNLOCK(ch->ch_lock, lock_flags); 721 return; 722 } 723 724 /* 725 * If we are throttled, simply don't read any data. 726 */ 727 if (ch->ch_flags & CH_FORCED_STOPI) { 728 DGNC_UNLOCK(ch->ch_lock, lock_flags); 729 DPR_READ(("Port %d throttled, not reading any data. head: %x tail: %x\n", 730 ch->ch_portnum, head, tail)); 731 return; 732 } 733 734 DPR_READ(("dgnc_input start 2\n")); 735 736 flip_len = TTY_FLIPBUF_SIZE; 737 738 /* Chop down the length, if needed */ 739 len = min(data_len, flip_len); 740 len = min(len, (N_TTY_BUF_SIZE - 1)); 741 742 ld = tty_ldisc_ref(tp); 743 744 #ifdef TTY_DONT_FLIP 745 /* 746 * If the DONT_FLIP flag is on, don't flush our buffer, and act 747 * like the ld doesn't have any space to put the data right now. 748 */ 749 if (test_bit(TTY_DONT_FLIP, &tp->flags)) 750 len = 0; 751 #endif 752 753 /* 754 * If we were unable to get a reference to the ld, 755 * don't flush our buffer, and act like the ld doesn't 756 * have any space to put the data right now. 757 */ 758 if (!ld) { 759 len = 0; 760 } else { 761 /* 762 * If ld doesn't have a pointer to a receive_buf function, 763 * flush the data, then act like the ld doesn't have any 764 * space to put the data right now. 765 */ 766 if (!ld->ops->receive_buf) { 767 ch->ch_r_head = ch->ch_r_tail; 768 len = 0; 769 } 770 } 771 772 if (len <= 0) { 773 DGNC_UNLOCK(ch->ch_lock, lock_flags); 774 if (ld) 775 tty_ldisc_deref(ld); 776 return; 777 } 778 779 /* 780 * The tty layer in the kernel has changed in 2.6.16+. 781 * 782 * The flip buffers in the tty structure are no longer exposed, 783 * and probably will be going away eventually. 784 * 785 * If we are completely raw, we don't need to go through a lot 786 * of the tty layers that exist. 787 * In this case, we take the shortest and fastest route we 788 * can to relay the data to the user. 789 * 790 * On the other hand, if we are not raw, we need to go through 791 * the new 2.6.16+ tty layer, which has its API more well defined. 792 */ 793 len = tty_buffer_request_room(tp->port, len); 794 n = len; 795 796 /* 797 * n now contains the most amount of data we can copy, 798 * bounded either by how much the Linux tty layer can handle, 799 * or the amount of data the card actually has pending... 800 */ 801 while (n) { 802 s = ((head >= tail) ? head : RQUEUESIZE) - tail; 803 s = min(s, n); 804 805 if (s <= 0) 806 break; 807 808 /* 809 * If conditions are such that ld needs to see all 810 * UART errors, we will have to walk each character 811 * and error byte and send them to the buffer one at 812 * a time. 813 */ 814 if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { 815 for (i = 0; i < s; i++) { 816 if (*(ch->ch_equeue + tail + i) & UART_LSR_BI) 817 tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_BREAK); 818 else if (*(ch->ch_equeue + tail + i) & UART_LSR_PE) 819 tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_PARITY); 820 else if (*(ch->ch_equeue + tail + i) & UART_LSR_FE) 821 tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_FRAME); 822 else 823 tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_NORMAL); 824 } 825 } else { 826 tty_insert_flip_string(tp->port, ch->ch_rqueue + tail, s); 827 } 828 829 dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s); 830 831 tail += s; 832 n -= s; 833 /* Flip queue if needed */ 834 tail &= rmask; 835 } 836 837 ch->ch_r_tail = tail & rmask; 838 ch->ch_e_tail = tail & rmask; 839 dgnc_check_queue_flow_control(ch); 840 DGNC_UNLOCK(ch->ch_lock, lock_flags); 841 842 /* Tell the tty layer its okay to "eat" the data now */ 843 tty_flip_buffer_push(tp->port); 844 845 if (ld) 846 tty_ldisc_deref(ld); 847 848 DPR_READ(("dgnc_input - finish\n")); 849 } 850 851 852 /************************************************************************ 853 * Determines when CARRIER changes state and takes appropriate 854 * action. 855 ************************************************************************/ 856 void dgnc_carrier(struct channel_t *ch) 857 { 858 struct dgnc_board *bd; 859 860 int virt_carrier = 0; 861 int phys_carrier = 0; 862 863 DPR_CARR(("dgnc_carrier called...\n")); 864 865 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 866 return; 867 868 bd = ch->ch_bd; 869 870 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 871 return; 872 873 if (ch->ch_mistat & UART_MSR_DCD) { 874 DPR_CARR(("mistat: %x D_CD: %x\n", ch->ch_mistat, ch->ch_mistat & UART_MSR_DCD)); 875 phys_carrier = 1; 876 } 877 878 if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) 879 virt_carrier = 1; 880 881 if (ch->ch_c_cflag & CLOCAL) 882 virt_carrier = 1; 883 884 DPR_CARR(("DCD: physical: %d virt: %d\n", phys_carrier, virt_carrier)); 885 886 /* 887 * Test for a VIRTUAL carrier transition to HIGH. 888 */ 889 if (((ch->ch_flags & CH_FCAR) == 0) && (virt_carrier == 1)) { 890 891 /* 892 * When carrier rises, wake any threads waiting 893 * for carrier in the open routine. 894 */ 895 896 DPR_CARR(("carrier: virt DCD rose\n")); 897 898 if (waitqueue_active(&(ch->ch_flags_wait))) 899 wake_up_interruptible(&ch->ch_flags_wait); 900 } 901 902 /* 903 * Test for a PHYSICAL carrier transition to HIGH. 904 */ 905 if (((ch->ch_flags & CH_CD) == 0) && (phys_carrier == 1)) { 906 907 /* 908 * When carrier rises, wake any threads waiting 909 * for carrier in the open routine. 910 */ 911 912 DPR_CARR(("carrier: physical DCD rose\n")); 913 914 if (waitqueue_active(&(ch->ch_flags_wait))) 915 wake_up_interruptible(&ch->ch_flags_wait); 916 } 917 918 /* 919 * Test for a PHYSICAL transition to low, so long as we aren't 920 * currently ignoring physical transitions (which is what "virtual 921 * carrier" indicates). 922 * 923 * The transition of the virtual carrier to low really doesn't 924 * matter... it really only means "ignore carrier state", not 925 * "make pretend that carrier is there". 926 */ 927 if ((virt_carrier == 0) && ((ch->ch_flags & CH_CD) != 0) && 928 (phys_carrier == 0)) 929 { 930 931 /* 932 * When carrier drops: 933 * 934 * Drop carrier on all open units. 935 * 936 * Flush queues, waking up any task waiting in the 937 * line discipline. 938 * 939 * Send a hangup to the control terminal. 940 * 941 * Enable all select calls. 942 */ 943 if (waitqueue_active(&(ch->ch_flags_wait))) 944 wake_up_interruptible(&ch->ch_flags_wait); 945 946 if (ch->ch_tun.un_open_count > 0) { 947 DPR_CARR(("Sending tty hangup\n")); 948 tty_hangup(ch->ch_tun.un_tty); 949 } 950 951 if (ch->ch_pun.un_open_count > 0) { 952 DPR_CARR(("Sending pr hangup\n")); 953 tty_hangup(ch->ch_pun.un_tty); 954 } 955 } 956 957 /* 958 * Make sure that our cached values reflect the current reality. 959 */ 960 if (virt_carrier == 1) 961 ch->ch_flags |= CH_FCAR; 962 else 963 ch->ch_flags &= ~CH_FCAR; 964 965 if (phys_carrier == 1) 966 ch->ch_flags |= CH_CD; 967 else 968 ch->ch_flags &= ~CH_CD; 969 } 970 971 /* 972 * Assign the custom baud rate to the channel structure 973 */ 974 static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate) 975 { 976 int testdiv; 977 int testrate_high; 978 int testrate_low; 979 int deltahigh; 980 int deltalow; 981 982 if (newrate <= 0) { 983 ch->ch_custom_speed = 0; 984 return; 985 } 986 987 /* 988 * Since the divisor is stored in a 16-bit integer, we make sure 989 * we don't allow any rates smaller than a 16-bit integer would allow. 990 * And of course, rates above the dividend won't fly. 991 */ 992 if (newrate && newrate < ((ch->ch_bd->bd_dividend / 0xFFFF) + 1)) 993 newrate = ((ch->ch_bd->bd_dividend / 0xFFFF) + 1); 994 995 if (newrate && newrate > ch->ch_bd->bd_dividend) 996 newrate = ch->ch_bd->bd_dividend; 997 998 if (newrate > 0) { 999 testdiv = ch->ch_bd->bd_dividend / newrate; 1000 1001 /* 1002 * If we try to figure out what rate the board would use 1003 * with the test divisor, it will be either equal or higher 1004 * than the requested baud rate. If we then determine the 1005 * rate with a divisor one higher, we will get the next lower 1006 * supported rate below the requested. 1007 */ 1008 testrate_high = ch->ch_bd->bd_dividend / testdiv; 1009 testrate_low = ch->ch_bd->bd_dividend / (testdiv + 1); 1010 1011 /* 1012 * If the rate for the requested divisor is correct, just 1013 * use it and be done. 1014 */ 1015 if (testrate_high != newrate) { 1016 /* 1017 * Otherwise, pick the rate that is closer (i.e. whichever rate 1018 * has a smaller delta). 1019 */ 1020 deltahigh = testrate_high - newrate; 1021 deltalow = newrate - testrate_low; 1022 1023 if (deltahigh < deltalow) 1024 newrate = testrate_high; 1025 else 1026 newrate = testrate_low; 1027 } 1028 } 1029 1030 ch->ch_custom_speed = newrate; 1031 } 1032 1033 1034 void dgnc_check_queue_flow_control(struct channel_t *ch) 1035 { 1036 int qleft = 0; 1037 1038 /* Store how much space we have left in the queue */ 1039 qleft = ch->ch_r_tail - ch->ch_r_head - 1; 1040 if (qleft < 0) 1041 qleft += RQUEUEMASK + 1; 1042 1043 /* 1044 * Check to see if we should enforce flow control on our queue because 1045 * the ld (or user) isn't reading data out of our queue fast enuf. 1046 * 1047 * NOTE: This is done based on what the current flow control of the 1048 * port is set for. 1049 * 1050 * 1) HWFLOW (RTS) - Turn off the UART's Receive interrupt. 1051 * This will cause the UART's FIFO to back up, and force 1052 * the RTS signal to be dropped. 1053 * 2) SWFLOW (IXOFF) - Keep trying to send a stop character to 1054 * the other side, in hopes it will stop sending data to us. 1055 * 3) NONE - Nothing we can do. We will simply drop any extra data 1056 * that gets sent into us when the queue fills up. 1057 */ 1058 if (qleft < 256) { 1059 /* HWFLOW */ 1060 if (ch->ch_digi.digi_flags & CTSPACE || ch->ch_c_cflag & CRTSCTS) { 1061 if (!(ch->ch_flags & CH_RECEIVER_OFF)) { 1062 ch->ch_bd->bd_ops->disable_receiver(ch); 1063 ch->ch_flags |= (CH_RECEIVER_OFF); 1064 DPR_READ(("Internal queue hit hilevel mark (%d)! Turning off interrupts.\n", 1065 qleft)); 1066 } 1067 } 1068 /* SWFLOW */ 1069 else if (ch->ch_c_iflag & IXOFF) { 1070 if (ch->ch_stops_sent <= MAX_STOPS_SENT) { 1071 ch->ch_bd->bd_ops->send_stop_character(ch); 1072 ch->ch_stops_sent++; 1073 DPR_READ(("Sending stop char! Times sent: %x\n", ch->ch_stops_sent)); 1074 } 1075 } 1076 /* No FLOW */ 1077 else { 1078 /* Empty... Can't do anything about the impending overflow... */ 1079 } 1080 } 1081 1082 /* 1083 * Check to see if we should unenforce flow control because 1084 * ld (or user) finally read enuf data out of our queue. 1085 * 1086 * NOTE: This is done based on what the current flow control of the 1087 * port is set for. 1088 * 1089 * 1) HWFLOW (RTS) - Turn back on the UART's Receive interrupt. 1090 * This will cause the UART's FIFO to raise RTS back up, 1091 * which will allow the other side to start sending data again. 1092 * 2) SWFLOW (IXOFF) - Send a start character to 1093 * the other side, so it will start sending data to us again. 1094 * 3) NONE - Do nothing. Since we didn't do anything to turn off the 1095 * other side, we don't need to do anything now. 1096 */ 1097 if (qleft > (RQUEUESIZE / 2)) { 1098 /* HWFLOW */ 1099 if (ch->ch_digi.digi_flags & RTSPACE || ch->ch_c_cflag & CRTSCTS) { 1100 if (ch->ch_flags & CH_RECEIVER_OFF) { 1101 ch->ch_bd->bd_ops->enable_receiver(ch); 1102 ch->ch_flags &= ~(CH_RECEIVER_OFF); 1103 DPR_READ(("Internal queue hit lowlevel mark (%d)! Turning on interrupts.\n", 1104 qleft)); 1105 } 1106 } 1107 /* SWFLOW */ 1108 else if (ch->ch_c_iflag & IXOFF && ch->ch_stops_sent) { 1109 ch->ch_stops_sent = 0; 1110 ch->ch_bd->bd_ops->send_start_character(ch); 1111 DPR_READ(("Sending start char!\n")); 1112 } 1113 /* No FLOW */ 1114 else { 1115 /* Nothing needed. */ 1116 } 1117 } 1118 } 1119 1120 1121 void dgnc_wakeup_writes(struct channel_t *ch) 1122 { 1123 int qlen = 0; 1124 ulong lock_flags; 1125 1126 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 1127 return; 1128 1129 DGNC_LOCK(ch->ch_lock, lock_flags); 1130 1131 /* 1132 * If channel now has space, wake up anyone waiting on the condition. 1133 */ 1134 qlen = ch->ch_w_head - ch->ch_w_tail; 1135 if (qlen < 0) 1136 qlen += WQUEUESIZE; 1137 1138 if (qlen >= (WQUEUESIZE - 256)) { 1139 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1140 return; 1141 } 1142 1143 if (ch->ch_tun.un_flags & UN_ISOPEN) { 1144 if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && 1145 ch->ch_tun.un_tty->ldisc->ops->write_wakeup) 1146 { 1147 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1148 (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); 1149 DGNC_LOCK(ch->ch_lock, lock_flags); 1150 } 1151 1152 wake_up_interruptible(&ch->ch_tun.un_tty->write_wait); 1153 1154 /* 1155 * If unit is set to wait until empty, check to make sure 1156 * the queue AND FIFO are both empty. 1157 */ 1158 if (ch->ch_tun.un_flags & UN_EMPTY) { 1159 if ((qlen == 0) && (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) { 1160 ch->ch_tun.un_flags &= ~(UN_EMPTY); 1161 1162 /* 1163 * If RTS Toggle mode is on, whenever 1164 * the queue and UART is empty, keep RTS low. 1165 */ 1166 if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) { 1167 ch->ch_mostat &= ~(UART_MCR_RTS); 1168 ch->ch_bd->bd_ops->assert_modem_signals(ch); 1169 } 1170 1171 /* 1172 * If DTR Toggle mode is on, whenever 1173 * the queue and UART is empty, keep DTR low. 1174 */ 1175 if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) { 1176 ch->ch_mostat &= ~(UART_MCR_DTR); 1177 ch->ch_bd->bd_ops->assert_modem_signals(ch); 1178 } 1179 } 1180 } 1181 1182 wake_up_interruptible(&ch->ch_tun.un_flags_wait); 1183 } 1184 1185 if (ch->ch_pun.un_flags & UN_ISOPEN) { 1186 if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && 1187 ch->ch_pun.un_tty->ldisc->ops->write_wakeup) 1188 { 1189 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1190 (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); 1191 DGNC_LOCK(ch->ch_lock, lock_flags); 1192 } 1193 1194 wake_up_interruptible(&ch->ch_pun.un_tty->write_wait); 1195 1196 /* 1197 * If unit is set to wait until empty, check to make sure 1198 * the queue AND FIFO are both empty. 1199 */ 1200 if (ch->ch_pun.un_flags & UN_EMPTY) { 1201 if ((qlen == 0) && (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) { 1202 ch->ch_pun.un_flags &= ~(UN_EMPTY); 1203 } 1204 } 1205 1206 wake_up_interruptible(&ch->ch_pun.un_flags_wait); 1207 } 1208 1209 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1210 } 1211 1212 1213 1214 /************************************************************************ 1215 * 1216 * TTY Entry points and helper functions 1217 * 1218 ************************************************************************/ 1219 1220 /* 1221 * dgnc_tty_open() 1222 * 1223 */ 1224 static int dgnc_tty_open(struct tty_struct *tty, struct file *file) 1225 { 1226 struct dgnc_board *brd; 1227 struct channel_t *ch; 1228 struct un_t *un; 1229 uint major = 0; 1230 uint minor = 0; 1231 int rc = 0; 1232 ulong lock_flags; 1233 1234 rc = 0; 1235 1236 major = MAJOR(tty_devnum(tty)); 1237 minor = MINOR(tty_devnum(tty)); 1238 1239 if (major > 255) 1240 return -ENXIO; 1241 1242 /* Get board pointer from our array of majors we have allocated */ 1243 brd = dgnc_BoardsByMajor[major]; 1244 if (!brd) 1245 return -ENXIO; 1246 1247 /* 1248 * If board is not yet up to a state of READY, go to 1249 * sleep waiting for it to happen or they cancel the open. 1250 */ 1251 rc = wait_event_interruptible(brd->state_wait, 1252 (brd->state & BOARD_READY)); 1253 1254 if (rc) 1255 return rc; 1256 1257 DGNC_LOCK(brd->bd_lock, lock_flags); 1258 1259 /* If opened device is greater than our number of ports, bail. */ 1260 if (PORT_NUM(minor) > brd->nasync) { 1261 DGNC_UNLOCK(brd->bd_lock, lock_flags); 1262 return -ENXIO; 1263 } 1264 1265 ch = brd->channels[PORT_NUM(minor)]; 1266 if (!ch) { 1267 DGNC_UNLOCK(brd->bd_lock, lock_flags); 1268 return -ENXIO; 1269 } 1270 1271 /* Drop board lock */ 1272 DGNC_UNLOCK(brd->bd_lock, lock_flags); 1273 1274 /* Grab channel lock */ 1275 DGNC_LOCK(ch->ch_lock, lock_flags); 1276 1277 /* Figure out our type */ 1278 if (!IS_PRINT(minor)) { 1279 un = &brd->channels[PORT_NUM(minor)]->ch_tun; 1280 un->un_type = DGNC_SERIAL; 1281 } else if (IS_PRINT(minor)) { 1282 un = &brd->channels[PORT_NUM(minor)]->ch_pun; 1283 un->un_type = DGNC_PRINT; 1284 } else { 1285 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1286 DPR_OPEN(("%d Unknown TYPE!\n", __LINE__)); 1287 return -ENXIO; 1288 } 1289 1290 /* 1291 * If the port is still in a previous open, and in a state 1292 * where we simply cannot safely keep going, wait until the 1293 * state clears. 1294 */ 1295 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1296 1297 rc = wait_event_interruptible(ch->ch_flags_wait, ((ch->ch_flags & CH_OPENING) == 0)); 1298 1299 /* If ret is non-zero, user ctrl-c'ed us */ 1300 if (rc) { 1301 DPR_OPEN(("%d User ctrl c'ed\n", __LINE__)); 1302 return -EINTR; 1303 } 1304 1305 /* 1306 * If either unit is in the middle of the fragile part of close, 1307 * we just cannot touch the channel safely. 1308 * Go to sleep, knowing that when the channel can be 1309 * touched safely, the close routine will signal the 1310 * ch_flags_wait to wake us back up. 1311 */ 1312 rc = wait_event_interruptible(ch->ch_flags_wait, 1313 (((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING) == 0)); 1314 1315 /* If ret is non-zero, user ctrl-c'ed us */ 1316 if (rc) { 1317 DPR_OPEN(("%d User ctrl c'ed\n", __LINE__)); 1318 return -EINTR; 1319 } 1320 1321 DGNC_LOCK(ch->ch_lock, lock_flags); 1322 1323 1324 /* Store our unit into driver_data, so we always have it available. */ 1325 tty->driver_data = un; 1326 1327 DPR_OPEN(("Open called. MAJOR: %d MINOR:%d PORT_NUM: %x unit: %p NAME: %s\n", 1328 MAJOR(tty_devnum(tty)), MINOR(tty_devnum(tty)), PORT_NUM(minor), un, brd->name)); 1329 1330 DPR_OPEN(("%d: tflag=%x pflag=%x\n", __LINE__, ch->ch_tun.un_flags, ch->ch_pun.un_flags)); 1331 1332 /* 1333 * Initialize tty's 1334 */ 1335 if (!(un->un_flags & UN_ISOPEN)) { 1336 /* Store important variables. */ 1337 un->un_tty = tty; 1338 1339 /* Maybe do something here to the TTY struct as well? */ 1340 } 1341 1342 1343 /* 1344 * Allocate channel buffers for read/write/error. 1345 * Set flag, so we don't get trounced on. 1346 */ 1347 ch->ch_flags |= (CH_OPENING); 1348 1349 /* Drop locks, as malloc with GFP_KERNEL can sleep */ 1350 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1351 1352 if (!ch->ch_rqueue) 1353 ch->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL); 1354 if (!ch->ch_equeue) 1355 ch->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL); 1356 if (!ch->ch_wqueue) 1357 ch->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL); 1358 1359 DGNC_LOCK(ch->ch_lock, lock_flags); 1360 1361 ch->ch_flags &= ~(CH_OPENING); 1362 wake_up_interruptible(&ch->ch_flags_wait); 1363 1364 /* 1365 * Initialize if neither terminal or printer is open. 1366 */ 1367 if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) { 1368 1369 DPR_OPEN(("dgnc_open: initializing channel in open...\n")); 1370 1371 /* 1372 * Flush input queues. 1373 */ 1374 ch->ch_r_head = ch->ch_r_tail = 0; 1375 ch->ch_e_head = ch->ch_e_tail = 0; 1376 ch->ch_w_head = ch->ch_w_tail = 0; 1377 1378 brd->bd_ops->flush_uart_write(ch); 1379 brd->bd_ops->flush_uart_read(ch); 1380 1381 ch->ch_flags = 0; 1382 ch->ch_cached_lsr = 0; 1383 ch->ch_stop_sending_break = 0; 1384 ch->ch_stops_sent = 0; 1385 1386 ch->ch_c_cflag = tty->termios.c_cflag; 1387 ch->ch_c_iflag = tty->termios.c_iflag; 1388 ch->ch_c_oflag = tty->termios.c_oflag; 1389 ch->ch_c_lflag = tty->termios.c_lflag; 1390 ch->ch_startc = tty->termios.c_cc[VSTART]; 1391 ch->ch_stopc = tty->termios.c_cc[VSTOP]; 1392 1393 /* 1394 * Bring up RTS and DTR... 1395 * Also handle RTS or DTR toggle if set. 1396 */ 1397 if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE)) 1398 ch->ch_mostat |= (UART_MCR_RTS); 1399 if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE)) 1400 ch->ch_mostat |= (UART_MCR_DTR); 1401 1402 /* Tell UART to init itself */ 1403 brd->bd_ops->uart_init(ch); 1404 } 1405 1406 /* 1407 * Run param in case we changed anything 1408 */ 1409 brd->bd_ops->param(tty); 1410 1411 dgnc_carrier(ch); 1412 1413 /* 1414 * follow protocol for opening port 1415 */ 1416 1417 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1418 1419 rc = dgnc_block_til_ready(tty, file, ch); 1420 1421 if (rc) 1422 DPR_OPEN(("dgnc_tty_open returning after dgnc_block_til_ready " 1423 "with %d\n", rc)); 1424 1425 /* No going back now, increment our unit and channel counters */ 1426 DGNC_LOCK(ch->ch_lock, lock_flags); 1427 ch->ch_open_count++; 1428 un->un_open_count++; 1429 un->un_flags |= (UN_ISOPEN); 1430 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1431 1432 DPR_OPEN(("dgnc_tty_open finished\n")); 1433 return rc; 1434 } 1435 1436 1437 /* 1438 * dgnc_block_til_ready() 1439 * 1440 * Wait for DCD, if needed. 1441 */ 1442 static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch) 1443 { 1444 int retval = 0; 1445 struct un_t *un = NULL; 1446 ulong lock_flags; 1447 uint old_flags = 0; 1448 int sleep_on_un_flags = 0; 1449 1450 if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGNC_CHANNEL_MAGIC) { 1451 return -ENXIO; 1452 } 1453 1454 un = tty->driver_data; 1455 if (!un || un->magic != DGNC_UNIT_MAGIC) 1456 return -ENXIO; 1457 1458 DPR_OPEN(("dgnc_block_til_ready - before block.\n")); 1459 1460 DGNC_LOCK(ch->ch_lock, lock_flags); 1461 1462 ch->ch_wopen++; 1463 1464 /* Loop forever */ 1465 while (1) { 1466 1467 sleep_on_un_flags = 0; 1468 1469 /* 1470 * If board has failed somehow during our sleep, bail with error. 1471 */ 1472 if (ch->ch_bd->state == BOARD_FAILED) { 1473 retval = -ENXIO; 1474 break; 1475 } 1476 1477 /* If tty was hung up, break out of loop and set error. */ 1478 if (tty_hung_up_p(file)) { 1479 retval = -EAGAIN; 1480 break; 1481 } 1482 1483 /* 1484 * If either unit is in the middle of the fragile part of close, 1485 * we just cannot touch the channel safely. 1486 * Go back to sleep, knowing that when the channel can be 1487 * touched safely, the close routine will signal the 1488 * ch_wait_flags to wake us back up. 1489 */ 1490 if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING)) { 1491 1492 /* 1493 * Our conditions to leave cleanly and happily: 1494 * 1) NONBLOCKING on the tty is set. 1495 * 2) CLOCAL is set. 1496 * 3) DCD (fake or real) is active. 1497 */ 1498 1499 if (file->f_flags & O_NONBLOCK) 1500 break; 1501 1502 if (tty->flags & (1 << TTY_IO_ERROR)) { 1503 retval = -EIO; 1504 break; 1505 } 1506 1507 if (ch->ch_flags & CH_CD) { 1508 DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); 1509 break; 1510 } 1511 1512 if (ch->ch_flags & CH_FCAR) { 1513 DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); 1514 break; 1515 } 1516 } else { 1517 sleep_on_un_flags = 1; 1518 } 1519 1520 /* 1521 * If there is a signal pending, the user probably 1522 * interrupted (ctrl-c) us. 1523 * Leave loop with error set. 1524 */ 1525 if (signal_pending(current)) { 1526 DPR_OPEN(("%d: signal pending...\n", __LINE__)); 1527 retval = -ERESTARTSYS; 1528 break; 1529 } 1530 1531 DPR_OPEN(("dgnc_block_til_ready - blocking.\n")); 1532 1533 /* 1534 * Store the flags before we let go of channel lock 1535 */ 1536 if (sleep_on_un_flags) 1537 old_flags = ch->ch_tun.un_flags | ch->ch_pun.un_flags; 1538 else 1539 old_flags = ch->ch_flags; 1540 1541 /* 1542 * Let go of channel lock before calling schedule. 1543 * Our poller will get any FEP events and wake us up when DCD 1544 * eventually goes active. 1545 */ 1546 1547 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1548 1549 DPR_OPEN(("Going to sleep on %s flags...\n", 1550 (sleep_on_un_flags ? "un" : "ch"))); 1551 1552 /* 1553 * Wait for something in the flags to change from the current value. 1554 */ 1555 if (sleep_on_un_flags) 1556 retval = wait_event_interruptible(un->un_flags_wait, 1557 (old_flags != (ch->ch_tun.un_flags | ch->ch_pun.un_flags))); 1558 else 1559 retval = wait_event_interruptible(ch->ch_flags_wait, 1560 (old_flags != ch->ch_flags)); 1561 1562 DPR_OPEN(("After sleep... retval: %x\n", retval)); 1563 1564 /* 1565 * We got woken up for some reason. 1566 * Before looping around, grab our channel lock. 1567 */ 1568 DGNC_LOCK(ch->ch_lock, lock_flags); 1569 } 1570 1571 ch->ch_wopen--; 1572 1573 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1574 1575 DPR_OPEN(("dgnc_block_til_ready - after blocking.\n")); 1576 1577 if (retval) { 1578 DPR_OPEN(("dgnc_block_til_ready - done. error. retval: %x\n", retval)); 1579 return retval; 1580 } 1581 1582 DPR_OPEN(("dgnc_block_til_ready - done no error. jiffies: %lu\n", jiffies)); 1583 1584 return 0; 1585 } 1586 1587 1588 /* 1589 * dgnc_tty_hangup() 1590 * 1591 * Hangup the port. Like a close, but don't wait for output to drain. 1592 */ 1593 static void dgnc_tty_hangup(struct tty_struct *tty) 1594 { 1595 struct un_t *un; 1596 1597 if (!tty || tty->magic != TTY_MAGIC) 1598 return; 1599 1600 un = tty->driver_data; 1601 if (!un || un->magic != DGNC_UNIT_MAGIC) 1602 return; 1603 1604 DPR_CLOSE(("dgnc_hangup called. ch->ch_open_count: %d un->un_open_count: %d\n", 1605 un->un_ch->ch_open_count, un->un_open_count)); 1606 1607 /* flush the transmit queues */ 1608 dgnc_tty_flush_buffer(tty); 1609 1610 DPR_CLOSE(("dgnc_hangup finished. ch->ch_open_count: %d un->un_open_count: %d\n", 1611 un->un_ch->ch_open_count, un->un_open_count)); 1612 } 1613 1614 1615 /* 1616 * dgnc_tty_close() 1617 * 1618 */ 1619 static void dgnc_tty_close(struct tty_struct *tty, struct file *file) 1620 { 1621 struct ktermios *ts; 1622 struct dgnc_board *bd; 1623 struct channel_t *ch; 1624 struct un_t *un; 1625 ulong lock_flags; 1626 int rc = 0; 1627 1628 if (!tty || tty->magic != TTY_MAGIC) 1629 return; 1630 1631 un = tty->driver_data; 1632 if (!un || un->magic != DGNC_UNIT_MAGIC) 1633 return; 1634 1635 ch = un->un_ch; 1636 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 1637 return; 1638 1639 bd = ch->ch_bd; 1640 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 1641 return; 1642 1643 ts = &tty->termios; 1644 1645 DPR_CLOSE(("Close called\n")); 1646 1647 DGNC_LOCK(ch->ch_lock, lock_flags); 1648 1649 /* 1650 * Determine if this is the last close or not - and if we agree about 1651 * which type of close it is with the Line Discipline 1652 */ 1653 if ((tty->count == 1) && (un->un_open_count != 1)) { 1654 /* 1655 * Uh, oh. tty->count is 1, which means that the tty 1656 * structure will be freed. un_open_count should always 1657 * be one in these conditions. If it's greater than 1658 * one, we've got real problems, since it means the 1659 * serial port won't be shutdown. 1660 */ 1661 APR(("tty->count is 1, un open count is %d\n", un->un_open_count)); 1662 un->un_open_count = 1; 1663 } 1664 1665 if (--un->un_open_count < 0) { 1666 APR(("bad serial port open count of %d\n", un->un_open_count)); 1667 un->un_open_count = 0; 1668 } 1669 1670 ch->ch_open_count--; 1671 1672 if (ch->ch_open_count && un->un_open_count) { 1673 DPR_CLOSE(("dgnc_tty_close: not last close ch: %d un:%d\n", 1674 ch->ch_open_count, un->un_open_count)); 1675 1676 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1677 return; 1678 } 1679 1680 /* OK, its the last close on the unit */ 1681 DPR_CLOSE(("dgnc_tty_close - last close on unit procedures\n")); 1682 1683 un->un_flags |= UN_CLOSING; 1684 1685 tty->closing = 1; 1686 1687 1688 /* 1689 * Only officially close channel if count is 0 and 1690 * DIGI_PRINTER bit is not set. 1691 */ 1692 if ((ch->ch_open_count == 0) && !(ch->ch_digi.digi_flags & DIGI_PRINTER)) { 1693 1694 ch->ch_flags &= ~(CH_STOPI | CH_FORCED_STOPI); 1695 1696 /* 1697 * turn off print device when closing print device. 1698 */ 1699 if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { 1700 dgnc_wmove(ch, ch->ch_digi.digi_offstr, 1701 (int) ch->ch_digi.digi_offlen); 1702 ch->ch_flags &= ~CH_PRON; 1703 } 1704 1705 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1706 /* wait for output to drain */ 1707 /* This will also return if we take an interrupt */ 1708 1709 DPR_CLOSE(("Calling wait_for_drain\n")); 1710 rc = bd->bd_ops->drain(tty, 0); 1711 1712 DPR_CLOSE(("After calling wait_for_drain\n")); 1713 1714 if (rc) 1715 DPR_BASIC(("dgnc_tty_close - bad return: %d ", rc)); 1716 1717 dgnc_tty_flush_buffer(tty); 1718 tty_ldisc_flush(tty); 1719 1720 DGNC_LOCK(ch->ch_lock, lock_flags); 1721 1722 tty->closing = 0; 1723 1724 /* 1725 * If we have HUPCL set, lower DTR and RTS 1726 */ 1727 if (ch->ch_c_cflag & HUPCL) { 1728 DPR_CLOSE(("Close. HUPCL set, dropping DTR/RTS\n")); 1729 1730 /* Drop RTS/DTR */ 1731 ch->ch_mostat &= ~(UART_MCR_DTR | UART_MCR_RTS); 1732 bd->bd_ops->assert_modem_signals(ch); 1733 1734 /* 1735 * Go to sleep to ensure RTS/DTR 1736 * have been dropped for modems to see it. 1737 */ 1738 if (ch->ch_close_delay) { 1739 DPR_CLOSE(("Close. Sleeping for RTS/DTR drop\n")); 1740 1741 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1742 dgnc_ms_sleep(ch->ch_close_delay); 1743 DGNC_LOCK(ch->ch_lock, lock_flags); 1744 1745 DPR_CLOSE(("Close. After sleeping for RTS/DTR drop\n")); 1746 } 1747 } 1748 1749 ch->ch_old_baud = 0; 1750 1751 /* Turn off UART interrupts for this port */ 1752 ch->ch_bd->bd_ops->uart_off(ch); 1753 } else { 1754 /* 1755 * turn off print device when closing print device. 1756 */ 1757 if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { 1758 dgnc_wmove(ch, ch->ch_digi.digi_offstr, 1759 (int) ch->ch_digi.digi_offlen); 1760 ch->ch_flags &= ~CH_PRON; 1761 } 1762 } 1763 1764 un->un_tty = NULL; 1765 un->un_flags &= ~(UN_ISOPEN | UN_CLOSING); 1766 1767 DPR_CLOSE(("Close. Doing wakeups\n")); 1768 wake_up_interruptible(&ch->ch_flags_wait); 1769 wake_up_interruptible(&un->un_flags_wait); 1770 1771 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1772 1773 DPR_BASIC(("dgnc_tty_close - complete\n")); 1774 } 1775 1776 1777 /* 1778 * dgnc_tty_chars_in_buffer() 1779 * 1780 * Return number of characters that have not been transmitted yet. 1781 * 1782 * This routine is used by the line discipline to determine if there 1783 * is data waiting to be transmitted/drained/flushed or not. 1784 */ 1785 static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) 1786 { 1787 struct channel_t *ch = NULL; 1788 struct un_t *un = NULL; 1789 ushort thead; 1790 ushort ttail; 1791 uint tmask; 1792 uint chars = 0; 1793 ulong lock_flags = 0; 1794 1795 if (tty == NULL) 1796 return 0; 1797 1798 un = tty->driver_data; 1799 if (!un || un->magic != DGNC_UNIT_MAGIC) 1800 return 0; 1801 1802 ch = un->un_ch; 1803 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 1804 return 0; 1805 1806 DGNC_LOCK(ch->ch_lock, lock_flags); 1807 1808 tmask = WQUEUEMASK; 1809 thead = ch->ch_w_head & tmask; 1810 ttail = ch->ch_w_tail & tmask; 1811 1812 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1813 1814 if (ttail == thead) { 1815 chars = 0; 1816 } else { 1817 if (thead >= ttail) 1818 chars = thead - ttail; 1819 else 1820 chars = thead - ttail + WQUEUESIZE; 1821 } 1822 1823 DPR_WRITE(("dgnc_tty_chars_in_buffer. Port: %x - %d (head: %d tail: %d)\n", 1824 ch->ch_portnum, chars, thead, ttail)); 1825 1826 return chars; 1827 } 1828 1829 1830 /* 1831 * dgnc_maxcps_room 1832 * 1833 * Reduces bytes_available to the max number of characters 1834 * that can be sent currently given the maxcps value, and 1835 * returns the new bytes_available. This only affects printer 1836 * output. 1837 */ 1838 static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) 1839 { 1840 struct channel_t *ch = NULL; 1841 struct un_t *un = NULL; 1842 1843 if (!tty) 1844 return bytes_available; 1845 1846 un = tty->driver_data; 1847 if (!un || un->magic != DGNC_UNIT_MAGIC) 1848 return bytes_available; 1849 1850 ch = un->un_ch; 1851 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 1852 return bytes_available; 1853 1854 /* 1855 * If its not the Transparent print device, return 1856 * the full data amount. 1857 */ 1858 if (un->un_type != DGNC_PRINT) 1859 return bytes_available; 1860 1861 if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0) { 1862 int cps_limit = 0; 1863 unsigned long current_time = jiffies; 1864 unsigned long buffer_time = current_time + 1865 (HZ * ch->ch_digi.digi_bufsize) / ch->ch_digi.digi_maxcps; 1866 1867 if (ch->ch_cpstime < current_time) { 1868 /* buffer is empty */ 1869 ch->ch_cpstime = current_time; /* reset ch_cpstime */ 1870 cps_limit = ch->ch_digi.digi_bufsize; 1871 } else if (ch->ch_cpstime < buffer_time) { 1872 /* still room in the buffer */ 1873 cps_limit = ((buffer_time - ch->ch_cpstime) * ch->ch_digi.digi_maxcps) / HZ; 1874 } else { 1875 /* no room in the buffer */ 1876 cps_limit = 0; 1877 } 1878 1879 bytes_available = min(cps_limit, bytes_available); 1880 } 1881 1882 return bytes_available; 1883 } 1884 1885 1886 /* 1887 * dgnc_tty_write_room() 1888 * 1889 * Return space available in Tx buffer 1890 */ 1891 static int dgnc_tty_write_room(struct tty_struct *tty) 1892 { 1893 struct channel_t *ch = NULL; 1894 struct un_t *un = NULL; 1895 ushort head; 1896 ushort tail; 1897 ushort tmask; 1898 int ret = 0; 1899 ulong lock_flags = 0; 1900 1901 if (tty == NULL || dgnc_TmpWriteBuf == NULL) 1902 return 0; 1903 1904 un = tty->driver_data; 1905 if (!un || un->magic != DGNC_UNIT_MAGIC) 1906 return 0; 1907 1908 ch = un->un_ch; 1909 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 1910 return 0; 1911 1912 DGNC_LOCK(ch->ch_lock, lock_flags); 1913 1914 tmask = WQUEUEMASK; 1915 head = (ch->ch_w_head) & tmask; 1916 tail = (ch->ch_w_tail) & tmask; 1917 1918 ret = tail - head - 1; 1919 if (ret < 0) 1920 ret += WQUEUESIZE; 1921 1922 /* Limit printer to maxcps */ 1923 ret = dgnc_maxcps_room(tty, ret); 1924 1925 /* 1926 * If we are printer device, leave space for 1927 * possibly both the on and off strings. 1928 */ 1929 if (un->un_type == DGNC_PRINT) { 1930 if (!(ch->ch_flags & CH_PRON)) 1931 ret -= ch->ch_digi.digi_onlen; 1932 ret -= ch->ch_digi.digi_offlen; 1933 } else { 1934 if (ch->ch_flags & CH_PRON) 1935 ret -= ch->ch_digi.digi_offlen; 1936 } 1937 1938 if (ret < 0) 1939 ret = 0; 1940 1941 DGNC_UNLOCK(ch->ch_lock, lock_flags); 1942 1943 DPR_WRITE(("dgnc_tty_write_room - %d tail: %d head: %d\n", ret, tail, head)); 1944 1945 return ret; 1946 } 1947 1948 1949 /* 1950 * dgnc_tty_put_char() 1951 * 1952 * Put a character into ch->ch_buf 1953 * 1954 * - used by the line discipline for OPOST processing 1955 */ 1956 static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c) 1957 { 1958 /* 1959 * Simply call tty_write. 1960 */ 1961 DPR_WRITE(("dgnc_tty_put_char called\n")); 1962 dgnc_tty_write(tty, &c, 1); 1963 return 1; 1964 } 1965 1966 1967 /* 1968 * dgnc_tty_write() 1969 * 1970 * Take data from the user or kernel and send it out to the FEP. 1971 * In here exists all the Transparent Print magic as well. 1972 */ 1973 static int dgnc_tty_write(struct tty_struct *tty, 1974 const unsigned char *buf, int count) 1975 { 1976 struct channel_t *ch = NULL; 1977 struct un_t *un = NULL; 1978 int bufcount = 0, n = 0; 1979 int orig_count = 0; 1980 ulong lock_flags; 1981 ushort head; 1982 ushort tail; 1983 ushort tmask; 1984 uint remain; 1985 int from_user = 0; 1986 1987 if (tty == NULL || dgnc_TmpWriteBuf == NULL) 1988 return 0; 1989 1990 un = tty->driver_data; 1991 if (!un || un->magic != DGNC_UNIT_MAGIC) 1992 return 0; 1993 1994 ch = un->un_ch; 1995 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 1996 return 0; 1997 1998 if (!count) 1999 return 0; 2000 2001 DPR_WRITE(("dgnc_tty_write: Port: %x tty=%p user=%d len=%d\n", 2002 ch->ch_portnum, tty, from_user, count)); 2003 2004 /* 2005 * Store original amount of characters passed in. 2006 * This helps to figure out if we should ask the FEP 2007 * to send us an event when it has more space available. 2008 */ 2009 orig_count = count; 2010 2011 DGNC_LOCK(ch->ch_lock, lock_flags); 2012 2013 /* Get our space available for the channel from the board */ 2014 tmask = WQUEUEMASK; 2015 head = (ch->ch_w_head) & tmask; 2016 tail = (ch->ch_w_tail) & tmask; 2017 2018 bufcount = tail - head - 1; 2019 if (bufcount < 0) 2020 bufcount += WQUEUESIZE; 2021 2022 DPR_WRITE(("%d: bufcount: %x count: %x tail: %x head: %x tmask: %x\n", 2023 __LINE__, bufcount, count, tail, head, tmask)); 2024 2025 /* 2026 * Limit printer output to maxcps overall, with bursts allowed 2027 * up to bufsize characters. 2028 */ 2029 bufcount = dgnc_maxcps_room(tty, bufcount); 2030 2031 /* 2032 * Take minimum of what the user wants to send, and the 2033 * space available in the FEP buffer. 2034 */ 2035 count = min(count, bufcount); 2036 2037 /* 2038 * Bail if no space left. 2039 */ 2040 if (count <= 0) { 2041 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2042 return 0; 2043 } 2044 2045 /* 2046 * Output the printer ON string, if we are in terminal mode, but 2047 * need to be in printer mode. 2048 */ 2049 if ((un->un_type == DGNC_PRINT) && !(ch->ch_flags & CH_PRON)) { 2050 dgnc_wmove(ch, ch->ch_digi.digi_onstr, 2051 (int) ch->ch_digi.digi_onlen); 2052 head = (ch->ch_w_head) & tmask; 2053 ch->ch_flags |= CH_PRON; 2054 } 2055 2056 /* 2057 * On the other hand, output the printer OFF string, if we are 2058 * currently in printer mode, but need to output to the terminal. 2059 */ 2060 if ((un->un_type != DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { 2061 dgnc_wmove(ch, ch->ch_digi.digi_offstr, 2062 (int) ch->ch_digi.digi_offlen); 2063 head = (ch->ch_w_head) & tmask; 2064 ch->ch_flags &= ~CH_PRON; 2065 } 2066 2067 /* 2068 * If there is nothing left to copy, or I can't handle any more data, leave. 2069 */ 2070 if (count <= 0) { 2071 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2072 return 0; 2073 } 2074 2075 if (from_user) { 2076 2077 count = min(count, WRITEBUFLEN); 2078 2079 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2080 2081 /* 2082 * If data is coming from user space, copy it into a temporary 2083 * buffer so we don't get swapped out while doing the copy to 2084 * the board. 2085 */ 2086 /* we're allowed to block if it's from_user */ 2087 if (down_interruptible(&dgnc_TmpWriteSem)) 2088 return -EINTR; 2089 2090 /* 2091 * copy_from_user() returns the number 2092 * of bytes that could *NOT* be copied. 2093 */ 2094 count -= copy_from_user(dgnc_TmpWriteBuf, (const uchar __user *) buf, count); 2095 2096 if (!count) { 2097 up(&dgnc_TmpWriteSem); 2098 return -EFAULT; 2099 } 2100 2101 DGNC_LOCK(ch->ch_lock, lock_flags); 2102 2103 buf = dgnc_TmpWriteBuf; 2104 2105 } 2106 2107 n = count; 2108 2109 /* 2110 * If the write wraps over the top of the circular buffer, 2111 * move the portion up to the wrap point, and reset the 2112 * pointers to the bottom. 2113 */ 2114 remain = WQUEUESIZE - head; 2115 2116 if (n >= remain) { 2117 n -= remain; 2118 memcpy(ch->ch_wqueue + head, buf, remain); 2119 dgnc_sniff_nowait_nolock(ch, "USER WRITE", ch->ch_wqueue + head, remain); 2120 head = 0; 2121 buf += remain; 2122 } 2123 2124 if (n > 0) { 2125 /* 2126 * Move rest of data. 2127 */ 2128 remain = n; 2129 memcpy(ch->ch_wqueue + head, buf, remain); 2130 dgnc_sniff_nowait_nolock(ch, "USER WRITE", ch->ch_wqueue + head, remain); 2131 head += remain; 2132 } 2133 2134 if (count) { 2135 head &= tmask; 2136 ch->ch_w_head = head; 2137 } 2138 2139 #if 0 2140 /* 2141 * If this is the print device, and the 2142 * printer is still on, we need to turn it 2143 * off before going idle. 2144 */ 2145 if (count == orig_count) { 2146 if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { 2147 head &= tmask; 2148 ch->ch_w_head = head; 2149 dgnc_wmove(ch, ch->ch_digi.digi_offstr, 2150 (int) ch->ch_digi.digi_offlen); 2151 head = (ch->ch_w_head) & tmask; 2152 ch->ch_flags &= ~CH_PRON; 2153 } 2154 } 2155 #endif 2156 2157 /* Update printer buffer empty time. */ 2158 if ((un->un_type == DGNC_PRINT) && (ch->ch_digi.digi_maxcps > 0) 2159 && (ch->ch_digi.digi_bufsize > 0)) { 2160 ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps; 2161 } 2162 2163 if (from_user) { 2164 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2165 up(&dgnc_TmpWriteSem); 2166 } else { 2167 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2168 } 2169 2170 DPR_WRITE(("Write finished - Write %d bytes of %d.\n", count, orig_count)); 2171 2172 if (count) { 2173 /* 2174 * Channel lock is grabbed and then released 2175 * inside this routine. 2176 */ 2177 ch->ch_bd->bd_ops->copy_data_from_queue_to_uart(ch); 2178 } 2179 2180 return count; 2181 } 2182 2183 2184 /* 2185 * Return modem signals to ld. 2186 */ 2187 2188 static int dgnc_tty_tiocmget(struct tty_struct *tty) 2189 { 2190 struct channel_t *ch; 2191 struct un_t *un; 2192 int result = -EIO; 2193 uchar mstat = 0; 2194 ulong lock_flags; 2195 2196 if (!tty || tty->magic != TTY_MAGIC) 2197 return result; 2198 2199 un = tty->driver_data; 2200 if (!un || un->magic != DGNC_UNIT_MAGIC) 2201 return result; 2202 2203 ch = un->un_ch; 2204 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2205 return result; 2206 2207 DPR_IOCTL(("dgnc_tty_tiocmget start\n")); 2208 2209 DGNC_LOCK(ch->ch_lock, lock_flags); 2210 2211 mstat = (ch->ch_mostat | ch->ch_mistat); 2212 2213 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2214 2215 result = 0; 2216 2217 if (mstat & UART_MCR_DTR) 2218 result |= TIOCM_DTR; 2219 if (mstat & UART_MCR_RTS) 2220 result |= TIOCM_RTS; 2221 if (mstat & UART_MSR_CTS) 2222 result |= TIOCM_CTS; 2223 if (mstat & UART_MSR_DSR) 2224 result |= TIOCM_DSR; 2225 if (mstat & UART_MSR_RI) 2226 result |= TIOCM_RI; 2227 if (mstat & UART_MSR_DCD) 2228 result |= TIOCM_CD; 2229 2230 DPR_IOCTL(("dgnc_tty_tiocmget finish\n")); 2231 2232 return result; 2233 } 2234 2235 2236 /* 2237 * dgnc_tty_tiocmset() 2238 * 2239 * Set modem signals, called by ld. 2240 */ 2241 2242 static int dgnc_tty_tiocmset(struct tty_struct *tty, 2243 unsigned int set, unsigned int clear) 2244 { 2245 struct dgnc_board *bd; 2246 struct channel_t *ch; 2247 struct un_t *un; 2248 int ret = -EIO; 2249 ulong lock_flags; 2250 2251 if (!tty || tty->magic != TTY_MAGIC) 2252 return ret; 2253 2254 un = tty->driver_data; 2255 if (!un || un->magic != DGNC_UNIT_MAGIC) 2256 return ret; 2257 2258 ch = un->un_ch; 2259 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2260 return ret; 2261 2262 bd = ch->ch_bd; 2263 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 2264 return ret; 2265 2266 DPR_IOCTL(("dgnc_tty_tiocmset start\n")); 2267 2268 2269 DGNC_LOCK(ch->ch_lock, lock_flags); 2270 2271 if (set & TIOCM_RTS) 2272 ch->ch_mostat |= UART_MCR_RTS; 2273 2274 if (set & TIOCM_DTR) 2275 ch->ch_mostat |= UART_MCR_DTR; 2276 2277 if (clear & TIOCM_RTS) 2278 ch->ch_mostat &= ~(UART_MCR_RTS); 2279 2280 if (clear & TIOCM_DTR) 2281 ch->ch_mostat &= ~(UART_MCR_DTR); 2282 2283 ch->ch_bd->bd_ops->assert_modem_signals(ch); 2284 2285 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2286 2287 DPR_IOCTL(("dgnc_tty_tiocmset finish\n")); 2288 2289 return 0; 2290 } 2291 2292 2293 /* 2294 * dgnc_tty_send_break() 2295 * 2296 * Send a Break, called by ld. 2297 */ 2298 static int dgnc_tty_send_break(struct tty_struct *tty, int msec) 2299 { 2300 struct dgnc_board *bd; 2301 struct channel_t *ch; 2302 struct un_t *un; 2303 int ret = -EIO; 2304 ulong lock_flags; 2305 2306 if (!tty || tty->magic != TTY_MAGIC) 2307 return ret; 2308 2309 un = tty->driver_data; 2310 if (!un || un->magic != DGNC_UNIT_MAGIC) 2311 return ret; 2312 2313 ch = un->un_ch; 2314 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2315 return ret; 2316 2317 bd = ch->ch_bd; 2318 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 2319 return ret; 2320 2321 switch (msec) { 2322 case -1: 2323 msec = 0xFFFF; 2324 break; 2325 case 0: 2326 msec = 0; 2327 break; 2328 default: 2329 break; 2330 } 2331 2332 DPR_IOCTL(("dgnc_tty_send_break start 1. %lx\n", jiffies)); 2333 2334 DGNC_LOCK(ch->ch_lock, lock_flags); 2335 2336 ch->ch_bd->bd_ops->send_break(ch, msec); 2337 2338 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2339 2340 DPR_IOCTL(("dgnc_tty_send_break finish\n")); 2341 2342 return 0; 2343 2344 } 2345 2346 2347 /* 2348 * dgnc_tty_wait_until_sent() 2349 * 2350 * wait until data has been transmitted, called by ld. 2351 */ 2352 static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout) 2353 { 2354 struct dgnc_board *bd; 2355 struct channel_t *ch; 2356 struct un_t *un; 2357 int rc; 2358 2359 if (!tty || tty->magic != TTY_MAGIC) 2360 return; 2361 2362 un = tty->driver_data; 2363 if (!un || un->magic != DGNC_UNIT_MAGIC) 2364 return; 2365 2366 ch = un->un_ch; 2367 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2368 return; 2369 2370 bd = ch->ch_bd; 2371 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 2372 return; 2373 2374 rc = bd->bd_ops->drain(tty, 0); 2375 if (rc) { 2376 DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); 2377 return; 2378 } 2379 return; 2380 } 2381 2382 2383 /* 2384 * dgnc_send_xchar() 2385 * 2386 * send a high priority character, called by ld. 2387 */ 2388 static void dgnc_tty_send_xchar(struct tty_struct *tty, char c) 2389 { 2390 struct dgnc_board *bd; 2391 struct channel_t *ch; 2392 struct un_t *un; 2393 ulong lock_flags; 2394 2395 if (!tty || tty->magic != TTY_MAGIC) 2396 return; 2397 2398 un = tty->driver_data; 2399 if (!un || un->magic != DGNC_UNIT_MAGIC) 2400 return; 2401 2402 ch = un->un_ch; 2403 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2404 return; 2405 2406 bd = ch->ch_bd; 2407 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 2408 return; 2409 2410 DPR_IOCTL(("dgnc_tty_send_xchar start\n")); 2411 printk("dgnc_tty_send_xchar start\n"); 2412 2413 DGNC_LOCK(ch->ch_lock, lock_flags); 2414 bd->bd_ops->send_immediate_char(ch, c); 2415 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2416 2417 DPR_IOCTL(("dgnc_tty_send_xchar finish\n")); 2418 printk("dgnc_tty_send_xchar finish\n"); 2419 return; 2420 } 2421 2422 2423 2424 2425 /* 2426 * Return modem signals to ld. 2427 */ 2428 static inline int dgnc_get_mstat(struct channel_t *ch) 2429 { 2430 unsigned char mstat; 2431 int result = -EIO; 2432 ulong lock_flags; 2433 2434 DPR_IOCTL(("dgnc_getmstat start\n")); 2435 2436 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2437 return -ENXIO; 2438 2439 DGNC_LOCK(ch->ch_lock, lock_flags); 2440 2441 mstat = (ch->ch_mostat | ch->ch_mistat); 2442 2443 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2444 2445 result = 0; 2446 2447 if (mstat & UART_MCR_DTR) 2448 result |= TIOCM_DTR; 2449 if (mstat & UART_MCR_RTS) 2450 result |= TIOCM_RTS; 2451 if (mstat & UART_MSR_CTS) 2452 result |= TIOCM_CTS; 2453 if (mstat & UART_MSR_DSR) 2454 result |= TIOCM_DSR; 2455 if (mstat & UART_MSR_RI) 2456 result |= TIOCM_RI; 2457 if (mstat & UART_MSR_DCD) 2458 result |= TIOCM_CD; 2459 2460 DPR_IOCTL(("dgnc_getmstat finish\n")); 2461 2462 return result; 2463 } 2464 2465 2466 2467 /* 2468 * Return modem signals to ld. 2469 */ 2470 static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user *value) 2471 { 2472 int result; 2473 int rc; 2474 2475 DPR_IOCTL(("dgnc_get_modem_info start\n")); 2476 2477 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2478 return -ENXIO; 2479 2480 result = dgnc_get_mstat(ch); 2481 2482 if (result < 0) 2483 return -ENXIO; 2484 2485 rc = put_user(result, value); 2486 2487 DPR_IOCTL(("dgnc_get_modem_info finish\n")); 2488 return rc; 2489 } 2490 2491 2492 /* 2493 * dgnc_set_modem_info() 2494 * 2495 * Set modem signals, called by ld. 2496 */ 2497 static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value) 2498 { 2499 struct dgnc_board *bd; 2500 struct channel_t *ch; 2501 struct un_t *un; 2502 int ret = -ENXIO; 2503 unsigned int arg = 0; 2504 ulong lock_flags; 2505 2506 if (!tty || tty->magic != TTY_MAGIC) 2507 return ret; 2508 2509 un = tty->driver_data; 2510 if (!un || un->magic != DGNC_UNIT_MAGIC) 2511 return ret; 2512 2513 ch = un->un_ch; 2514 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2515 return ret; 2516 2517 bd = ch->ch_bd; 2518 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 2519 return ret; 2520 2521 ret = 0; 2522 2523 DPR_IOCTL(("dgnc_set_modem_info() start\n")); 2524 2525 ret = get_user(arg, value); 2526 if (ret) 2527 return ret; 2528 2529 switch (command) { 2530 case TIOCMBIS: 2531 if (arg & TIOCM_RTS) 2532 ch->ch_mostat |= UART_MCR_RTS; 2533 2534 if (arg & TIOCM_DTR) 2535 ch->ch_mostat |= UART_MCR_DTR; 2536 2537 break; 2538 2539 case TIOCMBIC: 2540 if (arg & TIOCM_RTS) 2541 ch->ch_mostat &= ~(UART_MCR_RTS); 2542 2543 if (arg & TIOCM_DTR) 2544 ch->ch_mostat &= ~(UART_MCR_DTR); 2545 2546 break; 2547 2548 case TIOCMSET: 2549 2550 if (arg & TIOCM_RTS) 2551 ch->ch_mostat |= UART_MCR_RTS; 2552 else 2553 ch->ch_mostat &= ~(UART_MCR_RTS); 2554 2555 if (arg & TIOCM_DTR) 2556 ch->ch_mostat |= UART_MCR_DTR; 2557 else 2558 ch->ch_mostat &= ~(UART_MCR_DTR); 2559 2560 break; 2561 2562 default: 2563 return -EINVAL; 2564 } 2565 2566 DGNC_LOCK(ch->ch_lock, lock_flags); 2567 2568 ch->ch_bd->bd_ops->assert_modem_signals(ch); 2569 2570 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2571 2572 DPR_IOCTL(("dgnc_set_modem_info finish\n")); 2573 2574 return 0; 2575 } 2576 2577 2578 /* 2579 * dgnc_tty_digigeta() 2580 * 2581 * Ioctl to get the information for ditty. 2582 * 2583 * 2584 * 2585 */ 2586 static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo) 2587 { 2588 struct channel_t *ch; 2589 struct un_t *un; 2590 struct digi_t tmp; 2591 ulong lock_flags; 2592 2593 if (!retinfo) 2594 return -EFAULT; 2595 2596 if (!tty || tty->magic != TTY_MAGIC) 2597 return -EFAULT; 2598 2599 un = tty->driver_data; 2600 if (!un || un->magic != DGNC_UNIT_MAGIC) 2601 return -EFAULT; 2602 2603 ch = un->un_ch; 2604 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2605 return -EFAULT; 2606 2607 memset(&tmp, 0, sizeof(tmp)); 2608 2609 DGNC_LOCK(ch->ch_lock, lock_flags); 2610 memcpy(&tmp, &ch->ch_digi, sizeof(tmp)); 2611 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2612 2613 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 2614 return -EFAULT; 2615 2616 return 0; 2617 } 2618 2619 2620 /* 2621 * dgnc_tty_digiseta() 2622 * 2623 * Ioctl to set the information for ditty. 2624 * 2625 * 2626 * 2627 */ 2628 static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info) 2629 { 2630 struct dgnc_board *bd; 2631 struct channel_t *ch; 2632 struct un_t *un; 2633 struct digi_t new_digi; 2634 ulong lock_flags; 2635 2636 DPR_IOCTL(("DIGI_SETA start\n")); 2637 2638 if (!tty || tty->magic != TTY_MAGIC) 2639 return -EFAULT; 2640 2641 un = tty->driver_data; 2642 if (!un || un->magic != DGNC_UNIT_MAGIC) 2643 return -EFAULT; 2644 2645 ch = un->un_ch; 2646 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2647 return -EFAULT; 2648 2649 bd = ch->ch_bd; 2650 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 2651 return -EFAULT; 2652 2653 if (copy_from_user(&new_digi, new_info, sizeof(new_digi))) { 2654 DPR_IOCTL(("DIGI_SETA failed copy_from_user\n")); 2655 return -EFAULT; 2656 } 2657 2658 DGNC_LOCK(ch->ch_lock, lock_flags); 2659 2660 /* 2661 * Handle transistions to and from RTS Toggle. 2662 */ 2663 if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) && (new_digi.digi_flags & DIGI_RTS_TOGGLE)) 2664 ch->ch_mostat &= ~(UART_MCR_RTS); 2665 if ((ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) && !(new_digi.digi_flags & DIGI_RTS_TOGGLE)) 2666 ch->ch_mostat |= (UART_MCR_RTS); 2667 2668 /* 2669 * Handle transistions to and from DTR Toggle. 2670 */ 2671 if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && (new_digi.digi_flags & DIGI_DTR_TOGGLE)) 2672 ch->ch_mostat &= ~(UART_MCR_DTR); 2673 if ((ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && !(new_digi.digi_flags & DIGI_DTR_TOGGLE)) 2674 ch->ch_mostat |= (UART_MCR_DTR); 2675 2676 memcpy(&ch->ch_digi, &new_digi, sizeof(new_digi)); 2677 2678 if (ch->ch_digi.digi_maxcps < 1) 2679 ch->ch_digi.digi_maxcps = 1; 2680 2681 if (ch->ch_digi.digi_maxcps > 10000) 2682 ch->ch_digi.digi_maxcps = 10000; 2683 2684 if (ch->ch_digi.digi_bufsize < 10) 2685 ch->ch_digi.digi_bufsize = 10; 2686 2687 if (ch->ch_digi.digi_maxchar < 1) 2688 ch->ch_digi.digi_maxchar = 1; 2689 2690 if (ch->ch_digi.digi_maxchar > ch->ch_digi.digi_bufsize) 2691 ch->ch_digi.digi_maxchar = ch->ch_digi.digi_bufsize; 2692 2693 if (ch->ch_digi.digi_onlen > DIGI_PLEN) 2694 ch->ch_digi.digi_onlen = DIGI_PLEN; 2695 2696 if (ch->ch_digi.digi_offlen > DIGI_PLEN) 2697 ch->ch_digi.digi_offlen = DIGI_PLEN; 2698 2699 ch->ch_bd->bd_ops->param(tty); 2700 2701 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2702 2703 DPR_IOCTL(("DIGI_SETA finish\n")); 2704 2705 return 0; 2706 } 2707 2708 2709 /* 2710 * dgnc_set_termios() 2711 */ 2712 static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 2713 { 2714 struct dgnc_board *bd; 2715 struct channel_t *ch; 2716 struct un_t *un; 2717 unsigned long lock_flags; 2718 2719 if (!tty || tty->magic != TTY_MAGIC) 2720 return; 2721 2722 un = tty->driver_data; 2723 if (!un || un->magic != DGNC_UNIT_MAGIC) 2724 return; 2725 2726 ch = un->un_ch; 2727 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2728 return; 2729 2730 bd = ch->ch_bd; 2731 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 2732 return; 2733 2734 DGNC_LOCK(ch->ch_lock, lock_flags); 2735 2736 ch->ch_c_cflag = tty->termios.c_cflag; 2737 ch->ch_c_iflag = tty->termios.c_iflag; 2738 ch->ch_c_oflag = tty->termios.c_oflag; 2739 ch->ch_c_lflag = tty->termios.c_lflag; 2740 ch->ch_startc = tty->termios.c_cc[VSTART]; 2741 ch->ch_stopc = tty->termios.c_cc[VSTOP]; 2742 2743 ch->ch_bd->bd_ops->param(tty); 2744 dgnc_carrier(ch); 2745 2746 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2747 } 2748 2749 2750 static void dgnc_tty_throttle(struct tty_struct *tty) 2751 { 2752 struct channel_t *ch; 2753 struct un_t *un; 2754 ulong lock_flags = 0; 2755 2756 if (!tty || tty->magic != TTY_MAGIC) 2757 return; 2758 2759 un = tty->driver_data; 2760 if (!un || un->magic != DGNC_UNIT_MAGIC) 2761 return; 2762 2763 ch = un->un_ch; 2764 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2765 return; 2766 2767 DPR_IOCTL(("dgnc_tty_throttle start\n")); 2768 2769 DGNC_LOCK(ch->ch_lock, lock_flags); 2770 2771 ch->ch_flags |= (CH_FORCED_STOPI); 2772 2773 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2774 2775 DPR_IOCTL(("dgnc_tty_throttle finish\n")); 2776 } 2777 2778 2779 static void dgnc_tty_unthrottle(struct tty_struct *tty) 2780 { 2781 struct channel_t *ch; 2782 struct un_t *un; 2783 ulong lock_flags; 2784 2785 if (!tty || tty->magic != TTY_MAGIC) 2786 return; 2787 2788 un = tty->driver_data; 2789 if (!un || un->magic != DGNC_UNIT_MAGIC) 2790 return; 2791 2792 ch = un->un_ch; 2793 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2794 return; 2795 2796 DPR_IOCTL(("dgnc_tty_unthrottle start\n")); 2797 2798 DGNC_LOCK(ch->ch_lock, lock_flags); 2799 2800 ch->ch_flags &= ~(CH_FORCED_STOPI); 2801 2802 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2803 2804 DPR_IOCTL(("dgnc_tty_unthrottle finish\n")); 2805 } 2806 2807 2808 static void dgnc_tty_start(struct tty_struct *tty) 2809 { 2810 struct dgnc_board *bd; 2811 struct channel_t *ch; 2812 struct un_t *un; 2813 ulong lock_flags; 2814 2815 if (!tty || tty->magic != TTY_MAGIC) 2816 return; 2817 2818 un = tty->driver_data; 2819 if (!un || un->magic != DGNC_UNIT_MAGIC) 2820 return; 2821 2822 ch = un->un_ch; 2823 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2824 return; 2825 2826 bd = ch->ch_bd; 2827 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 2828 return; 2829 2830 DPR_IOCTL(("dgcn_tty_start start\n")); 2831 2832 DGNC_LOCK(ch->ch_lock, lock_flags); 2833 2834 ch->ch_flags &= ~(CH_FORCED_STOP); 2835 2836 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2837 2838 DPR_IOCTL(("dgnc_tty_start finish\n")); 2839 } 2840 2841 2842 static void dgnc_tty_stop(struct tty_struct *tty) 2843 { 2844 struct dgnc_board *bd; 2845 struct channel_t *ch; 2846 struct un_t *un; 2847 ulong lock_flags; 2848 2849 if (!tty || tty->magic != TTY_MAGIC) 2850 return; 2851 2852 un = tty->driver_data; 2853 if (!un || un->magic != DGNC_UNIT_MAGIC) 2854 return; 2855 2856 ch = un->un_ch; 2857 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2858 return; 2859 2860 bd = ch->ch_bd; 2861 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 2862 return; 2863 2864 DPR_IOCTL(("dgnc_tty_stop start\n")); 2865 2866 DGNC_LOCK(ch->ch_lock, lock_flags); 2867 2868 ch->ch_flags |= (CH_FORCED_STOP); 2869 2870 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2871 2872 DPR_IOCTL(("dgnc_tty_stop finish\n")); 2873 } 2874 2875 2876 /* 2877 * dgnc_tty_flush_chars() 2878 * 2879 * Flush the cook buffer 2880 * 2881 * Note to self, and any other poor souls who venture here: 2882 * 2883 * flush in this case DOES NOT mean dispose of the data. 2884 * instead, it means "stop buffering and send it if you 2885 * haven't already." Just guess how I figured that out... SRW 2-Jun-98 2886 * 2887 * It is also always called in interrupt context - JAR 8-Sept-99 2888 */ 2889 static void dgnc_tty_flush_chars(struct tty_struct *tty) 2890 { 2891 struct dgnc_board *bd; 2892 struct channel_t *ch; 2893 struct un_t *un; 2894 ulong lock_flags; 2895 2896 if (!tty || tty->magic != TTY_MAGIC) 2897 return; 2898 2899 un = tty->driver_data; 2900 if (!un || un->magic != DGNC_UNIT_MAGIC) 2901 return; 2902 2903 ch = un->un_ch; 2904 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2905 return; 2906 2907 bd = ch->ch_bd; 2908 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 2909 return; 2910 2911 DPR_IOCTL(("dgnc_tty_flush_chars start\n")); 2912 2913 DGNC_LOCK(ch->ch_lock, lock_flags); 2914 2915 /* Do something maybe here */ 2916 2917 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2918 2919 DPR_IOCTL(("dgnc_tty_flush_chars finish\n")); 2920 } 2921 2922 2923 2924 /* 2925 * dgnc_tty_flush_buffer() 2926 * 2927 * Flush Tx buffer (make in == out) 2928 */ 2929 static void dgnc_tty_flush_buffer(struct tty_struct *tty) 2930 { 2931 struct channel_t *ch; 2932 struct un_t *un; 2933 ulong lock_flags; 2934 2935 if (!tty || tty->magic != TTY_MAGIC) 2936 return; 2937 2938 un = tty->driver_data; 2939 if (!un || un->magic != DGNC_UNIT_MAGIC) 2940 return; 2941 2942 ch = un->un_ch; 2943 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 2944 return; 2945 2946 DPR_IOCTL(("dgnc_tty_flush_buffer on port: %d start\n", ch->ch_portnum)); 2947 2948 DGNC_LOCK(ch->ch_lock, lock_flags); 2949 2950 ch->ch_flags &= ~CH_STOP; 2951 2952 /* Flush our write queue */ 2953 ch->ch_w_head = ch->ch_w_tail; 2954 2955 /* Flush UARTs transmit FIFO */ 2956 ch->ch_bd->bd_ops->flush_uart_write(ch); 2957 2958 if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { 2959 ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); 2960 wake_up_interruptible(&ch->ch_tun.un_flags_wait); 2961 } 2962 if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { 2963 ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); 2964 wake_up_interruptible(&ch->ch_pun.un_flags_wait); 2965 } 2966 2967 DGNC_UNLOCK(ch->ch_lock, lock_flags); 2968 2969 DPR_IOCTL(("dgnc_tty_flush_buffer finish\n")); 2970 } 2971 2972 2973 2974 /***************************************************************************** 2975 * 2976 * The IOCTL function and all of its helpers 2977 * 2978 *****************************************************************************/ 2979 2980 /* 2981 * dgnc_tty_ioctl() 2982 * 2983 * The usual assortment of ioctl's 2984 */ 2985 static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, 2986 unsigned long arg) 2987 { 2988 struct dgnc_board *bd; 2989 struct channel_t *ch; 2990 struct un_t *un; 2991 int rc; 2992 ulong lock_flags; 2993 void __user *uarg = (void __user *) arg; 2994 2995 if (!tty || tty->magic != TTY_MAGIC) 2996 return -ENODEV; 2997 2998 un = tty->driver_data; 2999 if (!un || un->magic != DGNC_UNIT_MAGIC) 3000 return -ENODEV; 3001 3002 ch = un->un_ch; 3003 if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 3004 return -ENODEV; 3005 3006 bd = ch->ch_bd; 3007 if (!bd || bd->magic != DGNC_BOARD_MAGIC) 3008 return -ENODEV; 3009 3010 DPR_IOCTL(("dgnc_tty_ioctl start on port %d - cmd %s (%x), arg %lx\n", 3011 ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); 3012 3013 DGNC_LOCK(ch->ch_lock, lock_flags); 3014 3015 if (un->un_open_count <= 0) { 3016 DPR_BASIC(("dgnc_tty_ioctl - unit not open.\n")); 3017 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3018 return -EIO; 3019 } 3020 3021 switch (cmd) { 3022 3023 /* Here are all the standard ioctl's that we MUST implement */ 3024 3025 case TCSBRK: 3026 /* 3027 * TCSBRK is SVID version: non-zero arg --> no break 3028 * this behaviour is exploited by tcdrain(). 3029 * 3030 * According to POSIX.1 spec (7.2.2.1.2) breaks should be 3031 * between 0.25 and 0.5 seconds so we'll ask for something 3032 * in the middle: 0.375 seconds. 3033 */ 3034 rc = tty_check_change(tty); 3035 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3036 if (rc) 3037 return rc; 3038 3039 rc = ch->ch_bd->bd_ops->drain(tty, 0); 3040 3041 if (rc) { 3042 DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); 3043 return -EINTR; 3044 } 3045 3046 DGNC_LOCK(ch->ch_lock, lock_flags); 3047 3048 if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) { 3049 ch->ch_bd->bd_ops->send_break(ch, 250); 3050 } 3051 3052 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3053 3054 DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", 3055 ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); 3056 3057 return 0; 3058 3059 3060 case TCSBRKP: 3061 /* support for POSIX tcsendbreak() 3062 * According to POSIX.1 spec (7.2.2.1.2) breaks should be 3063 * between 0.25 and 0.5 seconds so we'll ask for something 3064 * in the middle: 0.375 seconds. 3065 */ 3066 rc = tty_check_change(tty); 3067 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3068 if (rc) 3069 return rc; 3070 3071 rc = ch->ch_bd->bd_ops->drain(tty, 0); 3072 if (rc) { 3073 DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); 3074 return -EINTR; 3075 } 3076 3077 DGNC_LOCK(ch->ch_lock, lock_flags); 3078 3079 ch->ch_bd->bd_ops->send_break(ch, 250); 3080 3081 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3082 3083 DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", 3084 ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); 3085 3086 return 0; 3087 3088 case TIOCSBRK: 3089 rc = tty_check_change(tty); 3090 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3091 if (rc) 3092 return rc; 3093 3094 rc = ch->ch_bd->bd_ops->drain(tty, 0); 3095 if (rc) { 3096 DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); 3097 return -EINTR; 3098 } 3099 3100 DGNC_LOCK(ch->ch_lock, lock_flags); 3101 3102 ch->ch_bd->bd_ops->send_break(ch, 250); 3103 3104 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3105 3106 DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", 3107 ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); 3108 3109 return 0; 3110 3111 case TIOCCBRK: 3112 /* Do Nothing */ 3113 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3114 return 0; 3115 3116 case TIOCGSOFTCAR: 3117 3118 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3119 3120 rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg); 3121 return rc; 3122 3123 case TIOCSSOFTCAR: 3124 3125 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3126 rc = get_user(arg, (unsigned long __user *) arg); 3127 if (rc) 3128 return rc; 3129 3130 DGNC_LOCK(ch->ch_lock, lock_flags); 3131 tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); 3132 ch->ch_bd->bd_ops->param(tty); 3133 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3134 3135 return 0; 3136 3137 case TIOCMGET: 3138 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3139 return dgnc_get_modem_info(ch, uarg); 3140 3141 case TIOCMBIS: 3142 case TIOCMBIC: 3143 case TIOCMSET: 3144 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3145 return dgnc_set_modem_info(tty, cmd, uarg); 3146 3147 /* 3148 * Here are any additional ioctl's that we want to implement 3149 */ 3150 3151 case TCFLSH: 3152 /* 3153 * The linux tty driver doesn't have a flush 3154 * input routine for the driver, assuming all backed 3155 * up data is in the line disc. buffers. However, 3156 * we all know that's not the case. Here, we 3157 * act on the ioctl, but then lie and say we didn't 3158 * so the line discipline will process the flush 3159 * also. 3160 */ 3161 rc = tty_check_change(tty); 3162 if (rc) { 3163 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3164 return rc; 3165 } 3166 3167 if ((arg == TCIFLUSH) || (arg == TCIOFLUSH)) { 3168 ch->ch_r_head = ch->ch_r_tail; 3169 ch->ch_bd->bd_ops->flush_uart_read(ch); 3170 /* Force queue flow control to be released, if needed */ 3171 dgnc_check_queue_flow_control(ch); 3172 } 3173 3174 if ((arg == TCOFLUSH) || (arg == TCIOFLUSH)) { 3175 if (!(un->un_type == DGNC_PRINT)) { 3176 ch->ch_w_head = ch->ch_w_tail; 3177 ch->ch_bd->bd_ops->flush_uart_write(ch); 3178 3179 if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { 3180 ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); 3181 wake_up_interruptible(&ch->ch_tun.un_flags_wait); 3182 } 3183 3184 if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { 3185 ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); 3186 wake_up_interruptible(&ch->ch_pun.un_flags_wait); 3187 } 3188 3189 } 3190 } 3191 3192 /* pretend we didn't recognize this IOCTL */ 3193 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3194 return -ENOIOCTLCMD; 3195 case TCSETSF: 3196 case TCSETSW: 3197 /* 3198 * The linux tty driver doesn't have a flush 3199 * input routine for the driver, assuming all backed 3200 * up data is in the line disc. buffers. However, 3201 * we all know that's not the case. Here, we 3202 * act on the ioctl, but then lie and say we didn't 3203 * so the line discipline will process the flush 3204 * also. 3205 */ 3206 if (cmd == TCSETSF) { 3207 /* flush rx */ 3208 ch->ch_flags &= ~CH_STOP; 3209 ch->ch_r_head = ch->ch_r_tail; 3210 ch->ch_bd->bd_ops->flush_uart_read(ch); 3211 /* Force queue flow control to be released, if needed */ 3212 dgnc_check_queue_flow_control(ch); 3213 } 3214 3215 /* now wait for all the output to drain */ 3216 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3217 rc = ch->ch_bd->bd_ops->drain(tty, 0); 3218 if (rc) { 3219 DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d\n", rc)); 3220 return -EINTR; 3221 } 3222 3223 DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", 3224 ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); 3225 3226 /* pretend we didn't recognize this */ 3227 return -ENOIOCTLCMD; 3228 3229 case TCSETAW: 3230 3231 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3232 rc = ch->ch_bd->bd_ops->drain(tty, 0); 3233 if (rc) { 3234 DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); 3235 return -EINTR; 3236 } 3237 3238 /* pretend we didn't recognize this */ 3239 return -ENOIOCTLCMD; 3240 3241 case TCXONC: 3242 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3243 /* Make the ld do it */ 3244 return -ENOIOCTLCMD; 3245 3246 case DIGI_GETA: 3247 /* get information for ditty */ 3248 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3249 return dgnc_tty_digigeta(tty, uarg); 3250 3251 case DIGI_SETAW: 3252 case DIGI_SETAF: 3253 3254 /* set information for ditty */ 3255 if (cmd == (DIGI_SETAW)) { 3256 3257 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3258 rc = ch->ch_bd->bd_ops->drain(tty, 0); 3259 if (rc) { 3260 DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); 3261 return -EINTR; 3262 } 3263 DGNC_LOCK(ch->ch_lock, lock_flags); 3264 } else { 3265 tty_ldisc_flush(tty); 3266 } 3267 /* fall thru */ 3268 3269 case DIGI_SETA: 3270 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3271 return dgnc_tty_digiseta(tty, uarg); 3272 3273 case DIGI_LOOPBACK: 3274 { 3275 uint loopback = 0; 3276 /* Let go of locks when accessing user space, could sleep */ 3277 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3278 rc = get_user(loopback, (unsigned int __user *) arg); 3279 if (rc) 3280 return rc; 3281 DGNC_LOCK(ch->ch_lock, lock_flags); 3282 3283 /* Enable/disable internal loopback for this port */ 3284 if (loopback) 3285 ch->ch_flags |= CH_LOOPBACK; 3286 else 3287 ch->ch_flags &= ~(CH_LOOPBACK); 3288 3289 ch->ch_bd->bd_ops->param(tty); 3290 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3291 return 0; 3292 } 3293 3294 case DIGI_GETCUSTOMBAUD: 3295 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3296 rc = put_user(ch->ch_custom_speed, (unsigned int __user *) arg); 3297 return rc; 3298 3299 case DIGI_SETCUSTOMBAUD: 3300 { 3301 int new_rate; 3302 /* Let go of locks when accessing user space, could sleep */ 3303 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3304 rc = get_user(new_rate, (int __user *) arg); 3305 if (rc) 3306 return rc; 3307 DGNC_LOCK(ch->ch_lock, lock_flags); 3308 dgnc_set_custom_speed(ch, new_rate); 3309 ch->ch_bd->bd_ops->param(tty); 3310 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3311 return 0; 3312 } 3313 3314 /* 3315 * This ioctl allows insertion of a character into the front 3316 * of any pending data to be transmitted. 3317 * 3318 * This ioctl is to satify the "Send Character Immediate" 3319 * call that the RealPort protocol spec requires. 3320 */ 3321 case DIGI_REALPORT_SENDIMMEDIATE: 3322 { 3323 unsigned char c; 3324 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3325 rc = get_user(c, (unsigned char __user *) arg); 3326 if (rc) 3327 return rc; 3328 DGNC_LOCK(ch->ch_lock, lock_flags); 3329 ch->ch_bd->bd_ops->send_immediate_char(ch, c); 3330 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3331 return 0; 3332 } 3333 3334 /* 3335 * This ioctl returns all the current counts for the port. 3336 * 3337 * This ioctl is to satify the "Line Error Counters" 3338 * call that the RealPort protocol spec requires. 3339 */ 3340 case DIGI_REALPORT_GETCOUNTERS: 3341 { 3342 struct digi_getcounter buf; 3343 3344 buf.norun = ch->ch_err_overrun; 3345 buf.noflow = 0; /* The driver doesn't keep this stat */ 3346 buf.nframe = ch->ch_err_frame; 3347 buf.nparity = ch->ch_err_parity; 3348 buf.nbreak = ch->ch_err_break; 3349 buf.rbytes = ch->ch_rxcount; 3350 buf.tbytes = ch->ch_txcount; 3351 3352 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3353 3354 if (copy_to_user(uarg, &buf, sizeof(buf))) 3355 return -EFAULT; 3356 3357 return 0; 3358 } 3359 3360 /* 3361 * This ioctl returns all current events. 3362 * 3363 * This ioctl is to satify the "Event Reporting" 3364 * call that the RealPort protocol spec requires. 3365 */ 3366 case DIGI_REALPORT_GETEVENTS: 3367 { 3368 unsigned int events = 0; 3369 3370 /* NOTE: MORE EVENTS NEEDS TO BE ADDED HERE */ 3371 if (ch->ch_flags & CH_BREAK_SENDING) 3372 events |= EV_TXB; 3373 if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_FORCED_STOP)) 3374 events |= (EV_OPU | EV_OPS); 3375 3376 if ((ch->ch_flags & CH_STOPI) || (ch->ch_flags & CH_FORCED_STOPI)) { 3377 events |= (EV_IPU | EV_IPS); 3378 } 3379 3380 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3381 rc = put_user(events, (unsigned int __user *) arg); 3382 return rc; 3383 } 3384 3385 /* 3386 * This ioctl returns TOUT and TIN counters based 3387 * upon the values passed in by the RealPort Server. 3388 * It also passes back whether the UART Transmitter is 3389 * empty as well. 3390 */ 3391 case DIGI_REALPORT_GETBUFFERS: 3392 { 3393 struct digi_getbuffer buf; 3394 int tdist; 3395 int count; 3396 3397 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3398 3399 /* 3400 * Get data from user first. 3401 */ 3402 if (copy_from_user(&buf, uarg, sizeof(buf))) 3403 return -EFAULT; 3404 3405 DGNC_LOCK(ch->ch_lock, lock_flags); 3406 3407 /* 3408 * Figure out how much data is in our RX and TX queues. 3409 */ 3410 buf.rxbuf = (ch->ch_r_head - ch->ch_r_tail) & RQUEUEMASK; 3411 buf.txbuf = (ch->ch_w_head - ch->ch_w_tail) & WQUEUEMASK; 3412 3413 /* 3414 * Is the UART empty? Add that value to whats in our TX queue. 3415 */ 3416 count = buf.txbuf + ch->ch_bd->bd_ops->get_uart_bytes_left(ch); 3417 3418 /* 3419 * Figure out how much data the RealPort Server believes should 3420 * be in our TX queue. 3421 */ 3422 tdist = (buf.tIn - buf.tOut) & 0xffff; 3423 3424 /* 3425 * If we have more data than the RealPort Server believes we 3426 * should have, reduce our count to its amount. 3427 * 3428 * This count difference CAN happen because the Linux LD can 3429 * insert more characters into our queue for OPOST processing 3430 * that the RealPort Server doesn't know about. 3431 */ 3432 if (buf.txbuf > tdist) 3433 buf.txbuf = tdist; 3434 3435 /* 3436 * Report whether our queue and UART TX are completely empty. 3437 */ 3438 if (count) 3439 buf.txdone = 0; 3440 else 3441 buf.txdone = 1; 3442 3443 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3444 3445 if (copy_to_user(uarg, &buf, sizeof(buf))) 3446 return -EFAULT; 3447 3448 return 0; 3449 } 3450 default: 3451 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3452 3453 DPR_IOCTL(("dgnc_tty_ioctl - in default\n")); 3454 DPR_IOCTL(("dgnc_tty_ioctl end - cmd %s (%x), arg %lx\n", 3455 dgnc_ioctl_name(cmd), cmd, arg)); 3456 3457 return -ENOIOCTLCMD; 3458 } 3459 3460 DGNC_UNLOCK(ch->ch_lock, lock_flags); 3461 3462 DPR_IOCTL(("dgnc_tty_ioctl end - cmd %s (%x), arg %lx\n", 3463 dgnc_ioctl_name(cmd), cmd, arg)); 3464 3465 return 0; 3466 } 3467 3468 3469 3470 3471 3472 /* LDV_COMMENT_BEGIN_MAIN */ 3473 #ifdef LDV_MAIN5_sequence_infinite_withcheck_stateful 3474 3475 /*###########################################################################*/ 3476 3477 /*############## Driver Environment Generator 0.2 output ####################*/ 3478 3479 /*###########################################################################*/ 3480 3481 3482 3483 /* 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. */ 3484 void ldv_check_final_state(void); 3485 3486 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */ 3487 void ldv_check_return_value(int res); 3488 3489 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */ 3490 void ldv_check_return_value_probe(int res); 3491 3492 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */ 3493 void ldv_initialize(void); 3494 3495 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */ 3496 void ldv_handler_precall(void); 3497 3498 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */ 3499 int nondet_int(void); 3500 3501 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */ 3502 int LDV_IN_INTERRUPT; 3503 3504 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */ 3505 void ldv_main5_sequence_infinite_withcheck_stateful(void) { 3506 3507 3508 3509 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */ 3510 /*============================= VARIABLE DECLARATION PART =============================*/ 3511 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 3512 /* content: static int dgnc_tty_open(struct tty_struct *tty, struct file *file)*/ 3513 /* LDV_COMMENT_BEGIN_PREP */ 3514 #define init_MUTEX(sem) sema_init(sem, 1) 3515 #define DECLARE_MUTEX(name) \ 3516 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3517 #define TMPBUFLEN (1024) 3518 #ifdef TTY_DONT_FLIP 3519 #endif 3520 /* LDV_COMMENT_END_PREP */ 3521 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_open" */ 3522 struct tty_struct * var_group1; 3523 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_open" */ 3524 struct file * var_group2; 3525 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "dgnc_tty_open" */ 3526 static int res_dgnc_tty_open_12; 3527 /* LDV_COMMENT_BEGIN_PREP */ 3528 #if 0 3529 #endif 3530 /* LDV_COMMENT_END_PREP */ 3531 /* content: static void dgnc_tty_close(struct tty_struct *tty, struct file *file)*/ 3532 /* LDV_COMMENT_BEGIN_PREP */ 3533 #define init_MUTEX(sem) sema_init(sem, 1) 3534 #define DECLARE_MUTEX(name) \ 3535 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3536 #define TMPBUFLEN (1024) 3537 #ifdef TTY_DONT_FLIP 3538 #endif 3539 /* LDV_COMMENT_END_PREP */ 3540 /* LDV_COMMENT_BEGIN_PREP */ 3541 #if 0 3542 #endif 3543 /* LDV_COMMENT_END_PREP */ 3544 /* content: static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)*/ 3545 /* LDV_COMMENT_BEGIN_PREP */ 3546 #define init_MUTEX(sem) sema_init(sem, 1) 3547 #define DECLARE_MUTEX(name) \ 3548 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3549 #define TMPBUFLEN (1024) 3550 #ifdef TTY_DONT_FLIP 3551 #endif 3552 /* LDV_COMMENT_END_PREP */ 3553 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_write" */ 3554 const unsigned char * var_dgnc_tty_write_20_p1; 3555 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_write" */ 3556 int var_dgnc_tty_write_20_p2; 3557 /* content: static int dgnc_tty_write_room(struct tty_struct *tty)*/ 3558 /* LDV_COMMENT_BEGIN_PREP */ 3559 #define init_MUTEX(sem) sema_init(sem, 1) 3560 #define DECLARE_MUTEX(name) \ 3561 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3562 #define TMPBUFLEN (1024) 3563 #ifdef TTY_DONT_FLIP 3564 #endif 3565 /* LDV_COMMENT_END_PREP */ 3566 /* LDV_COMMENT_BEGIN_PREP */ 3567 #if 0 3568 #endif 3569 /* LDV_COMMENT_END_PREP */ 3570 /* content: static void dgnc_tty_flush_buffer(struct tty_struct *tty)*/ 3571 /* LDV_COMMENT_BEGIN_PREP */ 3572 #define init_MUTEX(sem) sema_init(sem, 1) 3573 #define DECLARE_MUTEX(name) \ 3574 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3575 #define TMPBUFLEN (1024) 3576 #ifdef TTY_DONT_FLIP 3577 #endif 3578 #if 0 3579 #endif 3580 /* LDV_COMMENT_END_PREP */ 3581 /* content: static int dgnc_tty_chars_in_buffer(struct tty_struct *tty)*/ 3582 /* LDV_COMMENT_BEGIN_PREP */ 3583 #define init_MUTEX(sem) sema_init(sem, 1) 3584 #define DECLARE_MUTEX(name) \ 3585 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3586 #define TMPBUFLEN (1024) 3587 #ifdef TTY_DONT_FLIP 3588 #endif 3589 /* LDV_COMMENT_END_PREP */ 3590 /* LDV_COMMENT_BEGIN_PREP */ 3591 #if 0 3592 #endif 3593 /* LDV_COMMENT_END_PREP */ 3594 /* content: static void dgnc_tty_flush_chars(struct tty_struct *tty)*/ 3595 /* LDV_COMMENT_BEGIN_PREP */ 3596 #define init_MUTEX(sem) sema_init(sem, 1) 3597 #define DECLARE_MUTEX(name) \ 3598 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3599 #define TMPBUFLEN (1024) 3600 #ifdef TTY_DONT_FLIP 3601 #endif 3602 #if 0 3603 #endif 3604 /* LDV_COMMENT_END_PREP */ 3605 /* content: static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)*/ 3606 /* LDV_COMMENT_BEGIN_PREP */ 3607 #define init_MUTEX(sem) sema_init(sem, 1) 3608 #define DECLARE_MUTEX(name) \ 3609 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3610 #define TMPBUFLEN (1024) 3611 #ifdef TTY_DONT_FLIP 3612 #endif 3613 #if 0 3614 #endif 3615 /* LDV_COMMENT_END_PREP */ 3616 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_ioctl" */ 3617 unsigned int var_dgnc_tty_ioctl_38_p1; 3618 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_ioctl" */ 3619 unsigned long var_dgnc_tty_ioctl_38_p2; 3620 /* content: static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)*/ 3621 /* LDV_COMMENT_BEGIN_PREP */ 3622 #define init_MUTEX(sem) sema_init(sem, 1) 3623 #define DECLARE_MUTEX(name) \ 3624 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3625 #define TMPBUFLEN (1024) 3626 #ifdef TTY_DONT_FLIP 3627 #endif 3628 #if 0 3629 #endif 3630 /* LDV_COMMENT_END_PREP */ 3631 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_set_termios" */ 3632 struct ktermios * var_group3; 3633 /* content: static void dgnc_tty_stop(struct tty_struct *tty)*/ 3634 /* LDV_COMMENT_BEGIN_PREP */ 3635 #define init_MUTEX(sem) sema_init(sem, 1) 3636 #define DECLARE_MUTEX(name) \ 3637 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3638 #define TMPBUFLEN (1024) 3639 #ifdef TTY_DONT_FLIP 3640 #endif 3641 #if 0 3642 #endif 3643 /* LDV_COMMENT_END_PREP */ 3644 /* content: static void dgnc_tty_start(struct tty_struct *tty)*/ 3645 /* LDV_COMMENT_BEGIN_PREP */ 3646 #define init_MUTEX(sem) sema_init(sem, 1) 3647 #define DECLARE_MUTEX(name) \ 3648 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3649 #define TMPBUFLEN (1024) 3650 #ifdef TTY_DONT_FLIP 3651 #endif 3652 #if 0 3653 #endif 3654 /* LDV_COMMENT_END_PREP */ 3655 /* content: static void dgnc_tty_throttle(struct tty_struct *tty)*/ 3656 /* LDV_COMMENT_BEGIN_PREP */ 3657 #define init_MUTEX(sem) sema_init(sem, 1) 3658 #define DECLARE_MUTEX(name) \ 3659 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3660 #define TMPBUFLEN (1024) 3661 #ifdef TTY_DONT_FLIP 3662 #endif 3663 #if 0 3664 #endif 3665 /* LDV_COMMENT_END_PREP */ 3666 /* content: static void dgnc_tty_unthrottle(struct tty_struct *tty)*/ 3667 /* LDV_COMMENT_BEGIN_PREP */ 3668 #define init_MUTEX(sem) sema_init(sem, 1) 3669 #define DECLARE_MUTEX(name) \ 3670 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3671 #define TMPBUFLEN (1024) 3672 #ifdef TTY_DONT_FLIP 3673 #endif 3674 #if 0 3675 #endif 3676 /* LDV_COMMENT_END_PREP */ 3677 /* content: static void dgnc_tty_hangup(struct tty_struct *tty)*/ 3678 /* LDV_COMMENT_BEGIN_PREP */ 3679 #define init_MUTEX(sem) sema_init(sem, 1) 3680 #define DECLARE_MUTEX(name) \ 3681 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3682 #define TMPBUFLEN (1024) 3683 #ifdef TTY_DONT_FLIP 3684 #endif 3685 /* LDV_COMMENT_END_PREP */ 3686 /* LDV_COMMENT_BEGIN_PREP */ 3687 #if 0 3688 #endif 3689 /* LDV_COMMENT_END_PREP */ 3690 /* content: static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c)*/ 3691 /* LDV_COMMENT_BEGIN_PREP */ 3692 #define init_MUTEX(sem) sema_init(sem, 1) 3693 #define DECLARE_MUTEX(name) \ 3694 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3695 #define TMPBUFLEN (1024) 3696 #ifdef TTY_DONT_FLIP 3697 #endif 3698 /* LDV_COMMENT_END_PREP */ 3699 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_put_char" */ 3700 unsigned char var_dgnc_tty_put_char_19_p1; 3701 /* LDV_COMMENT_BEGIN_PREP */ 3702 #if 0 3703 #endif 3704 /* LDV_COMMENT_END_PREP */ 3705 /* content: static int dgnc_tty_tiocmget(struct tty_struct *tty)*/ 3706 /* LDV_COMMENT_BEGIN_PREP */ 3707 #define init_MUTEX(sem) sema_init(sem, 1) 3708 #define DECLARE_MUTEX(name) \ 3709 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3710 #define TMPBUFLEN (1024) 3711 #ifdef TTY_DONT_FLIP 3712 #endif 3713 #if 0 3714 #endif 3715 /* LDV_COMMENT_END_PREP */ 3716 /* content: static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear)*/ 3717 /* LDV_COMMENT_BEGIN_PREP */ 3718 #define init_MUTEX(sem) sema_init(sem, 1) 3719 #define DECLARE_MUTEX(name) \ 3720 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3721 #define TMPBUFLEN (1024) 3722 #ifdef TTY_DONT_FLIP 3723 #endif 3724 #if 0 3725 #endif 3726 /* LDV_COMMENT_END_PREP */ 3727 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_tiocmset" */ 3728 unsigned int var_dgnc_tty_tiocmset_22_p1; 3729 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_tiocmset" */ 3730 unsigned int var_dgnc_tty_tiocmset_22_p2; 3731 /* content: static int dgnc_tty_send_break(struct tty_struct *tty, int msec)*/ 3732 /* LDV_COMMENT_BEGIN_PREP */ 3733 #define init_MUTEX(sem) sema_init(sem, 1) 3734 #define DECLARE_MUTEX(name) \ 3735 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3736 #define TMPBUFLEN (1024) 3737 #ifdef TTY_DONT_FLIP 3738 #endif 3739 #if 0 3740 #endif 3741 /* LDV_COMMENT_END_PREP */ 3742 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_send_break" */ 3743 int var_dgnc_tty_send_break_23_p1; 3744 /* content: static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout)*/ 3745 /* LDV_COMMENT_BEGIN_PREP */ 3746 #define init_MUTEX(sem) sema_init(sem, 1) 3747 #define DECLARE_MUTEX(name) \ 3748 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3749 #define TMPBUFLEN (1024) 3750 #ifdef TTY_DONT_FLIP 3751 #endif 3752 #if 0 3753 #endif 3754 /* LDV_COMMENT_END_PREP */ 3755 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_wait_until_sent" */ 3756 int var_dgnc_tty_wait_until_sent_24_p1; 3757 /* content: static void dgnc_tty_send_xchar(struct tty_struct *tty, char c)*/ 3758 /* LDV_COMMENT_BEGIN_PREP */ 3759 #define init_MUTEX(sem) sema_init(sem, 1) 3760 #define DECLARE_MUTEX(name) \ 3761 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3762 #define TMPBUFLEN (1024) 3763 #ifdef TTY_DONT_FLIP 3764 #endif 3765 #if 0 3766 #endif 3767 /* LDV_COMMENT_END_PREP */ 3768 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "dgnc_tty_send_xchar" */ 3769 char var_dgnc_tty_send_xchar_25_p1; 3770 3771 3772 3773 3774 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */ 3775 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */ 3776 /*============================= VARIABLE INITIALIZING PART =============================*/ 3777 LDV_IN_INTERRUPT=1; 3778 3779 3780 3781 3782 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */ 3783 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */ 3784 /*============================= FUNCTION CALL SECTION =============================*/ 3785 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */ 3786 ldv_initialize(); 3787 int ldv_s_dgnc_tty_ops_tty_operations = 0; 3788 3789 3790 3791 while( nondet_int() 3792 || !(ldv_s_dgnc_tty_ops_tty_operations == 0) 3793 ) { 3794 3795 switch(nondet_int()) { 3796 3797 case 0: { 3798 3799 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 3800 if(ldv_s_dgnc_tty_ops_tty_operations==0) { 3801 3802 /* content: static int dgnc_tty_open(struct tty_struct *tty, struct file *file)*/ 3803 /* LDV_COMMENT_BEGIN_PREP */ 3804 #define init_MUTEX(sem) sema_init(sem, 1) 3805 #define DECLARE_MUTEX(name) \ 3806 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3807 #define TMPBUFLEN (1024) 3808 #ifdef TTY_DONT_FLIP 3809 #endif 3810 /* LDV_COMMENT_END_PREP */ 3811 /* LDV_COMMENT_FUNCTION_CALL Function from field "open" from driver structure with callbacks "dgnc_tty_ops". Standart function test for correct return result. */ 3812 ldv_handler_precall(); 3813 res_dgnc_tty_open_12 = dgnc_tty_open( var_group1, var_group2); 3814 ldv_check_return_value(res_dgnc_tty_open_12); 3815 if(res_dgnc_tty_open_12) 3816 goto ldv_module_exit; 3817 /* LDV_COMMENT_BEGIN_PREP */ 3818 #if 0 3819 #endif 3820 /* LDV_COMMENT_END_PREP */ 3821 ldv_s_dgnc_tty_ops_tty_operations++; 3822 3823 } 3824 3825 } 3826 3827 break; 3828 case 1: { 3829 3830 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 3831 if(ldv_s_dgnc_tty_ops_tty_operations==1) { 3832 3833 /* content: static void dgnc_tty_close(struct tty_struct *tty, struct file *file)*/ 3834 /* LDV_COMMENT_BEGIN_PREP */ 3835 #define init_MUTEX(sem) sema_init(sem, 1) 3836 #define DECLARE_MUTEX(name) \ 3837 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3838 #define TMPBUFLEN (1024) 3839 #ifdef TTY_DONT_FLIP 3840 #endif 3841 /* LDV_COMMENT_END_PREP */ 3842 /* LDV_COMMENT_FUNCTION_CALL Function from field "close" from driver structure with callbacks "dgnc_tty_ops" */ 3843 ldv_handler_precall(); 3844 dgnc_tty_close( var_group1, var_group2); 3845 /* LDV_COMMENT_BEGIN_PREP */ 3846 #if 0 3847 #endif 3848 /* LDV_COMMENT_END_PREP */ 3849 ldv_s_dgnc_tty_ops_tty_operations=0; 3850 3851 } 3852 3853 } 3854 3855 break; 3856 case 2: { 3857 3858 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 3859 3860 3861 /* content: static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)*/ 3862 /* LDV_COMMENT_BEGIN_PREP */ 3863 #define init_MUTEX(sem) sema_init(sem, 1) 3864 #define DECLARE_MUTEX(name) \ 3865 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3866 #define TMPBUFLEN (1024) 3867 #ifdef TTY_DONT_FLIP 3868 #endif 3869 /* LDV_COMMENT_END_PREP */ 3870 /* LDV_COMMENT_FUNCTION_CALL Function from field "write" from driver structure with callbacks "dgnc_tty_ops" */ 3871 ldv_handler_precall(); 3872 dgnc_tty_write( var_group1, var_dgnc_tty_write_20_p1, var_dgnc_tty_write_20_p2); 3873 3874 3875 3876 3877 } 3878 3879 break; 3880 case 3: { 3881 3882 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 3883 3884 3885 /* content: static int dgnc_tty_write_room(struct tty_struct *tty)*/ 3886 /* LDV_COMMENT_BEGIN_PREP */ 3887 #define init_MUTEX(sem) sema_init(sem, 1) 3888 #define DECLARE_MUTEX(name) \ 3889 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3890 #define TMPBUFLEN (1024) 3891 #ifdef TTY_DONT_FLIP 3892 #endif 3893 /* LDV_COMMENT_END_PREP */ 3894 /* LDV_COMMENT_FUNCTION_CALL Function from field "write_room" from driver structure with callbacks "dgnc_tty_ops" */ 3895 ldv_handler_precall(); 3896 dgnc_tty_write_room( var_group1); 3897 /* LDV_COMMENT_BEGIN_PREP */ 3898 #if 0 3899 #endif 3900 /* LDV_COMMENT_END_PREP */ 3901 3902 3903 3904 3905 } 3906 3907 break; 3908 case 4: { 3909 3910 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 3911 3912 3913 /* content: static void dgnc_tty_flush_buffer(struct tty_struct *tty)*/ 3914 /* LDV_COMMENT_BEGIN_PREP */ 3915 #define init_MUTEX(sem) sema_init(sem, 1) 3916 #define DECLARE_MUTEX(name) \ 3917 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3918 #define TMPBUFLEN (1024) 3919 #ifdef TTY_DONT_FLIP 3920 #endif 3921 #if 0 3922 #endif 3923 /* LDV_COMMENT_END_PREP */ 3924 /* LDV_COMMENT_FUNCTION_CALL Function from field "flush_buffer" from driver structure with callbacks "dgnc_tty_ops" */ 3925 ldv_handler_precall(); 3926 dgnc_tty_flush_buffer( var_group1); 3927 3928 3929 3930 3931 } 3932 3933 break; 3934 case 5: { 3935 3936 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 3937 3938 3939 /* content: static int dgnc_tty_chars_in_buffer(struct tty_struct *tty)*/ 3940 /* LDV_COMMENT_BEGIN_PREP */ 3941 #define init_MUTEX(sem) sema_init(sem, 1) 3942 #define DECLARE_MUTEX(name) \ 3943 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3944 #define TMPBUFLEN (1024) 3945 #ifdef TTY_DONT_FLIP 3946 #endif 3947 /* LDV_COMMENT_END_PREP */ 3948 /* LDV_COMMENT_FUNCTION_CALL Function from field "chars_in_buffer" from driver structure with callbacks "dgnc_tty_ops" */ 3949 ldv_handler_precall(); 3950 dgnc_tty_chars_in_buffer( var_group1); 3951 /* LDV_COMMENT_BEGIN_PREP */ 3952 #if 0 3953 #endif 3954 /* LDV_COMMENT_END_PREP */ 3955 3956 3957 3958 3959 } 3960 3961 break; 3962 case 6: { 3963 3964 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 3965 3966 3967 /* content: static void dgnc_tty_flush_chars(struct tty_struct *tty)*/ 3968 /* LDV_COMMENT_BEGIN_PREP */ 3969 #define init_MUTEX(sem) sema_init(sem, 1) 3970 #define DECLARE_MUTEX(name) \ 3971 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3972 #define TMPBUFLEN (1024) 3973 #ifdef TTY_DONT_FLIP 3974 #endif 3975 #if 0 3976 #endif 3977 /* LDV_COMMENT_END_PREP */ 3978 /* LDV_COMMENT_FUNCTION_CALL Function from field "flush_chars" from driver structure with callbacks "dgnc_tty_ops" */ 3979 ldv_handler_precall(); 3980 dgnc_tty_flush_chars( var_group1); 3981 3982 3983 3984 3985 } 3986 3987 break; 3988 case 7: { 3989 3990 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 3991 3992 3993 /* content: static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)*/ 3994 /* LDV_COMMENT_BEGIN_PREP */ 3995 #define init_MUTEX(sem) sema_init(sem, 1) 3996 #define DECLARE_MUTEX(name) \ 3997 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 3998 #define TMPBUFLEN (1024) 3999 #ifdef TTY_DONT_FLIP 4000 #endif 4001 #if 0 4002 #endif 4003 /* LDV_COMMENT_END_PREP */ 4004 /* LDV_COMMENT_FUNCTION_CALL Function from field "ioctl" from driver structure with callbacks "dgnc_tty_ops" */ 4005 ldv_handler_precall(); 4006 dgnc_tty_ioctl( var_group1, var_dgnc_tty_ioctl_38_p1, var_dgnc_tty_ioctl_38_p2); 4007 4008 4009 4010 4011 } 4012 4013 break; 4014 case 8: { 4015 4016 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4017 4018 4019 /* content: static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)*/ 4020 /* LDV_COMMENT_BEGIN_PREP */ 4021 #define init_MUTEX(sem) sema_init(sem, 1) 4022 #define DECLARE_MUTEX(name) \ 4023 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4024 #define TMPBUFLEN (1024) 4025 #ifdef TTY_DONT_FLIP 4026 #endif 4027 #if 0 4028 #endif 4029 /* LDV_COMMENT_END_PREP */ 4030 /* LDV_COMMENT_FUNCTION_CALL Function from field "set_termios" from driver structure with callbacks "dgnc_tty_ops" */ 4031 ldv_handler_precall(); 4032 dgnc_tty_set_termios( var_group1, var_group3); 4033 4034 4035 4036 4037 } 4038 4039 break; 4040 case 9: { 4041 4042 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4043 4044 4045 /* content: static void dgnc_tty_stop(struct tty_struct *tty)*/ 4046 /* LDV_COMMENT_BEGIN_PREP */ 4047 #define init_MUTEX(sem) sema_init(sem, 1) 4048 #define DECLARE_MUTEX(name) \ 4049 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4050 #define TMPBUFLEN (1024) 4051 #ifdef TTY_DONT_FLIP 4052 #endif 4053 #if 0 4054 #endif 4055 /* LDV_COMMENT_END_PREP */ 4056 /* LDV_COMMENT_FUNCTION_CALL Function from field "stop" from driver structure with callbacks "dgnc_tty_ops" */ 4057 ldv_handler_precall(); 4058 dgnc_tty_stop( var_group1); 4059 4060 4061 4062 4063 } 4064 4065 break; 4066 case 10: { 4067 4068 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4069 4070 4071 /* content: static void dgnc_tty_start(struct tty_struct *tty)*/ 4072 /* LDV_COMMENT_BEGIN_PREP */ 4073 #define init_MUTEX(sem) sema_init(sem, 1) 4074 #define DECLARE_MUTEX(name) \ 4075 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4076 #define TMPBUFLEN (1024) 4077 #ifdef TTY_DONT_FLIP 4078 #endif 4079 #if 0 4080 #endif 4081 /* LDV_COMMENT_END_PREP */ 4082 /* LDV_COMMENT_FUNCTION_CALL Function from field "start" from driver structure with callbacks "dgnc_tty_ops" */ 4083 ldv_handler_precall(); 4084 dgnc_tty_start( var_group1); 4085 4086 4087 4088 4089 } 4090 4091 break; 4092 case 11: { 4093 4094 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4095 4096 4097 /* content: static void dgnc_tty_throttle(struct tty_struct *tty)*/ 4098 /* LDV_COMMENT_BEGIN_PREP */ 4099 #define init_MUTEX(sem) sema_init(sem, 1) 4100 #define DECLARE_MUTEX(name) \ 4101 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4102 #define TMPBUFLEN (1024) 4103 #ifdef TTY_DONT_FLIP 4104 #endif 4105 #if 0 4106 #endif 4107 /* LDV_COMMENT_END_PREP */ 4108 /* LDV_COMMENT_FUNCTION_CALL Function from field "throttle" from driver structure with callbacks "dgnc_tty_ops" */ 4109 ldv_handler_precall(); 4110 dgnc_tty_throttle( var_group1); 4111 4112 4113 4114 4115 } 4116 4117 break; 4118 case 12: { 4119 4120 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4121 4122 4123 /* content: static void dgnc_tty_unthrottle(struct tty_struct *tty)*/ 4124 /* LDV_COMMENT_BEGIN_PREP */ 4125 #define init_MUTEX(sem) sema_init(sem, 1) 4126 #define DECLARE_MUTEX(name) \ 4127 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4128 #define TMPBUFLEN (1024) 4129 #ifdef TTY_DONT_FLIP 4130 #endif 4131 #if 0 4132 #endif 4133 /* LDV_COMMENT_END_PREP */ 4134 /* LDV_COMMENT_FUNCTION_CALL Function from field "unthrottle" from driver structure with callbacks "dgnc_tty_ops" */ 4135 ldv_handler_precall(); 4136 dgnc_tty_unthrottle( var_group1); 4137 4138 4139 4140 4141 } 4142 4143 break; 4144 case 13: { 4145 4146 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4147 4148 4149 /* content: static void dgnc_tty_hangup(struct tty_struct *tty)*/ 4150 /* LDV_COMMENT_BEGIN_PREP */ 4151 #define init_MUTEX(sem) sema_init(sem, 1) 4152 #define DECLARE_MUTEX(name) \ 4153 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4154 #define TMPBUFLEN (1024) 4155 #ifdef TTY_DONT_FLIP 4156 #endif 4157 /* LDV_COMMENT_END_PREP */ 4158 /* LDV_COMMENT_FUNCTION_CALL Function from field "hangup" from driver structure with callbacks "dgnc_tty_ops" */ 4159 ldv_handler_precall(); 4160 dgnc_tty_hangup( var_group1); 4161 /* LDV_COMMENT_BEGIN_PREP */ 4162 #if 0 4163 #endif 4164 /* LDV_COMMENT_END_PREP */ 4165 4166 4167 4168 4169 } 4170 4171 break; 4172 case 14: { 4173 4174 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4175 4176 4177 /* content: static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c)*/ 4178 /* LDV_COMMENT_BEGIN_PREP */ 4179 #define init_MUTEX(sem) sema_init(sem, 1) 4180 #define DECLARE_MUTEX(name) \ 4181 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4182 #define TMPBUFLEN (1024) 4183 #ifdef TTY_DONT_FLIP 4184 #endif 4185 /* LDV_COMMENT_END_PREP */ 4186 /* LDV_COMMENT_FUNCTION_CALL Function from field "put_char" from driver structure with callbacks "dgnc_tty_ops" */ 4187 ldv_handler_precall(); 4188 dgnc_tty_put_char( var_group1, var_dgnc_tty_put_char_19_p1); 4189 /* LDV_COMMENT_BEGIN_PREP */ 4190 #if 0 4191 #endif 4192 /* LDV_COMMENT_END_PREP */ 4193 4194 4195 4196 4197 } 4198 4199 break; 4200 case 15: { 4201 4202 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4203 4204 4205 /* content: static int dgnc_tty_tiocmget(struct tty_struct *tty)*/ 4206 /* LDV_COMMENT_BEGIN_PREP */ 4207 #define init_MUTEX(sem) sema_init(sem, 1) 4208 #define DECLARE_MUTEX(name) \ 4209 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4210 #define TMPBUFLEN (1024) 4211 #ifdef TTY_DONT_FLIP 4212 #endif 4213 #if 0 4214 #endif 4215 /* LDV_COMMENT_END_PREP */ 4216 /* LDV_COMMENT_FUNCTION_CALL Function from field "tiocmget" from driver structure with callbacks "dgnc_tty_ops" */ 4217 ldv_handler_precall(); 4218 dgnc_tty_tiocmget( var_group1); 4219 4220 4221 4222 4223 } 4224 4225 break; 4226 case 16: { 4227 4228 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4229 4230 4231 /* content: static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear)*/ 4232 /* LDV_COMMENT_BEGIN_PREP */ 4233 #define init_MUTEX(sem) sema_init(sem, 1) 4234 #define DECLARE_MUTEX(name) \ 4235 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4236 #define TMPBUFLEN (1024) 4237 #ifdef TTY_DONT_FLIP 4238 #endif 4239 #if 0 4240 #endif 4241 /* LDV_COMMENT_END_PREP */ 4242 /* LDV_COMMENT_FUNCTION_CALL Function from field "tiocmset" from driver structure with callbacks "dgnc_tty_ops" */ 4243 ldv_handler_precall(); 4244 dgnc_tty_tiocmset( var_group1, var_dgnc_tty_tiocmset_22_p1, var_dgnc_tty_tiocmset_22_p2); 4245 4246 4247 4248 4249 } 4250 4251 break; 4252 case 17: { 4253 4254 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4255 4256 4257 /* content: static int dgnc_tty_send_break(struct tty_struct *tty, int msec)*/ 4258 /* LDV_COMMENT_BEGIN_PREP */ 4259 #define init_MUTEX(sem) sema_init(sem, 1) 4260 #define DECLARE_MUTEX(name) \ 4261 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4262 #define TMPBUFLEN (1024) 4263 #ifdef TTY_DONT_FLIP 4264 #endif 4265 #if 0 4266 #endif 4267 /* LDV_COMMENT_END_PREP */ 4268 /* LDV_COMMENT_FUNCTION_CALL Function from field "break_ctl" from driver structure with callbacks "dgnc_tty_ops" */ 4269 ldv_handler_precall(); 4270 dgnc_tty_send_break( var_group1, var_dgnc_tty_send_break_23_p1); 4271 4272 4273 4274 4275 } 4276 4277 break; 4278 case 18: { 4279 4280 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4281 4282 4283 /* content: static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout)*/ 4284 /* LDV_COMMENT_BEGIN_PREP */ 4285 #define init_MUTEX(sem) sema_init(sem, 1) 4286 #define DECLARE_MUTEX(name) \ 4287 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4288 #define TMPBUFLEN (1024) 4289 #ifdef TTY_DONT_FLIP 4290 #endif 4291 #if 0 4292 #endif 4293 /* LDV_COMMENT_END_PREP */ 4294 /* LDV_COMMENT_FUNCTION_CALL Function from field "wait_until_sent" from driver structure with callbacks "dgnc_tty_ops" */ 4295 ldv_handler_precall(); 4296 dgnc_tty_wait_until_sent( var_group1, var_dgnc_tty_wait_until_sent_24_p1); 4297 4298 4299 4300 4301 } 4302 4303 break; 4304 case 19: { 4305 4306 /** STRUCT: struct type: tty_operations, struct name: dgnc_tty_ops **/ 4307 4308 4309 /* content: static void dgnc_tty_send_xchar(struct tty_struct *tty, char c)*/ 4310 /* LDV_COMMENT_BEGIN_PREP */ 4311 #define init_MUTEX(sem) sema_init(sem, 1) 4312 #define DECLARE_MUTEX(name) \ 4313 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 4314 #define TMPBUFLEN (1024) 4315 #ifdef TTY_DONT_FLIP 4316 #endif 4317 #if 0 4318 #endif 4319 /* LDV_COMMENT_END_PREP */ 4320 /* LDV_COMMENT_FUNCTION_CALL Function from field "send_xchar" from driver structure with callbacks "dgnc_tty_ops" */ 4321 ldv_handler_precall(); 4322 dgnc_tty_send_xchar( var_group1, var_dgnc_tty_send_xchar_25_p1); 4323 4324 4325 4326 4327 } 4328 4329 break; 4330 default: break; 4331 4332 } 4333 4334 } 4335 4336 ldv_module_exit: 4337 4338 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */ 4339 ldv_final: ldv_check_final_state(); 4340 4341 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */ 4342 return; 4343 4344 } 4345 #endif 4346 4347 /* LDV_COMMENT_END_MAIN */
1 2 3 #include <verifier/rcv.h> 4 #include <kernel-model/ERR.inc> 5 6 // There are 2 possible states of usb gadget class registration. 7 enum 8 { 9 LDV_USB_GADGET_CLASS_ZERO_STATE, // Usb gadget class is not registered. 10 LDV_USB_GADGET_CLASS_REGISTERED // Usb gadget class is registered. 11 }; 12 13 // There are 2 possible states of char device region registration. 14 enum 15 { 16 LDV_USB_GADGET_CHRDEV_ZERO_STATE, // Char device region is not registered for usb gadget. 17 LDV_USB_GADGET_CHRDEV_REGISTERED // Char device region is registered for usb gadget. 18 }; 19 20 // There are 2 possible states of usb gadget registration. 21 enum 22 { 23 LDV_USB_GADGET_ZERO_STATE, // Usb gadget is not registered. 24 LDV_USB_GADGET_REGISTERED // Usb gadget is registered. 25 }; 26 27 /* LDV_COMMENT_CHANGE_STATE Usb gadget class is not registered at the beginning. */ 28 int ldv_usb_gadget_class = LDV_USB_GADGET_CLASS_ZERO_STATE; 29 30 /* LDV_COMMENT_CHANGE_STATE Char device region is not registered at the beginning. */ 31 int ldv_usb_gadget_chrdev = LDV_USB_GADGET_CHRDEV_ZERO_STATE; 32 33 /* LDV_COMMENT_CHANGE_STATE Usb gadget is not registered at the beginning. */ 34 int ldv_usb_gadget = LDV_USB_GADGET_ZERO_STATE; 35 36 37 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_create_class') Check that usb gadget class was not registered. Then create and register class for it. */ 38 void *ldv_create_class(void) 39 { 40 void *is_got; 41 42 /* LDV_COMMENT_OTHER Get blk request in the nondeterministic way. */ 43 is_got = ldv_undef_ptr(); 44 45 /* LDV_COMMENT_ASSERT Get blk request just in case when an error did not happen. */ 46 if (is_got <= LDV_PTR_MAX) 47 { 48 /* LDV_COMMENT_ASSERT Registring usb gadget class is only allowed if usb gadget is not registered. */ 49 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 50 /* LDV_COMMENT_ASSERT Check that usb gadget class is unregistered. */ 51 ldv_assert(ldv_usb_gadget_class == LDV_USB_GADGET_CLASS_ZERO_STATE); 52 /* LDV_COMMENT_CHANGE_STATE Register class for usb gadget. */ 53 ldv_usb_gadget_class = LDV_USB_GADGET_CLASS_REGISTERED; 54 } 55 56 /* LDV_COMMENT_RETURN Return obtained blk request. */ 57 return is_got; 58 } 59 60 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_register_class') Check that usb gadget class was not registered and register class for it. */ 61 int ldv_register_class(void) 62 { 63 int is_reg; 64 65 /* LDV_COMMENT_OTHER Register gadget class in the nondeterministic way. */ 66 is_reg = ldv_undef_int_nonpositive(); 67 68 /* LDV_COMMENT_ASSERT Get blk request just in case when an error did not happen. */ 69 if (!is_reg) 70 { 71 /* LDV_COMMENT_ASSERT Registering usb gadget class is only allowed if usb gadget is not registered. */ 72 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 73 /* LDV_COMMENT_ASSERT Check that usb gadget class is unregistered. */ 74 ldv_assert(ldv_usb_gadget_class == LDV_USB_GADGET_CLASS_ZERO_STATE); 75 /* LDV_COMMENT_CHANGE_STATE Register class for usb gadget. */ 76 ldv_usb_gadget_class = LDV_USB_GADGET_CLASS_REGISTERED; 77 } 78 79 /* LDV_COMMENT_RETURN Return registration status (0 is success). */ 80 return is_reg; 81 } 82 83 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_unregister_class') Check that usb gadget class was registered and unregister it. */ 84 void ldv_unregister_class(void) 85 { 86 /* LDV_COMMENT_ASSERT Unregistering usb gadget class is only allowed if usb gadget is not registered. */ 87 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 88 /* LDV_COMMENT_ASSERT Check that usb gadget class is registered. */ 89 ldv_assert(ldv_usb_gadget_class == LDV_USB_GADGET_CLASS_REGISTERED); 90 /* LDV_COMMENT_CHANGE_STATE Unregister class for usb gadget. */ 91 ldv_usb_gadget_class = LDV_USB_GADGET_CLASS_ZERO_STATE; 92 } 93 94 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_register_chrdev_region') Check that chrdev region was not registered and register it. */ 95 int ldv_register_chrdev_region(void) 96 { 97 int is_reg; 98 99 /* LDV_COMMENT_OTHER Register chrdev in the nondeterministic way. */ 100 is_reg = ldv_undef_int_nonpositive(); 101 102 /* LDV_COMMENT_ASSERT Register chrdev just in case when an error did not happen. */ 103 if (!is_reg) 104 { 105 /* LDV_COMMENT_ASSERT Usb gadget should be unregistered at this point. */ 106 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 107 /* LDV_COMMENT_ASSERT Check that chrdev region is unregistered. */ 108 ldv_assert(ldv_usb_gadget_chrdev == LDV_USB_GADGET_CHRDEV_ZERO_STATE); 109 /* LDV_COMMENT_CHANGE_STATE Register chrdev region for usb gadget. */ 110 ldv_usb_gadget_chrdev = LDV_USB_GADGET_CHRDEV_REGISTERED; 111 } 112 113 /* LDV_COMMENT_RETURN Return registration status (0 is success). */ 114 return is_reg; 115 } 116 117 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_unregister_chrdev_region') Check that chrdev region was registered and unregister it. */ 118 void ldv_unregister_chrdev_region(void) 119 { 120 /* LDV_COMMENT_ASSERT Usb gadget should not be registered at this point. */ 121 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 122 /* LDV_COMMENT_ASSERT Check that chrdev region is registered. */ 123 ldv_assert(ldv_usb_gadget_chrdev == LDV_USB_GADGET_CHRDEV_REGISTERED); 124 /* LDV_COMMENT_CHANGE_STATE Unregister chrdev. */ 125 ldv_usb_gadget_chrdev = LDV_USB_GADGET_CHRDEV_ZERO_STATE; 126 } 127 128 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_register_usb_gadget') Check that usb gadget was not registered and register it. */ 129 int ldv_register_usb_gadget(void) 130 { 131 int is_reg; 132 133 /* LDV_COMMENT_OTHER Register usb gadget in the nondeterministic way. */ 134 is_reg = ldv_undef_int_nonpositive(); 135 136 /* LDV_COMMENT_ASSERT Register usb gadget just in case when an error did not happen. */ 137 if (!is_reg) 138 { 139 /* LDV_COMMENT_ASSERT Gadget should not be registered at this point. */ 140 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 141 /* LDV_COMMENT_CHANGE_STATE Register usb gadget. */ 142 ldv_usb_gadget = LDV_USB_GADGET_REGISTERED; 143 } 144 145 /* LDV_COMMENT_RETURN Return registration status (0 is success). */ 146 return is_reg; 147 } 148 149 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_unregister_usb_gadget') Check that usb gadget was registered and unregister it. */ 150 void ldv_unregister_usb_gadget(void) 151 { 152 /* LDV_COMMENT_ASSERT Usb gadget should be registered at this point. */ 153 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_REGISTERED); 154 /* LDV_COMMENT_CHANGE_STATE Unregister usb gadget. */ 155 ldv_usb_gadget = LDV_USB_GADGET_ZERO_STATE; 156 } 157 158 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_check_final_state') Check that usb gadget is fully unregistered at the end. */ 159 void ldv_check_final_state(void) 160 { 161 /* LDV_COMMENT_ASSERT Usb gadget class should be unregistered at the end. */ 162 ldv_assert(ldv_usb_gadget_class == LDV_USB_GADGET_CLASS_ZERO_STATE); 163 /* LDV_COMMENT_ASSERT Chrdev region should be unregistered at the end. */ 164 ldv_assert(ldv_usb_gadget_chrdev == LDV_USB_GADGET_CHRDEV_ZERO_STATE); 165 /* LDV_COMMENT_ASSERT Usb gadget should be unregistered at the end. */ 166 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 167 }
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 /* Return nondeterministic negative integer number. */ 29 static inline int ldv_undef_int_negative(void) 30 { 31 int ret = ldv_undef_int(); 32 33 ldv_assume(ret < 0); 34 35 return ret; 36 } 37 /* Return nondeterministic nonpositive integer number. */ 38 static inline int ldv_undef_int_nonpositive(void) 39 { 40 int ret = ldv_undef_int(); 41 42 ldv_assume(ret <= 0); 43 44 return ret; 45 } 46 47 /* Add explicit model for __builin_expect GCC function. Without the model a 48 return value will be treated as nondetermined by verifiers. */ 49 long __builtin_expect(long exp, long c) 50 { 51 return exp; 52 } 53 54 /* This function causes the program to exit abnormally. GCC implements this 55 function by using a target-dependent mechanism (such as intentionally executing 56 an illegal instruction) or by calling abort. The mechanism used may vary from 57 release to release so you should not rely on any particular implementation. 58 http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */ 59 void __builtin_trap(void) 60 { 61 ldv_assert(0); 62 } 63 64 /* The constant is for simulating an error of ldv_undef_ptr() function. */ 65 #define LDV_PTR_MAX 2012 66 67 #endif /* _LDV_RCV_H_ */
1 #ifndef _LINUX_FS_H 2 #define _LINUX_FS_H 3 4 5 #include <linux/linkage.h> 6 #include <linux/wait.h> 7 #include <linux/kdev_t.h> 8 #include <linux/dcache.h> 9 #include <linux/path.h> 10 #include <linux/stat.h> 11 #include <linux/cache.h> 12 #include <linux/list.h> 13 #include <linux/list_lru.h> 14 #include <linux/llist.h> 15 #include <linux/radix-tree.h> 16 #include <linux/rbtree.h> 17 #include <linux/init.h> 18 #include <linux/pid.h> 19 #include <linux/bug.h> 20 #include <linux/mutex.h> 21 #include <linux/capability.h> 22 #include <linux/semaphore.h> 23 #include <linux/fiemap.h> 24 #include <linux/rculist_bl.h> 25 #include <linux/atomic.h> 26 #include <linux/shrinker.h> 27 #include <linux/migrate_mode.h> 28 #include <linux/uidgid.h> 29 #include <linux/lockdep.h> 30 #include <linux/percpu-rwsem.h> 31 #include <linux/blk_types.h> 32 33 #include <asm/byteorder.h> 34 #include <uapi/linux/fs.h> 35 36 struct export_operations; 37 struct hd_geometry; 38 struct iovec; 39 struct nameidata; 40 struct kiocb; 41 struct kobject; 42 struct pipe_inode_info; 43 struct poll_table_struct; 44 struct kstatfs; 45 struct vm_area_struct; 46 struct vfsmount; 47 struct cred; 48 struct swap_info_struct; 49 struct seq_file; 50 struct workqueue_struct; 51 struct iov_iter; 52 53 extern void __init inode_init(void); 54 extern void __init inode_init_early(void); 55 extern void __init files_init(unsigned long); 56 57 extern struct files_stat_struct files_stat; 58 extern unsigned long get_max_files(void); 59 extern int sysctl_nr_open; 60 extern struct inodes_stat_t inodes_stat; 61 extern int leases_enable, lease_break_time; 62 extern int sysctl_protected_symlinks; 63 extern int sysctl_protected_hardlinks; 64 65 struct buffer_head; 66 typedef int (get_block_t)(struct inode *inode, sector_t iblock, 67 struct buffer_head *bh_result, int create); 68 typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset, 69 ssize_t bytes, void *private); 70 71 #define MAY_EXEC 0x00000001 72 #define MAY_WRITE 0x00000002 73 #define MAY_READ 0x00000004 74 #define MAY_APPEND 0x00000008 75 #define MAY_ACCESS 0x00000010 76 #define MAY_OPEN 0x00000020 77 #define MAY_CHDIR 0x00000040 78 /* called from RCU mode, don't block */ 79 #define MAY_NOT_BLOCK 0x00000080 80 81 /* 82 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond 83 * to O_WRONLY and O_RDWR via the strange trick in __dentry_open() 84 */ 85 86 /* file is open for reading */ 87 #define FMODE_READ ((__force fmode_t)0x1) 88 /* file is open for writing */ 89 #define FMODE_WRITE ((__force fmode_t)0x2) 90 /* file is seekable */ 91 #define FMODE_LSEEK ((__force fmode_t)0x4) 92 /* file can be accessed using pread */ 93 #define FMODE_PREAD ((__force fmode_t)0x8) 94 /* file can be accessed using pwrite */ 95 #define FMODE_PWRITE ((__force fmode_t)0x10) 96 /* File is opened for execution with sys_execve / sys_uselib */ 97 #define FMODE_EXEC ((__force fmode_t)0x20) 98 /* File is opened with O_NDELAY (only set for block devices) */ 99 #define FMODE_NDELAY ((__force fmode_t)0x40) 100 /* File is opened with O_EXCL (only set for block devices) */ 101 #define FMODE_EXCL ((__force fmode_t)0x80) 102 /* File is opened using open(.., 3, ..) and is writeable only for ioctls 103 (specialy hack for floppy.c) */ 104 #define FMODE_WRITE_IOCTL ((__force fmode_t)0x100) 105 /* 32bit hashes as llseek() offset (for directories) */ 106 #define FMODE_32BITHASH ((__force fmode_t)0x200) 107 /* 64bit hashes as llseek() offset (for directories) */ 108 #define FMODE_64BITHASH ((__force fmode_t)0x400) 109 110 /* 111 * Don't update ctime and mtime. 112 * 113 * Currently a special hack for the XFS open_by_handle ioctl, but we'll 114 * hopefully graduate it to a proper O_CMTIME flag supported by open(2) soon. 115 */ 116 #define FMODE_NOCMTIME ((__force fmode_t)0x800) 117 118 /* Expect random access pattern */ 119 #define FMODE_RANDOM ((__force fmode_t)0x1000) 120 121 /* File is huge (eg. /dev/kmem): treat loff_t as unsigned */ 122 #define FMODE_UNSIGNED_OFFSET ((__force fmode_t)0x2000) 123 124 /* File is opened with O_PATH; almost nothing can be done with it */ 125 #define FMODE_PATH ((__force fmode_t)0x4000) 126 127 /* File needs atomic accesses to f_pos */ 128 #define FMODE_ATOMIC_POS ((__force fmode_t)0x8000) 129 /* Write access to underlying fs */ 130 #define FMODE_WRITER ((__force fmode_t)0x10000) 131 /* Has read method(s) */ 132 #define FMODE_CAN_READ ((__force fmode_t)0x20000) 133 /* Has write method(s) */ 134 #define FMODE_CAN_WRITE ((__force fmode_t)0x40000) 135 136 /* File was opened by fanotify and shouldn't generate fanotify events */ 137 #define FMODE_NONOTIFY ((__force fmode_t)0x1000000) 138 139 /* 140 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector 141 * that indicates that they should check the contents of the iovec are 142 * valid, but not check the memory that the iovec elements 143 * points too. 144 */ 145 #define CHECK_IOVEC_ONLY -1 146 147 /* 148 * The below are the various read and write types that we support. Some of 149 * them include behavioral modifiers that send information down to the 150 * block layer and IO scheduler. Terminology: 151 * 152 * The block layer uses device plugging to defer IO a little bit, in 153 * the hope that we will see more IO very shortly. This increases 154 * coalescing of adjacent IO and thus reduces the number of IOs we 155 * have to send to the device. It also allows for better queuing, 156 * if the IO isn't mergeable. If the caller is going to be waiting 157 * for the IO, then he must ensure that the device is unplugged so 158 * that the IO is dispatched to the driver. 159 * 160 * All IO is handled async in Linux. This is fine for background 161 * writes, but for reads or writes that someone waits for completion 162 * on, we want to notify the block layer and IO scheduler so that they 163 * know about it. That allows them to make better scheduling 164 * decisions. So when the below references 'sync' and 'async', it 165 * is referencing this priority hint. 166 * 167 * With that in mind, the available types are: 168 * 169 * READ A normal read operation. Device will be plugged. 170 * READ_SYNC A synchronous read. Device is not plugged, caller can 171 * immediately wait on this read without caring about 172 * unplugging. 173 * READA Used for read-ahead operations. Lower priority, and the 174 * block layer could (in theory) choose to ignore this 175 * request if it runs into resource problems. 176 * WRITE A normal async write. Device will be plugged. 177 * WRITE_SYNC Synchronous write. Identical to WRITE, but passes down 178 * the hint that someone will be waiting on this IO 179 * shortly. The write equivalent of READ_SYNC. 180 * WRITE_ODIRECT Special case write for O_DIRECT only. 181 * WRITE_FLUSH Like WRITE_SYNC but with preceding cache flush. 182 * WRITE_FUA Like WRITE_SYNC but data is guaranteed to be on 183 * non-volatile media on completion. 184 * WRITE_FLUSH_FUA Combination of WRITE_FLUSH and FUA. The IO is preceded 185 * by a cache flush and data is guaranteed to be on 186 * non-volatile media on completion. 187 * 188 */ 189 #define RW_MASK REQ_WRITE 190 #define RWA_MASK REQ_RAHEAD 191 192 #define READ 0 193 #define WRITE RW_MASK 194 #define READA RWA_MASK 195 #define KERNEL_READ (READ|REQ_KERNEL) 196 #define KERNEL_WRITE (WRITE|REQ_KERNEL) 197 198 #define READ_SYNC (READ | REQ_SYNC) 199 #define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE) 200 #define WRITE_ODIRECT (WRITE | REQ_SYNC) 201 #define WRITE_FLUSH (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH) 202 #define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA) 203 #define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA) 204 205 /* 206 * Attribute flags. These should be or-ed together to figure out what 207 * has been changed! 208 */ 209 #define ATTR_MODE (1 << 0) 210 #define ATTR_UID (1 << 1) 211 #define ATTR_GID (1 << 2) 212 #define ATTR_SIZE (1 << 3) 213 #define ATTR_ATIME (1 << 4) 214 #define ATTR_MTIME (1 << 5) 215 #define ATTR_CTIME (1 << 6) 216 #define ATTR_ATIME_SET (1 << 7) 217 #define ATTR_MTIME_SET (1 << 8) 218 #define ATTR_FORCE (1 << 9) /* Not a change, but a change it */ 219 #define ATTR_ATTR_FLAG (1 << 10) 220 #define ATTR_KILL_SUID (1 << 11) 221 #define ATTR_KILL_SGID (1 << 12) 222 #define ATTR_FILE (1 << 13) 223 #define ATTR_KILL_PRIV (1 << 14) 224 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */ 225 #define ATTR_TIMES_SET (1 << 16) 226 227 /* 228 * This is the Inode Attributes structure, used for notify_change(). It 229 * uses the above definitions as flags, to know which values have changed. 230 * Also, in this manner, a Filesystem can look at only the values it cares 231 * about. Basically, these are the attributes that the VFS layer can 232 * request to change from the FS layer. 233 * 234 * Derek Atkins <warlord@MIT.EDU> 94-10-20 235 */ 236 struct iattr { 237 unsigned int ia_valid; 238 umode_t ia_mode; 239 kuid_t ia_uid; 240 kgid_t ia_gid; 241 loff_t ia_size; 242 struct timespec ia_atime; 243 struct timespec ia_mtime; 244 struct timespec ia_ctime; 245 246 /* 247 * Not an attribute, but an auxiliary info for filesystems wanting to 248 * implement an ftruncate() like method. NOTE: filesystem should 249 * check for (ia_valid & ATTR_FILE), and not for (ia_file != NULL). 250 */ 251 struct file *ia_file; 252 }; 253 254 /* 255 * Includes for diskquotas. 256 */ 257 #include <linux/quota.h> 258 259 /** 260 * enum positive_aop_returns - aop return codes with specific semantics 261 * 262 * @AOP_WRITEPAGE_ACTIVATE: Informs the caller that page writeback has 263 * completed, that the page is still locked, and 264 * should be considered active. The VM uses this hint 265 * to return the page to the active list -- it won't 266 * be a candidate for writeback again in the near 267 * future. Other callers must be careful to unlock 268 * the page if they get this return. Returned by 269 * writepage(); 270 * 271 * @AOP_TRUNCATED_PAGE: The AOP method that was handed a locked page has 272 * unlocked it and the page might have been truncated. 273 * The caller should back up to acquiring a new page and 274 * trying again. The aop will be taking reasonable 275 * precautions not to livelock. If the caller held a page 276 * reference, it should drop it before retrying. Returned 277 * by readpage(). 278 * 279 * address_space_operation functions return these large constants to indicate 280 * special semantics to the caller. These are much larger than the bytes in a 281 * page to allow for functions that return the number of bytes operated on in a 282 * given page. 283 */ 284 285 enum positive_aop_returns { 286 AOP_WRITEPAGE_ACTIVATE = 0x80000, 287 AOP_TRUNCATED_PAGE = 0x80001, 288 }; 289 290 #define AOP_FLAG_UNINTERRUPTIBLE 0x0001 /* will not do a short write */ 291 #define AOP_FLAG_CONT_EXPAND 0x0002 /* called from cont_expand */ 292 #define AOP_FLAG_NOFS 0x0004 /* used by filesystem to direct 293 * helper code (eg buffer layer) 294 * to clear GFP_FS from alloc */ 295 296 /* 297 * oh the beauties of C type declarations. 298 */ 299 struct page; 300 struct address_space; 301 struct writeback_control; 302 303 /* 304 * "descriptor" for what we're up to with a read. 305 * This allows us to use the same read code yet 306 * have multiple different users of the data that 307 * we read from a file. 308 * 309 * The simplest case just copies the data to user 310 * mode. 311 */ 312 typedef struct { 313 size_t written; 314 size_t count; 315 union { 316 char __user *buf; 317 void *data; 318 } arg; 319 int error; 320 } read_descriptor_t; 321 322 typedef int (*read_actor_t)(read_descriptor_t *, struct page *, 323 unsigned long, unsigned long); 324 325 struct address_space_operations { 326 int (*writepage)(struct page *page, struct writeback_control *wbc); 327 int (*readpage)(struct file *, struct page *); 328 329 /* Write back some dirty pages from this mapping. */ 330 int (*writepages)(struct address_space *, struct writeback_control *); 331 332 /* Set a page dirty. Return true if this dirtied it */ 333 int (*set_page_dirty)(struct page *page); 334 335 int (*readpages)(struct file *filp, struct address_space *mapping, 336 struct list_head *pages, unsigned nr_pages); 337 338 int (*write_begin)(struct file *, struct address_space *mapping, 339 loff_t pos, unsigned len, unsigned flags, 340 struct page **pagep, void **fsdata); 341 int (*write_end)(struct file *, struct address_space *mapping, 342 loff_t pos, unsigned len, unsigned copied, 343 struct page *page, void *fsdata); 344 345 /* Unfortunately this kludge is needed for FIBMAP. Don't use it */ 346 sector_t (*bmap)(struct address_space *, sector_t); 347 void (*invalidatepage) (struct page *, unsigned int, unsigned int); 348 int (*releasepage) (struct page *, gfp_t); 349 void (*freepage)(struct page *); 350 ssize_t (*direct_IO)(int, struct kiocb *, struct iov_iter *iter, loff_t offset); 351 int (*get_xip_mem)(struct address_space *, pgoff_t, int, 352 void **, unsigned long *); 353 /* 354 * migrate the contents of a page to the specified target. If 355 * migrate_mode is MIGRATE_ASYNC, it must not block. 356 */ 357 int (*migratepage) (struct address_space *, 358 struct page *, struct page *, enum migrate_mode); 359 int (*launder_page) (struct page *); 360 int (*is_partially_uptodate) (struct page *, unsigned long, 361 unsigned long); 362 void (*is_dirty_writeback) (struct page *, bool *, bool *); 363 int (*error_remove_page)(struct address_space *, struct page *); 364 365 /* swapfile support */ 366 int (*swap_activate)(struct swap_info_struct *sis, struct file *file, 367 sector_t *span); 368 void (*swap_deactivate)(struct file *file); 369 }; 370 371 extern const struct address_space_operations empty_aops; 372 373 /* 374 * pagecache_write_begin/pagecache_write_end must be used by general code 375 * to write into the pagecache. 376 */ 377 int pagecache_write_begin(struct file *, struct address_space *mapping, 378 loff_t pos, unsigned len, unsigned flags, 379 struct page **pagep, void **fsdata); 380 381 int pagecache_write_end(struct file *, struct address_space *mapping, 382 loff_t pos, unsigned len, unsigned copied, 383 struct page *page, void *fsdata); 384 385 struct backing_dev_info; 386 struct address_space { 387 struct inode *host; /* owner: inode, block_device */ 388 struct radix_tree_root page_tree; /* radix tree of all pages */ 389 spinlock_t tree_lock; /* and lock protecting it */ 390 unsigned int i_mmap_writable;/* count VM_SHARED mappings */ 391 struct rb_root i_mmap; /* tree of private and shared mappings */ 392 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ 393 struct mutex i_mmap_mutex; /* protect tree, count, list */ 394 /* Protected by tree_lock together with the radix tree */ 395 unsigned long nrpages; /* number of total pages */ 396 unsigned long nrshadows; /* number of shadow entries */ 397 pgoff_t writeback_index;/* writeback starts here */ 398 const struct address_space_operations *a_ops; /* methods */ 399 unsigned long flags; /* error bits/gfp mask */ 400 struct backing_dev_info *backing_dev_info; /* device readahead, etc */ 401 spinlock_t private_lock; /* for use by the address_space */ 402 struct list_head private_list; /* ditto */ 403 void *private_data; /* ditto */ 404 } __attribute__((aligned(sizeof(long)))); 405 /* 406 * On most architectures that alignment is already the case; but 407 * must be enforced here for CRIS, to let the least significant bit 408 * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON. 409 */ 410 struct request_queue; 411 412 struct block_device { 413 dev_t bd_dev; /* not a kdev_t - it's a search key */ 414 int bd_openers; 415 struct inode * bd_inode; /* will die */ 416 struct super_block * bd_super; 417 struct mutex bd_mutex; /* open/close mutex */ 418 struct list_head bd_inodes; 419 void * bd_claiming; 420 void * bd_holder; 421 int bd_holders; 422 bool bd_write_holder; 423 #ifdef CONFIG_SYSFS 424 struct list_head bd_holder_disks; 425 #endif 426 struct block_device * bd_contains; 427 unsigned bd_block_size; 428 struct hd_struct * bd_part; 429 /* number of times partitions within this device have been opened. */ 430 unsigned bd_part_count; 431 int bd_invalidated; 432 struct gendisk * bd_disk; 433 struct request_queue * bd_queue; 434 struct list_head bd_list; 435 /* 436 * Private data. You must have bd_claim'ed the block_device 437 * to use this. NOTE: bd_claim allows an owner to claim 438 * the same device multiple times, the owner must take special 439 * care to not mess up bd_private for that case. 440 */ 441 unsigned long bd_private; 442 443 /* The counter of freeze processes */ 444 int bd_fsfreeze_count; 445 /* Mutex for freeze */ 446 struct mutex bd_fsfreeze_mutex; 447 }; 448 449 /* 450 * Radix-tree tags, for tagging dirty and writeback pages within the pagecache 451 * radix trees 452 */ 453 #define PAGECACHE_TAG_DIRTY 0 454 #define PAGECACHE_TAG_WRITEBACK 1 455 #define PAGECACHE_TAG_TOWRITE 2 456 457 int mapping_tagged(struct address_space *mapping, int tag); 458 459 /* 460 * Might pages of this file be mapped into userspace? 461 */ 462 static inline int mapping_mapped(struct address_space *mapping) 463 { 464 return !RB_EMPTY_ROOT(&mapping->i_mmap) || 465 !list_empty(&mapping->i_mmap_nonlinear); 466 } 467 468 /* 469 * Might pages of this file have been modified in userspace? 470 * Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap_pgoff 471 * marks vma as VM_SHARED if it is shared, and the file was opened for 472 * writing i.e. vma may be mprotected writable even if now readonly. 473 */ 474 static inline int mapping_writably_mapped(struct address_space *mapping) 475 { 476 return mapping->i_mmap_writable != 0; 477 } 478 479 /* 480 * Use sequence counter to get consistent i_size on 32-bit processors. 481 */ 482 #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 483 #include <linux/seqlock.h> 484 #define __NEED_I_SIZE_ORDERED 485 #define i_size_ordered_init(inode) seqcount_init(&inode->i_size_seqcount) 486 #else 487 #define i_size_ordered_init(inode) do { } while (0) 488 #endif 489 490 struct posix_acl; 491 #define ACL_NOT_CACHED ((void *)(-1)) 492 493 #define IOP_FASTPERM 0x0001 494 #define IOP_LOOKUP 0x0002 495 #define IOP_NOFOLLOW 0x0004 496 497 /* 498 * Keep mostly read-only and often accessed (especially for 499 * the RCU path lookup and 'stat' data) fields at the beginning 500 * of the 'struct inode' 501 */ 502 struct inode { 503 umode_t i_mode; 504 unsigned short i_opflags; 505 kuid_t i_uid; 506 kgid_t i_gid; 507 unsigned int i_flags; 508 509 #ifdef CONFIG_FS_POSIX_ACL 510 struct posix_acl *i_acl; 511 struct posix_acl *i_default_acl; 512 #endif 513 514 const struct inode_operations *i_op; 515 struct super_block *i_sb; 516 struct address_space *i_mapping; 517 518 #ifdef CONFIG_SECURITY 519 void *i_security; 520 #endif 521 522 /* Stat data, not accessed from path walking */ 523 unsigned long i_ino; 524 /* 525 * Filesystems may only read i_nlink directly. They shall use the 526 * following functions for modification: 527 * 528 * (set|clear|inc|drop)_nlink 529 * inode_(inc|dec)_link_count 530 */ 531 union { 532 const unsigned int i_nlink; 533 unsigned int __i_nlink; 534 }; 535 dev_t i_rdev; 536 loff_t i_size; 537 struct timespec i_atime; 538 struct timespec i_mtime; 539 struct timespec i_ctime; 540 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ 541 unsigned short i_bytes; 542 unsigned int i_blkbits; 543 blkcnt_t i_blocks; 544 545 #ifdef __NEED_I_SIZE_ORDERED 546 seqcount_t i_size_seqcount; 547 #endif 548 549 /* Misc */ 550 unsigned long i_state; 551 struct mutex i_mutex; 552 553 unsigned long dirtied_when; /* jiffies of first dirtying */ 554 555 struct hlist_node i_hash; 556 struct list_head i_wb_list; /* backing dev IO list */ 557 struct list_head i_lru; /* inode LRU list */ 558 struct list_head i_sb_list; 559 union { 560 struct hlist_head i_dentry; 561 struct rcu_head i_rcu; 562 }; 563 u64 i_version; 564 atomic_t i_count; 565 atomic_t i_dio_count; 566 atomic_t i_writecount; 567 #ifdef CONFIG_IMA 568 atomic_t i_readcount; /* struct files open RO */ 569 #endif 570 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ 571 struct file_lock *i_flock; 572 struct address_space i_data; 573 #ifdef CONFIG_QUOTA 574 struct dquot *i_dquot[MAXQUOTAS]; 575 #endif 576 struct list_head i_devices; 577 union { 578 struct pipe_inode_info *i_pipe; 579 struct block_device *i_bdev; 580 struct cdev *i_cdev; 581 }; 582 583 __u32 i_generation; 584 585 #ifdef CONFIG_FSNOTIFY 586 __u32 i_fsnotify_mask; /* all events this inode cares about */ 587 struct hlist_head i_fsnotify_marks; 588 #endif 589 590 void *i_private; /* fs or device private pointer */ 591 }; 592 593 static inline int inode_unhashed(struct inode *inode) 594 { 595 return hlist_unhashed(&inode->i_hash); 596 } 597 598 /* 599 * inode->i_mutex nesting subclasses for the lock validator: 600 * 601 * 0: the object of the current VFS operation 602 * 1: parent 603 * 2: child/target 604 * 3: xattr 605 * 4: second non-directory 606 * The last is for certain operations (such as rename) which lock two 607 * non-directories at once. 608 * 609 * The locking order between these classes is 610 * parent -> child -> normal -> xattr -> second non-directory 611 */ 612 enum inode_i_mutex_lock_class 613 { 614 I_MUTEX_NORMAL, 615 I_MUTEX_PARENT, 616 I_MUTEX_CHILD, 617 I_MUTEX_XATTR, 618 I_MUTEX_NONDIR2 619 }; 620 621 void lock_two_nondirectories(struct inode *, struct inode*); 622 void unlock_two_nondirectories(struct inode *, struct inode*); 623 624 /* 625 * NOTE: in a 32bit arch with a preemptable kernel and 626 * an UP compile the i_size_read/write must be atomic 627 * with respect to the local cpu (unlike with preempt disabled), 628 * but they don't need to be atomic with respect to other cpus like in 629 * true SMP (so they need either to either locally disable irq around 630 * the read or for example on x86 they can be still implemented as a 631 * cmpxchg8b without the need of the lock prefix). For SMP compiles 632 * and 64bit archs it makes no difference if preempt is enabled or not. 633 */ 634 static inline loff_t i_size_read(const struct inode *inode) 635 { 636 #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 637 loff_t i_size; 638 unsigned int seq; 639 640 do { 641 seq = read_seqcount_begin(&inode->i_size_seqcount); 642 i_size = inode->i_size; 643 } while (read_seqcount_retry(&inode->i_size_seqcount, seq)); 644 return i_size; 645 #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT) 646 loff_t i_size; 647 648 preempt_disable(); 649 i_size = inode->i_size; 650 preempt_enable(); 651 return i_size; 652 #else 653 return inode->i_size; 654 #endif 655 } 656 657 /* 658 * NOTE: unlike i_size_read(), i_size_write() does need locking around it 659 * (normally i_mutex), otherwise on 32bit/SMP an update of i_size_seqcount 660 * can be lost, resulting in subsequent i_size_read() calls spinning forever. 661 */ 662 static inline void i_size_write(struct inode *inode, loff_t i_size) 663 { 664 #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 665 preempt_disable(); 666 write_seqcount_begin(&inode->i_size_seqcount); 667 inode->i_size = i_size; 668 write_seqcount_end(&inode->i_size_seqcount); 669 preempt_enable(); 670 #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT) 671 preempt_disable(); 672 inode->i_size = i_size; 673 preempt_enable(); 674 #else 675 inode->i_size = i_size; 676 #endif 677 } 678 679 /* Helper functions so that in most cases filesystems will 680 * not need to deal directly with kuid_t and kgid_t and can 681 * instead deal with the raw numeric values that are stored 682 * in the filesystem. 683 */ 684 static inline uid_t i_uid_read(const struct inode *inode) 685 { 686 return from_kuid(&init_user_ns, inode->i_uid); 687 } 688 689 static inline gid_t i_gid_read(const struct inode *inode) 690 { 691 return from_kgid(&init_user_ns, inode->i_gid); 692 } 693 694 static inline void i_uid_write(struct inode *inode, uid_t uid) 695 { 696 inode->i_uid = make_kuid(&init_user_ns, uid); 697 } 698 699 static inline void i_gid_write(struct inode *inode, gid_t gid) 700 { 701 inode->i_gid = make_kgid(&init_user_ns, gid); 702 } 703 704 static inline unsigned iminor(const struct inode *inode) 705 { 706 return MINOR(inode->i_rdev); 707 } 708 709 static inline unsigned imajor(const struct inode *inode) 710 { 711 return MAJOR(inode->i_rdev); 712 } 713 714 extern struct block_device *I_BDEV(struct inode *inode); 715 716 struct fown_struct { 717 rwlock_t lock; /* protects pid, uid, euid fields */ 718 struct pid *pid; /* pid or -pgrp where SIGIO should be sent */ 719 enum pid_type pid_type; /* Kind of process group SIGIO should be sent to */ 720 kuid_t uid, euid; /* uid/euid of process setting the owner */ 721 int signum; /* posix.1b rt signal to be delivered on IO */ 722 }; 723 724 /* 725 * Track a single file's readahead state 726 */ 727 struct file_ra_state { 728 pgoff_t start; /* where readahead started */ 729 unsigned int size; /* # of readahead pages */ 730 unsigned int async_size; /* do asynchronous readahead when 731 there are only # of pages ahead */ 732 733 unsigned int ra_pages; /* Maximum readahead window */ 734 unsigned int mmap_miss; /* Cache miss stat for mmap accesses */ 735 loff_t prev_pos; /* Cache last read() position */ 736 }; 737 738 /* 739 * Check if @index falls in the readahead windows. 740 */ 741 static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index) 742 { 743 return (index >= ra->start && 744 index < ra->start + ra->size); 745 } 746 747 struct file { 748 union { 749 struct llist_node fu_llist; 750 struct rcu_head fu_rcuhead; 751 } f_u; 752 struct path f_path; 753 #define f_dentry f_path.dentry 754 struct inode *f_inode; /* cached value */ 755 const struct file_operations *f_op; 756 757 /* 758 * Protects f_ep_links, f_flags. 759 * Must not be taken from IRQ context. 760 */ 761 spinlock_t f_lock; 762 atomic_long_t f_count; 763 unsigned int f_flags; 764 fmode_t f_mode; 765 struct mutex f_pos_lock; 766 loff_t f_pos; 767 struct fown_struct f_owner; 768 const struct cred *f_cred; 769 struct file_ra_state f_ra; 770 771 u64 f_version; 772 #ifdef CONFIG_SECURITY 773 void *f_security; 774 #endif 775 /* needed for tty driver, and maybe others */ 776 void *private_data; 777 778 #ifdef CONFIG_EPOLL 779 /* Used by fs/eventpoll.c to link all the hooks to this file */ 780 struct list_head f_ep_links; 781 struct list_head f_tfile_llink; 782 #endif /* #ifdef CONFIG_EPOLL */ 783 struct address_space *f_mapping; 784 } __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ 785 786 struct file_handle { 787 __u32 handle_bytes; 788 int handle_type; 789 /* file identifier */ 790 unsigned char f_handle[0]; 791 }; 792 793 static inline struct file *get_file(struct file *f) 794 { 795 atomic_long_inc(&f->f_count); 796 return f; 797 } 798 #define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1) 799 #define file_count(x) atomic_long_read(&(x)->f_count) 800 801 #define MAX_NON_LFS ((1UL<<31) - 1) 802 803 /* Page cache limit. The filesystems should put that into their s_maxbytes 804 limits, otherwise bad things can happen in VM. */ 805 #if BITS_PER_LONG==32 806 #define MAX_LFS_FILESIZE (((loff_t)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) 807 #elif BITS_PER_LONG==64 808 #define MAX_LFS_FILESIZE ((loff_t)0x7fffffffffffffffLL) 809 #endif 810 811 #define FL_POSIX 1 812 #define FL_FLOCK 2 813 #define FL_DELEG 4 /* NFSv4 delegation */ 814 #define FL_ACCESS 8 /* not trying to lock, just looking */ 815 #define FL_EXISTS 16 /* when unlocking, test for existence */ 816 #define FL_LEASE 32 /* lease held on this file */ 817 #define FL_CLOSE 64 /* unlock on close */ 818 #define FL_SLEEP 128 /* A blocking lock */ 819 #define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */ 820 #define FL_UNLOCK_PENDING 512 /* Lease is being broken */ 821 #define FL_OFDLCK 1024 /* lock is "owned" by struct file */ 822 823 /* 824 * Special return value from posix_lock_file() and vfs_lock_file() for 825 * asynchronous locking. 826 */ 827 #define FILE_LOCK_DEFERRED 1 828 829 /* 830 * The POSIX file lock owner is determined by 831 * the "struct files_struct" in the thread group 832 * (or NULL for no owner - BSD locks). 833 * 834 * Lockd stuffs a "host" pointer into this. 835 */ 836 typedef struct files_struct *fl_owner_t; 837 838 struct file_lock_operations { 839 void (*fl_copy_lock)(struct file_lock *, struct file_lock *); 840 void (*fl_release_private)(struct file_lock *); 841 }; 842 843 struct lock_manager_operations { 844 int (*lm_compare_owner)(struct file_lock *, struct file_lock *); 845 unsigned long (*lm_owner_key)(struct file_lock *); 846 void (*lm_notify)(struct file_lock *); /* unblock callback */ 847 int (*lm_grant)(struct file_lock *, struct file_lock *, int); 848 void (*lm_break)(struct file_lock *); 849 int (*lm_change)(struct file_lock **, int); 850 }; 851 852 struct lock_manager { 853 struct list_head list; 854 }; 855 856 struct net; 857 void locks_start_grace(struct net *, struct lock_manager *); 858 void locks_end_grace(struct lock_manager *); 859 int locks_in_grace(struct net *); 860 861 /* that will die - we need it for nfs_lock_info */ 862 #include <linux/nfs_fs_i.h> 863 864 /* 865 * struct file_lock represents a generic "file lock". It's used to represent 866 * POSIX byte range locks, BSD (flock) locks, and leases. It's important to 867 * note that the same struct is used to represent both a request for a lock and 868 * the lock itself, but the same object is never used for both. 869 * 870 * FIXME: should we create a separate "struct lock_request" to help distinguish 871 * these two uses? 872 * 873 * The i_flock list is ordered by: 874 * 875 * 1) lock type -- FL_LEASEs first, then FL_FLOCK, and finally FL_POSIX 876 * 2) lock owner 877 * 3) lock range start 878 * 4) lock range end 879 * 880 * Obviously, the last two criteria only matter for POSIX locks. 881 */ 882 struct file_lock { 883 struct file_lock *fl_next; /* singly linked list for this inode */ 884 struct hlist_node fl_link; /* node in global lists */ 885 struct list_head fl_block; /* circular list of blocked processes */ 886 fl_owner_t fl_owner; 887 unsigned int fl_flags; 888 unsigned char fl_type; 889 unsigned int fl_pid; 890 int fl_link_cpu; /* what cpu's list is this on? */ 891 struct pid *fl_nspid; 892 wait_queue_head_t fl_wait; 893 struct file *fl_file; 894 loff_t fl_start; 895 loff_t fl_end; 896 897 struct fasync_struct * fl_fasync; /* for lease break notifications */ 898 /* for lease breaks: */ 899 unsigned long fl_break_time; 900 unsigned long fl_downgrade_time; 901 902 const struct file_lock_operations *fl_ops; /* Callbacks for filesystems */ 903 const struct lock_manager_operations *fl_lmops; /* Callbacks for lockmanagers */ 904 union { 905 struct nfs_lock_info nfs_fl; 906 struct nfs4_lock_info nfs4_fl; 907 struct { 908 struct list_head link; /* link in AFS vnode's pending_locks list */ 909 int state; /* state of grant or error if -ve */ 910 } afs; 911 } fl_u; 912 }; 913 914 /* The following constant reflects the upper bound of the file/locking space */ 915 #ifndef OFFSET_MAX 916 #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1))) 917 #define OFFSET_MAX INT_LIMIT(loff_t) 918 #define OFFT_OFFSET_MAX INT_LIMIT(off_t) 919 #endif 920 921 #include <linux/fcntl.h> 922 923 extern void send_sigio(struct fown_struct *fown, int fd, int band); 924 925 #ifdef CONFIG_FILE_LOCKING 926 extern int fcntl_getlk(struct file *, unsigned int, struct flock __user *); 927 extern int fcntl_setlk(unsigned int, struct file *, unsigned int, 928 struct flock __user *); 929 930 #if BITS_PER_LONG == 32 931 extern int fcntl_getlk64(struct file *, unsigned int, struct flock64 __user *); 932 extern int fcntl_setlk64(unsigned int, struct file *, unsigned int, 933 struct flock64 __user *); 934 #endif 935 936 extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); 937 extern int fcntl_getlease(struct file *filp); 938 939 /* fs/locks.c */ 940 void locks_free_lock(struct file_lock *fl); 941 extern void locks_init_lock(struct file_lock *); 942 extern struct file_lock * locks_alloc_lock(void); 943 extern void locks_copy_lock(struct file_lock *, struct file_lock *); 944 extern void __locks_copy_lock(struct file_lock *, const struct file_lock *); 945 extern void locks_remove_posix(struct file *, fl_owner_t); 946 extern void locks_remove_file(struct file *); 947 extern void locks_release_private(struct file_lock *); 948 extern void posix_test_lock(struct file *, struct file_lock *); 949 extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *); 950 extern int posix_lock_file_wait(struct file *, struct file_lock *); 951 extern int posix_unblock_lock(struct file_lock *); 952 extern int vfs_test_lock(struct file *, struct file_lock *); 953 extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *); 954 extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl); 955 extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl); 956 extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type); 957 extern void lease_get_mtime(struct inode *, struct timespec *time); 958 extern int generic_setlease(struct file *, long, struct file_lock **); 959 extern int vfs_setlease(struct file *, long, struct file_lock **); 960 extern int lease_modify(struct file_lock **, int); 961 extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 962 extern int lock_may_write(struct inode *, loff_t start, unsigned long count); 963 #else /* !CONFIG_FILE_LOCKING */ 964 static inline int fcntl_getlk(struct file *file, unsigned int cmd, 965 struct flock __user *user) 966 { 967 return -EINVAL; 968 } 969 970 static inline int fcntl_setlk(unsigned int fd, struct file *file, 971 unsigned int cmd, struct flock __user *user) 972 { 973 return -EACCES; 974 } 975 976 #if BITS_PER_LONG == 32 977 static inline int fcntl_getlk64(struct file *file, unsigned int cmd, 978 struct flock64 __user *user) 979 { 980 return -EINVAL; 981 } 982 983 static inline int fcntl_setlk64(unsigned int fd, struct file *file, 984 unsigned int cmd, struct flock64 __user *user) 985 { 986 return -EACCES; 987 } 988 #endif 989 static inline int fcntl_setlease(unsigned int fd, struct file *filp, long arg) 990 { 991 return 0; 992 } 993 994 static inline int fcntl_getlease(struct file *filp) 995 { 996 return 0; 997 } 998 999 static inline void locks_init_lock(struct file_lock *fl) 1000 { 1001 return; 1002 } 1003 1004 static inline void __locks_copy_lock(struct file_lock *new, struct file_lock *fl) 1005 { 1006 return; 1007 } 1008 1009 static inline void locks_copy_lock(struct file_lock *new, struct file_lock *fl) 1010 { 1011 return; 1012 } 1013 1014 static inline void locks_remove_posix(struct file *filp, fl_owner_t owner) 1015 { 1016 return; 1017 } 1018 1019 static inline void locks_remove_file(struct file *filp) 1020 { 1021 return; 1022 } 1023 1024 static inline void posix_test_lock(struct file *filp, struct file_lock *fl) 1025 { 1026 return; 1027 } 1028 1029 static inline int posix_lock_file(struct file *filp, struct file_lock *fl, 1030 struct file_lock *conflock) 1031 { 1032 return -ENOLCK; 1033 } 1034 1035 static inline int posix_lock_file_wait(struct file *filp, struct file_lock *fl) 1036 { 1037 return -ENOLCK; 1038 } 1039 1040 static inline int posix_unblock_lock(struct file_lock *waiter) 1041 { 1042 return -ENOENT; 1043 } 1044 1045 static inline int vfs_test_lock(struct file *filp, struct file_lock *fl) 1046 { 1047 return 0; 1048 } 1049 1050 static inline int vfs_lock_file(struct file *filp, unsigned int cmd, 1051 struct file_lock *fl, struct file_lock *conf) 1052 { 1053 return -ENOLCK; 1054 } 1055 1056 static inline int vfs_cancel_lock(struct file *filp, struct file_lock *fl) 1057 { 1058 return 0; 1059 } 1060 1061 static inline int flock_lock_file_wait(struct file *filp, 1062 struct file_lock *request) 1063 { 1064 return -ENOLCK; 1065 } 1066 1067 static inline int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) 1068 { 1069 return 0; 1070 } 1071 1072 static inline void lease_get_mtime(struct inode *inode, struct timespec *time) 1073 { 1074 return; 1075 } 1076 1077 static inline int generic_setlease(struct file *filp, long arg, 1078 struct file_lock **flp) 1079 { 1080 return -EINVAL; 1081 } 1082 1083 static inline int vfs_setlease(struct file *filp, long arg, 1084 struct file_lock **lease) 1085 { 1086 return -EINVAL; 1087 } 1088 1089 static inline int lease_modify(struct file_lock **before, int arg) 1090 { 1091 return -EINVAL; 1092 } 1093 1094 static inline int lock_may_read(struct inode *inode, loff_t start, 1095 unsigned long len) 1096 { 1097 return 1; 1098 } 1099 1100 static inline int lock_may_write(struct inode *inode, loff_t start, 1101 unsigned long len) 1102 { 1103 return 1; 1104 } 1105 #endif /* !CONFIG_FILE_LOCKING */ 1106 1107 1108 struct fasync_struct { 1109 spinlock_t fa_lock; 1110 int magic; 1111 int fa_fd; 1112 struct fasync_struct *fa_next; /* singly linked list */ 1113 struct file *fa_file; 1114 struct rcu_head fa_rcu; 1115 }; 1116 1117 #define FASYNC_MAGIC 0x4601 1118 1119 /* SMP safe fasync helpers: */ 1120 extern int fasync_helper(int, struct file *, int, struct fasync_struct **); 1121 extern struct fasync_struct *fasync_insert_entry(int, struct file *, struct fasync_struct **, struct fasync_struct *); 1122 extern int fasync_remove_entry(struct file *, struct fasync_struct **); 1123 extern struct fasync_struct *fasync_alloc(void); 1124 extern void fasync_free(struct fasync_struct *); 1125 1126 /* can be called from interrupts */ 1127 extern void kill_fasync(struct fasync_struct **, int, int); 1128 1129 extern int __f_setown(struct file *filp, struct pid *, enum pid_type, int force); 1130 extern int f_setown(struct file *filp, unsigned long arg, int force); 1131 extern void f_delown(struct file *filp); 1132 extern pid_t f_getown(struct file *filp); 1133 extern int send_sigurg(struct fown_struct *fown); 1134 1135 struct mm_struct; 1136 1137 /* 1138 * Umount options 1139 */ 1140 1141 #define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */ 1142 #define MNT_DETACH 0x00000002 /* Just detach from the tree */ 1143 #define MNT_EXPIRE 0x00000004 /* Mark for expiry */ 1144 #define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */ 1145 #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */ 1146 1147 extern struct list_head super_blocks; 1148 extern spinlock_t sb_lock; 1149 1150 /* Possible states of 'frozen' field */ 1151 enum { 1152 SB_UNFROZEN = 0, /* FS is unfrozen */ 1153 SB_FREEZE_WRITE = 1, /* Writes, dir ops, ioctls frozen */ 1154 SB_FREEZE_PAGEFAULT = 2, /* Page faults stopped as well */ 1155 SB_FREEZE_FS = 3, /* For internal FS use (e.g. to stop 1156 * internal threads if needed) */ 1157 SB_FREEZE_COMPLETE = 4, /* ->freeze_fs finished successfully */ 1158 }; 1159 1160 #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1) 1161 1162 struct sb_writers { 1163 /* Counters for counting writers at each level */ 1164 struct percpu_counter counter[SB_FREEZE_LEVELS]; 1165 wait_queue_head_t wait; /* queue for waiting for 1166 writers / faults to finish */ 1167 int frozen; /* Is sb frozen? */ 1168 wait_queue_head_t wait_unfrozen; /* queue for waiting for 1169 sb to be thawed */ 1170 #ifdef CONFIG_DEBUG_LOCK_ALLOC 1171 struct lockdep_map lock_map[SB_FREEZE_LEVELS]; 1172 #endif 1173 }; 1174 1175 struct super_block { 1176 struct list_head s_list; /* Keep this first */ 1177 dev_t s_dev; /* search index; _not_ kdev_t */ 1178 unsigned char s_blocksize_bits; 1179 unsigned long s_blocksize; 1180 loff_t s_maxbytes; /* Max file size */ 1181 struct file_system_type *s_type; 1182 const struct super_operations *s_op; 1183 const struct dquot_operations *dq_op; 1184 const struct quotactl_ops *s_qcop; 1185 const struct export_operations *s_export_op; 1186 unsigned long s_flags; 1187 unsigned long s_magic; 1188 struct dentry *s_root; 1189 struct rw_semaphore s_umount; 1190 int s_count; 1191 atomic_t s_active; 1192 #ifdef CONFIG_SECURITY 1193 void *s_security; 1194 #endif 1195 const struct xattr_handler **s_xattr; 1196 1197 struct list_head s_inodes; /* all inodes */ 1198 struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */ 1199 struct list_head s_mounts; /* list of mounts; _not_ for fs use */ 1200 struct block_device *s_bdev; 1201 struct backing_dev_info *s_bdi; 1202 struct mtd_info *s_mtd; 1203 struct hlist_node s_instances; 1204 struct quota_info s_dquot; /* Diskquota specific options */ 1205 1206 struct sb_writers s_writers; 1207 1208 char s_id[32]; /* Informational name */ 1209 u8 s_uuid[16]; /* UUID */ 1210 1211 void *s_fs_info; /* Filesystem private info */ 1212 unsigned int s_max_links; 1213 fmode_t s_mode; 1214 1215 /* Granularity of c/m/atime in ns. 1216 Cannot be worse than a second */ 1217 u32 s_time_gran; 1218 1219 /* 1220 * The next field is for VFS *only*. No filesystems have any business 1221 * even looking at it. You had been warned. 1222 */ 1223 struct mutex s_vfs_rename_mutex; /* Kludge */ 1224 1225 /* 1226 * Filesystem subtype. If non-empty the filesystem type field 1227 * in /proc/mounts will be "type.subtype" 1228 */ 1229 char *s_subtype; 1230 1231 /* 1232 * Saved mount options for lazy filesystems using 1233 * generic_show_options() 1234 */ 1235 char __rcu *s_options; 1236 const struct dentry_operations *s_d_op; /* default d_op for dentries */ 1237 1238 /* 1239 * Saved pool identifier for cleancache (-1 means none) 1240 */ 1241 int cleancache_poolid; 1242 1243 struct shrinker s_shrink; /* per-sb shrinker handle */ 1244 1245 /* Number of inodes with nlink == 0 but still referenced */ 1246 atomic_long_t s_remove_count; 1247 1248 /* Being remounted read-only */ 1249 int s_readonly_remount; 1250 1251 /* AIO completions deferred from interrupt context */ 1252 struct workqueue_struct *s_dio_done_wq; 1253 1254 /* 1255 * Keep the lru lists last in the structure so they always sit on their 1256 * own individual cachelines. 1257 */ 1258 struct list_lru s_dentry_lru ____cacheline_aligned_in_smp; 1259 struct list_lru s_inode_lru ____cacheline_aligned_in_smp; 1260 struct rcu_head rcu; 1261 }; 1262 1263 extern struct timespec current_fs_time(struct super_block *sb); 1264 1265 /* 1266 * Snapshotting support. 1267 */ 1268 1269 void __sb_end_write(struct super_block *sb, int level); 1270 int __sb_start_write(struct super_block *sb, int level, bool wait); 1271 1272 /** 1273 * sb_end_write - drop write access to a superblock 1274 * @sb: the super we wrote to 1275 * 1276 * Decrement number of writers to the filesystem. Wake up possible waiters 1277 * wanting to freeze the filesystem. 1278 */ 1279 static inline void sb_end_write(struct super_block *sb) 1280 { 1281 __sb_end_write(sb, SB_FREEZE_WRITE); 1282 } 1283 1284 /** 1285 * sb_end_pagefault - drop write access to a superblock from a page fault 1286 * @sb: the super we wrote to 1287 * 1288 * Decrement number of processes handling write page fault to the filesystem. 1289 * Wake up possible waiters wanting to freeze the filesystem. 1290 */ 1291 static inline void sb_end_pagefault(struct super_block *sb) 1292 { 1293 __sb_end_write(sb, SB_FREEZE_PAGEFAULT); 1294 } 1295 1296 /** 1297 * sb_end_intwrite - drop write access to a superblock for internal fs purposes 1298 * @sb: the super we wrote to 1299 * 1300 * Decrement fs-internal number of writers to the filesystem. Wake up possible 1301 * waiters wanting to freeze the filesystem. 1302 */ 1303 static inline void sb_end_intwrite(struct super_block *sb) 1304 { 1305 __sb_end_write(sb, SB_FREEZE_FS); 1306 } 1307 1308 /** 1309 * sb_start_write - get write access to a superblock 1310 * @sb: the super we write to 1311 * 1312 * When a process wants to write data or metadata to a file system (i.e. dirty 1313 * a page or an inode), it should embed the operation in a sb_start_write() - 1314 * sb_end_write() pair to get exclusion against file system freezing. This 1315 * function increments number of writers preventing freezing. If the file 1316 * system is already frozen, the function waits until the file system is 1317 * thawed. 1318 * 1319 * Since freeze protection behaves as a lock, users have to preserve 1320 * ordering of freeze protection and other filesystem locks. Generally, 1321 * freeze protection should be the outermost lock. In particular, we have: 1322 * 1323 * sb_start_write 1324 * -> i_mutex (write path, truncate, directory ops, ...) 1325 * -> s_umount (freeze_super, thaw_super) 1326 */ 1327 static inline void sb_start_write(struct super_block *sb) 1328 { 1329 __sb_start_write(sb, SB_FREEZE_WRITE, true); 1330 } 1331 1332 static inline int sb_start_write_trylock(struct super_block *sb) 1333 { 1334 return __sb_start_write(sb, SB_FREEZE_WRITE, false); 1335 } 1336 1337 /** 1338 * sb_start_pagefault - get write access to a superblock from a page fault 1339 * @sb: the super we write to 1340 * 1341 * When a process starts handling write page fault, it should embed the 1342 * operation into sb_start_pagefault() - sb_end_pagefault() pair to get 1343 * exclusion against file system freezing. This is needed since the page fault 1344 * is going to dirty a page. This function increments number of running page 1345 * faults preventing freezing. If the file system is already frozen, the 1346 * function waits until the file system is thawed. 1347 * 1348 * Since page fault freeze protection behaves as a lock, users have to preserve 1349 * ordering of freeze protection and other filesystem locks. It is advised to 1350 * put sb_start_pagefault() close to mmap_sem in lock ordering. Page fault 1351 * handling code implies lock dependency: 1352 * 1353 * mmap_sem 1354 * -> sb_start_pagefault 1355 */ 1356 static inline void sb_start_pagefault(struct super_block *sb) 1357 { 1358 __sb_start_write(sb, SB_FREEZE_PAGEFAULT, true); 1359 } 1360 1361 /* 1362 * sb_start_intwrite - get write access to a superblock for internal fs purposes 1363 * @sb: the super we write to 1364 * 1365 * This is the third level of protection against filesystem freezing. It is 1366 * free for use by a filesystem. The only requirement is that it must rank 1367 * below sb_start_pagefault. 1368 * 1369 * For example filesystem can call sb_start_intwrite() when starting a 1370 * transaction which somewhat eases handling of freezing for internal sources 1371 * of filesystem changes (internal fs threads, discarding preallocation on file 1372 * close, etc.). 1373 */ 1374 static inline void sb_start_intwrite(struct super_block *sb) 1375 { 1376 __sb_start_write(sb, SB_FREEZE_FS, true); 1377 } 1378 1379 1380 extern bool inode_owner_or_capable(const struct inode *inode); 1381 1382 /* 1383 * VFS helper functions.. 1384 */ 1385 extern int vfs_create(struct inode *, struct dentry *, umode_t, bool); 1386 extern int vfs_mkdir(struct inode *, struct dentry *, umode_t); 1387 extern int vfs_mknod(struct inode *, struct dentry *, umode_t, dev_t); 1388 extern int vfs_symlink(struct inode *, struct dentry *, const char *); 1389 extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct inode **); 1390 extern int vfs_rmdir(struct inode *, struct dentry *); 1391 extern int vfs_unlink(struct inode *, struct dentry *, struct inode **); 1392 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int); 1393 1394 /* 1395 * VFS dentry helper functions. 1396 */ 1397 extern void dentry_unhash(struct dentry *dentry); 1398 1399 /* 1400 * VFS file helper functions. 1401 */ 1402 extern void inode_init_owner(struct inode *inode, const struct inode *dir, 1403 umode_t mode); 1404 /* 1405 * VFS FS_IOC_FIEMAP helper definitions. 1406 */ 1407 struct fiemap_extent_info { 1408 unsigned int fi_flags; /* Flags as passed from user */ 1409 unsigned int fi_extents_mapped; /* Number of mapped extents */ 1410 unsigned int fi_extents_max; /* Size of fiemap_extent array */ 1411 struct fiemap_extent __user *fi_extents_start; /* Start of 1412 fiemap_extent array */ 1413 }; 1414 int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, 1415 u64 phys, u64 len, u32 flags); 1416 int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags); 1417 1418 /* 1419 * File types 1420 * 1421 * NOTE! These match bits 12..15 of stat.st_mode 1422 * (ie "(i_mode >> 12) & 15"). 1423 */ 1424 #define DT_UNKNOWN 0 1425 #define DT_FIFO 1 1426 #define DT_CHR 2 1427 #define DT_DIR 4 1428 #define DT_BLK 6 1429 #define DT_REG 8 1430 #define DT_LNK 10 1431 #define DT_SOCK 12 1432 #define DT_WHT 14 1433 1434 /* 1435 * This is the "filldir" function type, used by readdir() to let 1436 * the kernel specify what kind of dirent layout it wants to have. 1437 * This allows the kernel to read directories into kernel space or 1438 * to have different dirent layouts depending on the binary type. 1439 */ 1440 typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned); 1441 struct dir_context { 1442 const filldir_t actor; 1443 loff_t pos; 1444 }; 1445 1446 struct block_device_operations; 1447 1448 /* These macros are for out of kernel modules to test that 1449 * the kernel supports the unlocked_ioctl and compat_ioctl 1450 * fields in struct file_operations. */ 1451 #define HAVE_COMPAT_IOCTL 1 1452 #define HAVE_UNLOCKED_IOCTL 1 1453 1454 struct iov_iter; 1455 1456 struct file_operations { 1457 struct module *owner; 1458 loff_t (*llseek) (struct file *, loff_t, int); 1459 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); 1460 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); 1461 ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t); 1462 ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t); 1463 ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); 1464 ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); 1465 int (*iterate) (struct file *, struct dir_context *); 1466 unsigned int (*poll) (struct file *, struct poll_table_struct *); 1467 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 1468 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1469 int (*mmap) (struct file *, struct vm_area_struct *); 1470 int (*open) (struct inode *, struct file *); 1471 int (*flush) (struct file *, fl_owner_t id); 1472 int (*release) (struct inode *, struct file *); 1473 int (*fsync) (struct file *, loff_t, loff_t, int datasync); 1474 int (*aio_fsync) (struct kiocb *, int datasync); 1475 int (*fasync) (int, struct file *, int); 1476 int (*lock) (struct file *, int, struct file_lock *); 1477 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); 1478 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 1479 int (*check_flags)(int); 1480 int (*flock) (struct file *, int, struct file_lock *); 1481 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); 1482 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); 1483 int (*setlease)(struct file *, long, struct file_lock **); 1484 long (*fallocate)(struct file *file, int mode, loff_t offset, 1485 loff_t len); 1486 int (*show_fdinfo)(struct seq_file *m, struct file *f); 1487 }; 1488 1489 struct inode_operations { 1490 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); 1491 void * (*follow_link) (struct dentry *, struct nameidata *); 1492 int (*permission) (struct inode *, int); 1493 struct posix_acl * (*get_acl)(struct inode *, int); 1494 1495 int (*readlink) (struct dentry *, char __user *,int); 1496 void (*put_link) (struct dentry *, struct nameidata *, void *); 1497 1498 int (*create) (struct inode *,struct dentry *, umode_t, bool); 1499 int (*link) (struct dentry *,struct inode *,struct dentry *); 1500 int (*unlink) (struct inode *,struct dentry *); 1501 int (*symlink) (struct inode *,struct dentry *,const char *); 1502 int (*mkdir) (struct inode *,struct dentry *,umode_t); 1503 int (*rmdir) (struct inode *,struct dentry *); 1504 int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); 1505 int (*rename) (struct inode *, struct dentry *, 1506 struct inode *, struct dentry *); 1507 int (*rename2) (struct inode *, struct dentry *, 1508 struct inode *, struct dentry *, unsigned int); 1509 int (*setattr) (struct dentry *, struct iattr *); 1510 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); 1511 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); 1512 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); 1513 ssize_t (*listxattr) (struct dentry *, char *, size_t); 1514 int (*removexattr) (struct dentry *, const char *); 1515 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, 1516 u64 len); 1517 int (*update_time)(struct inode *, struct timespec *, int); 1518 int (*atomic_open)(struct inode *, struct dentry *, 1519 struct file *, unsigned open_flag, 1520 umode_t create_mode, int *opened); 1521 int (*tmpfile) (struct inode *, struct dentry *, umode_t); 1522 int (*set_acl)(struct inode *, struct posix_acl *, int); 1523 } ____cacheline_aligned; 1524 1525 ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, 1526 unsigned long nr_segs, unsigned long fast_segs, 1527 struct iovec *fast_pointer, 1528 struct iovec **ret_pointer); 1529 1530 extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); 1531 extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *); 1532 extern ssize_t vfs_readv(struct file *, const struct iovec __user *, 1533 unsigned long, loff_t *); 1534 extern ssize_t vfs_writev(struct file *, const struct iovec __user *, 1535 unsigned long, loff_t *); 1536 1537 struct super_operations { 1538 struct inode *(*alloc_inode)(struct super_block *sb); 1539 void (*destroy_inode)(struct inode *); 1540 1541 void (*dirty_inode) (struct inode *, int flags); 1542 int (*write_inode) (struct inode *, struct writeback_control *wbc); 1543 int (*drop_inode) (struct inode *); 1544 void (*evict_inode) (struct inode *); 1545 void (*put_super) (struct super_block *); 1546 int (*sync_fs)(struct super_block *sb, int wait); 1547 int (*freeze_fs) (struct super_block *); 1548 int (*unfreeze_fs) (struct super_block *); 1549 int (*statfs) (struct dentry *, struct kstatfs *); 1550 int (*remount_fs) (struct super_block *, int *, char *); 1551 void (*umount_begin) (struct super_block *); 1552 1553 int (*show_options)(struct seq_file *, struct dentry *); 1554 int (*show_devname)(struct seq_file *, struct dentry *); 1555 int (*show_path)(struct seq_file *, struct dentry *); 1556 int (*show_stats)(struct seq_file *, struct dentry *); 1557 #ifdef CONFIG_QUOTA 1558 ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); 1559 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); 1560 #endif 1561 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); 1562 long (*nr_cached_objects)(struct super_block *, int); 1563 long (*free_cached_objects)(struct super_block *, long, int); 1564 }; 1565 1566 /* 1567 * Inode flags - they have no relation to superblock flags now 1568 */ 1569 #define S_SYNC 1 /* Writes are synced at once */ 1570 #define S_NOATIME 2 /* Do not update access times */ 1571 #define S_APPEND 4 /* Append-only file */ 1572 #define S_IMMUTABLE 8 /* Immutable file */ 1573 #define S_DEAD 16 /* removed, but still open directory */ 1574 #define S_NOQUOTA 32 /* Inode is not counted to quota */ 1575 #define S_DIRSYNC 64 /* Directory modifications are synchronous */ 1576 #define S_NOCMTIME 128 /* Do not update file c/mtime */ 1577 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ 1578 #define S_PRIVATE 512 /* Inode is fs-internal */ 1579 #define S_IMA 1024 /* Inode has an associated IMA struct */ 1580 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ 1581 #define S_NOSEC 4096 /* no suid or xattr security attributes */ 1582 1583 /* 1584 * Note that nosuid etc flags are inode-specific: setting some file-system 1585 * flags just means all the inodes inherit those flags by default. It might be 1586 * possible to override it selectively if you really wanted to with some 1587 * ioctl() that is not currently implemented. 1588 * 1589 * Exception: MS_RDONLY is always applied to the entire file system. 1590 * 1591 * Unfortunately, it is possible to change a filesystems flags with it mounted 1592 * with files in use. This means that all of the inodes will not have their 1593 * i_flags updated. Hence, i_flags no longer inherit the superblock mount 1594 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org 1595 */ 1596 #define __IS_FLG(inode, flg) ((inode)->i_sb->s_flags & (flg)) 1597 1598 #define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY) 1599 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \ 1600 ((inode)->i_flags & S_SYNC)) 1601 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \ 1602 ((inode)->i_flags & (S_SYNC|S_DIRSYNC))) 1603 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK) 1604 #define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME) 1605 #define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION) 1606 1607 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA) 1608 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) 1609 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE) 1610 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL) 1611 1612 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD) 1613 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME) 1614 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE) 1615 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE) 1616 #define IS_IMA(inode) ((inode)->i_flags & S_IMA) 1617 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) 1618 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) 1619 1620 /* 1621 * Inode state bits. Protected by inode->i_lock 1622 * 1623 * Three bits determine the dirty state of the inode, I_DIRTY_SYNC, 1624 * I_DIRTY_DATASYNC and I_DIRTY_PAGES. 1625 * 1626 * Four bits define the lifetime of an inode. Initially, inodes are I_NEW, 1627 * until that flag is cleared. I_WILL_FREE, I_FREEING and I_CLEAR are set at 1628 * various stages of removing an inode. 1629 * 1630 * Two bits are used for locking and completion notification, I_NEW and I_SYNC. 1631 * 1632 * I_DIRTY_SYNC Inode is dirty, but doesn't have to be written on 1633 * fdatasync(). i_atime is the usual cause. 1634 * I_DIRTY_DATASYNC Data-related inode changes pending. We keep track of 1635 * these changes separately from I_DIRTY_SYNC so that we 1636 * don't have to write inode on fdatasync() when only 1637 * mtime has changed in it. 1638 * I_DIRTY_PAGES Inode has dirty pages. Inode itself may be clean. 1639 * I_NEW Serves as both a mutex and completion notification. 1640 * New inodes set I_NEW. If two processes both create 1641 * the same inode, one of them will release its inode and 1642 * wait for I_NEW to be released before returning. 1643 * Inodes in I_WILL_FREE, I_FREEING or I_CLEAR state can 1644 * also cause waiting on I_NEW, without I_NEW actually 1645 * being set. find_inode() uses this to prevent returning 1646 * nearly-dead inodes. 1647 * I_WILL_FREE Must be set when calling write_inode_now() if i_count 1648 * is zero. I_FREEING must be set when I_WILL_FREE is 1649 * cleared. 1650 * I_FREEING Set when inode is about to be freed but still has dirty 1651 * pages or buffers attached or the inode itself is still 1652 * dirty. 1653 * I_CLEAR Added by clear_inode(). In this state the inode is 1654 * clean and can be destroyed. Inode keeps I_FREEING. 1655 * 1656 * Inodes that are I_WILL_FREE, I_FREEING or I_CLEAR are 1657 * prohibited for many purposes. iget() must wait for 1658 * the inode to be completely released, then create it 1659 * anew. Other functions will just ignore such inodes, 1660 * if appropriate. I_NEW is used for waiting. 1661 * 1662 * I_SYNC Writeback of inode is running. The bit is set during 1663 * data writeback, and cleared with a wakeup on the bit 1664 * address once it is done. The bit is also used to pin 1665 * the inode in memory for flusher thread. 1666 * 1667 * I_REFERENCED Marks the inode as recently references on the LRU list. 1668 * 1669 * I_DIO_WAKEUP Never set. Only used as a key for wait_on_bit(). 1670 * 1671 * Q: What is the difference between I_WILL_FREE and I_FREEING? 1672 */ 1673 #define I_DIRTY_SYNC (1 << 0) 1674 #define I_DIRTY_DATASYNC (1 << 1) 1675 #define I_DIRTY_PAGES (1 << 2) 1676 #define __I_NEW 3 1677 #define I_NEW (1 << __I_NEW) 1678 #define I_WILL_FREE (1 << 4) 1679 #define I_FREEING (1 << 5) 1680 #define I_CLEAR (1 << 6) 1681 #define __I_SYNC 7 1682 #define I_SYNC (1 << __I_SYNC) 1683 #define I_REFERENCED (1 << 8) 1684 #define __I_DIO_WAKEUP 9 1685 #define I_DIO_WAKEUP (1 << I_DIO_WAKEUP) 1686 #define I_LINKABLE (1 << 10) 1687 1688 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) 1689 1690 extern void __mark_inode_dirty(struct inode *, int); 1691 static inline void mark_inode_dirty(struct inode *inode) 1692 { 1693 __mark_inode_dirty(inode, I_DIRTY); 1694 } 1695 1696 static inline void mark_inode_dirty_sync(struct inode *inode) 1697 { 1698 __mark_inode_dirty(inode, I_DIRTY_SYNC); 1699 } 1700 1701 extern void inc_nlink(struct inode *inode); 1702 extern void drop_nlink(struct inode *inode); 1703 extern void clear_nlink(struct inode *inode); 1704 extern void set_nlink(struct inode *inode, unsigned int nlink); 1705 1706 static inline void inode_inc_link_count(struct inode *inode) 1707 { 1708 inc_nlink(inode); 1709 mark_inode_dirty(inode); 1710 } 1711 1712 static inline void inode_dec_link_count(struct inode *inode) 1713 { 1714 drop_nlink(inode); 1715 mark_inode_dirty(inode); 1716 } 1717 1718 /** 1719 * inode_inc_iversion - increments i_version 1720 * @inode: inode that need to be updated 1721 * 1722 * Every time the inode is modified, the i_version field will be incremented. 1723 * The filesystem has to be mounted with i_version flag 1724 */ 1725 1726 static inline void inode_inc_iversion(struct inode *inode) 1727 { 1728 spin_lock(&inode->i_lock); 1729 inode->i_version++; 1730 spin_unlock(&inode->i_lock); 1731 } 1732 1733 enum file_time_flags { 1734 S_ATIME = 1, 1735 S_MTIME = 2, 1736 S_CTIME = 4, 1737 S_VERSION = 8, 1738 }; 1739 1740 extern void touch_atime(const struct path *); 1741 static inline void file_accessed(struct file *file) 1742 { 1743 if (!(file->f_flags & O_NOATIME)) 1744 touch_atime(&file->f_path); 1745 } 1746 1747 int sync_inode(struct inode *inode, struct writeback_control *wbc); 1748 int sync_inode_metadata(struct inode *inode, int wait); 1749 1750 struct file_system_type { 1751 const char *name; 1752 int fs_flags; 1753 #define FS_REQUIRES_DEV 1 1754 #define FS_BINARY_MOUNTDATA 2 1755 #define FS_HAS_SUBTYPE 4 1756 #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ 1757 #define FS_USERNS_DEV_MOUNT 16 /* A userns mount does not imply MNT_NODEV */ 1758 #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ 1759 struct dentry *(*mount) (struct file_system_type *, int, 1760 const char *, void *); 1761 void (*kill_sb) (struct super_block *); 1762 struct module *owner; 1763 struct file_system_type * next; 1764 struct hlist_head fs_supers; 1765 1766 struct lock_class_key s_lock_key; 1767 struct lock_class_key s_umount_key; 1768 struct lock_class_key s_vfs_rename_key; 1769 struct lock_class_key s_writers_key[SB_FREEZE_LEVELS]; 1770 1771 struct lock_class_key i_lock_key; 1772 struct lock_class_key i_mutex_key; 1773 struct lock_class_key i_mutex_dir_key; 1774 }; 1775 1776 #define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME) 1777 1778 extern struct dentry *mount_ns(struct file_system_type *fs_type, int flags, 1779 void *data, int (*fill_super)(struct super_block *, void *, int)); 1780 extern struct dentry *mount_bdev(struct file_system_type *fs_type, 1781 int flags, const char *dev_name, void *data, 1782 int (*fill_super)(struct super_block *, void *, int)); 1783 extern struct dentry *mount_single(struct file_system_type *fs_type, 1784 int flags, void *data, 1785 int (*fill_super)(struct super_block *, void *, int)); 1786 extern struct dentry *mount_nodev(struct file_system_type *fs_type, 1787 int flags, void *data, 1788 int (*fill_super)(struct super_block *, void *, int)); 1789 extern struct dentry *mount_subtree(struct vfsmount *mnt, const char *path); 1790 void generic_shutdown_super(struct super_block *sb); 1791 void kill_block_super(struct super_block *sb); 1792 void kill_anon_super(struct super_block *sb); 1793 void kill_litter_super(struct super_block *sb); 1794 void deactivate_super(struct super_block *sb); 1795 void deactivate_locked_super(struct super_block *sb); 1796 int set_anon_super(struct super_block *s, void *data); 1797 int get_anon_bdev(dev_t *); 1798 void free_anon_bdev(dev_t); 1799 struct super_block *sget(struct file_system_type *type, 1800 int (*test)(struct super_block *,void *), 1801 int (*set)(struct super_block *,void *), 1802 int flags, void *data); 1803 extern struct dentry *mount_pseudo(struct file_system_type *, char *, 1804 const struct super_operations *ops, 1805 const struct dentry_operations *dops, 1806 unsigned long); 1807 1808 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ 1809 #define fops_get(fops) \ 1810 (((fops) && try_module_get((fops)->owner) ? (fops) : NULL)) 1811 #define fops_put(fops) \ 1812 do { if (fops) module_put((fops)->owner); } while(0) 1813 /* 1814 * This one is to be used *ONLY* from ->open() instances. 1815 * fops must be non-NULL, pinned down *and* module dependencies 1816 * should be sufficient to pin the caller down as well. 1817 */ 1818 #define replace_fops(f, fops) \ 1819 do { \ 1820 struct file *__file = (f); \ 1821 fops_put(__file->f_op); \ 1822 BUG_ON(!(__file->f_op = (fops))); \ 1823 } while(0) 1824 1825 extern int register_filesystem(struct file_system_type *); 1826 extern int unregister_filesystem(struct file_system_type *); 1827 extern struct vfsmount *kern_mount_data(struct file_system_type *, void *data); 1828 #define kern_mount(type) kern_mount_data(type, NULL) 1829 extern void kern_unmount(struct vfsmount *mnt); 1830 extern int may_umount_tree(struct vfsmount *); 1831 extern int may_umount(struct vfsmount *); 1832 extern long do_mount(const char *, const char *, const char *, unsigned long, void *); 1833 extern struct vfsmount *collect_mounts(struct path *); 1834 extern void drop_collected_mounts(struct vfsmount *); 1835 extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, 1836 struct vfsmount *); 1837 extern int vfs_statfs(struct path *, struct kstatfs *); 1838 extern int user_statfs(const char __user *, struct kstatfs *); 1839 extern int fd_statfs(int, struct kstatfs *); 1840 extern int vfs_ustat(dev_t, struct kstatfs *); 1841 extern int freeze_super(struct super_block *super); 1842 extern int thaw_super(struct super_block *super); 1843 extern bool our_mnt(struct vfsmount *mnt); 1844 extern bool fs_fully_visible(struct file_system_type *); 1845 1846 extern int current_umask(void); 1847 1848 extern void ihold(struct inode * inode); 1849 extern void iput(struct inode *); 1850 1851 static inline struct inode *file_inode(struct file *f) 1852 { 1853 return f->f_inode; 1854 } 1855 1856 /* /sys/fs */ 1857 extern struct kobject *fs_kobj; 1858 1859 #define MAX_RW_COUNT (INT_MAX & PAGE_CACHE_MASK) 1860 1861 #define FLOCK_VERIFY_READ 1 1862 #define FLOCK_VERIFY_WRITE 2 1863 1864 #ifdef CONFIG_FILE_LOCKING 1865 extern int locks_mandatory_locked(struct file *); 1866 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); 1867 1868 /* 1869 * Candidates for mandatory locking have the setgid bit set 1870 * but no group execute bit - an otherwise meaningless combination. 1871 */ 1872 1873 static inline int __mandatory_lock(struct inode *ino) 1874 { 1875 return (ino->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID; 1876 } 1877 1878 /* 1879 * ... and these candidates should be on MS_MANDLOCK mounted fs, 1880 * otherwise these will be advisory locks 1881 */ 1882 1883 static inline int mandatory_lock(struct inode *ino) 1884 { 1885 return IS_MANDLOCK(ino) && __mandatory_lock(ino); 1886 } 1887 1888 static inline int locks_verify_locked(struct file *file) 1889 { 1890 if (mandatory_lock(file_inode(file))) 1891 return locks_mandatory_locked(file); 1892 return 0; 1893 } 1894 1895 static inline int locks_verify_truncate(struct inode *inode, 1896 struct file *filp, 1897 loff_t size) 1898 { 1899 if (inode->i_flock && mandatory_lock(inode)) 1900 return locks_mandatory_area( 1901 FLOCK_VERIFY_WRITE, inode, filp, 1902 size < inode->i_size ? size : inode->i_size, 1903 (size < inode->i_size ? inode->i_size - size 1904 : size - inode->i_size) 1905 ); 1906 return 0; 1907 } 1908 1909 static inline int break_lease(struct inode *inode, unsigned int mode) 1910 { 1911 /* 1912 * Since this check is lockless, we must ensure that any refcounts 1913 * taken are done before checking inode->i_flock. Otherwise, we could 1914 * end up racing with tasks trying to set a new lease on this file. 1915 */ 1916 smp_mb(); 1917 if (inode->i_flock) 1918 return __break_lease(inode, mode, FL_LEASE); 1919 return 0; 1920 } 1921 1922 static inline int break_deleg(struct inode *inode, unsigned int mode) 1923 { 1924 if (inode->i_flock) 1925 return __break_lease(inode, mode, FL_DELEG); 1926 return 0; 1927 } 1928 1929 static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode) 1930 { 1931 int ret; 1932 1933 ret = break_deleg(inode, O_WRONLY|O_NONBLOCK); 1934 if (ret == -EWOULDBLOCK && delegated_inode) { 1935 *delegated_inode = inode; 1936 ihold(inode); 1937 } 1938 return ret; 1939 } 1940 1941 static inline int break_deleg_wait(struct inode **delegated_inode) 1942 { 1943 int ret; 1944 1945 ret = break_deleg(*delegated_inode, O_WRONLY); 1946 iput(*delegated_inode); 1947 *delegated_inode = NULL; 1948 return ret; 1949 } 1950 1951 #else /* !CONFIG_FILE_LOCKING */ 1952 static inline int locks_mandatory_locked(struct file *file) 1953 { 1954 return 0; 1955 } 1956 1957 static inline int locks_mandatory_area(int rw, struct inode *inode, 1958 struct file *filp, loff_t offset, 1959 size_t count) 1960 { 1961 return 0; 1962 } 1963 1964 static inline int __mandatory_lock(struct inode *inode) 1965 { 1966 return 0; 1967 } 1968 1969 static inline int mandatory_lock(struct inode *inode) 1970 { 1971 return 0; 1972 } 1973 1974 static inline int locks_verify_locked(struct file *file) 1975 { 1976 return 0; 1977 } 1978 1979 static inline int locks_verify_truncate(struct inode *inode, struct file *filp, 1980 size_t size) 1981 { 1982 return 0; 1983 } 1984 1985 static inline int break_lease(struct inode *inode, unsigned int mode) 1986 { 1987 return 0; 1988 } 1989 1990 static inline int break_deleg(struct inode *inode, unsigned int mode) 1991 { 1992 return 0; 1993 } 1994 1995 static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode) 1996 { 1997 return 0; 1998 } 1999 2000 static inline int break_deleg_wait(struct inode **delegated_inode) 2001 { 2002 BUG(); 2003 return 0; 2004 } 2005 2006 #endif /* CONFIG_FILE_LOCKING */ 2007 2008 /* fs/open.c */ 2009 struct audit_names; 2010 struct filename { 2011 const char *name; /* pointer to actual string */ 2012 const __user char *uptr; /* original userland pointer */ 2013 struct audit_names *aname; 2014 bool separate; /* should "name" be freed? */ 2015 }; 2016 2017 extern long vfs_truncate(struct path *, loff_t); 2018 extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, 2019 struct file *filp); 2020 extern int do_fallocate(struct file *file, int mode, loff_t offset, 2021 loff_t len); 2022 extern long do_sys_open(int dfd, const char __user *filename, int flags, 2023 umode_t mode); 2024 extern struct file *file_open_name(struct filename *, int, umode_t); 2025 extern struct file *filp_open(const char *, int, umode_t); 2026 extern struct file *file_open_root(struct dentry *, struct vfsmount *, 2027 const char *, int); 2028 extern struct file * dentry_open(const struct path *, int, const struct cred *); 2029 extern int filp_close(struct file *, fl_owner_t id); 2030 2031 extern struct filename *getname(const char __user *); 2032 extern struct filename *getname_kernel(const char *); 2033 2034 enum { 2035 FILE_CREATED = 1, 2036 FILE_OPENED = 2 2037 }; 2038 extern int finish_open(struct file *file, struct dentry *dentry, 2039 int (*open)(struct inode *, struct file *), 2040 int *opened); 2041 extern int finish_no_open(struct file *file, struct dentry *dentry); 2042 2043 /* fs/ioctl.c */ 2044 2045 extern int ioctl_preallocate(struct file *filp, void __user *argp); 2046 2047 /* fs/dcache.c */ 2048 extern void __init vfs_caches_init_early(void); 2049 extern void __init vfs_caches_init(unsigned long); 2050 2051 extern struct kmem_cache *names_cachep; 2052 2053 extern void final_putname(struct filename *name); 2054 2055 #define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) 2056 #define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) 2057 #ifndef CONFIG_AUDITSYSCALL 2058 #define putname(name) final_putname(name) 2059 #else 2060 extern void putname(struct filename *name); 2061 #endif 2062 2063 #ifdef CONFIG_BLOCK 2064 extern int register_blkdev(unsigned int, const char *); 2065 extern void unregister_blkdev(unsigned int, const char *); 2066 extern struct block_device *bdget(dev_t); 2067 extern struct block_device *bdgrab(struct block_device *bdev); 2068 extern void bd_set_size(struct block_device *, loff_t size); 2069 extern void bd_forget(struct inode *inode); 2070 extern void bdput(struct block_device *); 2071 extern void invalidate_bdev(struct block_device *); 2072 extern void iterate_bdevs(void (*)(struct block_device *, void *), void *); 2073 extern int sync_blockdev(struct block_device *bdev); 2074 extern void kill_bdev(struct block_device *); 2075 extern struct super_block *freeze_bdev(struct block_device *); 2076 extern void emergency_thaw_all(void); 2077 extern int thaw_bdev(struct block_device *bdev, struct super_block *sb); 2078 extern int fsync_bdev(struct block_device *); 2079 extern int sb_is_blkdev_sb(struct super_block *sb); 2080 #else 2081 static inline void bd_forget(struct inode *inode) {} 2082 static inline int sync_blockdev(struct block_device *bdev) { return 0; } 2083 static inline void kill_bdev(struct block_device *bdev) {} 2084 static inline void invalidate_bdev(struct block_device *bdev) {} 2085 2086 static inline struct super_block *freeze_bdev(struct block_device *sb) 2087 { 2088 return NULL; 2089 } 2090 2091 static inline int thaw_bdev(struct block_device *bdev, struct super_block *sb) 2092 { 2093 return 0; 2094 } 2095 2096 static inline void iterate_bdevs(void (*f)(struct block_device *, void *), void *arg) 2097 { 2098 } 2099 2100 static inline int sb_is_blkdev_sb(struct super_block *sb) 2101 { 2102 return 0; 2103 } 2104 #endif 2105 extern int sync_filesystem(struct super_block *); 2106 extern const struct file_operations def_blk_fops; 2107 extern const struct file_operations def_chr_fops; 2108 extern const struct file_operations bad_sock_fops; 2109 #ifdef CONFIG_BLOCK 2110 extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 2111 extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); 2112 extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 2113 extern int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder); 2114 extern struct block_device *blkdev_get_by_path(const char *path, fmode_t mode, 2115 void *holder); 2116 extern struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, 2117 void *holder); 2118 extern void blkdev_put(struct block_device *bdev, fmode_t mode); 2119 #ifdef CONFIG_SYSFS 2120 extern int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk); 2121 extern void bd_unlink_disk_holder(struct block_device *bdev, 2122 struct gendisk *disk); 2123 #else 2124 static inline int bd_link_disk_holder(struct block_device *bdev, 2125 struct gendisk *disk) 2126 { 2127 return 0; 2128 } 2129 static inline void bd_unlink_disk_holder(struct block_device *bdev, 2130 struct gendisk *disk) 2131 { 2132 } 2133 #endif 2134 #endif 2135 2136 /* fs/char_dev.c */ 2137 #define CHRDEV_MAJOR_HASH_SIZE 255 2138 extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *); 2139 extern int register_chrdev_region(dev_t, unsigned, const char *); 2140 extern int __register_chrdev(unsigned int major, unsigned int baseminor, 2141 unsigned int count, const char *name, 2142 const struct file_operations *fops); 2143 extern void __unregister_chrdev(unsigned int major, unsigned int baseminor, 2144 unsigned int count, const char *name); 2145 extern void unregister_chrdev_region(dev_t, unsigned); 2146 extern void chrdev_show(struct seq_file *,off_t); 2147 2148 static inline int register_chrdev(unsigned int major, const char *name, 2149 const struct file_operations *fops) 2150 { 2151 return __register_chrdev(major, 0, 256, name, fops); 2152 } 2153 2154 static inline void unregister_chrdev(unsigned int major, const char *name) 2155 { 2156 __unregister_chrdev(major, 0, 256, name); 2157 } 2158 2159 /* fs/block_dev.c */ 2160 #define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ 2161 #define BDEVT_SIZE 10 /* Largest string for MAJ:MIN for blkdev */ 2162 2163 #ifdef CONFIG_BLOCK 2164 #define BLKDEV_MAJOR_HASH_SIZE 255 2165 extern const char *__bdevname(dev_t, char *buffer); 2166 extern const char *bdevname(struct block_device *bdev, char *buffer); 2167 extern struct block_device *lookup_bdev(const char *); 2168 extern void blkdev_show(struct seq_file *,off_t); 2169 2170 #else 2171 #define BLKDEV_MAJOR_HASH_SIZE 0 2172 #endif 2173 2174 extern void init_special_inode(struct inode *, umode_t, dev_t); 2175 2176 /* Invalid inode operations -- fs/bad_inode.c */ 2177 extern void make_bad_inode(struct inode *); 2178 extern int is_bad_inode(struct inode *); 2179 2180 #ifdef CONFIG_BLOCK 2181 /* 2182 * return READ, READA, or WRITE 2183 */ 2184 #define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK)) 2185 2186 /* 2187 * return data direction, READ or WRITE 2188 */ 2189 #define bio_data_dir(bio) ((bio)->bi_rw & 1) 2190 2191 extern void check_disk_size_change(struct gendisk *disk, 2192 struct block_device *bdev); 2193 extern int revalidate_disk(struct gendisk *); 2194 extern int check_disk_change(struct block_device *); 2195 extern int __invalidate_device(struct block_device *, bool); 2196 extern int invalidate_partition(struct gendisk *, int); 2197 #endif 2198 unsigned long invalidate_mapping_pages(struct address_space *mapping, 2199 pgoff_t start, pgoff_t end); 2200 2201 static inline void invalidate_remote_inode(struct inode *inode) 2202 { 2203 if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 2204 S_ISLNK(inode->i_mode)) 2205 invalidate_mapping_pages(inode->i_mapping, 0, -1); 2206 } 2207 extern int invalidate_inode_pages2(struct address_space *mapping); 2208 extern int invalidate_inode_pages2_range(struct address_space *mapping, 2209 pgoff_t start, pgoff_t end); 2210 extern int write_inode_now(struct inode *, int); 2211 extern int filemap_fdatawrite(struct address_space *); 2212 extern int filemap_flush(struct address_space *); 2213 extern int filemap_fdatawait(struct address_space *); 2214 extern int filemap_fdatawait_range(struct address_space *, loff_t lstart, 2215 loff_t lend); 2216 extern int filemap_write_and_wait(struct address_space *mapping); 2217 extern int filemap_write_and_wait_range(struct address_space *mapping, 2218 loff_t lstart, loff_t lend); 2219 extern int __filemap_fdatawrite_range(struct address_space *mapping, 2220 loff_t start, loff_t end, int sync_mode); 2221 extern int filemap_fdatawrite_range(struct address_space *mapping, 2222 loff_t start, loff_t end); 2223 2224 extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end, 2225 int datasync); 2226 extern int vfs_fsync(struct file *file, int datasync); 2227 static inline int generic_write_sync(struct file *file, loff_t pos, loff_t count) 2228 { 2229 if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host)) 2230 return 0; 2231 return vfs_fsync_range(file, pos, pos + count - 1, 2232 (file->f_flags & __O_SYNC) ? 0 : 1); 2233 } 2234 extern void emergency_sync(void); 2235 extern void emergency_remount(void); 2236 #ifdef CONFIG_BLOCK 2237 extern sector_t bmap(struct inode *, sector_t); 2238 #endif 2239 extern int notify_change(struct dentry *, struct iattr *, struct inode **); 2240 extern int inode_permission(struct inode *, int); 2241 extern int generic_permission(struct inode *, int); 2242 2243 static inline bool execute_ok(struct inode *inode) 2244 { 2245 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode); 2246 } 2247 2248 static inline void file_start_write(struct file *file) 2249 { 2250 if (!S_ISREG(file_inode(file)->i_mode)) 2251 return; 2252 __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true); 2253 } 2254 2255 static inline bool file_start_write_trylock(struct file *file) 2256 { 2257 if (!S_ISREG(file_inode(file)->i_mode)) 2258 return true; 2259 return __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, false); 2260 } 2261 2262 static inline void file_end_write(struct file *file) 2263 { 2264 if (!S_ISREG(file_inode(file)->i_mode)) 2265 return; 2266 __sb_end_write(file_inode(file)->i_sb, SB_FREEZE_WRITE); 2267 } 2268 2269 /* 2270 * get_write_access() gets write permission for a file. 2271 * put_write_access() releases this write permission. 2272 * This is used for regular files. 2273 * We cannot support write (and maybe mmap read-write shared) accesses and 2274 * MAP_DENYWRITE mmappings simultaneously. The i_writecount field of an inode 2275 * can have the following values: 2276 * 0: no writers, no VM_DENYWRITE mappings 2277 * < 0: (-i_writecount) vm_area_structs with VM_DENYWRITE set exist 2278 * > 0: (i_writecount) users are writing to the file. 2279 * 2280 * Normally we operate on that counter with atomic_{inc,dec} and it's safe 2281 * except for the cases where we don't hold i_writecount yet. Then we need to 2282 * use {get,deny}_write_access() - these functions check the sign and refuse 2283 * to do the change if sign is wrong. 2284 */ 2285 static inline int get_write_access(struct inode *inode) 2286 { 2287 return atomic_inc_unless_negative(&inode->i_writecount) ? 0 : -ETXTBSY; 2288 } 2289 static inline int deny_write_access(struct file *file) 2290 { 2291 struct inode *inode = file_inode(file); 2292 return atomic_dec_unless_positive(&inode->i_writecount) ? 0 : -ETXTBSY; 2293 } 2294 static inline void put_write_access(struct inode * inode) 2295 { 2296 atomic_dec(&inode->i_writecount); 2297 } 2298 static inline void allow_write_access(struct file *file) 2299 { 2300 if (file) 2301 atomic_inc(&file_inode(file)->i_writecount); 2302 } 2303 static inline bool inode_is_open_for_write(const struct inode *inode) 2304 { 2305 return atomic_read(&inode->i_writecount) > 0; 2306 } 2307 2308 #ifdef CONFIG_IMA 2309 static inline void i_readcount_dec(struct inode *inode) 2310 { 2311 BUG_ON(!atomic_read(&inode->i_readcount)); 2312 atomic_dec(&inode->i_readcount); 2313 } 2314 static inline void i_readcount_inc(struct inode *inode) 2315 { 2316 atomic_inc(&inode->i_readcount); 2317 } 2318 #else 2319 static inline void i_readcount_dec(struct inode *inode) 2320 { 2321 return; 2322 } 2323 static inline void i_readcount_inc(struct inode *inode) 2324 { 2325 return; 2326 } 2327 #endif 2328 extern int do_pipe_flags(int *, int); 2329 2330 extern int kernel_read(struct file *, loff_t, char *, unsigned long); 2331 extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t); 2332 extern struct file * open_exec(const char *); 2333 2334 /* fs/dcache.c -- generic fs support functions */ 2335 extern int is_subdir(struct dentry *, struct dentry *); 2336 extern int path_is_under(struct path *, struct path *); 2337 2338 #include <linux/err.h> 2339 2340 /* needed for stackable file system support */ 2341 extern loff_t default_llseek(struct file *file, loff_t offset, int whence); 2342 2343 extern loff_t vfs_llseek(struct file *file, loff_t offset, int whence); 2344 2345 extern int inode_init_always(struct super_block *, struct inode *); 2346 extern void inode_init_once(struct inode *); 2347 extern void address_space_init_once(struct address_space *mapping); 2348 extern struct inode * igrab(struct inode *); 2349 extern ino_t iunique(struct super_block *, ino_t); 2350 extern int inode_needs_sync(struct inode *inode); 2351 extern int generic_delete_inode(struct inode *inode); 2352 static inline int generic_drop_inode(struct inode *inode) 2353 { 2354 return !inode->i_nlink || inode_unhashed(inode); 2355 } 2356 2357 extern struct inode *ilookup5_nowait(struct super_block *sb, 2358 unsigned long hashval, int (*test)(struct inode *, void *), 2359 void *data); 2360 extern struct inode *ilookup5(struct super_block *sb, unsigned long hashval, 2361 int (*test)(struct inode *, void *), void *data); 2362 extern struct inode *ilookup(struct super_block *sb, unsigned long ino); 2363 2364 extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *); 2365 extern struct inode * iget_locked(struct super_block *, unsigned long); 2366 extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); 2367 extern int insert_inode_locked(struct inode *); 2368 #ifdef CONFIG_DEBUG_LOCK_ALLOC 2369 extern void lockdep_annotate_inode_mutex_key(struct inode *inode); 2370 #else 2371 static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { }; 2372 #endif 2373 extern void unlock_new_inode(struct inode *); 2374 extern unsigned int get_next_ino(void); 2375 2376 extern void __iget(struct inode * inode); 2377 extern void iget_failed(struct inode *); 2378 extern void clear_inode(struct inode *); 2379 extern void __destroy_inode(struct inode *); 2380 extern struct inode *new_inode_pseudo(struct super_block *sb); 2381 extern struct inode *new_inode(struct super_block *sb); 2382 extern void free_inode_nonrcu(struct inode *inode); 2383 extern int should_remove_suid(struct dentry *); 2384 extern int file_remove_suid(struct file *); 2385 2386 extern void __insert_inode_hash(struct inode *, unsigned long hashval); 2387 static inline void insert_inode_hash(struct inode *inode) 2388 { 2389 __insert_inode_hash(inode, inode->i_ino); 2390 } 2391 2392 extern void __remove_inode_hash(struct inode *); 2393 static inline void remove_inode_hash(struct inode *inode) 2394 { 2395 if (!inode_unhashed(inode)) 2396 __remove_inode_hash(inode); 2397 } 2398 2399 extern void inode_sb_list_add(struct inode *inode); 2400 2401 #ifdef CONFIG_BLOCK 2402 extern void submit_bio(int, struct bio *); 2403 extern int bdev_read_only(struct block_device *); 2404 #endif 2405 extern int set_blocksize(struct block_device *, int); 2406 extern int sb_set_blocksize(struct super_block *, int); 2407 extern int sb_min_blocksize(struct super_block *, int); 2408 2409 extern int generic_file_mmap(struct file *, struct vm_area_struct *); 2410 extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); 2411 extern int generic_file_remap_pages(struct vm_area_struct *, unsigned long addr, 2412 unsigned long size, pgoff_t pgoff); 2413 int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk); 2414 extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); 2415 extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); 2416 extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); 2417 extern ssize_t generic_file_direct_write(struct kiocb *, struct iov_iter *, loff_t); 2418 extern ssize_t generic_perform_write(struct file *, struct iov_iter *, loff_t); 2419 extern ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos); 2420 extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); 2421 extern ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos); 2422 extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); 2423 2424 /* fs/block_dev.c */ 2425 extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from); 2426 extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end, 2427 int datasync); 2428 extern void block_sync_page(struct page *page); 2429 2430 /* fs/splice.c */ 2431 extern ssize_t generic_file_splice_read(struct file *, loff_t *, 2432 struct pipe_inode_info *, size_t, unsigned int); 2433 extern ssize_t default_file_splice_read(struct file *, loff_t *, 2434 struct pipe_inode_info *, size_t, unsigned int); 2435 extern ssize_t iter_file_splice_write(struct pipe_inode_info *, 2436 struct file *, loff_t *, size_t, unsigned int); 2437 extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, 2438 struct file *out, loff_t *, size_t len, unsigned int flags); 2439 2440 extern void 2441 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); 2442 extern loff_t noop_llseek(struct file *file, loff_t offset, int whence); 2443 extern loff_t no_llseek(struct file *file, loff_t offset, int whence); 2444 extern loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize); 2445 extern loff_t generic_file_llseek(struct file *file, loff_t offset, int whence); 2446 extern loff_t generic_file_llseek_size(struct file *file, loff_t offset, 2447 int whence, loff_t maxsize, loff_t eof); 2448 extern loff_t fixed_size_llseek(struct file *file, loff_t offset, 2449 int whence, loff_t size); 2450 extern int generic_file_open(struct inode * inode, struct file * filp); 2451 extern int nonseekable_open(struct inode * inode, struct file * filp); 2452 2453 #ifdef CONFIG_FS_XIP 2454 extern ssize_t xip_file_read(struct file *filp, char __user *buf, size_t len, 2455 loff_t *ppos); 2456 extern int xip_file_mmap(struct file * file, struct vm_area_struct * vma); 2457 extern ssize_t xip_file_write(struct file *filp, const char __user *buf, 2458 size_t len, loff_t *ppos); 2459 extern int xip_truncate_page(struct address_space *mapping, loff_t from); 2460 #else 2461 static inline int xip_truncate_page(struct address_space *mapping, loff_t from) 2462 { 2463 return 0; 2464 } 2465 #endif 2466 2467 #ifdef CONFIG_BLOCK 2468 typedef void (dio_submit_t)(int rw, struct bio *bio, struct inode *inode, 2469 loff_t file_offset); 2470 2471 enum { 2472 /* need locking between buffered and direct access */ 2473 DIO_LOCKING = 0x01, 2474 2475 /* filesystem does not support filling holes */ 2476 DIO_SKIP_HOLES = 0x02, 2477 2478 /* filesystem can handle aio writes beyond i_size */ 2479 DIO_ASYNC_EXTEND = 0x04, 2480 }; 2481 2482 void dio_end_io(struct bio *bio, int error); 2483 2484 ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, 2485 struct block_device *bdev, struct iov_iter *iter, loff_t offset, 2486 get_block_t get_block, dio_iodone_t end_io, 2487 dio_submit_t submit_io, int flags); 2488 2489 static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb, 2490 struct inode *inode, struct iov_iter *iter, loff_t offset, 2491 get_block_t get_block) 2492 { 2493 return __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iter, 2494 offset, get_block, NULL, NULL, 2495 DIO_LOCKING | DIO_SKIP_HOLES); 2496 } 2497 #endif 2498 2499 void inode_dio_wait(struct inode *inode); 2500 void inode_dio_done(struct inode *inode); 2501 2502 extern void inode_set_flags(struct inode *inode, unsigned int flags, 2503 unsigned int mask); 2504 2505 extern const struct file_operations generic_ro_fops; 2506 2507 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m)) 2508 2509 extern int readlink_copy(char __user *, int, const char *); 2510 extern int page_readlink(struct dentry *, char __user *, int); 2511 extern void *page_follow_link_light(struct dentry *, struct nameidata *); 2512 extern void page_put_link(struct dentry *, struct nameidata *, void *); 2513 extern int __page_symlink(struct inode *inode, const char *symname, int len, 2514 int nofs); 2515 extern int page_symlink(struct inode *inode, const char *symname, int len); 2516 extern const struct inode_operations page_symlink_inode_operations; 2517 extern void kfree_put_link(struct dentry *, struct nameidata *, void *); 2518 extern int generic_readlink(struct dentry *, char __user *, int); 2519 extern void generic_fillattr(struct inode *, struct kstat *); 2520 int vfs_getattr_nosec(struct path *path, struct kstat *stat); 2521 extern int vfs_getattr(struct path *, struct kstat *); 2522 void __inode_add_bytes(struct inode *inode, loff_t bytes); 2523 void inode_add_bytes(struct inode *inode, loff_t bytes); 2524 void __inode_sub_bytes(struct inode *inode, loff_t bytes); 2525 void inode_sub_bytes(struct inode *inode, loff_t bytes); 2526 loff_t inode_get_bytes(struct inode *inode); 2527 void inode_set_bytes(struct inode *inode, loff_t bytes); 2528 2529 extern int vfs_readdir(struct file *, filldir_t, void *); 2530 extern int iterate_dir(struct file *, struct dir_context *); 2531 2532 extern int vfs_stat(const char __user *, struct kstat *); 2533 extern int vfs_lstat(const char __user *, struct kstat *); 2534 extern int vfs_fstat(unsigned int, struct kstat *); 2535 extern int vfs_fstatat(int , const char __user *, struct kstat *, int); 2536 2537 extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, 2538 unsigned long arg); 2539 extern int __generic_block_fiemap(struct inode *inode, 2540 struct fiemap_extent_info *fieinfo, 2541 loff_t start, loff_t len, 2542 get_block_t *get_block); 2543 extern int generic_block_fiemap(struct inode *inode, 2544 struct fiemap_extent_info *fieinfo, u64 start, 2545 u64 len, get_block_t *get_block); 2546 2547 extern void get_filesystem(struct file_system_type *fs); 2548 extern void put_filesystem(struct file_system_type *fs); 2549 extern struct file_system_type *get_fs_type(const char *name); 2550 extern struct super_block *get_super(struct block_device *); 2551 extern struct super_block *get_super_thawed(struct block_device *); 2552 extern struct super_block *get_active_super(struct block_device *bdev); 2553 extern void drop_super(struct super_block *sb); 2554 extern void iterate_supers(void (*)(struct super_block *, void *), void *); 2555 extern void iterate_supers_type(struct file_system_type *, 2556 void (*)(struct super_block *, void *), void *); 2557 2558 extern int dcache_dir_open(struct inode *, struct file *); 2559 extern int dcache_dir_close(struct inode *, struct file *); 2560 extern loff_t dcache_dir_lseek(struct file *, loff_t, int); 2561 extern int dcache_readdir(struct file *, struct dir_context *); 2562 extern int simple_setattr(struct dentry *, struct iattr *); 2563 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *); 2564 extern int simple_statfs(struct dentry *, struct kstatfs *); 2565 extern int simple_open(struct inode *inode, struct file *file); 2566 extern int simple_link(struct dentry *, struct inode *, struct dentry *); 2567 extern int simple_unlink(struct inode *, struct dentry *); 2568 extern int simple_rmdir(struct inode *, struct dentry *); 2569 extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); 2570 extern int noop_fsync(struct file *, loff_t, loff_t, int); 2571 extern int simple_empty(struct dentry *); 2572 extern int simple_readpage(struct file *file, struct page *page); 2573 extern int simple_write_begin(struct file *file, struct address_space *mapping, 2574 loff_t pos, unsigned len, unsigned flags, 2575 struct page **pagep, void **fsdata); 2576 extern int simple_write_end(struct file *file, struct address_space *mapping, 2577 loff_t pos, unsigned len, unsigned copied, 2578 struct page *page, void *fsdata); 2579 extern int always_delete_dentry(const struct dentry *); 2580 extern struct inode *alloc_anon_inode(struct super_block *); 2581 extern const struct dentry_operations simple_dentry_operations; 2582 2583 extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); 2584 extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *); 2585 extern const struct file_operations simple_dir_operations; 2586 extern const struct inode_operations simple_dir_inode_operations; 2587 struct tree_descr { char *name; const struct file_operations *ops; int mode; }; 2588 struct dentry *d_alloc_name(struct dentry *, const char *); 2589 extern int simple_fill_super(struct super_block *, unsigned long, struct tree_descr *); 2590 extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count); 2591 extern void simple_release_fs(struct vfsmount **mount, int *count); 2592 2593 extern ssize_t simple_read_from_buffer(void __user *to, size_t count, 2594 loff_t *ppos, const void *from, size_t available); 2595 extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, 2596 const void __user *from, size_t count); 2597 2598 extern int __generic_file_fsync(struct file *, loff_t, loff_t, int); 2599 extern int generic_file_fsync(struct file *, loff_t, loff_t, int); 2600 2601 extern int generic_check_addressable(unsigned, u64); 2602 2603 #ifdef CONFIG_MIGRATION 2604 extern int buffer_migrate_page(struct address_space *, 2605 struct page *, struct page *, 2606 enum migrate_mode); 2607 #else 2608 #define buffer_migrate_page NULL 2609 #endif 2610 2611 extern int inode_change_ok(const struct inode *, struct iattr *); 2612 extern int inode_newsize_ok(const struct inode *, loff_t offset); 2613 extern void setattr_copy(struct inode *inode, const struct iattr *attr); 2614 2615 extern int file_update_time(struct file *file); 2616 2617 extern int generic_show_options(struct seq_file *m, struct dentry *root); 2618 extern void save_mount_options(struct super_block *sb, char *options); 2619 extern void replace_mount_options(struct super_block *sb, char *options); 2620 2621 static inline ino_t parent_ino(struct dentry *dentry) 2622 { 2623 ino_t res; 2624 2625 /* 2626 * Don't strictly need d_lock here? If the parent ino could change 2627 * then surely we'd have a deeper race in the caller? 2628 */ 2629 spin_lock(&dentry->d_lock); 2630 res = dentry->d_parent->d_inode->i_ino; 2631 spin_unlock(&dentry->d_lock); 2632 return res; 2633 } 2634 2635 /* Transaction based IO helpers */ 2636 2637 /* 2638 * An argresp is stored in an allocated page and holds the 2639 * size of the argument or response, along with its content 2640 */ 2641 struct simple_transaction_argresp { 2642 ssize_t size; 2643 char data[0]; 2644 }; 2645 2646 #define SIMPLE_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct simple_transaction_argresp)) 2647 2648 char *simple_transaction_get(struct file *file, const char __user *buf, 2649 size_t size); 2650 ssize_t simple_transaction_read(struct file *file, char __user *buf, 2651 size_t size, loff_t *pos); 2652 int simple_transaction_release(struct inode *inode, struct file *file); 2653 2654 void simple_transaction_set(struct file *file, size_t n); 2655 2656 /* 2657 * simple attribute files 2658 * 2659 * These attributes behave similar to those in sysfs: 2660 * 2661 * Writing to an attribute immediately sets a value, an open file can be 2662 * written to multiple times. 2663 * 2664 * Reading from an attribute creates a buffer from the value that might get 2665 * read with multiple read calls. When the attribute has been read 2666 * completely, no further read calls are possible until the file is opened 2667 * again. 2668 * 2669 * All attributes contain a text representation of a numeric value 2670 * that are accessed with the get() and set() functions. 2671 */ 2672 #define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \ 2673 static int __fops ## _open(struct inode *inode, struct file *file) \ 2674 { \ 2675 __simple_attr_check_format(__fmt, 0ull); \ 2676 return simple_attr_open(inode, file, __get, __set, __fmt); \ 2677 } \ 2678 static const struct file_operations __fops = { \ 2679 .owner = THIS_MODULE, \ 2680 .open = __fops ## _open, \ 2681 .release = simple_attr_release, \ 2682 .read = simple_attr_read, \ 2683 .write = simple_attr_write, \ 2684 .llseek = generic_file_llseek, \ 2685 }; 2686 2687 static inline __printf(1, 2) 2688 void __simple_attr_check_format(const char *fmt, ...) 2689 { 2690 /* don't do anything, just let the compiler check the arguments; */ 2691 } 2692 2693 int simple_attr_open(struct inode *inode, struct file *file, 2694 int (*get)(void *, u64 *), int (*set)(void *, u64), 2695 const char *fmt); 2696 int simple_attr_release(struct inode *inode, struct file *file); 2697 ssize_t simple_attr_read(struct file *file, char __user *buf, 2698 size_t len, loff_t *ppos); 2699 ssize_t simple_attr_write(struct file *file, const char __user *buf, 2700 size_t len, loff_t *ppos); 2701 2702 struct ctl_table; 2703 int proc_nr_files(struct ctl_table *table, int write, 2704 void __user *buffer, size_t *lenp, loff_t *ppos); 2705 int proc_nr_dentry(struct ctl_table *table, int write, 2706 void __user *buffer, size_t *lenp, loff_t *ppos); 2707 int proc_nr_inodes(struct ctl_table *table, int write, 2708 void __user *buffer, size_t *lenp, loff_t *ppos); 2709 int __init get_filesystem_list(char *buf); 2710 2711 #define __FMODE_EXEC ((__force int) FMODE_EXEC) 2712 #define __FMODE_NONOTIFY ((__force int) FMODE_NONOTIFY) 2713 2714 #define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE]) 2715 #define OPEN_FMODE(flag) ((__force fmode_t)(((flag + 1) & O_ACCMODE) | \ 2716 (flag & __FMODE_NONOTIFY))) 2717 2718 static inline int is_sxid(umode_t mode) 2719 { 2720 return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP)); 2721 } 2722 2723 static inline void inode_has_no_xattr(struct inode *inode) 2724 { 2725 if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & MS_NOSEC)) 2726 inode->i_flags |= S_NOSEC; 2727 } 2728 2729 static inline bool dir_emit(struct dir_context *ctx, 2730 const char *name, int namelen, 2731 u64 ino, unsigned type) 2732 { 2733 return ctx->actor(ctx, name, namelen, ctx->pos, ino, type) == 0; 2734 } 2735 static inline bool dir_emit_dot(struct file *file, struct dir_context *ctx) 2736 { 2737 return ctx->actor(ctx, ".", 1, ctx->pos, 2738 file->f_path.dentry->d_inode->i_ino, DT_DIR) == 0; 2739 } 2740 static inline bool dir_emit_dotdot(struct file *file, struct dir_context *ctx) 2741 { 2742 return ctx->actor(ctx, "..", 2, ctx->pos, 2743 parent_ino(file->f_path.dentry), DT_DIR) == 0; 2744 } 2745 static inline bool dir_emit_dots(struct file *file, struct dir_context *ctx) 2746 { 2747 if (ctx->pos == 0) { 2748 if (!dir_emit_dot(file, ctx)) 2749 return false; 2750 ctx->pos = 1; 2751 } 2752 if (ctx->pos == 1) { 2753 if (!dir_emit_dotdot(file, ctx)) 2754 return false; 2755 ctx->pos = 2; 2756 } 2757 return true; 2758 } 2759 static inline bool dir_relax(struct inode *inode) 2760 { 2761 mutex_unlock(&inode->i_mutex); 2762 mutex_lock(&inode->i_mutex); 2763 return !IS_DEADDIR(inode); 2764 } 2765 2766 #endif /* _LINUX_FS_H */
1 /* 2 * Written by Mark Hemment, 1996 (markhe@nextd.demon.co.uk). 3 * 4 * (C) SGI 2006, Christoph Lameter 5 * Cleaned up and restructured to ease the addition of alternative 6 * implementations of SLAB allocators. 7 * (C) Linux Foundation 2008-2013 8 * Unified interface for all slab allocators 9 */ 10 11 #ifndef _LINUX_SLAB_H 12 #define _LINUX_SLAB_H 13 14 #include <linux/gfp.h> 15 #include <linux/types.h> 16 #include <linux/workqueue.h> 17 18 19 /* 20 * Flags to pass to kmem_cache_create(). 21 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set. 22 */ 23 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */ 24 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */ 25 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */ 26 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */ 27 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ 28 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ 29 #define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ 30 /* 31 * SLAB_DESTROY_BY_RCU - **WARNING** READ THIS! 32 * 33 * This delays freeing the SLAB page by a grace period, it does _NOT_ 34 * delay object freeing. This means that if you do kmem_cache_free() 35 * that memory location is free to be reused at any time. Thus it may 36 * be possible to see another object there in the same RCU grace period. 37 * 38 * This feature only ensures the memory location backing the object 39 * stays valid, the trick to using this is relying on an independent 40 * object validation pass. Something like: 41 * 42 * rcu_read_lock() 43 * again: 44 * obj = lockless_lookup(key); 45 * if (obj) { 46 * if (!try_get_ref(obj)) // might fail for free objects 47 * goto again; 48 * 49 * if (obj->key != key) { // not the object we expected 50 * put_ref(obj); 51 * goto again; 52 * } 53 * } 54 * rcu_read_unlock(); 55 * 56 * This is useful if we need to approach a kernel structure obliquely, 57 * from its address obtained without the usual locking. We can lock 58 * the structure to stabilize it and check it's still at the given address, 59 * only if we can be sure that the memory has not been meanwhile reused 60 * for some other kind of object (which our subsystem's lock might corrupt). 61 * 62 * rcu_read_lock before reading the address, then rcu_read_unlock after 63 * taking the spinlock within the structure expected at that address. 64 */ 65 #define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ 66 #define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ 67 #define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ 68 69 /* Flag to prevent checks on free */ 70 #ifdef CONFIG_DEBUG_OBJECTS 71 # define SLAB_DEBUG_OBJECTS 0x00400000UL 72 #else 73 # define SLAB_DEBUG_OBJECTS 0x00000000UL 74 #endif 75 76 #define SLAB_NOLEAKTRACE 0x00800000UL /* Avoid kmemleak tracing */ 77 78 /* Don't track use of uninitialized memory */ 79 #ifdef CONFIG_KMEMCHECK 80 # define SLAB_NOTRACK 0x01000000UL 81 #else 82 # define SLAB_NOTRACK 0x00000000UL 83 #endif 84 #ifdef CONFIG_FAILSLAB 85 # define SLAB_FAILSLAB 0x02000000UL /* Fault injection mark */ 86 #else 87 # define SLAB_FAILSLAB 0x00000000UL 88 #endif 89 90 /* The following flags affect the page allocator grouping pages by mobility */ 91 #define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */ 92 #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ 93 /* 94 * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests. 95 * 96 * Dereferencing ZERO_SIZE_PTR will lead to a distinct access fault. 97 * 98 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can. 99 * Both make kfree a no-op. 100 */ 101 #define ZERO_SIZE_PTR ((void *)16) 102 103 #define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \ 104 (unsigned long)ZERO_SIZE_PTR) 105 106 #include <linux/kmemleak.h> 107 108 struct mem_cgroup; 109 /* 110 * struct kmem_cache related prototypes 111 */ 112 void __init kmem_cache_init(void); 113 int slab_is_available(void); 114 115 struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, 116 unsigned long, 117 void (*)(void *)); 118 #ifdef CONFIG_MEMCG_KMEM 119 struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *, 120 struct kmem_cache *, 121 const char *); 122 #endif 123 void kmem_cache_destroy(struct kmem_cache *); 124 int kmem_cache_shrink(struct kmem_cache *); 125 void kmem_cache_free(struct kmem_cache *, void *); 126 127 /* 128 * Please use this macro to create slab caches. Simply specify the 129 * name of the structure and maybe some flags that are listed above. 130 * 131 * The alignment of the struct determines object alignment. If you 132 * f.e. add ____cacheline_aligned_in_smp to the struct declaration 133 * then the objects will be properly aligned in SMP configurations. 134 */ 135 #define KMEM_CACHE(__struct, __flags) kmem_cache_create(#__struct,\ 136 sizeof(struct __struct), __alignof__(struct __struct),\ 137 (__flags), NULL) 138 139 /* 140 * Common kmalloc functions provided by all allocators 141 */ 142 void * __must_check __krealloc(const void *, size_t, gfp_t); 143 void * __must_check krealloc(const void *, size_t, gfp_t); 144 void kfree(const void *); 145 void kzfree(const void *); 146 size_t ksize(const void *); 147 148 /* 149 * Some archs want to perform DMA into kmalloc caches and need a guaranteed 150 * alignment larger than the alignment of a 64-bit integer. 151 * Setting ARCH_KMALLOC_MINALIGN in arch headers allows that. 152 */ 153 #if defined(ARCH_DMA_MINALIGN) && ARCH_DMA_MINALIGN > 8 154 #define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN 155 #define KMALLOC_MIN_SIZE ARCH_DMA_MINALIGN 156 #define KMALLOC_SHIFT_LOW ilog2(ARCH_DMA_MINALIGN) 157 #else 158 #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long) 159 #endif 160 161 #ifdef CONFIG_SLOB 162 /* 163 * Common fields provided in kmem_cache by all slab allocators 164 * This struct is either used directly by the allocator (SLOB) 165 * or the allocator must include definitions for all fields 166 * provided in kmem_cache_common in their definition of kmem_cache. 167 * 168 * Once we can do anonymous structs (C11 standard) we could put a 169 * anonymous struct definition in these allocators so that the 170 * separate allocations in the kmem_cache structure of SLAB and 171 * SLUB is no longer needed. 172 */ 173 struct kmem_cache { 174 unsigned int object_size;/* The original size of the object */ 175 unsigned int size; /* The aligned/padded/added on size */ 176 unsigned int align; /* Alignment as calculated */ 177 unsigned long flags; /* Active flags on the slab */ 178 const char *name; /* Slab name for sysfs */ 179 int refcount; /* Use counter */ 180 void (*ctor)(void *); /* Called on object slot creation */ 181 struct list_head list; /* List of all slab caches on the system */ 182 }; 183 184 #endif /* CONFIG_SLOB */ 185 186 /* 187 * Kmalloc array related definitions 188 */ 189 190 #ifdef CONFIG_SLAB 191 /* 192 * The largest kmalloc size supported by the SLAB allocators is 193 * 32 megabyte (2^25) or the maximum allocatable page order if that is 194 * less than 32 MB. 195 * 196 * WARNING: Its not easy to increase this value since the allocators have 197 * to do various tricks to work around compiler limitations in order to 198 * ensure proper constant folding. 199 */ 200 #define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT - 1) <= 25 ? \ 201 (MAX_ORDER + PAGE_SHIFT - 1) : 25) 202 #define KMALLOC_SHIFT_MAX KMALLOC_SHIFT_HIGH 203 #ifndef KMALLOC_SHIFT_LOW 204 #define KMALLOC_SHIFT_LOW 5 205 #endif 206 #endif 207 208 #ifdef CONFIG_SLUB 209 /* 210 * SLUB directly allocates requests fitting in to an order-1 page 211 * (PAGE_SIZE*2). Larger requests are passed to the page allocator. 212 */ 213 #define KMALLOC_SHIFT_HIGH (PAGE_SHIFT + 1) 214 #define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT) 215 #ifndef KMALLOC_SHIFT_LOW 216 #define KMALLOC_SHIFT_LOW 3 217 #endif 218 #endif 219 220 #ifdef CONFIG_SLOB 221 /* 222 * SLOB passes all requests larger than one page to the page allocator. 223 * No kmalloc array is necessary since objects of different sizes can 224 * be allocated from the same page. 225 */ 226 #define KMALLOC_SHIFT_HIGH PAGE_SHIFT 227 #define KMALLOC_SHIFT_MAX 30 228 #ifndef KMALLOC_SHIFT_LOW 229 #define KMALLOC_SHIFT_LOW 3 230 #endif 231 #endif 232 233 /* Maximum allocatable size */ 234 #define KMALLOC_MAX_SIZE (1UL << KMALLOC_SHIFT_MAX) 235 /* Maximum size for which we actually use a slab cache */ 236 #define KMALLOC_MAX_CACHE_SIZE (1UL << KMALLOC_SHIFT_HIGH) 237 /* Maximum order allocatable via the slab allocagtor */ 238 #define KMALLOC_MAX_ORDER (KMALLOC_SHIFT_MAX - PAGE_SHIFT) 239 240 /* 241 * Kmalloc subsystem. 242 */ 243 #ifndef KMALLOC_MIN_SIZE 244 #define KMALLOC_MIN_SIZE (1 << KMALLOC_SHIFT_LOW) 245 #endif 246 247 /* 248 * This restriction comes from byte sized index implementation. 249 * Page size is normally 2^12 bytes and, in this case, if we want to use 250 * byte sized index which can represent 2^8 entries, the size of the object 251 * should be equal or greater to 2^12 / 2^8 = 2^4 = 16. 252 * If minimum size of kmalloc is less than 16, we use it as minimum object 253 * size and give up to use byte sized index. 254 */ 255 #define SLAB_OBJ_MIN_SIZE (KMALLOC_MIN_SIZE < 16 ? \ 256 (KMALLOC_MIN_SIZE) : 16) 257 258 #ifndef CONFIG_SLOB 259 extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1]; 260 #ifdef CONFIG_ZONE_DMA 261 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1]; 262 #endif 263 264 /* 265 * Figure out which kmalloc slab an allocation of a certain size 266 * belongs to. 267 * 0 = zero alloc 268 * 1 = 65 .. 96 bytes 269 * 2 = 120 .. 192 bytes 270 * n = 2^(n-1) .. 2^n -1 271 */ 272 static __always_inline int kmalloc_index(size_t size) 273 { 274 if (!size) 275 return 0; 276 277 if (size <= KMALLOC_MIN_SIZE) 278 return KMALLOC_SHIFT_LOW; 279 280 if (KMALLOC_MIN_SIZE <= 32 && size > 64 && size <= 96) 281 return 1; 282 if (KMALLOC_MIN_SIZE <= 64 && size > 128 && size <= 192) 283 return 2; 284 if (size <= 8) return 3; 285 if (size <= 16) return 4; 286 if (size <= 32) return 5; 287 if (size <= 64) return 6; 288 if (size <= 128) return 7; 289 if (size <= 256) return 8; 290 if (size <= 512) return 9; 291 if (size <= 1024) return 10; 292 if (size <= 2 * 1024) return 11; 293 if (size <= 4 * 1024) return 12; 294 if (size <= 8 * 1024) return 13; 295 if (size <= 16 * 1024) return 14; 296 if (size <= 32 * 1024) return 15; 297 if (size <= 64 * 1024) return 16; 298 if (size <= 128 * 1024) return 17; 299 if (size <= 256 * 1024) return 18; 300 if (size <= 512 * 1024) return 19; 301 if (size <= 1024 * 1024) return 20; 302 if (size <= 2 * 1024 * 1024) return 21; 303 if (size <= 4 * 1024 * 1024) return 22; 304 if (size <= 8 * 1024 * 1024) return 23; 305 if (size <= 16 * 1024 * 1024) return 24; 306 if (size <= 32 * 1024 * 1024) return 25; 307 if (size <= 64 * 1024 * 1024) return 26; 308 BUG(); 309 310 /* Will never be reached. Needed because the compiler may complain */ 311 return -1; 312 } 313 #endif /* !CONFIG_SLOB */ 314 315 void *__kmalloc(size_t size, gfp_t flags); 316 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags); 317 318 #ifdef CONFIG_NUMA 319 void *__kmalloc_node(size_t size, gfp_t flags, int node); 320 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); 321 #else 322 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node) 323 { 324 return __kmalloc(size, flags); 325 } 326 327 static __always_inline void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t flags, int node) 328 { 329 return kmem_cache_alloc(s, flags); 330 } 331 #endif 332 333 #ifdef CONFIG_TRACING 334 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t); 335 336 #ifdef CONFIG_NUMA 337 extern void *kmem_cache_alloc_node_trace(struct kmem_cache *s, 338 gfp_t gfpflags, 339 int node, size_t size); 340 #else 341 static __always_inline void * 342 kmem_cache_alloc_node_trace(struct kmem_cache *s, 343 gfp_t gfpflags, 344 int node, size_t size) 345 { 346 return kmem_cache_alloc_trace(s, gfpflags, size); 347 } 348 #endif /* CONFIG_NUMA */ 349 350 #else /* CONFIG_TRACING */ 351 static __always_inline void *kmem_cache_alloc_trace(struct kmem_cache *s, 352 gfp_t flags, size_t size) 353 { 354 return kmem_cache_alloc(s, flags); 355 } 356 357 static __always_inline void * 358 kmem_cache_alloc_node_trace(struct kmem_cache *s, 359 gfp_t gfpflags, 360 int node, size_t size) 361 { 362 return kmem_cache_alloc_node(s, gfpflags, node); 363 } 364 #endif /* CONFIG_TRACING */ 365 366 #ifdef CONFIG_SLAB 367 #include <linux/slab_def.h> 368 #endif 369 370 #ifdef CONFIG_SLUB 371 #include <linux/slub_def.h> 372 #endif 373 374 extern void *kmalloc_order(size_t size, gfp_t flags, unsigned int order); 375 376 #ifdef CONFIG_TRACING 377 extern void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order); 378 #else 379 static __always_inline void * 380 kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order) 381 { 382 return kmalloc_order(size, flags, order); 383 } 384 #endif 385 386 static __always_inline void *kmalloc_large(size_t size, gfp_t flags) 387 { 388 unsigned int order = get_order(size); 389 return kmalloc_order_trace(size, flags, order); 390 } 391 392 /** 393 * kmalloc - allocate memory 394 * @size: how many bytes of memory are required. 395 * @flags: the type of memory to allocate. 396 * 397 * kmalloc is the normal method of allocating memory 398 * for objects smaller than page size in the kernel. 399 * 400 * The @flags argument may be one of: 401 * 402 * %GFP_USER - Allocate memory on behalf of user. May sleep. 403 * 404 * %GFP_KERNEL - Allocate normal kernel ram. May sleep. 405 * 406 * %GFP_ATOMIC - Allocation will not sleep. May use emergency pools. 407 * For example, use this inside interrupt handlers. 408 * 409 * %GFP_HIGHUSER - Allocate pages from high memory. 410 * 411 * %GFP_NOIO - Do not do any I/O at all while trying to get memory. 412 * 413 * %GFP_NOFS - Do not make any fs calls while trying to get memory. 414 * 415 * %GFP_NOWAIT - Allocation will not sleep. 416 * 417 * %__GFP_THISNODE - Allocate node-local memory only. 418 * 419 * %GFP_DMA - Allocation suitable for DMA. 420 * Should only be used for kmalloc() caches. Otherwise, use a 421 * slab created with SLAB_DMA. 422 * 423 * Also it is possible to set different flags by OR'ing 424 * in one or more of the following additional @flags: 425 * 426 * %__GFP_COLD - Request cache-cold pages instead of 427 * trying to return cache-warm pages. 428 * 429 * %__GFP_HIGH - This allocation has high priority and may use emergency pools. 430 * 431 * %__GFP_NOFAIL - Indicate that this allocation is in no way allowed to fail 432 * (think twice before using). 433 * 434 * %__GFP_NORETRY - If memory is not immediately available, 435 * then give up at once. 436 * 437 * %__GFP_NOWARN - If allocation fails, don't issue any warnings. 438 * 439 * %__GFP_REPEAT - If allocation fails initially, try once more before failing. 440 * 441 * There are other flags available as well, but these are not intended 442 * for general use, and so are not documented here. For a full list of 443 * potential flags, always refer to linux/gfp.h. 444 */ 445 static __always_inline void *kmalloc(size_t size, gfp_t flags) 446 { 447 if (__builtin_constant_p(size)) { 448 if (size > KMALLOC_MAX_CACHE_SIZE) 449 return kmalloc_large(size, flags); 450 #ifndef CONFIG_SLOB 451 if (!(flags & GFP_DMA)) { 452 int index = kmalloc_index(size); 453 454 if (!index) 455 return ZERO_SIZE_PTR; 456 457 return kmem_cache_alloc_trace(kmalloc_caches[index], 458 flags, size); 459 } 460 #endif 461 } 462 return __kmalloc(size, flags); 463 } 464 465 /* 466 * Determine size used for the nth kmalloc cache. 467 * return size or 0 if a kmalloc cache for that 468 * size does not exist 469 */ 470 static __always_inline int kmalloc_size(int n) 471 { 472 #ifndef CONFIG_SLOB 473 if (n > 2) 474 return 1 << n; 475 476 if (n == 1 && KMALLOC_MIN_SIZE <= 32) 477 return 96; 478 479 if (n == 2 && KMALLOC_MIN_SIZE <= 64) 480 return 192; 481 #endif 482 return 0; 483 } 484 485 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) 486 { 487 #ifndef CONFIG_SLOB 488 if (__builtin_constant_p(size) && 489 size <= KMALLOC_MAX_CACHE_SIZE && !(flags & GFP_DMA)) { 490 int i = kmalloc_index(size); 491 492 if (!i) 493 return ZERO_SIZE_PTR; 494 495 return kmem_cache_alloc_node_trace(kmalloc_caches[i], 496 flags, node, size); 497 } 498 #endif 499 return __kmalloc_node(size, flags, node); 500 } 501 502 /* 503 * Setting ARCH_SLAB_MINALIGN in arch headers allows a different alignment. 504 * Intended for arches that get misalignment faults even for 64 bit integer 505 * aligned buffers. 506 */ 507 #ifndef ARCH_SLAB_MINALIGN 508 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long) 509 #endif 510 /* 511 * This is the main placeholder for memcg-related information in kmem caches. 512 * struct kmem_cache will hold a pointer to it, so the memory cost while 513 * disabled is 1 pointer. The runtime cost while enabled, gets bigger than it 514 * would otherwise be if that would be bundled in kmem_cache: we'll need an 515 * extra pointer chase. But the trade off clearly lays in favor of not 516 * penalizing non-users. 517 * 518 * Both the root cache and the child caches will have it. For the root cache, 519 * this will hold a dynamically allocated array large enough to hold 520 * information about the currently limited memcgs in the system. To allow the 521 * array to be accessed without taking any locks, on relocation we free the old 522 * version only after a grace period. 523 * 524 * Child caches will hold extra metadata needed for its operation. Fields are: 525 * 526 * @memcg: pointer to the memcg this cache belongs to 527 * @list: list_head for the list of all caches in this memcg 528 * @root_cache: pointer to the global, root cache, this cache was derived from 529 * @nr_pages: number of pages that belongs to this cache. 530 */ 531 struct memcg_cache_params { 532 bool is_root_cache; 533 union { 534 struct { 535 struct rcu_head rcu_head; 536 struct kmem_cache *memcg_caches[0]; 537 }; 538 struct { 539 struct mem_cgroup *memcg; 540 struct list_head list; 541 struct kmem_cache *root_cache; 542 atomic_t nr_pages; 543 }; 544 }; 545 }; 546 547 int memcg_update_all_caches(int num_memcgs); 548 549 struct seq_file; 550 int cache_show(struct kmem_cache *s, struct seq_file *m); 551 void print_slabinfo_header(struct seq_file *m); 552 553 /** 554 * kmalloc_array - allocate memory for an array. 555 * @n: number of elements. 556 * @size: element size. 557 * @flags: the type of memory to allocate (see kmalloc). 558 */ 559 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) 560 { 561 if (size != 0 && n > SIZE_MAX / size) 562 return NULL; 563 return __kmalloc(n * size, flags); 564 } 565 566 /** 567 * kcalloc - allocate memory for an array. The memory is set to zero. 568 * @n: number of elements. 569 * @size: element size. 570 * @flags: the type of memory to allocate (see kmalloc). 571 */ 572 static inline void *kcalloc(size_t n, size_t size, gfp_t flags) 573 { 574 return kmalloc_array(n, size, flags | __GFP_ZERO); 575 } 576 577 /* 578 * kmalloc_track_caller is a special version of kmalloc that records the 579 * calling function of the routine calling it for slab leak tracking instead 580 * of just the calling function (confusing, eh?). 581 * It's useful when the call to kmalloc comes from a widely-used standard 582 * allocator where we care about the real place the memory allocation 583 * request comes from. 584 */ 585 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \ 586 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \ 587 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING)) 588 extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long); 589 #define kmalloc_track_caller(size, flags) \ 590 __kmalloc_track_caller(size, flags, _RET_IP_) 591 #else 592 #define kmalloc_track_caller(size, flags) \ 593 __kmalloc(size, flags) 594 #endif /* DEBUG_SLAB */ 595 596 #ifdef CONFIG_NUMA 597 /* 598 * kmalloc_node_track_caller is a special version of kmalloc_node that 599 * records the calling function of the routine calling it for slab leak 600 * tracking instead of just the calling function (confusing, eh?). 601 * It's useful when the call to kmalloc_node comes from a widely-used 602 * standard allocator where we care about the real place the memory 603 * allocation request comes from. 604 */ 605 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \ 606 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \ 607 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING)) 608 extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long); 609 #define kmalloc_node_track_caller(size, flags, node) \ 610 __kmalloc_node_track_caller(size, flags, node, \ 611 _RET_IP_) 612 #else 613 #define kmalloc_node_track_caller(size, flags, node) \ 614 __kmalloc_node(size, flags, node) 615 #endif 616 617 #else /* CONFIG_NUMA */ 618 619 #define kmalloc_node_track_caller(size, flags, node) \ 620 kmalloc_track_caller(size, flags) 621 622 #endif /* CONFIG_NUMA */ 623 624 /* 625 * Shortcuts 626 */ 627 static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags) 628 { 629 return kmem_cache_alloc(k, flags | __GFP_ZERO); 630 } 631 632 /** 633 * kzalloc - allocate memory. The memory is set to zero. 634 * @size: how many bytes of memory are required. 635 * @flags: the type of memory to allocate (see kmalloc). 636 */ 637 static inline void *kzalloc(size_t size, gfp_t flags) 638 { 639 return kmalloc(size, flags | __GFP_ZERO); 640 } 641 642 /** 643 * kzalloc_node - allocate zeroed memory from a particular memory node. 644 * @size: how many bytes of memory are required. 645 * @flags: the type of memory to allocate (see kmalloc). 646 * @node: memory node from which to allocate 647 */ 648 static inline void *kzalloc_node(size_t size, gfp_t flags, int node) 649 { 650 return kmalloc_node(size, flags | __GFP_ZERO, node); 651 } 652 653 /* 654 * Determine the size of a slab object 655 */ 656 static inline unsigned int kmem_cache_size(struct kmem_cache *s) 657 { 658 return s->object_size; 659 } 660 661 void __init kmem_cache_init_late(void); 662 663 #endif /* _LINUX_SLAB_H */
1 #ifndef __LINUX_SPINLOCK_H 2 #define __LINUX_SPINLOCK_H 3 4 /* 5 * include/linux/spinlock.h - generic spinlock/rwlock declarations 6 * 7 * here's the role of the various spinlock/rwlock related include files: 8 * 9 * on SMP builds: 10 * 11 * asm/spinlock_types.h: contains the arch_spinlock_t/arch_rwlock_t and the 12 * initializers 13 * 14 * linux/spinlock_types.h: 15 * defines the generic type and initializers 16 * 17 * asm/spinlock.h: contains the arch_spin_*()/etc. lowlevel 18 * implementations, mostly inline assembly code 19 * 20 * (also included on UP-debug builds:) 21 * 22 * linux/spinlock_api_smp.h: 23 * contains the prototypes for the _spin_*() APIs. 24 * 25 * linux/spinlock.h: builds the final spin_*() APIs. 26 * 27 * on UP builds: 28 * 29 * linux/spinlock_type_up.h: 30 * contains the generic, simplified UP spinlock type. 31 * (which is an empty structure on non-debug builds) 32 * 33 * linux/spinlock_types.h: 34 * defines the generic type and initializers 35 * 36 * linux/spinlock_up.h: 37 * contains the arch_spin_*()/etc. version of UP 38 * builds. (which are NOPs on non-debug, non-preempt 39 * builds) 40 * 41 * (included on UP-non-debug builds:) 42 * 43 * linux/spinlock_api_up.h: 44 * builds the _spin_*() APIs. 45 * 46 * linux/spinlock.h: builds the final spin_*() APIs. 47 */ 48 49 #include <linux/typecheck.h> 50 #include <linux/preempt.h> 51 #include <linux/linkage.h> 52 #include <linux/compiler.h> 53 #include <linux/irqflags.h> 54 #include <linux/thread_info.h> 55 #include <linux/kernel.h> 56 #include <linux/stringify.h> 57 #include <linux/bottom_half.h> 58 #include <asm/barrier.h> 59 60 61 /* 62 * Must define these before including other files, inline functions need them 63 */ 64 #define LOCK_SECTION_NAME ".text..lock."KBUILD_BASENAME 65 66 #define LOCK_SECTION_START(extra) \ 67 ".subsection 1\n\t" \ 68 extra \ 69 ".ifndef " LOCK_SECTION_NAME "\n\t" \ 70 LOCK_SECTION_NAME ":\n\t" \ 71 ".endif\n" 72 73 #define LOCK_SECTION_END \ 74 ".previous\n\t" 75 76 #define __lockfunc __attribute__((section(".spinlock.text"))) 77 78 /* 79 * Pull the arch_spinlock_t and arch_rwlock_t definitions: 80 */ 81 #include <linux/spinlock_types.h> 82 83 /* 84 * Pull the arch_spin*() functions/declarations (UP-nondebug doesn't need them): 85 */ 86 #ifdef CONFIG_SMP 87 # include <asm/spinlock.h> 88 #else 89 # include <linux/spinlock_up.h> 90 #endif 91 92 #ifdef CONFIG_DEBUG_SPINLOCK 93 extern void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name, 94 struct lock_class_key *key); 95 # define raw_spin_lock_init(lock) \ 96 do { \ 97 static struct lock_class_key __key; \ 98 \ 99 __raw_spin_lock_init((lock), #lock, &__key); \ 100 } while (0) 101 102 #else 103 # define raw_spin_lock_init(lock) \ 104 do { *(lock) = __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0) 105 #endif 106 107 #define raw_spin_is_locked(lock) arch_spin_is_locked(&(lock)->raw_lock) 108 109 #ifdef CONFIG_GENERIC_LOCKBREAK 110 #define raw_spin_is_contended(lock) ((lock)->break_lock) 111 #else 112 113 #ifdef arch_spin_is_contended 114 #define raw_spin_is_contended(lock) arch_spin_is_contended(&(lock)->raw_lock) 115 #else 116 #define raw_spin_is_contended(lock) (((void)(lock), 0)) 117 #endif /*arch_spin_is_contended*/ 118 #endif 119 120 /* 121 * Despite its name it doesn't necessarily has to be a full barrier. 122 * It should only guarantee that a STORE before the critical section 123 * can not be reordered with a LOAD inside this section. 124 * spin_lock() is the one-way barrier, this LOAD can not escape out 125 * of the region. So the default implementation simply ensures that 126 * a STORE can not move into the critical section, smp_wmb() should 127 * serialize it with another STORE done by spin_lock(). 128 */ 129 #ifndef smp_mb__before_spinlock 130 #define smp_mb__before_spinlock() smp_wmb() 131 #endif 132 133 /* 134 * Place this after a lock-acquisition primitive to guarantee that 135 * an UNLOCK+LOCK pair act as a full barrier. This guarantee applies 136 * if the UNLOCK and LOCK are executed by the same CPU or if the 137 * UNLOCK and LOCK operate on the same lock variable. 138 */ 139 #ifndef smp_mb__after_unlock_lock 140 #define smp_mb__after_unlock_lock() do { } while (0) 141 #endif 142 143 /** 144 * raw_spin_unlock_wait - wait until the spinlock gets unlocked 145 * @lock: the spinlock in question. 146 */ 147 #define raw_spin_unlock_wait(lock) arch_spin_unlock_wait(&(lock)->raw_lock) 148 149 #ifdef CONFIG_DEBUG_SPINLOCK 150 extern void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock); 151 #define do_raw_spin_lock_flags(lock, flags) do_raw_spin_lock(lock) 152 extern int do_raw_spin_trylock(raw_spinlock_t *lock); 153 extern void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock); 154 #else 155 static inline void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock) 156 { 157 __acquire(lock); 158 arch_spin_lock(&lock->raw_lock); 159 } 160 161 static inline void 162 do_raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long *flags) __acquires(lock) 163 { 164 __acquire(lock); 165 arch_spin_lock_flags(&lock->raw_lock, *flags); 166 } 167 168 static inline int do_raw_spin_trylock(raw_spinlock_t *lock) 169 { 170 return arch_spin_trylock(&(lock)->raw_lock); 171 } 172 173 static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock) 174 { 175 arch_spin_unlock(&lock->raw_lock); 176 __release(lock); 177 } 178 #endif 179 180 /* 181 * Define the various spin_lock methods. Note we define these 182 * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The 183 * various methods are defined as nops in the case they are not 184 * required. 185 */ 186 #define raw_spin_trylock(lock) __cond_lock(lock, _raw_spin_trylock(lock)) 187 188 #define raw_spin_lock(lock) _raw_spin_lock(lock) 189 190 #ifdef CONFIG_DEBUG_LOCK_ALLOC 191 # define raw_spin_lock_nested(lock, subclass) \ 192 _raw_spin_lock_nested(lock, subclass) 193 194 # define raw_spin_lock_nest_lock(lock, nest_lock) \ 195 do { \ 196 typecheck(struct lockdep_map *, &(nest_lock)->dep_map);\ 197 _raw_spin_lock_nest_lock(lock, &(nest_lock)->dep_map); \ 198 } while (0) 199 #else 200 # define raw_spin_lock_nested(lock, subclass) _raw_spin_lock(lock) 201 # define raw_spin_lock_nest_lock(lock, nest_lock) _raw_spin_lock(lock) 202 #endif 203 204 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) 205 206 #define raw_spin_lock_irqsave(lock, flags) \ 207 do { \ 208 typecheck(unsigned long, flags); \ 209 flags = _raw_spin_lock_irqsave(lock); \ 210 } while (0) 211 212 #ifdef CONFIG_DEBUG_LOCK_ALLOC 213 #define raw_spin_lock_irqsave_nested(lock, flags, subclass) \ 214 do { \ 215 typecheck(unsigned long, flags); \ 216 flags = _raw_spin_lock_irqsave_nested(lock, subclass); \ 217 } while (0) 218 #else 219 #define raw_spin_lock_irqsave_nested(lock, flags, subclass) \ 220 do { \ 221 typecheck(unsigned long, flags); \ 222 flags = _raw_spin_lock_irqsave(lock); \ 223 } while (0) 224 #endif 225 226 #else 227 228 #define raw_spin_lock_irqsave(lock, flags) \ 229 do { \ 230 typecheck(unsigned long, flags); \ 231 _raw_spin_lock_irqsave(lock, flags); \ 232 } while (0) 233 234 #define raw_spin_lock_irqsave_nested(lock, flags, subclass) \ 235 raw_spin_lock_irqsave(lock, flags) 236 237 #endif 238 239 #define raw_spin_lock_irq(lock) _raw_spin_lock_irq(lock) 240 #define raw_spin_lock_bh(lock) _raw_spin_lock_bh(lock) 241 #define raw_spin_unlock(lock) _raw_spin_unlock(lock) 242 #define raw_spin_unlock_irq(lock) _raw_spin_unlock_irq(lock) 243 244 #define raw_spin_unlock_irqrestore(lock, flags) \ 245 do { \ 246 typecheck(unsigned long, flags); \ 247 _raw_spin_unlock_irqrestore(lock, flags); \ 248 } while (0) 249 #define raw_spin_unlock_bh(lock) _raw_spin_unlock_bh(lock) 250 251 #define raw_spin_trylock_bh(lock) \ 252 __cond_lock(lock, _raw_spin_trylock_bh(lock)) 253 254 #define raw_spin_trylock_irq(lock) \ 255 ({ \ 256 local_irq_disable(); \ 257 raw_spin_trylock(lock) ? \ 258 1 : ({ local_irq_enable(); 0; }); \ 259 }) 260 261 #define raw_spin_trylock_irqsave(lock, flags) \ 262 ({ \ 263 local_irq_save(flags); \ 264 raw_spin_trylock(lock) ? \ 265 1 : ({ local_irq_restore(flags); 0; }); \ 266 }) 267 268 /** 269 * raw_spin_can_lock - would raw_spin_trylock() succeed? 270 * @lock: the spinlock in question. 271 */ 272 #define raw_spin_can_lock(lock) (!raw_spin_is_locked(lock)) 273 274 /* Include rwlock functions */ 275 #include <linux/rwlock.h> 276 277 /* 278 * Pull the _spin_*()/_read_*()/_write_*() functions/declarations: 279 */ 280 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) 281 # include <linux/spinlock_api_smp.h> 282 #else 283 # include <linux/spinlock_api_up.h> 284 #endif 285 286 /* 287 * Map the spin_lock functions to the raw variants for PREEMPT_RT=n 288 */ 289 290 static inline raw_spinlock_t *spinlock_check(spinlock_t *lock) 291 { 292 return &lock->rlock; 293 } 294 295 #define spin_lock_init(_lock) \ 296 do { \ 297 spinlock_check(_lock); \ 298 raw_spin_lock_init(&(_lock)->rlock); \ 299 } while (0) 300 301 static inline void spin_lock(spinlock_t *lock) 302 { 303 raw_spin_lock(&lock->rlock); 304 } 305 306 static inline void spin_lock_bh(spinlock_t *lock) 307 { 308 raw_spin_lock_bh(&lock->rlock); 309 } 310 311 static inline int spin_trylock(spinlock_t *lock) 312 { 313 return raw_spin_trylock(&lock->rlock); 314 } 315 316 #define spin_lock_nested(lock, subclass) \ 317 do { \ 318 raw_spin_lock_nested(spinlock_check(lock), subclass); \ 319 } while (0) 320 321 #define spin_lock_nest_lock(lock, nest_lock) \ 322 do { \ 323 raw_spin_lock_nest_lock(spinlock_check(lock), nest_lock); \ 324 } while (0) 325 326 static inline void spin_lock_irq(spinlock_t *lock) 327 { 328 raw_spin_lock_irq(&lock->rlock); 329 } 330 331 #define spin_lock_irqsave(lock, flags) \ 332 do { \ 333 raw_spin_lock_irqsave(spinlock_check(lock), flags); \ 334 } while (0) 335 336 #define spin_lock_irqsave_nested(lock, flags, subclass) \ 337 do { \ 338 raw_spin_lock_irqsave_nested(spinlock_check(lock), flags, subclass); \ 339 } while (0) 340 341 static inline void spin_unlock(spinlock_t *lock) 342 { 343 raw_spin_unlock(&lock->rlock); 344 } 345 346 static inline void spin_unlock_bh(spinlock_t *lock) 347 { 348 raw_spin_unlock_bh(&lock->rlock); 349 } 350 351 static inline void spin_unlock_irq(spinlock_t *lock) 352 { 353 raw_spin_unlock_irq(&lock->rlock); 354 } 355 356 static inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) 357 { 358 raw_spin_unlock_irqrestore(&lock->rlock, flags); 359 } 360 361 static inline int spin_trylock_bh(spinlock_t *lock) 362 { 363 return raw_spin_trylock_bh(&lock->rlock); 364 } 365 366 static inline int spin_trylock_irq(spinlock_t *lock) 367 { 368 return raw_spin_trylock_irq(&lock->rlock); 369 } 370 371 #define spin_trylock_irqsave(lock, flags) \ 372 ({ \ 373 raw_spin_trylock_irqsave(spinlock_check(lock), flags); \ 374 }) 375 376 static inline void spin_unlock_wait(spinlock_t *lock) 377 { 378 raw_spin_unlock_wait(&lock->rlock); 379 } 380 381 static inline int spin_is_locked(spinlock_t *lock) 382 { 383 return raw_spin_is_locked(&lock->rlock); 384 } 385 386 static inline int spin_is_contended(spinlock_t *lock) 387 { 388 return raw_spin_is_contended(&lock->rlock); 389 } 390 391 static inline int spin_can_lock(spinlock_t *lock) 392 { 393 return raw_spin_can_lock(&lock->rlock); 394 } 395 396 #define assert_spin_locked(lock) assert_raw_spin_locked(&(lock)->rlock) 397 398 /* 399 * Pull the atomic_t declaration: 400 * (asm-mips/atomic.h needs above definitions) 401 */ 402 #include <linux/atomic.h> 403 /** 404 * atomic_dec_and_lock - lock on reaching reference count zero 405 * @atomic: the atomic counter 406 * @lock: the spinlock in question 407 * 408 * Decrements @atomic by 1. If the result is 0, returns true and locks 409 * @lock. Returns false for all other cases. 410 */ 411 extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); 412 #define atomic_dec_and_lock(atomic, lock) \ 413 __cond_lock(lock, _atomic_dec_and_lock(atomic, lock)) 414 415 #endif /* __LINUX_SPINLOCK_H */

Here is an explanation of a rule violation arisen while checking your driver against a corresponding kernel.

Note that it may be false positive, i.e. there isn't a real error indeed. Please analyze a given error trace and related source code to understand whether there is an error in your driver.

Error trace column contains a path on which the given rule is violated. You can expand/collapse some entity classes by clicking on corresponding checkboxes in a main menu or in an advanced Others menu. Also you can expand/collapse each particular entity by clicking on +/-. In hovering on some entities you can see some tips. Also the error trace is bound with related source code. Line numbers may be shown as links on the left. You can click on them to open corresponding lines in source code.

Source code column contains a content of files related with the error trace. There is source code of your driver (note that there are some LDV modifications at the end), kernel headers and rule model. Tabs show a currently opened file and other available files. In hovering on them you can see full file names. On clicking a corresponding file content will be shown.

Kernel Module Rule Verifier Verdict Status Timestamp Bug report
linux-3.16-rc1.tar.xz drivers/staging/dgnc/dgnc.ko 106_1a CPAchecker Bug Reported 2014-12-12 13:15:42 LKML20141219368

Comment

dgnc_class is not checked for validness (ERR_PTR)

[Home]