linux/drivers/macintosh/windfarm_smu_sat.c
<<
> opt/spa opt/form opta > op href="../linux+v3.9.6/drivers/macintosh/windfarm_smu_sat.c"> > optimg src="../.static/gfx/right.png" alt=">>"> >t/spa >tspa class="lxr_search"> > ="+search" method="post" onsubmit="return do_search(this);"> > optinput typ="vhidden" nam="vnavtarget" alue="v"> > optinput typ="vtext" nam="vsearch" id"vsearch"> > optbuttn2vtyp="vsubmit">Searchtspa class="lxr_prefs" opta href="+prefs?return=drivers/macintosh/windfarm_smu_sat.c" > op onclick="return ajax_prefs();"> > opPrefs opt/a> >t/spa op pt/div op ptform aca> ="ajax+*" method="post" onsubmit="return false;"> >tinput typ="vhidden" nam="vajax_lookup" id"vajax_lookup" alue="v"> op pt/form op ptdiv class="headingbottnm">
tdiv id"vfile_contents"
p p1t/a>tspa  class="comment">/*t/spa  
p p2t/a>tspa  class="comment"> * Windfarm PowerMac thermal control.  SMU "satellite" controller sensors.t/spa  
p p3t/a>tspa  class="comment"> *t/spa  
p p4t/a>tspa  class="comment"> * Copyright (C) 2005 Paul Mackerras, IBM Corp. <paulus@samba.org>t/spa  
p p5t/a>tspa  class="comment"> *t/spa  
p p6t/a>tspa  class="comment"> * Released under the terms of the GNU GPL.12.t/spa  
p p7t/a>tspa  class="comment"> */t/spa  
p p8t/a> p p9t/a>#include <linux/typ=s.ht/a>> p tio2a>#include <linux/errno.ht/a>> p 11o2a>#include <linux/kernel.ht/a>> p 12o2a>#include <linux/slab.ht/a>> p 13o2a>#include <linux/init.ht/a>> p 14o2a>#include <linux/wait.ht/a>> p 15o2a>#include <linux/i2c.ht/a>> p 16o2a>#include <linux/mutex.ht/a>> p 17o2a>#include <asm/prom.ht/a>> p 18o2a>#include <asm/smu.ht/a>> p 19t/a>#include <asm/pmac_low_i2c.ht/a>> p 20t/a> p 21o2a>#include "windfarm.ht/a>" p 22t/a> p 23o2a>#definepta href="+code=VERSION" class="sref">VERSIONo2a> tspa  class="string">"1.0"p 24t/a> p 25o2a>#definepta href="+code=DEBUG" class="sref">DEBUGt/a> p 26t/a> p 27o2a>#ifdefpta href="+code=DEBUG" class="sref">DEBUGt/a> p 28o2a>#definepta href="+code=DBG" class="sref">DBGt/a>(ta href="+code=args" class="sref">argst/a>...)op pta href="+code=printk" class="sref">printkt/a>(ta href="+code=args" class="sref">argst/a>) p 29t/a>#else
p 30o2a>#definepta href="+code=DBG" class="sref">DBGt/a>(ta href="+code=args" class="sref">argst/a>...)op pdo { } while(0) p 31o2a>#endif p 32t/a> p 33t/a>tspa  class="comment">/* If the cache is older tha  800ms we'll refetch it */t/spa  
p 34o2a>#definepta href="+code=MAX_AGE" class="sref">MAX_AGEo2a>         ta href="+code=msecs_to_jiffies" class="sref">msecs_to_jiffiest/a>(800) p 35t/a> p 36t/a>struct ta href="+code=wf_sat" class="sref">wf_sato2a> { p 37o2a>        struct ta href="+code=kref" class="sref">krefo2a>             ta href="+code=ref" class="sref">refo2a>; p 38o2a>        int                     ta href="+code=nr" class="sref">nro2a>; p 39o2a>        struct ta href="+code=mutex" class="sref">mutexo2a>            ta href="+code=mutex" class="sref">mutexo2a>; p 40o2a>        unsigned long           ta href="+code=last_read" class="sref">last_reado2a>; tspa  class="comment">/* jiffies when cache last updated */t/spa  
p 41o2a>        ta href="+code=u8" class="sref">u8o2a>                      ta href="+code=cache" class="sref">cacheo2a>[16]; p 42o2a>        struct ta href="+code=list_head" class="sref">list_heado2a>        ta href="+code=sensors" class="sref">sensorso2a>; p 43o2a>        struct ta href="+code=i2c_client" class="sref">i2c_cliento2a>       *ta href="+code=i2c" class="sref">i2co2a>; p 44o2a>        struct ta href="+code=device_node" class="sref">device_nodeo2a>      *ta href="+code=node" class="sref">nodeo2a>; p 45t/a>}; p 46t/a> p 47t/a>static struct ta href="+code=wf_sat" class="sref">wf_sato2a> *ta href="+code=sats" class="sref">satso2a>[2]; p 48t/a> p 49t/a>struct ta href="+code=wf_sat_sensor" class="sref">wf_sat_sensoro2a> { p 50o2a>        struct ta href="+code=list_head" class="sref">list_heado2a>        ta href="+code=link" class="sref">linko2a>; p 51o2a>        int                     ta href="+code=index" class="sref">indexo2a>; p 52o2a>        int                     ta href="+code=index2" class="sref">index2o2a>;         tspa  class="comment">/* used for power sensors */t/spa  
p 53o2a>        int                     ta href="+code=shift" class="sref">shifto2a>; p 54o2a>        struct ta href="+code=wf_sat" class="sref">wf_sato2a>           *ta href="+code=sat" class="sref">sato2a>; p 55o2a>        struct ta href="+code=wf_sensor" class="sref">wf_sensoro2a>        ta href="+code=sens" class="sref">senso2a>; p 56t/a>}; p 57t/a> p 58o2a>#definepta href="+code=wf_to_sat" class="sref">wf_to_satt/a>(ta href="+code=c" class="sref">co2a>)op pta href="+code=container_of" class="sref">container_oft/a>(ta href="+code=c" class="sref">co2a>, struct ta href="+code=wf_sat_sensor" class="sref">wf_sat_sensoro2a>, ta href="+code=sens" class="sref">senso2a>) p 59t/a> p 60t/a>struct ta href="+code=smu_sdbp_header" class="sref">smu_sdbp_headero2a> *ta href="+code=smu_sat_get_sdb_partia>
 " class="sref">smu_sat_get_sdb_partia>
 t/a>(unsigned int ta href="+code=sat_id" class="sref">sat_ido2a>, int ta href="+code=id" class="sref">ido2a>, p 61o2a>                                                  unsigned int *ta href="+code=size" class="sref">sizeo2a>) p 62o2a>{ p 63o2a>        struct ta href="+code=wf_sat" class="sref">wf_sato2a> *ta href="+code=sat" class="sref">sato2a>; p 64o2a>        int ta href="+code=err" class="sref">erro2a>; p 65o2a>        unsigned int ta href="+code=i" class="sref">io2a>, ta href="+code=le " class="sref">le o2a>; p 66o2a>        ta href="+code=u8" class="sref">u8o2a> *ta href="+code=buf" class="sref">bufo2a>; p 67o2a>        ta href="+code=u8" class="sref">u8o2a> ta href="+code=data" class="sref">datao2a>[4]; p 68t/a> p 69o2a>        tspa  class="comment">/* TODO: Add the resulting partia>
  to the device-tree */t/spa  
p 70t/a> p 71o2a>        if (ta href="+code=sat_id" class="sref">sat_ido2a> > 1 || (ta href="+code=sat" class="sref">sato2a> = ta href="+code=sats" class="sref">satso2a>[ta href="+code=sat_id" class="sref">sat_ido2a>]) == ta href="+code=NULL" class="sref">NULLo2a>) p 72o2a>                return ta href="+code=NULL" class="sref">NULLo2a>; p 73t/a> p 74o2a>        ta href="+code=err" class="sref">erro2a> = ta href="+code=i2c_smbus_write_word_data" class="sref">i2c_smbus_write_word_datat/a>(ta href="+code=sat" class="sref">sato2a>->ta href="+code=i2c" class="sref">i2co2a>, 8, ta href="+code=id" class="sref">ido2a> << 8); p 75o2a>        if (ta href="+code=err" class="sref">erro2a>) { p 76o2a>                ta href="+code=printk" class="sref">printkt/a>(ta href="+code=KERN_ERR" class="sref">KERN_ERRo2a> tspa  class="string">"smu_sat_get_sdb_part wr error %d\n"erro2a>); p 77o2a>                return ta href="+code=NULL" class="sref">NULLo2a>; p 78o2a>        } p 79t/a> p 80o2a>        ta href="+code=err" class="sref">erro2a> = ta href="+code=i2c_smbus_read_word_data" class="sref">i2c_smbus_read_word_datat/a>(ta href="+code=sat" class="sref">sato2a>->ta href="+code=i2c" class="sref">i2co2a>, 9); p 81o2a>        if (ta href="+code=err" class="sref">erro2a> < 0) { p 82o2a>                ta href="+code=printk" class="sref">printkt/a>(ta href="+code=KERN_ERR" class="sref">KERN_ERRo2a> tspa  class="string">"smu_sat_get_sdb_part rd le  error\n"p 83o2a>                return ta href="+code=NULL" class="sref">NULLo2a>; p 84o2a>        } p 85o2a>        ta href="+code=le " class="sref">le o2a> = ta href="+code=err" class="sref">erro2a>; p 86o2a>        if (ta href="+code=le " class="sref">le o2a> == 0) { p 87o2a>                ta href="+code=printk" class="sref">printkt/a>(ta href="+code=KERN_ERR" class="sref">KERN_ERRo2a> tspa  class="string">"smu_sat_get_sdb_part no partia>
  %x\n"ido2a>); p 88o2a>                return ta href="+code=NULL" class="sref">NULLo2a>; p 89o2a>        } p 90t/a> p 91o2a>        ta href="+code=le " class="sref">le o2a> = ta href="+code=le16_to_cpu" class="sref">le16_to_cput/a>(ta href="+code=le " class="sref">le o2a>); p 92o2a>        ta href="+code=le " class="sref">le o2a> = (ta href="+code=le " class="sref">le o2a> + 3) & ~3; p 93o2a>        ta href="+code=buf" class="sref">bufo2a> = ta href="+code=kmalloc" class="sref">kmalloct/a>(ta href="+code=le " class="sref">le o2a>, ta href="+code=GFP_KERNEL" class="sref">GFP_KERNELo2a>); p 94o2a>        if (ta href="+code=buf" class="sref">bufo2a> == ta href="+code=NULL" class="sref">NULLo2a>) p 95o2a>                return ta href="+code=NULL" class="sref">NULLo2a>; p 96t/a> p 97o2a>        for (ta href="+code=i" class="sref">io2a> = 0; ta href="+code=i" class="sref">io2a> < ta href="+code=le " class="sref">le o2a>; ta href="+code=i" class="sref">io2a> += 4) { p 98o2a>                ta href="+code=err" class="sref">erro2a> = ta href="+code=i2c_smbus_read_i2c_block_data" class="sref">i2c_smbus_read_i2c_block_datat/a>(ta href="+code=sat" class="sref">sato2a>->ta href="+code=i2c" class="sref">i2co2a>, 0xa, 4, ta href="+code=data" class="sref">datao2a>); p 99o2a>                if (ta href="+code=err" class="sref">erro2a> < 0) { p100o2a>                        ta href="+code=printk" class="sref">printkt/a>(ta href="+code=KERN_ERR" class="sref">KERN_ERRo2a> tspa  class="string">"smu_sat_get_sdb_part rd err %d\n"p101o2a>                               ta href="+code=err" class="sref">erro2a>); p102o2a>                        goto ta href="+code=fail" class="sref">failo2a>; p103o2a>                } p104o2a>                ta href="+code=buf" class="sref">bufo2a>[ta href="+code=i" class="sref">io2a>] = ta href="+code=data" class="sref">datao2a>[1]; p105o2a>                ta href="+code=buf" class="sref">bufo2a>[ta href="+code=i" class="sref">io2a>+1] = ta href="+code=data" class="sref">datao2a>[0]; p106o2a>                ta href="+code=buf" class="sref">bufo2a>[ta href="+code=i" class="sref">io2a>+2] = ta href="+code=data" class="sref">datao2a>[3]; p107o2a>                ta href="+code=buf" class="sref">bufo2a>[ta href="+code=i" class="sref">io2a>+3] = ta href="+code=data" class="sref">datao2a>[2]; p108o2a>        } p109t/a>#ifdefpta href="+code=DEBUG" class="sref">DEBUGt/a> p110o2a>        ta href="+code=DBG" class="sref">DBGt/a>(ta href="+code=KERN_DEBUG" class="sref">KERN_DEBUGo2a> tspa  class="string">"sat %d partia>
  %x:"sat_ido2a>, ta href="+code=id" class="sref">ido2a>); p111o2a>        for (ta href="+code=i" class="sref">io2a> = 0; ta href="+code=i" class="sref">io2a> < ta href="+code=le " class="sref">le o2a>; ++ta href="+code=i" class="sref">io2a>) p112o2a>                ta href="+code=DBG" class="sref">DBGt/a>(tspa  class="string">" %x"bufo2a>[ta href="+code=i" class="sref">io2a>]); p113o2a>        ta href="+code=DBG" class="sref">DBGt/a>(tspa  class="string">"\n"p114o2a>#endif p115t/a> p116o2a>        if (ta href="+code=size" class="sref">sizeo2a>) p117o2a>                *ta href="+code=size" class="sref">sizeo2a> = ta href="+code=le " class="sref">le o2a>; p118o2a>        return (struct ta href="+code=smu_sdbp_header" class="sref">smu_sdbp_headero2a> *) ta href="+code=buf" class="sref">bufo2a>; p119t/a> p120t/a> ta href="+code=fail" class="sref">failo2a>: p121o2a>        ta href="+code=kfree" class="sref">kfreet/a>(ta href="+code=buf" class="sref">bufo2a>); p122o2a>        return ta href="+code=NULL" class="sref">NULLo2a>; p123o2a>} p124t/a>ta href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPLt/a>(ta href="+code=smu_sat_get_sdb_partia>
 " class="sref">smu_sat_get_sdb_partia>
 t/a>); p125t/a> p126t/a>tspa  class="comment">/* refresh the cache */t/spa  
p127t/a>static int ta href="+code=wf_sat_read_cache" class="sref">wf_sat_read_cachet/a>(struct ta href="+code=wf_sat" class="sref">wf_sato2a> *ta href="+code=sat" class="sref">sato2a>) p128o2a>{ p129o2a>        int ta href="+code=err" class="sref">erro2a>; p130t/a> p131o2a>        ta href="+code=err" class="sref">erro2a> = ta href="+code=i2c_smbus_read_i2c_block_data" class="sref">i2c_smbus_read_i2c_block_datat/a>(ta href="+code=sat" class="sref">sato2a>->ta href="+code=i2c" class="sref">i2co2a>, 0x3f, 16, ta href="+code=sat" class="sref">sato2a>->ta href="+code=cache" class="sref">cacheo2a>); p132o2a>        if (ta href="+code=err" class="sref">erro2a> < 0) p133o2a>                return ta href="+code=err" class="sref">erro2a>; p134o2a>        ta href="+code=sat" class="sref">sato2a>->ta href="+code=last_read" class="sref">last_reado2a> = ta href="+code=jiffies" class="sref">jiffiest/a>; p135t/a>#ifdefpta href="+code=LOTSA_DEBUG" class="sref">LOTSA_DEBUGt/a> p136o2a>        { p137o2a>                int ta href="+code=i" class="sref">io2a>; p138o2a>                ta href="+code=DBG" class="sref">DBGt/a>(ta href="+code=KERN_DEBUG" class="sref">KERN_DEBUGo2a> tspa  class="string">"wf_sat_get: data is"p139o2a>                for (ta href="+code=i" class="sref">io2a> = 0; ta href="+code=i" class="sref">io2a> < 16; ++ta href="+code=i" class="sref">io2a>) p140o2a>                        ta href="+code=DBG" class="sref">DBGt/a>(tspa  class="string">" %.2x"sato2a>->ta href="+code=cache" class="sref">cacheo2a>[ta href="+code=i" class="sref">io2a>]); p141o2a>                ta href="+code=DBG" class="sref">DBGt/a>(tspa  class="string">"\n"p142o2a>        } p143o2a>#endif p144o2a>        return 0; p145t/a>} p146t/a> p147t/a>static int ta href="+code=wf_sat_sensor_get" class="sref">wf_sat_sensor_gett/a>(struct ta href="+code=wf_sensor" class="sref">wf_sensoro2a> *ta href="+code=sr" class="sref">sro2a>, ta href="+code=s32" class="sref">s32o2a> *ta href="+code=alue=" class="sref">alue=o2a>) p148o2a>{ p149o2a>        struct ta href="+code=wf_sat_sensor" class="sref">wf_sat_sensoro2a> *ta href="+code=sens" class="sref">senso2a> = ta href="+code=wf_to_sat" class="sref">wf_to_satt/a>(ta href="+code=sr" class="sref">sro2a>); p150o2a>        struct ta href="+code=wf_sat" class="sref">wf_sato2a> *ta href="+code=sat" class="sref">sato2a> = ta href="+code=sens" class="sref">senso2a>->ta href="+code=sat" class="sref">sato2a>; p151o2a>        int ta href="+code=i" class="sref">io2a>, ta href="+code=err" class="sref">erro2a>; p152o2a>        ta href="+code=s32" class="sref">s32o2a> ta href="+code=alu" class="sref">aluo2a>; p153t/a> p154o2a>        if (ta href="+code=sat" class="sref">sato2a>->ta href="+code=i2c" class="sref">i2co2a> == ta href="+code=NULL" class="sref">NULLo2a>) p155o2a>                return -ta href="+code=ENODEV" class="sref">ENODEVo2a>; p156t/a> p157o2a>        ta href="+code=mutex_lock" class="sref">mutex_lockt/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=mutex" class="sref">mutexo2a>); p158o2a>        if (ta href="+code=time_after" class="sref">time_aftert/a>(ta href="+code=jiffies" class="sref">jiffiest/a>, (ta href="+code=sat" class="sref">sato2a>->ta href="+code=last_read" class="sref">last_reado2a> +pta href="+code=MAX_AGE" class="sref">MAX_AGEo2a>))) { p159o2a>                ta href="+code=err" class="sref">erro2a> = ta href="+code=wf_sat_read_cache" class="sref">wf_sat_read_cachet/a>(ta href="+code=sat" class="sref">sato2a>); p160o2a>                if (ta href="+code=err" class="sref">erro2a>) p161o2a>                        goto ta href="+code=fail" class="sref">failo2a>; p162o2a>        } p163t/a> p164o2a>        ta href="+code=i" class="sref">io2a> = ta href="+code=sens" class="sref">senso2a>->ta href="+code=index" class="sref">indexo2a> * 2; p165o2a>        ta href="+code=alu" class="sref">aluo2a> = ((ta href="+code=sat" class="sref">sato2a>->ta href="+code=cache" class="sref">cacheo2a>[ta href="+code=i" class="sref">io2a>] << 8) +pta href="+code=sat" class="sref">sato2a>->ta href="+code=cache" class="sref">cacheo2a>[ta href="+code=i" class="sref">io2a>+1]) << ta href="+code=sens" class="sref">senso2a>->ta href="+code=shift" class="sref">shifto2a>; p166o2a>        if (ta href="+code=sens" class="sref">senso2a>->ta href="+code=index2" class="sref">index2o2a> >= 0) { p167o2a>                ta href="+code=i" class="sref">io2a> = ta href="+code=sens" class="sref">senso2a>->ta href="+code=index2" class="sref">index2o2a> * 2; p168o2a>                tspa  class="comment">/* 4.12 * 8.8 -> 12.20; shift right 4 to getp16.16 */t/spa  
p169o2a>                ta href="+code=alu" class="sref">aluo2a> = (ta href="+code=alu" class="sref">aluo2a> * ((ta href="+code=sat" class="sref">sato2a>->ta href="+code=cache" class="sref">cacheo2a>[ta href="+code=i" class="sref">io2a>] << 8) +pta href="+code=sat" class="sref">sato2a>->ta href="+code=cache" class="sref">cacheo2a>[ta href="+code=i" class="sref">io2a>+1])) >> 4; p170o2a>        } p171o2a> p172o2a>        *ta href="+code=alue=" class="sref">alue=o2a> = ta href="+code=alu" class="sref">aluo2a>; p173o2a>        ta href="+code=err" class="sref">erro2a> = 0; p174t/a> p175o2a> ta href="+code=fail" class="sref">failo2a>: p176o2a>        ta href="+code=mutex_unlock" class="sref">mutex_unlockt/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=mutex" class="sref">mutexo2a>); p177o2a>        return ta href="+code=err" class="sref">erro2a>; p178o2a>} p179t/a> p180t/a>static void ta href="+code=wf_sat_release" class="sref">wf_sat_releaset/a>(struct ta href="+code=kref" class="sref">krefo2a> *ta href="+code=ref" class="sref">refo2a>) p181o2a>{ p182o2a>        struct ta href="+code=wf_sat" class="sref">wf_sato2a> *ta href="+code=sat" class="sref">sato2a> = ta href="+code=container_of" class="sref">container_oft/a>(ta href="+code=ref" class="sref">refo2a>, struct ta href="+code=wf_sat" class="sref">wf_sato2a>, ta href="+code=ref" class="sref">refo2a>); p183t/a> p184o2a>        if (ta href="+code=sat" class="sref">sato2a>->ta href="+code=nr" class="sref">nro2a> >= 0) p185o2a>                ta href="+code=sats" class="sref">satso2a>[ta href="+code=sat" class="sref">sato2a>->ta href="+code=nr" class="sref">nro2a>] = ta href="+code=NULL" class="sref">NULLo2a>; p186o2a>        ta href="+code=kfree" class="sref">kfreet/a>(ta href="+code=sat" class="sref">sato2a>); p187o2a>} p188t/a> p189t/a>static void ta href="+code=wf_sat_sensor_release" class="sref">wf_sat_sensor_releaset/a>(struct ta href="+code=wf_sensor" class="sref">wf_sensoro2a> *ta href="+code=sr" class="sref">sro2a>) p190t/a>{ p191o2a>        struct ta href="+code=wf_sat_sensor" class="sref">wf_sat_sensoro2a> *ta href="+code=sens" class="sref">senso2a> = ta href="+code=wf_to_sat" class="sref">wf_to_satt/a>(ta href="+code=sr" class="sref">sro2a>); p192o2a>        struct ta href="+code=wf_sat" class="sref">wf_sato2a> *ta href="+code=sat" class="sref">sato2a> = ta href="+code=sens" class="sref">senso2a>->ta href="+code=sat" class="sref">sato2a>; p193t/a> p194o2a>        ta href="+code=kfree" class="sref">kfreet/a>(ta href="+code=sens" class="sref">senso2a>); p195o2a>        ta href="+code=kref_put" class="sref">kref_putt/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=ref" class="sref">refo2a>, ta href="+code=wf_sat_release" class="sref">wf_sat_releaset/a>); p196t/a>} p197t/a> p198o2a>static struct ta href="+code=wf_sensor_ops" class="sref">wf_sensor_opso2a> ta href="+code=wf_sat_ops" class="sref">wf_sat_opso2a> = { p199o2a>        .ta href="+code=get_alue=" class="sref">get_alue=o2a>      = ta href="+code=wf_sat_sensor_get" class="sref">wf_sat_sensor_gett/a>, p200o2a>        .ta href="+code=release" class="sref">releaset/a>        = ta href="+code=wf_sat_sensor_release" class="sref">wf_sat_sensor_releaset/a>, p201o2a>        .ta href="+code=owner" class="sref">ownero2a>          = ta href="+code=THIS_MODULE" class="sref">THIS_MODULEt/a>, p202o2a>}; p203t/a> p204o2a>static int ta href="+code=wf_sat_probe" class="sref">wf_sat_probet/a>(struct ta href="+code=i2c_client" class="sref">i2c_cliento2a> *ta href="+code=client" class="sref">cliento2a>, p205o2a>                        const struct ta href="+code=i2c_device_id" class="sref">i2c_device_ido2a> *ta href="+code=id" class="sref">ido2a>) p206o2a>{ p207o2a>        struct ta href="+code=device_node" class="sref">device_nodeo2a> *ta href="+code=dev" class="sref">devo2a> = ta href="+code=client" class="sref">cliento2a>->ta href="+code=dev" class="sref">devo2a>.ta href="+code=of_node" class="sref">of_nodeo2a>; p208o2a>        struct ta href="+code=wf_sat" class="sref">wf_sato2a> *ta href="+code=sat" class="sref">sato2a>; p209o2a>        struct ta href="+code=wf_sat_sensor" class="sref">wf_sat_sensoro2a> *ta href="+code=sens" class="sref">senso2a>; p210o2a>        const ta href="+code=u32" class="sref">u32o2a> *ta href="+code=reg" class="sref">rego2a>; p211o2a>        const char *ta href="+code=loc" class="sref">loct/a>, *ta href="+code=type" class="sref">typeo2a>; p212o2a>        ta href="+code=u8" class="sref">u8o2a> ta href="+code=chip" class="sref">chipo2a>, ta href="+code=core" class="sref">coreo2a>; p213o2a>        struct ta href="+code=device_node" class="sref">device_nodeo2a> *ta href="+code=child" class="sref">childo2a>; p214o2a>        int ta href="+code=shift" class="sref">shifto2a>, ta href="+code=cpu" class="sref">cput/a>, ta href="+code=index" class="sref">indexo2a>; p215o2a>        char *ta href="+code=nam=" class="sref">nam=o2a>; p216o2a>        int ta href="+code=vsens" class="sref">vsenso2a>[2], ta href="+code=isens" class="sref">isenso2a>[2]; p217t/a> p218o2a>        ta href="+code=sat" class="sref">sato2a> = ta href="+code=kzalloc" class="sref">kzalloct/a>(sizeof(struct ta href="+code=wf_sat" class="sref">wf_sato2a>), ta href="+code=GFP_KERNEL" class="sref">GFP_KERNELo2a>); p219o2a>        if (ta href="+code=sat" class="sref">sato2a> == ta href="+code=NULL" class="sref">NULLo2a>) p220o2a>                return -ta href="+code=ENOMEM" class="sref">ENOMEMo2a>; p221o2a>        ta href="+code=sat" class="sref">sato2a>->ta href="+code=nr" class="sref">nro2a> = -1; p222o2a>        ta href="+code=sat" class="sref">sato2a>->ta href="+code=node" class="sref">nodeo2a> = ta href="+code=of_node_get" class="sref">of_node_gett/a>(ta href="+code=dev" class="sref">devo2a>); p223o2a>        ta href="+code=kref_init" class="sref">kref_initt/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=ref" class="sref">refo2a>); p224o2a>        ta href="+code=mutex_init" class="sref">mutex_initt/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=mutex" class="sref">mutexo2a>); p225o2a>        ta href="+code=sat" class="sref">sato2a>->ta href="+code=i2c" class="sref">i2co2a> = ta href="+code=client" class="sref">cliento2a>; p226o2a>        ta href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEADt/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=sensors" class="sref">sensorso2a>); p227o2a>        ta href="+code=i2c_set_clientdata" class="sref">i2c_set_clientdatat/a>(ta href="+code=client" class="sref">cliento2a>, ta href="+code=sat" class="sref">sato2a>); p228t/a> p229o2a>        ta href="+code=vsens" class="sref">vsenso2a>[0] = ta href="+code=vsens" class="sref">vsenso2a>[1] = -1; p230o2a>        ta href="+code=isens" class="sref">isenso2a>[0] = ta href="+code=isens" class="sref">isenso2a>[1] = -1; p231o2a>        ta href="+code=child" class="sref">childo2a> = ta href="+code=NULL" class="sref">NULLo2a>; p232o2a>        while ((ta href="+code=child" class="sref">childo2a> = ta href="+code=of_get_next_child" class="sref">of_get_next_childt/a>(ta href="+code=dev" class="sref">devo2a>, ta href="+code=child" class="sref">childo2a>)) != ta href="+code=NULL" class="sref">NULLo2a>) { p233o2a>                ta href="+code=reg" class="sref">rego2a> = ta href="+code=of_get_property" class="sref">of_get_propertyt/a>(ta href="+code=child" class="sref">childo2a>, tspa  class="string">"reg"NULLo2a>); p234o2a>                ta href="+code=type" class="sref">typeo2a> = ta href="+code=of_get_property" class="sref">of_get_propertyt/a>(ta href="+code=child" class="sref">childo2a>, tspa  class="string">"device_type"NULLo2a>); p235o2a>                ta href="+code=loc" class="sref">loct/a> = ta href="+code=of_get_property" class="sref">of_get_propertyt/a>(ta href="+code=child" class="sref">childo2a>, tspa  class="string">"locaa>
 "NULLo2a>); p236o2a>                if (ta href="+code=reg" class="sref">rego2a> == ta href="+code=NULL" class="sref">NULLo2a> || ta href="+code=loc" class="sref">loct/a> == ta href="+code=NULL" class="sref">NULLo2a>) p237o2a>                        continue; p238t/a> p239o2a>                tspa  class="comment">/* the cooked sensors are between 0x30 and 0x37 */t/spa  
p240o2a>                if (*ta href="+code=reg" class="sref">rego2a> < 0x30 || *ta href="+code=reg" class="sref">rego2a> > 0x37) p241o2a>                        continue; p242o2a>                ta href="+code=index" class="sref">indexo2a> = *ta href="+code=reg" class="sref">rego2a> - 0x30; p243t/a> p244o2a>                tspa  class="comment">/* expect locaa>
  to be CPU [AB][01] ... */t/spa  
p245o2a>                if (ta href="+code=strncmp" class="sref">strncmpt/a>(ta href="+code=loc" class="sref">loct/a>, tspa  class="string">"CPU "p246o2a>                        continue; p247o2a>                ta href="+code=chip" class="sref">chipo2a> = ta href="+code=loc" class="sref">loct/a>[4] - tspa  class="string">'A'p248o2a>                ta href="+code=core" class="sref">coreo2a> = ta href="+code=loc" class="sref">loct/a>[5] - tspa  class="string">'0'p249o2a>                if (ta href="+code=chip" class="sref">chipo2a> > 1 || ta href="+code=core" class="sref">coreo2a> > 1) { p250o2a>                        ta href="+code=printk" class="sref">printkt/a>(ta href="+code=KERN_ERR" class="sref">KERN_ERRo2a> tspa  class="string">"wf_sat_create: d
 't understand "p251o2a>                               tspa  class="string">"locaa>
  %s for %s\n"loct/a>, ta href="+code=child" class="sref">childo2a>->ta href="+code=full_nam=" class="sref">full_nam=o2a>); p252o2a>                        continue; p253o2a>                } p254o2a>                ta href="+code=cpu" class="sref">cput/a> = 2 * ta href="+code=chip" class="sref">chipo2a> +pta href="+code=core" class="sref">coreo2a>; p255o2a>                if (ta href="+code=sat" class="sref">sato2a>->ta href="+code=nr" class="sref">nro2a> < 0) p256o2a>                        ta href="+code=sat" class="sref">sato2a>->ta href="+code=nr" class="sref">nro2a> = ta href="+code=chip" class="sref">chipo2a>; p257o2a>                else if (ta href="+code=sat" class="sref">sato2a>->ta href="+code=nr" class="sref">nro2a> != ta href="+code=chip" class="sref">chipo2a>) { p258o2a>                        ta href="+code=printk" class="sref">printkt/a>(ta href="+code=KERN_ERR" class="sref">KERN_ERRo2a> tspa  class="string">"wf_sat_create: ca 't cope with "p259o2a>                               tspa  class="string">"multiple CPU chips 
  one SAT (%s)\n"loct/a>); p260o2a>                        continue; p261o2a>                } p262o2a> p263o2a>                if (ta href="+code=strcmp" class="sref">strcmpt/a>(ta href="+code=type" class="sref">typeo2a>, tspa  class="string">"voltage-sensor"p264o2a>                        ta href="+code=nam=" class="sref">nam=o2a> = tspa  class="string">"cpu-voltage"p265o2a>                        ta href="+code=shift" class="sref">shifto2a> = 4; p266o2a>                        ta href="+code=vsens" class="sref">vsenso2a>[ta href="+code=core" class="sref">coreo2a>] = ta href="+code=index" class="sref">indexo2a>; p267o2a>                } else if (ta href="+code=strcmp" class="sref">strcmpt/a>(ta href="+code=type" class="sref">typeo2a>, tspa  class="string">"current-sensor"p268o2a>                        ta href="+code=nam=" class="sref">nam=o2a> = tspa  class="string">"cpu-current"p269o2a>                        ta href="+code=shift" class="sref">shifto2a> = 8; p270o2a>                        ta href="+code=isens" class="sref">isenso2a>[ta href="+code=core" class="sref">coreo2a>] = ta href="+code=index" class="sref">indexo2a>; p271o2a>                } else if (ta href="+code=strcmp" class="sref">strcmpt/a>(ta href="+code=type" class="sref">typeo2a>, tspa  class="string">"temp-sensor"p272o2a>                        ta href="+code=nam=" class="sref">nam=o2a> = tspa  class="string">"cpu-temp"p273o2a>                        ta href="+code=shift" class="sref">shifto2a> = 10; p274o2a>                } else p275o2a>                        continue;       tspa  class="comment">/* hmmm should 't happen */t/spa  
p276t/a> p277o2a>                tspa  class="comment">/* the +16 is enough for "cpu-voltage-n" */t/spa  
p278o2a>                ta href="+code=sens" class="sref">senso2a> = ta href="+code=kzalloc" class="sref">kzalloct/a>(sizeof(struct ta href="+code=wf_sat_sensor" class="sref">wf_sat_sensoro2a>) +p16, ta href="+code=GFP_KERNEL" class="sref">GFP_KERNELo2a>); p279o2a>                if (ta href="+code=sens" class="sref">senso2a> == ta href="+code=NULL" class="sref">NULLo2a>) { p280o2a>                        ta href="+code=printk" class="sref">printkt/a>(ta href="+code=KERN_ERR" class="sref">KERN_ERRo2a> tspa  class="string">"wf_sat_create: could 't create "p281o2a>                               tspa  class="string">"%s sensor %d (no memory)\n"nam=o2a>, ta href="+code=cpu" class="sref">cput/a>); p282o2a>                        continue; p283o2a>                } p284o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=index" class="sref">indexo2a> = ta href="+code=index" class="sref">indexo2a>; p285o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=index2" class="sref">index2o2a> = -1; p286o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=shift" class="sref">shifto2a> = ta href="+code=shift" class="sref">shifto2a>; p287o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=sat" class="sref">sato2a> = ta href="+code=sat" class="sref">sato2a>; p288o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=sens" class="sref">senso2a>.ta href="+code=ops" class="sref">opso2a> = &ta href="+code=wf_sat_ops" class="sref">wf_sat_opso2a>; p289o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=sens" class="sref">senso2a>.ta href="+code=nam=" class="sref">nam=o2a> = (char *) (ta href="+code=sens" class="sref">senso2a> +p1); p290o2a>                ta href="+code=snprintf" class="sref">snprintft/a>((char *)ta href="+code=sens" class="sref">senso2a>->ta href="+code=sens" class="sref">senso2a>.ta href="+code=nam=" class="sref">nam=o2a>,p16, tspa  class="string">"%s-%d"nam=o2a>, ta href="+code=cpu" class="sref">cput/a>); p291o2a> p292o2a>                if (ta href="+code=wf_register_sensor" class="sref">wf_register_sensort/a>(&ta href="+code=sens" class="sref">senso2a>->ta href="+code=sens" class="sref">senso2a>)) p293o2a>                        ta href="+code=kfree" class="sref">kfreet/a>(ta href="+code=sens" class="sref">senso2a>); p294o2a>                else { p295o2a>                        ta href="+code=list_add" class="sref">list_addt/a>(&ta href="+code=sens" class="sref">senso2a>->ta href="+code=link" class="sref">linko2a>, &ta href="+code=sat" class="sref">sato2a>->ta href="+code=sensors" class="sref">sensorso2a>); p296o2a>                        ta href="+code=kref_get" class="sref">kref_gett/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=ref" class="sref">refo2a>); p297o2a>                } p298o2a>        } p299t/a> p300o2a>        tspa  class="comment">/* make the power sensors */t/spa  
p301o2a>        for (ta href="+code=core" class="sref">coreo2a> = 0; ta href="+code=core" class="sref">coreo2a> < 2; ++ta href="+code=core" class="sref">coreo2a>) { p302o2a>                if (ta href="+code=vsens" class="sref">vsenso2a>[ta href="+code=core" class="sref">coreo2a>] < 0 || ta href="+code=isens" class="sref">isenso2a>[ta href="+code=core" class="sref">coreo2a>] < 0) p303o2a>                        continue; p304o2a>                ta href="+code=cpu" class="sref">cput/a> = 2 * ta href="+code=sat" class="sref">sato2a>->ta href="+code=nr" class="sref">nro2a> +pta href="+code=core" class="sref">coreo2a>; p305o2a>                ta href="+code=sens" class="sref">senso2a> = ta href="+code=kzalloc" class="sref">kzalloct/a>(sizeof(struct ta href="+code=wf_sat_sensor" class="sref">wf_sat_sensoro2a>) +p16, ta href="+code=GFP_KERNEL" class="sref">GFP_KERNELo2a>); p306o2a>                if (ta href="+code=sens" class="sref">senso2a> == ta href="+code=NULL" class="sref">NULLo2a>) { p307o2a>                        ta href="+code=printk" class="sref">printkt/a>(ta href="+code=KERN_ERR" class="sref">KERN_ERRo2a> tspa  class="string">"wf_sat_create: could 't create power "p308o2a>                               tspa  class="string">"sensor %d (no memory)\n"cput/a>); p309o2a>                        continue; p310o2a>                } p311o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=index" class="sref">indexo2a> = ta href="+code=vsens" class="sref">vsenso2a>[ta href="+code=core" class="sref">coreo2a>]; p312o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=index2" class="sref">index2o2a> = ta href="+code=isens" class="sref">isenso2a>[ta href="+code=core" class="sref">coreo2a>]; p313o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=shift" class="sref">shifto2a> = 0; p314o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=sat" class="sref">sato2a> = ta href="+code=sat" class="sref">sato2a>; p315o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=sens" class="sref">senso2a>.ta href="+code=ops" class="sref">opso2a> = &ta href="+code=wf_sat_ops" class="sref">wf_sat_opso2a>; p316o2a>                ta href="+code=sens" class="sref">senso2a>->ta href="+code=sens" class="sref">senso2a>.ta href="+code=nam=" class="sref">nam=o2a> = (char *) (ta href="+code=sens" class="sref">senso2a> +p1); p317o2a>                ta href="+code=snprintf" class="sref">snprintft/a>((char *)ta href="+code=sens" class="sref">senso2a>->ta href="+code=sens" class="sref">senso2a>.ta href="+code=nam=" class="sref">nam=o2a>,p16, tspa  class="string">"cpu-power-%d"cput/a>); p318t/a> p319o2a>                if (ta href="+code=wf_register_sensor" class="sref">wf_register_sensort/a>(&ta href="+code=sens" class="sref">senso2a>->ta href="+code=sens" class="sref">senso2a>)) p320o2a>                        ta href="+code=kfree" class="sref">kfreet/a>(ta href="+code=sens" class="sref">senso2a>); p321o2a>                else { p322o2a>                        ta href="+code=list_add" class="sref">list_addt/a>(&ta href="+code=sens" class="sref">senso2a>->ta href="+code=link" class="sref">linko2a>, &ta href="+code=sat" class="sref">sato2a>->ta href="+code=sensors" class="sref">sensorso2a>); p323o2a>                        ta href="+code=kref_get" class="sref">kref_gett/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=ref" class="sref">refo2a>); p324o2a>                } p325o2a>        } p326t/a> p327o2a>        if (ta href="+code=sat" class="sref">sato2a>->ta href="+code=nr" class="sref">nro2a> >= 0) p328o2a>                ta href="+code=sats" class="sref">satso2a>[ta href="+code=sat" class="sref">sato2a>->ta href="+code=nr" class="sref">nro2a>] = ta href="+code=sat" class="sref">sato2a>; p329t/a> p330o2a>        return 0; p331o2a>} p332o2a> p333o2a>static int ta href="+code=wf_sat_remove" class="sref">wf_sat_removet/a>(struct ta href="+code=i2c_client" class="sref">i2c_cliento2a> *ta href="+code=client" class="sref">cliento2a>) p334o2a>{ p335o2a>        struct ta href="+code=wf_sat" class="sref">wf_sato2a> *ta href="+code=sat" class="sref">sato2a> = ta href="+code=i2c_get_clientdata" class="sref">i2c_get_clientdatat/a>(ta href="+code=client" class="sref">cliento2a>); p336o2a>        struct ta href="+code=wf_sat_sensor" class="sref">wf_sat_sensoro2a> *ta href="+code=sens" class="sref">senso2a>; p337t/a> p338o2a>        tspa  class="comment">/* release sensors */t/spa  
p339o2a>        while(!ta href="+code=list_empty" class="sref">list_emptyt/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=sensors" class="sref">sensorso2a>)) { p340o2a>                ta href="+code=sens" class="sref">senso2a> = ta href="+code=list_first_entry" class="sref">list_first_entryt/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=sensors" class="sref">sensorso2a>, p341o2a>                                        struct ta href="+code=wf_sat_sensor" class="sref">wf_sat_sensoro2a>, ta href="+code=link" class="sref">linko2a>); p342o2a>                ta href="+code=list_del" class="sref">list_delt/a>(&ta href="+code=sens" class="sref">senso2a>->ta href="+code=link" class="sref">linko2a>); p343o2a>                ta href="+code=wf_unregister_sensor" class="sref">wf_unregister_sensort/a>(&ta href="+code=sens" class="sref">senso2a>->ta href="+code=sens" class="sref">senso2a>); p344o2a>        } p345o2a>        ta href="+code=sat" class="sref">sato2a>->ta href="+code=i2c" class="sref">i2co2a> = ta href="+code=NULL" class="sref">NULLo2a>; p346o2a>        ta href="+code=i2c_set_clientdata" class="sref">i2c_set_clientdatat/a>(ta href="+code=client" class="sref">cliento2a>, ta href="+code=NULL" class="sref">NULLo2a>); p347o2a>        ta href="+code=kref_put" class="sref">kref_putt/a>(&ta href="+code=sat" class="sref">sato2a>->ta href="+code=ref" class="sref">refo2a>, ta href="+code=wf_sat_release" class="sref">wf_sat_releaset/a>); p348t/a> p349o2a>        return 0; p350o2a>} p351o2a> p352o2a>static const struct ta href="+code=i2c_device_id" class="sref">i2c_device_ido2a> ta href="+code=wf_sat_id" class="sref">wf_sat_ido2a>[] = { p353o2a>        { tspa  class="string">"MbC,smush/windfarm_smu_satlass="sref">satso2a>[ta href="+code= nam="iverso; [ta href="+code= nam="iverso; ); p236o2a>3      ="+code=wf_sat_MODULE_DEVICE_TABLE="sref">wf_sat_MODULE_DEVICE_TABLE href="+code=client"ass="sref">i2co2a> = ta hef="+code=wf_sat_releasess="sref">wf_sat_ido2a>[] = { ref="drivers/macintosh/windfarm_smu_sat.c#L348" id"vL257" cl3ss="line" nam="vL257">p237o2a>35a href="drivers/macintosh/windfarm_smu_sat.c#L338" id"vL258" cl3ss="line" nam="vL258">p238o2a>3      const sta href="+code=i2c_device_imacin="sref">i2c_device_imacin href="+code=wf_sat_id" claimacin="sref">i2c_devid" claimacinta hrefef="drivers/macintosh/windfarm_smu_sat.c#L353" id"vL349" class="line" nam="vL259">p239o2a>3              f="+code=nam=" cimacin="sref">i2c_devimacinta hrefef="drivers/macintosh/windfarm_smu_sat.c#L353" id"vL260" cl3ss="line" nam="vL260">p230o2a>3                      f="+code=nam=" class="sref">nam=o2a> = (charrrrrrrrrrr class="string">"cpu-temid" c#L353_smu_satlass="f="drivers/macintosh/windfarm_smu_sat.c#L353" id"vL351" class="line" nam="vL261">p231o2a>3              f">satso2a>[ta href="+code= nam="iverso; p232o2a>362            f="+code=nam=" cprobs="sref">nam=o2aprobs(charrrrrrrrrref="+code=NULL" cid" claprobs="sref">nam=o2aid" claprobsa href="drivers/macintosh/windfarm_smu_sat.c#L341" id"vL263" cl3ss="line" nam="vL263">p233o2a>3              f="+code=nam=" c class="sref">wf_sat_/a>(structrrrrrrrrref="+code=NULL" cid" cla class="sref">wf_sat_removet/a>(structef="drivers/macintosh/windfarm_smu_sat.c#L341" id"vstring="dss="line" nam="vL264">p234o2a>3              f="+code=nam=" cid_tabls="sref">wf_sat_id_tabls           ef="+code=NULL" cid" clauEode=sat" pa  ,642code             f="n); shifto2a> = 4; indexo2a>; 3       modul2a>" id"vL258" cl3ss="line"modul2a>" id"vL25236o2a>3      ="+codnst sta href="+code=i2c_device_imacin="sref">nt"ass="sref">i2co2a> = ta hef="+code=wf_sat_releasnsor"3i2co2a> = ta hef="+code=wf_sat_releaslass="sre3">shifto2a> = 8; 3                      fSMU t_rellit8" class="indfPef="Mac300"rmal.c#L3rol="+code=type" t"ass="sref">i2co2a> = ta hef="+code=wf_sat_releasl;cpu-temisref">indexo2a>; 3                      fGPL="+code=type" t"ass="sref">i2co2a> = ta hef="+code=wf_sat_releaslvL261">p2


The original.LXR softwvL239y300" ass="srefhttp://sourceindge.net/projects/lx=">LXR at.cuni39">p3,300linexperic#L3al.2co251">9y3ass="srefmailto:lx=@ 0)ux.no">lx=@ 0)ux.no">p3. lx=. 0)ux.no k"+cly hosted>9y3ass="srefhttp://www.redpill- 0)pro.no">Redpill L0)pro AS">p3,3provider of L0)ux/wind"vL2ng ass=L251"81">r52o281"ince 1995.