Changes in uspace/lib/drv/generic/driver.c [56fd7cf:77ad86c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
r56fd7cf r77ad86c 36 36 /** @file 37 37 */ 38 39 #define _DDF_DATA_IMPLANT40 38 41 39 #include <assert.h> … … 60 58 #include "ddf/driver.h" 61 59 #include "ddf/interrupt.h" 62 #include "private/driver.h"63 60 64 61 /** Driver structure */ … … 526 523 static void delete_device(ddf_dev_t *dev) 527 524 { 528 if (dev->parent_sess)529 async_hangup(dev->parent_sess);530 525 if (dev->driver_data != NULL) 531 526 free(dev->driver_data); … … 602 597 } 603 598 604 /** Implant foreign driver-specific device data.605 *606 * XXX This is used to transition USB to new interface. Do not use607 * in new code. Use of this function must be removed.608 */609 void ddf_fun_data_implant(ddf_fun_t *fun, void *data)610 {611 assert(fun->driver_data == NULL);612 fun->driver_data = data;613 }614 615 /** Return driver-specific device data. */616 void *ddf_dev_data_get(ddf_dev_t *dev)617 {618 return dev->driver_data;619 }620 621 /** Get device handle. */622 devman_handle_t ddf_dev_get_handle(ddf_dev_t *dev)623 {624 return dev->handle;625 }626 627 /** Return device name.628 *629 * @param dev Device630 * @return Device name. Valid as long as @a dev is valid.631 */632 const char *ddf_dev_get_name(ddf_dev_t *dev)633 {634 return dev->name;635 }636 637 /** Create session with the parent function.638 *639 * The session will be automatically closed when @a dev is destroyed.640 *641 * @param dev Device642 * @param mgmt Exchange management style643 * @return New session or NULL if session could not be created644 */645 async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev, exch_mgmt_t mgmt)646 {647 assert(dev->parent_sess == NULL);648 dev->parent_sess = devman_parent_device_connect(mgmt, dev->handle,649 IPC_FLAG_BLOCKING);650 651 return dev->parent_sess;652 }653 654 /** Return existing session with the parent function.655 *656 * @param dev Device657 * @return Existing session or NULL if there is no session658 */659 async_sess_t *ddf_dev_parent_sess_get(ddf_dev_t *dev)660 {661 return dev->parent_sess;662 }663 664 /** Set function name (if it was not specified when node was created.)665 *666 * @param dev Device whose name has not been set yet667 * @param name Name, will be copied668 * @return EOK on success, ENOMEM if out of memory669 */670 int ddf_fun_set_name(ddf_fun_t *dev, const char *name)671 {672 assert(dev->name == NULL);673 674 dev->name = str_dup(name);675 if (dev->name == NULL)676 return ENOENT;677 678 return EOK;679 }680 681 /** Get device to which function belongs. */682 ddf_dev_t *ddf_fun_get_dev(ddf_fun_t *fun)683 {684 return fun->dev;685 }686 687 /** Get function handle.688 *689 * XXX USB uses this, but its use should be eliminated.690 */691 devman_handle_t ddf_fun_get_handle(ddf_fun_t *fun)692 {693 return fun->handle;694 }695 696 599 /** Create a DDF function node. 697 600 * … … 705 608 * This function should only fail if there is not enough free memory. 706 609 * Specifically, this function succeeds even if @a dev already has 707 * a (bound) function with the same name. @a name can be NULL in which 708 * case the caller will set the name later using ddf_fun_set_name(). 709 * He must do this before binding the function. 610 * a (bound) function with the same name. 710 611 * 711 612 * Type: A function of type fun_inner indicates that DDF should attempt … … 715 616 * @param dev Device to which we are adding function 716 617 * @param ftype Type of function (fun_inner or fun_exposed) 717 * @param name Name of function or NULL618 * @param name Name of function 718 619 * 719 620 * @return New function or @c NULL if memory is not available … … 732 633 fun->ftype = ftype; 733 634 734 if (name != NULL) { 735 fun->name = str_dup(name); 736 if (fun->name == NULL) { 737 delete_function(fun); 738 return NULL; 739 } 635 fun->name = str_dup(name); 636 if (fun->name == NULL) { 637 delete_function(fun); 638 return NULL; 740 639 } 741 640 … … 755 654 fun->driver_data = data; 756 655 return data; 757 }758 759 /** Return driver-specific function data. */760 void *ddf_fun_data_get(ddf_fun_t *fun)761 {762 return fun->driver_data;763 }764 765 /** Return function name.766 *767 * @param fun Function768 * @return Function name. Valid as long as @a fun is valid.769 */770 const char *ddf_fun_get_name(ddf_fun_t *fun)771 {772 return fun->name;773 656 } 774 657 … … 922 805 add_match_id(&fun->match_ids, match_id); 923 806 return EOK; 924 }925 926 /** Set function ops. */927 void ddf_fun_set_ops(ddf_fun_t *fun, ddf_dev_ops_t *dev_ops)928 {929 assert(fun->conn_handler == NULL);930 fun->ops = dev_ops;931 }932 933 /** Set user-defined connection handler.934 *935 * This allows handling connections the non-devman way.936 */937 void ddf_fun_set_conn_handler(ddf_fun_t *fun, async_client_conn_t conn)938 {939 assert(fun->ops == NULL);940 fun->conn_handler = conn;941 807 } 942 808
Note:
See TracChangeset
for help on using the changeset viewer.