[pxa] refresh 2.6.21 patches
[openwrt.git] / target / linux / pxa / patches-2.6.21 / 012-serial-ether-addr.patch
1 --- a/drivers/usb/gadget/ether.c
2 +++ b/drivers/usb/gadget/ether.c
3 @@ -2249,6 +2249,38 @@ static u8 __devinit nibble (unsigned cha
4 return 0;
5 }
6
7 +static inline unsigned int is_gumstix_oui(u8 *addr)
8 +{
9 + return (addr[0] == 0x00 && addr[1] == 0x15 && addr[2] == 0xC9);
10 +}
11 +
12 +/**
13 + * gen_serial_ether_addr - Generate software assigned Ethernet address
14 + * based on the system_serial number
15 + * @addr: Pointer to a six-byte array containing the Ethernet address
16 + *
17 + * Generate an Ethernet address (MAC) that is not multicast
18 + * and has the local assigned bit set, keyed on the system_serial
19 + */
20 +static inline void gen_serial_ether_addr(u8 *addr)
21 +{
22 + static u8 ether_serial_digit = 0;
23 + addr [0] = system_serial_high >> 8;
24 + addr [1] = system_serial_high;
25 + addr [2] = system_serial_low >> 24;
26 + addr [3] = system_serial_low >> 16;
27 + addr [4] = system_serial_low >> 8;
28 + addr [5] = (system_serial_low & 0xc0) | /* top bits are from system serial */
29 + (2 << 4) | /* 2 bits identify interface type 1=ether, 2=usb, 3&4 undef */
30 + ((ether_serial_digit++) & 0x0f); /* 15 possible interfaces of each type */
31 +
32 + if(!is_gumstix_oui(addr))
33 + {
34 + addr [0] &= 0xfe; /* clear multicast bit */
35 + addr [0] |= 0x02; /* set local assignment bit (IEEE802) */
36 + }
37 +}
38 +
39 static int __devinit get_ether_addr(const char *str, u8 *dev_addr)
40 {
41 if (str) {
42 @@ -2266,8 +2298,16 @@ static int __devinit get_ether_addr(cons
43 if (is_valid_ether_addr (dev_addr))
44 return 0;
45 }
46 - random_ether_addr(dev_addr);
47 - return 1;
48 + if(system_serial_high | system_serial_low)
49 + {
50 + gen_serial_ether_addr(dev_addr);
51 + return 0;
52 + }
53 + else
54 + {
55 + random_ether_addr(dev_addr);
56 + return 1;
57 + }
58 }
59
60 static int __devinit
This page took 0.053756 seconds and 5 git commands to generate.