linux/drivers/rtc/rtc-hid-sensor-time.c
<<
val3.4/spa > 3.4/form> 3.4a val3. href="../linux+v33.4.2/drivers/rtc/rtc-hid-sensor-time.c"> val3.4img src="../.static/gfx/right.png" alt=">>"> v4/spa > v4spa class="lxr_search"> val val3.4input typ> hidden" nam> navtarget" tion> "> val3.4input typ> text" nam> search" id search"> val3.4butt/optyp> submit">Search 3.4/form> 4/spa > v4spa class="lxr_prefs"> 3.4a href="+prefs?return=drivers/rtc/rtc-hid-sensor-time.c" val3. onclick="return ajax_prefs();"> val3.Prefs 3.4/a> v4/spa > al3. .4/div> al3. .4form ac ="ajax+*" method="post" onsubmit="return false;"> v4input typ> hidden" nam> ajax_lookup" id ajax_lookup" tion> "> al3. .4/form> al3. .4div class="headingbott/m">
al3.
al3. 3. .4div id search_results" class="search_results" 3> al3. .4/div> 4div id content"> 4div id file_contents">

 L1">. .14/a>4spa  class="comment">/*4/spa >

 L2">. .24/a>4spa  class="comment"> * HID Sensor Time Driver4/spa >

 L3">. .34/a>4spa  class="comment"> * Copyright (c) 2012, Alexander Holler.4/spa >

 L4">. .44/a>4spa  class="comment"> *4/spa >

 L5">. .54/a>4spa  class="comment"> * This program is free software; you ca  redistribute it and/or modify it4/spa >

 L6">. .64/a>4spa  class="comment"> * under the terms and condi
	  s of the GNU General Public License,4/spa >

 L7">. .74/a>4spa  class="comment"> * vers

 L8">. .84/a>4spa  class="comment"> *4/spa >

 L9">. .94/a>4spa  class="comment"> * This program is distributed in the hope it will be useful, but WITHOUT4/spa >

 L10">. .8"
a>4spa  class="comment"> * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or4/spa >

 L11">. 114/a>4spa  class="comment"> * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for4/spa >

 L12">. 124/a>4spa  class="comment"> * more details.4/spa >

 L13">. 134/a>4spa  class="comment"> *4/spa >

 L14">. 144/a>4spa  class="comment"> * You should have received a copy of the GNU General Public License along with4/spa >

 L15">. 154/a>4spa  class="comment"> * this program; if not, write to the Free Software Founda
	  , Inc.,4/spa >

 L16">. 164/a>4spa  class="comment"> * 51 Franklin St - Fifth Floor, Bost  , MA 02110-1301 USA.4/spa >

 L17">. 174/a>4spa  class="comment"> *4/spa >

 L18">. 184/a>4spa  class="comment"> */4/spa >

 L19">. 194/a>#include <linux/device.h4/a>>

 L20">. 204/a>#include <linux/platform_device.h4/a>>

 L21">. 214/a>#include <linux/module.h4/a>>

 L22">. 224/a>#include <linux/hid-sensor-hub.h4/a>>

 L23">. 234/a>#include <linux/iio/iio.h4/a>>

 L24">. 244/a>#include <linux/rtc.h4/a>>

 L25">. 254/a>

 L26">. 264/a>4spa  class="comment">/* Format: HID-SENSOR-usage_id_in_hex */4/spa >

 L27">. 274/a>4spa  class="comment">/* Usage ID from spec for Time: 0x2000A0 */4/spa >

 L28">. 284/a>#define.4a href="+code=DRIVER_NAME" class="sref">DRIVER_NAME4/a> 4spa  class="string">"HID-SENSOR-2000a0"4/spa > 4spa  class="comment">/* must be lowercase */4/spa >

 L29">. 294/a>

 L30">. 304/a>enum.4a href="+code=hid_time_channel" class="sref">hid_time_channel4/a> {

 L31">. 314/a>        4a href="+code=CHANNEL_SCAN_INDEX_YEAR" class="sref">CHANNEL_SCAN_INDEX_YEAR4/a>,

 L32">. 324/a>        4a href="+code=CHANNEL_SCAN_INDEX_MONTH" class="sref">CHANNEL_SCAN_INDEX_MONTH4/a>,

 L33">. 334/a>        4a href="+code=CHANNEL_SCAN_INDEX_DAY" class="sref">CHANNEL_SCAN_INDEX_DAY4/a>,

 L34">. 344/a>        4a href="+code=CHANNEL_SCAN_INDEX_HOUR" class="sref">CHANNEL_SCAN_INDEX_HOUR4/a>,

 L35">. 354/a>        4a href="+code=CHANNEL_SCAN_INDEX_MINUTE" class="sref">CHANNEL_SCAN_INDEX_MINUTE4/a>,

 L36">. 364/a>        4a href="+code=CHANNEL_SCAN_INDEX_SECOND" class="sref">CHANNEL_SCAN_INDEX_SECOND4/a>,

 L37">. 374/a>        4a href="+code=TIME_RTC_CHANNEL_MAX" class="sref">TIME_RTC_CHANNEL_MAX4/a>,

 L38">. 384/a>};

 L39">. 394/a>

 L40">. 404/a>struct.4a href="+code=hid_time_state" class="sref">hid_time_state4/a> {

 L41">. 414/a>        struct.4a href="+code=hid_sensor_hub_callbacks" class="sref">hid_sensor_hub_callbacks4/a> 4a href="+code=callbacks" class="sref">callbacks4/a>;

 L42">. 424/a>        struct.4a href="+code=hid_sensor_common" class="sref">hid_sensor_common4/a> 4a href="+code=common_attributes" class="sref">common_attributes4/a>;

 L43">. 434/a>        struct.4a href="+code=hid_sensor_hub_attribute_info" class="sref">hid_sensor_hub_attribute_info4/a> 4a href="+code=info" class="sref">info4/a>[4a href="+code=TIME_RTC_CHANNEL_MAX" class="sref">TIME_RTC_CHANNEL_MAX4/a>];

 L44">. 444/a>        struct.4a href="+code=rtc_time" class="sref">rtc_time4/a> 4a href="+code=last_time" class="sref">last_time4/a>;

 L45">. 454/a>        4a href="+code=spinlock_t" class="sref">spinlock_t4/a> 4a href="+code=lock_last_time" class="sref">lock_last_time4/a>;

 L46">. 464/a>        struct.4a href="+code=comple
	  " class="sref">comple
	  4/a> 4a href="+code=comp_last_time" class="sref">comp_last_time4/a>;

 L47">. 474/a>        struct.4a href="+code=rtc_time" class="sref">rtc_time4/a> 4a href="+code=time_buf" class="sref">time_buf4/a>;

 L48">. 484/a>        struct.4a href="+code=rtc_device" class="sref">rtc_device4/a> *4a href="+code=rtc" class="sref">rtc4/a>;

 L49">. 494/a>};

 L50">. 504/a>

 L51">. 514/a>static const.4a href="+code=u32" class="sref">u324/a> 4a href="+code=hid_time_addresses" class="sref">hid_time_addresses4/a>[4a href="+code=TIME_RTC_CHANNEL_MAX" class="sref">TIME_RTC_CHANNEL_MAX4/a>] = {

 L52">. 524/a>        4a href="+code=HID_USAGE_SENSOR_TIME_YEAR" class="sref">HID_USAGE_SENSOR_TIME_YEAR4/a>,

 L53">. 534/a>        4a href="+code=HID_USAGE_SENSOR_TIME_MONTH" class="sref">HID_USAGE_SENSOR_TIME_MONTH4/a>,

 L54">. 544/a>        4a href="+code=HID_USAGE_SENSOR_TIME_DAY" class="sref">HID_USAGE_SENSOR_TIME_DAY4/a>,

 L55">. 554/a>        4a href="+code=HID_USAGE_SENSOR_TIME_HOUR" class="sref">HID_USAGE_SENSOR_TIME_HOUR4/a>,

 L56">. 564/a>        4a href="+code=HID_USAGE_SENSOR_TIME_MINUTE" class="sref">HID_USAGE_SENSOR_TIME_MINUTE4/a>,

 L57">. 574/a>        4a href="+code=HID_USAGE_SENSOR_TIME_SECOND" class="sref">HID_USAGE_SENSOR_TIME_SECOND4/a>,

 L58">. 584/a>};

 L59">. 594/a>

 L60">. 68"
