2001-01-18 20:11:48 -05:00
|
|
|
/*
|
|
|
|
* libraw1394 - library for raw access to the 1394 bus with the Linux subsystem.
|
|
|
|
*
|
2002-10-13 18:54:49 -04:00
|
|
|
* Copyright (C) 1999,2000,2001,2002 Andreas Bombe
|
2001-01-18 20:11:48 -05:00
|
|
|
*
|
|
|
|
* This library is licensed under the GNU Lesser General Public License (LGPL),
|
|
|
|
* version 2.1 or later. See the file COPYING.LIB in the distribution for
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "raw1394.h"
|
|
|
|
#include "kernel-raw1394.h"
|
|
|
|
#include "raw1394_private.h"
|
2001-01-18 20:19:04 -05:00
|
|
|
#include "ieee1394.h"
|
2001-01-18 20:11:48 -05:00
|
|
|
|
2002-10-13 18:54:49 -04:00
|
|
|
|
2001-01-18 20:11:48 -05:00
|
|
|
raw1394_errcode_t raw1394_get_errcode(struct raw1394_handle *handle)
|
|
|
|
{
|
2008-04-23 20:44:36 -04:00
|
|
|
if (handle && handle->is_fw)
|
|
|
|
return handle->mode.fw->err;
|
|
|
|
else
|
|
|
|
return handle->mode.ieee1394->err;
|
2001-01-18 20:11:48 -05:00
|
|
|
}
|
|
|
|
|
2008-04-23 20:44:36 -04:00
|
|
|
int ieee1394_errcode_to_errno(raw1394_errcode_t errcode)
|
2001-01-18 20:11:48 -05:00
|
|
|
{
|
|
|
|
static const int ack2errno[16] = {
|
|
|
|
0xdead, /* invalid ack code */
|
|
|
|
0, /* ack_complete */
|
|
|
|
0xdead, /* ack_pending, should not be used here */
|
|
|
|
EAGAIN, /* busy_x, busy_a and busy_b acks */
|
|
|
|
EAGAIN,
|
|
|
|
EAGAIN,
|
|
|
|
0xdead, /* invalid ack codes */
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
EREMOTEIO, /* ack_data_error */
|
|
|
|
EPERM, /* ack_type_error */
|
|
|
|
0xdead /* invalid ack code */
|
|
|
|
};
|
|
|
|
static const int rcode2errno[16] = {
|
|
|
|
0, /* rcode_complete */
|
|
|
|
0xdead, /* invalid rcodes */
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
EAGAIN, /* rcode_conflict_error */
|
|
|
|
EREMOTEIO, /* rcode_data_error */
|
|
|
|
EPERM, /* rcode_type_error */
|
|
|
|
EINVAL, /* rcode_address_error */
|
|
|
|
0xdead, /* invalid rcodes */
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
0xdead,
|
|
|
|
0xdead
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!raw1394_internal_err(errcode)) {
|
2001-06-27 08:14:20 -04:00
|
|
|
if (raw1394_get_ack(errcode) == 0x10
|
|
|
|
|| raw1394_get_ack(errcode) == L1394_ACK_PENDING)
|
2001-01-18 20:11:48 -05:00
|
|
|
return rcode2errno[raw1394_get_rcode(errcode)];
|
|
|
|
else
|
|
|
|
return ack2errno[raw1394_get_ack(errcode)];
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (raw1394_get_internal(errcode)) {
|
|
|
|
case RAW1394_ERROR_GENERATION:
|
|
|
|
case RAW1394_ERROR_SEND_ERROR:
|
|
|
|
case RAW1394_ERROR_ABORTED:
|
|
|
|
case RAW1394_ERROR_TIMEOUT:
|
|
|
|
return EAGAIN;
|
|
|
|
|
|
|
|
case RAW1394_ERROR_MEMFAULT:
|
|
|
|
return EFAULT;
|
|
|
|
|
|
|
|
case RAW1394_ERROR_COMPAT:
|
|
|
|
case RAW1394_ERROR_STATE_ORDER:
|
|
|
|
case RAW1394_ERROR_INVALID_ARG:
|
|
|
|
case RAW1394_ERROR_ALREADY:
|
|
|
|
case RAW1394_ERROR_EXCESSIVE:
|
|
|
|
case RAW1394_ERROR_UNTIDY_LEN:
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|