Skip to contentSkip to conversation

scsi: some (very) old clean ups

PATCH In review Andy Shevchenko 2 participants 7 messages May 6, 2016 – Jun 21, 2016

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover scsi: some (very) old clean ups

This is a set of independent clean ups that didn't land upstream for ages (some are dated 2010!). As agreed with Martin at some point I resend them.

I have more, but the rest is not yet ready for submission.

Andy Shevchenko (3):
libsas: remove private hex2bin() implementation
scsi: fnic: use kernel's '%pM' format option to print MAC
fusion: print lan address via %pMR

Oleksandr Khoshaba (1):
scsi: qla4xxx: print MAC and SID via %p[mM][R]

 drivers/message/fusion/mptbase.c    | 14 ++++----------
 drivers/scsi/fnic/vnic_dev.c        | 10 ++--------
 drivers/scsi/libsas/sas_scsi_host.c | 22 ++++++----------------
 drivers/scsi/qla4xxx/ql4_mbx.c      |  5 +----
 drivers/scsi/qla4xxx/ql4_nx.c       |  8 ++------
 drivers/scsi/qla4xxx/ql4_os.c       | 15 ++++-----------
 6 files changed, 19 insertions(+), 55 deletions(-)
Signature · 1 line
2.8.1
#1 lore raw

PATCH 1/4 libsas: remove private hex2bin() implementation

The function sas_parse_addr() could be easily substituted by hex2bin() which is in kernel library code.

Cc Christoph Hellwig <[email protected]>
---
 drivers/scsi/libsas/sas_scsi_host.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/scsi/libsas/sas_scsi_host.c +6 -16
index 519dac4..30a5970 100644
@@ -27,6 +27,7 @@
 #include <linux/firmware.h>
 #include <linux/export.h>
 #include <linux/ctype.h>
+#include <linux/kernel.h>
 
 #include "sas_internal.h"
 
@@ -961,21 +962,6 @@ void sas_target_destroy(struct scsi_target *starget)
 	sas_put_device(found_dev);
 }
 
-static void sas_parse_addr(u8 *sas_addr, const char *p)
-{
-	int i;
-	for (i = 0; i < SAS_ADDR_SIZE; i++) {
-		u8 h, l;
-		if (!*p)
-			break;
-		h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-		p++;
-		l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-		p++;
-		sas_addr[i] = (h<<4) | l;
-	}
-}
-
 #define SAS_STRING_ADDR_SIZE	16
 
 int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
@@ -992,7 +978,11 @@ int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
 		goto out;
 	}
 
-	sas_parse_addr(addr, fw->data);
+	res = hex2bin(addr, fw->data, strnlen(fw->data, SAS_ADDR_SIZE * 2) / 2);
+	if (res) {
+		res = -EINVAL;
+		goto out;
+	}
 
 out:
 	release_firmware(fw);
Signature · 1 line
2.8.1
#2 lore raw

PATCH 2/4 scsi: fnic: use kernel's '%pM' format option to print MAC

In reply to Andy Shevchenko

Instead of supplying each byte through stack let's use %pM specifier.

Cc Hiral Patel <[email protected]>
Cc Suma Ramars <[email protected]>
Cc Brian Uchino <[email protected]>
---
 drivers/scsi/fnic/vnic_dev.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/scsi/fnic/vnic_dev.c +2 -8
index 9795d6f..ba69d61 100644
@@ -499,10 +499,7 @@ void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr)
 
 	err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, &a0, &a1, wait);
 	if (err)
-		printk(KERN_ERR
-			"Can't add addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
-			addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-			err);
+		pr_err("Can't add addr [%pM], %d\n", addr, err);
 }
 
 void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
@@ -517,10 +514,7 @@ void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
 
 	err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, &a0, &a1, wait);
 	if (err)
-		printk(KERN_ERR
-			"Can't del addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
-			addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-			err);
+		pr_err("Can't del addr [%pM], %d\n", addr, err);
 }
 
 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
Signature · 1 line
2.8.1
#3 lore raw

PATCH 3/4 fusion: print lan address via %pMR

In reply to Andy Shevchenko

LAN MAC addresses can be printed directly using %pMR specifier.

---
 drivers/message/fusion/mptbase.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/message/fusion/mptbase.c +4 -10
