extern void abort(void); extern void __assert_fail(const char *, const char *, unsigned int, const char *) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); void reach_error() { __assert_fail("0", "drivers--hwmon--it87.ko_042.87b4b66.08_1a.cil_true-unreach-call.i", 3, "reach_error"); } /* Generated by CIL v. 1.5.1 */ /* print_CIL_Input is false */ typedef unsigned int __kernel_mode_t; typedef unsigned long __kernel_size_t; typedef long __kernel_ssize_t; typedef unsigned short __u16; typedef int __s32; typedef unsigned int __u32; typedef unsigned long long __u64; typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; typedef unsigned long long u64; typedef __u32 __kernel_dev_t; typedef __kernel_dev_t dev_t; typedef __kernel_mode_t mode_t; typedef __kernel_size_t size_t; typedef __kernel_ssize_t ssize_t; typedef unsigned int gfp_t; typedef u64 resource_size_t; struct bug_entry { unsigned long bug_addr ; char const *file ; unsigned short line ; unsigned short flags ; }; struct page; struct module; struct task_struct; struct completion; struct pt_regs; struct __anonstruct_mm_segment_t_8 { unsigned long seg ; }; typedef struct __anonstruct_mm_segment_t_8 mm_segment_t; struct exec_domain; struct map_segment; struct exec_domain { char const *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 ; }; struct list_head { struct list_head *next ; struct list_head *prev ; }; struct __anonstruct_ldv_2651_11 { unsigned long arg0 ; unsigned long arg1 ; unsigned long arg2 ; unsigned long arg3 ; }; struct __anonstruct_futex_12 { u32 *uaddr ; u32 val ; u32 flags ; u64 time ; }; union __anonunion_ldv_2658_10 { struct __anonstruct_ldv_2651_11 ldv_2651 ; struct __anonstruct_futex_12 futex ; }; struct restart_block { long (*fn)(struct restart_block * ) ; union __anonunion_ldv_2658_10 ldv_2658 ; }; struct thread_info { struct task_struct *task ; struct exec_domain *exec_domain ; __u32 flags ; __u32 status ; __u32 cpu ; int preempt_count ; mm_segment_t addr_limit ; struct restart_block restart_block ; }; struct __anonstruct_raw_spinlock_t_13 { unsigned int slock ; }; typedef struct __anonstruct_raw_spinlock_t_13 raw_spinlock_t; struct lockdep_map; struct stack_trace { unsigned int nr_entries ; unsigned int max_entries ; unsigned long *entries ; int skip ; }; struct lockdep_subclass_key { char __one_byte ; }; struct lock_class_key { struct lockdep_subclass_key subkeys[8U] ; }; struct lock_class { struct list_head hash_entry ; struct list_head lock_entry ; struct lockdep_subclass_key *key ; unsigned int subclass ; unsigned long usage_mask ; struct stack_trace usage_traces[9U] ; struct list_head locks_after ; struct list_head locks_before ; unsigned int version ; unsigned long ops ; char const *name ; int name_version ; unsigned long contention_point[4U] ; }; struct lockdep_map { struct lock_class_key *key ; struct lock_class *class_cache ; char const *name ; int cpu ; }; struct __anonstruct_spinlock_t_15 { raw_spinlock_t raw_lock ; unsigned int magic ; unsigned int owner_cpu ; void *owner ; struct lockdep_map dep_map ; }; typedef struct __anonstruct_spinlock_t_15 spinlock_t; struct __anonstruct_atomic_t_17 { int counter ; }; typedef struct __anonstruct_atomic_t_17 atomic_t; struct __anonstruct_atomic64_t_18 { long counter ; }; typedef struct __anonstruct_atomic64_t_18 atomic64_t; typedef atomic64_t atomic_long_t; struct pt_regs { unsigned long r15 ; unsigned long r14 ; unsigned long r13 ; unsigned long r12 ; unsigned long rbp ; unsigned long rbx ; unsigned long r11 ; unsigned long r10 ; unsigned long r9 ; unsigned long r8 ; unsigned long rax ; unsigned long rcx ; unsigned long rdx ; unsigned long rsi ; unsigned long rdi ; unsigned long orig_rax ; unsigned long rip ; unsigned long cs ; unsigned long eflags ; unsigned long rsp ; unsigned long ss ; }; typedef __u64 Elf64_Addr; typedef __u16 Elf64_Half; typedef __u32 Elf64_Word; typedef __u64 Elf64_Xword; 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 ; }; typedef struct elf64_sym Elf64_Sym; struct kobject; struct attribute { char const *name ; struct module *owner ; mode_t mode ; }; struct attribute_group { char const *name ; struct attribute **attrs ; }; struct sysfs_ops { ssize_t (*show)(struct kobject * , struct attribute * , char * ) ; ssize_t (*store)(struct kobject * , struct attribute * , char const * , size_t ) ; }; struct kref { atomic_t refcount ; }; struct __wait_queue_head { spinlock_t lock ; struct list_head task_list ; }; typedef struct __wait_queue_head wait_queue_head_t; struct kset; struct kobj_type; struct sysfs_dirent; struct kobject { char const *k_name ; struct kref kref ; struct list_head entry ; struct kobject *parent ; struct kset *kset ; struct kobj_type *ktype ; struct sysfs_dirent *sd ; }; struct kobj_type { void (*release)(struct kobject * ) ; struct sysfs_ops *sysfs_ops ; struct attribute **default_attrs ; }; struct kobj_uevent_env { char *envp[32U] ; int envp_idx ; char buf[2048U] ; int buflen ; }; struct kset_uevent_ops { int (*filter)(struct kset * , struct kobject * ) ; char const *(*name)(struct kset * , struct kobject * ) ; int (*uevent)(struct kset * , struct kobject * , struct kobj_uevent_env * ) ; }; struct kset { struct kobj_type *ktype ; struct list_head list ; spinlock_t list_lock ; struct kobject kobj ; struct kset_uevent_ops *uevent_ops ; }; struct marker; typedef void marker_probe_func(struct marker const * , void * , char const * , ...); struct marker { char const *name ; char const *format ; char state ; marker_probe_func *call ; void *private ; }; struct mutex { atomic_t count ; spinlock_t wait_lock ; struct list_head wait_list ; struct thread_info *owner ; char const *name ; void *magic ; struct lockdep_map dep_map ; }; struct rw_semaphore; struct rw_semaphore { __s32 activity ; spinlock_t wait_lock ; struct list_head wait_list ; struct lockdep_map dep_map ; }; struct notifier_block { int (*notifier_call)(struct notifier_block * , unsigned long , void * ) ; struct notifier_block *next ; int priority ; }; struct blocking_notifier_head { struct rw_semaphore rwsem ; struct notifier_block *head ; }; struct device; struct pm_message { int event ; }; typedef struct pm_message pm_message_t; struct dev_pm_info { pm_message_t power_state ; unsigned char can_wakeup : 1 ; unsigned char should_wakeup : 1 ; struct list_head entry ; }; struct kmem_cache; struct kmem_cache_cpu { void **freelist ; struct page *page ; int node ; unsigned int offset ; unsigned int objsize ; }; struct kmem_cache_node { spinlock_t list_lock ; unsigned long nr_partial ; atomic_long_t nr_slabs ; struct list_head partial ; struct list_head full ; }; struct kmem_cache { unsigned long flags ; int size ; int objsize ; int offset ; int order ; struct kmem_cache_node local_node ; int objects ; int refcount ; void (*ctor)(struct kmem_cache * , void * ) ; int inuse ; int align ; char const *name ; struct list_head list ; struct kobject kobj ; int defrag_ratio ; struct kmem_cache_node *node[64U] ; struct kmem_cache_cpu *cpu_slab[8U] ; }; struct __anonstruct_local_t_76 { atomic_long_t a ; }; typedef struct __anonstruct_local_t_76 local_t; struct mod_arch_specific { }; struct kernel_symbol { unsigned long value ; char const *name ; }; struct module_attribute { struct attribute attr ; ssize_t (*show)(struct module_attribute * , struct module * , char * ) ; ssize_t (*store)(struct module_attribute * , struct module * , char const * , size_t ) ; void (*setup)(struct module * , char const * ) ; int (*test)(struct module * ) ; void (*free)(struct module * ) ; }; struct module_kobject { struct kobject kobj ; struct module *mod ; struct kobject *drivers_dir ; }; struct exception_table_entry; struct module_ref { local_t count ; }; enum module_state { MODULE_STATE_LIVE = 0, MODULE_STATE_COMING = 1, MODULE_STATE_GOING = 2 } ; struct module_sect_attr { struct module_attribute mattr ; char *name ; unsigned long address ; }; struct module_sect_attrs { struct attribute_group grp ; int nsections ; struct module_sect_attr attrs[0U] ; }; struct module_param_attrs; struct module_notes_attrs; struct module { enum module_state state ; struct list_head list ; char name[56U] ; struct module_kobject mkobj ; struct module_param_attrs *param_attrs ; struct module_attribute *modinfo_attrs ; char const *version ; char const *srcversion ; struct kobject *holders_dir ; struct kernel_symbol const *syms ; unsigned int num_syms ; unsigned long const *crcs ; struct kernel_symbol const *gpl_syms ; unsigned int num_gpl_syms ; unsigned long const *gpl_crcs ; struct kernel_symbol const *unused_syms ; unsigned int num_unused_syms ; unsigned long const *unused_crcs ; struct kernel_symbol const *unused_gpl_syms ; unsigned int num_unused_gpl_syms ; unsigned long const *unused_gpl_crcs ; struct kernel_symbol const *gpl_future_syms ; unsigned int num_gpl_future_syms ; unsigned long const *gpl_future_crcs ; unsigned int num_exentries ; struct exception_table_entry const *extable ; int (*init)(void) ; void *module_init ; void *module_core ; unsigned long init_size ; unsigned long core_size ; unsigned long init_text_size ; unsigned long core_text_size ; void *unwind_info ; struct mod_arch_specific arch ; unsigned int taints ; struct list_head bug_list ; struct bug_entry *bug_table ; unsigned int num_bugs ; struct module_ref ref[8U] ; struct list_head modules_which_use_me ; struct task_struct *waiter ; void (*exit)(void) ; Elf64_Sym *symtab ; unsigned long num_symtab ; char *strtab ; struct module_sect_attrs *sect_attrs ; struct module_notes_attrs *notes_attrs ; void *percpu ; char *args ; struct marker *markers ; unsigned int num_markers ; }; struct device_driver; struct resource { resource_size_t start ; resource_size_t end ; char const *name ; unsigned long flags ; struct resource *parent ; struct resource *sibling ; struct resource *child ; }; struct completion { unsigned int done ; wait_queue_head_t wait ; }; struct klist_node; struct klist { spinlock_t k_lock ; struct list_head k_list ; void (*get)(struct klist_node * ) ; void (*put)(struct klist_node * ) ; }; struct klist_node { struct klist *n_klist ; struct list_head n_node ; struct kref n_ref ; struct completion n_removed ; }; struct semaphore { atomic_t count ; int sleepers ; wait_queue_head_t wait ; }; struct dev_archdata { void *acpi_handle ; void *iommu ; }; struct class; struct class_device; struct bus_type; struct bus_attribute { struct attribute attr ; ssize_t (*show)(struct bus_type * , char * ) ; ssize_t (*store)(struct bus_type * , char const * , size_t ) ; }; struct device_attribute; struct driver_attribute; struct bus_type { char const *name ; struct module *owner ; struct kset subsys ; struct kset drivers ; struct kset devices ; struct klist klist_devices ; struct klist klist_drivers ; struct blocking_notifier_head bus_notifier ; struct bus_attribute *bus_attrs ; struct device_attribute *dev_attrs ; struct driver_attribute *drv_attrs ; 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 (*suspend)(struct device * , pm_message_t ) ; int (*suspend_late)(struct device * , pm_message_t ) ; int (*resume_early)(struct device * ) ; int (*resume)(struct device * ) ; unsigned char drivers_autoprobe : 1 ; }; struct device_driver { char const *name ; struct bus_type *bus ; struct kobject kobj ; struct klist klist_devices ; struct klist_node knode_bus ; struct module *owner ; char const *mod_name ; struct module_kobject *mkobj ; int (*probe)(struct device * ) ; int (*remove)(struct device * ) ; void (*shutdown)(struct device * ) ; int (*suspend)(struct device * , pm_message_t ) ; int (*resume)(struct device * ) ; }; struct driver_attribute { struct attribute attr ; ssize_t (*show)(struct device_driver * , char * ) ; ssize_t (*store)(struct device_driver * , char const * , size_t ) ; }; struct class_attribute; struct class_device_attribute; struct class { char const *name ; struct module *owner ; struct kset subsys ; struct list_head children ; struct list_head devices ; struct list_head interfaces ; struct kset class_dirs ; struct semaphore sem ; struct class_attribute *class_attrs ; struct class_device_attribute *class_dev_attrs ; struct device_attribute *dev_attrs ; int (*uevent)(struct class_device * , struct kobj_uevent_env * ) ; int (*dev_uevent)(struct device * , struct kobj_uevent_env * ) ; void (*release)(struct class_device * ) ; void (*class_release)(struct class * ) ; void (*dev_release)(struct device * ) ; int (*suspend)(struct device * , pm_message_t ) ; int (*resume)(struct device * ) ; }; struct class_attribute { struct attribute attr ; ssize_t (*show)(struct class * , char * ) ; ssize_t (*store)(struct class * , char const * , size_t ) ; }; struct class_device_attribute { struct attribute attr ; ssize_t (*show)(struct class_device * , char * ) ; ssize_t (*store)(struct class_device * , char const * , size_t ) ; }; struct class_device { struct list_head node ; struct kobject kobj ; struct class *class ; dev_t devt ; struct device *dev ; void *class_data ; struct class_device *parent ; struct attribute_group **groups ; void (*release)(struct class_device * ) ; int (*uevent)(struct class_device * , struct kobj_uevent_env * ) ; char class_id[20U] ; }; struct device_type { char const *name ; struct attribute_group **groups ; int (*uevent)(struct device * , struct kobj_uevent_env * ) ; void (*release)(struct device * ) ; int (*suspend)(struct device * , pm_message_t ) ; int (*resume)(struct device * ) ; }; struct device_attribute { struct attribute attr ; ssize_t (*show)(struct device * , struct device_attribute * , char * ) ; ssize_t (*store)(struct device * , struct device_attribute * , char const * , size_t ) ; }; struct dma_coherent_mem; struct device { struct klist klist_children ; struct klist_node knode_parent ; struct klist_node knode_driver ; struct klist_node knode_bus ; struct device *parent ; struct kobject kobj ; char bus_id[20U] ; struct device_type *type ; unsigned char is_registered : 1 ; unsigned char uevent_suppress : 1 ; struct semaphore sem ; struct bus_type *bus ; struct device_driver *driver ; void *driver_data ; void *platform_data ; struct dev_pm_info power ; int numa_node ; u64 *dma_mask ; u64 coherent_dma_mask ; struct list_head dma_pools ; struct dma_coherent_mem *dma_mem ; struct dev_archdata archdata ; spinlock_t devres_lock ; struct list_head devres_head ; struct list_head node ; struct class *class ; dev_t devt ; struct attribute_group **groups ; void (*release)(struct device * ) ; }; struct platform_device { char const *name ; int id ; struct device dev ; u32 num_resources ; struct resource *resource ; }; struct platform_driver { int (*probe)(struct platform_device * ) ; int (*remove)(struct platform_device * ) ; void (*shutdown)(struct platform_device * ) ; int (*suspend)(struct platform_device * , pm_message_t ) ; int (*suspend_late)(struct platform_device * , pm_message_t ) ; int (*resume_early)(struct platform_device * ) ; int (*resume)(struct platform_device * ) ; struct device_driver driver ; }; struct sensor_device_attribute { struct device_attribute dev_attr ; int index ; }; enum chips { it87 = 0, it8712 = 1, it8716 = 2, it8718 = 3 } ; struct it87_sio_data { enum chips type ; u8 vid_value ; }; struct it87_data { struct device *hwmon_dev ; enum chips type ; unsigned short addr ; char const *name ; struct mutex update_lock ; char valid ; unsigned long last_updated ; u8 in[9U] ; u8 in_max[8U] ; u8 in_min[8U] ; u8 has_fan ; u16 fan[5U] ; u16 fan_min[5U] ; u8 temp[3U] ; u8 temp_high[3U] ; u8 temp_low[3U] ; u8 sensor ; u8 fan_div[3U] ; u8 vid ; u8 vrm ; u32 alarms ; u8 fan_main_ctrl ; u8 fan_ctl ; u8 manual_pwm_ctl[3U] ; }; long ldv__builtin_expect(long exp , long c ) ; extern unsigned long simple_strtoul(char const * , char ** , unsigned int ) ; extern long simple_strtol(char const * , char ** , unsigned int ) ; extern int sprintf(char * , char const * , ...) ; extern int printk(char const * , ...) ; extern int sysfs_create_group(struct kobject * , struct attribute_group const * ) ; extern void sysfs_remove_group(struct kobject * , struct attribute_group const * ) ; extern void __mutex_init(struct mutex * , char const * , struct lock_class_key * ) ; extern void mutex_lock_nested(struct mutex * , unsigned int ) ; extern void mutex_unlock(struct mutex * ) ; extern void kfree(void const * ) ; extern unsigned long volatile jiffies ; extern void *__kmalloc(size_t , gfp_t ) ; __inline static void *kmalloc(size_t size , gfp_t flags ) { void *tmp___3 ; { tmp___3 = __kmalloc(size, flags); return (tmp___3); } } __inline static void *kzalloc(size_t size , gfp_t flags ) { void *tmp ; { tmp = kmalloc(size, flags | 32768U); return (tmp); } } extern struct module __this_module ; extern struct resource ioport_resource ; extern struct resource *__request_region(struct resource * , resource_size_t , resource_size_t , char const * ) ; extern void __release_region(struct resource * , resource_size_t , resource_size_t ) ; extern int device_create_file(struct device * , struct device_attribute * ) ; __inline static void *dev_get_drvdata(struct device *dev ) { { return (dev->driver_data); } } __inline static void dev_set_drvdata(struct device *dev , void *data ) { { dev->driver_data = data; return; } } extern char const *dev_driver_string(struct device * ) ; extern void platform_device_unregister(struct platform_device * ) ; extern struct resource *platform_get_resource(struct platform_device * , unsigned int , unsigned int ) ; extern struct platform_device *platform_device_alloc(char const * , int ) ; extern int platform_device_add_resources(struct platform_device * , struct resource * , unsigned int ) ; extern int platform_device_add_data(struct platform_device * , void const * , size_t ) ; extern int platform_device_add(struct platform_device * ) ; extern void platform_device_put(struct platform_device * ) ; extern int platform_driver_register(struct platform_driver * ) ; extern void platform_driver_unregister(struct platform_driver * ) ; extern struct device *hwmon_device_register(struct device * ) ; extern void hwmon_device_unregister(struct device * ) ; __inline static int SENSORS_LIMIT(long value , long low , long high ) { { if (value < low) { return ((int )low); } else if (value > high) { return ((int )high); } else { return ((int )value); } } } extern int vid_from_reg(int , u8 ) ; extern u8 vid_which_vrm(void) ; __inline static long PTR_ERR(void const *ptr ) { { return ((long )ptr); } } __inline static long IS_ERR(void const *ptr ) { long tmp ; { tmp = ldv__builtin_expect((unsigned long )ptr > 0xfffffffffffff000UL, 0L); return (tmp); } } __inline static unsigned char inb(unsigned short port ) { unsigned char _v ; { __asm__ volatile ("inb %w1,%0": "=a" (_v): "Nd" (port)); return (_v); } } __inline static unsigned char inb_p(unsigned short port ) { unsigned char _v ; { __asm__ volatile ("inb %w1,%0\noutb %%al,$0x80": "=a" (_v): "Nd" (port)); return (_v); } } __inline static void outb(unsigned char value , unsigned short port ) { { __asm__ volatile ("outb %b0,%w1": : "a" (value), "Nd" (port)); return; } } __inline static void outb_p(unsigned char value , unsigned short port ) { { __asm__ volatile ("outb %b0,%w1\noutb %%al,$0x80": : "a" (value), "Nd" (port)); return; } } static struct platform_device *pdev ; __inline static int superio_inb(int reg ) { unsigned char tmp ; { outb((int )((unsigned char )reg), 46); tmp = inb(47); return ((int )tmp); } } static int superio_inw(int reg ) { int val ; int tmp ; unsigned char tmp___0 ; unsigned char tmp___1 ; { tmp = reg; reg = reg + 1; outb((int )((unsigned char )tmp), 46); tmp___0 = inb(47); val = (int )tmp___0 << 8; outb((int )((unsigned char )reg), 46); tmp___1 = inb(47); val = (int )tmp___1 | val; return (val); } } __inline static void superio_select(int ldn ) { { outb(7, 46); outb((int )((unsigned char )ldn), 47); return; } } __inline static void superio_enter(void) { { outb(135, 46); outb(1, 46); outb(85, 46); outb(85, 46); return; } } __inline static void superio_exit(void) { { outb(2, 46); outb(2, 47); return; } } static int update_vbat ; static int fix_pwm_polarity ; static u8 const IT87_REG_FAN[5U] = { 13U, 14U, 15U, 128U, 130U}; static u8 const IT87_REG_FAN_MIN[5U] = { 16U, 17U, 18U, 132U, 134U}; static u8 const IT87_REG_FANX[5U] = { 24U, 25U, 26U, 129U, 131U}; static u8 const IT87_REG_FANX_MIN[5U] = { 27U, 28U, 29U, 133U, 135U}; __inline static u8 FAN_TO_REG(long rpm , int div ) { int tmp ; int tmp___0 ; { if (rpm == 0L) { return (255U); } else { } tmp = SENSORS_LIMIT(rpm, 1L, 1000000L); rpm = (long )tmp; tmp___0 = SENSORS_LIMIT((((long )div * rpm) / 2L + 1350000L) / ((long )div * rpm), 1L, 254L); return ((u8 )tmp___0); } } __inline static u16 FAN16_TO_REG(long rpm ) { int tmp ; { if (rpm == 0L) { return (65535U); } else { } tmp = SENSORS_LIMIT((rpm + 1350000L) / (rpm * 2L), 1L, 65534L); return ((u16 )tmp); } } static int DIV_TO_REG(int val ) { int answer ; { answer = 0; goto ldv_7611; ldv_7610: answer = answer + 1; ldv_7611: ; if (answer <= 6) { val = val >> 1; if (val != 0) { goto ldv_7610; } else { goto ldv_7612; } } else { } ldv_7612: ; return (answer); } } static unsigned int const pwm_freq[8U] = { 375000U, 187500U, 93750U, 62500U, 46875U, 23437U, 11718U, 5859U}; static int it87_probe(struct platform_device *pdev___0 ) ; static int it87_remove(struct platform_device *pdev___0 ) ; static int it87_read_value(struct it87_data *data , u8 reg ) ; static void it87_write_value(struct it87_data *data , u8 reg , u8 value ) ; static struct it87_data *it87_update_device(struct device *dev ) ; static int it87_check_pwm(struct device *dev ) ; static void it87_init_device(struct platform_device *pdev___0 ) ; static struct platform_driver it87_driver = {& it87_probe, & it87_remove, 0, 0, 0, 0, 0, {"it87", 0, {0, {{0}}, {0, 0}, 0, 0, 0, 0}, {{{0U}, 0U, 0U, 0, {0, 0, 0, 0}}, {0, 0}, 0, 0}, {0, {0, 0}, {{0}}, {0U, {{{0U}, 0U, 0U, 0, {0, 0, 0, 0}}, {0, 0}}}}, & __this_module, 0, 0, 0, 0, 0, 0, 0}}; static ssize_t show_in(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (int )data->in[nr] * 16); return ((ssize_t )tmp___0); } } static ssize_t show_in_min(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (int )data->in_min[nr] * 16); return ((ssize_t )tmp___0); } } static ssize_t show_in_max(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (int )data->in_max[nr] * 16); return ((ssize_t )tmp___0); } } static ssize_t set_in_min(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; void *tmp ; unsigned long val ; unsigned long tmp___0 ; int tmp___1 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtoul(buf, 0, 10U); val = tmp___0; mutex_lock_nested(& data->update_lock, 0U); tmp___1 = SENSORS_LIMIT((long )((val + 8UL) / 16UL), 0L, 255L); data->in_min[nr] = (u8 )tmp___1; it87_write_value(data, (int )((unsigned int )((u8 )nr) * 2U + 49U), (int )data->in_min[nr]); mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static ssize_t set_in_max(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; void *tmp ; unsigned long val ; unsigned long tmp___0 ; int tmp___1 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtoul(buf, 0, 10U); val = tmp___0; mutex_lock_nested(& data->update_lock, 0U); tmp___1 = SENSORS_LIMIT((long )((val + 8UL) / 16UL), 0L, 255L); data->in_max[nr] = (u8 )tmp___1; it87_write_value(data, (int )((unsigned int )((u8 )(nr + 24)) * 2U), (int )data->in_max[nr]); mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static struct sensor_device_attribute sensor_dev_attr_in0_input = {{{"in0_input", 0, 292U}, & show_in, 0}, 0}; static struct sensor_device_attribute sensor_dev_attr_in0_min = {{{"in0_min", 0, 420U}, & show_in_min, & set_in_min}, 0}; static struct sensor_device_attribute sensor_dev_attr_in0_max = {{{"in0_max", 0, 420U}, & show_in_max, & set_in_max}, 0}; static struct sensor_device_attribute sensor_dev_attr_in1_input = {{{"in1_input", 0, 292U}, & show_in, 0}, 1}; static struct sensor_device_attribute sensor_dev_attr_in1_min = {{{"in1_min", 0, 420U}, & show_in_min, & set_in_min}, 1}; static struct sensor_device_attribute sensor_dev_attr_in1_max = {{{"in1_max", 0, 420U}, & show_in_max, & set_in_max}, 1}; static struct sensor_device_attribute sensor_dev_attr_in2_input = {{{"in2_input", 0, 292U}, & show_in, 0}, 2}; static struct sensor_device_attribute sensor_dev_attr_in2_min = {{{"in2_min", 0, 420U}, & show_in_min, & set_in_min}, 2}; static struct sensor_device_attribute sensor_dev_attr_in2_max = {{{"in2_max", 0, 420U}, & show_in_max, & set_in_max}, 2}; static struct sensor_device_attribute sensor_dev_attr_in3_input = {{{"in3_input", 0, 292U}, & show_in, 0}, 3}; static struct sensor_device_attribute sensor_dev_attr_in3_min = {{{"in3_min", 0, 420U}, & show_in_min, & set_in_min}, 3}; static struct sensor_device_attribute sensor_dev_attr_in3_max = {{{"in3_max", 0, 420U}, & show_in_max, & set_in_max}, 3}; static struct sensor_device_attribute sensor_dev_attr_in4_input = {{{"in4_input", 0, 292U}, & show_in, 0}, 4}; static struct sensor_device_attribute sensor_dev_attr_in4_min = {{{"in4_min", 0, 420U}, & show_in_min, & set_in_min}, 4}; static struct sensor_device_attribute sensor_dev_attr_in4_max = {{{"in4_max", 0, 420U}, & show_in_max, & set_in_max}, 4}; static struct sensor_device_attribute sensor_dev_attr_in5_input = {{{"in5_input", 0, 292U}, & show_in, 0}, 5}; static struct sensor_device_attribute sensor_dev_attr_in5_min = {{{"in5_min", 0, 420U}, & show_in_min, & set_in_min}, 5}; static struct sensor_device_attribute sensor_dev_attr_in5_max = {{{"in5_max", 0, 420U}, & show_in_max, & set_in_max}, 5}; static struct sensor_device_attribute sensor_dev_attr_in6_input = {{{"in6_input", 0, 292U}, & show_in, 0}, 6}; static struct sensor_device_attribute sensor_dev_attr_in6_min = {{{"in6_min", 0, 420U}, & show_in_min, & set_in_min}, 6}; static struct sensor_device_attribute sensor_dev_attr_in6_max = {{{"in6_max", 0, 420U}, & show_in_max, & set_in_max}, 6}; static struct sensor_device_attribute sensor_dev_attr_in7_input = {{{"in7_input", 0, 292U}, & show_in, 0}, 7}; static struct sensor_device_attribute sensor_dev_attr_in7_min = {{{"in7_min", 0, 420U}, & show_in_min, & set_in_min}, 7}; static struct sensor_device_attribute sensor_dev_attr_in7_max = {{{"in7_max", 0, 420U}, & show_in_max, & set_in_max}, 7}; static struct sensor_device_attribute sensor_dev_attr_in8_input = {{{"in8_input", 0, 292U}, & show_in, 0}, 8}; static ssize_t show_temp(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (unsigned int )data->temp[nr] > 128U ? (int )data->temp[nr] * 1000 + -256000 : (int )data->temp[nr] * 1000); return ((ssize_t )tmp___0); } } static ssize_t show_temp_max(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (unsigned int )data->temp_high[nr] > 128U ? (int )data->temp_high[nr] * 1000 + -256000 : (int )data->temp_high[nr] * 1000); return ((ssize_t )tmp___0); } } static ssize_t show_temp_min(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (unsigned int )data->temp_low[nr] > 128U ? (int )data->temp_low[nr] * 1000 + -256000 : (int )data->temp_low[nr] * 1000); return ((ssize_t )tmp___0); } } static ssize_t set_temp_max(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; void *tmp ; int val ; long tmp___0 ; int tmp___1 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtol(buf, 0, 10U); val = (int )tmp___0; mutex_lock_nested(& data->update_lock, 0U); tmp___1 = SENSORS_LIMIT((long )(val < 0 ? (val + -500) / 1000 : (val + 500) / 1000), -128L, 127L); data->temp_high[nr] = (u8 )tmp___1; it87_write_value(data, (int )((unsigned int )((u8 )(nr + 32)) * 2U), (int )data->temp_high[nr]); mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static ssize_t set_temp_min(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; void *tmp ; int val ; long tmp___0 ; int tmp___1 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtol(buf, 0, 10U); val = (int )tmp___0; mutex_lock_nested(& data->update_lock, 0U); tmp___1 = SENSORS_LIMIT((long )(val < 0 ? (val + -500) / 1000 : (val + 500) / 1000), -128L, 127L); data->temp_low[nr] = (u8 )tmp___1; it87_write_value(data, (int )((unsigned int )((u8 )nr) * 2U + 65U), (int )data->temp_low[nr]); mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static struct sensor_device_attribute sensor_dev_attr_temp1_input = {{{"temp1_input", 0, 292U}, & show_temp, 0}, 0}; static struct sensor_device_attribute sensor_dev_attr_temp1_max = {{{"temp1_max", 0, 420U}, & show_temp_max, & set_temp_max}, 0}; static struct sensor_device_attribute sensor_dev_attr_temp1_min = {{{"temp1_min", 0, 420U}, & show_temp_min, & set_temp_min}, 0}; static struct sensor_device_attribute sensor_dev_attr_temp2_input = {{{"temp2_input", 0, 292U}, & show_temp, 0}, 1}; static struct sensor_device_attribute sensor_dev_attr_temp2_max = {{{"temp2_max", 0, 420U}, & show_temp_max, & set_temp_max}, 1}; static struct sensor_device_attribute sensor_dev_attr_temp2_min = {{{"temp2_min", 0, 420U}, & show_temp_min, & set_temp_min}, 1}; static struct sensor_device_attribute sensor_dev_attr_temp3_input = {{{"temp3_input", 0, 292U}, & show_temp, 0}, 2}; static struct sensor_device_attribute sensor_dev_attr_temp3_max = {{{"temp3_max", 0, 420U}, & show_temp_max, & set_temp_max}, 2}; static struct sensor_device_attribute sensor_dev_attr_temp3_min = {{{"temp3_min", 0, 420U}, & show_temp_min, & set_temp_min}, 2}; static ssize_t show_sensor(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; u8 reg ; int tmp___0 ; int tmp___1 ; int tmp___2 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; reg = data->sensor; if (((int )reg >> nr) & 1) { tmp___0 = sprintf(buf, "3\n"); return ((ssize_t )tmp___0); } else { } if (((int )reg & (8 << nr)) != 0) { tmp___1 = sprintf(buf, "2\n"); return ((ssize_t )tmp___1); } else { } tmp___2 = sprintf(buf, "0\n"); return ((ssize_t )tmp___2); } } static ssize_t set_sensor(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; void *tmp ; int val ; long tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtol(buf, 0, 10U); val = (int )tmp___0; mutex_lock_nested(& data->update_lock, 0U); data->sensor = (u8 )((int )((signed char )data->sensor) & ~ ((int )((signed char )(1 << nr)))); data->sensor = (u8 )((int )((signed char )data->sensor) & ~ ((int )((signed char )(8 << nr)))); if (val == 3) { data->sensor = (u8 )((int )((signed char )data->sensor) | (int )((signed char )(1 << nr))); } else if (val == 2) { data->sensor = (u8 )((int )((signed char )data->sensor) | (int )((signed char )(8 << nr))); } else if (val != 0) { mutex_unlock(& data->update_lock); return (-22L); } else { } it87_write_value(data, 81, (int )data->sensor); mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static struct sensor_device_attribute sensor_dev_attr_temp1_type = {{{"temp1_type", 0, 420U}, & show_sensor, & set_sensor}, 0}; static struct sensor_device_attribute sensor_dev_attr_temp2_type = {{{"temp2_type", 0, 420U}, & show_sensor, & set_sensor}, 1}; static struct sensor_device_attribute sensor_dev_attr_temp3_type = {{{"temp3_type", 0, 420U}, & show_sensor, & set_sensor}, 2}; static ssize_t show_fan(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (unsigned int )data->fan[nr] != 0U ? ((unsigned int )data->fan[nr] != 255U ? 1350000 / ((int )data->fan[nr] << (int )data->fan_div[nr]) : 0) : -1); return ((ssize_t )tmp___0); } } static ssize_t show_fan_min(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (unsigned int )data->fan_min[nr] != 0U ? ((unsigned int )data->fan_min[nr] != 255U ? 1350000 / ((int )data->fan_min[nr] << (int )data->fan_div[nr]) : 0) : -1); return ((ssize_t )tmp___0); } } static ssize_t show_fan_div(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", 1 << (int )data->fan_div[nr]); return ((ssize_t )tmp___0); } } static ssize_t show_pwm_enable(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", ((int )data->fan_main_ctrl >> nr) & 1); return ((ssize_t )tmp___0); } } static ssize_t show_pwm(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (int )data->manual_pwm_ctl[nr]); return ((ssize_t )tmp___0); } } static ssize_t show_pwm_freq(struct device *dev , struct device_attribute *attr , char *buf ) { struct it87_data *data ; struct it87_data *tmp ; int index ; int tmp___0 ; { tmp = it87_update_device(dev); data = tmp; index = ((int )data->fan_ctl >> 4) & 7; tmp___0 = sprintf(buf, "%u\n", pwm_freq[index]); return ((ssize_t )tmp___0); } } static ssize_t set_fan_min(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; void *tmp ; int val ; long tmp___0 ; u8 reg ; int tmp___1 ; u8 tmp___2 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtol(buf, 0, 10U); val = (int )tmp___0; mutex_lock_nested(& data->update_lock, 0U); tmp___1 = it87_read_value(data, 11); reg = (u8 )tmp___1; switch (nr) { case 0: data->fan_div[nr] = (unsigned int )reg & 7U; goto ldv_7899; case 1: data->fan_div[nr] = (unsigned int )((u8 )((int )reg >> 3)) & 7U; goto ldv_7899; case 2: data->fan_div[nr] = ((int )reg & 64) != 0 ? 3U : 1U; goto ldv_7899; } ldv_7899: tmp___2 = FAN_TO_REG((long )val, 1 << (int )data->fan_div[nr]); data->fan_min[nr] = (u16 )tmp___2; it87_write_value(data, (int )IT87_REG_FAN_MIN[nr], (int )((u8 )data->fan_min[nr])); mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static ssize_t set_fan_div(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; void *tmp ; unsigned long val ; unsigned long tmp___0 ; int min ; u8 old ; int tmp___1 ; int tmp___2 ; u8 tmp___3 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtoul(buf, 0, 10U); val = tmp___0; mutex_lock_nested(& data->update_lock, 0U); tmp___1 = it87_read_value(data, 11); old = (u8 )tmp___1; min = (unsigned int )data->fan_min[nr] != 0U ? ((unsigned int )data->fan_min[nr] != 255U ? 1350000 / ((int )data->fan_min[nr] << (int )data->fan_div[nr]) : 0) : -1; switch (nr) { case 0: ; case 1: tmp___2 = DIV_TO_REG((int )val); data->fan_div[nr] = (u8 )tmp___2; goto ldv_7918; case 2: ; if (val <= 7UL) { data->fan_div[nr] = 1U; } else { data->fan_div[nr] = 3U; } } ldv_7918: val = (unsigned long )old & 128UL; val = ((unsigned long )data->fan_div[0] & 7UL) | val; val = (unsigned long )(((int )data->fan_div[1] & 7) << 3) | val; if ((unsigned int )data->fan_div[2] == 3U) { val = val | 64UL; } else { } it87_write_value(data, 11, (int )((u8 )val)); tmp___3 = FAN_TO_REG((long )min, 1 << (int )data->fan_div[nr]); data->fan_min[nr] = (u16 )tmp___3; it87_write_value(data, (int )IT87_REG_FAN_MIN[nr], (int )((u8 )data->fan_min[nr])); mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static ssize_t set_pwm_enable(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; void *tmp ; int val ; long tmp___0 ; int tmp___1 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtol(buf, 0, 10U); val = (int )tmp___0; mutex_lock_nested(& data->update_lock, 0U); if (val == 0) { tmp___1 = it87_read_value(data, 20); it87_write_value(data, 20, (int )((u8 )((int )((signed char )(1 << nr)) | (int )((signed char )tmp___1)))); data->fan_main_ctrl = (u8 )((int )((signed char )data->fan_main_ctrl) & ~ ((int )((signed char )(1 << nr)))); it87_write_value(data, 19, (int )data->fan_main_ctrl); } else if (val == 1) { data->fan_main_ctrl = (u8 )((int )((signed char )data->fan_main_ctrl) | (int )((signed char )(1 << nr))); it87_write_value(data, 19, (int )data->fan_main_ctrl); it87_write_value(data, (int )((unsigned int )((u8 )nr) + 21U), (int )data->manual_pwm_ctl[nr] >> 1); } else { mutex_unlock(& data->update_lock); return (-22L); } mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static ssize_t set_pwm(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; void *tmp ; int val ; long tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtol(buf, 0, 10U); val = (int )tmp___0; if (val < 0 || val > 255) { return (-22L); } else { } mutex_lock_nested(& data->update_lock, 0U); data->manual_pwm_ctl[nr] = (u8 )val; if (((int )data->fan_main_ctrl >> nr) & 1) { it87_write_value(data, (int )((unsigned int )((u8 )nr) + 21U), (int )data->manual_pwm_ctl[nr] >> 1); } else { } mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static ssize_t set_pwm_freq(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct it87_data *data ; void *tmp ; unsigned long val ; unsigned long tmp___0 ; int i ; int tmp___1 ; { tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtoul(buf, 0, 10U); val = tmp___0; i = 0; goto ldv_7956; ldv_7955: ; if ((unsigned long )(((unsigned int )pwm_freq[i] + (unsigned int )pwm_freq[i + 1]) / 2U) < val) { goto ldv_7954; } else { } i = i + 1; ldv_7956: ; if (i <= 6) { goto ldv_7955; } else { } ldv_7954: mutex_lock_nested(& data->update_lock, 0U); tmp___1 = it87_read_value(data, 20); data->fan_ctl = (unsigned int )((u8 )tmp___1) & 143U; data->fan_ctl = (u8 )((int )((signed char )data->fan_ctl) | (int )((signed char )(i << 4))); it87_write_value(data, 20, (int )data->fan_ctl); mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static struct sensor_device_attribute sensor_dev_attr_fan1_input = {{{"fan1_input", 0, 292U}, & show_fan, 0}, 0}; static struct sensor_device_attribute sensor_dev_attr_fan1_min = {{{"fan1_min", 0, 420U}, & show_fan_min, & set_fan_min}, 0}; static struct sensor_device_attribute sensor_dev_attr_fan1_div = {{{"fan1_div", 0, 420U}, & show_fan_div, & set_fan_div}, 0}; static struct sensor_device_attribute sensor_dev_attr_fan2_input = {{{"fan2_input", 0, 292U}, & show_fan, 0}, 1}; static struct sensor_device_attribute sensor_dev_attr_fan2_min = {{{"fan2_min", 0, 420U}, & show_fan_min, & set_fan_min}, 1}; static struct sensor_device_attribute sensor_dev_attr_fan2_div = {{{"fan2_div", 0, 420U}, & show_fan_div, & set_fan_div}, 1}; static struct sensor_device_attribute sensor_dev_attr_fan3_input = {{{"fan3_input", 0, 292U}, & show_fan, 0}, 2}; static struct sensor_device_attribute sensor_dev_attr_fan3_min = {{{"fan3_min", 0, 420U}, & show_fan_min, & set_fan_min}, 2}; static struct sensor_device_attribute sensor_dev_attr_fan3_div = {{{"fan3_div", 0, 420U}, & show_fan_div, & set_fan_div}, 2}; static struct sensor_device_attribute sensor_dev_attr_pwm1_enable = {{{"pwm1_enable", 0, 420U}, & show_pwm_enable, & set_pwm_enable}, 0}; static struct sensor_device_attribute sensor_dev_attr_pwm1 = {{{"pwm1", 0, 420U}, & show_pwm, & set_pwm}, 0}; static struct device_attribute dev_attr_pwm1_freq = {{"pwm1_freq", 0, 420U}, & show_pwm_freq, & set_pwm_freq}; static struct sensor_device_attribute sensor_dev_attr_pwm2_enable = {{{"pwm2_enable", 0, 420U}, & show_pwm_enable, & set_pwm_enable}, 1}; static struct sensor_device_attribute sensor_dev_attr_pwm2 = {{{"pwm2", 0, 420U}, & show_pwm, & set_pwm}, 1}; static struct device_attribute dev_attr_pwm2_freq = {{"pwm2_freq", 0, 292U}, & show_pwm_freq, 0}; static struct sensor_device_attribute sensor_dev_attr_pwm3_enable = {{{"pwm3_enable", 0, 420U}, & show_pwm_enable, & set_pwm_enable}, 2}; static struct sensor_device_attribute sensor_dev_attr_pwm3 = {{{"pwm3", 0, 420U}, & show_pwm, & set_pwm}, 2}; static struct device_attribute dev_attr_pwm3_freq = {{"pwm3_freq", 0, 292U}, & show_pwm_freq, 0}; static ssize_t show_fan16(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (unsigned int )data->fan[nr] != 0U ? ((unsigned int )data->fan[nr] != 65535U ? 1350000 / ((int )data->fan[nr] * 2) : 0) : -1); return ((ssize_t )tmp___0); } } static ssize_t show_fan16_min(struct device *dev , struct device_attribute *attr , char *buf ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%d\n", (unsigned int )data->fan_min[nr] != 0U ? ((unsigned int )data->fan_min[nr] != 65535U ? 1350000 / ((int )data->fan_min[nr] * 2) : 0) : -1); return ((ssize_t )tmp___0); } } static ssize_t set_fan16_min(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct sensor_device_attribute *sensor_attr ; struct device_attribute const *__mptr ; int nr ; struct it87_data *data ; void *tmp ; int val ; long tmp___0 ; { __mptr = (struct device_attribute const *)attr; sensor_attr = (struct sensor_device_attribute *)__mptr; nr = sensor_attr->index; tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtol(buf, 0, 10U); val = (int )tmp___0; mutex_lock_nested(& data->update_lock, 0U); data->fan_min[nr] = FAN16_TO_REG((long )val); it87_write_value(data, (int )IT87_REG_FAN_MIN[nr], (int )((u8 )data->fan_min[nr])); it87_write_value(data, (int )IT87_REG_FANX_MIN[nr], (int )((u8 )((int )data->fan_min[nr] >> 8))); mutex_unlock(& data->update_lock); return ((ssize_t )count); } } static struct sensor_device_attribute sensor_dev_attr_fan1_input16 = {{{"fan1_input", 0, 292U}, & show_fan16, 0}, 0}; static struct sensor_device_attribute sensor_dev_attr_fan1_min16 = {{{"fan1_min", 0, 420U}, & show_fan16_min, & set_fan16_min}, 0}; static struct sensor_device_attribute sensor_dev_attr_fan2_input16 = {{{"fan2_input", 0, 292U}, & show_fan16, 0}, 1}; static struct sensor_device_attribute sensor_dev_attr_fan2_min16 = {{{"fan2_min", 0, 420U}, & show_fan16_min, & set_fan16_min}, 1}; static struct sensor_device_attribute sensor_dev_attr_fan3_input16 = {{{"fan3_input", 0, 292U}, & show_fan16, 0}, 2}; static struct sensor_device_attribute sensor_dev_attr_fan3_min16 = {{{"fan3_min", 0, 420U}, & show_fan16_min, & set_fan16_min}, 2}; static struct sensor_device_attribute sensor_dev_attr_fan4_input16 = {{{"fan4_input", 0, 292U}, & show_fan16, 0}, 3}; static struct sensor_device_attribute sensor_dev_attr_fan4_min16 = {{{"fan4_min", 0, 420U}, & show_fan16_min, & set_fan16_min}, 3}; static struct sensor_device_attribute sensor_dev_attr_fan5_input16 = {{{"fan5_input", 0, 292U}, & show_fan16, 0}, 4}; static struct sensor_device_attribute sensor_dev_attr_fan5_min16 = {{{"fan5_min", 0, 420U}, & show_fan16_min, & set_fan16_min}, 4}; static ssize_t show_alarms(struct device *dev , struct device_attribute *attr , char *buf ) { struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; { tmp = it87_update_device(dev); data = tmp; tmp___0 = sprintf(buf, "%u\n", data->alarms); return ((ssize_t )tmp___0); } } static struct device_attribute dev_attr_alarms = {{"alarms", 0, 292U}, & show_alarms, 0}; static ssize_t show_vrm_reg(struct device *dev , struct device_attribute *attr , char *buf ) { struct it87_data *data ; void *tmp ; int tmp___0 ; { tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = sprintf(buf, "%u\n", (int )data->vrm); return ((ssize_t )tmp___0); } } static ssize_t store_vrm_reg(struct device *dev , struct device_attribute *attr , char const *buf , size_t count ) { struct it87_data *data ; void *tmp ; u32 val ; unsigned long tmp___0 ; { tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = simple_strtoul(buf, 0, 10U); val = (u32 )tmp___0; data->vrm = (u8 )val; return ((ssize_t )count); } } static struct device_attribute dev_attr_vrm = {{"vrm", 0, 420U}, & show_vrm_reg, & store_vrm_reg}; static ssize_t show_vid_reg(struct device *dev , struct device_attribute *attr , char *buf ) { struct it87_data *data ; struct it87_data *tmp ; int tmp___0 ; int tmp___1 ; { tmp = it87_update_device(dev); data = tmp; tmp___0 = vid_from_reg((int )data->vid, (int )data->vrm); tmp___1 = sprintf(buf, "%ld\n", (long )tmp___0); return ((ssize_t )tmp___1); } } static struct device_attribute dev_attr_cpu0_vid = {{"cpu0_vid", 0, 292U}, & show_vid_reg, 0}; static ssize_t show_name(struct device *dev , struct device_attribute *devattr , char *buf ) { struct it87_data *data ; void *tmp ; int tmp___0 ; { tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___0 = sprintf(buf, "%s\n", data->name); return ((ssize_t )tmp___0); } } static struct device_attribute dev_attr_name = {{"name", 0, 292U}, & show_name, 0}; static struct attribute *it87_attributes[40U] = { & sensor_dev_attr_in0_input.dev_attr.attr, & sensor_dev_attr_in1_input.dev_attr.attr, & sensor_dev_attr_in2_input.dev_attr.attr, & sensor_dev_attr_in3_input.dev_attr.attr, & sensor_dev_attr_in4_input.dev_attr.attr, & sensor_dev_attr_in5_input.dev_attr.attr, & sensor_dev_attr_in6_input.dev_attr.attr, & sensor_dev_attr_in7_input.dev_attr.attr, & sensor_dev_attr_in8_input.dev_attr.attr, & sensor_dev_attr_in0_min.dev_attr.attr, & sensor_dev_attr_in1_min.dev_attr.attr, & sensor_dev_attr_in2_min.dev_attr.attr, & sensor_dev_attr_in3_min.dev_attr.attr, & sensor_dev_attr_in4_min.dev_attr.attr, & sensor_dev_attr_in5_min.dev_attr.attr, & sensor_dev_attr_in6_min.dev_attr.attr, & sensor_dev_attr_in7_min.dev_attr.attr, & sensor_dev_attr_in0_max.dev_attr.attr, & sensor_dev_attr_in1_max.dev_attr.attr, & sensor_dev_attr_in2_max.dev_attr.attr, & sensor_dev_attr_in3_max.dev_attr.attr, & sensor_dev_attr_in4_max.dev_attr.attr, & sensor_dev_attr_in5_max.dev_attr.attr, & sensor_dev_attr_in6_max.dev_attr.attr, & sensor_dev_attr_in7_max.dev_attr.attr, & sensor_dev_attr_temp1_input.dev_attr.attr, & sensor_dev_attr_temp2_input.dev_attr.attr, & sensor_dev_attr_temp3_input.dev_attr.attr, & sensor_dev_attr_temp1_max.dev_attr.attr, & sensor_dev_attr_temp2_max.dev_attr.attr, & sensor_dev_attr_temp3_max.dev_attr.attr, & sensor_dev_attr_temp1_min.dev_attr.attr, & sensor_dev_attr_temp2_min.dev_attr.attr, & sensor_dev_attr_temp3_min.dev_attr.attr, & sensor_dev_attr_temp1_type.dev_attr.attr, & sensor_dev_attr_temp2_type.dev_attr.attr, & sensor_dev_attr_temp3_type.dev_attr.attr, & dev_attr_alarms.attr, & dev_attr_name.attr, 0}; static struct attribute_group const it87_group = {0, (struct attribute **)(& it87_attributes)}; static struct attribute *it87_attributes_opt[28U] = { & sensor_dev_attr_fan1_input16.dev_attr.attr, & sensor_dev_attr_fan1_min16.dev_attr.attr, & sensor_dev_attr_fan2_input16.dev_attr.attr, & sensor_dev_attr_fan2_min16.dev_attr.attr, & sensor_dev_attr_fan3_input16.dev_attr.attr, & sensor_dev_attr_fan3_min16.dev_attr.attr, & sensor_dev_attr_fan4_input16.dev_attr.attr, & sensor_dev_attr_fan4_min16.dev_attr.attr, & sensor_dev_attr_fan5_input16.dev_attr.attr, & sensor_dev_attr_fan5_min16.dev_attr.attr, & sensor_dev_attr_fan1_input.dev_attr.attr, & sensor_dev_attr_fan1_min.dev_attr.attr, & sensor_dev_attr_fan1_div.dev_attr.attr, & sensor_dev_attr_fan2_input.dev_attr.attr, & sensor_dev_attr_fan2_min.dev_attr.attr, & sensor_dev_attr_fan2_div.dev_attr.attr, & sensor_dev_attr_fan3_input.dev_attr.attr, & sensor_dev_attr_fan3_min.dev_attr.attr, & sensor_dev_attr_fan3_div.dev_attr.attr, & sensor_dev_attr_pwm1_enable.dev_attr.attr, & sensor_dev_attr_pwm2_enable.dev_attr.attr, & sensor_dev_attr_pwm3_enable.dev_attr.attr, & sensor_dev_attr_pwm1.dev_attr.attr, & sensor_dev_attr_pwm2.dev_attr.attr, & sensor_dev_attr_pwm3.dev_attr.attr, & dev_attr_vrm.attr, & dev_attr_cpu0_vid.attr, 0}; static struct attribute_group const it87_group_opt = {0, (struct attribute **)(& it87_attributes_opt)}; static int it87_find(unsigned short *address , struct it87_sio_data *sio_data ) { int err ; u16 chip_type ; int tmp ; int tmp___0 ; int tmp___1 ; int tmp___2 ; int reg ; int tmp___3 ; { err = -19; superio_enter(); tmp = superio_inw(32); chip_type = (u16 )tmp; switch ((int )chip_type) { case 34565: sio_data->type = it87; goto ldv_8064; case 34578: sio_data->type = it8712; goto ldv_8064; case 34582: ; case 34598: sio_data->type = it8716; goto ldv_8064; case 34584: sio_data->type = it8718; goto ldv_8064; case 65535: ; goto exit; default: printk("<7>it87: Unsupported chip (DEVID=0x%x)\n", (int )chip_type); goto exit; } ldv_8064: superio_select(4); tmp___0 = superio_inb(48); if ((tmp___0 & 1) == 0) { printk("<6>it87: Device not activated, skipping\n"); goto exit; } else { } tmp___1 = superio_inw(96); *address = (unsigned int )((unsigned short )tmp___1) & 65528U; if ((unsigned int )*address == 0U) { printk("<6>it87: Base address not set, skipping\n"); goto exit; } else { } err = 0; tmp___2 = superio_inb(34); printk("<6>it87: Found IT%04xF chip at 0x%x, revision %d\n", (int )chip_type, (int )*address, tmp___2 & 15); if ((unsigned int )chip_type != 34565U) { superio_select(7); if ((unsigned int )chip_type == 3U) { tmp___3 = superio_inb(252); sio_data->vid_value = (u8 )tmp___3; } else { } reg = superio_inb(44); if (reg & 1) { printk("<6>it87: in3 is VCC (+5V)\n"); } else { } if ((reg & 2) != 0) { printk("<6>it87: in7 is VCCH (+5V Stand-By)\n"); } else { } } else { } exit: superio_exit(); return (err); } } static int it87_probe(struct platform_device *pdev___0 ) { struct it87_data *data ; struct resource *res ; struct device *dev ; struct it87_sio_data *sio_data ; int err ; int enable_pwm_interface ; char const *names[4U] ; char const *tmp ; struct resource *tmp___0 ; void *tmp___1 ; int tmp___2 ; int tmp___3 ; struct lock_class_key __key ; long tmp___4 ; long tmp___5 ; { dev = & pdev___0->dev; sio_data = (struct it87_sio_data *)dev->platform_data; err = 0; names[0] = "it87"; names[1] = "it8712"; names[2] = "it8716"; names[3] = "it8718"; res = platform_get_resource(pdev___0, 256U, 0U); tmp___0 = __request_region(& ioport_resource, res->start, 2ULL, "it87"); if ((unsigned long )tmp___0 == (unsigned long )((struct resource *)0)) { tmp = dev_driver_string(dev); printk("<3>%s %s: Failed to request region 0x%lx-0x%lx\n", tmp, (char *)(& dev->bus_id), (unsigned long )res->start, (unsigned long )(res->start + 1ULL)); err = -16; goto ERROR0; } else { } tmp___1 = kzalloc(256UL, 208U); data = (struct it87_data *)tmp___1; if ((unsigned long )data == (unsigned long )((struct it87_data *)0)) { err = -12; goto ERROR1; } else { } data->addr = (unsigned short )res->start; data->type = sio_data->type; data->name = names[(unsigned int )sio_data->type]; tmp___2 = it87_read_value(data, 0); if ((tmp___2 & 128) != 0) { err = -19; goto ERROR2; } else { tmp___3 = it87_read_value(data, 88); if (tmp___3 != 144) { err = -19; goto ERROR2; } else { } } dev_set_drvdata(& pdev___0->dev, (void *)data); __mutex_init(& data->update_lock, "&data->update_lock", & __key); enable_pwm_interface = it87_check_pwm(dev); it87_init_device(pdev___0); err = sysfs_create_group(& dev->kobj, & it87_group); if (err != 0) { goto ERROR2; } else { } if ((unsigned int )data->type == 2U || (unsigned int )data->type == 3U) { if ((int )data->has_fan & 1) { err = device_create_file(dev, & sensor_dev_attr_fan1_input16.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan1_min16.dev_attr); if (err != 0) { goto ERROR4; } else { } } } else { } if (((int )data->has_fan & 2) != 0) { err = device_create_file(dev, & sensor_dev_attr_fan2_input16.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan2_min16.dev_attr); if (err != 0) { goto ERROR4; } else { } } } else { } if (((int )data->has_fan & 4) != 0) { err = device_create_file(dev, & sensor_dev_attr_fan3_input16.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan3_min16.dev_attr); if (err != 0) { goto ERROR4; } else { } } } else { } if (((int )data->has_fan & 8) != 0) { err = device_create_file(dev, & sensor_dev_attr_fan4_input16.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan4_min16.dev_attr); if (err != 0) { goto ERROR4; } else { } } } else { } if (((int )data->has_fan & 16) != 0) { err = device_create_file(dev, & sensor_dev_attr_fan5_input16.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan5_min16.dev_attr); if (err != 0) { goto ERROR4; } else { } } } else { } } else { if ((int )data->has_fan & 1) { err = device_create_file(dev, & sensor_dev_attr_fan1_input.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan1_min.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan1_div.dev_attr); if (err != 0) { goto ERROR4; } else { } } } } else { } if (((int )data->has_fan & 2) != 0) { err = device_create_file(dev, & sensor_dev_attr_fan2_input.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan2_min.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan2_div.dev_attr); if (err != 0) { goto ERROR4; } else { } } } } else { } if (((int )data->has_fan & 4) != 0) { err = device_create_file(dev, & sensor_dev_attr_fan3_input.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan3_min.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_fan3_div.dev_attr); if (err != 0) { goto ERROR4; } else { } } } } else { } } if (enable_pwm_interface != 0) { err = device_create_file(dev, & sensor_dev_attr_pwm1_enable.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_pwm2_enable.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_pwm3_enable.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_pwm1.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_pwm2.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & sensor_dev_attr_pwm3.dev_attr); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & dev_attr_pwm1_freq); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & dev_attr_pwm2_freq); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & dev_attr_pwm3_freq); if (err != 0) { goto ERROR4; } else { } } } } } } } } } } else { } if (((unsigned int )data->type == 1U || (unsigned int )data->type == 2U) || (unsigned int )data->type == 3U) { data->vrm = vid_which_vrm(); data->vid = sio_data->vid_value; err = device_create_file(dev, & dev_attr_vrm); if (err != 0) { goto ERROR4; } else { err = device_create_file(dev, & dev_attr_cpu0_vid); if (err != 0) { goto ERROR4; } else { } } } else { } data->hwmon_dev = hwmon_device_register(dev); tmp___5 = IS_ERR((void const *)data->hwmon_dev); if (tmp___5 != 0L) { tmp___4 = PTR_ERR((void const *)data->hwmon_dev); err = (int )tmp___4; goto ERROR4; } else { } return (0); ERROR4: sysfs_remove_group(& dev->kobj, & it87_group); sysfs_remove_group(& dev->kobj, & it87_group_opt); ERROR2: dev_set_drvdata(& pdev___0->dev, 0); kfree((void const *)data); ERROR1: __release_region(& ioport_resource, res->start, 2ULL); ERROR0: ; return (err); } } static int it87_remove(struct platform_device *pdev___0 ) { struct it87_data *data ; void *tmp ; { tmp = dev_get_drvdata(& pdev___0->dev); data = (struct it87_data *)tmp; hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(& pdev___0->dev.kobj, & it87_group); sysfs_remove_group(& pdev___0->dev.kobj, & it87_group_opt); __release_region(& ioport_resource, (resource_size_t )data->addr, 2ULL); dev_set_drvdata(& pdev___0->dev, 0); kfree((void const *)data); return (0); } } static int it87_read_value(struct it87_data *data , u8 reg ) { unsigned char tmp ; { outb_p((int )reg, (int )data->addr); tmp = inb_p((int )((unsigned int )data->addr + 1U)); return ((int )tmp); } } static void it87_write_value(struct it87_data *data , u8 reg , u8 value ) { { outb_p((int )reg, (int )data->addr); outb_p((int )value, (int )((unsigned int )data->addr + 1U)); return; } } static int it87_check_pwm(struct device *dev ) { struct it87_data *data ; void *tmp ; int tmp___0 ; int tmp___1 ; int i ; u8 pwm[3U] ; int tmp___2 ; char const *tmp___3 ; char const *tmp___4 ; char const *tmp___5 ; char const *tmp___6 ; { tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; tmp___1 = it87_read_value(data, 20); tmp___0 = tmp___1; if ((tmp___0 & 135) == 0) { if (fix_pwm_polarity != 0) { i = 0; goto ldv_8109; ldv_8108: tmp___2 = it87_read_value(data, (int )((unsigned int )((u8 )i) + 21U)); pwm[i] = (u8 )tmp___2; i = i + 1; ldv_8109: ; if (i <= 2) { goto ldv_8108; } else { } if ((int )((signed char )(((int )pwm[0] | (int )pwm[1]) | (int )pwm[2])) >= 0) { tmp___3 = dev_driver_string(dev); printk("<6>%s %s: Reconfiguring PWM to active high polarity\n", tmp___3, (char *)(& dev->bus_id)); it87_write_value(data, 20, (int )((u8 )((int )((signed char )tmp___0) | -121))); i = 0; goto ldv_8112; ldv_8111: it87_write_value(data, (int )((unsigned int )((u8 )i) + 21U), ~ ((int )pwm[i]) & 127); i = i + 1; ldv_8112: ; if (i <= 2) { goto ldv_8111; } else { } return (1); } else { } tmp___4 = dev_driver_string(dev); printk("<6>%s %s: PWM configuration is too broken to be fixed\n", tmp___4, (char *)(& dev->bus_id)); } else { } tmp___5 = dev_driver_string(dev); printk("<6>%s %s: Detected broken BIOS defaults, disabling PWM interface\n", tmp___5, (char *)(& dev->bus_id)); return (0); } else if (fix_pwm_polarity != 0) { tmp___6 = dev_driver_string(dev); printk("<6>%s %s: PWM configuration looks sane, won\'t touch\n", tmp___6, (char *)(& dev->bus_id)); } else { } return (1); } } static void it87_init_device(struct platform_device *pdev___0 ) { struct it87_data *data ; void *tmp ; int tmp___0 ; int i ; int tmp___1 ; char const *tmp___2 ; int tmp___3 ; { tmp = dev_get_drvdata(& pdev___0->dev); data = (struct it87_data *)tmp; i = 0; goto ldv_8121; ldv_8120: data->manual_pwm_ctl[i] = 255U; i = i + 1; ldv_8121: ; if (i <= 2) { goto ldv_8120; } else { } i = 0; goto ldv_8124; ldv_8123: tmp___0 = it87_read_value(data, (int )((unsigned int )((u8 )i) * 2U + 49U)); if (tmp___0 == 255) { it87_write_value(data, (int )((unsigned int )((u8 )i) * 2U + 49U), 0); } else { } i = i + 1; ldv_8124: ; if (i <= 7) { goto ldv_8123; } else { } i = 0; goto ldv_8127; ldv_8126: tmp___0 = it87_read_value(data, (int )((unsigned int )((u8 )(i + 32)) * 2U)); if (tmp___0 == 255) { it87_write_value(data, (int )((unsigned int )((u8 )(i + 32)) * 2U), 127); } else { } i = i + 1; ldv_8127: ; if (i <= 2) { goto ldv_8126; } else { } tmp___0 = it87_read_value(data, 81); if ((tmp___0 & 63) == 0) { tmp___0 = (tmp___0 & 192) | 42; it87_write_value(data, 81, (int )((u8 )tmp___0)); } else { } data->sensor = (u8 )tmp___0; tmp___0 = it87_read_value(data, 80); if ((tmp___0 & 255) == 0) { it87_write_value(data, 80, 255); } else { } tmp___1 = it87_read_value(data, 19); data->fan_main_ctrl = (u8 )tmp___1; if (((int )data->fan_main_ctrl & 112) == 0) { data->fan_main_ctrl = (u8 )((unsigned int )data->fan_main_ctrl | 112U); it87_write_value(data, 19, (int )data->fan_main_ctrl); } else { } data->has_fan = (unsigned int )((u8 )((int )data->fan_main_ctrl >> 4)) & 7U; if ((unsigned int )data->type == 2U || (unsigned int )data->type == 3U) { tmp___0 = it87_read_value(data, 12); if (((~ tmp___0 & 7) & (int )data->has_fan) != 0) { tmp___2 = dev_driver_string(& pdev___0->dev); printk("<7>%s %s: Setting fan1-3 to 16-bit mode\n", tmp___2, (char *)(& pdev___0->dev.bus_id)); it87_write_value(data, 12, (int )((u8 )((int )((signed char )tmp___0) | 7))); } else { } if ((tmp___0 & 16) != 0) { data->has_fan = (u8 )((unsigned int )data->has_fan | 8U); } else { } if ((tmp___0 & 32) != 0) { data->has_fan = (u8 )((unsigned int )data->has_fan | 16U); } else { } } else { } i = 0; goto ldv_8130; ldv_8129: ; if (((int )data->fan_main_ctrl >> i) & 1) { tmp___0 = it87_read_value(data, (int )((unsigned int )((u8 )i) + 21U)); if ((tmp___0 & 128) != 0) { } else { data->manual_pwm_ctl[i] = (u8 )(tmp___0 << 1); } } else { } i = i + 1; ldv_8130: ; if (i <= 2) { goto ldv_8129; } else { } tmp___3 = it87_read_value(data, 0); it87_write_value(data, 0, (int )((u8 )(((int )((signed char )tmp___3) & 54) | (update_vbat != 0 ? 65 : 1)))); return; } } static struct it87_data *it87_update_device(struct device *dev ) { struct it87_data *data ; void *tmp ; int i ; int tmp___0 ; int tmp___1 ; int tmp___2 ; int tmp___3 ; int tmp___4 ; int tmp___5 ; int tmp___6 ; int tmp___7 ; int tmp___8 ; int tmp___9 ; int tmp___10 ; int tmp___11 ; int tmp___12 ; int tmp___13 ; int tmp___14 ; int tmp___15 ; int tmp___16 ; int tmp___17 ; int tmp___18 ; { tmp = dev_get_drvdata(dev); data = (struct it87_data *)tmp; mutex_lock_nested(& data->update_lock, 0U); if (((1 != 0 && 1 != 0) && (long )(data->last_updated + 375UL) - (long )jiffies < 0L) || (int )((signed char )data->valid) == 0) { if (update_vbat != 0) { tmp___0 = it87_read_value(data, 0); it87_write_value(data, 0, (int )((u8 )((int )((signed char )tmp___0) | 64))); } else { } i = 0; goto ldv_8144; ldv_8143: tmp___1 = it87_read_value(data, (int )((unsigned int )((u8 )i) + 32U)); data->in[i] = (u8 )tmp___1; tmp___2 = it87_read_value(data, (int )((unsigned int )((u8 )i) * 2U + 49U)); data->in_min[i] = (u8 )tmp___2; tmp___3 = it87_read_value(data, (int )((unsigned int )((u8 )(i + 24)) * 2U)); data->in_max[i] = (u8 )tmp___3; i = i + 1; ldv_8144: ; if (i <= 7) { goto ldv_8143; } else { } tmp___4 = it87_read_value(data, 40); data->in[8] = (u8 )tmp___4; i = 0; goto ldv_8148; ldv_8147: ; if ((((int )data->has_fan >> i) & 1) == 0) { goto ldv_8146; } else { } tmp___5 = it87_read_value(data, (int )IT87_REG_FAN_MIN[i]); data->fan_min[i] = (u16 )tmp___5; tmp___6 = it87_read_value(data, (int )IT87_REG_FAN[i]); data->fan[i] = (u16 )tmp___6; if ((unsigned int )data->type == 2U || (unsigned int )data->type == 3U) { tmp___7 = it87_read_value(data, (int )IT87_REG_FANX[i]); data->fan[i] = (u16 )((int )((short )data->fan[i]) | (int )((short )(tmp___7 << 8))); tmp___8 = it87_read_value(data, (int )IT87_REG_FANX_MIN[i]); data->fan_min[i] = (u16 )((int )((short )data->fan_min[i]) | (int )((short )(tmp___8 << 8))); } else { } ldv_8146: i = i + 1; ldv_8148: ; if (i <= 4) { goto ldv_8147; } else { } i = 0; goto ldv_8151; ldv_8150: tmp___9 = it87_read_value(data, (int )((unsigned int )((u8 )i) + 41U)); data->temp[i] = (u8 )tmp___9; tmp___10 = it87_read_value(data, (int )((unsigned int )((u8 )(i + 32)) * 2U)); data->temp_high[i] = (u8 )tmp___10; tmp___11 = it87_read_value(data, (int )((unsigned int )((u8 )i) * 2U + 65U)); data->temp_low[i] = (u8 )tmp___11; i = i + 1; ldv_8151: ; if (i <= 2) { goto ldv_8150; } else { } if ((((int )data->has_fan & 7) != 0 && (unsigned int )data->type != 2U) && (unsigned int )data->type != 3U) { i = it87_read_value(data, 11); data->fan_div[0] = (unsigned int )((u8 )i) & 7U; data->fan_div[1] = (unsigned int )((u8 )(i >> 3)) & 7U; data->fan_div[2] = (i & 64) != 0 ? 3U : 1U; } else { } tmp___12 = it87_read_value(data, 1); tmp___13 = it87_read_value(data, 2); tmp___14 = it87_read_value(data, 3); data->alarms = (u32 )((tmp___12 | (tmp___13 << 8)) | (tmp___14 << 16)); tmp___15 = it87_read_value(data, 19); data->fan_main_ctrl = (u8 )tmp___15; tmp___16 = it87_read_value(data, 20); data->fan_ctl = (u8 )tmp___16; tmp___17 = it87_read_value(data, 81); data->sensor = (u8 )tmp___17; if ((unsigned int )data->type == 1U || (unsigned int )data->type == 2U) { tmp___18 = it87_read_value(data, 10); data->vid = (u8 )tmp___18; data->vid = (unsigned int )data->vid & 63U; } else { } data->last_updated = jiffies; data->valid = 1; } else { } mutex_unlock(& data->update_lock); return (data); } } static int it87_device_add(unsigned short address , struct it87_sio_data const *sio_data ) { struct resource res ; int err ; { res.start = (unsigned long long )((int )address + 5); res.end = (unsigned long long )((int )address + 6); res.name = "it87"; res.flags = 256UL; res.parent = 0; res.sibling = 0; res.child = 0; pdev = platform_device_alloc("it87", (int )address); if ((unsigned long )pdev == (unsigned long )((struct platform_device *)0)) { err = -12; printk("<3>it87: Device allocation failed\n"); goto exit; } else { } err = platform_device_add_resources(pdev, & res, 1U); if (err != 0) { printk("<3>it87: Device resource addition failed (%d)\n", err); goto exit_device_put; } else { } err = platform_device_add_data(pdev, (void const *)sio_data, 8UL); if (err != 0) { printk("<3>it87: Platform data allocation failed\n"); goto exit_device_put; } else { } err = platform_device_add(pdev); if (err != 0) { printk("<3>it87: Device addition failed (%d)\n", err); goto exit_device_put; } else { } return (0); exit_device_put: platform_device_put(pdev); exit: ; return (err); } } static int sm_it87_init(void) { int err ; unsigned short isa_address ; struct it87_sio_data sio_data ; { isa_address = 0U; err = it87_find(& isa_address, & sio_data); if (err != 0) { return (err); } else { } err = platform_driver_register(& it87_driver); if (err != 0) { return (err); } else { } err = it87_device_add((int )isa_address, (struct it87_sio_data const *)(& sio_data)); if (err != 0) { platform_driver_unregister(& it87_driver); return (err); } else { } return (0); } } static void sm_it87_exit(void) { { platform_device_unregister(pdev); platform_driver_unregister(& it87_driver); return; } } void ldv_check_final_state(void) ; extern void ldv_check_return_value(int ) ; extern void ldv_check_return_value_probe(int ) ; extern void ldv_initialize(void) ; extern void ldv_handler_precall(void) ; extern int nondet_int(void) ; int LDV_IN_INTERRUPT ; int main(void) { struct platform_device *var_group1 ; int res_it87_probe_40 ; int ldv_s_it87_driver_platform_driver ; int tmp ; int tmp___0 ; int tmp___1 ; { ldv_s_it87_driver_platform_driver = 0; LDV_IN_INTERRUPT = 1; ldv_initialize(); ldv_handler_precall(); tmp = sm_it87_init(); if (tmp != 0) { goto ldv_final; } else { } goto ldv_8225; ldv_8224: tmp___0 = nondet_int(); switch (tmp___0) { case 0: ; if (ldv_s_it87_driver_platform_driver == 0) { res_it87_probe_40 = it87_probe(var_group1); ldv_check_return_value(res_it87_probe_40); ldv_check_return_value_probe(res_it87_probe_40); if (res_it87_probe_40 != 0) { goto ldv_module_exit; } else { } ldv_s_it87_driver_platform_driver = ldv_s_it87_driver_platform_driver + 1; } else { } goto ldv_8221; case 1: ; if (ldv_s_it87_driver_platform_driver == 1) { ldv_handler_precall(); it87_remove(var_group1); ldv_s_it87_driver_platform_driver = 0; } else { } goto ldv_8221; default: ; goto ldv_8221; } ldv_8221: ; ldv_8225: tmp___1 = nondet_int(); if (tmp___1 != 0 || ldv_s_it87_driver_platform_driver != 0) { goto ldv_8224; } else { } ldv_module_exit: ldv_handler_precall(); sm_it87_exit(); ldv_final: ldv_check_final_state(); return 0; } } __inline static void ldv_error(void) { { LDV_ERROR: {reach_error();abort();} } } extern int ldv_undef_int(void) ; long ldv__builtin_expect(long exp , long c ) { { return (exp); } } int ldv_module_refcounter = 1; void ldv_module_get(struct module *module ) { { if (module) { ldv_module_refcounter = ldv_module_refcounter + 1; } else { } return; } } int ldv_try_module_get(struct module *module ) { int module_get_succeeded ; { if (module) { module_get_succeeded = ldv_undef_int(); if (module_get_succeeded == 1) { ldv_module_refcounter = ldv_module_refcounter + 1; return (1); } else { return (0); } } else { } return (0); } } void ldv_module_put(struct module *module ) { { if (module) { if (ldv_module_refcounter > 1) { } else { ldv_error(); } ldv_module_refcounter = ldv_module_refcounter - 1; } else { } return; } } void ldv_module_put_and_exit(void) { { ldv_module_put((struct module *)1); LDV_STOP: goto LDV_STOP; } } unsigned int ldv_module_refcount(void) { { return (ldv_module_refcounter - 1); } } void ldv_check_final_state(void) { { if (ldv_module_refcounter == 1) { } else { ldv_error(); } return; } }