Changeset 4f87a85a in mainline


Ignore:
Timestamp:
2018-12-10T14:29:35Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ca4c5596
Parents:
433d52f
git-author:
Jiri Svoboda <jiri@…> (2018-12-10 07:39:07)
git-committer:
Jiri Svoboda <jiri@…> (2018-12-10 14:29:35)
Message:

Check return code from ddf_add_fun_to_category

Location:
uspace
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/hdaudio/hdaudio.c

    r433d52f r4f87a85a  
    151151{
    152152        ddf_fun_t *fun_pcm = NULL;
     153        bool bound = false;
    153154        hda_t *hda = NULL;
    154155        hw_res_list_parsed_t res;
     
    299300        }
    300301
    301         ddf_fun_add_to_category(fun_pcm, "audio-pcm");
     302        bound = true;
     303
     304        rc = ddf_fun_add_to_category(fun_pcm, "audio-pcm");
     305        if (rc != EOK) {
     306                ddf_msg(LVL_ERROR, "Failed adding function to audio-pcm category.");
     307                goto error;
     308        }
    302309
    303310        hw_res_list_parsed_clean(&res);
    304311        return EOK;
    305312error:
     313        if (bound)
     314                ddf_fun_unbind(fun_pcm);
    306315        if (fun_pcm != NULL)
    307316                ddf_fun_destroy(fun_pcm);
  • uspace/drv/block/ata_bd/main.c

    r433d52f r4f87a85a  
    162162        ddf_fun_t *fun = NULL;
    163163        ata_fun_t *afun = NULL;
     164        bool bound = false;
    164165
    165166        fun_name = ata_fun_name(disk);
     
    202203        }
    203204
    204         ddf_fun_add_to_category(fun, "disk");
     205        bound = true;
     206
     207        rc = ddf_fun_add_to_category(fun, "disk");
     208        if (rc != EOK) {
     209                ddf_msg(LVL_ERROR, "Failed adding function %s to "
     210                    "category 'disk': %s", fun_name, str_error(rc));
     211                goto error;
     212        }
    205213
    206214        free(fun_name);
     
    208216        return EOK;
    209217error:
     218        if (bound)
     219                ddf_fun_unbind(fun);
    210220        if (fun != NULL)
    211221                ddf_fun_destroy(fun);
  • uspace/drv/block/ddisk/ddisk.c

    r433d52f r4f87a85a  
    319319        errno_t rc;
    320320        ddf_fun_t *fun = NULL;
     321        bool bound = false;
    321322
    322323        fun = ddf_fun_create(ddisk->dev, fun_exposed, DDISK_FUN_NAME);
     
    337338        }
    338339
    339         ddf_fun_add_to_category(fun, "disk");
     340        bound = true;
     341
     342        rc = ddf_fun_add_to_category(fun, "disk");
     343        if (rc != EOK) {
     344                ddf_msg(LVL_ERROR, "Failed adding function %s to category "
     345                    "'disk': %s.\n", DDISK_FUN_NAME, str_error(rc));
     346                goto error;
     347        }
    340348        ddisk->fun = fun;
    341349
    342350        return EOK;
    343351error:
     352        if (bound)
     353                ddf_fun_unbind(fun);
    344354        if (fun != NULL)
    345355                ddf_fun_destroy(fun);
  • uspace/drv/block/usbmast/main.c

    r433d52f r4f87a85a  
    223223        ddf_fun_t *fun = NULL;
    224224        usbmast_fun_t *mfun = NULL;
     225        bool bound = false;
    225226
    226227        if (asprintf(&fun_name, "l%u", lun) < 0) {
     
    299300        }
    300301
    301         ddf_fun_add_to_category(fun, "disk");
     302        bound = true;
     303
     304        rc = ddf_fun_add_to_category(fun, "disk");
     305        if (rc != EOK) {
     306                usb_log_error("Failed to add function %s to category 'disk': %s.",
     307                    fun_name, str_error(rc));
     308                goto error;
     309        }
    302310
    303311        free(fun_name);
     
    308316        /* Error cleanup */
    309317error:
     318        if (bound)
     319                ddf_fun_unbind(fun);
    310320        if (fun != NULL)
    311321                ddf_fun_destroy(fun);
  • uspace/drv/char/msim-con/msim-con.c

    r433d52f r4f87a85a  
    8585        irq_cmd_t *msim_cmds = NULL;
    8686        errno_t rc;
     87        bool bound = false;
    8788
    8889        circ_buf_init(&con->cbuf, con->buf, msim_con_buf_size, 1);
     
    143144        }
    144145
    145         ddf_fun_add_to_category(fun, "console");
     146        bound = true;
     147
     148        rc = ddf_fun_add_to_category(fun, "console");
     149        if (rc != EOK) {
     150                ddf_msg(LVL_ERROR, "Error adding function 'a' to category "
     151                    "'console'.");
     152                goto error;
     153        }
    146154
    147155        return EOK;
     
    149157        if (CAP_HANDLE_VALID(con->irq_handle))
    150158                async_irq_unsubscribe(con->irq_handle);
     159        if (bound)
     160                ddf_fun_unbind(fun);
    151161        if (fun != NULL)
    152162                ddf_fun_destroy(fun);
  • uspace/drv/char/ns8250/ns8250.c

    r433d52f r4f87a85a  
    829829        bool need_cleanup = false;
    830830        bool need_unreg_intr_handler = false;
     831        bool bound = false;
    831832        errno_t rc;
    832833
     
    909910        }
    910911
     912        bound = true;
    911913        ns->fun = fun;
    912914
    913         ddf_fun_add_to_category(fun, "serial");
     915        rc = ddf_fun_add_to_category(fun, "serial");
     916        if (rc != EOK) {
     917                ddf_msg(LVL_ERROR, "Error adding function to category 'serial'.");
     918                goto fail;
     919        }
    914920
    915921        ddf_msg(LVL_NOTE, "Device %s successfully initialized.",
     
    918924        return EOK;
    919925fail:
     926        if (bound)
     927                ddf_fun_unbind(fun);
    920928        if (fun != NULL)
    921929                ddf_fun_destroy(fun);
  • uspace/drv/char/ski-con/ski-con.c

    r433d52f r4f87a85a  
    112112        }
    113113
    114         ddf_fun_add_to_category(fun, "console");
    115 
    116114        bound = true;
     115
     116        rc = ddf_fun_add_to_category(fun, "console");
     117        if (rc != EOK) {
     118                ddf_msg(LVL_ERROR, "Error adding function 'a' to category "
     119                    "'console'.");
     120                goto error;
     121        }
    117122
    118123        fid = fibril_create(ski_con_fibril, con);
  • uspace/drv/char/sun4v-con/sun4v-con.c

    r433d52f r4f87a85a  
    7474        ddf_fun_t *fun = NULL;
    7575        errno_t rc;
     76        bool bound = false;
    7677
    7778        con->res = *res;
     
    113114        }
    114115
    115         ddf_fun_add_to_category(fun, "console");
     116        bound = true;
     117
     118        rc = ddf_fun_add_to_category(fun, "console");
     119        if (rc != EOK) {
     120                ddf_msg(LVL_ERROR, "Error adding function 'a' to category "
     121                    "'console'.");
     122                goto error;
     123        }
    116124
    117125        return EOK;
     
    122130        if (con->output_buffer != (niagara_output_buffer_t *) AS_AREA_ANY)
    123131                physmem_unmap((void *) con->output_buffer);
     132
     133        if (bound)
     134                ddf_fun_unbind(fun);
    124135
    125136        if (fun != NULL)
  • uspace/drv/fb/amdm37x_dispc/main.c

    r433d52f r4f87a85a  
    6060        ddf_fun_t *fun = ddf_fun_create(dev, fun_exposed, "viz");
    6161        if (!fun) {
    62                 ddf_log_error("Failed to create visualizer function\n");
     62                ddf_log_error("Failed to create visualizer function.");
    6363                return ENOMEM;
    6464        }
     
    6666        visualizer_t *vis = ddf_fun_data_alloc(fun, sizeof(visualizer_t));
    6767        if (!vis) {
    68                 ddf_log_error("Failed to allocate visualizer structure\n");
     68                ddf_log_error("Failed to allocate visualizer structure.");
    6969                ddf_fun_destroy(fun);
    7070                return ENOMEM;
     
    7979            ddf_dev_data_alloc(dev, sizeof(amdm37x_dispc_t));
    8080        if (!dispc) {
    81                 ddf_log_error("Failed to allocate dispc structure\n");
     81                ddf_log_error("Failed to allocate dispc structure.");
    8282                ddf_fun_destroy(fun);
    8383                return ENOMEM;
    8484        }
    8585
    86         errno_t ret = amdm37x_dispc_init(dispc, vis);
    87         if (ret != EOK) {
    88                 ddf_log_error("Failed to init dispc: %s\n", str_error(ret));
     86        errno_t rc = amdm37x_dispc_init(dispc, vis);
     87        if (rc != EOK) {
     88                ddf_log_error("Failed to init dispc: %s.", str_error(rc));
    8989                ddf_fun_destroy(fun);
    90                 return ret;
     90                return rc;
    9191        }
    9292
    9393        /* Bind function */
    94         ret = ddf_fun_bind(fun);
    95         if (ret != EOK) {
    96                 ddf_log_error("Failed to bind function: %s\n", str_error(ret));
     94        rc = ddf_fun_bind(fun);
     95        if (rc != EOK) {
     96                ddf_log_error("Failed to bind function: %s.", str_error(rc));
    9797                amdm37x_dispc_fini(dispc);
    9898                ddf_fun_destroy(fun);
    99                 return ret;
     99                return rc;
    100100        }
    101         ddf_fun_add_to_category(fun, "visualizer");
    102101
    103         ddf_log_note("Added device `%s'\n", ddf_dev_get_name(dev));
     102        rc = ddf_fun_add_to_category(fun, "visualizer");
     103        if (rc != EOK) {
     104                ddf_log_error("Failed to add function: %s to visualizer "
     105                    "category.", str_error(rc));
     106                amdm37x_dispc_fini(dispc);
     107                ddf_fun_unbind(fun);
     108                ddf_fun_destroy(fun);
     109                return rc;
     110        }
     111
     112        ddf_log_note("Added device `%s'", ddf_dev_get_name(dev));
    104113        return EOK;
    105114}
  • uspace/drv/fb/kfb/port.c

    r433d52f r4f87a85a  
    348348
    349349        vs->reg_svc_handle = ddf_fun_get_handle(fun_vs);
    350         ddf_fun_add_to_category(fun_vs, "visualizer");
     350        rc = ddf_fun_add_to_category(fun_vs, "visualizer");
     351        if (rc != EOK) {
     352                list_remove(&pixel_mode.link);
     353                ddf_fun_unbind(fun_vs);
     354                ddf_fun_destroy(fun_vs);
     355                as_area_destroy(kfb.addr);
     356                return rc;
     357        }
    351358
    352359        return EOK;
  • uspace/drv/intctl/apic/apic.c

    r433d52f r4f87a85a  
    212212        void *regs;
    213213        errno_t rc;
     214        bool bound = false;
    214215
    215216        if ((sysinfo_get_value("apic", &have_apic) != EOK) || (!have_apic)) {
     
    241242        }
    242243
     244        bound = true;
     245
    243246        rc = ddf_fun_add_to_category(fun_a, "irc");
    244247        if (rc != EOK)
     
    247250        return EOK;
    248251error:
     252        if (bound)
     253                ddf_fun_unbind(fun_a);
    249254        if (fun_a != NULL)
    250255                ddf_fun_destroy(fun_a);
  • uspace/drv/intctl/i8259/i8259.c

    r433d52f r4f87a85a  
    142142        ddf_fun_t *fun_a = NULL;
    143143        errno_t rc;
     144        bool bound = false;
    144145
    145146        if ((sysinfo_get_value("i8259", &have_i8259) != EOK) || (!have_i8259)) {
     
    174175        }
    175176
     177        bound = true;
     178
    176179        rc = ddf_fun_add_to_category(fun_a, "irc");
    177180        if (rc != EOK)
     
    180183        return EOK;
    181184error:
     185        if (bound)
     186                ddf_fun_unbind(fun_a);
    182187        if (fun_a != NULL)
    183188                ddf_fun_destroy(fun_a);
  • uspace/drv/intctl/icp-ic/icp-ic.c

    r433d52f r4f87a85a  
    116116        void *regs;
    117117        errno_t rc;
     118        bool bound = false;
    118119
    119120        rc = pio_enable((void *)res->base, sizeof(icpic_regs_t), &regs);
     
    146147        return EOK;
    147148error:
     149        if (bound)
     150                ddf_fun_unbind(fun_a);
    148151        if (fun_a != NULL)
    149152                ddf_fun_destroy(fun_a);
  • uspace/drv/intctl/obio/obio.c

    r433d52f r4f87a85a  
    118118        ddf_fun_t *fun_a = NULL;
    119119        errno_t rc;
     120        bool bound = false;
    120121
    121122        rc = pio_enable((void *)res->base, OBIO_SIZE, (void **) &obio->regs);
     
    149150        return EOK;
    150151error:
     152        if (bound)
     153                ddf_fun_unbind(fun_a);
    151154        if (fun_a != NULL)
    152155                ddf_fun_destroy(fun_a);
  • uspace/drv/test/test1/test1.c

    r433d52f r4f87a85a  
    176176        }
    177177
    178         ddf_fun_add_to_category(fun_a, "virtual");
     178        rc = ddf_fun_add_to_category(fun_a, "virtual");
     179        if (rc != EOK) {
     180                ddf_msg(LVL_ERROR, "Failed adding function 'a' to category "
     181                    "'virtual'.");
     182                ddf_fun_unbind(fun_a);
     183                ddf_fun_destroy(fun_a);
     184                goto error;
     185        }
    179186
    180187        if (str_cmp(dev_name, "test1") == 0) {
  • uspace/drv/test/test2/test2.c

    r433d52f r4f87a85a  
    140140        rc = ddf_fun_bind(fun_a);
    141141        if (rc != EOK) {
     142                ddf_fun_destroy(fun_a);
    142143                ddf_msg(LVL_ERROR, "Failed binding function 'a'.");
    143144                return rc;
    144145        }
    145146
    146         ddf_fun_add_to_category(fun_a, "virtual");
     147        rc = ddf_fun_add_to_category(fun_a, "virtual");
     148        if (rc != EOK) {
     149                ddf_fun_unbind(fun_a);
     150                ddf_fun_destroy(fun_a);
     151                ddf_msg(LVL_ERROR, "Failed adding function 'a' to category "
     152                    "'virtual'.");
     153                return rc;
     154        }
     155
    147156        test2->fun_a = fun_a;
    148157
  • uspace/drv/test/test3/test3.c

    r433d52f r4f87a85a  
    7070        errno_t rc;
    7171        char *fun_name = NULL;
     72        bool bound = false;
    7273
    7374        if (asprintf(&fun_name, "%s%zu", base_name, index) < 0) {
     
    9192        }
    9293
    93         ddf_fun_add_to_category(fun, class_name);
     94        bound = true;
     95
     96        rc = ddf_fun_add_to_category(fun, class_name);
     97        if (rc != EOK) {
     98                ddf_msg(LVL_ERROR, "Failed addning function %s to category %s: "
     99                    "%s", fun_name, class_name, str_error(rc));
     100                goto leave;
     101        }
    94102
    95103        ddf_msg(LVL_NOTE, "Registered exposed function `%s'.", fun_name);
     
    98106        free(fun_name);
    99107
     108        if (bound)
     109                ddf_fun_unbind(fun);
    100110        if ((rc != EOK) && (fun != NULL)) {
    101111                ddf_fun_destroy(fun);
  • uspace/drv/time/cmos-rtc/cmos-rtc.c

    r433d52f r4f87a85a  
    588588        errno_t rc;
    589589        bool need_cleanup = false;
     590        bool bound = false;
    590591
    591592        ddf_msg(LVL_DEBUG, "rtc_dev_add %s (handle = %d)",
     
    624625        }
    625626
     627        bound = true;
    626628        rtc->fun = fun;
    627629
    628         ddf_fun_add_to_category(fun, "clock");
     630        rc = ddf_fun_add_to_category(fun, "clock");
     631        if (rc != EOK) {
     632                ddf_msg(LVL_ERROR, "Failed adding service to clock category.");
     633                goto error;
     634        }
    629635
    630636        ddf_msg(LVL_NOTE, "Device %s successfully initialized",
     
    634640
    635641error:
     642        if (bound)
     643                ddf_fun_unbind(fun);
    636644        if (fun)
    637645                ddf_fun_destroy(fun);
     
    754762
    755763        rc = ddf_fun_online(fun);
    756         if (rc == EOK)
    757                 ddf_fun_add_to_category(fun, "clock");
     764        if (rc == EOK) {
     765                // XXX This should be probably handled by the framework
     766                rc = ddf_fun_add_to_category(fun, "clock");
     767        }
    758768
    759769        return rc;
  • uspace/lib/ieee80211/src/ieee80211.c

    r433d52f r4f87a85a  
    803803        if (rc != EOK) {
    804804                ddf_fun_unbind(fun);
     805                ddf_fun_destroy(fun);
    805806                return rc;
    806807        }
     
    809810        if (rc != EOK) {
    810811                ddf_fun_unbind(fun);
     812                ddf_fun_destroy(fun);
    811813                return rc;
    812814        }
Note: See TracChangeset for help on using the changeset viewer.