diff options
author | Pawel Szewczyk <p.szewczyk@samsung.com> | 2015-09-04 12:23:51 +0200 |
---|---|---|
committer | Pawel Szewczyk <p.szewczyk@samsung.com> | 2015-09-22 16:32:16 +0200 |
commit | 6b7e59231014b94636f4a1b730143fbe6f60c3f4 (patch) | |
tree | 56638d1c47a56d87935aba6ef52d2b560670a435 /src/core/socket.c | |
parent | 602524469ecd7db0e0d5a71ecd1dce34f7a108b6 (diff) |
core: Add FFSDescriptors and FFSStrings service parameters
By using these parameters functionfs service can specify ffs descriptors
and strings which should be written to ep0.
Diffstat (limited to 'src/core/socket.c')
-rw-r--r-- | src/core/socket.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/socket.c b/src/core/socket.c index d8de58ef15..54e94c4f74 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -50,6 +50,7 @@ #include "formats-util.h" #include "signal-util.h" #include "socket.h" +#include "copy.h" static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = { [SOCKET_DEAD] = UNIT_INACTIVE, @@ -1165,6 +1166,22 @@ static int socket_symlink(Socket *s) { return 0; } +static int ffs_write_descs(int fd, Unit *u) { + Service *s = SERVICE(u); + int r; + + if (!s->usb_function_descriptors || !s->usb_function_strings) + return -EINVAL; + + r = copy_file_fd(s->usb_function_descriptors, fd, false); + if (r < 0) + return 0; + + r = copy_file_fd(s->usb_function_strings, fd, false); + + return r; +} + static int select_ep(const struct dirent *d) { return d->d_name[0] != '.' && !streq(d->d_name, "ep0"); } @@ -1323,6 +1340,10 @@ static int socket_open_fds(Socket *s) { if (r < 0) goto rollback; + r = ffs_write_descs(p->fd, s->service.unit); + if (r < 0) + goto rollback; + r = ffs_dispatch_eps(p); if (r < 0) goto rollback; |