Changeset 36f2b3e in mainline


Ignore:
Timestamp:
2011-01-09T20:14:03Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
97adec8
Parents:
d35ac1d
Message:

Cstyle cleanup.

Location:
uspace/lib/drv/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/dev_iface.c

    rd35ac1d r36f2b3e  
    4747};
    4848
    49 remote_iface_t* get_remote_iface(int idx)
     49remote_iface_t *get_remote_iface(int idx)
    5050{
    5151        assert(is_valid_iface_idx(idx));
     
    5959                return NULL;
    6060        }
     61
    6162        return rem_iface->methods[iface_method_idx];
    6263}
  • uspace/lib/drv/generic/driver.c

    rd35ac1d r36f2b3e  
    5454#include "driver.h"
    5555
    56 /* driver structure */
    57 
     56/** Driver structure */
    5857static driver_t *driver;
    5958
    60 /* devices */
    61 
     59/** Devices */
    6260LIST_INITIALIZE(devices);
    6361FIBRIL_MUTEX_INITIALIZE(devices_mutex);
    6462
    65 /* interrupts */
    66 
     63/** Interrupts */
    6764static interrupt_context_list_t interrupt_contexts;
    6865
     
    8582       
    8683        ctx = find_interrupt_context_by_id(&interrupt_contexts, id);
    87         if (NULL != ctx && NULL != ctx->handler)
     84        if (ctx != NULL && ctx->handler != NULL)
    8885                (*ctx->handler)(ctx->dev, iid, icall);
    8986}
     
    10198        add_interrupt_context(&interrupt_contexts, ctx);
    10299       
    103         if (NULL == pseudocode)
     100        if (pseudocode == NULL)
    104101                pseudocode = &default_pseudocode;
    105102       
    106103        int res = ipc_register_irq(irq, dev->handle, ctx->id, pseudocode);
    107         if (0 != res) {
     104        if (res != EOK) {
    108105                remove_interrupt_context(&interrupt_contexts, ctx);
    109106                delete_interrupt_context(ctx);
     
    118115            dev, irq);
    119116        int res = ipc_unregister_irq(irq, dev->handle);
    120 
    121         if (NULL != ctx) {
     117       
     118        if (ctx != NULL) {
    122119                remove_interrupt_context(&interrupt_contexts, ctx);
    123120                delete_interrupt_context(ctx);
    124121        }
     122       
    125123        return res;
    126124}
     
    146144        fibril_mutex_lock(&devices_mutex);
    147145        link_t *link = devices->next;
     146       
    148147        while (link != devices) {
    149148                dev = list_get_instance(link, device_t, link);
    150                 if (handle == dev->handle) {
     149                if (dev->handle == handle) {
    151150                        fibril_mutex_unlock(&devices_mutex);
    152151                        return dev;
     
    154153                link = link->next;
    155154        }
     155       
    156156        fibril_mutex_unlock(&devices_mutex);
    157 
     157       
    158158        return NULL;
    159159}
     
    162162{
    163163        char *dev_name = NULL;
    164         int res = EOK;
     164        int res;
    165165       
    166166        devman_handle_t dev_handle = IPC_GET_ARG1(*icall);
     
    177177       
    178178        res = driver->driver_ops->add_device(dev);
    179         if (res == 0) {
     179        if (res == EOK) {
    180180                printf("%s: new device with handle=%" PRIun " was added.\n",
    181181                    driver->name, dev_handle);
     
    194194        /* Accept connection */
    195195        ipc_answer_0(iid, EOK);
    196 
     196       
    197197        bool cont = true;
    198198        while (cont) {
    199199                ipc_call_t call;
    200200                ipc_callid_t callid = async_get_call(&call);
    201 
     201               
    202202                switch (IPC_GET_IMETHOD(call)) {
    203203                case IPC_M_PHONE_HUNGUP:
     
    240240         * use the device.
    241241         */
    242 
     242       
    243243        int ret = EOK;
    244244        /* open the device */
    245         if (NULL != dev->ops && NULL != dev->ops->open)
     245        if (dev->ops != NULL && dev->ops->open != NULL)
    246246                ret = (*dev->ops->open)(dev);
    247247       
    248248        ipc_answer_0(iid, ret);
    249         if (EOK != ret)
     249        if (ret != EOK)
    250250                return;
    251 
     251       
    252252        while (1) {
    253253                ipc_callid_t callid;
     
    260260                case IPC_M_PHONE_HUNGUP:
    261261                        /* close the device */
    262                         if (NULL != dev->ops && NULL != dev->ops->close)
     262                        if (dev->ops != NULL && dev->ops->close != NULL)
    263263                                (*dev->ops->close)(dev);
    264264                        ipc_answer_0(callid, EOK);
     
    272272                                remote_handler_t *default_handler =
    273273                                    device_get_default_handler(dev);
    274                                 if (NULL != default_handler) {
     274                                if (default_handler != NULL) {
    275275                                        (*default_handler)(dev, callid, &call);
    276276                                        break;
     
    286286                                break;
    287287                        }
    288 
     288                       
    289289                        /* calling one of the device's interfaces */
    290290                       
     
    299299                                break;
    300300                        }
    301 
     301                       
    302302                        /*
    303303                         * Get the corresponding interface for remote request
     
    305305                         */
    306306                        remote_iface_t *rem_iface = get_remote_iface(iface_idx);
    307                         assert(NULL != rem_iface);
    308 
     307                        assert(rem_iface != NULL);
     308                       
    309309                        /* get the method of the remote interface */
    310310                        sysarg_t iface_method_idx = IPC_GET_ARG1(call);
    311311                        remote_iface_func_ptr_t iface_method_ptr =
    312312                            get_remote_method(rem_iface, iface_method_idx);
    313                         if (NULL == iface_method_ptr) {
     313                        if (iface_method_ptr == NULL) {
    314314                                // the interface has not such method
    315315                                printf("%s: driver_connection_gen error - "
     
    348348        switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
    349349        case DRIVER_DEVMAN:
    350                 /* handle PnP events from device manager */
     350                /* Handle request from device manager */
    351351                driver_connection_devman(iid, icall);
    352352                break;
    353353        case DRIVER_DRIVER:
    354                 /* handle request from drivers of child devices */
     354                /* Handle request from drivers of child devices */
    355355                driver_connection_driver(iid, icall);
    356356                break;
    357357        case DRIVER_CLIENT:
    358                 /* handle requests from client applications */
     358                /* Handle request from client applications */
    359359                driver_connection_client(iid, icall);
    360360                break;
    361 
    362361        default:
    363362                /* No such interface */
     
    368367int child_device_register(device_t *child, device_t *parent)
    369368{
    370         assert(NULL != child->name);
    371 
     369        assert(child->name != NULL);
     370       
    372371        int res;
    373372       
     
    375374        res = devman_child_device_register(child->name, &child->match_ids,
    376375            parent->handle, &child->handle);
    377         if (EOK == res)
     376        if (res != EOK) {
     377                remove_from_devices_list(child);
    378378                return res;
    379         remove_from_devices_list(child);
     379        }
     380       
    380381        return res;
    381382}
     
    395396        match_id_t *match_id = NULL;
    396397        int rc;
    397 
     398       
    398399        child = create_device();
    399400        if (child == NULL) {
     
    401402                goto failure;
    402403        }
    403 
     404       
    404405        child->name = child_name;
    405 
     406       
    406407        match_id = create_match_id();
    407408        if (match_id == NULL) {
     
    409410                goto failure;
    410411        }
    411 
     412       
    412413        match_id->id = child_match_id;
    413414        match_id->score = child_match_score;
    414415        add_match_id(&child->match_ids, match_id);
    415 
     416       
    416417        rc = child_device_register(child, parent);
    417         if (EOK != rc)
     418        if (rc != EOK)
    418419                goto failure;
    419 
     420       
    420421        return EOK;
    421 
     422       
    422423failure:
    423424        if (match_id != NULL) {
     
    425426                delete_match_id(match_id);
    426427        }
    427 
     428       
    428429        if (child != NULL) {
    429430                child->name = NULL;
    430431                delete_device(child);
    431432        }
    432 
     433       
    433434        return rc;
    434435}
     
    441442         */
    442443        driver = drv;
    443 
     444       
    444445        /* Initialize the list of interrupt contexts. */
    445446        init_interrupt_context_list(&interrupt_contexts);
     
    453454         */
    454455        devman_driver_register(driver->name, driver_connection);
    455 
     456       
    456457        async_manager();
    457 
     458       
    458459        /* Never reached. */
    459460        return 0;
  • uspace/lib/drv/generic/remote_hw_res.c

    rd35ac1d r36f2b3e  
    4040#include "driver.h"
    4141
    42 static void remote_res_get_resource_list(device_t *, void *, ipc_callid_t,
     42static void remote_hw_res_get_resource_list(device_t *, void *, ipc_callid_t,
    4343    ipc_call_t *);
    44 static void remote_res_enable_interrupt(device_t *, void *, ipc_callid_t,
     44static void remote_hw_res_enable_interrupt(device_t *, void *, ipc_callid_t,
    4545    ipc_call_t *);
    4646
    4747static remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {
    48         &remote_res_get_resource_list,
    49         &remote_res_enable_interrupt
     48        &remote_hw_res_get_resource_list,
     49        &remote_hw_res_enable_interrupt
    5050};
    5151
     
    5656};
    5757
    58 static void remote_res_enable_interrupt(device_t *dev, void *ops,
     58static void remote_hw_res_enable_interrupt(device_t *dev, void *ops,
    5959    ipc_callid_t callid, ipc_call_t *call)
    6060{
     
    6969}
    7070
    71 static void remote_res_get_resource_list(device_t *dev, void *ops,
     71static void remote_hw_res_get_resource_list(device_t *dev, void *ops,
    7272    ipc_callid_t callid, ipc_call_t *call)
    7373{
     
    8080       
    8181        hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(dev);
    82         if (NULL == hw_resources){
     82        if (hw_resources == NULL){
    8383                ipc_answer_0(callid, ENOENT);
    8484                return;
    85         }       
     85        }
    8686       
    87         ipc_answer_1(callid, EOK, hw_resources->count); 
     87        ipc_answer_1(callid, EOK, hw_resources->count);
    8888
    8989        size_t len;
    9090        if (!async_data_read_receive(&callid, &len)) {
    91                 /* protocol error - the recipient is not accepting data */
     91                /* Protocol error - the recipient is not accepting data */
    9292                return;
    9393        }
Note: See TracChangeset for help on using the changeset viewer.