Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78630
b: refs/heads/master
c: 7ffc49a
h: refs/heads/master
v: v3
  • Loading branch information
Michael Chan authored and David S. Miller committed Jan 28, 2008
1 parent 3caf9ca commit ded53a4
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 21371f768bf7127ee45bfaadd17899df6a439e8f
refs/heads/master: 7ffc49a6ee92b7138c2ee28073a8e10e58335d62
14 changes: 1 addition & 13 deletions trunk/drivers/scsi/qla4xxx/ql4_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,6 @@ static void qla4xxx_conn_stop(struct iscsi_cls_conn *conn, int flag)
printk(KERN_ERR "iscsi: invalid stop flag %d\n", flag);
}

static ssize_t format_addr(char *buf, const unsigned char *addr, int len)
{
int i;
char *cp = buf;

for (i = 0; i < len; i++)
cp += sprintf(cp, "%02x%c", addr[i],
i == (len - 1) ? '\n' : ':');
return cp - buf;
}


static int qla4xxx_host_get_param(struct Scsi_Host *shost,
enum iscsi_host_param param, char *buf)
{
Expand All @@ -193,7 +181,7 @@ static int qla4xxx_host_get_param(struct Scsi_Host *shost,

switch (param) {
case ISCSI_HOST_PARAM_HWADDRESS:
len = format_addr(buf, ha->my_mac, MAC_ADDR_LEN);
len = sysfs_format_mac(buf, ha->my_mac, MAC_ADDR_LEN);
break;
case ISCSI_HOST_PARAM_IPADDRESS:
len = sprintf(buf, "%d.%d.%d.%d\n", ha->ip_address[0],
Expand Down
8 changes: 5 additions & 3 deletions trunk/include/linux/if_ether.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
extern struct ctl_table ether_table[];
#endif

extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);

/*
* Display a 6 byte device address (MAC) in a readable format.
*/
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
extern char *print_mac(char *buf, const u8 *addr);
#define DECLARE_MAC_BUF(var) char var[18] __maybe_unused
extern char *print_mac(char *buf, const unsigned char *addr);
#define MAC_BUF_SIZE 18
#define DECLARE_MAC_BUF(var) char var[MAC_BUF_SIZE] __maybe_unused

#endif

Expand Down
15 changes: 2 additions & 13 deletions trunk/net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ NETDEVICE_SHOW(type, fmt_dec);
NETDEVICE_SHOW(link_mode, fmt_dec);

/* use same locking rules as GIFHWADDR ioctl's */
static ssize_t format_addr(char *buf, const unsigned char *addr, int len)
{
int i;
char *cp = buf;

for (i = 0; i < len; i++)
cp += sprintf(cp, "%02x%c", addr[i],
i == (len - 1) ? '\n' : ':');
return cp - buf;
}

static ssize_t show_address(struct device *dev, struct device_attribute *attr,
char *buf)
{
Expand All @@ -114,7 +103,7 @@ static ssize_t show_address(struct device *dev, struct device_attribute *attr,

read_lock(&dev_base_lock);
if (dev_isalive(net))
ret = format_addr(buf, net->dev_addr, net->addr_len);
ret = sysfs_format_mac(buf, net->dev_addr, net->addr_len);
read_unlock(&dev_base_lock);
return ret;
}
Expand All @@ -124,7 +113,7 @@ static ssize_t show_broadcast(struct device *dev,
{
struct net_device *net = to_net_dev(dev);
if (dev_isalive(net))
return format_addr(buf, net->broadcast, net->addr_len);
return sysfs_format_mac(buf, net->broadcast, net->addr_len);
return -EINVAL;
}

Expand Down
30 changes: 27 additions & 3 deletions trunk/net/ethernet/eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,34 @@ struct net_device *alloc_etherdev_mq(int sizeof_priv, unsigned int queue_count)
}
EXPORT_SYMBOL(alloc_etherdev_mq);

char *print_mac(char *buf, const u8 *addr)
static size_t _format_mac_addr(char *buf, int buflen,
const unsigned char *addr, int len)
{
sprintf(buf, MAC_FMT,
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
int i;
char *cp = buf;

for (i = 0; i < len; i++) {
cp += scnprintf(cp, buflen - (cp - buf), "%02x", addr[i]);
if (i == len - 1)
break;
cp += strlcpy(cp, ":", buflen - (cp - buf));
}
return cp - buf;
}

ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len)
{
size_t l;

l = _format_mac_addr(buf, PAGE_SIZE, addr, len);
l += strlcpy(buf + l, "\n", PAGE_SIZE - l);
return ((ssize_t) l);
}
EXPORT_SYMBOL(sysfs_format_mac);

char *print_mac(char *buf, const unsigned char *addr)
{
_format_mac_addr(buf, MAC_BUF_SIZE, addr, ETH_ALEN);
return buf;
}
EXPORT_SYMBOL(print_mac);

0 comments on commit ded53a4

Please sign in to comment.