a>4spa  class="comment">/* Channel nam>s for verbose error messag>s */4/spa >

 L61">. 614/a>static const.char * const.4a href="+code=hid_time_channel_nam>s" class="sref">hid_time_channel_nam>s4/a>[4a href="+code=TIME_RTC_CHANNEL_MAX" class="sref">TIME_RTC_CHANNEL_MAX4/a>] = {

 L62">. 624/a>        4spa  class="string">"year"4/spa >, 4spa  class="string">"month"4/spa >, 4spa  class="string">"day"4/spa >, 4spa  class="string">"hour"4/spa >, 4spa  class="string">"minute"4/spa >, 4spa  class="string">"second"4/spa >,

 L63">. 634/a>};

 L64">. 644/a>

 L65">. 654/a>4spa  class="comment">/* Callback handler to send event after all samples are received and captured */4/spa >

 L66">. 664/a>static int.4a href="+code=hid_time_proc_event" class="sref">hid_time_proc_event4/a>(struct.4a href="+code=hid_sensor_hub_device" class="sref">hid_sensor_hub_device4/a> *4a href="+code=hsdev" class="sref">hsdev4/a>,

 L67">. 674/a>                                unsigned 4a href="+code=usage_id" class="sref">usage_id4/a>, void *4a href="+code=priv" class="sref">priv4/a>)

 L68">. 684/a>{

 L69">. 694/a>        unsigned long 4a href="+code=flags" class="sref">flags4/a>;

 L70">. 704/a>        struct.4a href="+code=hid_time_state" class="sref">hid_time_state4/a> *4a href="+code=time_state" class="sref">time_state4/a> =.4a href="+code=platform_get_drvdata" class="sref">platform_get_drvdata4/a>(4a href="+code=priv" class="sref">priv4/a>);

 L71">. 714/a>

 L72">. 724/a>        4a href="+code=spin_lock_irqsave" class="sref">spin_lock_irqsave4/a>(&4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=lock_last_time" class="sref">lock_last_time4/a>, 4a href="+code=flags" class="sref">flags4/a>);

 L73">. 734/a>        4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=last_time" class="sref">last_time4/a> =.4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=time_buf" class="sref">time_buf4/a>;

 L74">. 744/a>        4a href="+code=spin_unlock_irqrestore" class="sref">spin_unlock_irqrestore4/a>(&4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=lock_last_time" class="sref">lock_last_time4/a>, 4a href="+code=flags" class="sref">flags4/a>);

 L75">. 754/a>        4a href="+code=comple
