149
149
#define LTQ_SPI_IRNEN_T_XRX BIT(0) /* Receive end interrupt request */
150
150
#define LTQ_SPI_IRNEN_ALL 0x1F
151
151
152
+ struct lantiq_ssc_spi ;
153
+
152
154
struct lantiq_ssc_hwcfg {
155
+ int (* cfg_irq )(struct platform_device * pdev , struct lantiq_ssc_spi * spi );
153
156
unsigned int irnen_r ;
154
157
unsigned int irnen_t ;
155
158
unsigned int irncr ;
@@ -799,7 +802,40 @@ static int lantiq_ssc_transfer_one(struct spi_master *master,
799
802
return transfer_start (spi , spidev , t );
800
803
}
801
804
805
+ static int lantiq_cfg_irq (struct platform_device * pdev , struct lantiq_ssc_spi * spi )
806
+ {
807
+ int irq , err ;
808
+
809
+ irq = platform_get_irq_byname (pdev , LTQ_SPI_RX_IRQ_NAME );
810
+ if (irq < 0 )
811
+ return irq ;
812
+
813
+ err = devm_request_irq (& pdev -> dev , irq , lantiq_ssc_xmit_interrupt ,
814
+ 0 , LTQ_SPI_RX_IRQ_NAME , spi );
815
+ if (err )
816
+ return err ;
817
+
818
+ irq = platform_get_irq_byname (pdev , LTQ_SPI_TX_IRQ_NAME );
819
+ if (irq < 0 )
820
+ return irq ;
821
+
822
+ err = devm_request_irq (& pdev -> dev , irq , lantiq_ssc_xmit_interrupt ,
823
+ 0 , LTQ_SPI_TX_IRQ_NAME , spi );
824
+
825
+ if (err )
826
+ return err ;
827
+
828
+ irq = platform_get_irq_byname (pdev , LTQ_SPI_ERR_IRQ_NAME );
829
+ if (irq < 0 )
830
+ return irq ;
831
+
832
+ err = devm_request_irq (& pdev -> dev , irq , lantiq_ssc_err_interrupt ,
833
+ 0 , LTQ_SPI_ERR_IRQ_NAME , spi );
834
+ return err ;
835
+ }
836
+
802
837
static const struct lantiq_ssc_hwcfg lantiq_ssc_xway = {
838
+ .cfg_irq = lantiq_cfg_irq ,
803
839
.irnen_r = LTQ_SPI_IRNEN_R_XWAY ,
804
840
.irnen_t = LTQ_SPI_IRNEN_T_XWAY ,
805
841
.irnicr = 0xF8 ,
@@ -809,6 +845,7 @@ static const struct lantiq_ssc_hwcfg lantiq_ssc_xway = {
809
845
};
810
846
811
847
static const struct lantiq_ssc_hwcfg lantiq_ssc_xrx = {
848
+ .cfg_irq = lantiq_cfg_irq ,
812
849
.irnen_r = LTQ_SPI_IRNEN_R_XRX ,
813
850
.irnen_t = LTQ_SPI_IRNEN_T_XRX ,
814
851
.irnicr = 0xF8 ,
@@ -832,9 +869,9 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
832
869
struct lantiq_ssc_spi * spi ;
833
870
const struct lantiq_ssc_hwcfg * hwcfg ;
834
871
const struct of_device_id * match ;
835
- int err , rx_irq , tx_irq , err_irq ;
836
872
u32 id , supports_dma , revision ;
837
873
unsigned int num_cs ;
874
+ int err ;
838
875
839
876
match = of_match_device (lantiq_ssc_match , dev );
840
877
if (!match ) {
@@ -843,18 +880,6 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
843
880
}
844
881
hwcfg = match -> data ;
845
882
846
- rx_irq = platform_get_irq_byname (pdev , LTQ_SPI_RX_IRQ_NAME );
847
- if (rx_irq < 0 )
848
- return - ENXIO ;
849
-
850
- tx_irq = platform_get_irq_byname (pdev , LTQ_SPI_TX_IRQ_NAME );
851
- if (tx_irq < 0 )
852
- return - ENXIO ;
853
-
854
- err_irq = platform_get_irq_byname (pdev , LTQ_SPI_ERR_IRQ_NAME );
855
- if (err_irq < 0 )
856
- return - ENXIO ;
857
-
858
883
master = spi_alloc_master (dev , sizeof (struct lantiq_ssc_spi ));
859
884
if (!master )
860
885
return - ENOMEM ;
@@ -870,18 +895,7 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
870
895
goto err_master_put ;
871
896
}
872
897
873
- err = devm_request_irq (dev , rx_irq , lantiq_ssc_xmit_interrupt ,
874
- 0 , LTQ_SPI_RX_IRQ_NAME , spi );
875
- if (err )
876
- goto err_master_put ;
877
-
878
- err = devm_request_irq (dev , tx_irq , lantiq_ssc_xmit_interrupt ,
879
- 0 , LTQ_SPI_TX_IRQ_NAME , spi );
880
- if (err )
881
- goto err_master_put ;
882
-
883
- err = devm_request_irq (dev , err_irq , lantiq_ssc_err_interrupt ,
884
- 0 , LTQ_SPI_ERR_IRQ_NAME , spi );
898
+ err = hwcfg -> cfg_irq (pdev , spi );
885
899
if (err )
886
900
goto err_master_put ;
887
901
0 commit comments