2021-04-15 08:46:09

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH v2 1/3] mmc: sdhci-s3c: simplify getting of_device_id match data

Use of_device_get_match_data() to make the code slightly smaller and to
remove the of_device_id table forward declaration.

Signed-off-by: Krzysztof Kozlowski <[email protected]>

---

Changes since v1:
1. Rewrite the commit msg as it is not a NULL pointer dereference.
---
drivers/mmc/host/sdhci-s3c.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index f48a788a9d3d..8e1dca625620 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -20,6 +20,7 @@
#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
@@ -461,19 +462,12 @@ static int sdhci_s3c_parse_dt(struct device *dev,
}
#endif

-#ifdef CONFIG_OF
-static const struct of_device_id sdhci_s3c_dt_match[];
-#endif
-
static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
struct platform_device *pdev)
{
#ifdef CONFIG_OF
- if (pdev->dev.of_node) {
- const struct of_device_id *match;
- match = of_match_node(sdhci_s3c_dt_match, pdev->dev.of_node);
- return (struct sdhci_s3c_drv_data *)match->data;
- }
+ if (pdev->dev.of_node)
+ return (struct sdhci_s3c_drv_data *)of_device_get_match_data(&pdev->dev);
#endif
return (struct sdhci_s3c_drv_data *)
platform_get_device_id(pdev)->driver_data;
--
2.25.1


2021-04-15 08:46:27

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH v2 3/3] mmc: sdhci-s3c: constify uses of driver/match data

The driver data (struct sdhci_s3c_drv_data) stored in of_device_id
table is allocated as const and used only in const-way. Skip
unnecessary const-away casts and convert all users to work with pointer
to const. This is both more logical and safer.

Signed-off-by: Krzysztof Kozlowski <[email protected]>

---

Changes since v1:
1. None
---
drivers/mmc/host/sdhci-s3c.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index a07a8f011741..862f033d235d 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -462,21 +462,21 @@ static int sdhci_s3c_parse_dt(struct device *dev,
}
#endif

-static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
+static inline const struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
struct platform_device *pdev)
{
#ifdef CONFIG_OF
if (pdev->dev.of_node)
- return (struct sdhci_s3c_drv_data *)of_device_get_match_data(&pdev->dev);
+ return of_device_get_match_data(&pdev->dev);
#endif
- return (struct sdhci_s3c_drv_data *)
+ return (const struct sdhci_s3c_drv_data *)
platform_get_device_id(pdev)->driver_data;
}

static int sdhci_s3c_probe(struct platform_device *pdev)
{
struct s3c_sdhci_platdata *pdata;
- struct sdhci_s3c_drv_data *drv_data;
+ const struct sdhci_s3c_drv_data *drv_data;
struct device *dev = &pdev->dev;
struct sdhci_host *host;
struct sdhci_s3c *sc;
@@ -761,7 +761,7 @@ static const struct platform_device_id sdhci_s3c_driver_ids[] = {
MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids);

#ifdef CONFIG_OF
-static struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
+static const struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
.no_divider = true,
};

--
2.25.1

2021-04-15 08:46:52

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH v2 2/3] mmc: sdhci-s3c: correct kerneldoc of sdhci_s3c_drv_data

Correct the name of sdhci_s3c_drv_data structure in kerneldoc:

drivers/mmc/host/sdhci-s3c.c:143: warning:
expecting prototype for struct sdhci_s3c_driver_data. Prototype was for struct sdhci_s3c_drv_data instead

Signed-off-by: Krzysztof Kozlowski <[email protected]>

---

Changes since v1:
1. None
---
drivers/mmc/host/sdhci-s3c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 8e1dca625620..a07a8f011741 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -130,7 +130,7 @@ struct sdhci_s3c {
};

