Re: [PATCH resend v1 5/7] pps: clients: gpio: Make use of device properties

2021-03-09 Thread Rodolfo Giometti
On 09/03/21 12:24, Andy Shevchenko wrote:
> Device property API allows to gather device resources from different sources,
> such as ACPI. Convert the drivers to unleash the power of device property API.
> 
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/pps/clients/pps-gpio.c | 17 +++--
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
> index 291240dce79e..c6db3a3b257b 100644
> --- a/drivers/pps/clients/pps-gpio.c
> +++ b/drivers/pps/clients/pps-gpio.c
> @@ -12,14 +12,14 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> -#include 
> -#include 
> +#include 
>  #include 
>  #include 
>  
> @@ -102,7 +102,6 @@ static void pps_gpio_echo_timer_callback(struct 
> timer_list *t)
>  static int pps_gpio_setup(struct platform_device *pdev)
>  {
>   struct pps_gpio_device_data *data = platform_get_drvdata(pdev);
> - struct device_node *np = pdev->dev.of_node;
>   int ret;
>   u32 value;
>  
> @@ -121,26 +120,24 @@ static int pps_gpio_setup(struct platform_device *pdev)
>"failed to request ECHO GPIO\n");
>  
>   if (data->echo_pin) {
> - ret = of_property_read_u32(np,
> - "echo-active-ms",
> - );
> + ret = device_property_read_u32(>dev, "echo-active-ms", 
> );
>   if (ret) {
>   dev_err(>dev,
> - "failed to get echo-active-ms from OF\n");
> + "failed to get echo-active-ms from FW\n");
>   return ret;
>   }
>   data->echo_active_ms = value;
>   /* sanity check on echo_active_ms */
>   if (!data->echo_active_ms || data->echo_active_ms > 999) {
>   dev_err(>dev,
> - "echo-active-ms: %u - bad value from OF\n",
> + "echo-active-ms: %u - bad value from FW\n",
>   data->echo_active_ms);
>   return -EINVAL;
>   }
>   }
>  
> - if (of_property_read_bool(np, "assert-falling-edge"))
> - data->assert_falling_edge = true;
> + data->assert_falling_edge =
> + device_property_read_bool(>dev, "assert-falling-edge");
>   return 0;
>  }
>  
> 

Acked-by: Rodolfo Giometti 

-- 
GNU/Linux Solutions  e-mail: giome...@enneenne.com
Linux Device Driver  giome...@linux.it
Embedded Systems phone:  +39 349 2432127
UNIX programming skype:  rodolfo.giometti


[PATCH resend v1 5/7] pps: clients: gpio: Make use of device properties

2021-03-09 Thread Andy Shevchenko
Device property API allows to gather device resources from different sources,
such as ACPI. Convert the drivers to unleash the power of device property API.

Signed-off-by: Andy Shevchenko 
---
 drivers/pps/clients/pps-gpio.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 291240dce79e..c6db3a3b257b 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -12,14 +12,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
 #include 
 #include 
 
@@ -102,7 +102,6 @@ static void pps_gpio_echo_timer_callback(struct timer_list 
*t)
 static int pps_gpio_setup(struct platform_device *pdev)
 {
struct pps_gpio_device_data *data = platform_get_drvdata(pdev);
-   struct device_node *np = pdev->dev.of_node;
int ret;
u32 value;
 
@@ -121,26 +120,24 @@ static int pps_gpio_setup(struct platform_device *pdev)
 "failed to request ECHO GPIO\n");
 
if (data->echo_pin) {
-   ret = of_property_read_u32(np,
-   "echo-active-ms",
-   );
+   ret = device_property_read_u32(>dev, "echo-active-ms", 
);
if (ret) {
dev_err(>dev,
-   "failed to get echo-active-ms from OF\n");
+   "failed to get echo-active-ms from FW\n");
return ret;
}
data->echo_active_ms = value;
/* sanity check on echo_active_ms */
if (!data->echo_active_ms || data->echo_active_ms > 999) {
dev_err(>dev,
-   "echo-active-ms: %u - bad value from OF\n",
+   "echo-active-ms: %u - bad value from FW\n",
data->echo_active_ms);
return -EINVAL;
}
}
 
-   if (of_property_read_bool(np, "assert-falling-edge"))
-   data->assert_falling_edge = true;
+   data->assert_falling_edge =
+   device_property_read_bool(>dev, "assert-falling-edge");
return 0;
 }
 
-- 
2.30.1