Produce an error if request_irq() fails and clean up properly. Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx> --- >> This is all a bit whacky, at this point the only sane thing I can think >> of doing is to panic if we cannot get the irq. > > Panic from driver which fails on request_irq is not a sane thing at all. > There is just /proc entry creation, tasklet init and the things done in > cvm_oct_configure_common_hw. I believe it's not that hard to revert the > initialization properly. Thanks, How about this? Can I move the request_irq() like this? Roel diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index b847951..9ada8e3 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -185,9 +185,19 @@ out: /** * Configure common hardware for all interfaces */ -static __init void cvm_oct_configure_common_hw(void) +static __init int cvm_oct_configure_common_hw(void) { int r; + + /* Register an IRQ hander for to receive POW interrupts */ + r = request_irq(OCTEON_IRQ_WORKQ0 + pow_receive_group, + cvm_oct_do_interrupt, IRQF_SHARED, "Ethernet", + cvm_oct_device); + if (r != 0) { + pr_err("cvm_oct_configure_common_hw: request_irq failed"); + return r; + } + /* Setup the FPA */ cvmx_fpa_enable(); cvm_oct_mem_fill_fpa(CVMX_FPA_PACKET_POOL, CVMX_FPA_PACKET_POOL_SIZE, @@ -206,17 +216,13 @@ static __init void cvm_oct_configure_common_hw(void) if (!octeon_is_simulation()) cvmx_write_csr(CVMX_SMIX_EN(0), 1); - /* Register an IRQ hander for to receive POW interrupts */ - r = request_irq(OCTEON_IRQ_WORKQ0 + pow_receive_group, - cvm_oct_do_interrupt, IRQF_SHARED, "Ethernet", - cvm_oct_device); - #if defined(CONFIG_SMP) && 0 if (USE_MULTICORE_RECEIVE) { irq_set_affinity(OCTEON_IRQ_WORKQ0 + pow_receive_group, cpu_online_mask); } #endif + return 0; } /** @@ -617,12 +623,15 @@ static int __init cvm_oct_init_module(void) int interface; int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE; int qos; + int r; pr_notice("cavium-ethernet %s\n", OCTEON_ETHERNET_VERSION); cvm_oct_proc_initialize(); cvm_oct_rx_initialize(); - cvm_oct_configure_common_hw(); + r = cvm_oct_configure_common_hw(); + if (r != 0) + goto out_rx_shutdown; cvmx_helper_initialize_packet_io_global(); @@ -806,6 +815,11 @@ static int __init cvm_oct_init_module(void) mod_timer(&cvm_oct_poll_timer, jiffies + HZ); return 0; + +out_rx_shutdown: + cvm_oct_rx_shutdown(); + cvm_oct_proc_shutdown(); + return r; } /** _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel