diff mbox

[5/9] hwmon: gpio-fan: Mandate OF_GPIO and cut pdata path

Message ID 20170925230911.20824-6-linus.walleij@linaro.org (mailing list archive)
State Accepted
Headers show

Commit Message

Linus Walleij Sept. 25, 2017, 11:09 p.m. UTC
We have no users of platform data, we made platform data driver-local,
so cut all #ifdefs for the platform data case, and depend on the
Kconfig CONFIG_OF_GPIO symbol.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/hwmon/Kconfig    |  1 +
 drivers/hwmon/gpio-fan.c | 36 ++++++++++--------------------------
 2 files changed, 11 insertions(+), 26 deletions(-)

Comments

Guenter Roeck Oct. 8, 2017, 2:29 p.m. UTC | #1
On Tue, Sep 26, 2017 at 01:09:07AM +0200, Linus Walleij wrote:
> We have no users of platform data, we made platform data driver-local,
> so cut all #ifdefs for the platform data case, and depend on the
> Kconfig CONFIG_OF_GPIO symbol.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/Kconfig    |  1 +
>  drivers/hwmon/gpio-fan.c | 36 ++++++++++--------------------------
>  2 files changed, 11 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> index d65431417b17..9b0e1db2202d 100644
> --- a/drivers/hwmon/Kconfig
> +++ b/drivers/hwmon/Kconfig
> @@ -552,6 +552,7 @@ config SENSORS_G762
>  
>  config SENSORS_GPIO_FAN
>  	tristate "GPIO fan"
> +	depends on OF_GPIO
>  	depends on GPIOLIB || COMPILE_TEST
>  	depends on THERMAL || THERMAL=n
>  	help
> diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
> index ad7d8fdf4f81..55dbdb223e02 100644
> --- a/drivers/hwmon/gpio-fan.c
> +++ b/drivers/hwmon/gpio-fan.c
> @@ -453,7 +453,6 @@ static const struct thermal_cooling_device_ops gpio_fan_cool_ops = {
>  	.set_cur_state = gpio_fan_set_cur_state,
>  };
>  
> -#ifdef CONFIG_OF_GPIO
>  /*
>   * Translate OpenFirmware node properties into platform_data
>   */
> @@ -556,7 +555,6 @@ static const struct of_device_id of_gpio_fan_match[] = {
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, of_gpio_fan_match);
> -#endif /* CONFIG_OF_GPIO */
>  
>  static int gpio_fan_probe(struct platform_device *pdev)
>  {
> @@ -564,29 +562,22 @@ static int gpio_fan_probe(struct platform_device *pdev)
>  	struct gpio_fan_data *fan_data;
>  	struct device *dev = &pdev->dev;
>  	struct device_node *np = dev->of_node;
> -	struct gpio_fan_platform_data *pdata = dev_get_platdata(dev);
> +	struct gpio_fan_platform_data *pdata;
>  
>  	fan_data = devm_kzalloc(dev, sizeof(struct gpio_fan_data),
>  				GFP_KERNEL);
>  	if (!fan_data)
>  		return -ENOMEM;
>  
> -#ifdef CONFIG_OF_GPIO
> -	if (!pdata) {
> -		pdata = devm_kzalloc(dev,
> -					sizeof(struct gpio_fan_platform_data),
> -					GFP_KERNEL);
> -		if (!pdata)
> -			return -ENOMEM;
> -
> -		err = gpio_fan_get_of_pdata(dev, pdata);
> -		if (err)
> -			return err;
> -	}
> -#else /* CONFIG_OF_GPIO */
> +	pdata = devm_kzalloc(dev,
> +			     sizeof(struct gpio_fan_platform_data),
> +			     GFP_KERNEL);
>  	if (!pdata)
> -		return -EINVAL;
> -#endif /* CONFIG_OF_GPIO */
> +		return -ENOMEM;
> +
> +	err = gpio_fan_get_of_pdata(dev, pdata);
> +	if (err)
> +		return err;
>  
>  	fan_data->dev = dev;
>  	platform_set_drvdata(pdev, fan_data);
> @@ -615,17 +606,12 @@ static int gpio_fan_probe(struct platform_device *pdev)
>  						       gpio_fan_groups);
>  	if (IS_ERR(fan_data->hwmon_dev))
>  		return PTR_ERR(fan_data->hwmon_dev);
> -#ifdef CONFIG_OF_GPIO
> +
>  	/* Optional cooling device register for Device tree platforms */
>  	fan_data->cdev = thermal_of_cooling_device_register(np,
>  							    "gpio-fan",
>  							    fan_data,
>  							    &gpio_fan_cool_ops);
> -#else /* CONFIG_OF_GPIO */
> -	/* Optional cooling device register for non Device tree platforms */
> -	fan_data->cdev = thermal_cooling_device_register("gpio-fan", fan_data,
> -							 &gpio_fan_cool_ops);
> -#endif /* CONFIG_OF_GPIO */
>  
>  	dev_info(dev, "GPIO fan initialized\n");
>  
> @@ -686,9 +672,7 @@ static struct platform_driver gpio_fan_driver = {
>  	.driver	= {
>  		.name	= "gpio-fan",
>  		.pm	= GPIO_FAN_PM,
> -#ifdef CONFIG_OF_GPIO
>  		.of_match_table = of_match_ptr(of_gpio_fan_match),
> -#endif
>  	},
>  };
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index d65431417b17..9b0e1db2202d 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -552,6 +552,7 @@  config SENSORS_G762
 
 config SENSORS_GPIO_FAN
 	tristate "GPIO fan"
