@@ -57,6 +57,7 @@ o ` ~~~~\___/~~~~ ` controller in FPGA is ,.`
5757#include <linux/types.h>
5858
5959#include <linux/gpio/driver.h>
60+ #include <linux/gpio/generic.h>
6061
6162#include "gpiolib.h"
6263
@@ -737,6 +738,8 @@ MODULE_DEVICE_TABLE(of, bgpio_of_match);
737738
738739static int bgpio_pdev_probe (struct platform_device * pdev )
739740{
741+ struct gpio_generic_chip_config config ;
742+ struct gpio_generic_chip * gen_gc ;
740743 struct device * dev = & pdev -> dev ;
741744 struct resource * r ;
742745 void __iomem * dat ;
@@ -748,7 +751,6 @@ static int bgpio_pdev_probe(struct platform_device *pdev)
748751 unsigned long flags = 0 ;
749752 unsigned int base ;
750753 int err ;
751- struct gpio_chip * gc ;
752754 const char * label ;
753755
754756 r = platform_get_resource_byname (pdev , IORESOURCE_MEM , "dat" );
@@ -777,8 +779,8 @@ static int bgpio_pdev_probe(struct platform_device *pdev)
777779 if (IS_ERR (dirin ))
778780 return PTR_ERR (dirin );
779781
780- gc = devm_kzalloc (& pdev -> dev , sizeof (* gc ), GFP_KERNEL );
781- if (!gc )
782+ gen_gc = devm_kzalloc (& pdev -> dev , sizeof (* gen_gc ), GFP_KERNEL );
783+ if (!gen_gc )
782784 return - ENOMEM ;
783785
784786 if (device_is_big_endian (dev ))
@@ -787,25 +789,36 @@ static int bgpio_pdev_probe(struct platform_device *pdev)
787789 if (device_property_read_bool (dev , "no-output" ))
788790 flags |= BGPIOF_NO_OUTPUT ;
789791
790- err = bgpio_init (gc , dev , sz , dat , set , clr , dirout , dirin , flags );
792+ config = (struct gpio_generic_chip_config ) {
793+ .dev = dev ,
794+ .sz = sz ,
795+ .dat = dat ,
796+ .set = set ,
797+ .clr = clr ,
798+ .dirout = dirout ,
799+ .dirin = dirin ,
800+ .flags = flags ,
801+ };
802+
803+ err = gpio_generic_chip_init (gen_gc , & config );
791804 if (err )
792805 return err ;
793806
794807 err = device_property_read_string (dev , "label" , & label );
795808 if (!err )
796- gc -> label = label ;
809+ gen_gc -> gc . label = label ;
797810
798811 /*
799812 * This property *must not* be used in device-tree sources, it's only
800813 * meant to be passed to the driver from board files and MFD core.
801814 */
802815 err = device_property_read_u32 (dev , "gpio-mmio,base" , & base );
803816 if (!err && base <= INT_MAX )
804- gc -> base = base ;
817+ gen_gc -> gc . base = base ;
805818
806- platform_set_drvdata (pdev , gc );
819+ platform_set_drvdata (pdev , & gen_gc -> gc );
807820
808- return devm_gpiochip_add_data (& pdev -> dev , gc , NULL );
821+ return devm_gpiochip_add_data (& pdev -> dev , & gen_gc -> gc , NULL );
809822}
810823
811824static const struct platform_device_id bgpio_id_table [] = {
0 commit comments