Changeset 1d5a540 in mainline for uspace/lib/nic/src/nic_driver.c


Ignore:
Timestamp:
2012-08-17T11:52:20Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
034c4202
Parents:
8312577 (diff), 56fd7cf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge DDF interface tightening.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/nic/src/nic_driver.c

    r8312577 r1d5a540  
    4747#include <sysinfo.h>
    4848#include <as.h>
    49 #include <devman.h>
    5049#include <ddf/interrupt.h>
    5150#include <ops/nic.h>
     
    250249{
    251250        ddf_dev_t *dev = nic_data->dev;
     251        async_sess_t *parent_sess;
    252252       
    253253        /* Connect to the parent's driver. */
    254         dev->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE,
    255                 dev->handle, IPC_FLAG_BLOCKING);
    256         if (dev->parent_sess == NULL)
     254        parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
     255        if (parent_sess == NULL)
    257256                return EPARTY;
    258257       
    259         return hw_res_get_list_parsed(nic_data->dev->parent_sess, resources, 0);
     258        return hw_res_get_list_parsed(parent_sess, resources, 0);
    260259}
    261260
     
    650649 *
    651650 */
    652 static nic_t *nic_create(void)
    653 {
    654         nic_t *nic_data = malloc(sizeof(nic_t));
     651static nic_t *nic_create(ddf_dev_t *dev)
     652{
     653        nic_t *nic_data = ddf_dev_data_alloc(dev, sizeof(nic_t));
    655654        if (nic_data == NULL)
    656655                return NULL;
    657656       
    658657        /* Force zero to all uninitialized fields (e.g. added in future) */
    659         bzero(nic_data, sizeof(nic_t));
    660658        if (nic_rxc_init(&nic_data->rx_control) != EOK) {
    661                 free(nic_data);
    662659                return NULL;
    663660        }
    664661       
    665662        if (nic_wol_virtues_init(&nic_data->wol_virtues) != EOK) {
    666                 free(nic_data);
    667663                return NULL;
    668664        }
     
    705701nic_t *nic_create_and_bind(ddf_dev_t *device)
    706702{
    707         assert(device);
    708         assert(!device->driver_data);
    709        
    710         nic_t *nic_data = nic_create();
     703        nic_t *nic_data = nic_create(device);
    711704        if (!nic_data)
    712705                return NULL;
    713706       
    714707        nic_data->dev = device;
    715         device->driver_data = nic_data;
    716708       
    717709        return nic_data;
     
    724716 * @param data
    725717 */
    726 static void nic_destroy(nic_t *nic_data) {
    727         if (nic_data->client_session != NULL) {
    728                 async_hangup(nic_data->client_session);
    729         }
    730 
     718static void nic_destroy(nic_t *nic_data)
     719{
    731720        free(nic_data->specific);
    732         free(nic_data);
    733721}
    734722
     
    740728 * @param device The NIC device structure
    741729 */
    742 void nic_unbind_and_destroy(ddf_dev_t *device){
    743         if (!device)
    744                 return;
    745         if (!device->driver_data)
    746                 return;
    747 
    748         nic_destroy((nic_t *) device->driver_data);
    749         device->driver_data = NULL;
     730void nic_unbind_and_destroy(ddf_dev_t *device)
     731{
     732        nic_destroy(nic_get_from_ddf_dev(device));
    750733        return;
    751734}
     
    983966nic_t *nic_get_from_ddf_dev(ddf_dev_t *dev)
    984967{
    985         return (nic_t *) dev->driver_data;
    986 };
     968        return (nic_t *) ddf_dev_data_get(dev);
     969}
    987970
    988971/**
     
    992975nic_t *nic_get_from_ddf_fun(ddf_fun_t *fun)
    993976{
    994         return (nic_t *) fun->driver_data;
    995 };
     977        return (nic_t *) ddf_fun_data_get(fun);
     978}
    996979
    997980/**
Note: See TracChangeset for help on using the changeset viewer.