Skip to contentSkip to conversation

platform: add two helpers for early_platform code

PATCH In review Bartosz Golaszewski 2 participants 5 messages Apr 20, 2018 – Apr 23, 2018

lore
Share & tools
lore
#0 lore raw

cover platform: add two helpers for early_platform code

From: Bartosz Golaszewski <[email protected]>

I'm using the early_platform infrastructure for converting the davinci timer support to a real platform_driver. I noticed that it would be nice to have these two helpers for more code brevity.

Bartosz Golaszewski (2):
platform: provide early_platform_add_device()
platform: provide early_platform_driver_register_probe_all()

 include/linux/platform_device.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/2 platform: provide early_platform_add_device()

From: Bartosz Golaszewski <[email protected]>

Currently we only have early_platform_add_devices() which takes struct platform_device ** as argument, requiring the users to have an intermediate array of platform_device pointers even if we're only adding a single device. Provide a helper for adding a single device at a time.

---
 include/linux/platform_device.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/platform_device.h +5 -0
index 49f634d96118..80942ed0f728 100644
@@ -301,6 +301,11 @@ extern int early_platform_driver_register(struct early_platform_driver *epdrv,
 					  char *buf);
 extern void early_platform_add_devices(struct platform_device **devs, int num);
 
+static inline void early_platform_add_device(struct platform_device *pdev)
+{
+	early_platform_add_devices(&pdev, 1);
+}
+
 static inline int is_early_platform_device(struct platform_device *pdev)
 {
 	return !pdev->dev.driver;
Signature · 1 line
2.17.0
#2 lore raw

Re: [PATCH 1/2] platform: provide early_platform_add_device()

Quoted 9 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Currently we only have early_platform_add_devices() which takes struct platform_device ** as argument, requiring the users to have an intermediate array of platform_device pointers even if we're only adding a single device. Provide a helper for adding a single device at a time.

Feel free to take these with your driver cleanups:

#3 lore raw

PATCH 2/2 platform: provide early_platform_driver_register_probe_all()

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

All users of early_platform_driver_register_all() subsequently call early_platform_driver_probe(). Provide a helper that calls both functions.

---
 include/linux/platform_device.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/linux/platform_device.h +9 -0
index 80942ed0f728..a06b194ba30b 100644
@@ -314,6 +314,15 @@ static inline int is_early_platform_device(struct platform_device *pdev)
 extern void early_platform_driver_register_all(char *class_str);
 extern int early_platform_driver_probe(char *class_str,
 				       int nr_probe, int user_only);
+
+static inline int early_platform_driver_register_probe_all(char *class_str,
+							   int nr_probe,
+							   int user_only)
+{
+	early_platform_driver_register_all(class_str);
+	return early_platform_driver_probe(class_str, nr_probe, user_only);
+}
+
 extern void early_platform_cleanup(void);
 
 #define early_platform_init(class_string, platdrv)		\
Signature · 1 line
2.17.0