Source
x
evt->rc = __uwb_rc_get(rc); /* will be put by uwbd's uwbd_event_handle() */
/*
* Ultra Wide Band
* UWB basic command support and radio reset
*
* Copyright (C) 2005-2006 Intel Corporation
* Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*
* FIXME:
*
* - docs
*
* - Now we are serializing (using the uwb_dev->mutex) the command
* execution; it should be parallelized as much as possible some
* day.
*/
/**
* Command result codes (WUSB1.0[T8-69])
*/
static
const char *__strerror[] = {
"success",
"failure",
"hardware failure",
"no more slots",
"beacon is too large",
"invalid parameter",
"unsupported power level",
"time out (wa) or invalid ie data (whci)",
"beacon size exceeded",
"cancelled",
"invalid state",
"invalid size",
"ack not received",
"no more asie notification",
};
/** Return a string matching the given error code */
const char *uwb_rc_strerror(unsigned code)
{
if (code == 255)
return "time out";
if (code >= ARRAY_SIZE(__strerror))
return "unknown error";
return __strerror[code];
}
int uwb_rc_cmd_async(struct uwb_rc *rc, const char *cmd_name,
struct uwb_rccb *cmd, size_t cmd_size,
u8 expected_type, u16 expected_event,
uwb_rc_cmd_cb_f cb, void *arg)
{
struct device *dev = &rc->uwb_dev.dev;
struct uwb_rc_neh *neh;
int needtofree = 0;
int result;
uwb_dev_lock(&rc->uwb_dev); /* Protect against rc->priv being removed */
if (rc->priv == NULL) {
uwb_dev_unlock(&rc->uwb_dev);
return -ESHUTDOWN;
}
if (rc->filter_cmd) {
needtofree = rc->filter_cmd(rc, &cmd, &cmd_size);
if (needtofree < 0 && needtofree != -ENOANO) {
dev_err(dev, "%s: filter error: %d\n",
cmd_name, needtofree);
uwb_dev_unlock(&rc->uwb_dev);