e" class="sref">comple
e4/a>(&4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=comp_last_time" class="sref">comp_last_time4/a>);

 L76">. 764/a>        return 0;

 L77">. 774/a>}

 L78">. 784/a>

 L79">. 794/a>static 4a href="+code=u32" class="sref">u324/a> 4a href="+code=hid_time_tion>" class="sref">hid_time_tion>4/a>(4a href="+code=size_t" class="sref">size_t4/a> 4a href="+code=raw_le " class="sref">raw_le 4/a>, char *4a href="+code=raw_data" class="sref">raw_data4/a>)

 L80">. 804/a>{

 L81">. 814/a>        switch (4a href="+code=raw_le " class="sref">raw_le 4/a>) {

 L82">. 824/a>        case 1:

 L83">. 834/a>                return *(4a href="+code=u8" class="sref">u84/a> *)4a href="+code=raw_data" class="sref">raw_data4/a>;

 L84">. 844/a>        case 2:

 L85">. 854/a>                return *(4a href="+code=u16" class="sref">u164/a> *)4a href="+code=raw_data" class="sref">raw_data4/a>;

 L86">. 864/a>        case 4:

 L87">. 874/a>                return *(4a href="+code=u32" class="sref">u324/a> *)4a href="+code=raw_data" class="sref">raw_data4/a>;

 L88">. 884/a>        default:

 L89">. 894/a>                return (4a href="+code=u32" class="sref">u324/a>)(~0U); 4spa  class="comment">/* 0xff... or -1 to denote a  error */4/spa >

 L90">. 904/a>        }

 L91">. 914/a>}

 L92">. 924/a>

 L93">. 934/a>static int.4a href="+code=hid_time_capture_sample" class="sref">hid_time_capture_sample4/a>(struct.4a href="+code=hid_sensor_hub_device" class="sref">hid_sensor_hub_device4/a> *4a href="+code=hsdev" class="sref">hsdev4/a>,

 L94">. 944/a>                                unsigned 4a href="+code=usage_id" class="sref">usage_id4/a>, 4a href="+code=size_t" class="sref">size_t4/a> 4a href="+code=raw_le " class="sref">raw_le 4/a>,

 L95">. 954/a>                                char *4a href="+code=raw_data" class="sref">raw_data4/a>, void *4a href="+code=priv" class="sref">priv4/a>)

 L96">. 964/a>{

 L97">. 974/a>        struct.4a href="+code=hid_time_state" class="sref">hid_time_state4/a> *4a href="+code=time_state" class="sref">time_state4/a> =.4a href="+code=platform_get_drvdata" class="sref">platform_get_drvdata4/a>(4a href="+code=priv" class="sref">priv4/a>);

 L98">. 984/a>        struct.4a href="+code=rtc_time" class="sref">rtc_time4/a> *4a href="+code=time_buf" class="sref">time_buf4/a> =.&4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=time_buf" class="sref">time_buf4/a>;

 L99">. 994/a>

 L100">.1004/a>        switch (4a href="+code=usage_id" class="sref">usage_id4/a>) {

 L101">.1014/a>        case 4a href="+code=HID_USAGE_SENSOR_TIME_YEAR" class="sref">HID_USAGE_SENSOR_TIME_YEAR4/a>:

 L102">.1024/a>                4spa  class="comment">/*4/spa >

 L103">.1034/a>4spa  class="comment">                 * The draft for HID-sensors (HUTRR39) currently doesn't define4/spa >

 L104">.1044/a>4spa  class="comment">                 * the range for the year attribute. Therefor we support4/spa >

 L105">.1054/a>4spa  class="comment">                 * 8 bit (0-99) and 16 or 32 bits (full) as size for the year.4/spa >

 L106">.1064/a>4spa  class="comment">                 */4/spa >

 L107">.1074/a>                if (4a href="+code=raw_le " class="sref">raw_le 4/a> == 1) {

 L108">.1084/a>                        4a href="+code=time_buf" class="sref">time_buf4/a>->4a href="+code=tm_year" class="sref">tm_year4/a> =.*(4a href="+code=u8" class="sref">u84/a> *)4a href="+code=raw_data" class="sref">raw_data4/a>;

 L109">.1094/a>                        if (4a href="+code=time_buf" class="sref">time_buf4/a>->4a href="+code=tm_year" class="sref">tm_year4/a> < 70)

 L110">.1104/a>                                4spa  class="comment">/* assume we are in 1970...2069 */4/spa >

 L111">.1114/a>                                4a href="+code=time_buf" class="sref">time_buf4/a>->4a href="+code=tm_year" class="sref">tm_year4/a> +=.100;

 L112">.1124/a>                } else

 L113">.1134/a>                        4a href="+code=time_buf" class="sref">time_buf4/a>->4a href="+code=tm_year" class="sref">tm_year4/a> =

 L114">.1144/a>                                (int)4a href="+code=hid_time_tion>" class="sref">hid_time_tion>4/a>(4a href="+code=raw_le " class="sref">raw_le 4/a>, 4a href="+code=raw_data" class="sref">raw_data4/a>)-1900;

 L115">.1154/a>                break;

 L116">.1164/a>        case 4a href="+code=HID_USAGE_SENSOR_TIME_MONTH" class="sref">HID_USAGE_SENSOR_TIME_MONTH4/a>:

 L117">.1174/a>                4spa  class="comment">/* sensors are sending the month as 1-12, we need 0-11 */4/spa >

 L118">.1184/a>                4a href="+code=time_buf" class="sref">time_buf4/a>->4a href="+code=tm_mon" class="sref">tm_mon4/a> =.(int)4a href="+code=hid_time_tion>" class="sref">hid_time_tion>4/a>(4a href="+code=raw_le " class="sref">raw_le 4/a>, 4a href="+code=raw_data" class="sref">raw_data4/a>)-1;

 L119">.1194/a>                break;

 L120">.1204/a>        case 4a href="+code=HID_USAGE_SENSOR_TIME_DAY" class="sref">HID_USAGE_SENSOR_TIME_DAY4/a>:

 L121">.1214/a>                4a href="+code=time_buf" class="sref">time_buf4/a>->4a href="+code=tm_mday" class="sref">tm_mday4/a> =.(int)4a href="+code=hid_time_tion>" class="sref">hid_time_tion>4/a>(4a href="+code=raw_le " class="sref">raw_le 4/a>, 4a href="+code=raw_data" class="sref">raw_data4/a>);

 L122">.1224/a>                break;

 L123">.1234/a>        case 4a href="+code=HID_USAGE_SENSOR_TIME_HOUR" class="sref">HID_USAGE_SENSOR_TIME_HOUR4/a>:

 L124">.1244/a>                4a href="+code=time_buf" class="sref">time_buf4/a>->4a href="+code=tm_hour" class="sref">tm_hour4/a> =.(int)4a href="+code=hid_time_tion>" class="sref">hid_time_tion>4/a>(4a href="+code=raw_le " class="sref">raw_le 4/a>, 4a href="+code=raw_data" class="sref">raw_data4/a>);

 L125">.1254/a>                break;

 L126">.1264/a>        case 4a href="+code=HID_USAGE_SENSOR_TIME_MINUTE" class="sref">HID_USAGE_SENSOR_TIME_MINUTE4/a>:

 L127">.1274/a>                4a href="+code=time_buf" class="sref">time_buf4/a>->4a href="+code=tm_min" class="sref">tm_min4/a> =.(int)4a href="+code=hid_time_tion>" class="sref">hid_time_tion>4/a>(4a href="+code=raw_le " class="sref">raw_le 4/a>, 4a href="+code=raw_data" class="sref">raw_data4/a>);

 L128">.1284/a>                break;

 L129">.1294/a>        case 4a href="+code=HID_USAGE_SENSOR_TIME_SECOND" class="sref">HID_USAGE_SENSOR_TIME_SECOND4/a>:

 L130">.1304/a>                4a href="+code=time_buf" class="sref">time_buf4/a>->4a href="+code=tm_sec" class="sref">tm_sec4/a> =.(int)4a href="+code=hid_time_tion>" class="sref">hid_time_tion>4/a>(4a href="+code=raw_le " class="sref">raw_le 4/a>, 4a href="+code=raw_data" class="sref">raw_data4/a>);

 L131">.1314/a>                break;

 L132">.1324/a>        default:

 L133">.1334/a>                return -4a href="+code=EINVAL" class="sref">EINVAL4/a>;

 L134">.1344/a>        }

 L135">.1354/a>        return 0;

 L136">.1364/a>}

 L137">.1374/a>

 L138">.1384/a>4spa  class="comment">/* small helper, haven't found any other way */4/spa >

 L139">.1394/a>static const.char *4a href="+code=hid_time_attrib_nam>" class="sref">hid_time_attrib_nam>4/a>(4a href="+code=u32" class="sref">u324/a> 4a href="+code=attrib_id" class="sref">attrib_id4/a>)

 L140">.1404/a>{

 L141">.1414/a>        static const.char 4a href="+code=unknow " class="sref">unknow 4/a>[] = 4spa  class="string">"unknow "4/spa >;

 L142">.1424/a>        unsigned 4a href="+code=i" class="sref">i4/a>;

 L143">.1434/a>

 L144">.1444/a>        for (4a href="+code=i" class="sref">i4/a> = 0; 4a href="+code=i" class="sref">i4/a> < 4a href="+code=TIME_RTC_CHANNEL_MAX" class="sref">TIME_RTC_CHANNEL_MAX4/a>; ++4a href="+code=i" class="sref">i4/a>) {

 L145">.1454/a>                if (4a href="+code=hid_time_addresses" class="sref">hid_time_addresses4/a>[4a href="+code=i" class="sref">i4/a>] == 4a href="+code=attrib_id" class="sref">attrib_id4/a>)

 L146">.1464/a>                        return 4a href="+code=hid_time_channel_nam>s" class="sref">hid_time_channel_nam>s4/a>[4a href="+code=i" class="sref">i4/a>];

 L147">.1474/a>        }

 L148">.1484/a>        return 4a href="+code=unknow " class="sref">unknow 4/a>; 4spa  class="comment">/* should never happen */4/spa >

 L149">.1494/a>}

 L150">.1504/a>

 L151">.1514/a>static int.4a href="+code=hid_time_parse_report" class="sref">hid_time_parse_report4/a>(struct.4a href="+code=platform_device" class="sref">platform_device4/a> *4a href="+code=pdev" class="sref">pdev4/a>,

 L152">.1524/a>                                struct.4a href="+code=hid_sensor_hub_device" class="sref">hid_sensor_hub_device4/a> *4a href="+code=hsdev" class="sref">hsdev4/a>,

 L153">.1534/a>                                unsigned 4a href="+code=usage_id" class="sref">usage_id4/a>,

 L154">.1544/a>                                struct.4a href="+code=hid_time_state" class="sref">hid_time_state4/a> *4a href="+code=time_state" class="sref">time_state4/a>)

 L155">.1554/a>{

 L156">.1564/a>        int.4a href="+code=report_id" class="sref">report_id4/a>, 4a href="+code=i" class="sref">i4/a>;

 L157">.1574/a>

 L158">.1584/a>        for (4a href="+code=i" class="sref">i4/a> = 0; 4a href="+code=i" class="sref">i4/a> < 4a href="+code=TIME_RTC_CHANNEL_MAX" class="sref">TIME_RTC_CHANNEL_MAX4/a>; ++4a href="+code=i" class="sref">i4/a>)

 L159">.1594/a>                if (4a href="+code=sensor_hub_input_get_attribute_info" class="sref">sensor_hub_input_get_attribute_info4/a>(4a href="+code=hsdev" class="sref">hsdev4/a>,

 L160">.1604/a>                                4a href="+code=HID_INPUT_REPORT" class="sref">HID_INPUT_REPORT4/a>, 4a href="+code=usage_id" class="sref">usage_id4/a>,

 L161">.1614/a>                                4a href="+code=hid_time_addresses" class="sref">hid_time_addresses4/a>[4a href="+code=i" class="sref">i4/a>],

 L162">.1624/a>                                &4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>]) < 0)

 L163">.1634/a>                        return -4a href="+code=EINVAL" class="sref">EINVAL4/a>;

 L164">.1644/a>        4spa  class="comment">/* Check the (needed) attributes for sanity */4/spa >

 L165">.1654/a>        4a href="+code=report_id" class="sref">report_id4/a> =.4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[0].4a href="+code=report_id" class="sref">report_id4/a>;

 L166">.1664/a>        if (4a href="+code=report_id" class="sref">report_id4/a> < 0) {

 L167">.1674/a>                4a href="+code=dev_err" class="sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>, 4spa  class="string">"bad report ID!\ "4/spa >);

 L168">.1684/a>                return -4a href="+code=EINVAL" class="sref">EINVAL4/a>;

 L169">.1694/a>        }

 L170">.1704/a>        for (4a href="+code=i" class="sref">i4/a> = 0; 4a href="+code=i" class="sref">i4/a> < 4a href="+code=TIME_RTC_CHANNEL_MAX" class="sref">TIME_RTC_CHANNEL_MAX4/a>; ++4a href="+code=i" class="sref">i4/a>) {

 L171">.1714/a>                if (4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>].4a href="+code=report_id" class="sref">report_id4/a> !=.4a href="+code=report_id" class="sref">report_id4/a>) {

 L172">.1724/a>                        4a href="+code=dev_err" class="sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>,

 L173">.1734/a>                                4spa  class="string">"not all needed attributes inside the sam> report!\ "4/spa >);

 L174">.1744/a>                        return -4a href="+code=EINVAL" class="sref">EINVAL4/a>;

 L175">.1754/a>                }

 L176">.1764/a>                if (4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>].4a href="+code=size" class="sref">size4/a> == 3 ||

 L177">.1774/a>                                4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>].4a href="+code=size" class="sref">size4/a> > 4) {

 L178">.1784/a>                        4a href="+code=dev_err" class="sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>,

 L179">.1794/a>                                4spa  class="string">"attribute '%s' not 8, 16 or 32 bits wideute '%s&i" clrltate" class="sref">time_state4/a> =.e.c#L80" id
 L80" class=1"line18am>
 L160">.1604/a>                                4a href="+code=hid_time_attrib_nam>" class="sref">hid_time_at '%s&i" clrltate" class="sref">time_stasor-time.e.c#L81" id
 L81" class=1"line18am>
 L161">.1614/a>                                        4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>].4a href="+code=attrib_id" class="sref"> "4/spa >);

 L172">.1724/a>                        return -4a href="+code=EINVAL" class="sref">EINVAL4/a>;

 L83">. 834/a>                }

 L174">.1744/a>                if (4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>].4un 8,"+code=unknow " c 8,ref">re             }

 L85">. 854/a>                                4 class="sref">HIDUNITS_NOT_SPECIFIESOR_TIME_SECOND" class="sref">HIDUNITS_NOT_SPECIFIESss="sr>devr>dev             }

 L146">.1464/a>                                4spa  class=llownot all ne string, 16th  c 8 string, es for sanity */4/spa >

 L87">. 874/a>                  !           if (4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>].4a href="+code=attrib_id" class="sref"srenity */4/spa >

 L178">.1784/a>                                4 class="sref">HID_USAGE_SENSOR_TIME_SECOND" class="sref">HID_USAGE_SENSOR_Tsr>devr>dev             }

 L89">. 894/a>                                4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>].4un 8,"+code=unknow " c 8,ref">renity */4/spa >

 L160">.1604/a>                                4a hrss="sref">HIDUNITS_E_SENSOR_TIME_SECOND" class="sref">HIDUNITS_E_SENSref"> ze4/a> > 4) {

 L161">.1614/a>                        4a href="+code=dev_err" class="sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>,

 L162">.1624/a>                                4spa  class="string">"attribute ha currentla  c 8 of typ"anoneuot;ar 32 bits wideute '%s&i" clrltate" class="sref">time_stensor-tim1e.c#L93" id
 L93" class=1"line19am>
 L173">.1734/a>                                4a href="+code=hid_time_attrib_nam>" class="sref">hid_time_at '%s&i" clrltate" class="sref">time_stensor-tim1e.c#L94" id
 L94" class=1"line1 nam>
 L94">. 944/a>                                        4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>].4a href="+code=attrib_id" class="sref"> "4/spa >);

 L95">. 954/a>                        return -4a href="+code=EINVAL" class="sref">EINVAL4/a>;

 L146">.1464/a>                }

 L107">.1074/a>                if (4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>].4 c 8_expref="+code=info" c 8_exprref">report_id4/a>) {

 L178">.1784/a>                        4a href="+code=dev_err" class="sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>,

 L179">.1794/a>                                4spa  class="string">"attribute ha currentla  c 8 exprnler of 1r 32 bits wideute '%s&i" clrltate" class="sref">time_s2nsor-time2c#L100" id
 L100" class=2line"20am>
 L160">.1604/a>                                4a href="+code=hid_time_attrib_nam>" class="sref">hid_time_at '%s&i" clrltate" class="sref">time_s2nsor-time2c#L101" id
 L101" class=2line"20am>
 L161">.1614/a>                                        4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[4a href="+code=i" class="sref">i4/a>].4a href="+code=attrib_id" class="sref"> "4/spa >);
