lkml.org 
[lkml]   [2022]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 3/3] ARM: orion5x: Add D-Link DNS-323 based on Device Tree
On Thu, Sep 22, 2022, at 10:24 PM, Mauri Sandberg wrote:
> +
> +/* dns323_parse_hex_*() taken from tsx09-common.c; should a common
> copy of these
> + * functions be kept somewhere?
> + */
> +static int __init dns323_parse_hex_nibble(char n)
> +{
> + if (n >= '0' && n <= '9')
> + return n - '0';
> +
> + if (n >= 'A' && n <= 'F')
> + return n - 'A' + 10;
> +
> + if (n >= 'a' && n <= 'f')
> + return n - 'a' + 10;
> +
> + return -1;
> +}
> +
> +static int __init dns323_parse_hex_byte(const char *b)
> +{
> + int hi;
> + int lo;
> +
> + hi = dns323_parse_hex_nibble(b[0]);
> + lo = dns323_parse_hex_nibble(b[1]);
> +
> + if (hi < 0 || lo < 0)
> + return -1;
> +
> + return (hi << 4) | lo;
> +}
> +

Can you use simple_strntoull() to parse the address into a u64 instead?

> +static int __init dns323_read_mac_addr(u8 *addr)
> +{
> + int i;
> + char *mac_page;
> +
> + /* MAC address is stored as a regular ol' string in /dev/mtdblock4
> + * (0x007d0000-0x00800000) starting at offset 196480 (0x2ff80).
> + */
> + mac_page = ioremap(DNS323_NOR_BOOT_BASE + 0x7d0000 + 196480, 1024);
> + if (!mac_page)
> + return -ENOMEM;

It would be nicer to use of_iomap() on the nor device than a
hardcoded physical address here, at least if that doesn't add
too much extra complexity.

Arnd

\
 
 \ /
  Last update: 2022-09-22 23:40    [W:0.866 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site