mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] drivers/base: Mark (of|platform)_device_id data as constant
Date: Tue, 14 Apr 2015 22:00:47 +0200	[thread overview]
Message-ID: <1429041647-2020-1-git-send-email-u.kleine-koenig@pengutronix.de> (raw)

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

             reply	other threads:[~2015-04-14 20:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-14 20:00 Uwe Kleine-König [this message]
2015-04-15  5:30 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429041647-2020-1-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox