Changes in uspace/drv/char/ns8250/ns8250.c [267f235:956d4281] in mainline
- File:
-
- 1 edited
-
uspace/drv/char/ns8250/ns8250.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/ns8250/ns8250.c
r267f235 r956d4281 40 40 #include <stdio.h> 41 41 #include <errno.h> 42 #include < bool.h>42 #include <stdbool.h> 43 43 #include <fibril_synch.h> 44 44 #include <stdlib.h> … … 51 51 #include <sys/stat.h> 52 52 #include <ddi.h> 53 #include <libarch/ddi.h>54 53 55 54 #include <ddf/driver.h> … … 161 160 /** I/O registers **/ 162 161 ns8250_regs_t *regs; 163 /** Is there any client conntected to the device? */164 bool client_connected;162 /** Are there any clients connected to the device? */ 163 unsigned client_connections; 165 164 /** The irq assigned to this device. */ 166 165 int irq; … … 169 168 /** The i/o port used to access the serial ports registers. */ 170 169 ioport8_t *port; 171 /** The buffer for incom ming data. */170 /** The buffer for incoming data. */ 172 171 cyclic_buffer_t input_buffer; 173 172 /** The fibril mutex for synchronizing the access to the device. */ … … 191 190 } 192 191 193 /** Find out if there is some incom ming data available on the serial port.192 /** Find out if there is some incoming data available on the serial port. 194 193 * 195 194 * @param port The base address of the serial port device's ports. … … 237 236 * 238 237 * @param fun The serial port function 239 * @param buf The ou put buffer for read data.238 * @param buf The output buffer for read data. 240 239 * @param count The number of bytes to be read. 241 240 * … … 421 420 ns->irq = res->res.interrupt.irq; 422 421 irq = true; 423 ddf_msg(LVL_NOTE, "Device %s was as igned irq = 0x%x.",422 ddf_msg(LVL_NOTE, "Device %s was assigned irq = 0x%x.", 424 423 ddf_dev_get_name(ns->dev), ns->irq); 425 424 break; … … 434 433 } 435 434 ioport = true; 436 ddf_msg(LVL_NOTE, "Device %s was as igned I/O address = "435 ddf_msg(LVL_NOTE, "Device %s was assigned I/O address = " 437 436 "0x%x.", ddf_dev_get_name(ns->dev), ns->io_addr); 438 437 break; … … 754 753 uint8_t val = ns8250_read_8(regs); 755 754 756 if (ns->client_connect ed) {755 if (ns->client_connections > 0) { 757 756 bool buf_was_empty = buf_is_empty(&ns->input_buffer); 758 757 if (!buf_push_back(&ns->input_buffer, val)) { … … 828 827 ddf_fun_t *fun = NULL; 829 828 bool need_cleanup = false; 829 bool need_unreg_intr_handler = false; 830 830 int rc; 831 831 … … 870 870 goto fail; 871 871 } 872 need_unreg_intr_handler = true; 872 873 873 874 /* Enable interrupt. */ … … 904 905 if (fun != NULL) 905 906 ddf_fun_destroy(fun); 907 if (need_unreg_intr_handler) 908 ns8250_unregister_interrupt_handler(ns); 906 909 if (need_cleanup) 907 910 ns8250_dev_cleanup(ns); … … 915 918 916 919 fibril_mutex_lock(&ns->mutex); 917 if (ns->client_connect ed) {920 if (ns->client_connections > 0) { 918 921 fibril_mutex_unlock(&ns->mutex); 919 922 return EBUSY; … … 949 952 950 953 fibril_mutex_lock(&ns->mutex); 951 if (ns->client_connected) { 952 res = ELIMIT; 953 } else if (ns->removed) { 954 if (ns->removed) { 954 955 res = ENXIO; 955 956 } else { 956 957 res = EOK; 957 ns->client_connect ed = true;958 ns->client_connections++; 958 959 } 959 960 fibril_mutex_unlock(&ns->mutex); … … 975 976 fibril_mutex_lock(&data->mutex); 976 977 977 assert(data->client_connect ed);978 979 data->client_connected = false;980 buf_clear(&data->input_buffer);978 assert(data->client_connections > 0); 979 980 if (!(--data->client_connections)) 981 buf_clear(&data->input_buffer); 981 982 982 983 fibril_mutex_unlock(&data->mutex);
Note:
See TracChangeset
for help on using the changeset viewer.
