Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9a79dfe authored by Joe Perches's avatar Joe Perches Committed by Jeff Garzik
Browse files

ata: Convert ata_<foo>_printk(KERN_<LEVEL> to ata_<foo>_<level>



Saves text by removing nearly duplicated text format strings by
creating ata_<foo>_printk functions and printf extension %pV.

ata defconfig size shrinks ~5% (~8KB), allyesconfig ~2.5% (~13KB)

Format string duplication comes from:

 #define ata_link_printk(link, lv, fmt, args...) do { \
       if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link)    \
               printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id,   \
                      (link)->pmp , ##args); \
       else \
               printk("%sata%u: "fmt, lv, (link)->ap->print_id , ##args); \
       } while(0)

Coalesce long formats.

$ size drivers/ata/built-in.*
   text	   data	    bss	    dec	    hex	filename
 544969	  73893	 116584	 735446	  b38d6	drivers/ata/built-in.allyesconfig.ata.o
 558429	  73893	 117864	 750186	  b726a	drivers/ata/built-in.allyesconfig.dev_level.o
 141328	  14689	   4220	 160237	  271ed	drivers/ata/built-in.defconfig.ata.o
 149567	  14689	   4220	 168476	  2921c	drivers/ata/built-in.defconfig.dev_level.o

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent a44fec1f
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -540,9 +540,8 @@ static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
	if (rc == -EIO) {
	if (rc == -EIO) {
		irq_sts = readl(port_mmio + PORT_IRQ_STAT);
		irq_sts = readl(port_mmio + PORT_IRQ_STAT);
		if (irq_sts & PORT_IRQ_BAD_PMP) {
		if (irq_sts & PORT_IRQ_BAD_PMP) {
			ata_link_printk(link, KERN_WARNING,
			ata_link_warn(link,
					"applying SB600 PMP SRST workaround "
				      "applying SB600 PMP SRST workaround and retrying\n");
					"and retrying\n");
			rc = ahci_do_softreset(link, class, 0, deadline,
			rc = ahci_do_softreset(link, class, 0, deadline,
					       ahci_check_ready);
					       ahci_check_ready);
		}
		}
+2 −3
Original line number Original line Diff line number Diff line
@@ -81,14 +81,13 @@ static int generic_set_mode(struct ata_link *link, struct ata_device **unused)
				xfer_mask |= ata_xfer_mode2mask(XFER_MW_DMA_0);
				xfer_mask |= ata_xfer_mode2mask(XFER_MW_DMA_0);
			}
			}


			ata_dev_printk(dev, KERN_INFO, "configured for %s\n",
			ata_dev_info(dev, "configured for %s\n", name);
				       name);


			dev->xfer_mode = ata_xfer_mask2mode(xfer_mask);
			dev->xfer_mode = ata_xfer_mask2mode(xfer_mask);
			dev->xfer_shift = ata_xfer_mode2shift(dev->xfer_mode);
			dev->xfer_shift = ata_xfer_mode2shift(dev->xfer_mode);
			dev->flags &= ~ATA_DFLAG_PIO;
			dev->flags &= ~ATA_DFLAG_PIO;
		} else {
		} else {
			ata_dev_printk(dev, KERN_INFO, "configured for PIO\n");
			ata_dev_info(dev, "configured for PIO\n");
			dev->xfer_mode = XFER_PIO_0;
			dev->xfer_mode = XFER_PIO_0;
			dev->xfer_shift = ATA_SHIFT_PIO;
			dev->xfer_shift = ATA_SHIFT_PIO;
			dev->flags |= ATA_DFLAG_PIO;
			dev->flags |= ATA_DFLAG_PIO;
+11 −13
Original line number Original line Diff line number Diff line
@@ -286,7 +286,7 @@ static ssize_t ahci_read_em_buffer(struct device *dev,
	/* the count should not be larger than PAGE_SIZE */
	/* the count should not be larger than PAGE_SIZE */
	if (count > PAGE_SIZE) {
	if (count > PAGE_SIZE) {
		if (printk_ratelimit())
		if (printk_ratelimit())
			ata_port_printk(ap, KERN_WARNING,
			ata_port_warn(ap,
				      "EM read buffer size too large: "
				      "EM read buffer size too large: "
				      "buffer size %u, page size %lu\n",
				      "buffer size %u, page size %lu\n",
				      hpriv->em_buf_sz, PAGE_SIZE);
				      hpriv->em_buf_sz, PAGE_SIZE);
@@ -1124,7 +1124,7 @@ static void ahci_dev_config(struct ata_device *dev)


	if (hpriv->flags & AHCI_HFLAG_SECT255) {
	if (hpriv->flags & AHCI_HFLAG_SECT255) {
		dev->max_sectors = 255;
		dev->max_sectors = 255;
		ata_dev_printk(dev, KERN_INFO,
		ata_dev_info(dev,
			     "SB600 AHCI: limiting to 255 sectors per cmd\n");
			     "SB600 AHCI: limiting to 255 sectors per cmd\n");
	}
	}
}
}
@@ -1249,8 +1249,7 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
	/* prepare for SRST (AHCI-1.1 10.4.1) */
	/* prepare for SRST (AHCI-1.1 10.4.1) */
	rc = ahci_kick_engine(ap);
	rc = ahci_kick_engine(ap);
	if (rc && rc != -EOPNOTSUPP)
	if (rc && rc != -EOPNOTSUPP)
		ata_link_printk(link, KERN_WARNING,
		ata_link_warn(link, "failed to reset engine (errno=%d)\n", rc);
				"failed to reset engine (errno=%d)\n", rc);


	ata_tf_init(link->device, &tf);
	ata_tf_init(link->device, &tf);


@@ -1283,8 +1282,7 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
		 * be trusted.  Treat device readiness timeout as link
		 * be trusted.  Treat device readiness timeout as link
		 * offline.
		 * offline.
		 */
		 */
		ata_link_printk(link, KERN_INFO,
		ata_link_info(link, "device not ready, treating as offline\n");
				"device not ready, treating as offline\n");
		*class = ATA_DEV_NONE;
		*class = ATA_DEV_NONE;
	} else if (rc) {
	} else if (rc) {
		/* link occupied, -ENODEV too is an error */
		/* link occupied, -ENODEV too is an error */
@@ -1297,7 +1295,7 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
	return 0;
	return 0;


 fail:
 fail:
	ata_link_printk(link, KERN_ERR, "softreset failed (%s)\n", reason);
	ata_link_err(link, "softreset failed (%s)\n", reason);
	return rc;
	return rc;
}
}


