Skip to content

Commit

Permalink
[PATCH] libata: add @print_info argument to ata_dev_configure()
Browse files Browse the repository at this point in the history
Add @print_info argument to ata_dev_configure().  Details of
configured device is printed only when @pinfo_info is non-zero.  This
patch also reorganizes device info printing for LBA case to simplify
code (necessary as @print_info adds extra nesting around it).

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
  • Loading branch information
Tejun Heo authored and Jeff Garzik committed Mar 5, 2006
1 parent 208a993 commit 4c2d721
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions drivers/scsi/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ static inline u8 ata_dev_knobble(const struct ata_port *ap,
* ata_dev_configure - Configure the specified ATA/ATAPI device
* @ap: Port on which target device resides
* @dev: Target device to configure
* @print_info: Enable device info printout
*
* Configure @dev according to @dev->id. Generic and low-level
* driver specific fixups are also applied.
Expand All @@ -1073,7 +1074,8 @@ static inline u8 ata_dev_knobble(const struct ata_port *ap,
* RETURNS:
* 0 on success, -errno otherwise
*/
static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev)
static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
int print_info)
{
unsigned long xfer_modes;
int i, rc;
Expand Down Expand Up @@ -1120,18 +1122,24 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev)
dev->n_sectors = ata_id_n_sectors(dev->id);

if (ata_id_has_lba(dev->id)) {
dev->flags |= ATA_DFLAG_LBA;
const char *lba_desc;

if (ata_id_has_lba48(dev->id))
lba_desc = "LBA";
dev->flags |= ATA_DFLAG_LBA;
if (ata_id_has_lba48(dev->id)) {
dev->flags |= ATA_DFLAG_LBA48;
lba_desc = "LBA48";
}

/* print device info to dmesg */
printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n",
ap->id, dev->devno,
ata_id_major_version(dev->id),
ata_mode_string(xfer_modes),
(unsigned long long)dev->n_sectors,
dev->flags & ATA_DFLAG_LBA48 ? " LBA48" : " LBA");
if (print_info)
printk(KERN_INFO "ata%u: dev %u ATA-%d, "
"max %s, %Lu sectors: %s\n",
ap->id, dev->devno,
ata_id_major_version(dev->id),
ata_mode_string(xfer_modes),
(unsigned long long)dev->n_sectors,
lba_desc);
} else {
/* CHS */

Expand All @@ -1148,13 +1156,14 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev)
}

/* print device info to dmesg */
printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors: CHS %d/%d/%d\n",
ap->id, dev->devno,
ata_id_major_version(dev->id),
ata_mode_string(xfer_modes),
(unsigned long long)dev->n_sectors,
(int)dev->cylinders, (int)dev->heads, (int)dev->sectors);

if (print_info)
printk(KERN_INFO "ata%u: dev %u ATA-%d, "
"max %s, %Lu sectors: CHS %u/%u/%u\n",
ap->id, dev->devno,
ata_id_major_version(dev->id),
ata_mode_string(xfer_modes),
(unsigned long long)dev->n_sectors,
dev->cylinders, dev->heads, dev->sectors);
}

dev->cdb_len = 16;
Expand All @@ -1171,9 +1180,9 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev)
dev->cdb_len = (unsigned int) rc;

/* print device info to dmesg */
printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n",
ap->id, dev->devno,
ata_mode_string(xfer_modes));
if (print_info)
printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n",
ap->id, dev->devno, ata_mode_string(xfer_modes));
}

ap->host->max_cmd_len = 0;
Expand All @@ -1184,8 +1193,9 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev)

/* limit bridge transfers to udma5, 200 sectors */
if (ata_dev_knobble(ap, dev)) {
printk(KERN_INFO "ata%u(%u): applying bridge limits\n",
ap->id, dev->devno);
if (print_info)
printk(KERN_INFO "ata%u(%u): applying bridge limits\n",
ap->id, dev->devno);
ap->udma_mask &= ATA_UDMA5;
dev->max_sectors = ATA_MAX_SECTORS;
}
Expand Down Expand Up @@ -1263,7 +1273,7 @@ static int ata_bus_probe(struct ata_port *ap)
continue;
}

if (ata_dev_configure(ap, dev)) {
if (ata_dev_configure(ap, dev, 1)) {
dev->class++; /* disable device */
continue;
}
Expand Down

0 comments on commit 4c2d721

Please sign in to comment.