Ignore:
Timestamp:
2023-09-16T19:58:18Z (16 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7d7f5e3
Parents:
6a0b2cc
git-author:
Jiri Svoboda <jiri@…> (2023-09-16 19:48:07)
git-committer:
Jiri Svoboda <jiri@…> (2023-09-16 19:58:18)
Message:

loc_server_register() should be callable more than once (API only)

Now loc_server_register() returns a pointer to a loc_srv_t object,
that is then passed to loc_service_register() and
loc_service_add_to_cat().

Added loc_server_unregister() that unregisters the server
and frees the loc_srv_t object.

Updated all callers. The implementation, however, is a stub.
It is not actually possible to call loc_server_register() more
than once, yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c

    r6a0b2cc r4c6fd56  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    8181int main(int argc, char *argv[])
    8282{
     83        loc_srv_t *srv;
     84
    8385        printf("%s: S3C24xx touchscreen driver\n", NAME);
    8486
    8587        async_set_fallback_port_handler(s3c24xx_ts_connection, NULL);
    86         errno_t rc = loc_server_register(NAME);
     88        errno_t rc = loc_server_register(NAME, &srv);
    8789        if (rc != EOK) {
    8890                printf("%s: Unable to register driver.\n", NAME);
     
    9193
    9294        ts = malloc(sizeof(s3c24xx_ts_t));
    93         if (ts == NULL)
     95        if (ts == NULL) {
     96                loc_server_unregister(srv);
    9497                return -1;
    95 
    96         if (s3c24xx_ts_init(ts) != EOK)
     98        }
     99
     100        if (s3c24xx_ts_init(ts) != EOK) {
     101                free(ts);
     102                loc_server_unregister(srv);
    97103                return -1;
    98 
    99         rc = loc_service_register(NAMESPACE "/mouse", &ts->service_id);
     104        }
     105
     106        rc = loc_service_register(srv, NAMESPACE "/mouse", &ts->service_id);
    100107        if (rc != EOK) {
     108                // XXX s3c24xx_ts_fini();
     109                free(ts);
     110                loc_server_unregister(srv);
    101111                printf(NAME ": Unable to register device %s.\n",
    102112                    NAMESPACE "/mouse");
Note: See TracChangeset for help on using the changeset viewer.