From a596849c2e49df3a1ff3769a1076725efd740ed5 Mon Sep 17 00:00:00 2001 From: Tom Knot Date: Wed, 4 Jul 2018 14:56:22 +0200 Subject: [PATCH] - Removed debug prints - Fixed division by zero --- modules/unipi/src/unipi_spi.c | 2 +- modules/unipi/src/unipi_sysfs.c | 10 ++++++++-- modules/unipi/src/unipi_tty.c | 2 ++ modules/unipi/src/unipi_uart.c | 31 ++++++++++++++++++++----------- version.txt | 2 +- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/modules/unipi/src/unipi_spi.c b/modules/unipi/src/unipi_spi.c index f65179d..d143b02 100644 --- a/modules/unipi/src/unipi_spi.c +++ b/modules/unipi/src/unipi_spi.c @@ -635,7 +635,7 @@ void neuronspi_spi_iio_stm_ao_set_current(struct iio_dev *indio_dev, struct iio_ u32 stm_v_inp_ref = 0; u32 stm_i_err = 0; u32 stm_i_off = 0; - u64 stm_true_val = 0; + u64 stm_true_val = val; u64 stm_true_ref = 0; regmap_read(n_spi->reg_map, n_spi->regstart_table->vref_int, &stm_v_int_ref); regmap_read(n_spi->reg_map, n_spi->regstart_table->vref_inp, &stm_v_inp_ref); diff --git a/modules/unipi/src/unipi_sysfs.c b/modules/unipi/src/unipi_sysfs.c index 31862df..a3691a1 100644 --- a/modules/unipi/src/unipi_sysfs.c +++ b/modules/unipi/src/unipi_sysfs.c @@ -200,7 +200,9 @@ static ssize_t neuronspi_spi_show_uart_timeout(struct device *dev, struct device struct neuronspi_driver_data *n_spi; struct platform_device *plat = to_platform_device(dev); n_spi = platform_get_drvdata(plat); +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI: Index %d\n", n_spi->neuron_index); +#endif spi = neuronspi_s_dev[n_spi->neuron_index]; if (n_spi && n_spi->combination_id != 0xFF && n_spi->reg_map && n_spi->regstart_table->uart_conf_reg) { read_length = neuronspi_spi_compose_single_register_read(504, &inp_buf, &outp_buf); @@ -224,7 +226,9 @@ static ssize_t neuronspi_spi_store_uart_timeout(struct device *dev, struct devic struct neuronspi_driver_data *n_spi; struct platform_device *plat = to_platform_device(dev); n_spi = platform_get_drvdata(plat); +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI: Index %d\n", n_spi->neuron_index); +#endif spi = neuronspi_s_dev[n_spi->neuron_index]; err = kstrtouint(buf, 0, &val); if (err < 0) goto err_end; @@ -1008,7 +1012,6 @@ static ssize_t neuronspi_iio_show_stm_ai_mode(struct device *dev, struct device_ struct spi_device *spi = ai_data->parent; struct neuronspi_driver_data *n_spi = spi_get_drvdata(spi); regmap_read(n_spi->reg_map, n_spi->regstart_table->stm_ai_mode_reg + ai_data->index, &val); - ret = scnprintf(buf, 255, "%d\n", val); return ret; } @@ -1038,9 +1041,10 @@ static ssize_t neuronspi_iio_show_stm_ao_mode(struct device *dev, struct device_ struct neuronspi_analog_data *ao_data = iio_priv(indio_dev); struct spi_device *spi = ao_data->parent; struct neuronspi_driver_data *n_spi = spi_get_drvdata(spi); - regmap_read(n_spi->reg_map, n_spi->regstart_table->stm_ao_mode_reg + ao_data->index, &val); +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI: Mode register %d set to %x", n_spi->regstart_table->stm_ao_mode_reg + ao_data->index, val); +#endif ret = scnprintf(buf, 255, "%d\n", val); return ret; } @@ -1056,7 +1060,9 @@ static ssize_t neuronspi_iio_store_stm_ao_mode(struct device *dev, struct device err = kstrtouint(buf, 0, &val); if (err < 0) goto err_end; if (n_spi && n_spi->combination_id != -1 && n_spi->reg_map) { +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI: Mode register %d set to %x", n_spi->regstart_table->stm_ao_mode_reg + ao_data->index, val); +#endif regmap_write(n_spi->reg_map, n_spi->regstart_table->stm_ao_mode_reg + ao_data->index, val); } err_end: diff --git a/modules/unipi/src/unipi_tty.c b/modules/unipi/src/unipi_tty.c index 79f260d..2179359 100644 --- a/modules/unipi/src/unipi_tty.c +++ b/modules/unipi/src/unipi_tty.c @@ -25,7 +25,9 @@ struct tty_ldisc_ops neuronspi_tty_ldisc; int neuronspi_tty_init() { int err; +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI TTY Init\n"); +#endif memset(&neuronspi_tty_ldisc, 0, sizeof(neuronspi_tty_ldisc)); n_tty_inherit_ops(&neuronspi_tty_ldisc); neuronspi_tty_ldisc.magic = TTY_LDISC_MAGIC; diff --git a/modules/unipi/src/unipi_uart.c b/modules/unipi/src/unipi_uart.c index 71562c4..79827d5 100644 --- a/modules/unipi/src/unipi_uart.c +++ b/modules/unipi/src/unipi_uart.c @@ -120,9 +120,9 @@ int neuronspi_uart_ioctl (struct uart_port *port, unsigned int ioctl_code, unsig return 1; } case 0x5481: { -//#if NEURONSPI_DETAILED_DEBUG > 0 +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI: IOCTL 0x5481\n"); -//#endif +#endif write_length = neuronspi_spi_compose_single_register_write(NEURONSPI_UART_TIMEOUT_REGISTER, &inp_buf, &outp_buf, (ioctl_arg * 1000000) / n_port->baud); printk(KERN_INFO "NEURONSPI: val_upper: %x, val_lower: %x", inp_buf[10], inp_buf[11]); neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 25, 1, 0); @@ -131,9 +131,9 @@ int neuronspi_uart_ioctl (struct uart_port *port, unsigned int ioctl_code, unsig return 0; } case 0x5480: { -//#if NEURONSPI_DETAILED_DEBUG > 0 +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI: IOCTL 0x5480\n"); -//#endif +#endif write_length = neuronspi_spi_compose_single_register_write(NEURONSPI_UART_TIMEOUT_REGISTER, &inp_buf, &outp_buf, ioctl_arg * 10); printk(KERN_INFO "NEURONSPI: val_upper: %x, val_lower: %x", inp_buf[10], inp_buf[11]); neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 25, 1, 0); @@ -158,9 +158,9 @@ void neuronspi_uart_set_termios(struct uart_port *port, struct ktermios *termios printk(KERN_INFO "NEURONSPI: c_iflag termios:%d\n", termios->c_iflag); #endif } -//#if NEURONSPI_DETAILED_DEBUG > 0 +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_DEBUG "NEURONSPI: TERMIOS Set, p:%d, c_cflag:%x\n", port->line, termios->c_cflag); -//#endif +#endif neuronspi_spi_uart_set_cflag(neuronspi_s_dev[n_port->dev_index], n_port->dev_port, termios->c_cflag); if (old && termios && (old->c_iflag & PARMRK) != (termios->c_iflag & PARMRK)) { neuronspi_uart_set_iflags(port, termios->c_iflag); @@ -169,7 +169,6 @@ void neuronspi_uart_set_termios(struct uart_port *port, struct ktermios *termios } } if (old && termios && old->c_line != termios->c_line) { - printk(KERN_INFO "NEURONSPI: Line Discipline change\n"); if (termios->c_line == N_PROFIBUS_FDL) { #if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI: Line Discipline change\n"); @@ -205,14 +204,14 @@ void neuronspi_uart_fifo_read(struct uart_port *port, u32 rxlen) s32 i; struct neuronspi_port *s = to_neuronspi_port(port,port); struct neuronspi_driver_data *d_data = spi_get_drvdata(neuronspi_s_dev[s->dev_index]); -//#if NEURONSPI_DETAILED_DEBUG > 2 +#if NEURONSPI_DETAILED_DEBUG > 2 printk(KERN_INFO "NEURONSPI: FIFO Read len:%d\n", rxlen); -//#endif +#endif memcpy(s->buf, d_data->uart_buf, rxlen); for (i = 0; i < rxlen; i++) { -//#if NEURONSPI_DETAILED_DEBUG > 2 +#if NEURONSPI_DETAILED_DEBUG > 2 printk(KERN_INFO "NEURONSPI: UART Char Read: %x\n", d_data->uart_buf[i]); -//#endif +#endif } } @@ -323,7 +322,9 @@ void neuronspi_uart_handle_tx(struct neuronspi_port *port) spin_lock_irqsave(&port->port.lock, flags); to_send = uart_circ_chars_pending(xmit); spin_unlock_irqrestore(&port->port.lock, flags); +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI UART_HANDLE_TX A, to_send:%d\n", to_send); +#endif if (likely(to_send)) { /* Limit to size of (TX FIFO / 2) */ max_txlen = NEURONSPI_FIFO_SIZE >> 2; @@ -339,7 +340,9 @@ void neuronspi_uart_handle_tx(struct neuronspi_port *port) xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); } spin_unlock_irqrestore(&port->port.lock, flags); +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI UART_HANDLE_TX B, to_send:%d\n", to_send_packet); +#endif neuronspi_uart_fifo_write(port, to_send_packet); spin_lock_irqsave(&port->port.lock, flags); to_send = uart_circ_chars_pending(xmit); @@ -356,7 +359,9 @@ void neuronspi_uart_handle_tx(struct neuronspi_port *port) xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); } spin_unlock_irqrestore(&port->port.lock, flags); +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI UART_HANDLE_TX C, to_send:%d\n", to_send_packet); +#endif neuronspi_uart_fifo_write(port, to_send_packet); } @@ -450,7 +455,9 @@ s32 neuronspi_uart_probe(struct spi_device* dev, u8 device_index) kthread_init_work(&(uart_data->p[i].rx_work), neuronspi_uart_rx_proc); kthread_init_work(&(uart_data->p[i].irq_work), neuronspi_uart_ist); uart_add_one_port(driver_data->serial_driver, &uart_data->p[i].port); +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI: Added UART port %d\n", i); +#endif } // For ports on multiple SPI devices renumber the ports to correspond to SPI chip-select numbering @@ -579,7 +586,9 @@ void neuronspi_uart_start_tx(struct uart_port *port) printk(KERN_INFO "NEURONSPI: Start TX\n"); #endif if (!kthread_queue_work(&n_port->parent->kworker, &n_port->tx_work)) { +#if NEURONSPI_DETAILED_DEBUG > 0 printk(KERN_INFO "NEURONSPI: TX WORK OVERFLOW\n"); +#endif } } diff --git a/version.txt b/version.txt index 024b8d6..62893fc 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -Repository:neuron-kernel ActiveBranch:[uart_timeout] PrecedingRelease:v.0.12 PrecedingRevision:79(399f005) LatestCommit:Wed Jul 4 14:41:13 CEST 2018 +Repository:neuron-kernel ActiveBranch:[uart_timeout] PrecedingRelease:v.0.12 PrecedingRevision:80(7ebe7c2) LatestCommit:Wed Jul 4 14:56:23 CEST 2018 -- 2.34.1