diff mbox series

scsi: ufs-qcom: Make structure ufs_hba_qcom_vops constant

Message ID 20190819075557.1547-1-nishkadg.linux@gmail.com (mailing list archive)
State Mainlined
Commit d508e31df10ff1f309fddb88d7e830315bdbb93a
Headers show
Series scsi: ufs-qcom: Make structure ufs_hba_qcom_vops constant | expand

Commit Message

Nishka Dasgupta Aug. 19, 2019, 7:55 a.m. UTC
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.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/scsi/ufs/ufs-qcom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Vivek Gautam Aug. 19, 2019, 8:25 a.m. UTC | #1
On Mon, Aug 19, 2019 at 1:26 PM Nishka Dasgupta
<nishkadg.linux@gmail.com> wrote:
>
> 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.
>
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
>  drivers/scsi/ufs/ufs-qcom.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index ee4b1da1e223..4473f339cbc0 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -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,
> --
> 2.19.1
>
Reviewed-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Martin K. Petersen Aug. 20, 2019, 2:18 a.m. UTC | #2
Nishka,

> 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.
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index ee4b1da1e223..4473f339cbc0 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -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,