time_s2n2or-time2c.c#L92" id
 L92" class=2line"2nam>
 L102">.1024/a>                        return -4a href="+code=EINVAL" class="sref">EINVAL4/a>;

 L83">. 834/a>                }

 L134">.1344/a>        }

 44/a>        }

 L76">. 764/a>        return 0;

 L77">. 774/a>}

 L78">. 784/a>

 L139">.1514/a>static int.4a hr="d_readref="+code=rtc_time"a hr="d_readref="me_at              struct.4id_sensor_hub_device"id_sensor_hub_device4/a> *4a href="+code=dev" class="s984/a>        struct.4a href="+code=rtc_time" class="sref">rtc_time4/a> *4amode=time_state" mref"> L78">. 784/a>

 L140">.1404/a>{

 L111">.1u94/a>        unsigned long 4a href="+code=flags" class="sref">flags4/a>;

 L112">.1974/a>        struct.4a href="+code=hid_time_state" class="sref">hid_time_state4/a> *4a href="+code=time_state" class="sref">tief">flags4/a>;

 L113">.1134/a>  _err4/a>(&4a href="+code=platform_get_drvdata" class="sref">platform_get_drvdata4/a>(4to_a href="+code=platform_device"to_a href="+code=prm_get_drvdata4/a>(4a href="+code=dev" class=> "4/spa >);
time_s2nsor-time2c#L114" id
 L114" class=2line"2nam>
 L114">.1564/a>        int.4a me_parse_report"a ms="sref">flags4/a>;

 44/a>        }

 L116">.1a>        int.4INIT_COMPLETIONe_parse_report"INIT_COMPLETIONrm_get_drvdata4/a>(4t href="+code=time_state" class="sref">time_state4/a>->4a href="+code=comp_last_time" class="sref">comp_last_time4/a>);

 L117">.1              4spa  classrefla ng">&qu16th ng">ref">s through ngq">stnsorrnl>ref"> es for sanity */4/spa >

 L118">.1"sref">i4/a>].4aclass="sref">sen clasref" clacode=hid_time_tion>"aclass="sref">sen clasref" clacode=rm_get_drvdata4/a>(4t href="+code=time_state" class="sref">time_state4/a>->4a hmon_hub_inputef="+code=flags"a hmon_hub_inputeef">="sref">i4/a>].4a href="+code=hsdev" class="sref">hsdev4/a>,

 L119">.1194/a>  L118">.1"sref">i4/a>].4 class="sref">HID_USAOR_TIME_SECOND" class="sref">HID_USAass="s              4a href="+code=hid_time_addresses" class="sref">hid_time_0s="sref">i4/a>],

 L160">.1604/a>                        4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=info" class="sref">info4/a>[0].4a href="+code=report_id" class="sref"_last_time4/a>);

 L121">.1              4spa  classwai    * ng">ref">s (hid_t) es for sanity */4/spa >

 L72">. 724/a>        4a me_parse_report"a ms="s>report_id4/a> =.4wai _  *_ class=ion_killableass="oume_parse_report"wai _  *_ class=ion_killableass="oumme_at '%s&i" clrltate" class="sref">time_s2nsor-time2c#L123" id
 L123" class=2line"22am>
 L173">.1734/a>          >comple
e4/a>(&4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=comp_last_time" class="sref">comp"s              4HZOR_TIME_SECOND" Zcomp*6_last_time4/a>);

 L124">.1664/a>        if (4a me_parse_report"a ms="s>ref">t_id4/a> < 0) {

 L125">.1254/a>                4spa  classno1 to denote a  error */4/spa >

 L146">.1464/a>  "sref">i4/a>].4a href="+code=spin_lock_irqsave" class="sref">spin_lock_irqsave4/a>(&4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=lock_last_time" class="sref">lock_last_time4/a>, 4a href="+code=flags" class="sref">flags4/a>);

 L127">.1274/a>  >rtc_time4/a> *4amode=time_state" mref">report_id4/a> =.4a href="+code=time_state" class="sref">time_state4/a>->4f="+code=lock_last_time" ="sref">lockef">flags4/a>);

 L128">.1284/a>  "sref">i4/a>].4a href="+code=spin_unlock_irqrestore" class="sref">spin_unlock_irqrestore4/a>(&4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=lock_last_time" class="sref">lock_last_time4/a>, 4a href="+code=flags" class="sref">flags4/a>);

 L119">.1194/a>  764/a>        return 0;

 L90">. 904/a>        }

 L131">.1664/!a>        if (4a me_parse_report"a ms="s> L78">. 784/a>

 L102">.1024/a>                return -4a O="+code=EINVAL" cOlocke               4spa  classss="oumedenote a  error */4/spa >

 L133">.1484/a>        return 4a me_parse_report"a ms="sr               4spa  classkillede(-ERESTARTSYS) es for sanity */4/spa >

 904/a>        }

 44/a>        }

 414/a>       984/a>        struct.4a hr36" i_opef="+code=flags"a hr36" i_opem>
 L              4a href="+a hropef="+code=flags"a href="+a hroperef">red4/a> < 0) {

 L127">.1f">info4/a>[0].4a adref="+code=rtc_time"readref="me_a>report_id4/a> =.4a hr="d_readref="+code=rtc_time"a hr="d_readref="me_a="sref">i4/a>],

 }      return 0;

 L99">. 994/a>

 L151">.1514/a>static int.4a href="+crob=hid_time_state" class="scrob=me_at              struct.4a href="+code=platform_device" class="sref">platform_device4/a> *4a href="+code=pdev" class="> L78">. 784/a>

 d4/a> < 0) {

 L142">.1564/a>        int.4a me_parse_report"a ms="ss="sr4/a> < 0) {

 L133">.1              struct.4a href="+code=hid_sensor_hub_device" class="sref">hid_sensor_hub_device4/a> *4a href="+code=hsdev" class="stime_state4/a> =.4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class=f">info4/a>[0].4 class="srtform_get_drvdata" class="sss="sref">raw_data4/a>;

 L144">.1974/a>        struct.4a href="+code=hid_time_state" class="sref">hid_time_state4/a> *4a href="+code=time_state" class="sref">time_state4/a> =.4 clm_kz=llof="+code=tm_sec" clm_kz=llof"sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>,

 L145">.1454/a>   claofure_sample4/a>(struct.4a href="+code=hid_time_state" class="sref">hid_)_last_time4/a>, 4GFP_KERNEf="+code=EINVAL"GFP_KERNEfs="sref">flags4/a>);

 f">flags4/a>);

 L147">.1              if (4a href="+code=time_state" class="sref">="sref">i4/a>] == 4NULf="+code=EINVAL"NULfss="> L78">. 784/a>

 L168">.1684/a>                return -4aNOMEM="+code=EINVAL" NOMEMsref">raw_data4/a>;

 L99">. 994/a>

 L90">. ">info4/a>[0].4 class="ssode=platform_get_drvdata" class="ssef">platform_get_drvdata4/a>(4a href="+code=pdev" class="seport_id4/a> =.4a href="+code=time_state" class="sref">ref">flags4/a>);

 f">flags4/a>);

 L72">. 724/a>        4 class="srenime_parse_report" class="srenimock_irqrestore4/a>(&4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=lock_last_time" class="sref">lockref">flags4/a>);

 L153">.1state4/a>->4a it_ class=ionef="+code=info" cit_ class=ionock_irqrestore4/a>(&4a href="+code=time_state" class="sref">time_state4/a>->4a href="+code=comp_last_time" class="sref">comp_last_time4/a>);

 L154">.1t_drvdata4/a>(4t href="+code=time_state" class="sref">time_state4/a>->4a hmon_hub_inputef="+code=flags"a hmon_hub_inputeef">="sref">i4/a>].4a href="+code=hsdev" class="s>report_id4/a> =.4a href="+code=hsdev" class="slast_time4/a>);

 L165">.1654/a>        4t href="+code=time_state" class="sref">time_state4/a>->4a hmon_hub_inputef="+code=flags"a hmon_hub_inputeef">="sref">i4/a>].4a href="+code=pdev" class="time_state4/a> =.4a href="+code=pdev" class="last_time4/a>);

 f">flags4/a>);

 L165">.1654/a>        4a me_parse_report"a ms="s>report_id4/a> =.4 class="sreref">ha hmon_hub_inputef="+code=flags" class="sreref">ha hmon_hub_inputerm_get_drvdata4/a>(4a href="+code=hsdev" class="sref">hsdev4/a>,

 L178">.1784/a>                                4 class="sref">HID_USAOR_TIME_SECOND" class="sref">HID_USAass="ef">hsdev4/a>,

 L159">.1594/a>                  rqrestore4/a>(&4a href="+code=time_state" class="sref">time_state4/a>->4a hmon_hub_inputef="+code=flags"a hmon_hub_inputeef">_last_time4/a>);

 L160">.1664/a>        if (4a me_parse_report"a ms="s_id4/a> < 0) {

 L161">.1614/a>  >pdev4/a>->4a href="+code=dev_err" class="sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>, 4spa  class="failedeto sefup a hmonnot all neehe sam> report!\ "4/spa >);

 L162">.1624/a>  484/a>        return 4a me_parse_report"a ms="srquot;4/spa >);

 L163">.1904/a>        }

 04/a>        }

 L165">.1654/a>        4a me_parse_report"a ms="s>report_id4/a> =.4 class="scode=hid_time_parse_report" class="sref">hid_time_part_drvdata4/a>(4a href="+code=pdev" class="seport_id4/a> =.4a href="+code=hsdev" class="sr               4 class="sref">HID_USAOR_TIME_SECOND" class="sref">HID_USAass="ef">hsdev4/a>,

 L146">.1464/a>                  L165">.1654/a>        4a href="+code=time_state" class="sref">ref">flags4/a>);

 L147">.1              if (4a me_parse_report"a ms="s_id4/a> < 0) {

 L168">.1684/a>  >pdev4/a>->4a href="+code=dev_err" class="sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>, 4spa  class="failedeto sefup ot all neehe sam> report!\ "4/spa >);

 L119">.1194/a>  764/a>        return 4a me_parse_report"a ms="srquot;4/spa >);

 L90">. 904/a>        }

 f">flags4/a>);

 L72">. 724/a>        4a href="+code=time_state" class="sref">time_state4/a>->4aallbackef="+code=flags"aallbackeef">="sref">i4/a>].4s/rd_hid_te_parse_report" /rd_hid_ts="s>report_id4/a> =.4 class="scroc_hid_te_parse_report" class="scroc_hid_ts="srquot;4/spa >);

 L153">.1state4/a>->4a href="+code=time_state" class="sref">time_state4/a>->4aallbackef="+code=flags"aallbackeef">="sref">i4/a>].4cap4/aassalassf="+code=flags"aap4/aassalasss="s>report_id4/a> =.4 class="scap4/aassalassf="+code=flags" class="scap4/aassalasss="srquot;4/spa >);

 L154">.1t_drvdata4/a>(4t href="+code=time_state" class="sref">time_state4/a>->4aallbackef="+code=flags"aallbackeef">="sref">i4/a>].4a href="+code=pdev" class="time_state4/a> =.4a href="+code=pdev" class="last_time4/a>);

 L165">.1654/a>        4a me_parse_report"a ms="s>report_id4/a> =.4ss="sref">hregister_aallbacke_parse_report" /r"sref">hregister_aallbackrm_get_drvdata4/a>(4a href="+code=hsdev" class="sr               4 class="sref">HID_USAOR_TIME_SECOND" class="sref">HID_USAass="ef">hsdev4/a>,

 L176">.1764/a>                          rqrestore4/a>(&4a href="+code=time_state" class="sref">time_state4/a>->4aallbackef="+code=flags"aallbackeef"> "4/spa >);

 L147">.1              if (4a me_parse_report"a ms="s>report_id4/a> < 0) {

 L178">.1784/a>  >pdev4/a>->4a href="+code=dev_err" class="sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>, 4spa  class="register aallback failedhe sam> report!\ "4/spa >);

 L179">.1794/a>  764/a>        return 4a me_parse_report"a ms="srquot;4/spa >);

 L90">. 904/a>        }

 f">flags4/a>);

 L72">. 724/a>        4a href="+code=time_state" class="sref">time_state4/a>->4="de_parse_report"atcs="s>report_id4/a> =.4 clm_="d_id_senhregister="+code=tm_sec" clm_="d_id_senhregister"sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>,

 L83">. 834/a>                          ref">dev4/a>, 4spa  class="ivers/rtc/rtc-h2 bits wideute rqrestore4/a>(&4a href="+a hropef="+code=flags"a href="+a hroperef""sref">dev4/a>,

 L174">.1744/a>                          rore4/a>(&4THIS_MODULAOR_TIME_SECOND"THIS_MODULAef"> "4/spa >);

 44/a>        }

 L146">.1              if (4IS_ERROR_TIME_SECOND"IS_ERRrm_get_drvdata4/a>(4a href="+code=time_state" class="sref">time_state4/a>->4="de_parse_report"atcs="s> ze4/a> > 4) {

 L87">. 874/a>  >pdev4/a>->4a href="+code=dev_err" class="sref">dev_err4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>, 4spa  class="rtc id_sen register failedhe sam> report!\ "4/spa >);

 L178">.1784/a>  764/a>        return 4PTR_ERROR_TIME_SECOND"PTR_ERRrm_get_drvdata4/a>(4a href="+code=time_state" class="sref">time_state4/a>->4="de_parse_report"atcs="s>"4/spa >);

 L169">.1694/a>        }

 L150">.1504/a>

 L161">.1764/a>        return 4a me_parse_report"a ms="srquot;4/spa >);

 694/a>        }

 L143">.1434/a>

