Skip to contentSkip to conversation

drivers: depend on HAS_IOMEM for devm_platform_ioremap_resource()

PATCH In review Bartosz Golaszewski 8 participants 20 messages Feb 21, 2019 – Jun 25, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: depend on HAS_IOMEM for devm_platform_ioremap_resource()

From: Bartosz Golaszewski <[email protected]>

We only build devm_ioremap_resource() if HAS_IOMEM is selected, so this dependency must cascade down to devm_platform_ioremap_resource().

---
 drivers/base/platform.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/base/platform.c +2 -0
index f82691e1c26c..5f837f2e4f41 100644
@@ -87,6 +87,7 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
  *        resource managemend
  * @index: resource index
  */
+#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
 					     unsigned int index)
 {
@@ -96,6 +97,7 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
 	return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+#endif /* CONFIG_HAS_IOMEM */
 
 /**
  * platform_get_irq - get an IRQ for a device
Signature · 1 line
2.20.1
#2 lore raw
In reply to Bartosz Golaszewski
Quoted 11 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We only build devm_ioremap_resource() if HAS_IOMEM is selected, so this dependency must cascade down to devm_platform_ioremap_resource().

drivers/base/platform.c +1 -0
+#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
                                             unsigned int index)
 {

drivers/base/platform.c void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev, · line 100

Quoted 4 lines
drivers/base/platform.c +1 -0
@@ -96,6 +97,7 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
        return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+#endif /* CONFIG_HAS_IOMEM */

What about declaration in *.h?

Perhaps you may just do this inside the function?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 20 lines · Andy Shevchenko
Quoted 11 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We only build devm_ioremap_resource() if HAS_IOMEM is selected, so this dependency must cascade down to devm_platform_ioremap_resource().

drivers/base/platform.c +1 -0
+#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
                                             unsigned int index)
 {

drivers/base/platform.c void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev, · line 100

Quoted 4 lines
drivers/base/platform.c +1 -0
@@ -96,6 +97,7 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
        return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+#endif /* CONFIG_HAS_IOMEM */

What about declaration in *.h?

Quoted 1 line

Perhaps you may just do this inside the function?

#ifdef ...
#else
return ERR_PTR(-ENOTSUPP);
#endif

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

czw., 21 lut 2019 o 20:56 Andy Shevchenko <[email protected]> napisał(a):

Quoted 23 lines
Quoted 20 lines · Andy Shevchenko
Quoted 11 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We only build devm_ioremap_resource() if HAS_IOMEM is selected, so this dependency must cascade down to devm_platform_ioremap_resource().

drivers/base/platform.c +1 -0
+#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
                                             unsigned int index)
 {

drivers/base/platform.c void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev, · line 100

Quoted 4 lines
drivers/base/platform.c +1 -0
@@ -96,6 +97,7 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
        return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+#endif /* CONFIG_HAS_IOMEM */

What about declaration in *.h?

Quoted 7 lines
Quoted 1 line

Perhaps you may just do this inside the function?

#ifdef ...
#else
return ERR_PTR(-ENOTSUPP);
#endif

I followed the example of devm_ioremap_resource() which doesn't do this - it just expects never to be used by systems without IOMEM.

Bart

#5 lore raw
Quoted 28 lines · Bartosz Golaszewski

czw., 21 lut 2019 o 20:56 Andy Shevchenko <[email protected]> napisał(a):

Quoted 25 lines
Quoted 21 lines · Andy Shevchenko
Quoted 11 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We only build devm_ioremap_resource() if HAS_IOMEM is selected, so this dependency must cascade down to devm_platform_ioremap_resource().

drivers/base/platform.c +1 -0
+#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
                                             unsigned int index)
 {

drivers/base/platform.c void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev, · line 100

Quoted 4 lines
drivers/base/platform.c +1 -0
@@ -96,6 +97,7 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
        return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+#endif /* CONFIG_HAS_IOMEM */

What about declaration in *.h?

Perhaps you may just do this inside the function?

Quoted 8 lines
Quoted 5 lines

#ifdef ...
#else
return ERR_PTR(-ENOTSUPP);
#endif

I followed the example of devm_ioremap_resource() which doesn't do this - it just expects never to be used by systems without IOMEM.

Okay, that's fine!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw
In reply to Andy Shevchenko
Quoted 20 lines · Andy Shevchenko
Quoted 11 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We only build devm_ioremap_resource() if HAS_IOMEM is selected, so this dependency must cascade down to devm_platform_ioremap_resource().

drivers/base/platform.c +1 -0
+#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
                                             unsigned int index)
 {

drivers/base/platform.c void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev, · line 100

Quoted 4 lines
drivers/base/platform.c +1 -0
@@ -96,6 +97,7 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
        return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+#endif /* CONFIG_HAS_IOMEM */

What about declaration in *.h?

Quoted 1 line

Perhaps you may just do this inside the function?

Just a drive by comment, but IMO we should just get rid of HAS_IOMEM altogether. It is really just a !UML option as I think every other arch enables it. If folks really want to disable drivers on UML, just disable the subsystems.

Though now with kunit mocking, there's a desire to enable HAS_IOMEM on UML, too.

Rob

#7 lore raw
Quoted 4 lines · Rob Herring

Just a drive by comment, but IMO we should just get rid of HAS_IOMEM altogether. It is really just a !UML option as I think every other arch enables it. If folks really want to disable drivers on UML, just disable the subsystems.

I just got a build failure from S390 for the same thing so apparently there is S390 Linux without IOMEM. I have no idea how that works but whenever Arnd start talking to me about how S390 works my head start spinning.

Yours,
Linus Walleij

#8 lore raw

PATCH 1/1 drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

In reply to Bartosz Golaszewski

From: Markus Elfring <[email protected]>
Date: Fri, 14 Jun 2019 17:45:13 +0200

Move the preprocessor statement “#ifdef CONFIG_HAS_IOMEM” so that the corresponding scope for conditional compilation includes also comments for this function implementation.

---
 drivers/base/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +1 -1
index 4d1729853d1a..a5f40974a6ef 100644
@@ -78,6 +78,7 @@ struct resource *platform_get_resource(struct platform_device *dev,
 	return NULL;
 }
 EXPORT_SYMBOL_GPL(platform_get_resource);
+#ifdef CONFIG_HAS_IOMEM
 
 /**
  * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
@@ -87,7 +88,6 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
  *        resource management
  * @index: resource index
  */
-#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
 					     unsigned int index)
 {

--
2.22.0

#9 lore raw

Re: [PATCH] drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

pt., 14 cze 2019 o 18:50 Markus Elfring <[email protected]> napisał(a):

Quoted 34 lines

From: Markus Elfring <[email protected]>
Date: Fri, 14 Jun 2019 17:45:13 +0200

Move the preprocessor statement “#ifdef CONFIG_HAS_IOMEM” so that the corresponding scope for conditional compilation includes also comments for this function implementation.

---
 drivers/base/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +1 -2
index 4d1729853d1a..a5f40974a6ef 100644
@@ -78,6 +78,7 @@ struct resource *platform_get_resource(struct platform_device *dev,
        return NULL;
 }
 EXPORT_SYMBOL_GPL(platform_get_resource);
+#ifdef CONFIG_HAS_IOMEM
 
 /**
  * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
@@ -87,7 +88,6 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
  *        resource management
  * @index: resource index
  */
-#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
                                             unsigned int index)
 {
--
Quoted 2 lines

2.22.0

And what is the purpose of that?

Bart

#10 lore raw

Re: [PATCH] drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

Quoted 24 lines · Bartosz Golaszewski

pt., 14 cze 2019 o 18:50 Markus Elfring <[email protected]> napisał(a):

Quoted 23 lines

From: Markus Elfring <[email protected]>
Date: Fri, 14 Jun 2019 17:45:13 +0200

Move the preprocessor statement “#ifdef CONFIG_HAS_IOMEM” so that the corresponding scope for conditional compilation includes also comments for this function implementation.

---
 drivers/base/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +1 -0
index 4d1729853d1a..a5f40974a6ef 100644
@@ -78,6 +78,7 @@ struct resource *platform_get_resource(struct platform_device *dev,
        return NULL;
 }
 EXPORT_SYMBOL_GPL(platform_get_resource);
+#ifdef CONFIG_HAS_IOMEM
 
Quoted 15 lines
Quoted 11 lines
drivers/base/platform.c +0 -2
 /**
  * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
@@ -87,7 +88,6 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
  *        resource management
  * @index: resource index
  */
-#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
                                             unsigned int index)
 {
--
Quoted 2 lines

2.22.0

And what is the purpose of that?

I can imagine that this could improve readability a little bit. Maybe if one uses same fancy ide/editor that can fold code blocks like functions and conditionals, this patch could make the code prettier.

The patch seems pretty trivial and doesn't change any actual code, so I don't see hard resons for rejecting it.

--mtx

Signature · 3 lines
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
[email protected] -- +49-151-27565287
#11 lore raw

Re: [PATCH] drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

pon., 24 cze 2019 o 12:05 Enrico Weigelt, metux IT consult <[email protected]> napisał(a):

Quoted 42 lines · Bartosz Golaszewski
Quoted 24 lines

pt., 14 cze 2019 o 18:50 Markus Elfring <[email protected]> napisał(a):

Quoted 23 lines

From: Markus Elfring <[email protected]>
Date: Fri, 14 Jun 2019 17:45:13 +0200

Move the preprocessor statement “#ifdef CONFIG_HAS_IOMEM” so that the corresponding scope for conditional compilation includes also comments for this function implementation.

---
 drivers/base/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +1 -0
index 4d1729853d1a..a5f40974a6ef 100644
@@ -78,6 +78,7 @@ struct resource *platform_get_resource(struct platform_device *dev,
        return NULL;
 }
 EXPORT_SYMBOL_GPL(platform_get_resource);
+#ifdef CONFIG_HAS_IOMEM
 
Quoted 15 lines
Quoted 11 lines
drivers/base/platform.c +0 -2
 /**
  * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
@@ -87,7 +88,6 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
  *        resource management
  * @index: resource index
  */
-#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
                                             unsigned int index)
 {
--
Quoted 2 lines

2.22.0

And what is the purpose of that?

Quoted 7 lines

I can imagine that this could improve readability a little bit. Maybe if one uses same fancy ide/editor that can fold code blocks like functions and conditionals, this patch could make the code prettier.

The patch seems pretty trivial and doesn't change any actual code, so I don't see hard resons for rejecting it.

In its current form it makes the code even less readable. The #ifdef should actually be one line lower and touch the comment instead of the EXPORT_SYMBOL() related to a different function.

Bart

#12 lore raw

Re: drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

Quoted 1 line

In its current form it makes the code even less readable.

This can be your development opinion.

Quoted 1 line

The #ifdef should actually be one line lower

I suggested that the conditional compilation can contain also a blank line together with a comment block.

Quoted 1 line

and touch the comment instead of the EXPORT_SYMBOL() related to a different function.

I find that this macro call was kept unchanged.

Regards,
Markus

#13 lore raw

Re: [PATCH] drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

In reply to Bartosz Golaszewski
Quoted 7 lines · Bartosz Golaszewski
Quoted 3 lines

The patch seems pretty trivial and doesn't change any actual code, so I don't see hard resons for rejecting it.

In its current form it makes the code even less readable. The #ifdef should actually be one line lower and touch the comment instead of the EXPORT_SYMBOL() related to a different function.

Okay, that missing newline should be fixed (as well as the extra one after the #ifdef). Besides that, I don't see any further problems.

--mtx

Signature · 3 lines
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
[email protected] -- +49-151-27565287
#14 lore raw

Re: [PATCH] drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

pon., 24 cze 2019 o 20:22 Enrico Weigelt, metux IT consult <[email protected]> napisaÅ‚(a):

Quoted 7 lines · Bartosz Golaszewski
Quoted 5 lines
Quoted 4 lines

The patch seems pretty trivial and doesn't change any actual code, so I don't see hard resons for rejecting it.

Quoted 7 lines
Quoted 3 lines

In its current form it makes the code even less readable. The #ifdef should actually be one line lower and touch the comment instead of the EXPORT_SYMBOL() related to a different function.

Okay, that missing newline should be fixed (as well as the extra one after the #ifdef). Besides that, I don't see any further problems.

Are we sure this even changes something? Does kernel documentation get generated according to current config options? I really think this patch just pollutes the history for now apparent reason.

Greg, could you give your opinion on this?

Bart

#15 lore raw

Re: [PATCH] drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

Quoted 17 lines · Bartosz Golaszewski

pon., 24 cze 2019 o 20:22 Enrico Weigelt, metux IT consult <[email protected]> napisaÅ‚(a):

Quoted 7 lines · Bartosz Golaszewski
Quoted 5 lines
Quoted 4 lines

The patch seems pretty trivial and doesn't change any actual code, so I don't see hard resons for rejecting it.

Quoted 7 lines
Quoted 3 lines

In its current form it makes the code even less readable. The #ifdef should actually be one line lower and touch the comment instead of the EXPORT_SYMBOL() related to a different function.

Okay, that missing newline should be fixed (as well as the extra one after the #ifdef). Besides that, I don't see any further problems.

Quoted 5 lines

Are we sure this even changes something? Does kernel documentation get generated according to current config options? I really think this patch just pollutes the history for now apparent reason.

Greg, could you give your opinion on this?

Why are you all arguing with a all-but-instinguishable-from-a-bot persona about a patch that I will never apply?

greg k-h

#16 lore raw

Re: [PATCH] drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

wt., 25 cze 2019 o 09:30 Greg Kroah-Hartman
<[email protected]> napisał(a):

Quoted 23 lines · Bartosz Golaszewski
Quoted 21 lines

pon., 24 cze 2019 o 20:22 Enrico Weigelt, metux IT consult <[email protected]> napisał(a):

Quoted 7 lines · Bartosz Golaszewski
Quoted 5 lines
Quoted 4 lines

The patch seems pretty trivial and doesn't change any actual code, so I don't see hard resons for rejecting it.

Quoted 7 lines
Quoted 3 lines

In its current form it makes the code even less readable. The #ifdef should actually be one line lower and touch the comment instead of the EXPORT_SYMBOL() related to a different function.

Okay, that missing newline should be fixed (as well as the extra one after the #ifdef). Besides that, I don't see any further problems.

Are we sure this even changes something? Does kernel documentation get generated according to current config options? I really think this patch just pollutes the history for now apparent reason.

Quoted 6 lines
Quoted 1 line

Greg, could you give your opinion on this?

Why are you all arguing with a all-but-instinguishable-from-a-bot persona about a patch that I will never apply?

greg k-h

Oh so it's another troll then? Good to know, ignoring from now on.

Thanks,
Bart

#17 lore raw

Re: drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

Quoted 1 line

Oh so it's another troll then?

I am just a contributor.

Quoted 1 line

Good to know, ignoring from now on.

The opinions can vary for my contributions as usual.

I hope that the software development attention can evolve in more positive ways again.

Regards,
Markus

#18 lore raw

Re: drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

In reply to Greg Kroah-Hartman
Quoted 1 line

Why are you all arguing with a all-but-instinguishable-from-a-bot persona

I am curious if another meeting at a Linux conference can adjust this view.

Quoted 1 line

about a patch that I will never apply?

I hope that you can get into a more constructive mood a bit later for the reconsideration of the position for the preprocessor statement “#ifdef CONFIG_HAS_IOMEM” before a function implementation.

Regards,
Markus

#19 lore raw

Re: [PATCH] drivers: Adjust scope for CONFIG_HAS_IOMEM before devm_platform_ioremap_resource()

In reply to Bartosz Golaszewski
Quoted 7 lines
Quoted 7 lines

+++ b/drivers/base/platform.c

drivers/base/platform.c +1 -0
@@ -78,6 +78,7 @@ struct resource *platform_get_resource(struct platform_device *dev,
        return NULL;
 }
 EXPORT_SYMBOL_GPL(platform_get_resource);
+#ifdef CONFIG_HAS_IOMEM
 
Quoted 10 lines

drivers/base/platform.c EXPORT_SYMBOL_GPL(platform_get_resource); · line 93

Quoted 10 lines
drivers/base/platform.c +0 -1
 /**
  * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
@@ -87,7 +88,6 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
  *        resource management
  * @index: resource index
  */
-#ifdef CONFIG_HAS_IOMEM
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
                                             unsigned int index)
 {

…

Quoted 1 line

And what is the purpose of that?

I recommend to let the availability of additional documentation for this function depend also on the mentioned preprocessor symbol

Regards,
Markus