index 5537f8d..3af67e6 100644
@@ -2584,10 +2584,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
 				(void) GetLanConfigPages(ioc);
 				a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow;
 				dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
-					"LanAddr = %02X:%02X:%02X"
-					":%02X:%02X:%02X\n",
-					ioc->name, a[5], a[4],
-					a[3], a[2], a[1], a[0]));
+					"LanAddr = %pMR\n", ioc->name, a));
 			}
 			break;
 
@@ -6782,8 +6779,7 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
 		if (ioc->bus_type == FC) {
 			if (ioc->pfacts[p].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) {
 				u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow;
-				seq_printf(m, "    LanAddr = %02X:%02X:%02X:%02X:%02X:%02X\n",
-						a[5], a[4], a[3], a[2], a[1], a[0]);
+				seq_printf(m, "    LanAddr = %pMR\n", a);
 			}
 			seq_printf(m, "    WWN = %08X%08X:%08X%08X\n",
 					ioc->fc_port_page0[p].WWNN.High,
@@ -6860,8 +6856,7 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int *size, int len, int sh
 
 	if (showlan && (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN)) {
 		u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow;
-		y += sprintf(buffer+len+y, ", LanAddr=%02X:%02X:%02X:%02X:%02X:%02X",
-			a[5], a[4], a[3], a[2], a[1], a[0]);
+		y += sprintf(buffer+len+y, ", LanAddr=%pMR", a);
 	}
 
 	y += sprintf(buffer+len+y, ", IRQ=%d", ioc->pci_irq);
@@ -6895,8 +6890,7 @@ static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, struct seq_file *m, int
 
 	if (showlan && (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN)) {
 		u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow;
-		seq_printf(m, ", LanAddr=%02X:%02X:%02X:%02X:%02X:%02X",
-			a[5], a[4], a[3], a[2], a[1], a[0]);
+		seq_printf(m, ", LanAddr=%pMR", a);
 	}
 
 	seq_printf(m, ", IRQ=%d", ioc->pci_irq);
Signature · 1 line
2.8.1
#4 lore raw

PATCH 4/4 scsi: qla4xxx: print MAC and SID via %p[mM][R]

In reply to Andy Shevchenko

From: Oleksandr Khoshaba <[email protected]>

In the kernel we have nice specifier to print MAC by given pointer to the address in a binary form.

---
 drivers/scsi/qla4xxx/ql4_mbx.c |  5 +----
 drivers/scsi/qla4xxx/ql4_nx.c  |  8 ++------
 drivers/scsi/qla4xxx/ql4_os.c  | 15 ++++-----------
 3 files changed, 7 insertions(+), 21 deletions(-)
drivers/scsi/qla4xxx/ql4_mbx.c +1 -4
index c291fdf..1da04f3 100644
@@ -2032,10 +2032,7 @@ int qla4xxx_set_param_ddbentry(struct scsi_qla_host *ha,
 	ptid = (uint16_t *)&fw_ddb_entry->isid[1];
 	*ptid = cpu_to_le16((uint16_t)ddb_entry->sess->target_id);
 
-	DEBUG2(ql4_printk(KERN_INFO, ha, "ISID [%02x%02x%02x%02x%02x%02x]\n",
-			  fw_ddb_entry->isid[5], fw_ddb_entry->isid[4],
-			  fw_ddb_entry->isid[3], fw_ddb_entry->isid[2],
-			  fw_ddb_entry->isid[1], fw_ddb_entry->isid[0]));
+	DEBUG2(ql4_printk(KERN_INFO, ha, "ISID [%pmR]\n", fw_ddb_entry->isid));
 
 	iscsi_opts = le16_to_cpu(fw_ddb_entry->iscsi_options);
 	memset(fw_ddb_entry->iscsi_alias, 0, sizeof(fw_ddb_entry->iscsi_alias));
drivers/scsi/qla4xxx/ql4_nx.c +2 -6
index ae87d6c..157938e 100644
@@ -4094,12 +4094,8 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha)
 	ha->phy_port_num = sys_info->port_num;
 	ha->iscsi_pci_func_cnt = sys_info->iscsi_pci_func_cnt;
 
-	DEBUG2(printk("scsi%ld: %s: "
-	    "mac %02x:%02x:%02x:%02x:%02x:%02x "
-	    "serial %s\n", ha->host_no, __func__,
-	    ha->my_mac[0], ha->my_mac[1], ha->my_mac[2],
-	    ha->my_mac[3], ha->my_mac[4], ha->my_mac[5],
-	    ha->serial_number));
+	DEBUG2(printk("scsi%ld: %s: mac %pM serial %s\n",
+	    ha->host_no, __func__, ha->my_mac, ha->serial_number));
 
 	status = QLA_SUCCESS;
 
drivers/scsi/qla4xxx/ql4_os.c +4 -11
index 01c3610..9fbb33f 100644
@@ -6304,13 +6304,9 @@ static int qla4xxx_compare_tuple_ddb(struct scsi_qla_host *ha,
 	 * ISID would not match firmware generated ISID.
 	 */
 	if (is_isid_compare) {
-		DEBUG2(ql4_printk(KERN_INFO, ha, "%s: old ISID [%02x%02x%02x"
-			"%02x%02x%02x] New ISID [%02x%02x%02x%02x%02x%02x]\n",
-			__func__, old_tddb->isid[5], old_tddb->isid[4],
-			old_tddb->isid[3], old_tddb->isid[2], old_tddb->isid[1],
-			old_tddb->isid[0], new_tddb->isid[5], new_tddb->isid[4],
-			new_tddb->isid[3], new_tddb->isid[2], new_tddb->isid[1],
-			new_tddb->isid[0]));
+		DEBUG2(ql4_printk(KERN_INFO, ha,
+			"%s: old ISID [%pmR] New ISID [%pmR]\n",
+			__func__, old_tddb->isid, new_tddb->isid));
 
 		if (memcmp(&old_tddb->isid[0], &new_tddb->isid[0],
 			   sizeof(old_tddb->isid)))
@@ -7925,10 +7921,7 @@ qla4xxx_sysfs_ddb_get_param(struct iscsi_bus_flash_session *fnode_sess,
 		rc = sprintf(buf, "%u\n", fnode_conn->keepalive_timeout);
 		break;
 	case ISCSI_FLASHNODE_ISID:
-		rc = sprintf(buf, "%02x%02x%02x%02x%02x%02x\n",
-			     fnode_sess->isid[0], fnode_sess->isid[1],
-			     fnode_sess->isid[2], fnode_sess->isid[3],
-			     fnode_sess->isid[4], fnode_sess->isid[5]);
+		rc = sprintf(buf, "%pm\n", fnode_sess->isid);
 		break;
 	case ISCSI_FLASHNODE_TSID:
 		rc = sprintf(buf, "%u\n", fnode_sess->tsid);
Signature · 1 line
2.8.1
#5 lore raw
In reply to Andy Shevchenko
Quoted 6 lines · Andy Shevchenko

This is a set of independent clean ups that didn't land upstream for ages (some
are dated 2010!).  As agreed with Martin at some point I resend them.

I have more, but the rest is not yet ready for submission.

Gentle ping to get know what is the destiny of my patches.

Quoted 17 lines

Andy Shevchenko (3):
  libsas: remove private hex2bin() implementation
  scsi: fnic: use kernel's '%pM' format option to print MAC
  fusion: print lan address via %pMR

Oleksandr Khoshaba (1):
  scsi: qla4xxx: print MAC and SID via %p[mM][R]

 drivers/message/fusion/mptbase.c    | 14 ++++---------- drivers/scsi/fnic/vnic_dev.c        | 10 ++-------- drivers/scsi/libsas/sas_scsi_host.c | 22 ++++++---------------- drivers/scsi/qla4xxx/ql4_mbx.c      |  5 +---- drivers/scsi/qla4xxx/ql4_nx.c       |  8 ++------ drivers/scsi/qla4xxx/ql4_os.c       | 15 ++++-----------

 6 files changed, 19 insertions(+), 55 deletions(-)
Signature · 6 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Andy" == Andy Shevchenko <[email protected]> writes:

Andy,

Andy> Gentle ping to get know what is the destiny of my patches.

-ENOREVIEWS

At this point they have expired from patchworks so it's probably best to post them again. And make sure to pester the relevant driver maintainers.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering