@@ -566,6 +566,42 @@ static void msm_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
566
566
#define msm_gpio_dbg_show NULL
567
567
#endif
568
568
569
+ static int msm_gpio_init_valid_mask (struct gpio_chip * chip )
570
+ {
571
+ struct msm_pinctrl * pctrl = gpiochip_get_data (chip );
572
+ int ret ;
573
+ unsigned int len , i ;
574
+ unsigned int max_gpios = pctrl -> soc -> ngpios ;
575
+ u16 * tmp ;
576
+
577
+ /* The number of GPIOs in the ACPI tables */
578
+ len = ret = device_property_read_u16_array (pctrl -> dev , "gpios" , NULL ,
579
+ 0 );
580
+ if (ret < 0 )
581
+ return 0 ;
582
+
583
+ if (ret > max_gpios )
584
+ return - EINVAL ;
585
+
586
+ tmp = kmalloc_array (len , sizeof (* tmp ), GFP_KERNEL );
587
+ if (!tmp )
588
+ return - ENOMEM ;
589
+
590
+ ret = device_property_read_u16_array (pctrl -> dev , "gpios" , tmp , len );
591
+ if (ret < 0 ) {
592
+ dev_err (pctrl -> dev , "could not read list of GPIOs\n" );
593
+ goto out ;
594
+ }
595
+
596
+ bitmap_zero (chip -> valid_mask , max_gpios );
597
+ for (i = 0 ; i < len ; i ++ )
598
+ set_bit (tmp [i ], chip -> valid_mask );
599
+
600
+ out :
601
+ kfree (tmp );
602
+ return ret ;
603
+ }
604
+
569
605
static const struct gpio_chip msm_gpio_template = {
570
606
.direction_input = msm_gpio_direction_input ,
571
607
.direction_output = msm_gpio_direction_output ,
@@ -575,6 +611,7 @@ static const struct gpio_chip msm_gpio_template = {
575
611
.request = gpiochip_generic_request ,
576
612
.free = gpiochip_generic_free ,
577
613
.dbg_show = msm_gpio_dbg_show ,
614
+ .init_valid_mask = msm_gpio_init_valid_mask ,
578
615
};
579
616
580
617
/* For dual-edge interrupts in software, since some hardware has no
@@ -831,41 +868,6 @@ static void msm_gpio_irq_handler(struct irq_desc *desc)
831
868
chained_irq_exit (chip , desc );
832
869
}
833
870
834
- static int msm_gpio_init_valid_mask (struct gpio_chip * chip ,
835
- struct msm_pinctrl * pctrl )
836
- {
837
- int ret ;
838
- unsigned int len , i ;
839
- unsigned int max_gpios = pctrl -> soc -> ngpios ;
840
- u16 * tmp ;
841
-
842
- /* The number of GPIOs in the ACPI tables */
843
- len = ret = device_property_read_u16_array (pctrl -> dev , "gpios" , NULL , 0 );
844
- if (ret < 0 )
845
- return 0 ;
846
-
847
- if (ret > max_gpios )
848
- return - EINVAL ;
849
-
850
- tmp = kmalloc_array (len , sizeof (* tmp ), GFP_KERNEL );
851
- if (!tmp )
852
- return - ENOMEM ;
853
-
854
- ret = device_property_read_u16_array (pctrl -> dev , "gpios" , tmp , len );
855
- if (ret < 0 ) {
856
- dev_err (pctrl -> dev , "could not read list of GPIOs\n" );
857
- goto out ;
858
- }
859
-
860
- bitmap_zero (chip -> valid_mask , max_gpios );
861
- for (i = 0 ; i < len ; i ++ )
862
- set_bit (tmp [i ], chip -> valid_mask );
863
-
864
- out :
865
- kfree (tmp );
866
- return ret ;
867
- }
868
-
869
871
static bool msm_gpio_needs_valid_mask (struct msm_pinctrl * pctrl )
870
872
{
871
873
return device_property_read_u16_array (pctrl -> dev , "gpios" , NULL , 0 ) > 0 ;
@@ -902,13 +904,6 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
902
904
return ret ;
903
905
}
904
906
905
- ret = msm_gpio_init_valid_mask (chip , pctrl );
906
- if (ret ) {
907
- dev_err (pctrl -> dev , "Failed to setup irq valid bits\n" );
908
- gpiochip_remove (& pctrl -> chip );
909
- return ret ;
910
- }
911
-
912
907
/*
913
908
* For DeviceTree-supported systems, the gpio core checks the
914
909
* pinctrl's device node for the "gpio-ranges" property.
0 commit comments