/**
- * struct sdhci_s3c_driver_data - S3C SDHCI platform specific driver data
+ * struct sdhci_s3c_drv_data - S3C SDHCI platform specific driver data
* @sdhci_quirks: sdhci host specific quirks.
* @no_divider: no or non-standard internal clock divider.
*
--
2.25.1

2021-04-15 09:42:51

by Sylwester Nawrocki

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] mmc: sdhci-s3c: simplify getting of_device_id match data


On 15.04.2021 10:44, Krzysztof Kozlowski wrote:
> Use of_device_get_match_data() to make the code slightly smaller and to
> remove the of_device_id table forward declaration.
>
> Signed-off-by: Krzysztof Kozlowski<[email protected]>

Reviewed-by: Sylwester Nawrocki <[email protected]>

2021-04-15 09:43:42

by Sylwester Nawrocki

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] mmc: sdhci-s3c: constify uses of driver/match data



On 15.04.2021 10:44, Krzysztof Kozlowski wrote:
> The driver data (struct sdhci_s3c_drv_data) stored in of_device_id
> table is allocated as const and used only in const-way. Skip
> unnecessary const-away casts and convert all users to work with pointer
> to const. This is both more logical and safer.
>
> Signed-off-by: Krzysztof Kozlowski<[email protected]>

Reviewed-by: Sylwester Nawrocki <[email protected]>

2021-04-15 09:59:18

by Sylwester Nawrocki

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] mmc: sdhci-s3c: correct kerneldoc of sdhci_s3c_drv_data


On 15.04.2021 10:44, Krzysztof Kozlowski wrote:
> Correct the name of sdhci_s3c_drv_data structure in kerneldoc:
>
> drivers/mmc/host/sdhci-s3c.c:143: warning:
> expecting prototype for struct sdhci_s3c_driver_data. Prototype was for struct sdhci_s3c_drv_data instead
>
> Signed-off-by: Krzysztof Kozlowski<[email protected]>

Reviewed-by: Sylwester Nawrocki <[email protected]>

2021-04-15 12:04:22

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] mmc: sdhci-s3c: simplify getting of_device_id match data

On Thu, 15 Apr 2021 at 10:44, Krzysztof Kozlowski
<[email protected]> wrote:
>
> Use of_device_get_match_data() to make the code slightly smaller and to
> remove the of_device_id table forward declaration.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Applied for next, thanks!

Kind regards
Uffe


>
> ---
>
> Changes since v1:
> 1. Rewrite the commit msg as it is not a NULL pointer dereference.
> ---
> drivers/mmc/host/sdhci-s3c.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index f48a788a9d3d..8e1dca625620 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -20,6 +20,7 @@
> #include <linux/gpio.h>
> #include <linux/module.h>
> #include <linux/of.h>
> +#include <linux/of_device.h>
> #include <linux/of_gpio.h>
> #include <linux/pm.h>
> #include <linux/pm_runtime.h>
> @@ -461,19 +462,12 @@ static int sdhci_s3c_parse_dt(struct device *dev,
> }
> #endif
>
> -#ifdef CONFIG_OF
> -static const struct of_device_id sdhci_s3c_dt_match[];
> -#endif
> -
> static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
> struct platform_device *pdev)
> {
> #ifdef CONFIG_OF
> - if (pdev->dev.of_node) {
> - const struct of_device_id *match;
> - match = of_match_node(sdhci_s3c_dt_match, pdev->dev.of_node);
> - return (struct sdhci_s3c_drv_data *)match->data;
> - }
> + if (pdev->dev.of_node)
> + return (struct sdhci_s3c_drv_data *)of_device_get_match_data(&pdev->dev);
> #endif
> return (struct sdhci_s3c_drv_data *)
> platform_get_device_id(pdev)->driver_data;
> --
> 2.25.1
>

2021-04-15 12:04:51

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] mmc: sdhci-s3c: constify uses of driver/match data

On Thu, 15 Apr 2021 at 10:44, Krzysztof Kozlowski
<[email protected]> wrote:
>
> The driver data (struct sdhci_s3c_drv_data) stored in of_device_id
> table is allocated as const and used only in const-way. Skip
> unnecessary const-away casts and convert all users to work with pointer
> to const. This is both more logical and safer.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
>

Applied for next, thanks!

Kind regards
Uffe


> ---
>
> Changes since v1:
> 1. None
> ---
> drivers/mmc/host/sdhci-s3c.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index a07a8f011741..862f033d235d 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -462,21 +462,21 @@ static int sdhci_s3c_parse_dt(struct device *dev,
> }
> #endif
>
> -static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
> +static inline const struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
> struct platform_device *pdev)
> {
> #ifdef CONFIG_OF
> if (pdev->dev.of_node)
> - return (struct sdhci_s3c_drv_data *)of_device_get_match_data(&pdev->dev);
> + return of_device_get_match_data(&pdev->dev);
> #endif
> - return (struct sdhci_s3c_drv_data *)
> + return (const struct sdhci_s3c_drv_data *)
> platform_get_device_id(pdev)->driver_data;
> }
>
> static int sdhci_s3c_probe(struct platform_device *pdev)
> {
> struct s3c_sdhci_platdata *pdata;
> - struct sdhci_s3c_drv_data *drv_data;
> + const struct sdhci_s3c_drv_data *drv_data;
> struct device *dev = &pdev->dev;
> struct sdhci_host *host;
> struct sdhci_s3c *sc;
> @@ -761,7 +761,7 @@ static const struct platform_device_id sdhci_s3c_driver_ids[] = {
> MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids);
>
> #ifdef CONFIG_OF
> -static struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
> +static const struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
> .no_divider = true,
> };
>
> --
> 2.25.1
>

2021-04-15 12:04:53

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] mmc: sdhci-s3c: correct kerneldoc of sdhci_s3c_drv_data

On Thu, 15 Apr 2021 at 10:44, Krzysztof Kozlowski
<[email protected]> wrote:
>
> Correct the name of sdhci_s3c_drv_data structure in kerneldoc:
>
> drivers/mmc/host/sdhci-s3c.c:143: warning:
> expecting prototype for struct sdhci_s3c_driver_data. Prototype was for struct sdhci_s3c_drv_data instead
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
>

Applied for next, thanks!

Kind regards
Uffe


> ---
>
> Changes since v1:
> 1. None
> ---
> drivers/mmc/host/sdhci-s3c.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index 8e1dca625620..a07a8f011741 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -130,7 +130,7 @@ struct sdhci_s3c {
> };
>
> /**
> - * struct sdhci_s3c_driver_data - S3C SDHCI platform specific driver data
> + * struct sdhci_s3c_drv_data - S3C SDHCI platform specific driver data
> * @sdhci_quirks: sdhci host specific quirks.
> * @no_divider: no or non-standard internal clock divider.
> *
> --
> 2.25.1
>