File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -478,3 +478,49 @@ void devm_gpio_free(struct device *dev, unsigned int gpio)
478478 & gpio ));
479479}
480480EXPORT_SYMBOL_GPL (devm_gpio_free );
481+
482+ static void devm_gpio_chip_release (struct device * dev , void * res )
483+ {
484+ struct gpio_chip * gc = * (struct gpio_chip * * )res ;
485+
486+ gpiochip_remove (gc );
487+ }
488+
489+ /**
490+ * devm_gpiochip_add_data() - Resource managed gpiochip_add_data()
491+ * @dev: pointer to the device that gpio_chip belongs to.
492+ * @gc: the GPIO chip to register
493+ * @data: driver-private data associated with this chip
494+ *
495+ * Context: potentially before irqs will work
496+ *
497+ * The gpio chip automatically be released when the device is unbound.
498+ *
499+ * Returns:
500+ * A negative errno if the chip can't be registered, such as because the
501+ * gc->base is invalid or already associated with a different chip.
502+ * Otherwise it returns zero as a success code.
503+ */
504+ int devm_gpiochip_add_data (struct device * dev , struct gpio_chip * gc ,
505+ void * data )
506+ {
507+ struct gpio_chip * * ptr ;
508+ int ret ;
509+
510+ ptr = devres_alloc (devm_gpio_chip_release , sizeof (* ptr ),
511+ GFP_KERNEL );
512+ if (!ptr )
513+ return - ENOMEM ;
514+
515+ ret = gpiochip_add_data (gc , data );
516+ if (ret < 0 ) {
517+ devres_free (ptr );
518+ return ret ;
519+ }
520+
521+ * ptr = gc ;
522+ devres_add (dev , ptr );
523+
524+ return 0 ;
525+ }
526+ EXPORT_SYMBOL_GPL (devm_gpiochip_add_data );
Original file line number Diff line number Diff line change @@ -1838,52 +1838,6 @@ void gpiochip_remove(struct gpio_chip *chip)
18381838}
18391839EXPORT_SYMBOL_GPL (gpiochip_remove );
18401840
1841- static void devm_gpio_chip_release (struct device * dev , void * res )
1842- {
1843- struct gpio_chip * chip = * (struct gpio_chip * * )res ;
1844-
1845- gpiochip_remove (chip );
1846- }
1847-
1848- /**
1849- * devm_gpiochip_add_data() - Resource managed gpiochip_add_data()
1850- * @dev: pointer to the device that gpio_chip belongs to.
1851- * @chip: the chip to register, with chip->base initialized
1852- * @data: driver-private data associated with this chip
1853- *
1854- * Context: potentially before irqs will work
1855- *
1856- * The gpio chip automatically be released when the device is unbound.
1857- *
1858- * Returns:
1859- * A negative errno if the chip can't be registered, such as because the
1860- * chip->base is invalid or already associated with a different chip.
1861- * Otherwise it returns zero as a success code.
1862- */
1863- int devm_gpiochip_add_data (struct device * dev , struct gpio_chip * chip ,
1864- void * data )
1865- {
1866- struct gpio_chip * * ptr ;
1867- int ret ;
1868-
1869- ptr = devres_alloc (devm_gpio_chip_release , sizeof (* ptr ),
1870- GFP_KERNEL );
1871- if (!ptr )
1872- return - ENOMEM ;
1873-
1874- ret = gpiochip_add_data (chip , data );
1875- if (ret < 0 ) {
1876- devres_free (ptr );
1877- return ret ;
1878- }
1879-
1880- * ptr = chip ;
1881- devres_add (dev , ptr );
1882-
1883- return 0 ;
1884- }
1885- EXPORT_SYMBOL_GPL (devm_gpiochip_add_data );
1886-
18871841/**
18881842 * gpiochip_find() - iterator for locating a specific gpio_chip
18891843 * @data: data to pass to match function
You can’t perform that action at this time.
0 commit comments