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

Commit a0cf733b authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik
Browse files

libata: straighten out ATA_ID_* constants



* Kill _OFS suffixes in ATA_ID_{SERNO|FW_REV|PROD}_OFS for consistency
  with other ATA_ID_* constants.

* Kill ATA_SERNO_LEN

* Add and use ATA_ID_SERNO_LEN, ATA_ID_FW_REV_LEN and ATA_ID_PROD_LEN.
  This change also makes ata_device_blacklisted() use proper length
  for fwrev.

Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent cdf56bcf
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -3187,7 +3187,8 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
			       const u16 *new_id)
{
	const u16 *old_id = dev->id;
	unsigned char model[2][41], serial[2][21];
	unsigned char model[2][ATA_ID_PROD_LEN + 1];
	unsigned char serial[2][ATA_ID_SERNO_LEN + 1];
	u64 new_n_sectors;

	if (dev->class != new_class) {
@@ -3196,10 +3197,10 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
		return 0;
	}

	ata_id_c_string(old_id, model[0], ATA_ID_PROD_OFS, sizeof(model[0]));
	ata_id_c_string(new_id, model[1], ATA_ID_PROD_OFS, sizeof(model[1]));
	ata_id_c_string(old_id, serial[0], ATA_ID_SERNO_OFS, sizeof(serial[0]));
	ata_id_c_string(new_id, serial[1], ATA_ID_SERNO_OFS, sizeof(serial[1]));
	ata_id_c_string(old_id, model[0], ATA_ID_PROD, sizeof(model[0]));
	ata_id_c_string(new_id, model[1], ATA_ID_PROD, sizeof(model[1]));
	ata_id_c_string(old_id, serial[0], ATA_ID_SERNO, sizeof(serial[0]));
	ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1]));
	new_n_sectors = ata_id_n_sectors(new_id);

	if (strcmp(model[0], model[1])) {
@@ -3338,15 +3339,13 @@ static int ata_strim(char *s, size_t len)

unsigned long ata_device_blacklisted(const struct ata_device *dev)
{
	unsigned char model_num[40];
	unsigned char model_rev[16];
	unsigned char model_num[ATA_ID_PROD_LEN];
	unsigned char model_rev[ATA_ID_FW_REV_LEN];
	unsigned int nlen, rlen;
	const struct ata_blacklist_entry *ad = ata_device_blacklist;

	ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS,
			  sizeof(model_num));
	ata_id_string(dev->id, model_rev, ATA_ID_FW_REV_OFS,
			  sizeof(model_rev));
	ata_id_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
	ata_id_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev));
	nlen = ata_strim(model_num, sizeof(model_num));
	rlen = ata_strim(model_rev, sizeof(model_rev));

+16 −17
Original line number Diff line number Diff line
@@ -1698,8 +1698,8 @@ unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,

	if (buflen > 35) {
		memcpy(&rbuf[8], "ATA     ", 8);
		ata_id_string(args->id, &rbuf[16], ATA_ID_PROD_OFS, 16);
		ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV_OFS, 4);
		ata_id_string(args->id, &rbuf[16], ATA_ID_PROD, 16);
		ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4);
		if (rbuf[32] == 0 || rbuf[32] == ' ')
			memcpy(&rbuf[32], "n/a ", 4);
	}
