From: Andrew Morton <akpm@linux-foundation.org>
To: Philip Prindeville <philipp@redfish-solutions.com>
Cc: linux-kernel@vger.kernel.org, Richard Purdie <rpurdie@rpsys.net>,
Alessandro Zummo <a.zummo@towertech.it>
Subject: Re: [PATCH 1/1] net5501: platform driver for Soekris Engineering net5501 single-board computer
Date: Fri, 27 Jan 2012 14:59:07 -0800 [thread overview]
Message-ID: <20120127145907.dfd5f8a0.akpm@linux-foundation.org> (raw)
In-Reply-To: <1325323722-25930-1-git-send-email-philipp@redfish-solutions.com>
On Sat, 31 Dec 2011 02:28:42 -0700
Philip Prindeville <philipp@redfish-solutions.com> wrote:
> From: "Philip A. Prindeville" <philipp@redfish-solutions.com>
>
> Trivial platform driver for Soekris Engineering net5501 single-board
> computer. Probes well-known locations in ROM for BIOS signature to
> confirm correct platform. Registers 1 LED and 1 GPIO-based button
> (typically used for soft reset).
>
>
> ...
>
> +static int __init net5501_present(void)
> +{
> + int i;
> + unsigned char *rombase, *bios;
> +
> + rombase = ioremap(BIOS_REGION_BASE, BIOS_REGION_SIZE - 1);
> + if (!rombase)
> + printk(KERN_INFO "Soekris net5501 LED driver failed to get rombase");
It seems wrong to continue if ioremap() failed. It should return
-ENOMEM here. And perhaps boost the KERN_INFO to KERN_ERR?
> + bios = rombase + 0x20; /* null terminated */
> +
> + if (memcmp(bios, "comBIOS", 7))
> + goto unmap;
> +
> + for (i = 0; i < ARRAY_SIZE(boards); i++) {
> + unsigned char *model = rombase + boards[i].offset;
> +
> + if (memcmp(model, boards[i].sig, boards[i].len) == 0) {
> + printk(KERN_INFO "Soekris %s: %s\n", model, bios);
> +
> + register_net5501();
> + break;
> + }
> + }
> +
> +unmap:
> + iounmap(rombase);
> + return 0;
> +}
> +
> +static int __init net5501_init(void)
> +{
> + if (!is_geode())
> + return 0;
> +
> + if (net5501_present())
> + register_net5501();
This makes no sense. net5501_present() always returns zero so
register_net5501() is never called. net5501_present() itself calls
register_net5501(), so perhaps this is just dead code.
It seems cleaner to me to do the register_net5501() call from
net5501_init(). A function called "foo_present()" should test for the
presence of foo (and return a bool!) - we don't expect it to run off
and register things.
I assume this code is all runtime tested?
>
> ...
>
next prev parent reply other threads:[~2012-01-27 22:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-31 9:28 [PATCH 1/1] net5501: platform driver for Soekris Engineering net5501 single-board computer Philip Prindeville
2012-01-27 22:59 ` Andrew Morton [this message]
2012-01-28 5:02 ` [PATCH v2 " Philip Prindeville
2012-01-31 22:19 ` Andrew Morton
2012-02-01 1:38 ` Philip Prindeville
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120127145907.dfd5f8a0.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=a.zummo@towertech.it \
--cc=linux-kernel@vger.kernel.org \
--cc=philipp@redfish-solutions.com \
--cc=rpurdie@rpsys.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).