@@ -1966,7 +1964,7 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
	if (rc == 0)
	if (rc == 0)
		ahci_power_down(ap);
		ahci_power_down(ap);
	else {
	else {
		ata_port_printk(ap, KERN_ERR, "%s (%d)\n", emsg, rc);
		ata_port_err(ap, "%s (%d)\n", emsg, rc);
		ahci_start_port(ap);
		ahci_start_port(ap);
	}
	}


@@ -2061,7 +2059,7 @@ static void ahci_port_stop(struct ata_port *ap)
	/* de-initialize port */
	/* de-initialize port */
	rc = ahci_deinit_port(ap, &emsg);
	rc = ahci_deinit_port(ap, &emsg);
	if (rc)
	if (rc)
		ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc);
		ata_port_warn(ap, "%s (%d)\n", emsg, rc);
}
}


void ahci_print_info(struct ata_host *host, const char *scc_s)
void ahci_print_info(struct ata_host *host, const char *scc_s)
+28 −38
Original line number Original line Diff line number Diff line
@@ -332,24 +332,21 @@ int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)


	rc = -EINVAL;
	rc = -EINVAL;
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		ata_port_printk(ap, KERN_ERR,
		ata_port_err(ap, "ACPI get timing mode failed (AE 0x%x)\n",
				"ACPI get timing mode failed (AE 0x%x)\n",
			     status);
			     status);
		goto out_free;
		goto out_free;
	}
	}


	out_obj = output.pointer;
	out_obj = output.pointer;
	if (out_obj->type != ACPI_TYPE_BUFFER) {
	if (out_obj->type != ACPI_TYPE_BUFFER) {
		ata_port_printk(ap, KERN_WARNING,
		ata_port_warn(ap, "_GTM returned unexpected object type 0x%x\n",
				"_GTM returned unexpected object type 0x%x\n",
			      out_obj->type);
			      out_obj->type);


		goto out_free;
		goto out_free;
	}
	}


	if (out_obj->buffer.length != sizeof(struct ata_acpi_gtm)) {
	if (out_obj->buffer.length != sizeof(struct ata_acpi_gtm)) {
		ata_port_printk(ap, KERN_ERR,
		ata_port_err(ap, "_GTM returned invalid length %d\n",
				"_GTM returned invalid length %d\n",
			     out_obj->buffer.length);
			     out_obj->buffer.length);
		goto out_free;
		goto out_free;
	}
	}
@@ -402,8 +399,8 @@ int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm)
	if (status == AE_NOT_FOUND)
	if (status == AE_NOT_FOUND)
		return -ENOENT;
		return -ENOENT;
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		ata_port_printk(ap, KERN_ERR,
		ata_port_err(ap, "ACPI set timing mode failed (status=0x%x)\n",
			"ACPI set timing mode failed (status=0x%x)\n", status);
			     status);
		return -EINVAL;
		return -EINVAL;
	}
	}
	return 0;
	return 0;
@@ -450,7 +447,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
	output.pointer = NULL;	/* ACPI-CA sets this; save/free it later */
	output.pointer = NULL;	/* ACPI-CA sets this; save/free it later */


	if (ata_msg_probe(ap))
	if (ata_msg_probe(ap))
		ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
		ata_dev_dbg(dev, "%s: ENTER: port#: %d\n",
			    __func__, ap->port_no);
			    __func__, ap->port_no);


	/* _GTF has no input parameters */
	/* _GTF has no input parameters */
@@ -459,8 +456,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)


	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		if (status != AE_NOT_FOUND) {
		if (status != AE_NOT_FOUND) {
			ata_dev_printk(dev, KERN_WARNING,
			ata_dev_warn(dev, "_GTF evaluation failed (AE 0x%x)\n",
				       "_GTF evaluation failed (AE 0x%x)\n",
				     status);
				     status);
			rc = -EINVAL;
			rc = -EINVAL;
		}
		}
@@ -469,8 +465,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)


	if (!output.length || !output.pointer) {
	if (!output.length || !output.pointer) {
		if (ata_msg_probe(ap))
		if (ata_msg_probe(ap))
			ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: "
			ata_dev_dbg(dev, "%s: Run _GTF: length or ptr is NULL (0x%llx, 0x%p)\n",
				"length or ptr is NULL (0x%llx, 0x%p)\n",
				    __func__,
				    __func__,
				    (unsigned long long)output.length,
				    (unsigned long long)output.length,
				    output.pointer);
				    output.pointer);
@@ -479,16 +474,14 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
	}
	}


	if (out_obj->type != ACPI_TYPE_BUFFER) {
	if (out_obj->type != ACPI_TYPE_BUFFER) {
		ata_dev_printk(dev, KERN_WARNING,
		ata_dev_warn(dev, "_GTF unexpected object type 0x%x\n",
			       "_GTF unexpected object type 0x%x\n",
			     out_obj->type);
			     out_obj->type);
		rc = -EINVAL;
		rc = -EINVAL;
		goto out_free;
		goto out_free;
	}
	}


	if (out_obj->buffer.length % REGS_PER_GTF) {
	if (out_obj->buffer.length % REGS_PER_GTF) {
		ata_dev_printk(dev, KERN_WARNING,
		ata_dev_warn(dev, "unexpected _GTF length (%d)\n",
			       "unexpected _GTF length (%d)\n",
			     out_obj->buffer.length);
			     out_obj->buffer.length);
		rc = -EINVAL;
		rc = -EINVAL;
		goto out_free;
		goto out_free;
@@ -499,8 +492,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
	if (gtf) {
	if (gtf) {
		*gtf = (void *)out_obj->buffer.pointer;
		*gtf = (void *)out_obj->buffer.pointer;
		if (ata_msg_probe(ap))
		if (ata_msg_probe(ap))
			ata_dev_printk(dev, KERN_DEBUG,
			ata_dev_dbg(dev, "%s: returning gtf=%p, gtf_count=%d\n",
				       "%s: returning gtf=%p, gtf_count=%d\n",
				    __func__, *gtf, rc);
				    __func__, *gtf, rc);
	}
	}
	return rc;
	return rc;
@@ -811,7 +803,7 @@ static int ata_acpi_push_id(struct ata_device *dev)
	union acpi_object in_params[1];
	union acpi_object in_params[1];


	if (ata_msg_probe(ap))
	if (ata_msg_probe(ap))
		ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n",
		ata_dev_dbg(dev, "%s: ix = %d, port#: %d\n",
			    __func__, dev->devno, ap->port_no);
			    __func__, dev->devno, ap->port_no);


	/* Give the drive Identify data to the drive via the _SDD method */
	/* Give the drive Identify data to the drive via the _SDD method */
@@ -832,8 +824,7 @@ static int ata_acpi_push_id(struct ata_device *dev)
		return -ENOENT;
		return -ENOENT;


	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		ata_dev_printk(dev, KERN_WARNING,
		ata_dev_warn(dev, "ACPI _SDD failed (AE 0x%x)\n", status);
			       "ACPI _SDD failed (AE 0x%x)\n", status);
		return -EIO;
		return -EIO;
	}
	}


@@ -983,8 +974,8 @@ int ata_acpi_on_devcfg(struct ata_device *dev)
	if (nr_executed) {
	if (nr_executed) {
		rc = ata_dev_reread_id(dev, 0);
		rc = ata_dev_reread_id(dev, 0);
		if (rc < 0) {
		if (rc < 0) {
			ata_dev_printk(dev, KERN_ERR, "failed to IDENTIFY "
			ata_dev_err(dev,
				       "after ACPI commands\n");
				    "failed to IDENTIFY after ACPI commands\n");
			return rc;
			return rc;
		}
		}
	}
	}
@@ -1002,8 +993,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev)
		return rc;
		return rc;
	}
	}


	ata_dev_printk(dev, KERN_WARNING,
	ata_dev_warn(dev, "ACPI: failed the second time, disabled\n");
		       "ACPI: failed the second time, disabled\n");
	dev->acpi_handle = NULL;
	dev->acpi_handle = NULL;


	/* We can safely continue if no _GTF command has been executed
	/* We can safely continue if no _GTF command has been executed
+215 −166

File changed.

Preview size limit exceeded, changes collapsed.

Loading