@@ -1768,13 +1768,13 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
		0,
		0x80,			/* this page code */
		0,
		ATA_SERNO_LEN,		/* page len */
		ATA_ID_SERNO_LEN,	/* page len */
	};
	memcpy(rbuf, hdr, sizeof(hdr));

	if (buflen > (ATA_SERNO_LEN + 4 - 1))
	if (buflen > (ATA_ID_SERNO_LEN + 4 - 1))
		ata_id_string(args->id, (unsigned char *) &rbuf[4],
			      ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
			      ATA_ID_SERNO, ATA_ID_SERNO_LEN);

	return 0;
}
@@ -1799,19 +1799,18 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
{
	int num;
	const int sat_model_serial_desc_len = 68;
	const int ata_model_byte_len = 40;

	rbuf[1] = 0x83;			/* this page code */
	num = 4;

	if (buflen > (ATA_SERNO_LEN + num + 3)) {
	if (buflen > (ATA_ID_SERNO_LEN + num + 3)) {
		/* piv=0, assoc=lu, code_set=ACSII, designator=vendor */
		rbuf[num + 0] = 2;
		rbuf[num + 3] = ATA_SERNO_LEN;
		rbuf[num + 3] = ATA_ID_SERNO_LEN;
		num += 4;
		ata_id_string(args->id, (unsigned char *) rbuf + num,
			      ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
		num += ATA_SERNO_LEN;
			      ATA_ID_SERNO, ATA_ID_SERNO_LEN);
		num += ATA_ID_SERNO_LEN;
	}
	if (buflen > (sat_model_serial_desc_len + num + 3)) {
		/* SAT defined lu model and serial numbers descriptor */
@@ -1823,11 +1822,11 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
		memcpy(rbuf + num, "ATA     ", 8);
		num += 8;
		ata_id_string(args->id, (unsigned char *) rbuf + num,
			      ATA_ID_PROD_OFS, ata_model_byte_len);
		num += ata_model_byte_len;
			      ATA_ID_PROD, ATA_ID_PROD_LEN);
		num += ATA_ID_PROD_LEN;
		ata_id_string(args->id, (unsigned char *) rbuf + num,
			      ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
		num += ATA_SERNO_LEN;
			      ATA_ID_SERNO, ATA_ID_SERNO_LEN);
		num += ATA_ID_SERNO_LEN;
	}
	rbuf[3] = num - 4;    /* page len (assume less than 256 bytes) */
	return 0;
@@ -1955,15 +1954,15 @@ static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last)
 */
static int ata_dev_supports_fua(u16 *id)
{
	unsigned char model[41], fw[9];
	unsigned char model[ATA_ID_PROD_LEN + 1], fw[ATA_ID_FW_REV_LEN + 1];

	if (!libata_fua)
		return 0;
	if (!ata_id_has_fua(id))
		return 0;

	ata_id_c_string(id, model, ATA_ID_PROD_OFS, sizeof(model));
	ata_id_c_string(id, fw, ATA_ID_FW_REV_OFS, sizeof(fw));
	ata_id_c_string(id, model, ATA_ID_PROD, sizeof(model));
	ata_id_c_string(id, fw, ATA_ID_FW_REV, sizeof(fw));

	if (strcmp(model, "Maxtor"))
		return 1;
+2 −2
Original line number Diff line number Diff line
@@ -153,11 +153,11 @@ static void ali_early_error_handler(struct ata_port *ap)

static unsigned long ali_20_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask)
{
	char model_num[40];
	char model_num[ATA_ID_PROD_LEN];
	/* No DMA on anything but a disk for now */
	if (adev->class != ATA_DEV_ATA)
		mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
	ata_id_string(adev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num));
	ata_id_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
	if (strstr(model_num, "WDC"))
		return mask &= ~ATA_MASK_UDMA;
	return ata_pci_default_filter(ap, adev, mask);
+2 −2
Original line number Diff line number Diff line
@@ -151,12 +151,12 @@ static const char *bad_ata66_3[] = {

static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char *list[])
{
	unsigned char model_num[40];
	unsigned char model_num[ATA_ID_PROD_LEN];
	char *s;
	unsigned int len;
	int i = 0;

	ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num));
	ata_id_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
	s = &model_num[0];
	len = strnlen(s, sizeof(model_num));

+2 −3
Original line number Diff line number Diff line
@@ -349,13 +349,12 @@ static u32 hpt37x_find_mode(struct ata_port *ap, int speed)

static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char *list[])
{
	unsigned char model_num[40];
	unsigned char model_num[ATA_ID_PROD_LEN];
	char *s;
	unsigned int len;
	int i = 0;

	ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS,
			  sizeof(model_num));
	ata_id_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
	s = &model_num[0];
	len = strnlen(s, sizeof(model_num));

Loading