diff mbox series

[11/28] ata: add CONFIG_SATA_HOST=n version of ata_ncq_enabled()

Message ID 20200128133343.29905-12-b.zolnierkie@samsung.com
State Not Applicable
Delegated to: David Miller
Headers show
Series ata: optimize core code size on PATA only setups | expand

Commit Message

Bartlomiej Zolnierkiewicz Jan. 28, 2020, 1:33 p.m. UTC
When CONFIG_SATA_HOST=n there are no NCQ capable host drivers
built so it is safe to hardwire ata_ncq_enabled() to always
return zero.

Code size savings on m68k arch using atari_defconfig:

   text    data     bss     dec     hex filename
before:
  37820     572      40   38432    9620 drivers/ata/libata-core.o
  21040     105    4096   25241    6299 drivers/ata/libata-scsi.o
  17405      18       0   17423    440f drivers/ata/libata-eh.o
after:
  37582     572      40   38194    9532 drivers/ata/libata-core.o
  20702     105    4096   24903    6147 drivers/ata/libata-scsi.o
  17353      18       0   17371    43db drivers/ata/libata-eh.o

Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
---
 include/linux/libata.h | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Christoph Hellwig Jan. 29, 2020, 5:24 p.m. UTC | #1
>  static inline int ata_ncq_enabled(struct ata_device *dev)
>  {
> +#ifdef CONFIG_SATA_HOST
>  	return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
>  			      ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
> +#else
> +	return 0;
> +#endif

I think this is a prime candidate for IS_ENABLED:

	if (!IS_ENABLED(CONFIG_SATA_HOST))
		return 0;
 	return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
  			      ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
Bartlomiej Zolnierkiewicz Feb. 7, 2020, 2:21 p.m. UTC | #2
On 1/29/20 6:24 PM, Christoph Hellwig wrote:
>>  static inline int ata_ncq_enabled(struct ata_device *dev)
>>  {
>> +#ifdef CONFIG_SATA_HOST
>>  	return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
>>  			      ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
>> +#else
>> +	return 0;
>> +#endif
> 
> I think this is a prime candidate for IS_ENABLED:
> 
> 	if (!IS_ENABLED(CONFIG_SATA_HOST))
> 		return 0;
>  	return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
>   			      ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
> 

Fully agreed, fixed in v2.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
diff mbox series

Patch

diff --git a/include/linux/libata.h b/include/linux/libata.h
index 79953c6d769c..5b7bed18f56e 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1633,8 +1633,12 @@  extern struct ata_device *ata_dev_next(struct ata_device *dev,
  */
 static inline int ata_ncq_enabled(struct ata_device *dev)
 {
+#ifdef CONFIG_SATA_HOST
 	return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
 			      ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
+#else
+	return 0;
+#endif
 }
 
 static inline bool ata_fpdma_dsm_supported(struct ata_device *dev)