linux/drivers/uwb/scan.c
<<
v3211/spa<2 211/form2 211a v321 href="../linux+v3.8.6/drivers/uwb/scan.c"> v3211img src="../.static/gfx/right.png" alt=">>"> 1/spa<2 1spa< class="lxr_search"> v3 v3211input typ2 >hidden" nam2 >navtarget" 9.1"2 >"> v3211input typ2 >text" nam2 >search" id >search"> v3211buttv3.typ2 >submit">Search v321Prefs 211/a> 1/spa<2 v321 11/div2 v321 11form ac <="ajax+*" method="post" onsubmit="return false;"> 1input typ2 >hidden" nam2 >ajax_lookup" id >ajax_lookup" 9.1"2 >"> v321 11/form2 v321 11div class="headingbottvm">search_results" class="search_results" 22 v321 11/div2 1div id >content"> 1div id >file_contents"2
87/aa/cda329789ffe4b688f931bfa63eecbddd42f_3/0"2L1" class="line" nam2 >L1">1 111/a>1spa< class="comment">/*1/spa<2 L2" class="line" nam2 >L2">1 121/a>1spa< class="comment"> * Ultra Wide Band1/spa<2 L3" class="line" nam2 >L3">1 131/a>1spa< class="comment"> * Scanning management1/spa<2 L4" class="line" nam2 >L4">1 141/a>1spa< class="comment"> *1/spa<2 L5" class="line" nam2 >L5">1 151/a>1spa< class="comment"> * Copyright (C) 2005-2006 Intel Corpora
  <1/spa<2 L6" class="line" nam2 >L6">1 161/a>1spa< class="comment"> * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>1/spa<2 L7" class="line" nam2 >L7">1 171/a>1spa< class="comment"> *1/spa<2 L8" class="line" nam2 >L8">1 181/a>1spa< class="comment"> * This program is free software; you can redistribute it and/or1/spa<2 L9" class="line" nam2 >L9">1 191/a>1spa< class="comment"> * modify it under the terms of the GNU General Public License vers  <1/spa<2 L10" class="line" nam2 >L10">1 tiona>1spa< class="comment"> * 2 as published by the Free Software Founda
  <.1/spa<2 L11" class="line" nam2 >L11">1 111/a>1spa< class="comment"> *1/spa<2 L12" class="line" nam2 >L12">1 121/a>1spa< class="comment"> * This program is distributed in the hope that it will be useful,1/spa<2 L13" class="line" nam2 >L13">1 131/a>1spa< class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of1/spa<2 L14" class="line" nam2 >L14">1 141/a>1spa< class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the1/spa<2 L15" class="line" nam2 >L15">1 151/a>1spa< class="comment"> * GNU General Public License for more details.1/spa<2 L16" class="line" nam2 >L16">1 161/a>1spa< class="comment"> *1/spa<2 L17" class="line" nam2 >L17">1 171/a>1spa< class="comment"> * You should have received a copy of the GNU General Public License1/spa<2 L18" class="line" nam2 >L18">1 181/a>1spa< class="comment"> * along with this program; if not, write to the Free Software1/spa<2 L19" class="line" nam2 >L19">1 191/a>1spa< class="comment"> * Founda
  <, Inc., 51 Franklin Street, Fifth Floor, Bost <, MA1/spa<2 L20" class="line" nam2 >L20">1 2iona>1spa< class="comment"> * 02110-1301, USA.1/spa<2 L21" class="line" nam2 >L21">1 211/a>1spa< class="comment"> *1/spa<2 L22" class="line" nam2 >L22">1 221/a>1spa< class="comment"> *1/spa<2 L23" class="line" nam2 >L23">1 231/a>1spa< class="comment"> *1/spa<2 L24" class="line" nam2 >L24">1 241/a>1spa< class="comment"> * FIXME: docs1/spa<2 L25" class="line" nam2 >L25">1 251/a>1spa< class="comment"> * FIXME: there are issues here v3.how BEACON and SCAN v3.USB RCI deal1/spa<2 L26" class="line" nam2 >L26">1 261/a>1spa< class="comment"> *        with each other. Currently seems that START_BEACON while1/spa<2 L27" class="line" nam2 >L27">1 271/a>1spa< class="comment"> *        SCAN_ONLY will cancel the scan, so we need to upda
