Changeset 5f6e25e in mainline for uspace/drv/bus/usb/usbmast/main.c


Ignore:
Timestamp:
2011-08-29T23:00:12Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
58cbb0c8
Parents:
c5be39b
Message:

Leave it up to DDF to free driver-specific data. This makes it possible
to ensure soft state is not freed during calls to driver entry points.

This requires some driver changes:

  • minimum change is not to free() driver-data structures (ddf_fun_t.driver_data and ddf_dev_t.driver_data)
  • ideally allocate using ddf_dev_data_alloc(), ddf_fun_data_alloc()

I tried fixing existing drivers accordingly (mostly the minimalistic
change variant), but could have missed something.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbmast/main.c

    rc5be39b r5f6e25e  
    145145        usbmast_fun_t *mfun = NULL;
    146146
    147         /* Allocate softstate */
    148         mfun = calloc(1, sizeof(usbmast_fun_t));
    149         if (mfun == NULL) {
    150                 usb_log_error("Failed allocating softstate.\n");
    151                 rc = ENOMEM;
    152                 goto error;
    153         }
    154 
    155         mfun->mdev = mdev;
    156         mfun->lun = lun;
    157 
    158147        if (asprintf(&fun_name, "l%u", lun) < 0) {
    159148                usb_log_error("Out of memory.\n");
     
    170159
    171160        free(fun_name);
     161
     162        /* Allocate soft state */
     163        mfun = ddf_dev_data_alloc(mdev->ddf_dev, sizeof(usbmast_fun_t));
     164        if (mfun == NULL) {
     165                usb_log_error("Failed allocating softstate.\n");
     166                rc = ENOMEM;
     167                goto error;
     168        }
     169
     170        mfun->mdev = mdev;
     171        mfun->lun = lun;
     172
    172173        fun_name = NULL;
    173174
     
    227228        if (fun_name != NULL)
    228229                free(fun_name);
    229         if (mfun != NULL)
    230                 free(mfun);
    231230        return rc;
    232231}
Note: See TracChangeset for help on using the changeset viewer.