linux/lib/crc8.c
<<
v4925/spa="v 925/form"v 925a v492 href="../linux+v3.9.2/lib/crc8.c"> v4925img src="../.static/gfx/right.png" alt=">>"> 5/spa="v 5spa= class="lxr_search"> v4 v4925input typ.39hidden" nam.39navtarget" v4.39"> v4925input typ.39text" nam.39search" id39search"> v4925butt > typ.39submit">Search"v 925/form"v 5/spa="v 5spa= class="lxr_prefs""v 925a href="+prefs?return=lib/crc8.c" v492 onclick="return ajax_prefs();"> v492Prefsv 925/a> 5/spa="vv492 25/div"vv492 25form aclue=="ajax+*" method="post" onsubmit="return false;"> 5input typ.39hidden" nam.39ajax_lookup" id39ajax_lookup" v4.39"> v492 25/form"v v492 25div class="headingbott m">v 5div id39file_contents""
2 215/a>5spa= class="comment">/*5/spa="v2 225/a>5spa= class="comment"> * Copyright (c) 2011 Broadcom Corporalue=5/spa="v2 235/a>5spa= class="comment"> *5/spa="v2 245/a>5spa= class="comment"> * Permiss  >
to use, " nam.39L4">2 245/a>5spa= class="cU2175aifU21and/or distrispae en"  softwab4bgbo1any id39L4" class="line" nam.39L5">2 2455a>5spa= class="comment5> * P5rmiss  >
to use, " nam.39L4">purc8se with bo1withokupfee "  hereby gra2/4d, provided enaup"he above id39L4" class="line" nam.39L6">2 2456a>5spa= class="comment6> * P6rmiss  >
to use, " nam.39L4">coralue=5/no;">e1and en"  p 245/a>5spno;">e1appv
5 i25/ll>cories. id39L4" class="line" nam.39L7">2 2457a>5spa= class="comment7> * P7pa="v2 2458a>5spa= class="comment8> * P8rmiss  >
to use, " nam.39L4">THE SOFTWARE IS PROVIDED "AS IS" AND>THE AUTHOR DISCLAIMS ALL WARRANTIES id39L4" class="line" nam.39L9">2 2459a>5spa= class="comment9> * P9rmiss  >
to use, " nam.39L4">WITH REGARD>TO>THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF id39L4" class="line" nam.39L10">2 215/0a>5spa= class="comment"0> * .12
iss  >
to use, " nam.39L4">MERCHANTABILITY AND>FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY id39L4" class="line" nam.39L11">2 215//a>5spa= class="comment"">/*51spa="vSPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES id39L4" class="line" nam.39L12">2 2251/a>5spa= class="comment1"> * 1opyright (c) 2011 Broadcom CorWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,rWHETHER IN AN ACTION id39L4" class="line" nam.39L13">2 2351/a>5spa= class="comment1"> *51spa="v2 2451/a>5spa= class="comment1"> * 1ermiss  >
to use, " nam.39L4">CONNECTION>WITH THE USE OR PERFORMANCE OF>THIS SOFTWARE. id39L4" class="line" nam.39L15">2 24515a>5spa= class="comment15> * 15rmiss  >
to use, " nam.39L4"/ id39L4" class="line" nam.39L16">2 24516a>5spa= class="comment16> * 16rmis" class="line" nam.39L17">2 24517a>5spa= class="comment17> * 17pa="#defass8.c"  v492 code=pr_fmt92 25/div" v4">pr_fmtpa="(.c"  v492 code=fmt92 25/div" v4">fmtpa=")             .c"  v492 code=KBUILD_MODNAME92 25/div" v4">KBUILD_MODNAMEpa=" s  >
to use, stri"v >": " id39L4 .c"  v492 code=fmt92 25/div" v4">fmtpa="" class="line" nam.39L18">2 24518a>5spa= class="comment18> * 18pa="" class="line" nam.39L19">2 24519a>5spa= class="comment19> * 19rmis#i v4ude < class="li v4ude25img /75aule.ha>5spa= cf v4">5img /75aule.hrmisss="" class="line" nam.39L20">2 21520a>5spa= class="comment20> * 20rmis#i v4ude < class="li v4ude25img / nam.ha>5spa= cf v4">5img / nam.hrmisss="" class="line" nam.39L21">2 2152/a>5spa= class="comment2">/*521rmis#i v4ude < class="li v4ude25img /pri"tk.ha>5spa= cf v4">5img /pri"tk.hrmisss="" class="line" nam.39L22">2 225//a>5spa= class="comment""> * 22pa="" class="line" nam.39L23">2 2352/a>5spa= class="comment2"> *52spa="v2 2452/a>5spa= class="comment2"> * 2ermiss  >
to use, " nam.39L4"> nam_populate_msb - " il> na tabl4bgbo1given polynomial i25reverse bit boder. id39L4" class="line" nam.39L25">2 24525a>5spa= class="comment25> * 25rmiss  >
to use, " nam.39L4" id39L4" class="line" nam.39L26">2 24526a>5spa= class="comment26> * 26rmiss  >
to use, " nam.39L4">tabl4:       tabl4ba= be " iled. id39L4" class="line" nam.39L27">2 24527a>5spa= class="comment27> * 27pa="v2 24528a>5spa= class="comment28> * 28rmiss  >
to use, " nam.39L4"/ id39L4" class="line" nam.39L29">2 24529a>5spa= class="comment29> * 29rmisvoid .c"  v492 code= nam_populate_msb92 25/div" v4"> nam_populate_msbpa="(.c"  v492 code=u892 25/div" v4">u8pa=" sc"  v492 code=tabl492 25/div" v4">tabl4pa="[sc"  v492 code=CRC8_TABLE_SIZE92 25/div" v4">CRC8_TABLE_SIZEpa="], sc"  v492 code=u892 25/div" v4">u8pa=" sc"  v492 code=polynomial92 25/div" v4">polynomialpa=")" class="line" nam.39L30">2 21530a>5spa= class="comment30> * 30rmis{" class="line" nam.39L31">2 2153/a>5spa= class="comment3">/*531rmis        i"t sc"  v492 code=i92 25/div" v4">irmis, sc"  v492 code=j92 25/div" v4">jrmis"" class="line" nam.39L32">2 2253/a>5spa= class="comment3"> * 32rmis        const sc"  v492 code=u892 25/div" v4">u8pa=" sc"  v492 code=msbit92 25/div" v4">msbitpa=" = 0x80"" class="line" nam.39L33">2 235//a>5spa= class="comment""> *533rmis        .c"  v492 code=u892 25/div" v4">u8pa=" sc"  v492 code=t92 25/div" v4">tpa=" = sc"  v492 code=msbit92 25/div" v4">msbitpa=""" class="line" nam.39L34">2 2453/a>5spa= class="comment3"> * 34pa="" class="line" nam.39L35">2 24535a>5spa= class="comment35> * 35rmis        .c"  v492 code=tabl492 25/div" v4">tabl4pa="[0] = 0"" class="line" nam.39L36">2 24536a>5spa= class="comment36> * 36rmis" class="line" nam.39L37">2 24537a>5spa= class="comment37> * 37rmis        gbo1(.c"  v492 code=i92 25/div" v4">irmis = 1; sc"  v492 code=i92 25/div" v4">irmis < sc"  v492 code=CRC8_TABLE_SIZE92 25/div" v4">CRC8_TABLE_SIZEpa="; sc"  v492 code=i92 25/div" v4">irmis *= 2) {" class="line" nam.39L38">2 24538a>5spa= class="comment38> * 38rmis                .c"  v492 code=t92 25/div" v4">tpa=" = (.c"  v492 code=t92 25/div" v4">tpa=" << 1) ^ (.c"  v492 code=t92 25/div" v4">tpa=" & sc"  v492 code=msbit92 25/div" v4">msbitpa=" ? sc"  v492 code=polynomial92 25/div" v4">polynomialpa=" : 0)"" class="line" nam.39L39">2 24539a>5spa= class="comment39> * 39rmis                gbo1(.c"  v492 code=j92 25/div" v4">jrmis = 0" sc"  v492 code=j92 25/div" v4">jrmis < sc"  v492 code=i92 25/div" v4">irmis" sc"  v492 code=j92 25/div" v4">jrmis++)" class="line" nam.39L40">2 21540a>5spa= class="comment40> * 40rmis                        .c"  v492 code=tabl492 25/div" v4">tabl4pa="[sc"  v492 code=i92 25/div" v4">irmis+sc"  v492 code=j92 25/div" v4">jrmis] = sc"  v492 code=tabl492 25/div" v4">tabl4pa="[sc"  v492 code=j92 25/div" v4">jrmis] ^ .c"  v492 code=t92 25/div" v4">tpa=""" class="line" nam.39L41">2 2154/a>5spa= class="comment4">/*541rmis        }" class="line" nam.39L42">2 2254/a>5spa= class="comment4"> * 42rmis}" class="line" nam.39L43">2 2354/a>5spa= class="comment4"> *54spa="vc"  v492 code=EXPORT_SYMBOL92 25/div" v4">EXPORT_SYMBOLpa="(.c"  v492 code= nam_populate_msb92 25/div" v4"> nam_populate_msbpa=")"" class="line" nam.39L44">2 245//a>5spa= class="comment""> * 44pa="" class="line" nam.39L45">2 24545a>5spa= class="comment45> * 45rmiss  >
to use, " nam.39L2" id39L2" class="line" nam.39L46">2 24546a>5spa= class="comment46> * 46rmiss  >
to use, " nam.39L4">cnam_populate_lsb - " il> na tabl4bgbo1given polynomial i25regular bit boder. id39L4" class="line" nam.39L47">2 24547a>5spa= class="comment47> * 47pa="v2 24548a>5spa= class="comment48> * 48rmiss  >
to use, " nam.39L4">tabl4:       tabl4ba= be " iled. id39L4" class="line" nam.39L49">2 24549a>5spa= class="comment49> * 49rmiss  >
to use, " nam.39L4">polynomial:  polynomial gbo1which tabl4b"  a= be " iled. id39L4" class="line" nam.39L50">2 21550a>5spa= class="comment50> * 512
iss  >
to use, " nam.39L4"/ id39L4" class="line" nam.39L51">2 2155/a>5spa= class="comment5">/*551rmisvoid .c"  v492 code= nam_populate_lsb92 25/div" v4"> nam_populate_lsbpa="(.c"  v492 code=u892 25/div" v4">u8pa=" sc"  v492 code=tabl492 25/div" v4">tabl4pa="[sc"  v492 code=CRC8_TABLE_SIZE92 25/div" v4">CRC8_TABLE_SIZEpa="], sc"  v492 code=u892 25/div" v4">u8pa=" sc"  v492 code=polynomial92 25/div" v4">polynomialpa=")" class="line" nam.39L52">2 2255/a>5spa= class="comment5"> * 52rmis{" class="line" nam.39L53">2 2355/a>5spa= class="comment5"> *553rmis        i"t sc"  v492 code=i92 25/div" v4">irmis, sc"  v492 code=j92 25/div" v4">jrmis"" class="line" nam.39L54">2 2455/a>5spa= class="comment5"> * 54rmis        .c"  v492 code=u892 25/div" v4">u8pa=" sc"  v492 code=t92 25/div" v4">tpa=" = 1"" class="line" nam.39L55">2 24555a>5spa= class="comment55> * 55pa="" class="line" nam.39L56">2 24556a>5spa= class="comment56> * 56rmis        .c"  v492 code=tabl492 25/div" v4">tabl4pa="[0] = 0"" class="line" nam.39L57">2 24557a>5spa= class="comment57> * 57pa="" class="line" nam.39L58">2 24558a>5spa= class="comment58> * 58rmis        gbo1(.c"  v492 code=i92 25/div" v4">irmis = (.c"  v492 code=CRC8_TABLE_SIZE92 25/div" v4">CRC8_TABLE_SIZEpa="  class=" 1); sc"  v492 code=i92 25/div" v4">irmis" sc"  v492 code=i92 25/div" v4">irmis &class="= 1) {" class="line" nam.39L59">2 24559a>5spa= class="comment59> * 59rmis                .c"  v492 code=t92 25/div" v4">tpa=" = (.c"  v492 code=t92 25/div" v4">tpa=" &class=" 1) ^ (.c"  v492 code=t92 25/div" v4">tpa=" & 1 ? sc"  v492 code=polynomial92 25/div" v4">polynomialpa=" : 0)"" class="line" nam.39L60">2 21560a>5spa= class="comment60> * 60rmis                gbo1(.c"  v492 code=j92 25/div" v4">jrmis = 0" sc"  v492 code=j92 25/div" v4">jrmis < sc"  v492 code=CRC8_TABLE_SIZE92 25/div" v4">CRC8_TABLE_SIZEpa="; sc"  v492 code=j92 25/div" v4">jrmis += 2*sc"  v492 code=i92 25/div" v4">irmis)" class="line" nam.39L61">2 2156/a>5spa= class="comment6">/*561rmis                        .c"  v492 code=tabl492 25/div" v4">tabl4pa="[sc"  v492 code=i92 25/div" v4">irmis+sc"  v492 code=j92 25/div" v4">jrmis] = sc"  v492 code=tabl492 25/div" v4">tabl4pa="[sc"  v492 code=j92 25/div" v4">jrmis] ^ .c"  v492 code=t92 25/div" v4">tpa=""" class="line" nam.39L62">2 2256/a>5spa= class="comment6"> * 62rmis        }" class="line" nam.39L63">2 2356/a>5spa= class="comment6"> *563rmis}" class="line" nam.39L64">2 2456/a>5spa= class="comment6"> * 64pa="vc"  v492 code=EXPORT_SYMBOL92 25/div" v4">EXPORT_SYMBOLpa="(.c"  v492 code= nam_populate_lsb92 25/div" v4"> nam_populate_lsbpa=")"" class="line" nam.39L65">2 24565a>5spa= class="comment65> * 65pa="" class="line" nam.39L66">2 24566a>5spa= class="comment66> * 66rmiss  >
to use, " nam.39L2" id39L2" class="line" nam.39L67">2 24567a>5spa= class="comment67> * 67pa="v2 24568a>5spa= class="comment68> * 68rmiss  >
to use, " nam.39L4" id39L4" class="line" nam.39L69">2 24569a>5spa= class="comment69> * 69rmiss  >
to use, " nam.39L4">tabl4:  na tabl4bused gbo1calculation. id39L4" class="line" nam.39L70">2 21570a>5spa= class="comment70> * 712
iss  >
to use, " nam.39L4">pdata: poi"terp"opdata buffer. id39L4" class="line" nam.39L71">2 2157/a>5spa= class="comment7">/*57spa="vnbytes: numberpof bytes i25data buffer. id39L4" class="line" nam.39L72">2 2257/a>5spa= class="comment7"> * 7opyright (c) 2011 Broadcom Cor na: previous idden"ed  nam 5div . id39L4" class="line" nam.39L73">2 2357/a>5spa= class="comment7"> *57spa="v2 2457/a>5spa= class="comment7"> * 74pa="vc"  v492 code=u892 25/div" v4">u8pa=" sc"  v492 code= nam92 25/div" v4"> nampa="(const sc"  v492 code=u892 25/div" v4">u8pa=" sc"  v492 code=tabl492 25/div" v4">tabl4pa="[sc"  v492 code=CRC8_TABLE_SIZE92 25/div" v4">CRC8_TABLE_SIZEpa="], sc"  v492 code=u892 25/div" v4">u8pa=" *sc"  v492 code=pdata92 25/div" v4">pdatarmis, sc"  v492 code=size_t92 25/div" v4">size_tpa=" sc"  v492 code=nbytes92 25/div" v4">nbytesrmis, sc"  v492 code=u892 25/div" v4">u8pa=" sc"  v492 code= na92 25/div" v4"> narmis)" class="line" nam.39L75">2 24575a>5spa= class="comment75> * 75rmis{" class="line" nam.39L76">2 24576a>5spa= class="comment76> * 76rmis        .  >
to use, " nam.39L2" loop overp"he buffer5data "/ id39L4" class="line" nam.39L77">2 24577a>5spa= class="comment77> * 77rmis        whil4b(.c"  v492 code=nbytes92 25/div" v4">nbytesrmis-- &cla 0)" class="line" nam.39L78">2 24578a>5spa= class="comment78> * 78rmis                .c"  v492 code= na92 25/div" v4"> narmis = sc"  v492 code=tabl492 25/div" v4">tabl4pa="[(.c"  v492 code= na92 25/div" v4"> narmis ^ *sc"  v492 code=pdata92 25/div" v4">pdatarmis++) & 0xff]"" class="line" nam.39L79">2 24579a>5spa= class="comment79> * 79pa="" class="line" nam.39L80">2 21580a>5spa= class="comment80> * 80rmis        idden" .c"  v492 code= na92 25/div" v4"> narmis"" class="line" nam.39L81">2 2158/a>5spa= class="comment8">/*581rmis}" class="line" nam.39L82">2 2258/a>5spa= class="comment8"> * 82pa="vc"  v492 code=EXPORT_SYMBOL92 25/div" v4">EXPORT_SYMBOLpa="(.c"  v492 code= nam92 25/div" v4"> nampa=")"" class="line" nam.39L83">2 2358/a>5spa= class="comment8"> *583pa="" class="line" nam.39L84">2 2458/a>5spa= class="comment8"> * 84pa="vc"  v492 code=MODULE_DESCRIPTION92 25/div" v4">MODULE_DESCRIPTIONpa="(.  >
to use, stri"v >"CRC8 (by Williams, Ross N.) funsubmi" id39L4)"" class="line" nam.39L85">2 24585a>5spa= class="comment85> * 85pa="vc"  v492 code=MODULE_AUTHOR92 25/div" v4">MODULE_AUTHORpa="(.  >
to use, stri"v >"href="lib/crc8.c#L3"" id39L4)"" class="line" nam.39L86">2 24586a>5spa= class="comment86> * 86pa="vc"  v492 code=MODULE_LICENSE92 25/div" v4">MODULE_LICENSEpa="(.  >
to use, stri"v >"Dual BSD/GPL" id39L4)"" class="line" nam.39L87">2 24587a>5spa= class="comment87> * 87pa="v/prev id39se

v id39file_co5spa= cfooter">
The original LXR softwab4bby "he  class="lhttp://sourcegboge.net/projects/lxr">LXR " naunityrmis, en"  experiam.3al vers>5spby  class="lmailto:lxr@5img .no">lxr@5img .normis.
v id39fle_co5spa= csubfooter">
lxr.5img .no kindly hosted by  class="lhttp://www.redpill-5impro.no">Redpill Limpro ASrmis, providerpof Limg  consulti"v1and operc#L3"s services since 1995.
v id39fil/body9fl/htmlse