Skip to contentSkip to conversation

fsi: Constify fsi_device_ids

PATCH In review Rikard Falkeborn 2 participants 5 messages Aug 5, 2020 FSI

lore
Share & tools
lore
#0 lore raw

cover fsi: Constify fsi_device_ids

fsi_device_id is never modified (and it's a const pointer in the fsi_driver struct), so make the static variables const to allow the compiler to put them in read-only memory.

Rikard Falkeborn (3):
fsi: master: Constify hub_master_ids
fsi: sbefifo: Constify sbefifo_ids
fsi: scom: Constify scom_ids

 drivers/fsi/fsi-master-hub.c | 2 +-
 drivers/fsi/fsi-sbefifo.c    | 2 +-
 drivers/fsi/fsi-scom.c       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/3 fsi: master: Constify hub_master_ids

The only usage of hub_master_ids is to assign its address to the id_table field in the fsi_driver struct, which is a const pointer, so make it const to allow the compiler to put it in read-only memory.

---
 drivers/fsi/fsi-master-hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fsi/fsi-master-hub.c +1 -1
index 3caa2da7838c..01f0a796111e 100644
@@ -276,7 +276,7 @@ static int hub_master_remove(struct device *dev)
 	return 0;
 }
 
-static struct fsi_device_id hub_master_ids[] = {
+static const struct fsi_device_id hub_master_ids[] = {
 	{
 		.engine_type = FSI_ENGID_HUB_MASTER,
 		.version = FSI_VERSION_ANY,
Signature · 1 line
2.28.0
#2 lore raw

PATCH 2/3 fsi: sbefifo: Constify sbefifo_ids

In reply to Rikard Falkeborn

The only usage of sbefifo_ids is to assign its address to the id_table field in the fsi_driver struct, which is a const pointer, so make it const to allow the compiler to put it in read-only memory

---
 drivers/fsi/fsi-sbefifo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fsi/fsi-sbefifo.c +1 -1
index c8ccc99e214f..84cb965bfed5 100644
@@ -1030,7 +1030,7 @@ static int sbefifo_remove(struct device *dev)
 	return 0;
 }
 
-static struct fsi_device_id sbefifo_ids[] = {
+static const struct fsi_device_id sbefifo_ids[] = {
 	{
 		.engine_type = FSI_ENGID_SBE,
 		.version = FSI_VERSION_ANY,
Signature · 1 line
2.28.0
#3 lore raw

PATCH 3/3 fsi: scom: Constify scom_ids

In reply to Rikard Falkeborn

The only usage of scom_ids is to assign its address to the id_table field in the fsi_driver struct, which is a const pointer, so make it const to allow the compiler to put it in read-only memory

---
 drivers/fsi/fsi-scom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fsi/fsi-scom.c +1 -1
index 004dc03ccf09..b45bfab7b7f5 100644
@@ -627,7 +627,7 @@ static int scom_remove(struct device *dev)
 	return 0;
 }
 
-static struct fsi_device_id scom_ids[] = {
+static const struct fsi_device_id scom_ids[] = {
 	{
 		.engine_type = FSI_ENGID_SCOM,
 		.version = FSI_VERSION_ANY,
Signature · 1 line
2.28.0
#4 lore raw
In reply to Rikard Falkeborn
Quoted 4 lines · Rikard Falkeborn

fsi_device_id is never modified (and it's a const pointer in the fsi_driver struct), so make the static variables const to allow the compiler to put them in read-only memory.

Thanks, I have applied these to the fsi next tree.

Cheers,

Joel

Quoted 14 lines

Rikard Falkeborn (3):
fsi: master: Constify hub_master_ids
fsi: sbefifo: Constify sbefifo_ids
fsi: scom: Constify scom_ids

 drivers/fsi/fsi-master-hub.c | 2 +-
 drivers/fsi/fsi-sbefifo.c    | 2 +-
 drivers/fsi/fsi-scom.c       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

--
2.28.0