diff mbox series

[v2,19/22] ata: sata_fsl: fix scsi host initialization

Message ID 20220104105843.1730172-20-damien.lemoal@opensource.wdc.com
State New
Headers show
Series Improve compile test coverage | expand

Commit Message

Damien Le Moal Jan. 4, 2022, 10:58 a.m. UTC
When compiling with W=1, the sata_fsl driver compilation throws the
warning:

drivers/ata/sata_fsl.c:1385:22: error: initialized field overwritten
[-Werror=override-init]
 1385 |         .can_queue = SATA_FSL_QUEUE_DEPTH,

This is due to the driver scsi host template initialization overwriting
the can_queue field that is already set using the ATA_NCQ_SHT()
initializer macro, resulting in the same field being initialized twice
in the host template declaration.

To remove this warning, introduce the ATA_SUBBASE_SHT_QD() and
ATA_NCQ_SHT_QD() initialization macros to allow specifying a queue depth
different from the default ATA_DEF_QUEUE using an additional argument to
the macro.

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
 drivers/ata/sata_fsl.c |  3 +--
 include/linux/libata.h | 11 +++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

Comments

Hannes Reinecke Jan. 4, 2022, 11:41 a.m. UTC | #1
On 1/4/22 11:58 AM, Damien Le Moal wrote:
> When compiling with W=1, the sata_fsl driver compilation throws the
> warning:
> 
> drivers/ata/sata_fsl.c:1385:22: error: initialized field overwritten
> [-Werror=override-init]
>  1385 |         .can_queue = SATA_FSL_QUEUE_DEPTH,
> 
> This is due to the driver scsi host template initialization overwriting
> the can_queue field that is already set using the ATA_NCQ_SHT()
> initializer macro, resulting in the same field being initialized twice
> in the host template declaration.
> 
> To remove this warning, introduce the ATA_SUBBASE_SHT_QD() and
> ATA_NCQ_SHT_QD() initialization macros to allow specifying a queue depth
> different from the default ATA_DEF_QUEUE using an additional argument to
> the macro.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> ---
>  drivers/ata/sata_fsl.c |  3 +--
>  include/linux/libata.h | 11 +++++++++++
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
> index 142e65d5efc7..101d4dd79f62 100644
> --- a/drivers/ata/sata_fsl.c
> +++ b/drivers/ata/sata_fsl.c
> @@ -1380,8 +1380,7 @@ static void sata_fsl_host_stop(struct ata_host *host)
>   * scsi mid-layer and libata interface structures
>   */
>  static struct scsi_host_template sata_fsl_sht = {
> -	ATA_NCQ_SHT("sata_fsl"),
> -	.can_queue = SATA_FSL_QUEUE_DEPTH,
> +	ATA_NCQ_SHT_QD("sata_fsl", SATA_FSL_QUEUE_DEPTH),
>  	.sg_tablesize = SATA_FSL_MAX_PRD_USABLE,
>  	.dma_boundary = ATA_DMA_BOUNDARY,
>  };
> diff --git a/include/linux/libata.h b/include/linux/libata.h
> index ab2d404cde08..cafe360ab3cd 100644
> --- a/include/linux/libata.h
> +++ b/include/linux/libata.h
> @@ -1385,6 +1385,12 @@ extern const struct attribute_group *ata_common_sdev_groups[];
>  	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,		\
>  	.slave_configure	= ata_scsi_slave_config
>  
> +#define ATA_SUBBASE_SHT_QD(drv_name, drv_qd)			\
> +	__ATA_BASE_SHT(drv_name),				\
> +	.can_queue		= drv_qd,			\
> +	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,		\
> +	.slave_configure	= ata_scsi_slave_config
> +
>  #define ATA_BASE_SHT(drv_name)					\
>  	ATA_SUBBASE_SHT(drv_name),				\
>  	.sdev_groups		= ata_common_sdev_groups
> @@ -1396,6 +1402,11 @@ extern const struct attribute_group *ata_ncq_sdev_groups[];
>  	ATA_SUBBASE_SHT(drv_name),				\
>  	.sdev_groups		= ata_ncq_sdev_groups,		\
>  	.change_queue_depth	= ata_scsi_change_queue_depth
> +
> +#define ATA_NCQ_SHT_QD(drv_name, drv_qd)			\
> +	ATA_SUBBASE_SHT_QD(drv_name, drv_qd),			\
> +	.sdev_groups		= ata_ncq_sdev_groups,		\
> +	.change_queue_depth	= ata_scsi_change_queue_depth
>  #endif
>  
>  /*
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 142e65d5efc7..101d4dd79f62 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -1380,8 +1380,7 @@  static void sata_fsl_host_stop(struct ata_host *host)
  * scsi mid-layer and libata interface structures
  */
 static struct scsi_host_template sata_fsl_sht = {
-	ATA_NCQ_SHT("sata_fsl"),
-	.can_queue = SATA_FSL_QUEUE_DEPTH,
+	ATA_NCQ_SHT_QD("sata_fsl", SATA_FSL_QUEUE_DEPTH),
 	.sg_tablesize = SATA_FSL_MAX_PRD_USABLE,
 	.dma_boundary = ATA_DMA_BOUNDARY,
 };
diff --git a/include/linux/libata.h b/include/linux/libata.h
index ab2d404cde08..cafe360ab3cd 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1385,6 +1385,12 @@  extern const struct attribute_group *ata_common_sdev_groups[];
 	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,		\
 	.slave_configure	= ata_scsi_slave_config
 
+#define ATA_SUBBASE_SHT_QD(drv_name, drv_qd)			\
+	__ATA_BASE_SHT(drv_name),				\
+	.can_queue		= drv_qd,			\
+	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,		\
+	.slave_configure	= ata_scsi_slave_config
+
 #define ATA_BASE_SHT(drv_name)					\
 	ATA_SUBBASE_SHT(drv_name),				\
 	.sdev_groups		= ata_common_sdev_groups
@@ -1396,6 +1402,11 @@  extern const struct attribute_group *ata_ncq_sdev_groups[];
 	ATA_SUBBASE_SHT(drv_name),				\
 	.sdev_groups		= ata_ncq_sdev_groups,		\
 	.change_queue_depth	= ata_scsi_change_queue_depth
+
+#define ATA_NCQ_SHT_QD(drv_name, drv_qd)			\
+	ATA_SUBBASE_SHT_QD(drv_name, drv_qd),			\
+	.sdev_groups		= ata_ncq_sdev_groups,		\
+	.change_queue_depth	= ata_scsi_change_queue_depth
 #endif
 
 /*