Change handle validation to prevent segfault and be more informative.
This commit is contained in:
parent
4ce429a797
commit
8f942654d9
298
src/dispatch.c
298
src/dispatch.c
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "raw1394.h"
|
#include "raw1394.h"
|
||||||
#include "csr.h"
|
#include "csr.h"
|
||||||
|
@ -54,7 +55,10 @@ raw1394handle_t raw1394_new_handle(void)
|
||||||
|
|
||||||
void raw1394_destroy_handle(raw1394handle_t handle)
|
void raw1394_destroy_handle(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
fw_destroy_handle(handle->mode.fw);
|
fw_destroy_handle(handle->mode.fw);
|
||||||
else
|
else
|
||||||
ieee1394_destroy_handle(handle->mode.ieee1394);;
|
ieee1394_destroy_handle(handle->mode.ieee1394);;
|
||||||
|
@ -85,7 +89,11 @@ raw1394handle_t raw1394_new_handle_on_port(int port)
|
||||||
|
|
||||||
int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch)
|
int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_busreset_notify(handle->mode.fw, off_on_switch);
|
return fw_busreset_notify(handle->mode.fw, off_on_switch);
|
||||||
else
|
else
|
||||||
return ieee1394_busreset_notify(handle->mode.ieee1394, off_on_switch);
|
return ieee1394_busreset_notify(handle->mode.ieee1394, off_on_switch);
|
||||||
|
@ -93,7 +101,11 @@ int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch)
|
||||||
|
|
||||||
int raw1394_get_fd(raw1394handle_t handle)
|
int raw1394_get_fd(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_get_fd(handle->mode.fw);
|
return fw_get_fd(handle->mode.fw);
|
||||||
else
|
else
|
||||||
return ieee1394_get_fd(handle->mode.ieee1394);
|
return ieee1394_get_fd(handle->mode.ieee1394);
|
||||||
|
@ -101,7 +113,11 @@ int raw1394_get_fd(raw1394handle_t handle)
|
||||||
|
|
||||||
nodeid_t raw1394_get_local_id(raw1394handle_t handle)
|
nodeid_t raw1394_get_local_id(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return 0xFFFF;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_get_local_id(handle->mode.fw);
|
return fw_get_local_id(handle->mode.fw);
|
||||||
else
|
else
|
||||||
return ieee1394_get_local_id(handle->mode.ieee1394);
|
return ieee1394_get_local_id(handle->mode.ieee1394);
|
||||||
|
@ -109,7 +125,11 @@ nodeid_t raw1394_get_local_id(raw1394handle_t handle)
|
||||||
|
|
||||||
nodeid_t raw1394_get_irm_id(raw1394handle_t handle)
|
nodeid_t raw1394_get_irm_id(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return 0xFFFF;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_get_irm_id(handle->mode.fw);
|
return fw_get_irm_id(handle->mode.fw);
|
||||||
else
|
else
|
||||||
return ieee1394_get_irm_id(handle->mode.ieee1394);
|
return ieee1394_get_irm_id(handle->mode.ieee1394);
|
||||||
|
@ -117,7 +137,11 @@ nodeid_t raw1394_get_irm_id(raw1394handle_t handle)
|
||||||
|
|
||||||
int raw1394_get_nodecount(raw1394handle_t handle)
|
int raw1394_get_nodecount(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_get_nodecount(handle->mode.fw);
|
return fw_get_nodecount(handle->mode.fw);
|
||||||
else
|
else
|
||||||
return ieee1394_get_nodecount(handle->mode.ieee1394);
|
return ieee1394_get_nodecount(handle->mode.ieee1394);
|
||||||
|
@ -126,7 +150,11 @@ int raw1394_get_nodecount(raw1394handle_t handle)
|
||||||
int raw1394_get_port_info(raw1394handle_t handle, struct raw1394_portinfo *pinf,
|
int raw1394_get_port_info(raw1394handle_t handle, struct raw1394_portinfo *pinf,
|
||||||
int maxports)
|
int maxports)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_get_port_info(handle->mode.fw, pinf, maxports);
|
return fw_get_port_info(handle->mode.fw, pinf, maxports);
|
||||||
else
|
else
|
||||||
return ieee1394_get_port_info(handle->mode.ieee1394, pinf, maxports);
|
return ieee1394_get_port_info(handle->mode.ieee1394, pinf, maxports);
|
||||||
|
@ -134,7 +162,11 @@ int raw1394_get_port_info(raw1394handle_t handle, struct raw1394_portinfo *pinf,
|
||||||
|
|
||||||
int raw1394_set_port(raw1394handle_t handle, int port)
|
int raw1394_set_port(raw1394handle_t handle, int port)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_set_port(handle->mode.fw, port);
|
return fw_set_port(handle->mode.fw, port);
|
||||||
else
|
else
|
||||||
return ieee1394_set_port(handle->mode.ieee1394, port);
|
return ieee1394_set_port(handle->mode.ieee1394, port);
|
||||||
|
@ -142,7 +174,11 @@ int raw1394_set_port(raw1394handle_t handle, int port)
|
||||||
|
|
||||||
int raw1394_reset_bus_new(raw1394handle_t handle, int type)
|
int raw1394_reset_bus_new(raw1394handle_t handle, int type)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_reset_bus_new(handle->mode.fw, type);
|
return fw_reset_bus_new(handle->mode.fw, type);
|
||||||
else
|
else
|
||||||
return ieee1394_reset_bus_new(handle->mode.ieee1394, type);
|
return ieee1394_reset_bus_new(handle->mode.ieee1394, type);
|
||||||
|
@ -150,7 +186,11 @@ int raw1394_reset_bus_new(raw1394handle_t handle, int type)
|
||||||
|
|
||||||
int raw1394_loop_iterate(raw1394handle_t handle)
|
int raw1394_loop_iterate(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_loop_iterate(handle);
|
return fw_loop_iterate(handle);
|
||||||
else
|
else
|
||||||
return ieee1394_loop_iterate(handle);
|
return ieee1394_loop_iterate(handle);
|
||||||
|
@ -162,7 +202,11 @@ int raw1394_arm_register(raw1394handle_t handle, nodeaddr_t start,
|
||||||
arm_options_t notification_options,
|
arm_options_t notification_options,
|
||||||
arm_options_t client_transactions)
|
arm_options_t client_transactions)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_arm_register(handle->mode.fw, start, length, initial_value,
|
return fw_arm_register(handle->mode.fw, start, length, initial_value,
|
||||||
arm_tag, access_rights, notification_options, client_transactions);
|
arm_tag, access_rights, notification_options, client_transactions);
|
||||||
else
|
else
|
||||||
|
@ -173,7 +217,11 @@ int raw1394_arm_register(raw1394handle_t handle, nodeaddr_t start,
|
||||||
|
|
||||||
int raw1394_arm_unregister(raw1394handle_t handle, nodeaddr_t start)
|
int raw1394_arm_unregister(raw1394handle_t handle, nodeaddr_t start)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_arm_unregister(handle->mode.fw, start);
|
return fw_arm_unregister(handle->mode.fw, start);
|
||||||
else
|
else
|
||||||
return ieee1394_arm_unregister(handle->mode.ieee1394, start);
|
return ieee1394_arm_unregister(handle->mode.ieee1394, start);
|
||||||
|
@ -182,7 +230,11 @@ int raw1394_arm_unregister(raw1394handle_t handle, nodeaddr_t start)
|
||||||
int raw1394_arm_set_buf (raw1394handle_t handle, nodeaddr_t start,
|
int raw1394_arm_set_buf (raw1394handle_t handle, nodeaddr_t start,
|
||||||
size_t length, void *buf)
|
size_t length, void *buf)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_arm_set_buf(handle->mode.fw, start, length, buf);
|
return fw_arm_set_buf(handle->mode.fw, start, length, buf);
|
||||||
else
|
else
|
||||||
return ieee1394_arm_set_buf(handle->mode.ieee1394, start, length, buf);
|
return ieee1394_arm_set_buf(handle->mode.ieee1394, start, length, buf);
|
||||||
|
@ -191,7 +243,11 @@ int raw1394_arm_set_buf (raw1394handle_t handle, nodeaddr_t start,
|
||||||
int raw1394_arm_get_buf (raw1394handle_t handle, nodeaddr_t start,
|
int raw1394_arm_get_buf (raw1394handle_t handle, nodeaddr_t start,
|
||||||
size_t length, void *buf)
|
size_t length, void *buf)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_arm_get_buf(handle->mode.fw, start, length, buf);
|
return fw_arm_get_buf(handle->mode.fw, start, length, buf);
|
||||||
else
|
else
|
||||||
return ieee1394_arm_get_buf(handle->mode.ieee1394, start, length, buf);
|
return ieee1394_arm_get_buf(handle->mode.ieee1394, start, length, buf);
|
||||||
|
@ -199,7 +255,11 @@ int raw1394_arm_get_buf (raw1394handle_t handle, nodeaddr_t start,
|
||||||
|
|
||||||
int raw1394_echo_request(raw1394handle_t handle, quadlet_t data)
|
int raw1394_echo_request(raw1394handle_t handle, quadlet_t data)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_echo_request(handle->mode.fw, data);
|
return fw_echo_request(handle->mode.fw, data);
|
||||||
else
|
else
|
||||||
return ieee1394_echo_request(handle->mode.ieee1394, data);
|
return ieee1394_echo_request(handle->mode.ieee1394, data);
|
||||||
|
@ -207,7 +267,11 @@ int raw1394_echo_request(raw1394handle_t handle, quadlet_t data)
|
||||||
|
|
||||||
int raw1394_wake_up(raw1394handle_t handle)
|
int raw1394_wake_up(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_wake_up(handle->mode.fw);
|
return fw_wake_up(handle->mode.fw);
|
||||||
else
|
else
|
||||||
return ieee1394_wake_up(handle->mode.ieee1394);
|
return ieee1394_wake_up(handle->mode.ieee1394);
|
||||||
|
@ -215,7 +279,11 @@ int raw1394_wake_up(raw1394handle_t handle)
|
||||||
|
|
||||||
int raw1394_phy_packet_write (raw1394handle_t handle, quadlet_t data)
|
int raw1394_phy_packet_write (raw1394handle_t handle, quadlet_t data)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_phy_packet_write(handle->mode.fw, data);
|
return fw_phy_packet_write(handle->mode.fw, data);
|
||||||
else
|
else
|
||||||
return ieee1394_phy_packet_write(handle, data);
|
return ieee1394_phy_packet_write(handle, data);
|
||||||
|
@ -224,7 +292,11 @@ int raw1394_phy_packet_write (raw1394handle_t handle, quadlet_t data)
|
||||||
int raw1394_start_phy_packet_write(raw1394handle_t handle,
|
int raw1394_start_phy_packet_write(raw1394handle_t handle,
|
||||||
quadlet_t data, unsigned long tag)
|
quadlet_t data, unsigned long tag)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_start_phy_packet_write(handle->mode.fw, data, tag);
|
return fw_start_phy_packet_write(handle->mode.fw, data, tag);
|
||||||
else
|
else
|
||||||
return ieee1394_start_phy_packet_write(handle->mode.ieee1394, data, tag);
|
return ieee1394_start_phy_packet_write(handle->mode.ieee1394, data, tag);
|
||||||
|
@ -233,7 +305,11 @@ int raw1394_start_phy_packet_write(raw1394handle_t handle,
|
||||||
int raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
int raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
||||||
size_t length, quadlet_t *buffer, unsigned long tag)
|
size_t length, quadlet_t *buffer, unsigned long tag)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_start_read(handle->mode.fw, node, addr, length, buffer, tag);
|
return fw_start_read(handle->mode.fw, node, addr, length, buffer, tag);
|
||||||
else
|
else
|
||||||
return ieee1394_start_read(handle->mode.ieee1394, node, addr, length, buffer, tag);
|
return ieee1394_start_read(handle->mode.ieee1394, node, addr, length, buffer, tag);
|
||||||
|
@ -242,7 +318,11 @@ int raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
||||||
int raw1394_start_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
int raw1394_start_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
||||||
size_t length, quadlet_t *data, unsigned long tag)
|
size_t length, quadlet_t *data, unsigned long tag)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_start_write(handle->mode.fw, node, addr, length, data, tag);
|
return fw_start_write(handle->mode.fw, node, addr, length, data, tag);
|
||||||
else
|
else
|
||||||
return ieee1394_start_write(handle->mode.ieee1394, node, addr, length, data, tag);
|
return ieee1394_start_write(handle->mode.ieee1394, node, addr, length, data, tag);
|
||||||
|
@ -252,7 +332,11 @@ int raw1394_start_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
||||||
unsigned int extcode, quadlet_t data, quadlet_t arg,
|
unsigned int extcode, quadlet_t data, quadlet_t arg,
|
||||||
quadlet_t *result, unsigned long tag)
|
quadlet_t *result, unsigned long tag)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_start_lock(handle->mode.fw, node, addr, extcode, data, arg, result, tag);
|
return fw_start_lock(handle->mode.fw, node, addr, extcode, data, arg, result, tag);
|
||||||
else
|
else
|
||||||
return ieee1394_start_lock(handle->mode.ieee1394, node, addr, extcode, data, arg, result, tag);
|
return ieee1394_start_lock(handle->mode.ieee1394, node, addr, extcode, data, arg, result, tag);
|
||||||
|
@ -262,7 +346,11 @@ int raw1394_start_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
||||||
unsigned int extcode, octlet_t data, octlet_t arg,
|
unsigned int extcode, octlet_t data, octlet_t arg,
|
||||||
octlet_t *result, unsigned long tag)
|
octlet_t *result, unsigned long tag)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_start_lock64(handle->mode.fw, node, addr, extcode, data, arg, result, tag);
|
return fw_start_lock64(handle->mode.fw, node, addr, extcode, data, arg, result, tag);
|
||||||
else
|
else
|
||||||
return ieee1394_start_lock64(handle->mode.ieee1394, node, addr, extcode, data, arg, result, tag);
|
return ieee1394_start_lock64(handle->mode.ieee1394, node, addr, extcode, data, arg, result, tag);
|
||||||
|
@ -273,7 +361,11 @@ int raw1394_start_async_stream(raw1394handle_t handle, unsigned int channel,
|
||||||
unsigned int speed, size_t length, quadlet_t *data,
|
unsigned int speed, size_t length, quadlet_t *data,
|
||||||
unsigned long rawtag)
|
unsigned long rawtag)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_start_async_stream(handle->mode.fw, channel, tag, sy, speed, length, data, rawtag);
|
return fw_start_async_stream(handle->mode.fw, channel, tag, sy, speed, length, data, rawtag);
|
||||||
else
|
else
|
||||||
return ieee1394_start_async_stream(handle->mode.ieee1394, channel, tag, sy, speed, length, data, rawtag);
|
return ieee1394_start_async_stream(handle->mode.ieee1394, channel, tag, sy, speed, length, data, rawtag);
|
||||||
|
@ -284,7 +376,11 @@ int raw1394_start_async_send(raw1394handle_t handle,
|
||||||
unsigned int expect_response,
|
unsigned int expect_response,
|
||||||
quadlet_t *data, unsigned long rawtag)
|
quadlet_t *data, unsigned long rawtag)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_start_async_send(handle->mode.fw, length, header_length,
|
return fw_start_async_send(handle->mode.fw, length, header_length,
|
||||||
expect_response, data, rawtag);
|
expect_response, data, rawtag);
|
||||||
else
|
else
|
||||||
|
@ -295,7 +391,11 @@ int raw1394_start_async_send(raw1394handle_t handle,
|
||||||
int raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
int raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
||||||
size_t length, quadlet_t *buffer)
|
size_t length, quadlet_t *buffer)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_read(handle, node, addr, length, buffer);
|
return fw_read(handle, node, addr, length, buffer);
|
||||||
else
|
else
|
||||||
return ieee1394_read(handle, node, addr, length, buffer);
|
return ieee1394_read(handle, node, addr, length, buffer);
|
||||||
|
@ -304,7 +404,11 @@ int raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
||||||
int raw1394_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
int raw1394_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
||||||
size_t length, quadlet_t *data)
|
size_t length, quadlet_t *data)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_write(handle, node, addr, length, data);
|
return fw_write(handle, node, addr, length, data);
|
||||||
else
|
else
|
||||||
return ieee1394_write(handle, node, addr, length, data);
|
return ieee1394_write(handle, node, addr, length, data);
|
||||||
|
@ -314,7 +418,11 @@ int raw1394_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
||||||
unsigned int extcode, quadlet_t data, quadlet_t arg,
|
unsigned int extcode, quadlet_t data, quadlet_t arg,
|
||||||
quadlet_t *result)
|
quadlet_t *result)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_lock(handle, node, addr, extcode, data, arg, result);
|
return fw_lock(handle, node, addr, extcode, data, arg, result);
|
||||||
else
|
else
|
||||||
return ieee1394_lock(handle, node, addr, extcode, data, arg, result);
|
return ieee1394_lock(handle, node, addr, extcode, data, arg, result);
|
||||||
|
@ -324,7 +432,11 @@ int raw1394_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
|
||||||
unsigned int extcode, octlet_t data, octlet_t arg,
|
unsigned int extcode, octlet_t data, octlet_t arg,
|
||||||
octlet_t *result)
|
octlet_t *result)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_lock64(handle, node, addr, extcode, data, arg, result);
|
return fw_lock64(handle, node, addr, extcode, data, arg, result);
|
||||||
else
|
else
|
||||||
return ieee1394_lock64(handle, node, addr, extcode, data, arg, result);
|
return ieee1394_lock64(handle, node, addr, extcode, data, arg, result);
|
||||||
|
@ -334,7 +446,11 @@ int raw1394_async_stream(raw1394handle_t handle, unsigned int channel,
|
||||||
unsigned int tag, unsigned int sy, unsigned int speed,
|
unsigned int tag, unsigned int sy, unsigned int speed,
|
||||||
size_t length, quadlet_t *data)
|
size_t length, quadlet_t *data)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_async_stream(handle->mode.fw, channel, tag, sy, speed, length, data);
|
return fw_async_stream(handle->mode.fw, channel, tag, sy, speed, length, data);
|
||||||
else
|
else
|
||||||
return ieee1394_async_stream(handle, channel, tag, sy, speed, length, data);
|
return ieee1394_async_stream(handle, channel, tag, sy, speed, length, data);
|
||||||
|
@ -345,7 +461,11 @@ int raw1394_async_send(raw1394handle_t handle,
|
||||||
unsigned int expect_response,
|
unsigned int expect_response,
|
||||||
quadlet_t *data)
|
quadlet_t *data)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_async_send(handle->mode.fw, length, header_length,
|
return fw_async_send(handle->mode.fw, length, header_length,
|
||||||
expect_response, data);
|
expect_response, data);
|
||||||
else
|
else
|
||||||
|
@ -355,7 +475,11 @@ int raw1394_async_send(raw1394handle_t handle,
|
||||||
|
|
||||||
int raw1394_start_fcp_listen(raw1394handle_t handle)
|
int raw1394_start_fcp_listen(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_start_fcp_listen(handle->mode.fw);
|
return fw_start_fcp_listen(handle->mode.fw);
|
||||||
else
|
else
|
||||||
return ieee1394_start_fcp_listen(handle);
|
return ieee1394_start_fcp_listen(handle);
|
||||||
|
@ -363,7 +487,11 @@ int raw1394_start_fcp_listen(raw1394handle_t handle)
|
||||||
|
|
||||||
int raw1394_stop_fcp_listen(raw1394handle_t handle)
|
int raw1394_stop_fcp_listen(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_stop_fcp_listen(handle->mode.fw);
|
return fw_stop_fcp_listen(handle->mode.fw);
|
||||||
else
|
else
|
||||||
return ieee1394_stop_fcp_listen(handle);
|
return ieee1394_stop_fcp_listen(handle);
|
||||||
|
@ -372,7 +500,11 @@ int raw1394_stop_fcp_listen(raw1394handle_t handle)
|
||||||
int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t
|
int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t
|
||||||
*new_rom, size_t size, unsigned char rom_version)
|
*new_rom, size_t size, unsigned char rom_version)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_update_config_rom(handle->mode.fw, new_rom, size, rom_version);
|
return fw_update_config_rom(handle->mode.fw, new_rom, size, rom_version);
|
||||||
else
|
else
|
||||||
return ieee1394_update_config_rom(handle->mode.ieee1394,
|
return ieee1394_update_config_rom(handle->mode.ieee1394,
|
||||||
|
@ -382,7 +514,11 @@ int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t
|
||||||
int raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer,
|
int raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer,
|
||||||
size_t buffersize, size_t *rom_size, unsigned char *rom_version)
|
size_t buffersize, size_t *rom_size, unsigned char *rom_version)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_get_config_rom(handle->mode.fw, buffer, buffersize,
|
return fw_get_config_rom(handle->mode.fw, buffer, buffersize,
|
||||||
rom_size, rom_version);
|
rom_size, rom_version);
|
||||||
else
|
else
|
||||||
|
@ -393,7 +529,11 @@ int raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer,
|
||||||
int raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth,
|
int raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth,
|
||||||
enum raw1394_modify_mode mode)
|
enum raw1394_modify_mode mode)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_bandwidth_modify(handle, bandwidth, mode);
|
return fw_bandwidth_modify(handle, bandwidth, mode);
|
||||||
else
|
else
|
||||||
return ieee1394_bandwidth_modify(handle, bandwidth, mode);
|
return ieee1394_bandwidth_modify(handle, bandwidth, mode);
|
||||||
|
@ -402,7 +542,11 @@ int raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth,
|
||||||
int raw1394_channel_modify (raw1394handle_t handle, unsigned int channel,
|
int raw1394_channel_modify (raw1394handle_t handle, unsigned int channel,
|
||||||
enum raw1394_modify_mode mode)
|
enum raw1394_modify_mode mode)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_channel_modify(handle, channel, mode);
|
return fw_channel_modify(handle, channel, mode);
|
||||||
else
|
else
|
||||||
return ieee1394_channel_modify(handle, channel, mode);
|
return ieee1394_channel_modify(handle, channel, mode);
|
||||||
|
@ -416,7 +560,11 @@ int raw1394_iso_xmit_init(raw1394handle_t handle,
|
||||||
enum raw1394_iso_speed speed,
|
enum raw1394_iso_speed speed,
|
||||||
int irq_interval)
|
int irq_interval)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_xmit_init(handle->mode.fw, handler, buf_packets,
|
return fw_iso_xmit_init(handle->mode.fw, handler, buf_packets,
|
||||||
max_packet_size, channel, speed, irq_interval);
|
max_packet_size, channel, speed, irq_interval);
|
||||||
else
|
else
|
||||||
|
@ -432,7 +580,11 @@ int raw1394_iso_recv_init(raw1394handle_t handle,
|
||||||
enum raw1394_iso_dma_recv_mode mode,
|
enum raw1394_iso_dma_recv_mode mode,
|
||||||
int irq_interval)
|
int irq_interval)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_recv_init(handle->mode.fw, handler, buf_packets,
|
return fw_iso_recv_init(handle->mode.fw, handler, buf_packets,
|
||||||
max_packet_size, channel, mode, irq_interval);
|
max_packet_size, channel, mode, irq_interval);
|
||||||
else
|
else
|
||||||
|
@ -446,7 +598,11 @@ int raw1394_iso_multichannel_recv_init(raw1394handle_t handle,
|
||||||
unsigned int max_packet_size,
|
unsigned int max_packet_size,
|
||||||
int irq_interval)
|
int irq_interval)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_multichannel_recv_init(handle->mode.fw, handler, buf_packets,
|
return fw_iso_multichannel_recv_init(handle->mode.fw, handler, buf_packets,
|
||||||
max_packet_size, irq_interval);
|
max_packet_size, irq_interval);
|
||||||
else
|
else
|
||||||
|
@ -457,7 +613,11 @@ int raw1394_iso_multichannel_recv_init(raw1394handle_t handle,
|
||||||
int raw1394_iso_recv_listen_channel(raw1394handle_t handle,
|
int raw1394_iso_recv_listen_channel(raw1394handle_t handle,
|
||||||
unsigned char channel)
|
unsigned char channel)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_recv_listen_channel(handle->mode.fw, channel);
|
return fw_iso_recv_listen_channel(handle->mode.fw, channel);
|
||||||
else
|
else
|
||||||
return ieee1394_iso_recv_listen_channel(handle->mode.ieee1394, channel);
|
return ieee1394_iso_recv_listen_channel(handle->mode.ieee1394, channel);
|
||||||
|
@ -466,7 +626,11 @@ int raw1394_iso_recv_listen_channel(raw1394handle_t handle,
|
||||||
int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle,
|
int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle,
|
||||||
unsigned char channel)
|
unsigned char channel)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_recv_unlisten_channel(handle->mode.fw, channel);
|
return fw_iso_recv_unlisten_channel(handle->mode.fw, channel);
|
||||||
else
|
else
|
||||||
return ieee1394_iso_recv_unlisten_channel(handle->mode.ieee1394, channel);
|
return ieee1394_iso_recv_unlisten_channel(handle->mode.ieee1394, channel);
|
||||||
|
@ -474,7 +638,11 @@ int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle,
|
||||||
|
|
||||||
int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask)
|
int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_recv_set_channel_mask(handle->mode.fw, mask);
|
return fw_iso_recv_set_channel_mask(handle->mode.fw, mask);
|
||||||
else
|
else
|
||||||
return ieee1394_iso_recv_set_channel_mask(handle->mode.ieee1394, mask);
|
return ieee1394_iso_recv_set_channel_mask(handle->mode.ieee1394, mask);
|
||||||
|
@ -483,7 +651,11 @@ int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask)
|
||||||
int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle,
|
int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle,
|
||||||
int prebuffer_packets)
|
int prebuffer_packets)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_xmit_start(handle,
|
return fw_iso_xmit_start(handle,
|
||||||
start_on_cycle, prebuffer_packets);
|
start_on_cycle, prebuffer_packets);
|
||||||
else
|
else
|
||||||
|
@ -494,7 +666,11 @@ int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle,
|
||||||
int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle,
|
int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle,
|
||||||
int tag_mask, int sync)
|
int tag_mask, int sync)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_recv_start(handle->mode.fw,
|
return fw_iso_recv_start(handle->mode.fw,
|
||||||
start_on_cycle, tag_mask, sync);
|
start_on_cycle, tag_mask, sync);
|
||||||
else
|
else
|
||||||
|
@ -506,7 +682,11 @@ int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data,
|
||||||
unsigned int len, unsigned char tag,
|
unsigned int len, unsigned char tag,
|
||||||
unsigned char sy)
|
unsigned char sy)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_xmit_write(handle, data, len, tag, sy);
|
return fw_iso_xmit_write(handle, data, len, tag, sy);
|
||||||
else
|
else
|
||||||
return ieee1394_iso_xmit_write(handle, data, len, tag, sy);
|
return ieee1394_iso_xmit_write(handle, data, len, tag, sy);
|
||||||
|
@ -514,7 +694,11 @@ int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data,
|
||||||
|
|
||||||
int raw1394_iso_xmit_sync(raw1394handle_t handle)
|
int raw1394_iso_xmit_sync(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_xmit_sync(handle);
|
return fw_iso_xmit_sync(handle);
|
||||||
else
|
else
|
||||||
return ieee1394_iso_xmit_sync(handle->mode.ieee1394);
|
return ieee1394_iso_xmit_sync(handle->mode.ieee1394);
|
||||||
|
@ -522,7 +706,11 @@ int raw1394_iso_xmit_sync(raw1394handle_t handle)
|
||||||
|
|
||||||
int raw1394_iso_recv_flush(raw1394handle_t handle)
|
int raw1394_iso_recv_flush(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_iso_recv_flush(handle->mode.fw);
|
return fw_iso_recv_flush(handle->mode.fw);
|
||||||
else
|
else
|
||||||
return ieee1394_iso_recv_flush(handle->mode.ieee1394);
|
return ieee1394_iso_recv_flush(handle->mode.ieee1394);
|
||||||
|
@ -530,7 +718,10 @@ int raw1394_iso_recv_flush(raw1394handle_t handle)
|
||||||
|
|
||||||
void raw1394_iso_stop(raw1394handle_t handle)
|
void raw1394_iso_stop(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
fw_iso_stop(handle->mode.fw);
|
fw_iso_stop(handle->mode.fw);
|
||||||
else
|
else
|
||||||
ieee1394_iso_stop(handle->mode.ieee1394);
|
ieee1394_iso_stop(handle->mode.ieee1394);
|
||||||
|
@ -538,7 +729,10 @@ void raw1394_iso_stop(raw1394handle_t handle)
|
||||||
|
|
||||||
void raw1394_iso_shutdown(raw1394handle_t handle)
|
void raw1394_iso_shutdown(raw1394handle_t handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
fw_iso_shutdown(handle->mode.fw);
|
fw_iso_shutdown(handle->mode.fw);
|
||||||
else
|
else
|
||||||
ieee1394_iso_shutdown(handle->mode.ieee1394);
|
ieee1394_iso_shutdown(handle->mode.ieee1394);
|
||||||
|
@ -547,7 +741,11 @@ void raw1394_iso_shutdown(raw1394handle_t handle)
|
||||||
int raw1394_read_cycle_timer(raw1394handle_t handle,
|
int raw1394_read_cycle_timer(raw1394handle_t handle,
|
||||||
u_int32_t *cycle_timer, u_int64_t *local_time)
|
u_int32_t *cycle_timer, u_int64_t *local_time)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return fw_read_cycle_timer(handle->mode.fw,
|
return fw_read_cycle_timer(handle->mode.fw,
|
||||||
cycle_timer, local_time);
|
cycle_timer, local_time);
|
||||||
else
|
else
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
|
|
||||||
raw1394_errcode_t raw1394_get_errcode(struct raw1394_handle *handle)
|
raw1394_errcode_t raw1394_get_errcode(struct raw1394_handle *handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
return RAW1394_ERROR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return handle->mode.fw->err;
|
return handle->mode.fw->err;
|
||||||
else
|
else
|
||||||
return handle->mode.ieee1394->err;
|
return handle->mode.ieee1394->err;
|
||||||
|
|
|
@ -97,7 +97,11 @@ bus_reset_handler_t raw1394_set_bus_reset_handler(struct raw1394_handle *handle,
|
||||||
bus_reset_handler_t new)
|
bus_reset_handler_t new)
|
||||||
{
|
{
|
||||||
bus_reset_handler_t old;
|
bus_reset_handler_t old;
|
||||||
if (handle && handle->is_fw) {
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (handle->is_fw) {
|
||||||
old = handle->mode.fw->bus_reset_handler;
|
old = handle->mode.fw->bus_reset_handler;
|
||||||
handle->mode.fw->bus_reset_handler = new;
|
handle->mode.fw->bus_reset_handler = new;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +116,11 @@ tag_handler_t raw1394_set_tag_handler(struct raw1394_handle *handle,
|
||||||
tag_handler_t new)
|
tag_handler_t new)
|
||||||
{
|
{
|
||||||
tag_handler_t old;
|
tag_handler_t old;
|
||||||
if (handle && handle->is_fw) {
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (handle->is_fw) {
|
||||||
old = handle->mode.fw->tag_handler;
|
old = handle->mode.fw->tag_handler;
|
||||||
handle->mode.fw->tag_handler = new;
|
handle->mode.fw->tag_handler = new;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +135,11 @@ arm_tag_handler_t raw1394_set_arm_tag_handler(struct raw1394_handle *handle,
|
||||||
arm_tag_handler_t new)
|
arm_tag_handler_t new)
|
||||||
{
|
{
|
||||||
arm_tag_handler_t old;
|
arm_tag_handler_t old;
|
||||||
if (handle && handle->is_fw) {
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (handle->is_fw) {
|
||||||
old = handle->mode.fw->arm_tag_handler;
|
old = handle->mode.fw->arm_tag_handler;
|
||||||
handle->mode.fw->arm_tag_handler = new;
|
handle->mode.fw->arm_tag_handler = new;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +154,11 @@ fcp_handler_t raw1394_set_fcp_handler(struct raw1394_handle *handle,
|
||||||
fcp_handler_t new)
|
fcp_handler_t new)
|
||||||
{
|
{
|
||||||
fcp_handler_t old;
|
fcp_handler_t old;
|
||||||
if (handle && handle->is_fw) {
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (handle->is_fw) {
|
||||||
old = handle->mode.fw->fcp_handler;
|
old = handle->mode.fw->fcp_handler;
|
||||||
handle->mode.fw->fcp_handler = new;
|
handle->mode.fw->fcp_handler = new;
|
||||||
}
|
}
|
||||||
|
|
42
src/main.c
42
src/main.c
|
@ -28,6 +28,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include "raw1394.h"
|
#include "raw1394.h"
|
||||||
#include "csr.h"
|
#include "csr.h"
|
||||||
|
@ -178,7 +179,11 @@ int ieee1394_get_fd(struct ieee1394_handle *handle)
|
||||||
|
|
||||||
unsigned int raw1394_get_generation(struct raw1394_handle *handle)
|
unsigned int raw1394_get_generation(struct raw1394_handle *handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return UINT_MAX;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return handle->mode.fw->generation;
|
return handle->mode.fw->generation;
|
||||||
else
|
else
|
||||||
return handle->mode.ieee1394->generation;
|
return handle->mode.ieee1394->generation;
|
||||||
|
@ -186,7 +191,10 @@ unsigned int raw1394_get_generation(struct raw1394_handle *handle)
|
||||||
|
|
||||||
void raw1394_update_generation(struct raw1394_handle *handle, unsigned int gen)
|
void raw1394_update_generation(struct raw1394_handle *handle, unsigned int gen)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
handle->mode.fw->generation = gen;
|
handle->mode.fw->generation = gen;
|
||||||
else
|
else
|
||||||
handle->mode.ieee1394->generation = gen;
|
handle->mode.ieee1394->generation = gen;
|
||||||
|
@ -194,22 +202,37 @@ void raw1394_update_generation(struct raw1394_handle *handle, unsigned int gen)
|
||||||
|
|
||||||
int ieee1394_get_nodecount(struct ieee1394_handle *handle)
|
int ieee1394_get_nodecount(struct ieee1394_handle *handle)
|
||||||
{
|
{
|
||||||
return handle->num_of_nodes;
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return UINT_MAX;
|
||||||
|
}
|
||||||
|
return handle->num_of_nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeid_t ieee1394_get_local_id(struct ieee1394_handle *handle)
|
nodeid_t ieee1394_get_local_id(struct ieee1394_handle *handle)
|
||||||
{
|
{
|
||||||
return handle->local_id;
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return 0xFFFF;
|
||||||
|
}
|
||||||
|
return handle->local_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeid_t ieee1394_get_irm_id(struct ieee1394_handle *handle)
|
nodeid_t ieee1394_get_irm_id(struct ieee1394_handle *handle)
|
||||||
{
|
{
|
||||||
return handle->irm_id;
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return 0xFFFF;
|
||||||
|
}
|
||||||
|
return handle->irm_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw1394_set_userdata(struct raw1394_handle *handle, void *data)
|
void raw1394_set_userdata(struct raw1394_handle *handle, void *data)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
handle->mode.fw->userdata = data;
|
handle->mode.fw->userdata = data;
|
||||||
else
|
else
|
||||||
handle->mode.ieee1394->userdata = data;
|
handle->mode.ieee1394->userdata = data;
|
||||||
|
@ -217,7 +240,11 @@ void raw1394_set_userdata(struct raw1394_handle *handle, void *data)
|
||||||
|
|
||||||
void *raw1394_get_userdata(struct raw1394_handle *handle)
|
void *raw1394_get_userdata(struct raw1394_handle *handle)
|
||||||
{
|
{
|
||||||
if (handle && handle->is_fw)
|
if (!handle) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (handle->is_fw)
|
||||||
return handle->mode.fw->userdata;
|
return handle->mode.fw->userdata;
|
||||||
else
|
else
|
||||||
return handle->mode.ieee1394->userdata;
|
return handle->mode.ieee1394->userdata;
|
||||||
|
@ -503,4 +530,3 @@ int ieee1394_channel_modify (raw1394handle_t handle, unsigned int channel,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -458,7 +458,8 @@ int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch);
|
||||||
* the blocking behaviour in raw1394_loop_iterate(). It must not be used for
|
* the blocking behaviour in raw1394_loop_iterate(). It must not be used for
|
||||||
* anything else.
|
* anything else.
|
||||||
*
|
*
|
||||||
* Returns: the fd used for communication with the raw1394 kernel module.
|
* Returns: the fd used for communication with the raw1394 kernel module or -1
|
||||||
|
* on failure (sets errno).
|
||||||
**/
|
**/
|
||||||
int raw1394_get_fd(raw1394handle_t handle);
|
int raw1394_get_fd(raw1394handle_t handle);
|
||||||
|
|
||||||
|
@ -603,7 +604,7 @@ typedef int (*bus_reset_handler_t)(raw1394handle_t, unsigned int generation);
|
||||||
* Sets the handler to be called on every bus reset to @new_h.
|
* Sets the handler to be called on every bus reset to @new_h.
|
||||||
* The default handler just calls raw1394_update_generation().
|
* The default handler just calls raw1394_update_generation().
|
||||||
*
|
*
|
||||||
* Returns: the old handler
|
* Returns: the old handler or NULL on failure (sets errno)
|
||||||
**/
|
**/
|
||||||
bus_reset_handler_t raw1394_set_bus_reset_handler(raw1394handle_t handle,
|
bus_reset_handler_t raw1394_set_bus_reset_handler(raw1394handle_t handle,
|
||||||
bus_reset_handler_t new_h);
|
bus_reset_handler_t new_h);
|
||||||
|
@ -618,7 +619,8 @@ bus_reset_handler_t raw1394_set_bus_reset_handler(raw1394handle_t handle,
|
||||||
* The generation number of the handle is not automatically updated,
|
* The generation number of the handle is not automatically updated,
|
||||||
* raw1394_update_generation() has to be used for this.
|
* raw1394_update_generation() has to be used for this.
|
||||||
*
|
*
|
||||||
* Returns: the generation number associated with the handle
|
* Returns: the generation number associated with the handle or UINT_MAX on
|
||||||
|
* failure.
|
||||||
**/
|
**/
|
||||||
unsigned int raw1394_get_generation(raw1394handle_t handle);
|
unsigned int raw1394_get_generation(raw1394handle_t handle);
|
||||||
|
|
||||||
|
@ -654,7 +656,7 @@ typedef int (*tag_handler_t)(raw1394handle_t, unsigned long tag,
|
||||||
* raw1394_lock()) since these do pass pointers to &struct
|
* raw1394_lock()) since these do pass pointers to &struct
|
||||||
* raw1394_reqhandle as the tag and expect the callback to be invoked.
|
* raw1394_reqhandle as the tag and expect the callback to be invoked.
|
||||||
*
|
*
|
||||||
* Returns: the old handler
|
* Returns: the old handler or NULL on failure (sets errno)
|
||||||
**/
|
**/
|
||||||
tag_handler_t raw1394_set_tag_handler(raw1394handle_t handle,
|
tag_handler_t raw1394_set_tag_handler(raw1394handle_t handle,
|
||||||
tag_handler_t new_h);
|
tag_handler_t new_h);
|
||||||
|
@ -672,7 +674,7 @@ typedef int (*arm_tag_handler_t)(raw1394handle_t handle, unsigned long arm_tag,
|
||||||
* arrived. The default action is to call the arm_callback in the
|
* arrived. The default action is to call the arm_callback in the
|
||||||
* raw1394_arm_reqhandle pointed to by arm_tag.
|
* raw1394_arm_reqhandle pointed to by arm_tag.
|
||||||
*
|
*
|
||||||
* Returns: old handler
|
* Returns: old handler or NULL on failure (sets errno)
|
||||||
**/
|
**/
|
||||||
arm_tag_handler_t raw1394_set_arm_tag_handler(raw1394handle_t handle,
|
arm_tag_handler_t raw1394_set_arm_tag_handler(raw1394handle_t handle,
|
||||||
arm_tag_handler_t new_h);
|
arm_tag_handler_t new_h);
|
||||||
|
@ -692,7 +694,7 @@ typedef int (*fcp_handler_t)(raw1394handle_t, nodeid_t nodeid, int response,
|
||||||
* In order to actually get FCP events, you have to enable it with
|
* In order to actually get FCP events, you have to enable it with
|
||||||
* raw1394_start_fcp_listen() and can stop it with raw1394_stop_fcp_listen().
|
* raw1394_start_fcp_listen() and can stop it with raw1394_stop_fcp_listen().
|
||||||
*
|
*
|
||||||
* Returns: the old handler
|
* Returns: the old handler or NULL on failure (sets errno)
|
||||||
**/
|
**/
|
||||||
fcp_handler_t raw1394_set_fcp_handler(raw1394handle_t handle, fcp_handler_t new_h);
|
fcp_handler_t raw1394_set_fcp_handler(raw1394handle_t handle, fcp_handler_t new_h);
|
||||||
|
|
||||||
|
|
Reference in New Issue