add raw1394_new_handle_on_port() convenience function

git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@104 53a565d1-3bb7-0310-b661-cf11e63c67ab
This commit is contained in:
dmaas 2003-03-26 22:48:46 +00:00
parent e753a09b38
commit 081780c175
2 changed files with 41 additions and 1 deletions

View File

@ -394,6 +394,38 @@ int raw1394_set_port(struct raw1394_handle *handle, int port)
}
}
/**
* raw1394_new_handle_on_port - create a new handle and bind it to a port
* @port: port to connect to (same as argument to raw1394_set_port())
*
* Same as raw1394_new_handle(), but also binds the handle to the
* specified 1394 port. Equivalent to raw1394_new_handle() followed by
* raw1394_get_port_info() and raw1394_set_port(). Useful for
* command-line programs that already know what port they want. If
* raw1394_set_port() returns ESTALE, retries automatically.
**/
raw1394handle_t raw1394_new_handle_on_port(int port)
{
raw1394handle_t handle = raw1394_new_handle();
if (!handle)
return NULL;
tryagain:
if (raw1394_get_port_info(handle, NULL, 0) < 0)
return NULL;
if (raw1394_set_port(handle, port)) {
if (errno == ESTALE || errno == EINTR) {
goto tryagain;
} else {
raw1394_destroy_handle(handle);
return NULL;
}
}
return handle;
}
int raw1394_reset_bus_new(struct raw1394_handle *handle, int type)
{
struct raw1394_request *req = &handle->req;

View File

@ -156,6 +156,14 @@ int raw1394_errcode_to_errno(raw1394_errcode_t);
raw1394handle_t raw1394_new_handle(void);
void raw1394_destroy_handle(raw1394handle_t handle);
/*
* Same as raw1394_new_handle(), but also binds the handle to the
* specified 1394 port. Equivalent to raw1394_new_handle() followed by
* raw1394_get_port_info() and raw1394_set_port(). Useful for
* command-line programs that already know what port they want.
*/
raw1394handle_t raw1394_new_handle_on_port(int port);
/*
* Switch off/on busreset-notification for handle
* return-value: