Changeset 5f6e25e in mainline for uspace/drv/bus/pci/pciintel/pci.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/pci/pciintel/pci.c

    rc5be39b r5f6e25e  
    215215};
    216216
    217 static pci_bus_t *pci_bus_new(void)
    218 {
    219         pci_bus_t *bus;
    220        
    221         bus = (pci_bus_t *) calloc(1, sizeof(pci_bus_t));
    222         if (bus == NULL)
    223                 return NULL;
    224        
    225         fibril_mutex_initialize(&bus->conf_mutex);
    226         return bus;
    227 }
    228 
    229 static void pci_bus_delete(pci_bus_t *bus)
    230 {
    231         assert(bus != NULL);
    232         free(bus);
    233 }
    234 
    235217static void pci_conf_read(pci_fun_t *fun, int reg, uint8_t *buf, size_t len)
    236218{
     
    584566        dnode->parent_sess = NULL;
    585567       
    586         bus = pci_bus_new();
     568        bus = ddf_dev_data_alloc(dnode, sizeof(pci_bus_t));
    587569        if (bus == NULL) {
    588570                ddf_msg(LVL_ERROR, "pci_add_device allocation failed.");
     
    590572                goto fail;
    591573        }
     574        fibril_mutex_initialize(&bus->conf_mutex);
     575
    592576        bus->dnode = dnode;
    593577        dnode->driver_data = bus;
     
    655639       
    656640fail:
    657         if (bus != NULL)
    658                 pci_bus_delete(bus);
    659        
    660641        if (dnode->parent_sess)
    661642                async_hangup(dnode->parent_sess);
Note: See TracChangeset for help on using the changeset viewer.