Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 56fd7cf in mainline for uspace/drv/test/test1/test1.c


Ignore:
Timestamp:
2012-08-17T11:37:03Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
1d5a540
Parents:
be2a38ad
Message:

Make ddf_dev_t and ddf_fun_t opaque. This further tighthens the DDF interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/test/test1/test1.c

    rbe2a38ad r56fd7cf  
    145145        ddf_fun_t *fun_a;
    146146        test1_t *test1;
    147         int rc;
    148 
     147        const char *dev_name;
     148        int rc;
     149
     150        dev_name = ddf_dev_get_name(dev);
    149151        ddf_msg(LVL_DEBUG, "dev_add(name=\"%s\", handle=%d)",
    150             dev->name, (int) dev->handle);
     152            dev_name, (int) ddf_dev_get_handle(dev));
    151153
    152154        test1 = ddf_dev_data_alloc(dev, sizeof(test1_t));
    153155        if (test1 == NULL) {
    154156                ddf_msg(LVL_ERROR, "Failed allocating soft state.\n");
    155                 return ENOMEM;
     157                rc = ENOMEM;
     158                goto error;
    156159        }
    157160
     
    159162        if (fun_a == NULL) {
    160163                ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
    161                 return ENOMEM;
     164                rc = ENOMEM;
     165                goto error;
    162166        }
    163167
     
    168172                ddf_msg(LVL_ERROR, "Failed binding function 'a'.");
    169173                ddf_fun_destroy(fun_a);
    170                 return rc;
     174                goto error;
    171175        }
    172176
    173177        ddf_fun_add_to_category(fun_a, "virtual");
    174178
    175         if (str_cmp(dev->name, "null") == 0) {
    176                 fun_a->ops = &char_device_ops;
     179        if (str_cmp(dev_name, "null") == 0) {
     180                ddf_fun_set_ops(fun_a,  &char_device_ops);
    177181                ddf_fun_add_to_category(fun_a, "virt-null");
    178         } else if (str_cmp(dev->name, "test1") == 0) {
     182        } else if (str_cmp(dev_name, "test1") == 0) {
    179183                (void) register_fun_verbose(dev,
    180184                    "cloning myself ;-)", "clone",
     
    183187                    "cloning myself twice ;-)", "clone",
    184188                    "virtual&test1", 10, EEXISTS, NULL);
    185         } else if (str_cmp(dev->name, "clone") == 0) {
     189        } else if (str_cmp(dev_name, "clone") == 0) {
    186190                (void) register_fun_verbose(dev,
    187191                    "run by the same task", "child",
     
    189193        }
    190194
    191         ddf_msg(LVL_DEBUG, "Device `%s' accepted.", dev->name);
    192 
    193         return EOK;
     195        ddf_msg(LVL_DEBUG, "Device `%s' accepted.", dev_name);
     196        return EOK;
     197error:
     198        return rc;
    194199}
    195200
     
    232237static int test1_dev_remove(ddf_dev_t *dev)
    233238{
    234         test1_t *test1 = (test1_t *)dev->driver_data;
     239        test1_t *test1 = (test1_t *)ddf_dev_data_get(dev);
    235240        int rc;
    236241
     
    260265static int test1_dev_gone(ddf_dev_t *dev)
    261266{
    262         test1_t *test1 = (test1_t *)dev->driver_data;
     267        test1_t *test1 = (test1_t *)ddf_dev_data_get(dev);
    263268        int rc;
    264269
Note: See TracChangeset for help on using the changeset viewer.