Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: mrst_max3110: Make the IRQ option runtime

And while we are at it allow it to fail to find one. Without this the IRQ
option will cause the 3110 driver to fail on 0.7 SFI firmware.

Acked-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Cox and committed by
Greg Kroah-Hartman
91efa75c ee9b4500

+29 -35
-7
drivers/serial/Kconfig
··· 717 717 the Intel Moorestown platform. On other systems use the max3100 718 718 driver. 719 719 720 - config MRST_MAX3110_IRQ 721 - boolean "Enable GPIO IRQ for Max3110 over Moorestown" 722 - default n 723 - depends on SERIAL_MRST_MAX3110 && GPIO_LANGWELL 724 - help 725 - This has to be enabled after Moorestown GPIO driver is loaded 726 - 727 720 config SERIAL_MFD_HSU 728 721 tristate "Medfield High Speed UART support" 729 722 depends on PCI
+29 -28
drivers/serial/mrst_max3110.c
··· 447 447 return ret; 448 448 } 449 449 450 - #ifdef CONFIG_MRST_MAX3110_IRQ 451 450 static irqreturn_t serial_m3110_irq(int irq, void *dev_id) 452 451 { 453 452 struct uart_max3110 *max = dev_id; ··· 458 459 459 460 return IRQ_HANDLED; 460 461 } 461 - #else 462 + 462 463 /* if don't use RX IRQ, then need a thread to polling read */ 463 464 static int max3110_read_thread(void *_max) 464 465 { ··· 481 482 482 483 return 0; 483 484 } 484 - #endif 485 485 486 486 static int serial_m3110_startup(struct uart_port *port) 487 487 { ··· 503 505 /* as we use thread to handle tx/rx, need set low latency */ 504 506 port->state->port.tty->low_latency = 1; 505 507 506 - #ifdef CONFIG_MRST_MAX3110_IRQ 507 - ret = request_irq(max->irq, serial_m3110_irq, 508 - IRQ_TYPE_EDGE_FALLING, "max3110", max); 509 - if (ret) 510 - return ret; 511 - 512 - /* Enable RX IRQ only */ 513 - config |= WC_RXA_IRQ_ENABLE; 514 - #else 515 - /* If IRQ is disabled, start a read thread for input data */ 516 - max->read_thread = 517 - kthread_run(max3110_read_thread, max, "max3110_read"); 518 - if (IS_ERR(max->read_thread)) { 519 - ret = PTR_ERR(max->read_thread); 508 + if (max->irq) { 520 509 max->read_thread = NULL; 521 - pr_err(PR_FMT "Can't create read thread!"); 522 - return ret; 510 + ret = request_irq(max->irq, serial_m3110_irq, 511 + IRQ_TYPE_EDGE_FALLING, "max3110", max); 512 + if (ret) { 513 + max->irq = 0; 514 + pr_err(PR_FMT "unable to allocate IRQ, polling\n"); 515 + } else { 516 + /* Enable RX IRQ only */ 517 + config |= WC_RXA_IRQ_ENABLE; 518 + } 523 519 } 524 - #endif 520 + 521 + if (max->irq == 0) { 522 + /* If IRQ is disabled, start a read thread for input data */ 523 + max->read_thread = 524 + kthread_run(max3110_read_thread, max, "max3110_read"); 525 + if (IS_ERR(max->read_thread)) { 526 + ret = PTR_ERR(max->read_thread); 527 + max->read_thread = NULL; 528 + pr_err(PR_FMT "Can't create read thread!\n"); 529 + return ret; 530 + } 531 + } 525 532 526 533 ret = max3110_out(max, config); 527 534 if (ret) { 528 - #ifdef CONFIG_MRST_MAX3110_IRQ 529 - free_irq(max->irq, max); 530 - #else 531 - kthread_stop(max->read_thread); 535 + if (max->irq) 536 + free_irq(max->irq, max); 537 + if (max->read_thread) 538 + kthread_stop(max->read_thread); 532 539 max->read_thread = NULL; 533 - #endif 534 540 return ret; 535 541 } 536 542 ··· 553 551 max->read_thread = NULL; 554 552 } 555 553 556 - #ifdef CONFIG_MRST_MAX3110_IRQ 557 - free_irq(max->irq, max); 558 - #endif 554 + if (max->irq) 555 + free_irq(max->irq, max); 559 556 560 557 /* Disable interrupts from this port */ 561 558 config = WC_TAG | WC_SW_SHDI;