Ignore:
Timestamp:
2014-07-21T22:10:18Z (10 years ago)
Author:
Agnieszka Tabaka <nufcia@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1f1fa64
Parents:
96e368a (diff), 54a1ca7 (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:
  • Merged mainline changes
  • Refactored rtl8169 driver to work with recent driver framework changes
  • Fixed speed selection in rtl8169 (disables autonegotiation first)
  • Added support for restarting autonegotiation
  • Added new switch to 'nic' utility which restarts autonegotiation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.c

    r96e368a rcbfece7  
    3434 * USB Mouse driver API.
    3535 */
    36 
    37 /* XXX Fix this */
    38 #define _DDF_DATA_IMPLANT
    3936
    4037#include <usb/debug.h>
     
    249246}
    250247
    251 #define FUN_UNBIND_DESTROY(fun) \
    252 if (fun) { \
    253         if (ddf_fun_unbind((fun)) == EOK) { \
    254                 ddf_fun_destroy((fun)); \
    255         } else { \
    256                 usb_log_error("Could not unbind function `%s', it " \
    257                     "will not be destroyed.\n", ddf_fun_get_name(fun)); \
    258         } \
    259 } else (void)0
    260 
    261 static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse)
    262 {
    263         assert(hid_dev != NULL);
    264         assert(mouse != NULL);
    265 
    266         /* Create the exposed function. */
    267         usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME);
    268         ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
    269             HID_MOUSE_FUN_NAME);
    270         if (fun == NULL) {
    271                 usb_log_error("Could not create DDF function node `%s'.\n",
    272                     HID_MOUSE_FUN_NAME);
    273                 return ENOMEM;
    274         }
    275 
    276         ddf_fun_set_ops(fun, &ops);
    277         ddf_fun_data_implant(fun, mouse);
    278 
    279         int rc = ddf_fun_bind(fun);
    280         if (rc != EOK) {
    281                 usb_log_error("Could not bind DDF function `%s': %s.\n",
    282                     ddf_fun_get_name(fun), str_error(rc));
    283                 ddf_fun_destroy(fun);
    284                 return rc;
    285         }
    286 
    287         usb_log_debug("Adding DDF function `%s' to category %s...\n",
    288             ddf_fun_get_name(fun), HID_MOUSE_CATEGORY);
    289         rc = ddf_fun_add_to_category(fun, HID_MOUSE_CATEGORY);
    290         if (rc != EOK) {
    291                 usb_log_error(
    292                     "Could not add DDF function to category %s: %s.\n",
    293                     HID_MOUSE_CATEGORY, str_error(rc));
    294                 FUN_UNBIND_DESTROY(fun);
    295                 return rc;
    296         }
    297         mouse->mouse_fun = fun;
    298         return EOK;
    299 }
    300 
    301248/** Get highest index of a button mentioned in given report.
    302249 *
     
    341288int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data)
    342289{
     290        ddf_fun_t *fun = NULL;
     291        usb_mouse_t *mouse_dev = NULL;
     292        bool bound = false;
     293        int rc;
     294
    343295        usb_log_debug("Initializing HID/Mouse structure...\n");
    344296
     
    346298                usb_log_error("Failed to init mouse structure: no structure"
    347299                    " given.\n");
    348                 return EINVAL;
    349         }
    350 
    351         usb_mouse_t *mouse_dev = calloc(1, sizeof(usb_mouse_t));
     300                rc = EINVAL;
     301                goto error;
     302        }
     303
     304        /* Create the exposed function. */
     305        usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME);
     306        fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
     307            HID_MOUSE_FUN_NAME);
     308        if (fun == NULL) {
     309                usb_log_error("Could not create DDF function node `%s'.\n",
     310                    HID_MOUSE_FUN_NAME);
     311                rc = ENOMEM;
     312                goto error;
     313        }
     314
     315        ddf_fun_set_ops(fun, &ops);
     316
     317        mouse_dev = ddf_fun_data_alloc(fun, sizeof(usb_mouse_t));
    352318        if (mouse_dev == NULL) {
    353319                usb_log_error("Error while creating USB/HID Mouse device "
    354320                    "structure.\n");
    355                 return ENOMEM;
     321                rc = ENOMEM;
     322                goto error;
    356323        }
    357324
     
    368335        if (mouse_dev->buttons == NULL) {
    369336                usb_log_error(NAME ": out of memory, giving up on device!\n");
    370                 free(mouse_dev);
    371                 return ENOMEM;
     337                rc = ENOMEM;
     338                goto error;
    372339        }
    373340
     
    376343            hid_dev->usb_dev->interface_no, IDLE_RATE);
    377344
    378         int rc = usb_mouse_create_function(hid_dev, mouse_dev);
     345        rc = ddf_fun_bind(fun);
    379346        if (rc != EOK) {
    380                 free(mouse_dev->buttons);
    381                 free(mouse_dev);
    382                 return rc;
    383         }
     347                usb_log_error("Could not bind DDF function `%s': %s.\n",
     348                    ddf_fun_get_name(fun), str_error(rc));
     349                goto error;
     350        }
     351
     352        bound = true;
     353
     354        usb_log_debug("Adding DDF function `%s' to category %s...\n",
     355            ddf_fun_get_name(fun), HID_MOUSE_CATEGORY);
     356        rc = ddf_fun_add_to_category(fun, HID_MOUSE_CATEGORY);
     357        if (rc != EOK) {
     358                usb_log_error("Could not add DDF function to category %s: "
     359                    "%s.\n", HID_MOUSE_CATEGORY, str_error(rc));
     360                goto error;
     361        }
     362
     363        mouse_dev->mouse_fun = fun;
    384364
    385365        /* Save the Mouse device structure into the HID device structure. */
    386366        *data = mouse_dev;
    387 
    388367        return EOK;
     368error:
     369        if (bound)
     370                ddf_fun_unbind(fun);
     371        if (mouse_dev != NULL)
     372                free(mouse_dev->buttons);
     373        if (fun != NULL)
     374                ddf_fun_destroy(fun);
     375        return rc;
    389376}
    390377
     
    417404        }
    418405
    419         FUN_UNBIND_DESTROY(mouse_dev->mouse_fun);
    420 
     406        ddf_fun_unbind(mouse_dev->mouse_fun);
    421407        free(mouse_dev->buttons);
     408        ddf_fun_destroy(mouse_dev->mouse_fun);
    422409}
    423410
Note: See TracChangeset for help on using the changeset viewer.