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