Skip to contentSkip to conversation

scsi: ufs-qcom: Make structure ufs_hba_qcom_vops constant

PATCH Applied Nishka Dasgupta 3 participants 3 messages Aug 19, 2019 – Aug 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ufs-qcom: Make structure ufs_hba_qcom_vops constant

Static structure ufs_hba_qcom_vops, of type ufs_hba_variant_ops, is used only once, when it is passed as the second argument to function ufshcd_pltfrm_init(). In the definition of ufshcd_pltfrm_init(), its second parameter (corresponding to ufs_hba_qcom_vops) is declared as constant. Hence declare ufs_hba_qcom_vops itself constant as well to protect it from unintended modification.
Issue found with Coccinelle.

---
 drivers/scsi/ufs/ufs-qcom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufs-qcom.c +1 -1
index ee4b1da1e223..4473f339cbc0 100644
@@ -1551,7 +1551,7 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
  * The variant operations configure the necessary controller and PHY
  * handshake during initialization.
  */
-static struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
+static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
 	.name                   = "qcom",
 	.init                   = ufs_qcom_init,
 	.exit                   = ufs_qcom_exit,
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Nishka Dasgupta

Static structure ufs_hba_qcom_vops, of type ufs_hba_variant_ops, is used only once, when it is passed as the second argument to function ufshcd_pltfrm_init(). In the definition of ufshcd_pltfrm_init(), its second parameter (corresponding to ufs_hba_qcom_vops) is declared as constant. Hence declare ufs_hba_qcom_vops itself constant as well to protect it from unintended modification.
Issue found with Coccinelle.

---
 drivers/scsi/ufs/ufs-qcom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufs-qcom.c +1 -2
index ee4b1da1e223..4473f339cbc0 100644
@@ -1551,7 +1551,7 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
  * The variant operations configure the necessary controller and PHY
  * handshake during initialization.
  */
-static struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
+static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
        .name                   = "qcom",
        .init                   = ufs_qcom_init,
        .exit                   = ufs_qcom_exit,
--
Quoted 2 lines

2.19.1

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw
In reply to Nishka Dasgupta

Nishka,

Quoted 7 lines

Static structure ufs_hba_qcom_vops, of type ufs_hba_variant_ops, is used only once, when it is passed as the second argument to function ufshcd_pltfrm_init(). In the definition of ufshcd_pltfrm_init(), its second parameter (corresponding to ufs_hba_qcom_vops) is declared as constant. Hence declare ufs_hba_qcom_vops itself constant as well to protect it from unintended modification.
Issue found with Coccinelle.

Applied to 5.4/scsi-queue, thanks.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering