ata: move sata_scr_*() to libata-sata.c
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Thu, 26 Mar 2020 15:58:12 +0000 (16:58 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 26 Mar 2020 16:28:19 +0000 (10:28 -0600)
* move sata_scr_*() to libata-sata.c

* add static inlines for CONFIG_SATA_HOST=n case

Code size savings on m68k arch using (modified) atari_defconfig:

   text    data     bss     dec     hex filename
before:
  35642     572      40   36254    8d9e drivers/ata/libata-core.o
  16607      18       0   16625    40f1 drivers/ata/libata-eh.o
after:
  32846     572      40   33458    82b2 drivers/ata/libata-core.o
  16243      18       0   16261    3f85 drivers/ata/libata-eh.o

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/ata/libata-core.c
drivers/ata/libata-sata.c
include/linux/libata.h

index b4a952dce7ab0891e4a51442628fe6ad43988a78..ba1e5c4d3c099915ff2e9f6fc2240609dcc4f5a2 100644 (file)
@@ -5215,115 +5215,6 @@ err:
        ata_qc_complete(qc);
 }
 
-/**
- *     sata_scr_valid - test whether SCRs are accessible
- *     @link: ATA link to test SCR accessibility for
- *
- *     Test whether SCRs are accessible for @link.
- *
- *     LOCKING:
- *     None.
- *
- *     RETURNS:
- *     1 if SCRs are accessible, 0 otherwise.
- */
-int sata_scr_valid(struct ata_link *link)
-{
-       struct ata_port *ap = link->ap;
-
-       return (ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read;
-}
-EXPORT_SYMBOL_GPL(sata_scr_valid);
-
-/**
- *     sata_scr_read - read SCR register of the specified port
- *     @link: ATA link to read SCR for
- *     @reg: SCR to read
- *     @val: Place to store read value
- *
- *     Read SCR register @reg of @link into *@val.  This function is
- *     guaranteed to succeed if @link is ap->link, the cable type of
- *     the port is SATA and the port implements ->scr_read.
- *
- *     LOCKING:
- *     None if @link is ap->link.  Kernel thread context otherwise.
- *
- *     RETURNS:
- *     0 on success, negative errno on failure.
- */
-int sata_scr_read(struct ata_link *link, int reg, u32 *val)
-{
-       if (ata_is_host_link(link)) {
-               if (sata_scr_valid(link))
-                       return link->ap->ops->scr_read(link, reg, val);
-               return -EOPNOTSUPP;
-       }
-
-       return sata_pmp_scr_read(link, reg, val);
-}
-EXPORT_SYMBOL_GPL(sata_scr_read);
-
-/**
- *     sata_scr_write - write SCR register of the specified port
- *     @link: ATA link to write SCR for
- *     @reg: SCR to write
- *     @val: value to write
- *
- *     Write @val to SCR register @reg of @link.  This function is
- *     guaranteed to succeed if @link is ap->link, the cable type of
- *     the port is SATA and the port implements ->scr_read.
- *
- *     LOCKING:
- *     None if @link is ap->link.  Kernel thread context otherwise.
- *
- *     RETURNS:
- *     0 on success, negative errno on failure.
- */
-int sata_scr_write(struct ata_link *link, int reg, u32 val)
-{
-       if (ata_is_host_link(link)) {
-               if (sata_scr_valid(link))
-                       return link->ap->ops->scr_write(link, reg, val);
-               return -EOPNOTSUPP;
-       }
-
-       return sata_pmp_scr_write(link, reg, val);
-}
-EXPORT_SYMBOL_GPL(sata_scr_write);
-
-/**
- *     sata_scr_write_flush - write SCR register of the specified port and flush
- *     @link: ATA link to write SCR for
- *     @reg: SCR to write
- *     @val: value to write
- *
- *     This function is identical to sata_scr_write() except that this
- *     function performs flush after writing to the register.
- *
- *     LOCKING:
- *     None if @link is ap->link.  Kernel thread context otherwise.
- *
- *     RETURNS:
- *     0 on success, negative errno on failure.
- */
-int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
-{
-       if (ata_is_host_link(link)) {
-               int rc;
-
-               if (sata_scr_valid(link)) {
-                       rc = link->ap->ops->scr_write(link, reg, val);
-                       if (rc == 0)
-                               rc = link->ap->ops->scr_read(link, reg, &val);
-                       return rc;
-               }
-               return -EOPNOTSUPP;
-       }
-
-       return sata_pmp_scr_write(link, reg, val);
-}
-EXPORT_SYMBOL_GPL(sata_scr_write_flush);
-
 /**
  *     ata_phys_link_online - test whether the given link is online
  *     @link: ATA link to test
index 04f1ecaf414c1ee495b6848ee89b28a8a9a56bd5..1ef4c19864ac197c50b4aa1ab60e8e81720eb7f4 100644 (file)
 
 #include "libata.h"
 
+/**
+ *     sata_scr_valid - test whether SCRs are accessible
+ *     @link: ATA link to test SCR accessibility for
+ *
+ *     Test whether SCRs are accessible for @link.
+ *
+ *     LOCKING:
+ *     None.
+ *
+ *     RETURNS:
+ *     1 if SCRs are accessible, 0 otherwise.
+ */
+int sata_scr_valid(struct ata_link *link)
+{
+       struct ata_port *ap = link->ap;
+
+       return (ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read;
+}
+EXPORT_SYMBOL_GPL(sata_scr_valid);
+
+/**
+ *     sata_scr_read - read SCR register of the specified port
+ *     @link: ATA link to read SCR for
+ *     @reg: SCR to read
+ *     @val: Place to store read value
+ *
+ *     Read SCR register @reg of @link into *@val.  This function is
+ *     guaranteed to succeed if @link is ap->link, the cable type of
+ *     the port is SATA and the port implements ->scr_read.
+ *
+ *     LOCKING:
+ *     None if @link is ap->link.  Kernel thread context otherwise.
+ *
+ *     RETURNS:
+ *     0 on success, negative errno on failure.
+ */
+int sata_scr_read(struct ata_link *link, int reg, u32 *val)
+{
+       if (ata_is_host_link(link)) {
+               if (sata_scr_valid(link))
+                       return link->ap->ops->scr_read(link, reg, val);
+               return -EOPNOTSUPP;
+       }
+
+       return sata_pmp_scr_read(link, reg, val);
+}
+EXPORT_SYMBOL_GPL(sata_scr_read);
+
+/**
+ *     sata_scr_write - write SCR register of the specified port
+ *     @link: ATA link to write SCR for
+ *     @reg: SCR to write
+ *     @val: value to write
+ *
+ *     Write @val to SCR register @reg of @link.  This function is
+ *     guaranteed to succeed if @link is ap->link, the cable type of
+ *     the port is SATA and the port implements ->scr_read.
+ *
+ *     LOCKING:
+ *     None if @link is ap->link.  Kernel thread context otherwise.
+ *
+ *     RETURNS:
+ *     0 on success, negative errno on failure.
+ */
+int sata_scr_write(struct ata_link *link, int reg, u32 val)
+{
+       if (ata_is_host_link(link)) {
+               if (sata_scr_valid(link))
+                       return link->ap->ops->scr_write(link, reg, val);
+               return -EOPNOTSUPP;
+       }
+
+       return sata_pmp_scr_write(link, reg, val);
+}
+EXPORT_SYMBOL_GPL(sata_scr_write);
+
+/**
+ *     sata_scr_write_flush - write SCR register of the specified port and flush
+ *     @link: ATA link to write SCR for
+ *     @reg: SCR to write
+ *     @val: value to write
+ *
+ *     This function is identical to sata_scr_write() except that this
+ *     function performs flush after writing to the register.
+ *
+ *     LOCKING:
+ *     None if @link is ap->link.  Kernel thread context otherwise.
+ *
+ *     RETURNS:
+ *     0 on success, negative errno on failure.
+ */
+int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
+{
+       if (ata_is_host_link(link)) {
+               int rc;
+
+               if (sata_scr_valid(link)) {
+                       rc = link->ap->ops->scr_write(link, reg, val);
+                       if (rc == 0)
+                               rc = link->ap->ops->scr_read(link, reg, &val);
+                       return rc;
+               }
+               return -EOPNOTSUPP;
+       }
+
+       return sata_pmp_scr_write(link, reg, val);
+}
+EXPORT_SYMBOL_GPL(sata_scr_write_flush);
+
 /**
  *     ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
  *     @tf: Taskfile to convert
index b419d7412f712892676b9244c0a28d2193de5101..86703ce5a33e0d2ccc5d597096433addf26dbb36 100644 (file)
@@ -1125,10 +1125,6 @@ extern void ata_sas_tport_delete(struct ata_port *ap);
 extern void ata_sas_port_stop(struct ata_port *ap);
 extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *);
 extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap);
-extern int sata_scr_valid(struct ata_link *link);
-extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
-extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
-extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val);
 extern bool ata_link_online(struct ata_link *link);
 extern bool ata_link_offline(struct ata_link *link);
 #ifdef CONFIG_PM
@@ -1193,6 +1189,26 @@ extern void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *
 /*
  * SATA specific code - drivers/ata/libata-sata.c
  */
+#ifdef CONFIG_SATA_HOST
+extern int sata_scr_valid(struct ata_link *link);
+extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
+extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
+extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val);
+#else
+static inline int sata_scr_valid(struct ata_link *link) { return 0; }
+static inline int sata_scr_read(struct ata_link *link, int reg, u32 *val)
+{
+       return -EOPNOTSUPP;
+}
+static inline int sata_scr_write(struct ata_link *link, int reg, u32 val)
+{
+       return -EOPNOTSUPP;
+}
+static inline int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
+{
+       return -EOPNOTSUPP;
+}
+#endif
 extern int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
                             bool spm_wakeup);
 extern int ata_slave_link_init(struct ata_port *ap);