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/hw/char/s3c24xx_uart/s3c24xx_uart.c

    r6a0b2cc r4c6fd56  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    8080int main(int argc, char *argv[])
    8181{
     82        loc_srv_t *srv;
     83
    8284        printf("%s: S3C24xx on-chip UART driver\n", NAME);
    8385
    8486        async_set_fallback_port_handler(s3c24xx_uart_connection, uart);
    85         errno_t rc = loc_server_register(NAME);
     87        errno_t rc = loc_server_register(NAME, &srv);
    8688        if (rc != EOK) {
    8789                printf("%s: Unable to register server.\n", NAME);
     
    9092
    9193        uart = malloc(sizeof(s3c24xx_uart_t));
    92         if (uart == NULL)
    93                 return -1;
    94 
    95         if (s3c24xx_uart_init(uart) != EOK)
    96                 return -1;
    97 
    98         rc = loc_service_register(NAMESPACE "/" NAME, &uart->service_id);
     94        if (uart == NULL) {
     95                loc_server_unregister(srv);
     96                return -1;
     97        }
     98
     99        if (s3c24xx_uart_init(uart) != EOK) {
     100                free(uart);
     101                loc_server_unregister(srv);
     102                return -1;
     103        }
     104
     105        rc = loc_service_register(srv, NAMESPACE "/" NAME, &uart->service_id);
    99106        if (rc != EOK) {
     107                // XXX s3c24xx_uart_fini(uart);
     108                free(uart);
     109                loc_server_unregister(srv);
    100110                printf(NAME ": Unable to register device %s.\n",
    101111                    NAMESPACE "/" NAME);
Note: See TracChangeset for help on using the changeset viewer.