+	depends on OF_GPIO
 	depends on GPIOLIB || COMPILE_TEST
 	depends on THERMAL || THERMAL=n
 	help
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index ad7d8fdf4f81..55dbdb223e02 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -453,7 +453,6 @@  static const struct thermal_cooling_device_ops gpio_fan_cool_ops = {
 	.set_cur_state = gpio_fan_set_cur_state,
 };
 
-#ifdef CONFIG_OF_GPIO
 /*
  * Translate OpenFirmware node properties into platform_data
  */
@@ -556,7 +555,6 @@  static const struct of_device_id of_gpio_fan_match[] = {
 	{},
 };
 MODULE_DEVICE_TABLE(of, of_gpio_fan_match);
-#endif /* CONFIG_OF_GPIO */
 
 static int gpio_fan_probe(struct platform_device *pdev)
 {
@@ -564,29 +562,22 @@  static int gpio_fan_probe(struct platform_device *pdev)
 	struct gpio_fan_data *fan_data;
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
-	struct gpio_fan_platform_data *pdata = dev_get_platdata(dev);
+	struct gpio_fan_platform_data *pdata;
 
 	fan_data = devm_kzalloc(dev, sizeof(struct gpio_fan_data),
 				GFP_KERNEL);
 	if (!fan_data)
 		return -ENOMEM;
 
-#ifdef CONFIG_OF_GPIO
-	if (!pdata) {
-		pdata = devm_kzalloc(dev,
-					sizeof(struct gpio_fan_platform_data),
-					GFP_KERNEL);
-		if (!pdata)
-			return -ENOMEM;
-
-		err = gpio_fan_get_of_pdata(dev, pdata);
-		if (err)
-			return err;
-	}
-#else /* CONFIG_OF_GPIO */
+	pdata = devm_kzalloc(dev,
+			     sizeof(struct gpio_fan_platform_data),
+			     GFP_KERNEL);
 	if (!pdata)
-		return -EINVAL;
-#endif /* CONFIG_OF_GPIO */
+		return -ENOMEM;
+
+	err = gpio_fan_get_of_pdata(dev, pdata);
+	if (err)
+		return err;
 
 	fan_data->dev = dev;
 	platform_set_drvdata(pdev, fan_data);
@@ -615,17 +606,12 @@  static int gpio_fan_probe(struct platform_device *pdev)
 						       gpio_fan_groups);
 	if (IS_ERR(fan_data->hwmon_dev))
 		return PTR_ERR(fan_data->hwmon_dev);
-#ifdef CONFIG_OF_GPIO
+
 	/* Optional cooling device register for Device tree platforms */
 	fan_data->cdev = thermal_of_cooling_device_register(np,
 							    "gpio-fan",
 							    fan_data,
 							    &gpio_fan_cool_ops);
-#else /* CONFIG_OF_GPIO */
-	/* Optional cooling device register for non Device tree platforms */
-	fan_data->cdev = thermal_cooling_device_register("gpio-fan", fan_data,
-							 &gpio_fan_cool_ops);
-#endif /* CONFIG_OF_GPIO */
 
 	dev_info(dev, "GPIO fan initialized\n");
 
@@ -686,9 +672,7 @@  static struct platform_driver gpio_fan_driver = {
 	.driver	= {
 		.name	= "gpio-fan",
 		.pm	= GPIO_FAN_PM,
-#ifdef CONFIG_OF_GPIO
 		.of_match_table = of_match_ptr(of_gpio_fan_match),
-#endif
 	},
 };