[PATCH] drivers/base: Mark (of|platform)_device_id data as constant
Uwe Kleine-König
u.kleine-koenig at pengutronix.de
Tue Apr 14 13:00:47 PDT 2015
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 at 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
More information about the barebox
mailing list