[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f6a27b077f8b595e9c74152f1fa3c780@ext.kapsi.fi>
Date: Fri, 23 Sep 2022 12:13:24 +0300
From: maukka@....kapsi.fi
To: Arnd Bergmann <arnd@...db.de>
Cc: Rob Herring <robh+dt@...nel.org>,
krzysztof.kozlowski+dt@...aro.org, Olof Johansson <olof@...om.net>,
Andrew Lunn <andrew@...n.ch>,
Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>,
Gregory Clement <gregory.clement@...tlin.com>,
Russell King <linux@...linux.org.uk>,
Pali Rohár <pali@...nel.org>,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v2 3/3] ARM: orion5x: Add D-Link DNS-323 based on Device
Tree
On 23.9.2022 00:39, Arnd Bergmann wrote:
> 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?
>
Nice idea. Its current replacement seems to be kstrtoull(). I'll have to
do
it byte by byte, right? Or what do you have in mind with 64bit unsigned?
>> +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.
>
I'll look into this.
Powered by blists - more mailing lists