mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] drivers/base: Mark (of|platform)_device_id data as constant
@ 2015-04-14 20:00 Uwe Kleine-König
  2015-04-15  5:30 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2015-04-14 20:00 UTC (permalink / raw)
  To: barebox

There should be no reason to ever change the data pointed to by id_table
or of_compatible. So make this offical by adding some 'const's.

In Linux the corresponding pointers are marked as const, too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Build tested on arm/mvebu+am33xx only

 drivers/base/bus.c | 4 ++--
 include/driver.h   | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index c41e0b04381a..1264e40250dd 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -58,7 +58,7 @@ int device_match(struct device_d *dev, struct driver_d *drv)
 		return 0;
 
 	if (drv->id_table) {
-		struct platform_device_id *id = drv->id_table;
+		const struct platform_device_id *id = drv->id_table;
 
 		while (id->name) {
 			if (!strcmp(id->name, dev->name)) {
@@ -74,7 +74,7 @@ int device_match(struct device_d *dev, struct driver_d *drv)
 
 int device_match_of_modalias(struct device_d *dev, struct driver_d *drv)
 {
-	struct platform_device_id *id = drv->id_table;
+	const struct platform_device_id *id = drv->id_table;
 	const char *of_modalias = NULL, *p;
 	int cplen;
 	const char *compat;
diff --git a/include/driver.h b/include/driver.h
index 0ee3b4554f98..174571731579 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -77,7 +77,7 @@ struct device_d {
 
 	struct list_head cdevs;
 
-	struct platform_device_id *id_entry;
+	const struct platform_device_id *id_entry;
 	struct device_node *device_node;
 
 	const struct of_device_id *of_id_entry;
@@ -107,8 +107,8 @@ struct driver_d {
 
 	struct bus_type *bus;
 
-	struct platform_device_id *id_table;
-	struct of_device_id *of_compatible;
+	const struct platform_device_id *id_table;
+	const struct of_device_id *of_compatible;
 };
 
 /*@}*/	/* do not delete, doxygen relevant */
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-15  5:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-14 20:00 [PATCH] drivers/base: Mark (of|platform)_device_id data as constant Uwe Kleine-König
2015-04-15  5:30 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox