backports: add devm_gpio_free()

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
diff --git a/backport/backport-include/linux/gpio.h b/backport/backport-include/linux/gpio.h
index 8fb7211..964f1f3 100644
--- a/backport/backport-include/linux/gpio.h
+++ b/backport/backport-include/linux/gpio.h
@@ -9,6 +9,7 @@
 int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
 int devm_gpio_request_one(struct device *dev, unsigned gpio,
 			  unsigned long flags, const char *label);
+void devm_gpio_free(struct device *dev, unsigned int gpio);
 #else
 static inline int devm_gpio_request(struct device *dev, unsigned gpio,
 				    const char *label)
@@ -23,6 +24,11 @@
 	WARN_ON(1);
 	return -EINVAL;
 }
+
+static inline void devm_gpio_free(struct device *dev, unsigned int gpio)
+{
+	WARN_ON(1);
+}
 #endif /* CONFIG_GPIOLIB */
 #endif
 
diff --git a/backport/compat/compat-3.5.c b/backport/compat/compat-3.5.c
index 13f6476..1b8f787 100644
--- a/backport/compat/compat-3.5.c
+++ b/backport/compat/compat-3.5.c
@@ -149,4 +149,19 @@
 	return 0;
 }
 EXPORT_SYMBOL_GPL(devm_gpio_request_one);
+
+static int devm_gpio_match(struct device *dev, void *res, void *data)
+{
+	unsigned *this = res, *gpio = data;
+
+	return *this == *gpio;
+}
+
+void devm_gpio_free(struct device *dev, unsigned int gpio)
+{
+	WARN_ON(devres_destroy(dev, devm_gpio_release, devm_gpio_match,
+		&gpio));
+	gpio_free(gpio);
+}
+EXPORT_SYMBOL_GPL(devm_gpio_free);
 #endif /* CONFIG_GPIOLIB */