linux/drivers/macintosh/windfarm_core.c
<<
ver_nt.len

3.21s5l.17"v2.6.33" > v2.6.33 3.21s5l.17"v2.6.33" > v2.6.33 3.21s5l.17"v2.6..17"value="v3.2.14" > v3.2.14 v2.6.32.50 v2.6.32.40 v2.6.32.30 v2.6.32.20 v3.2.10 v3.2.10 v3.2.10 n> n> 327l7 n> n6u8 n 325l7 u u u 3.21s52.17"v2.6.33" > v2.6.33 3221s5l.17"v2.6..17"2alue="v3.2.14" > v3.2.14 32215l.17"v2.6..17"2ale="v3.2.14" > v3.2.14 n> u> u > v2.6.33 v3.0.16 u6l2 u u u

   1 /a> spa3 class="comment">/* /spa33.   2 /a> spa3 class="comment"> * Windfarm PowerMac thermal control. Core /spa33.   3 /a> spa3 class="comment"> * /spa33.   4 /a> spa3 class="comment"> * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp. /spa33.   5 /a> spa3 class="comment"> *                    <benh@kernel.crashing.org> /spa33.   6 /a> spa3 class="comment"> * /spa33.   7 /a> spa3 class="comment"> * Released under the term of the GNU GPLptio /spa33.   8 /a> spa3 class="comment"> * /spa33.   9 /a> spa3 class="comment"> * This core code tracks the list of sensors & controls, register /spa33.  ue="a> spa3 class="comment"> * clients, and holds the kernel thread used for control. /spa33.  11 /a> spa3 class="comment"> * /spa33.  12 /a> spa3 class="comment"> * TODO: /spa33.  13 /a> spa3 class="comment"> * /spa33.  14 /a> spa3 class="comment"> * Add some informa
  v2about sensor/control typ3 and data forma
 to /spa33.  15 /a> spa3 class="comment"> * sensors/controls, and have the sysfs attribute stuff be moved /spa33.  16 /a> spa3 class="comment"> * generically here instead of hard coded in the platform specific /spa33.  17 /a> spa3 class="comment"> * driver as it us currently /spa33.  18 /a> spa3 class="comment"> * /spa33.  19 /a> spa3 class="comment"> * This however requires solving some annoying lifetime issues with /spa33.  2e="a> spa3 class="comment"> * sysfs which doesn't seem to have lifetime rules for struct attribute, /spa33.  21 /a> spa3 class="comment"> * I may have to create full features kobjects for every sensor/control /spa33.  22 /a> spa3 class="comment"> * instead which is a bit of a3 overkill imho /spa33.  23 /a> spa3 class="comment"> */ /spa33.  24 /a>.  25 /a>#include <linux/typ3s.h /a>>.  26 /a>#include <linux/errno.h /a>>.  27 /a>#include <linux/kernel.h /a>>.  28 /a>#include <linux/slab.h /a>>.  29 /a>#include <linux/init.h /a>>.  30 /a>#include <linux/spinlock.h /a>>.  31 /a>#include <linux/kthread.h /a>>.  32 /a>#include <linux/jiffi3s.h /a>>.  33 /a>#include <linux/reboot.h /a>>.  34 /a>#include <linux/device.h /a>>.  35 /a>#include <linux/platform_device.h /a>>.  36 /a>#include <linux/mutex.h /a>>.  37 /a>#include <linux/freezer.h /a>>.  38 /a>.  39 /a>#include <asm/prom.h /a>>.  40 /a>.  41 /a>#include "windfarm.h /a>".  42 /a>.  43 /a>#define  a href="+code=VERSION" class="sref">VERSION /a>  spa3 class="string">"0.2"  44 /a>.  45 /a>#undef  a href="+code=DEBUG" class="sref">DEBUG /a>.  46 /a>.  47 /a>#ifdef  a href="+code=DEBUG" class="sref">DEBUG /a>.  48 /a>#define  a href="+code=DBG" class="sref">DBG /a>( a href="+code=args" class="sref">args /a>...)     a href="+code=printk" class="sref">printk /a>( a href="+code=args" class="sref">args /a>).  49 /a>#else.  50 /a>#define  a href="+code=DBG" class="sref">DBG /a>( a href="+code=args" class="sref">args /a>...)    do { } while(0).  51 /a>#endif.  52 /a>.  53 /a>static  a href="+code=LIST_HEAD" class="sref">LIST_HEAD /a>( a href="+code=wf_controls" class="sref">wf_controls /a>);.  54 /a>static  a href="+code=LIST_HEAD" class="sref">LIST_HEAD /a>( a href="+code=wf_sensors" class="sref">wf_sensors /a>);.  55 /a>static  a href="+code=DEFINE_MUTEX" class="sref">DEFINE_MUTEX /a>( a href="+code=wf_lock" class="sref">wf_lock /a>);.  56 /a>static  a href="+code=BLOCKING_NOTIFIER_HEAD" class="sref">BLOCKING_NOTIFIER_HEAD /a>( a href="+code=wf_client_list" class="sref">wf_client_list /a>);.  57 /a>static int  a href="+code=wf_client_count" class="sref">wf_client_count /a>;.  58 /a>static unsigned int  a href="+code=wf_overtemp" class="sref">wf_overtemp /a>;.  59 /a>static unsigned int  a href="+code=wf_overtemp_counter" class="sref">wf_overtemp_counter /a>;.  60 /a>struct  a href="+code=task_struct" class="sref">task_struct /a> * a href="+code=wf_thread" class="sref">wf_thread /a>;.  61 /a>.  62 /a>static struct  a href="+code=platform_device" class="sref">platform_device /a>  a href="+code=wf_platform_device" class="sref">wf_platform_device /a> = {.  63 /a>        . a href="+code=nam3" class="sref">nam3 /a>   =  spa3 class="string">"windfarm"  64 /a>};.  65 /a>.  66 /a> spa3 class="comment">/* /spa33.  67 /a> spa3 class="comment"> * Utilities & tick thread /spa33.  68 /a> spa3 class="comment"> */ /spa33.  69 /a>.  70 /a>static  a href="+code=inline" class="sref">inline /a> void  a href="+code=wf_notify" class="sref">wf_notify /a>(int  a href="+code=event" class="sref">event /a>, void * a href="+code=param" class="sref">param /a>).  71 /a>{.  72 /a>         a href="+code=blocking_notifier_call_chain" class="sref">blocking_notifier_call_chain /a>(& a href="+code=wf_client_list" class="sref">wf_client_list /a>,  a href="+code=event" class="sref">event /a>,  a href="+code=param" class="sref">param /a>);.  73 /a>}.  74 /a>.  75 /a>int  a href="+code=wf_critical_overtemp" class="sref">wf_critical_overtemp /a>(void).  76 /a>{.  77 /a>        static char *  a href="+code=critical_overtemp_path" class="sref">critical_overtemp_path /a> =  spa3 class="string">"/sbin/critical_overtemp"  78 /a>        char * a href="+code=argv" class="sref">argv /a>[] = {  a href="+code=critical_overtemp_path" class="sref">critical_overtemp_path /a>,  a href="+code=NULL" class="sref">NULL /a> };.  79 /a>        static char * a href="+code=envp" class="sref">envp /a>[] = {  spa3 class="string">"HOME=/"  80 /a>                                 spa3 class="string">"TERM=linux"  81 /a>                                 spa3 class="string">"PATH=/sbin:/usr/sbin:/bin:/usr/bin"  82 /a>                                 a href="+code=NULL" class="sref">NULL /a> };.  83 /a>.  84 /a>        return  a href="+code=call_usermodehelper" class="sref">call_usermodehelper /a>( a href="+code=critical_overtemp_path" class="sref">critical_overtemp_path /a>,.  85 /a>                                    a href="+code=argv" class="sref">argv /a>,  a href="+code=envp" class="sref">envp /a>,  a href="+code=UMH_WAIT_EXEC" class="sref">UMH_WAIT_EXEC /a>);.  86 /a>}.  87 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_critical_overtemp" class="sref">wf_critical_overtemp /a>);.  88 /a>.  89 /a>static int  a href="+code=wf_thread_func" class="sref">wf_thread_func /a>(void * a href="+code=data" class="sref">data /a>).  90 /a>{.  91 /a>        unsigned long  a href="+code=next" class="sref">next /a>,  a href="+code=delay" class="sref">delay /a>;.  92 /a>.  93 /a>         a href="+code=next" class="sref">next /a> =  a href="+code=jiffi3s" class="sref">jiffi3s /a>;.  94 /a>.  95 /a>         a href="+code=DBG" class="sref">DBG /a>( spa3 class="string">"wf: thread started\n"  96 /a>.  97 /a>         a href="+code=set_freezable" class="sref">set_freezable /a>();.  98 /a>        while (! a href="+code=kthread_should_stop" class="sref">kthread_should_stop /a>()) {.  99 /a>                 a href="+code=try_to_freeze" class="sref">try_to_freeze /a>();. 100 /a>. 101 /a>                if ( a href="+code=time_after_eq" class="sref">time_after_eq /a>( a href="+code=jiffi3s" class="sref">jiffi3s /a>,  a href="+code=next" class="sref">next /a>)) {. 102 /a>                         a href="+code=wf_notify" class="sref">wf_notify /a>( a href="+code=WF_EVENT_TICK" class="sref">WF_EVENT_TICK /a>,  a href="+code=NULL" class="sref">NULL /a>);. 103 /a>                        if ( a href="+code=wf_overtemp" class="sref">wf_overtemp /a>) {. 104 /a>                                 a href="+code=wf_overtemp_counter" class="sref">wf_overtemp_counter /a>++;. 105 /a>                                 spa3 class="comment">/* 10 seconds overtemp, notify userland */ /spa33. 106 /a>                                if ( a href="+code=wf_overtemp_counter" class="sref">wf_overtemp_counter /a> > 10). 107 /a>                                         a href="+code=wf_critical_overtemp" class="sref">wf_critical_overtemp /a>();. 108 /a>                                 spa3 class="comment">/* 30 seconds, shutdown */ /spa33. 109 /a>                                if ( a href="+code=wf_overtemp_counter" class="sref">wf_overtemp_counter /a> > 30) {. 110 /a>                                         a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_ERR" class="sref">KERN_ERR /a>  spa3 class="string">"windfarm: Overtemp " 111 /a>                                                spa3 class="string">"for more tha3 30" 112 /a>                                                spa3 class="string">" seconds, shutting down\n" 113 /a>                                         a href="+code=machine_power_off" class="sref">machine_power_off /a>();. 114 /a>                                }. 115 /a>                        }. 116 /a>                         a href="+code=next" class="sref">next /a> +=  a href="+code=HZ" class="sref">HZ /a>;. 117 /a>                }. 118 /a>. 119 /a>                 a href="+code=delay" class="sref">delay /a> =  a href="+code=next" class="sref">next /a> -  a href="+code=jiffi3s" class="sref">jiffi3s /a>;. 120 /a>                if ( a href="+code=delay" class="sref">delay /a> <=  a href="+code=HZ" class="sref">HZ /a>). 121 /a>                         a href="+code=schedule_timeout_interruptible" class="sref">schedule_timeout_interruptible /a>( a href="+code=delay" class="sref">delay /a>);. 122 /a>        }. 123 /a>. 124 /a>         a href="+code=DBG" class="sref">DBG /a>( spa3 class="string">"wf: thread stopped\n" 125 /a>. 126 /a>        return 0;. 127 /a>}. 128 /a>. 129 /a>static void  a href="+code=wf_start_thread" class="sref">wf_start_thread /a>(void). 130 /a>{. 131 /a>         a href="+code=wf_thread" class="sref">wf_thread /a> =  a href="+code=kthread_run" class="sref">kthread_run /a>( a href="+code=wf_thread_func" class="sref">wf_thread_func /a>,  a href="+code=NULL" class="sref">NULL /a>,  spa3 class="string">"kwindfarm" 132 /a>        if ( a href="+code=IS_ERR" class="sref">IS_ERR /a>( a href="+code=wf_thread" class="sref">wf_thread /a>)) {. 133 /a>                 a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_ERR" class="sref">KERN_ERR /a>  spa3 class="string">"windfarm: failed to create thread,err %ld\n" 134 /a>                        a href="+code=PTR_ERR" class="sref">PTR_ERR /a>( a href="+code=wf_thread" class="sref">wf_thread /a>));. 135 /a>                 a href="+code=wf_thread" class="sref">wf_thread /a> =  a href="+code=NULL" class="sref">NULL /a>;. 136 /a>        }. 137 /a>}. 138 /a>. 139 /a>. 140 /a>static void  a href="+code=wf_stop_thread" class="sref">wf_stop_thread /a>(void). 141 /a>{. 142 /a>        if ( a href="+code=wf_thread" class="sref">wf_thread /a>). 143 /a>                 a href="+code=kthread_stop" class="sref">kthread_stop /a>( a href="+code=wf_thread" class="sref">wf_thread /a>);. 144 /a>         a href="+code=wf_thread" class="sref">wf_thread /a> =  a href="+code=NULL" class="sref">NULL /a>;. 145 /a>}. 146 /a>. 147 /a> spa3 class="comment">/* /spa33. 148 /a> spa3 class="comment"> * Controls /spa33. 149 /a> spa3 class="comment"> */ /spa33. 150 /a>. 151 /a>static void  a href="+code=wf_control_release" class="sref">wf_control_release /a>(struct  a href="+code=kref" class="sref">kref /a> * a href="+code=kref" class="sref">kref /a>). 152 /a>{. 153 /a>        struct  a href="+code=wf_control" class="sref">wf_control /a> * a href="+code=ct" class="sref">ct /a> =  a href="+code=container_of" class="sref">container_of /a>( a href="+code=kref" class="sref">kref /a>, struct  a href="+code=wf_control" class="sref">wf_control /a>,  a href="+code=ref" class="sref">ref /a>);. 154 /a>. 155 /a>         a href="+code=DBG" class="sref">DBG /a>( spa3 class="string">"wf: Deleting control %s\n"ct /a>-> a href="+code=nam3" class="sref">nam3 /a>);. 156 /a>. 157 /a>        if ( a href="+code=ct" class="sref">ct /a>-> a href="+code=ops" class="sref">ops /a> &&  a href="+code=ct" class="sref">ct /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=release" class="sref">release /a>). 158 /a>                 a href="+code=ct" class="sref">ct /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=release" class="sref">release /a>( a href="+code=ct" class="sref">ct /a>);. 159 /a>        else. 160 /a>                 a href="+code=kfree" class="sref">kfree /a>( a href="+code=ct" class="sref">ct /a>);. 161 /a>}. 162 /a>. 163 /a>static  a href="+code=ssize_t" class="sref">ssize_t /a>  a href="+code=wf_show_control" class="sref">wf_show_control /a>(struct  a href="+code=device" class="sref">device /a> * a href="+code=dev" class="sref">dev /a>,. 164 /a>                               struct  a href="+code=device_attribute" class="sref">device_attribute /a> * a href="+code=attr" class="sref">attr /a>, char * a href="+code=buf" class="sref">buf /a>). 165 /a>{. 166 /a>        struct  a href="+code=wf_control" class="sref">wf_control /a> * a href="+code=ctrl" class="sref">ctrl /a> =  a href="+code=container_of" class="sref">container_of /a>( a href="+code=attr" class="sref">attr /a>, struct  a href="+code=wf_control" class="sref">wf_control /a>,  a href="+code=attr" class="sref">attr /a>);. 167 /a>        const char * a href="+code=typ3str" class="sref">typ3str /a>;. 168 /a>         a href="+code=s32" class="sref">s32 /a>  a href="+code=val" class="sref">val /a> = 0;. 169 /a>        int  a href="+code=err" class="sref">err /a>;. 170 /a>. 171 /a>         a href="+code=err" class="sref">err /a> =  a href="+code=ctrl" class="sref">ctrl /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=get_.6.33" class="sref">get_.6.33 /a>( a href="+code=ctrl" class="sref">ctrl /a>, & a href="+code=val" class="sref">val /a>);. 172 /a>        if ( a href="+code=err" class="sref">err /a> < 0) {. 173 /a>                if ( a href="+code=err" class="sref">err /a> == - a href="+code=EFAULT" class="sref">EFAULT /a>). 174 /a>                        return  a href="+code=sprintf" class="sref">sprintf /a>( a href="+code=buf" class="sref">buf /a>,  spa3 class="string">"<HW FAULT>\n" 175 /a>                return  a href="+code=err" class="sref">err /a>;. 176 /a>        }. 177 /a>        switch( a href="+code=ctrl" class="sref">ctrl /a>-> a href="+code=typ3" class="sref">typ3 /a>) {. 178 /a>        case  a href="+code=WF_CONTROL_RPM_FAN" class="sref">WF_CONTROL_RPM_FAN /a>:. 179 /a>                 a href="+code=typ3str" class="sref">typ3str /a> =  spa3 class="string">" RPM" 180 /a>                break;. 181 /a>        case  a href="+code=WF_CONTROL_PWM_FAN" class="sref">WF_CONTROL_PWM_FAN /a>:. 182 /a>                 a href="+code=typ3str" class="sref">typ3str /a> =  spa3 class="string">" %" 183 /a>                break;. 184 /a>        default:. 185 /a>                 a href="+code=typ3str" class="sref">typ3str /a> =  spa3 class="string">"" 186 /a>        }. 187 /a>        return  a href="+code=sprintf" class="sref">sprintf /a>( a href="+code=buf" class="sref">buf /a>,  spa3 class="string">"%d%s\n"val /a>,  a href="+code=typ3str" class="sref">typ3str /a>);. 188 /a>}. 189 /a>. 19e="a> spa3 class="comment">/* This is really only for debugging... */ /spa33. 191 /a>static  a href="+code=ssize_t" class="sref">ssize_t /a>  a href="+code=wf_store_control" class="sref">wf_store_control /a>(struct  a href="+code=device" class="sref">device /a> * a href="+code=dev" class="sref">dev /a>,. 192 /a>                                struct  a href="+code=device_attribute" class="sref">device_attribute /a> * a href="+code=attr" class="sref">attr /a>,. 193 /a>                                const char * a href="+code=buf" class="sref">buf /a>,  a href="+code=size_t" class="sref">size_t /a>  a href="+code=count" class="sref">count /a>). 194 /a>{. 195 /a>        struct  a href="+code=wf_control" class="sref">wf_control /a> * a href="+code=ctrl" class="sref">ctrl /a> =  a href="+code=container_of" class="sref">container_of /a>( a href="+code=attr" class="sref">attr /a>, struct  a href="+code=wf_control" class="sref">wf_control /a>,  a href="+code=attr" class="sref">attr /a>);. 196 /a>        int  a href="+code=val" class="sref">val /a>;. 197 /a>        int  a href="+code=err" class="sref">err /a>;. 198 /a>        char * a href="+code=endp" class="sref">endp /a>;. 199 /a>. 200 /a>         a href="+code=val" class="sref">val /a> =  a href="+code=simple_strtoul" class="sref">simple_strtoul /a>( a href="+code=buf" class="sref">buf /a>, & a href="+code=endp" class="sref">endp /a>, 0);. 201 /a>        while ( a href="+code=endp" class="sref">endp /a> <  a href="+code=buf" class="sref">buf /a> +  a href="+code=count" class="sref">count /a> && (* a href="+code=endp" class="sref">endp /a> ==  spa3 class="string">' ' /spa33 || * a href="+code=endp" class="sref">endp /a> ==  spa3 class="string">'\n' /spa33)). 202 /a>                ++ a href="+code=endp" class="sref">endp /a>;. 203 /a>        if ( a href="+code=endp" class="sref">endp /a> -  a href="+code=buf" class="sref">buf /a> <  a href="+code=count" class="sref">count /a>). 204 /a>                return - a href="+code=EINVAL" class="sref">EINVAL /a>;. 205 /a>         a href="+code=err" class="sref">err /a> =  a href="+code=ctrl" class="sref">ctrl /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=set_.6.33" class="sref">set_.6.33 /a>( a href="+code=ctrl" class="sref">ctrl /a>,  a href="+code=val" class="sref">val /a>);. 206 /a>        if ( a href="+code=err" class="sref">err /a> < 0). 207 /a>                return  a href="+code=err" class="sref">err /a>;. 208 /a>        return  a href="+code=count" class="sref">count /a>;. 209 /a>}. 210 /a>. 211 /a>int  a href="+code=wf_register_control" class="sref">wf_register_control /a>(struct  a href="+code=wf_control" class="sref">wf_control /a> * a href="+code=new_ct" class="sref">new_ct /a>). 212 /a>{. 213 /a>        struct  a href="+code=wf_control" class="sref">wf_control /a> * a href="+code=ct" class="sref">ct /a>;. 214 /a>. 215 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 216 /a>         a href="+code=list_for_each_entry" class="sref">list_for_each_entry /a>( a href="+code=ct" class="sref">ct /a>, & a href="+code=wf_controls" class="sref">wf_controls /a>,  a href="+code=link" class="sref">link /a>) {. 217 /a>                if (! a href="+code=strcmp" class="sref">strcmp /a>( a href="+code=ct" class="sref">ct /a>-> a href="+code=nam3" class="sref">nam3 /a>,  a href="+code=new_ct" class="sref">new_ct /a>-> a href="+code=nam3" class="sref">nam3 /a>)) {. 218 /a>                         a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_WARNING" class="sref">KERN_WARNING /a>  spa3 class="string">"windfarm: trying to register" 219 /a>                                spa3 class="string">" duplicate control %s\n"ct /a>-> a href="+code=nam3" class="sref">nam3 /a>);. 220 /a>                         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 221 /a>                        return - a href="+code=EEXIST" class="sref">EEXIST /a>;. 222 /a>                }. 223 /a>        }. 224 /a>         a href="+code=kref_init" class="sref">kref_init /a>(& a href="+code=new_ct" class="sref">new_ct /a>-> a href="+code=ref" class="sref">ref /a>);. 225 /a>         a href="+code=list_add" class="sref">list_add /a>(& a href="+code=new_ct" class="sref">new_ct /a>-> a href="+code=link" class="sref">link /a>, & a href="+code=wf_controls" class="sref">wf_controls /a>);. 226 /a>. 227 /a>         a href="+code=sysfs_attr_init" class="sref">sysfs_attr_init /a>(& a href="+code=new_ct" class="sref">new_ct /a>-> a href="+code=attr" class="sref">attr /a>. a href="+code=attr" class="sref">attr /a>);. 228 /a>         a href="+code=new_ct" class="sref">new_ct /a>-> a href="+code=attr" class="sref">attr /a>. a href="+code=attr" class="sref">attr /a>. a href="+code=nam3" class="sref">nam3 /a> =  a href="+code=new_ct" class="sref">new_ct /a>-> a href="+code=nam3" class="sref">nam3 /a>;. 229 /a>         a href="+code=new_ct" class="sref">new_ct /a>-> a href="+code=attr" class="sref">attr /a>. a href="+code=attr" class="sref">attr /a>. a href="+code=mode" class="sref">mode /a> = 0644;. 230 /a>         a href="+code=new_ct" class="sref">new_ct /a>-> a href="+code=attr" class="sref">attr /a>. a href="+code=show" class="sref">show /a> =  a href="+code=wf_show_control" class="sref">wf_show_control /a>;. 231 /a>         a href="+code=new_ct" class="sref">new_ct /a>-> a href="+code=attr" class="sref">attr /a>. a href="+code=store" class="sref">store /a> =  a href="+code=wf_store_control" class="sref">wf_store_control /a>;. 232 /a>        if ( a href="+code=device_create_file" class="sref">device_create_file /a>(& a href="+code=wf_platform_device" class="sref">wf_platform_device /a>. a href="+code=dev" class="sref">dev /a>, & a href="+code=new_ct" class="sref">new_ct /a>-> a href="+code=attr" class="sref">attr /a>)). 233 /a>                 a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_WARNING" class="sref">KERN_WARNING /a>  spa3 class="string">"windfarm: device_create_file failed" 234 /a>                         spa3 class="string">" for %s\n"new_ct /a>-> a href="+code=nam3" class="sref">nam3 /a>);. 235 /a>                 spa3 class="comment">/* the subsystem still does useful work without the file */ /spa33. 236 /a>. 237 /a>         a href="+code=DBG" class="sref">DBG /a>( spa3 class="string">"wf: Registered control %s\n"new_ct /a>-> a href="+code=nam3" class="sref">nam3 /a>);. 238 /a>. 239 /a>         a href="+code=wf_notify" class="sref">wf_notify /a>( a href="+code=WF_EVENT_NEW_CONTROL" class="sref">WF_EVENT_NEW_CONTROL /a>,  a href="+code=new_ct" class="sref">new_ct /a>);. 240 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 241 /a>. 242 /a>        return 0;. 243 /a>}. 244 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_register_control" class="sref">wf_register_control /a>);. 245 /a>. 246 /a>void  a href="+code=wf_unregister_control" class="sref">wf_unregister_control /a>(struct  a href="+code=wf_control" class="sref">wf_control /a> * a href="+code=ct" class="sref">ct /a>). 247 /a>{. 248 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 249 /a>         a href="+code=list_del" class="sref">list_del /a>(& a href="+code=ct" class="sref">ct /a>-> a href="+code=link" class="sref">link /a>);. 250 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 251 /a>. 252 /a>         a href="+code=DBG" class="sref">DBG /a>( spa3 class="string">"wf: Unregistered control %s\n"ct /a>-> a href="+code=nam3" class="sref">nam3 /a>);. 253 /a>. 254 /a>         a href="+code=kref_put" class="sref">kref_put /a>(& a href="+code=ct" class="sref">ct /a>-> a href="+code=ref" class="sref">ref /a>,  a href="+code=wf_control_release" class="sref">wf_control_release /a>);. 255 /a>}. 256 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_unregister_control" class="sref">wf_unregister_control /a>);. 257 /a>. 258 /a>struct  a href="+code=wf_control" class="sref">wf_control /a> *  a href="+code=wf_find_control" class="sref">wf_find_control /a>(const char * a href="+code=nam3" class="sref">nam3 /a>). 259 /a>{. 260 /a>        struct  a href="+code=wf_control" class="sref">wf_control /a> * a href="+code=ct" class="sref">ct /a>;. 261 /a>. 262 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 263 /a>         a href="+code=list_for_each_entry" class="sref">list_for_each_entry /a>( a href="+code=ct" class="sref">ct /a>, & a href="+code=wf_controls" class="sref">wf_controls /a>,  a href="+code=link" class="sref">link /a>) {. 264 /a>                if (! a href="+code=strcmp" class="sref">strcmp /a>( a href="+code=ct" class="sref">ct /a>-> a href="+code=nam3" class="sref">nam3 /a>,  a href="+code=nam3" class="sref">nam3 /a>)) {. 265 /a>                        if ( a href="+code=wf_get_control" class="sref">wf_get_control /a>( a href="+code=ct" class="sref">ct /a>)). 266 /a>                                 a href="+code=ct" class="sref">ct /a> =  a href="+code=NULL" class="sref">NULL /a>;. 267 /a>                         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 268 /a>                        return  a href="+code=ct" class="sref">ct /a>;. 269 /a>                }. 270 /a>        }. 271 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 272 /a>        return  a href="+code=NULL" class="sref">NULL /a>;. 273 /a>}. 274 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_find_control" class="sref">wf_find_control /a>);. 275 /a>. 276 /a>int  a href="+code=wf_get_control" class="sref">wf_get_control /a>(struct  a href="+code=wf_control" class="sref">wf_control /a> * a href="+code=ct" class="sref">ct /a>). 277 /a>{. 278 /a>        if (! a href="+code=try_module_get" class="sref">try_module_get /a>( a href="+code=ct" class="sref">ct /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=owner" class="sref">owner /a>)). 279 /a>                return - a href="+code=ENODEV" class="sref">ENODEV /a>;. 280 /a>         a href="+code=kref_get" class="sref">kref_get /a>(& a href="+code=ct" class="sref">ct /a>-> a href="+code=ref" class="sref">ref /a>);. 281 /a>        return 0;. 282 /a>}. 283 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_get_control" class="sref">wf_get_control /a>);. 284 /a>. 285 /a>void  a href="+code=wf_put_control" class="sref">wf_put_control /a>(struct  a href="+code=wf_control" class="sref">wf_control /a> * a href="+code=ct" class="sref">ct /a>). 286 /a>{. 287 /a>        struct  a href="+code=module" class="sref">module /a> * a href="+code=mod" class="sref">mod /a> =  a href="+code=ct" class="sref">ct /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=owner" class="sref">owner /a>;. 288 /a>         a href="+code=kref_put" class="sref">kref_put /a>(& a href="+code=ct" class="sref">ct /a>-> a href="+code=ref" class="sref">ref /a>,  a href="+code=wf_control_release" class="sref">wf_control_release /a>);. 289 /a>         a href="+code=module_put" class="sref">module_put /a>( a href="+code=mod" class="sref">mod /a>);. 29e="a>}. 291 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_put_control" class="sref">wf_put_control /a>);. 292 /a>. 293 /a>. 294 /a> spa3 class="comment">/* /spa33. 295 /a> spa3 class="comment"> * Sensors /spa33. 296 /a> spa3 class="comment"> */ /spa33. 297 /a>. 298 /a>. 299 /a>static void  a href="+code=wf_sensor_release" class="sref">wf_sensor_release /a>(struct  a href="+code=kref" class="sref">kref /a> * a href="+code=kref" class="sref">kref /a>). 300 /a>{. 301 /a>        struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=sr" class="sref">sr /a> =  a href="+code=container_of" class="sref">container_of /a>( a href="+code=kref" class="sref">kref /a>, struct  a href="+code=wf_sensor" class="sref">wf_sensor /a>,  a href="+code=ref" class="sref">ref /a>);. 302 /a>. 303 /a>         a href="+code=DBG" class="sref">DBG /a>( spa3 class="string">"wf: Deleting sensor %s\n"sr /a>-> a href="+code=nam3" class="sref">nam3 /a>);. 304 /a>. 305 /a>        if ( a href="+code=sr" class="sref">sr /a>-> a href="+code=ops" class="sref">ops /a> &&  a href="+code=sr" class="sref">sr /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=release" class="sref">release /a>). 306 /a>                 a href="+code=sr" class="sref">sr /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=release" class="sref">release /a>( a href="+code=sr" class="sref">sr /a>);. 307 /a>        else. 308 /a>                 a href="+code=kfree" class="sref">kfree /a>( a href="+code=sr" class="sref">sr /a>);. 309 /a>}. 310 /a>. 311 /a>static  a href="+code=ssize_t" class="sref">ssize_t /a>  a href="+code=wf_show_sensor" class="sref">wf_show_sensor /a>(struct  a href="+code=device" class="sref">device /a> * a href="+code=dev" class="sref">dev /a>,. 312 /a>                              struct  a href="+code=device_attribute" class="sref">device_attribute /a> * a href="+code=attr" class="sref">attr /a>, char * a href="+code=buf" class="sref">buf /a>). 313 /a>{. 314 /a>        struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=sens" class="sref">sens /a> =  a href="+code=container_of" class="sref">container_of /a>( a href="+code=attr" class="sref">attr /a>, struct  a href="+code=wf_sensor" class="sref">wf_sensor /a>,  a href="+code=attr" class="sref">attr /a>);. 315 /a>         a href="+code=s32" class="sref">s32 /a>  a href="+code=val" class="sref">val /a> = 0;. 316 /a>        int  a href="+code=err" class="sref">err /a>;. 317 /a>. 318 /a>         a href="+code=err" class="sref">err /a> =  a href="+code=sens" class="sref">sens /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=get_.6.33" class="sref">get_.6.33 /a>( a href="+code=sens" class="sref">sens /a>, & a href="+code=val" class="sref">val /a>);. 319 /a>        if ( a href="+code=err" class="sref">err /a> < 0). 320 /a>                return  a href="+code=err" class="sref">err /a>;. 321 /a>        return  a href="+code=sprintf" class="sref">sprintf /a>( a href="+code=buf" class="sref">buf /a>,  spa3 class="string">"%d.%03d\n"FIX32TOPRINT /a>( a href="+code=val" class="sref">val /a>));. 322 /a>}. 323 /a>. 324 /a>int  a href="+code=wf_register_sensor" class="sref">wf_register_sensor /a>(struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=new_sr" class="sref">new_sr /a>). 325 /a>{. 326 /a>        struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=sr" class="sref">sr /a>;. 327 /a>. 328 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 329 /a>         a href="+code=list_for_each_entry" class="sref">list_for_each_entry /a>( a href="+code=sr" class="sref">sr /a>, & a href="+code=wf_sensors" class="sref">wf_sensors /a>,  a href="+code=link" class="sref">link /a>) {. 330 /a>                if (! a href="+code=strcmp" class="sref">strcmp /a>( a href="+code=sr" class="sref">sr /a>-> a href="+code=nam3" class="sref">nam3 /a>,  a href="+code=new_sr" class="sref">new_sr /a>-> a href="+code=nam3" class="sref">nam3 /a>)) {. 331 /a>                         a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_WARNING" class="sref">KERN_WARNING /a>  spa3 class="string">"windfarm: trying to register" 332 /a>                                spa3 class="string">" duplicate sensor %s\n"sr /a>-> a href="+code=nam3" class="sref">nam3 /a>);. 333 /a>                         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 334 /a>                        return - a href="+code=EEXIST" class="sref">EEXIST /a>;. 335 /a>                }. 336 /a>        }. 337 /a>         a href="+code=kref_init" class="sref">kref_init /a>(& a href="+code=new_sr" class="sref">new_sr /a>-> a href="+code=ref" class="sref">ref /a>);. 338 /a>         a href="+code=list_add" class="sref">list_add /a>(& a href="+code=new_sr" class="sref">new_sr /a>-> a href="+code=link" class="sref">link /a>, & a href="+code=wf_sensors" class="sref">wf_sensors /a>);. 339 /a>. 340 /a>         a href="+code=sysfs_attr_init" class="sref">sysfs_attr_init /a>(& a href="+code=new_sr" class="sref">new_sr /a>-> a href="+code=attr" class="sref">attr /a>. a href="+code=attr" class="sref">attr /a>);. 341 /a>         a href="+code=new_sr" class="sref">new_sr /a>-> a href="+code=attr" class="sref">attr /a>. a href="+code=attr" class="sref">attr /a>. a href="+code=nam3" class="sref">nam3 /a> =  a href="+code=new_sr" class="sref">new_sr /a>-> a href="+code=nam3" class="sref">nam3 /a>;. 342 /a>         a href="+code=new_sr" class="sref">new_sr /a>-> a href="+code=attr" class="sref">attr /a>. a href="+code=attr" class="sref">attr /a>. a href="+code=mode" class="sref">mode /a> = 0444;. 343 /a>         a href="+code=new_sr" class="sref">new_sr /a>-> a href="+code=attr" class="sref">attr /a>. a href="+code=show" class="sref">show /a> =  a href="+code=wf_show_sensor" class="sref">wf_show_sensor /a>;. 344 /a>         a href="+code=new_sr" class="sref">new_sr /a>-> a href="+code=attr" class="sref">attr /a>. a href="+code=store" class="sref">store /a> =  a href="+code=NULL" class="sref">NULL /a>;. 345 /a>        if ( a href="+code=device_create_file" class="sref">device_create_file /a>(& a href="+code=wf_platform_device" class="sref">wf_platform_device /a>. a href="+code=dev" class="sref">dev /a>, & a href="+code=new_sr" class="sref">new_sr /a>-> a href="+code=attr" class="sref">attr /a>)). 346 /a>                 a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_WARNING" class="sref">KERN_WARNING /a>  spa3 class="string">"windfarm: device_create_file failed" 347 /a>                         spa3 class="string">" for %s\n"new_sr /a>-> a href="+code=nam3" class="sref">nam3 /a>);. 348 /a>                 spa3 class="comment">/* the subsystem still does useful work without the file */ /spa33. 349 /a>. 350 /a>         a href="+code=DBG" class="sref">DBG /a>( spa3 class="string">"wf: Registered sensor %s\n"new_sr /a>-> a href="+code=nam3" class="sref">nam3 /a>);. 351 /a>. 352 /a>         a href="+code=wf_notify" class="sref">wf_notify /a>( a href="+code=WF_EVENT_NEW_SENSOR" class="sref">WF_EVENT_NEW_SENSOR /a>,  a href="+code=new_sr" class="sref">new_sr /a>);. 353 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 354 /a>. 355 /a>        return 0;. 356 /a>}. 357 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_register_sensor" class="sref">wf_register_sensor /a>);. 358 /a>. 359 /a>void  a href="+code=wf_unregister_sensor" class="sref">wf_unregister_sensor /a>(struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=sr" class="sref">sr /a>). 360 /a>{. 361 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 362 /a>         a href="+code=list_del" class="sref">list_del /a>(& a href="+code=sr" class="sref">sr /a>-> a href="+code=link" class="sref">link /a>);. 363 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 364 /a>. 365 /a>         a href="+code=DBG" class="sref">DBG /a>( spa3 class="string">"wf: Unregistered sensor %s\n"sr /a>-> a href="+code=nam3" class="sref">nam3 /a>);. 366 /a>. 367 /a>         a href="+code=wf_put_sensor" class="sref">wf_put_sensor /a>( a href="+code=sr" class="sref">sr /a>);. 368 /a>}. 369 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_unregister_sensor" class="sref">wf_unregister_sensor /a>);. 370 /a>. 371 /a>struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> *  a href="+code=wf_find_sensor" class="sref">wf_find_sensor /a>(const char * a href="+code=nam3" class="sref">nam3 /a>). 372 /a>{. 373 /a>        struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=sr" class="sref">sr /a>;. 374 /a>. 375 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 376 /a>         a href="+code=list_for_each_entry" class="sref">list_for_each_entry /a>( a href="+code=sr" class="sref">sr /a>, & a href="+code=wf_sensors" class="sref">wf_sensors /a>,  a href="+code=link" class="sref">link /a>) {. 377 /a>                if (! a href="+code=strcmp" class="sref">strcmp /a>( a href="+code=sr" class="sref">sr /a>-> a href="+code=nam3" class="sref">nam3 /a>,  a href="+code=nam3" class="sref">nam3 /a>)) {. 378 /a>                        if ( a href="+code=wf_get_sensor" class="sref">wf_get_sensor /a>( a href="+code=sr" class="sref">sr /a>)). 379 /a>                                 a href="+code=sr" class="sref">sr /a> =  a href="+code=NULL" class="sref">NULL /a>;. 380 /a>                         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 381 /a>                        return  a href="+code=sr" class="sref">sr /a>;. 382 /a>                }. 383 /a>        }. 384 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 385 /a>        return  a href="+code=NULL" class="sref">NULL /a>;. 386 /a>}. 387 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_find_sensor" class="sref">wf_find_sensor /a>);. 388 /a>. 389 /a>int  a href="+code=wf_get_sensor" class="sref">wf_get_sensor /a>(struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=sr" class="sref">sr /a>). 390 /a>{. 391 /a>        if (! a href="+code=try_module_get" class="sref">try_module_get /a>( a href="+code=sr" class="sref">sr /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=owner" class="sref">owner /a>)). 392 /a>                return - a href="+code=ENODEV" class="sref">ENODEV /a>;. 393 /a>         a href="+code=kref_get" class="sref">kref_get /a>(& a href="+code=sr" class="sref">sr /a>-> a href="+code=ref" class="sref">ref /a>);. 394 /a>        return 0;. 395 /a>}. 396 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_get_sensor" class="sref">wf_get_sensor /a>);. 397 /a>. 398 /a>void  a href="+code=wf_put_sensor" class="sref">wf_put_sensor /a>(struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=sr" class="sref">sr /a>). 399 /a>{. 400 /a>        struct  a href="+code=module" class="sref">module /a> * a href="+code=mod" class="sref">mod /a> =  a href="+code=sr" class="sref">sr /a>-> a href="+code=ops" class="sref">ops /a>-> a href="+code=owner" class="sref">owner /a>;. 401 /a>         a href="+code=kref_put" class="sref">kref_put /a>(& a href="+code=sr" class="sref">sr /a>-> a href="+code=ref" class="sref">ref /a>,  a href="+code=wf_sensor_release" class="sref">wf_sensor_release /a>);. 402 /a>         a href="+code=module_put" class="sref">module_put /a>( a href="+code=mod" class="sref">mod /a>);. 403 /a>}. 404 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_put_sensor" class="sref">wf_put_sensor /a>);. 405 /a>. 406 /a>. 407 /a> spa3 class="comment">/* /spa33. 408 /a> spa3 class="comment"> * Client & notification /spa33. 409 /a> spa3 class="comment"> */ /spa33. 410 /a>. 411 /a>int  a href="+code=wf_register_client" class="sref">wf_register_client /a>(struct  a href="+code=notifier_block" class="sref">notifier_block /a> * a href="+code=nb" class="sref">nb /a>). 412 /a>{. 413 /a>        int  a href="+code=rc" class="sref">rc /a>;. 414 /a>        struct  a href="+code=wf_control" class="sref">wf_control /a> * a href="+code=ct" class="sref">ct /a>;. 415 /a>        struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=sr" class="sref">sr /a>;. 416 /a>. 417 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 418 /a>         a href="+code=rc" class="sref">rc /a> =  a href="+code=blocking_notifier_chain_register" class="sref">blocking_notifier_chain_register /a>(& a href="+code=wf_client_list" class="sref">wf_client_list /a>,  a href="+code=nb" class="sref">nb /a>);. 419 /a>        if ( a href="+code=rc" class="sref">rc /a> != 0). 420 /a>                goto  a href="+code=bail" class="sref">bail /a>;. 421 /a>         a href="+code=wf_client_count" class="sref">wf_client_count /a>++;. 422 /a>         a href="+code=list_for_each_entry" class="sref">list_for_each_entry /a>( a href="+code=ct" class="sref">ct /a>, & a href="+code=wf_controls" class="sref">wf_controls /a>,  a href="+code=link" class="sref">link /a>). 423 /a>                 a href="+code=wf_notify" class="sref">wf_notify /a>( a href="+code=WF_EVENT_NEW_CONTROL" class="sref">WF_EVENT_NEW_CONTROL /a>,  a href="+code=ct" class="sref">ct /a>);. 424 /a>         a href="+code=list_for_each_entry" class="sref">list_for_each_entry /a>( a href="+code=sr" class="sref">sr /a>, & a href="+code=wf_sensors" class="sref">wf_sensors /a>,  a href="+code=link" class="sref">link /a>). 425 /a>                 a href="+code=wf_notify" class="sref">wf_notify /a>( a href="+code=WF_EVENT_NEW_SENSOR" class="sref">WF_EVENT_NEW_SENSOR /a>,  a href="+code=sr" class="sref">sr /a>);. 426 /a>        if ( a href="+code=wf_client_count" class="sref">wf_client_count /a> == 1). 427 /a>                 a href="+code=wf_start_thread" class="sref">wf_start_thread /a>();. 428 /a>  a href="+code=bail" class="sref">bail /a>:. 429 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 430 /a>        return  a href="+code=rc" class="sref">rc /a>;. 431 /a>}. 432 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_register_client" class="sref">wf_register_client /a>);. 433 /a>. 434 /a>int  a href="+code=wf_unregister_client" class="sref">wf_unregister_client /a>(struct  a href="+code=notifier_block" class="sref">notifier_block /a> * a href="+code=nb" class="sref">nb /a>). 435 /a>{. 436 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 437 /a>         a href="+code=blocking_notifier_chain_unregister" class="sref">blocking_notifier_chain_unregister /a>(& a href="+code=wf_client_list" class="sref">wf_client_list /a>,  a href="+code=nb" class="sref">nb /a>);. 438 /a>         a href="+code=wf_client_count" class="sref">wf_client_count /a>++;. 439 /a>        if ( a href="+code=wf_client_count" class="sref">wf_client_count /a> == 0). 440 /a>                 a href="+code=wf_stop_thread" class="sref">wf_stop_thread /a>();. 441 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 442 /a>. 443 /a>        return 0;. 444 /a>}. 445 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_unregister_client" class="sref">wf_unregister_client /a>);. 446 /a>. 447 /a>void  a href="+code=wf_set_overtemp" class="sref">wf_set_overtemp /a>(void). 448 /a>{. 449 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 450 /a>         a href="+code=wf_overtemp" class="sref">wf_overtemp /a>++;. 451 /a>        if ( a href="+code=wf_overtemp" class="sref">wf_overtemp /a> == 1) {. 452 /a>                 a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_WARNING" class="sref">KERN_WARNING /a>  spa3 class="string">"windfarm: Overtemp condition detected !\n" 453 /a>                 a href="+code=wf_overtemp_counter" class="sref">wf_overtemp_counter /a> = 0;. 454 /a>                 a href="+code=wf_notify" class="sref">wf_notify /a>( a href="+code=WF_EVENT_OVERTEMP" class="sref">WF_EVENT_OVERTEMP /a>,  a href="+code=NULL" class="sref">NULL /a>);. 455 /a>        }. 456 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 457 /a>}. 458 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_set_overtemp" class="sref">wf_set_overtemp /a>);. 459 /a>. 460 /a>void  a href="+code=wf_clear_overtemp" class="sref">wf_clear_overtemp /a>(void). 461 /a>{. 462 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 463 /a>         a href="+code=WARN_ON" class="sref">WARN_ON /a>( a href="+code=wf_overtemp" class="sref">wf_overtemp /a> == 0);. 464 /a>        if ( a href="+code=wf_overtemp" class="sref">wf_overtemp /a> == 0) {. 465 /a>                 a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 466 /a>                return;. 467 /a>        }. 468 /a>         a href="+code=wf_overtemp" class="sref">wf_overtemp /a>--;. 469 /a>        if ( a href="+code=wf_overtemp" class="sref">wf_overtemp /a> == 0) {. 470 /a>                 a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_WARNING" class="sref">KERN_WARNING /a>  spa3 class="string">"windfarm: Overtemp condition cleared !\n" 471 /a>                 a href="+code=wf_notify" class="sref">wf_notify /a>( a href="+code=WF_EVENT_NORMALTEMP" class="sref">WF_EVENT_NORMALTEMP /a>,  a href="+code=NULL" class="sref">NULL /a>);. 472 /a>        }. 473 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=wf_lock" class="sref">wf_lock /a>);. 474 /a>}. 475 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_clear_overtemp" class="sref">wf_clear_overtemp /a>);. 476 /a>. 477 /a>int  a href="+code=wf_is_overtemp" class="sref">wf_is_overtemp /a>(void). 478 /a>{. 479 /a>        return ( a href="+code=wf_overtemp" class="sref">wf_overtemp /a> != 0);. 480 /a>}. 481 /a> a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL /a>( a href="+code=wf_is_overtemp" class="sref">wf_is_overtemp /a>);. 482 /a>. 483 /a>static int  a href="+code=__init" class="sref">__init /a>  a href="+code=windfarm_core_init" class="sref">windfarm_core_init /a>(void). 484 /a>{. 485 /a>         a href="+code=DBG" class="sref">DBG /a>( spa3 class="string">"wf: core loaded\n" 486 /a>. 487 /a>         a href="+code=platform_device_register" class="sref">platform_device_register /a>(& a href="+code=wf_platform_device" class="sref">wf_platform_device /a>);. 488 /a>        return 0;. 489 /a>}. 490 /a>. 491 /a>static void  a href="+code=__exit" class="sref">__exit /a>  a href="+code=windfarm_core_exit" class="sref">windfarm_core_exit /a>(void). 492 /a>{. 493 /a>         a href="+code=BUG_ON" class="sref">BUG_ON /a>( a href="+code=wf_client_count" class="sref">wf_client_count /a> != 0);. 494 /a>. 495 /a>         a href="+code=DBG" class="sref">DBG /a>( spa3 class="string">"wf: core unloaded\n" 496 /a>. 497 /a>         a href="+code=platform_device_unregister" class="sref">platform_device_unregister /a>(& a href="+code=wf_platform_device" class="sref">wf_platform_device /a>);. 498 /a>}. 499 /a>. 500 /a>. 501 /a> a href="+code=module_init" class="sref">module_init /a>( a href="+code=windfarm_core_init" class="sref">windfarm_core_init /a>);. 502 /a> a href="+code=module_exit" class="sref">module_exit /a>( a href="+code=windfarm_core_exit" class="sref">windfarm_core_exit /a>);. 503 /a>. 504 /a> a href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHOR /a>( spa3 class="string">"Benjamin Herrenschmidt <benh@kernel.crashing.org>" 505 /a> a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION /a>( spa3 class="string">"Core component of PowerMac thermal control" 506 /a> a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE /a>( spa3 class="string">"GPL" 507 /a>. 508 /a> /pre> /div>


 /div>