e the1/spa<2 L28" class="line" nam2 >L28">1 281/a>1spa< class="comment"> *        state here. Clarifica
  < request sent by email  <1/spa<2 L29" class="line" nam2 >L29">1 291/a>1spa< class="comment"> *        10/05/2005.1/spa<2 L30" class="line" nam2 >L30">1 3iona>1spa< class="comment"> *        10/28/2005 No clear answer heard--maybe we'll hack the API1/spa<2 L31" class="line" nam2 >L31">1 311/a>1spa< class="comment"> *                   so that when we start beaconing, if the HC is1/spa<2 L32" class="line" nam2 >L32">1 321/a>1spa< class="comment"> *                   scanning in a mode not compa
 ble with beaconing1/spa<2 L33" class="line" nam2 >L33">1 331/a>1spa< class="comment"> *                   we just fail.1/spa<2 L34" class="line" nam2 >L34">1 341/a>1spa< class="comment"> */1/spa<2 L35" class="line" nam2 >L35">1 351/a> L36" class="line" nam2 >L36">1 361/a>#include <linux/device.h1/a>> L37" class="line" nam2 >L37">1 371/a>#include <linux/err.h1/a>> L38" class="line" nam2 >L38">1 381/a>#include <linux/slab.h1/a>> L39" class="line" nam2 >L39">1 391/a>#include <linux/stat.h1/a>> L40" class="line" nam2 >L40">1 401/a>#include "uwb-internal.h1/a>" L41" class="line" nam2 >L41">1 411/a> L42" class="line" nam2 >L42">1 421/a> L43" class="line" nam2 >L43">1 431/a>1spa< class="comment">/**1/spa<2 L44" class="line" nam2 >L44">1 441/a>1spa< class="comment"> * Start/stop scanning in a radio controller1/spa<2 L45" class="line" nam2 >L45">1 451/a>1spa< class="comment"> *1/spa<2 L46" class="line" nam2 >L46">1 461/a>1spa< class="comment"> * @rc:      UWB Radio Controller1/spa<2 L47" class="line" nam2 >L47">1 471/a>1spa< class="comment"> * @channel: Channel to scan; encodings in WUSB1.0[Table  L48" class="line" nam2 >L48">1 481/a>1spa< class="comment"> * @typ2:    Typ2 of scanning to do.1/spa<2 L49" class="line" nam2 >L49">1 491/a>1spa< class="comment"> * @bpst_offset: 9.1"2 at which to start scanning (if typ2 ==1/spa<2 L50" class="line" nam2 >L50">1 5iona>1spa< class="comment"> *                UWB_SCAN_ONLY_STARTTIME)1/spa<2 L51" class="line" nam2 >L51">1 511/a>1spa< class="comment"> * @returns: 0 if ok, < 0 errno code v3.error1/spa<2 L52" class="line" nam2 >L52">1 521/a>1spa< class="comment"> *1/spa<2 L53" class="line" nam2 >L53">1 531/a>1spa< class="comment"> * We put the command v3.kmalloc'ed memory as some arches cannot do1/spa<2 L54" class="line" nam2 >L54">1 541/a>1spa< class="comment"> * USB from the stack. The reply event is copied from a< stage buffer,1/spa<2 L55" class="line" nam2 >L55">1 551/a>1spa< class="comment"> * so it can be in the stack. See WUSB1.0[8.6.2.4] for more details.1/spa<2 L56" class="line" nam2 >L56">1 561/a>1spa< class="comment"> */1/spa<2 L57" class="line" nam2 >L57">1 571/a>int11a href="+code=uwb_rc_scan" class="sref">uwb_rc_scan1/a>(struct11a href="+code=uwb_rc" class="sref">uwb_rc1/a> *1a href="+code=rc" class="sref">rc1/a>, L58" class="line" nam2 >L58">1 581/a>                unsigned 1a href="+code=channel" class="sref">channel1/a>, enum11a href="+code=uwb_scan_typ2" class="sref">uwb_scan_typ21/a> 1a href="+code=typ2" class="sref">typ21/a>, L59" class="line" nam2 >L59">1 591/a>                unsigned 1a href="+code=bpst_offset" class="sref">bpst_offset1/a>) L60" class="line" nam2 >L60">1 6iona>{ L61" class="line" nam2 >L61">1 611/a>        int11a href="+code=result" class="sref">result1/a>; L62" class="line" nam2 >L62">1 621/a>        struct11a href="+code=uwb_rc_cmd_scan" class="sref">uwb_rc_cmd_scan1/a> *1a href="+code=cmd" class="sref">cmd1/a>; L63" class="line" nam2 >L63">1 631/a>        struct11a href="+code=uwb_rc_evt_confirm" class="sref">uwb_rc_evt_confirm1/a> 1a href="+code=reply" class="sref">reply1/a>; L64" class="line" nam2 >L64">1 641/a> L65" class="line" nam2 >L65">1 651/a>        1a href="+code=result" class="sref">result1/a> = -1a href="+code=ENOMEM" class="sref">ENOMEM1/a>; L66" class="line" nam2 >L66">1 661/a>        1a href="+code=cmd" class="sref">cmd1/a> = 1a href="+code=kzalloc" class="sref">kzalloc1/a>(sizeof(*1a href="+code=cmd" class="sref">cmd1/a>), 1a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL1/a>); L67" class="line" nam2 >L67">1 671/a>        if (1a href="+code=cmd" class="sref">cmd1/a> == 1a href="+code=NULL" class="sref">NULL1/a>) L68" class="line" nam2 >L68">1 681/a>                goto 1a href="+code=error_kzalloc" class="sref">error_kzalloc1/a>; L69" class="line" nam2 >L69">1 691/a>        1a href="+code=mutex_lock" class="sref">mutex_lock1/a>(&1a href="+code=rc" class="sref">rc1/a>->1a href="+code=uwb_dev" class="sref">uwb_dev1/a>.1a href="+code=mutex" class="sref">mutex1/a>); L70" class="line" nam2 >L70">1 701/a>        1a href="+code=cmd" class="sref">cmd1/a>->1a href="+code=rccb" class="sref">rccb1/a>.1a href="+code=bCommandTyp2" class="sref">bCommandTyp21/a> = 1a href="+code=UWB_RC_CET_GENERAL" class="sref">UWB_RC_CET_GENERAL1/a>; L71" class="line" nam2 >L71">1 711/a>        1a href="+code=cmd" class="sref">cmd1/a>->1a href="+code=rccb" class="sref">rccb1/a>.1a href="+code=wCommand" class="sref">wCommand1/a> = 1a href="+code=cpu_to_le16" class="sref">cpu_to_le161/a>(1a href="+code=UWB_RC_CMD_SCAN" class="sref">UWB_RC_CMD_SCAN1/a>); L72" class="line" nam2 >L72">1 721/a>        1a href="+code=cmd" class="sref">cmd1/a>->1a href="+code=bChannelNumber" class="sref">bChannelNumber1/a> = 1a href="+code=channel" class="sref">channel1/a>; L73" class="line" nam2 >L73">1 731/a>        1a href="+code=cmd" class="sref">cmd1/a>->1a href="+code=bScanState" class="sref">bScanState1/a> = 1a href="+code=typ2" class="sref">typ21/a>; L74" class="line" nam2 >L74">1 741/a>        1a href="+code=cmd" class="sref">cmd1/a>->1a href="+code=wStartTim2" class="sref">wStartTim21/a> = 1a href="+code=cpu_to_le16" class="sref">cpu_to_le161/a>(1a href="+code=bpst_offset" class="sref">bpst_offset1/a>); L75" class="line" nam2 >L75">1 751/a>        1a href="+code=reply" class="sref">reply1/a>.1a href="+code=rceb" class="sref">rceb1/a>.1a href="+code=bEventTyp2" class="sref">bEventTyp21/a> = 1a href="+code=UWB_RC_CET_GENERAL" class="sref">UWB_RC_CET_GENERAL1/a>; L76" class="line" nam2 >L76">1 761/a>        1a href="+code=reply" class="sref">reply1/a>.1a href="+code=rceb" class="sref">rceb1/a>.1a href="+code=wEvent" class="sref">wEvent1/a> = 1a href="+code=UWB_RC_CMD_SCAN" class="sref">UWB_RC_CMD_SCAN1/a>; L77" class="line" nam2 >L77">1 771/a>        1a href="+code=result" class="sref">result1/a> = 1a href="+code=uwb_rc_cmd" class="sref">uwb_rc_cmd1/a>(1a href="+code=rc" class="sref">rc1/a>, 1spa< class="string">"SCAN"cmd1/a>->1a href="+code=rccb" class="sref">rccb1/a>, sizeof(*1a href="+code=cmd" class="sref">cmd1/a>), L78" class="line" nam2 >L78">1 781/a>                            &1a href="+code=reply" class="sref">reply1/a>.1a href="+code=rceb" class="sref">rceb1/a>, sizeof(1a href="+code=reply" class="sref">reply1/a>)); L79" class="line" nam2 >L79">1 791/a>        if (1a href="+code=result" class="sref">result1/a> < 0) L80" class="line" nam2 >L80">1 801/a>                goto 1a href="+code=error_cmd" class="sref">error_cmd1/a>; L81" class="line" nam2 >L81">1 811/a>        if (1a href="+code=reply" class="sref">reply1/a>.1a href="+code=bResultCode" class="sref">bResultCode1/a> != 1a href="+code=UWB_RC_RES_SUCCESS" class="sref">UWB_RC_RES_SUCCESS1/a>) { L82" class="line" nam2 >L82">1 821/a>                1a href="+code=dev_err" class="sref">dev_err1/a>(&1a href="+code=rc" class="sref">rc1/a>->1a href="+code=uwb_dev" class="sref">uwb_dev1/a>.1a href="+code=dev" class="sref">dev1/a>, L83" class="line" nam2 >L83">1 831/a>                        1spa< class="string">"SCAN: command execu
  < failed: %s (%d)\n"L84" class="line" nam2 >L84">1 841/a>                        1a href="+code=uwb_rc_strerror" class="sref">uwb_rc_strerror1/a>(1a href="+code=reply" class="sref">reply1/a>.1a href="+code=bResultCode" class="sref">bResultCode1/a>), 1a href="+code=reply" class="sref">reply1/a>.1a href="+code=bResultCode" class="sref">bResultCode1/a>); L85" class="line" nam2 >L85">1 851/a>                1a href="+code=result" class="sref">result1/a> = -1a href="+code=EIO" class="sref">EIO1/a>; L86" class="line" nam2 >L86">1 861/a>                goto 1a href="+code=error_cmd" class="sref">error_cmd1/a>; L87" class="line" nam2 >L87">1 871/a>        } L88" class="line" nam2 >L88">1 881/a>        1a href="+code=rc" class="sref">rc1/a>->1a href="+code=scanning" class="sref">scanning1/a> = 1a href="+code=channel" class="sref">channel1/a>; L89" class="line" nam2 >L89">1 891/a>        1a href="+code=rc" class="sref">rc1/a>->1a href="+code=scan_typ2" class="sref">scan_typ21/a> = 1a href="+code=typ2" class="sref">typ21/a>; L90" class="line" nam2 >L90">1 9iona>1a href="+code=error_cmd" class="sref">error_cmd1/a>: L91" class="line" nam2 >L91">1 911/a>        1a href="+code=mutex_unlock" class="sref">mutex_unlock1/a>(&1a href="+code=rc" class="sref">rc1/a>->1a href="+code=uwb_dev" class="sref">uwb_dev1/a>.1a href="+code=mutex" class="sref">mutex1/a>); L92" class="line" nam2 >L92">1 921/a>        1a href="+code=kfree" class="sref">kfree1/a>(1a href="+code=cmd" class="sref">cmd1/a>); L93" class="line" nam2 >L93">1 93ona>1a href="+code=error_kzalloc" class="sref">error_kzalloc1/a>: L94" class="line" nam2 >L94">1 941/a>        return 1a href="+code=result" class="sref">result1/a>; L95" class="line" nam2 >L95">1 951/a>} L96" class="line" nam2 >L96">1 961/a> L97" class="line" nam2 >L97">1 971/a>1spa< class="comment">/*1/spa<2 L98" class="line" nam2 >L98">1 981/a>1spa< class="comment"> * Print1scanning state1/spa<2 L99" class="line" nam2 >L99">1 991/a>1spa< class="comment"> */1/spa<2 L100" class="line" nam2 >L100">11001/a>static 1a href="+code=ssize_t" class="sref">ssize_t1/a> 1a href="+code=uwb_rc_scan_show" class="sref">uwb_rc_scan_show1/a>(struct11a href="+code=device" class="sref">device1/a> *1a href="+code=dev" class="sref">dev1/a>, L101" class="line" nam2 >L101">11011/a>                                struct11a href="+code=device_attribute" class="sref">device_attribute1/a> *1a href="+code=attr" class="sref">attr1/a>, char *1a href="+code=buf" class="sref">buf1/a>) L102" class="line" nam2 >L102">11021/a>{ L103" class="line" nam2 >L103">11031/a>        struct11a href="+code=uwb_dev" class="sref">uwb_dev1/a> *1a href="+code=uwb_dev" class="sref">uwb_dev1/a> = 1a href="+code=to_uwb_dev" class="sref">to_uwb_dev1/a>(1a href="+code=dev" class="sref">dev1/a>); L104" class="line" nam2 >L104">11041/a>        struct11a href="+code=uwb_rc" class="sref">uwb_rc1/a> *1a href="+code=rc" class="sref">rc1/a> = 1a href="+code=uwb_dev" class="sref">uwb_dev1/a>->1a href="+code=rc" class="sref">rc1/a>; L105" class="line" nam2 >L105">11051/a>        1a href="+code=ssize_t" class="sref">ssize_t1/a> 1a href="+code=result" class="sref">result1/a>; L106" class="line" nam2 >L106">11061/a> L107" class="line" nam2 >L107">11071/a>        1a href="+code=mutex_lock" class="sref">mutex_lock1/a>(&1a href="+code=rc" class="sref">rc1/a>->1a href="+code=uwb_dev" class="sref">uwb_dev1/a>.1a href="+code=mutex" class="sref">mutex1/a>); L108" class="line" nam2 >L108">11081/a>        1a href="+code=result" class="sref">result1/a> = 1a href="+code=sprintf" class="sref">sprintf1/a>(1a href="+code=buf" class="sref">buf1/a>, 1spa< class="string">"%d %d\n"rc1/a>->1a href="+code=scanning" class="sref">scanning1/a>, 1a href="+code=rc" class="sref">rc1/a>->1a href="+code=scan_typ2" class="sref">scan_typ21/a>); L109" class="line" nam2 >L109">11091/a>        1a href="+code=mutex_unlock" class="sref">mutex_unlock1/a>(&1a href="+code=rc" class="sref">rc1/a>->1a href="+code=uwb_dev" class="sref">uwb_dev1/a>.1a href="+code=mutex" class="sref">mutex1/a>); L110" class="line" nam2 >L110">11101/a>        return 1a href="+code=result" class="sref">result1/a>; L111" class="line" nam2 >L111">11111/a>} L112" class="line" nam2 >L112">11121/a> L113" class="line" nam2 >L113">11131/a>1spa< class="comment">/*1/spa<2 L114" class="line" nam2 >L114">11141/a>1spa< class="comment"> *1/spa<2 L115" class="line" nam2 >L115">11151/a>1spa< class="comment"> */1/spa<2 L116" class="line" nam2 >L116">11161/a>static 1a href="+code=ssize_t" class="sref">ssize_t1/a> 1a href="+code=uwb_rc_scan_stor2" class="sref">uwb_rc_scan_stor21/a>(struct11a href="+code=device" class="sref">device1/a> *1a href="+code=dev" class="sref">dev1/a>, L117" class="line" nam2 >L117">11171/a>                                 struct11a href="+code=device_attribute" class="sref">device_attribute1/a> *1a href="+code=attr" class="sref">attr1/a>, L118" class="line" nam2 >L118">11181/a>                                 const char *1a href="+code=buf" class="sref">buf1/a>, 1a href="+code=size_t" class="sref">size_t1/a> 1a href="+code=size" class="sref">size1/a>) L119" class="line" nam2 >L119">11191/a>{ L120" class="line" nam2 >L120">11201/a>        struct11a href="+code=uwb_dev" class="sref">uwb_dev1/a> *1a href="+code=uwb_dev" class="sref">uwb_dev1/a> = 1a href="+code=to_uwb_dev" class="sref">to_uwb_dev1/a>(1a href="+code=dev" class="sref">dev1/a>); L121" class="line" nam2 >L121">11211/a>        struct11a href="+code=uwb_rc" class="sref">uwb_rc1/a> *1a href="+code=rc" class="sref">rc1/a> = 1a href="+code=uwb_dev" class="sref">uwb_dev1/a>->1a href="+code=rc" class="sref">rc1/a>; L122" class="line" nam2 >L122">11221/a>        unsigned 1a href="+code=channel" class="sref">channel1/a>; L123" class="line" nam2 >L123">11231/a>        unsigned 1a href="+code=typ2" class="sref">typ21/a>; L124" class="line" nam2 >L124">11241/a>        unsigned 1a href="+code=bpst_offset" class="sref">bpst_offset1/a> = 0; L125" class="line" nam2 >L125">11251/a>        1a href="+code=ssize_t" class="sref">ssize_t1/a> 1a href="+code=result" class="sref">result1/a> = -1a href="+code=EINVAL" class="sref">EINVAL1/a>; L126" class="line" nam2 >L126">11261/a> L127" class="line" nam2 >L127">11271/a>        1a href="+code=result" class="sref">result1/a> = 1a href="+code=sscanf" class="sref">sscanf1/a>(1a href="+code=buf" class="sref">buf1/a>, 1spa< class="string">"%u %u %u\n"channel1/a>, &1a href="+code=typ2" class="sref">typ21/a>, &1a href="+code=bpst_offset" class="sref">bpst_offset1/a>); L128" class="line" nam2 >L128">11281/a>        if (1a href="+code=result" class="sref">result1/a> >= 2 && 1a href="+code=typ2" class="sref">typ21/a> < 1a href="+code=UWB_SCAN_TOP" class="sref">UWB_SCAN_TOP1/a>) L129" class="line" nam2 >L129">11291/a>                1a href="+code=result" class="sref">result1/a> = 1a href="+code=uwb_rc_scan" class="sref">uwb_rc_scan1/a>(1a href="+code=rc" class="sref">rc1/a>, 1a href="+code=channel" class="sref">channel1/a>, 1a href="+code=typ2" class="sref">typ21/a>, 1a href="+code=bpst_offset" class="sref">bpst_offset1/a>); L130" class="line" nam2 >L130">113iona> L131" class="line" nam2 >L131">11311/a>        return 1a href="+code=result" class="sref">result1/a> < 0 ? 1a href="+code=result" class="sref">result1/a> : 1a href="+code=size" class="sref">size1/a>; L132" class="line" nam2 >L132">11321/a>} L133" class="line" nam2 >L133">11331/a> L134" class="line" nam2 >L134">11341/a>1spa< class="comment">/** Radio Control sysfs interface (declara
  <) */1/spa<2 L135" class="line" nam2 >L135">11351/a>1a href="+code=DEVICE_ATTR" class="sref">DEVICE_ATTR1/a>(1a href="+code=scan" class="sref">scan1/a>, 1a href="+code=S_IRUGO" class="sref">S_IRUGO1/a> | 1a href="+code=S_IWUSR" class="sref">S_IWUSR1/a>, 1a href="+code=uwb_rc_scan_show" class="sref">uwb_rc_scan_show1/a>, 1a href="+code=uwb_rc_scan_stor2" class="sref">uwb_rc_scan_stor21/a>); L136" class="line" nam2 >L136">11361/a>
The original LXR software by the LXR community1/a>, this experimental vers < by lxr@linux.no1/a>. 1/div2 1div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS1/a>, provider of Linux consulting and vpera