Changeset bd41ac52 in mainline for uspace/lib/nic/src
- Timestamp:
- 2018-08-25T22:21:25Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cca80a2
- Parents:
- e2625b1a
- Location:
- uspace/lib/nic/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_driver.c
re2625b1a rbd41ac52 384 384 * @return Current polling mode of the controller 385 385 */ 386 nic_poll_mode_t nic_query_poll_mode(nic_t *nic_data, struct time val*period)386 nic_poll_mode_t nic_query_poll_mode(nic_t *nic_data, struct timespec *period) 387 387 { 388 388 if (period) … … 400 400 */ 401 401 errno_t nic_report_poll_mode(nic_t *nic_data, nic_poll_mode_t mode, 402 struct time val*period)402 struct timespec *period) 403 403 { 404 404 errno_t rc = EOK; … … 408 408 if (mode == NIC_POLL_PERIODIC) { 409 409 if (period) { 410 memcpy(&nic_data->default_poll_period, period, sizeof(struct time val));411 memcpy(&nic_data->poll_period, period, sizeof(struct time val));410 memcpy(&nic_data->default_poll_period, period, sizeof(struct timespec)); 411 memcpy(&nic_data->poll_period, period, sizeof(struct timespec)); 412 412 } else { 413 413 rc = EINVAL; … … 1030 1030 * @returns Nonzero if t is zero interval 1031 1031 */ 1032 static int time val_nonpositive(struct timevalt)1033 { 1034 return (t.tv_sec <= 0) && (t.tv_ usec <= 0);1032 static int timespec_nonpositive(struct timespec t) 1033 { 1034 return (t.tv_sec <= 0) && (t.tv_nsec <= 0); 1035 1035 } 1036 1036 … … 1051 1051 int run = info->run; 1052 1052 int running = info->running; 1053 struct time valremaining = nic->poll_period;1053 struct timespec remaining = nic->poll_period; 1054 1054 fibril_rwlock_read_unlock(&nic->main_lock); 1055 1055 1056 1056 if (!running) { 1057 1057 remaining.tv_sec = 5; 1058 remaining.tv_ usec = 0;1058 remaining.tv_nsec = 0; 1059 1059 } 1060 1060 1061 1061 /* Wait the period (keep attention to overflows) */ 1062 while (!time val_nonpositive(remaining)) {1063 suseconds_t wait = 0;1062 while (!timespec_nonpositive(remaining)) { 1063 usec_t wait = 0; 1064 1064 if (remaining.tv_sec > 0) { 1065 1065 time_t wait_sec = remaining.tv_sec; … … 1071 1071 wait_sec = 5; 1072 1072 1073 wait = (suseconds_t) wait_sec * 1000000;1073 wait = SEC2USEC(wait_sec); 1074 1074 1075 1075 remaining.tv_sec -= wait_sec; 1076 1076 } else { 1077 wait = remaining.tv_usec;1077 wait = NSEC2USEC(remaining.tv_nsec); 1078 1078 1079 1079 if (wait > 5 * 1000000) { … … 1081 1081 } 1082 1082 1083 remaining.tv_ usec -= wait;1083 remaining.tv_nsec -= USEC2NSEC(wait); 1084 1084 } 1085 1085 fibril_usleep(wait); -
uspace/lib/nic/src/nic_impl.c
re2625b1a rbd41ac52 121 121 nic_data->poll_mode = nic_data->default_poll_mode; 122 122 memcpy(&nic_data->poll_period, &nic_data->default_poll_period, 123 sizeof(struct time val));123 sizeof(struct timespec)); 124 124 if (rc != EOK) { 125 125 /* … … 714 714 */ 715 715 errno_t nic_poll_get_mode_impl(ddf_fun_t *fun, 716 nic_poll_mode_t *mode, struct time val*period)716 nic_poll_mode_t *mode, struct timespec *period) 717 717 { 718 718 nic_t *nic_data = nic_get_from_ddf_fun(fun); 719 719 fibril_rwlock_read_lock(&nic_data->main_lock); 720 720 *mode = nic_data->poll_mode; 721 memcpy(period, &nic_data->poll_period, sizeof(struct time val));721 memcpy(period, &nic_data->poll_period, sizeof(struct timespec)); 722 722 fibril_rwlock_read_unlock(&nic_data->main_lock); 723 723 return EOK; … … 737 737 */ 738 738 errno_t nic_poll_set_mode_impl(ddf_fun_t *fun, 739 nic_poll_mode_t mode, const struct time val*period)739 nic_poll_mode_t mode, const struct timespec *period) 740 740 { 741 741 nic_t *nic_data = nic_get_from_ddf_fun(fun); … … 753 753 if (period == NULL) 754 754 return EINVAL; 755 if (period->tv_sec == 0 && period->tv_ usec == 0)755 if (period->tv_sec == 0 && period->tv_nsec == 0) 756 756 return EINVAL; 757 if (period->tv_sec < 0 || period->tv_ usec < 0)757 if (period->tv_sec < 0 || period->tv_nsec < 0) 758 758 return EINVAL; 759 759 }
Note:
See TracChangeset
for help on using the changeset viewer.