Commit 79ac5224 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by David S. Miller

net: atm: use %*ph to print small buffer

Use %*ph format to print small buffer as hex string.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent edc7e489
...@@ -33,23 +33,17 @@ static ssize_t show_atmaddress(struct device *cdev, ...@@ -33,23 +33,17 @@ static ssize_t show_atmaddress(struct device *cdev,
unsigned long flags; unsigned long flags;
struct atm_dev *adev = to_atm_dev(cdev); struct atm_dev *adev = to_atm_dev(cdev);
struct atm_dev_addr *aaddr; struct atm_dev_addr *aaddr;
int bin[] = { 1, 2, 10, 6, 1 }, *fmt = bin; int count = 0;
int i, j, count = 0;
spin_lock_irqsave(&adev->lock, flags); spin_lock_irqsave(&adev->lock, flags);
list_for_each_entry(aaddr, &adev->local, entry) { list_for_each_entry(aaddr, &adev->local, entry) {
for (i = 0, j = 0; i < ATM_ESA_LEN; ++i, ++j) { count += scnprintf(buf + count, PAGE_SIZE - count,
if (j == *fmt) { "%1phN.%2phN.%10phN.%6phN.%1phN\n",
count += scnprintf(buf + count, &aaddr->addr.sas_addr.prv[0],
PAGE_SIZE - count, "."); &aaddr->addr.sas_addr.prv[1],
++fmt; &aaddr->addr.sas_addr.prv[3],
j = 0; &aaddr->addr.sas_addr.prv[13],
} &aaddr->addr.sas_addr.prv[19]);
count += scnprintf(buf + count,
PAGE_SIZE - count, "%02x",
aaddr->addr.sas_addr.prv[i]);
}
count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
} }
spin_unlock_irqrestore(&adev->lock, flags); spin_unlock_irqrestore(&adev->lock, flags);
......
...@@ -799,14 +799,9 @@ static const char *lec_arp_get_status_string(unsigned char status) ...@@ -799,14 +799,9 @@ static const char *lec_arp_get_status_string(unsigned char status)
static void lec_info(struct seq_file *seq, struct lec_arp_table *entry) static void lec_info(struct seq_file *seq, struct lec_arp_table *entry)
{ {
int i; seq_printf(seq, "%pM ", entry->mac_addr);
seq_printf(seq, "%*phN ", ATM_ESA_LEN, entry->atm_addr);
for (i = 0; i < ETH_ALEN; i++) seq_printf(seq, "%s %4.4x", lec_arp_get_status_string(entry->status),
seq_printf(seq, "%2.2x", entry->mac_addr[i] & 0xff);
seq_printf(seq, " ");
for (i = 0; i < ATM_ESA_LEN; i++)
seq_printf(seq, "%2.2x", entry->atm_addr[i] & 0xff);
seq_printf(seq, " %s %4.4x", lec_arp_get_status_string(entry->status),
entry->flags & 0xffff); entry->flags & 0xffff);
if (entry->vcc) if (entry->vcc)
seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci); seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci);
...@@ -1354,7 +1349,7 @@ static void dump_arp_table(struct lec_priv *priv) ...@@ -1354,7 +1349,7 @@ static void dump_arp_table(struct lec_priv *priv)
{ {
struct lec_arp_table *rulla; struct lec_arp_table *rulla;
char buf[256]; char buf[256];
int i, j, offset; int i, offset;
pr_info("Dump %p:\n", priv); pr_info("Dump %p:\n", priv);
for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
...@@ -1362,14 +1357,10 @@ static void dump_arp_table(struct lec_priv *priv) ...@@ -1362,14 +1357,10 @@ static void dump_arp_table(struct lec_priv *priv)
&priv->lec_arp_tables[i], next) { &priv->lec_arp_tables[i], next) {
offset = 0; offset = 0;
offset += sprintf(buf, "%d: %p\n", i, rulla); offset += sprintf(buf, "%d: %p\n", i, rulla);
offset += sprintf(buf + offset, "Mac: %pM", offset += sprintf(buf + offset, "Mac: %pM ",
rulla->mac_addr); rulla->mac_addr);
offset += sprintf(buf + offset, " Atm:"); offset += sprintf(buf + offset, "Atm: %*ph ", ATM_ESA_LEN,
for (j = 0; j < ATM_ESA_LEN; j++) { rulla->atm_addr);
offset += sprintf(buf + offset,
"%2.2x ",
rulla->atm_addr[j] & 0xff);
}
offset += sprintf(buf + offset, offset += sprintf(buf + offset,
"Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
rulla->vcc ? rulla->vcc->vpi : 0, rulla->vcc ? rulla->vcc->vpi : 0,
...@@ -1392,12 +1383,9 @@ static void dump_arp_table(struct lec_priv *priv) ...@@ -1392,12 +1383,9 @@ static void dump_arp_table(struct lec_priv *priv)
pr_info("No forward\n"); pr_info("No forward\n");
hlist_for_each_entry(rulla, &priv->lec_no_forward, next) { hlist_for_each_entry(rulla, &priv->lec_no_forward, next) {
offset = 0; offset = 0;
offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr); offset += sprintf(buf + offset, "Mac: %pM ", rulla->mac_addr);
offset += sprintf(buf + offset, " Atm:"); offset += sprintf(buf + offset, "Atm: %*ph ", ATM_ESA_LEN,
for (j = 0; j < ATM_ESA_LEN; j++) { rulla->atm_addr);
offset += sprintf(buf + offset, "%2.2x ",
rulla->atm_addr[j] & 0xff);
}
offset += sprintf(buf + offset, offset += sprintf(buf + offset,
"Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
rulla->vcc ? rulla->vcc->vpi : 0, rulla->vcc ? rulla->vcc->vpi : 0,
...@@ -1417,12 +1405,9 @@ static void dump_arp_table(struct lec_priv *priv) ...@@ -1417,12 +1405,9 @@ static void dump_arp_table(struct lec_priv *priv)
pr_info("Empty ones\n"); pr_info("Empty ones\n");
hlist_for_each_entry(rulla, &priv->lec_arp_empty_ones, next) { hlist_for_each_entry(rulla, &priv->lec_arp_empty_ones, next) {
offset = 0; offset = 0;
offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr); offset += sprintf(buf + offset, "Mac: %pM ", rulla->mac_addr);
offset += sprintf(buf + offset, " Atm:"); offset += sprintf(buf + offset, "Atm: %*ph ", ATM_ESA_LEN,
for (j = 0; j < ATM_ESA_LEN; j++) { rulla->atm_addr);
offset += sprintf(buf + offset, "%2.2x ",
rulla->atm_addr[j] & 0xff);
}
offset += sprintf(buf + offset, offset += sprintf(buf + offset,
"Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
rulla->vcc ? rulla->vcc->vpi : 0, rulla->vcc ? rulla->vcc->vpi : 0,
...@@ -1442,12 +1427,9 @@ static void dump_arp_table(struct lec_priv *priv) ...@@ -1442,12 +1427,9 @@ static void dump_arp_table(struct lec_priv *priv)
pr_info("Multicast Forward VCCs\n"); pr_info("Multicast Forward VCCs\n");
hlist_for_each_entry(rulla, &priv->mcast_fwds, next) { hlist_for_each_entry(rulla, &priv->mcast_fwds, next) {
offset = 0; offset = 0;
offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr); offset += sprintf(buf + offset, "Mac: %pM ", rulla->mac_addr);
offset += sprintf(buf + offset, " Atm:"); offset += sprintf(buf + offset, "Atm: %*ph ", ATM_ESA_LEN,
for (j = 0; j < ATM_ESA_LEN; j++) { rulla->atm_addr);
offset += sprintf(buf + offset, "%2.2x ",
rulla->atm_addr[j] & 0xff);
}
offset += sprintf(buf + offset, offset += sprintf(buf + offset,
"Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
rulla->vcc ? rulla->vcc->vpi : 0, rulla->vcc ? rulla->vcc->vpi : 0,
...@@ -1973,17 +1955,8 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, ...@@ -1973,17 +1955,8 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,
* Vcc which we don't want to make default vcc, * Vcc which we don't want to make default vcc,
* attach it anyway. * attach it anyway.
*/ */
pr_debug("LEC_ARP:Attaching data direct, not default: %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", pr_debug("LEC_ARP:Attaching data direct, not default: %*phN\n",
ioc_data->atm_addr[0], ioc_data->atm_addr[1], ATM_ESA_LEN, ioc_data->atm_addr);
ioc_data->atm_addr[2], ioc_data->atm_addr[3],
ioc_data->atm_addr[4], ioc_data->atm_addr[5],
ioc_data->atm_addr[6], ioc_data->atm_addr[7],
ioc_data->atm_addr[8], ioc_data->atm_addr[9],
ioc_data->atm_addr[10], ioc_data->atm_addr[11],
ioc_data->atm_addr[12], ioc_data->atm_addr[13],
ioc_data->atm_addr[14], ioc_data->atm_addr[15],
ioc_data->atm_addr[16], ioc_data->atm_addr[17],
ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
entry = make_entry(priv, bus_mac); entry = make_entry(priv, bus_mac);
if (entry == NULL) if (entry == NULL)
goto out; goto out;
...@@ -1999,17 +1972,8 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, ...@@ -1999,17 +1972,8 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,
dump_arp_table(priv); dump_arp_table(priv);
goto out; goto out;
} }
pr_debug("LEC_ARP:Attaching data direct, default: %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", pr_debug("LEC_ARP:Attaching data direct, default: %*phN\n",
ioc_data->atm_addr[0], ioc_data->atm_addr[1], ATM_ESA_LEN, ioc_data->atm_addr);
ioc_data->atm_addr[2], ioc_data->atm_addr[3],
ioc_data->atm_addr[4], ioc_data->atm_addr[5],
ioc_data->atm_addr[6], ioc_data->atm_addr[7],
ioc_data->atm_addr[8], ioc_data->atm_addr[9],
ioc_data->atm_addr[10], ioc_data->atm_addr[11],
ioc_data->atm_addr[12], ioc_data->atm_addr[13],
ioc_data->atm_addr[14], ioc_data->atm_addr[15],
ioc_data->atm_addr[16], ioc_data->atm_addr[17],
ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
hlist_for_each_entry(entry, hlist_for_each_entry(entry,
&priv->lec_arp_tables[i], next) { &priv->lec_arp_tables[i], next) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment