Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] scsi: ufs-qcom: Make structure ufs_hba_qcom_vops constant
@ 2019-08-19  7:55 Nishka Dasgupta
  2019-08-19  8:25 ` Vivek Gautam
  2019-08-20  2:18 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Nishka Dasgupta @ 2019-08-19  7:55 UTC (permalink / raw)
  To: agross, alim.akhtar, avri.altman, pedrom.sousa, jejb,
	martin.peterson, linux-scsi, linux-arm-msm
  Cc: 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.

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: ufs-qcom: Make structure ufs_hba_qcom_vops constant
  2019-08-19  7:55 [PATCH] scsi: ufs-qcom: Make structure ufs_hba_qcom_vops constant Nishka Dasgupta
@ 2019-08-19  8:25 ` Vivek Gautam
  2019-08-20  2:18 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Vivek Gautam @ 2019-08-19  8:25 UTC (permalink / raw)
  To: Nishka Dasgupta
  Cc: Andy Gross, ALIM AKHTAR, avri.altman, pedrom.sousa, jejb,
	martin.peterson, linux-scsi, linux-arm-msm

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>

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: ufs-qcom: Make structure ufs_hba_qcom_vops constant
  2019-08-19  7:55 [PATCH] scsi: ufs-qcom: Make structure ufs_hba_qcom_vops constant Nishka Dasgupta
  2019-08-19  8:25 ` Vivek Gautam
@ 2019-08-20  2:18 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2019-08-20  2:18 UTC (permalink / raw)
  To: Nishka Dasgupta
  Cc: agross, alim.akhtar, avri.altman, pedrom.sousa, jejb,
	martin.peterson, linux-scsi, linux-arm-msm


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.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19  7:55 [PATCH] scsi: ufs-qcom: Make structure ufs_hba_qcom_vops constant Nishka Dasgupta
2019-08-19  8:25 ` Vivek Gautam
2019-08-20  2:18 ` Martin K. Petersen

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org linux-arm-msm@archiver.kernel.org
	public-inbox-index linux-arm-msm


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/ public-inbox