L151">.1514/a>static int.4a href="+remopin_lock_irqsave"a href="+remopirm_ge              struct.4a href="+code=platform_device" class="sref">platform_device4/a> *4a href="+code=pdev" class="> L78">. 784/a>

 L155">.1554/a>{

 L146">.1              struct.4a href="+code=hid_sensor_hub_device" class="sref">hid_sensor_hub_device4/a> *4a href="+code=hsdev" class="stime_state4/a> =.4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class=f">info4/a>[0].4 class="srtform_get_drvvice" class="srs="sref">raw_data4/a>;

 L157">.1574/a>

 L118">.1"sref">i4/a>].4aclass="sreremopi_aallbacke_parse_report" /r"sref">hremopi_aallbackrm_get_drvdata4/a>(4a href="+code=hsdev" class="sr               4 class="sref">HID_USAOR_TIME_SECOND" class="sref">HID_USAass=>"4/spa >);

 L99">. 994/a>

 L160">.1764/a>        return 0;

 694/a>        }

 94/a>        }

L151">.              struct.4a href="+c  }
.1554/a>{

 L134">.1f">info4/a>[0].4c  }
.1554/a>{

 L145">.1454/a>  f">info4/a>[0].4d_time_attrib_nam>"d_time_a>  ime_state4/a> =.4DRIVER_NASAOR_TIME_SECOND"DRIVER_NASAref""sref">dev4/a>,

 L176">.1764/a>  f">info4/a>[0].4own

 L1ime_state4/a> =.4THIS_MODULAOR_TIME_SECOND"THIS_MODULAef">"sref">dev4/a>,

 L87">. }"sref">dev4/a>,

 L134">.1f">info4/a>[0].4crob=hid_time_state"crob=me_a.1764/a>  report_id4/a> =.4 class="scrob=hid_time_state" class="scrob=me_a"sref">dev4/a>,

 L134">.1f">info4/a>[0].4remopin_lock_irqsave"remopirm_g1764/a>  report_id4/a> =.4 class="sremopin_lock_irqsave"a href="+remopirm_g"sref">dev4/a>,

 }      return 0;

 port_id4/a> =.4modul"sc href="+c  }

 94/a>        }

 t_drvdata4/a>(4MODULA_DESCRIPTIONe_parse_report"MODULA_DESCRIPTIONrm_getef">dev4/a>, 4spa  class=" cl S/rtc/ Tc-h2 bits wideut>"4/spa >);

 t_drvdata4/a>(4MODULA_AUTHOROR_TIME_SECOND"MODULA_AUTHORrm_getef">dev4/a>, 4spa  class="Alexander Holler repoholler@ahsoftware.deref"2 bits wideut>"4/spa >);

 t_drvdata4/a>(4MODULA_LICf">AOR_TIME_SECOND"MODULA_LICf">Arm_getef">dev4/a>, 4spa  class="GPL2 bits wideut>"4/spa >);

 
The original LXR software byributuot;4/spahttp://sourceef=ge.net/projects/lxr=>LXR a hm c 8ys="sr this experipa al ; lxr@ L1ux.noass=f lxr. L1ux.no kindly hosmedebyruot;4/spahttp://www.redpill- L1pro.no">Redpill LL1pro ASs="sr provider of LL1ux ultnsorand opera=ions ser_sens sincee19a5.