2010-01-12 08:01:45

by Németh Márton

[permalink] [raw]
Subject: [PATCH] crypto: make Open Firmware device id constant

From: Márton Németh <[email protected]>

The match_table field of the struct of_device_id is constant in <linux/of_platform.h>
so it is worth to make the initialization data also constant.

The semantic match that finds this kind of pattern is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@[email protected]
disable decl_init,const_decl_init;
identifier I1, I2, x;
@@
struct I1 {
...
const struct I2 *x;
...
};
@[email protected]
identifier r.I1, y;
identifier r.x, E;
@@
struct I1 y = {
.x = E,
};
@[email protected]
identifier r.I2;
identifier s.E;
@@
const struct I2 E[] = ... ;
@depends on [email protected]
identifier r.I2;
identifier s.E;
@@
+ const
struct I2 E[] = ...;
// </smpl>

Signed-off-by: Márton Németh <[email protected]>
Cc: Julia Lawall <[email protected]>
Cc: [email protected]
---
diff -u -p a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
--- a/drivers/crypto/talitos.c 2009-12-03 04:51:21.000000000 +0100
+++ b/drivers/crypto/talitos.c 2010-01-08 14:16:24.000000000 +0100
@@ -1958,7 +1958,7 @@ err_out:
return err;
}

-static struct of_device_id talitos_match[] = {
+static const struct of_device_id talitos_match[] = {
{
.compatible = "fsl,sec2.0",
},
diff -u -p a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c
--- a/drivers/crypto/amcc/crypto4xx_core.c 2009-12-03 04:51:21.000000000 +0100
+++ b/drivers/crypto/amcc/crypto4xx_core.c 2010-01-08 14:16:45.000000000 +0100
@@ -1274,7 +1274,7 @@ static int __exit crypto4xx_remove(struc
return 0;
}

-static struct of_device_id crypto4xx_match[] = {
+static const struct of_device_id crypto4xx_match[] = {
{ .compatible = "amcc,ppc4xx-crypto",},
{ },
};
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)


2010-01-17 10:54:24

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: make Open Firmware device id constant

On Tue, Jan 12, 2010 at 09:01:45AM +0100, N?meth M?rton wrote:
> From: M?rton N?meth <[email protected]>
>
> The match_table field of the struct of_device_id is constant in <linux/of_platform.h>
> so it is worth to make the initialization data also constant.

Applied to cryptodev. Thanks.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt