From: Mike Frysinger <vapier.adi@gmail.com>
To: graff yang <graff.yang@gmail.com>
Cc: gyang <graf.yang@analog.com>,
samuel@sortiz.org, irda-users@lists.sourceforge.net,
linux-kernel@vger.kernel.org, cooloney@kernel.org
Subject: Re: [PATCH] [net/irda]: new Blackfin on-chip SIR IrDA driver
Date: Thu, 12 Mar 2009 02:24:16 -0400 [thread overview]
Message-ID: <8bd0f97a0903112324p3ecae9f9i44f9338f90cac85@mail.gmail.com> (raw)
In-Reply-To: <7d86d44a0903112255m34392231ne0cd04196e33f1b2@mail.gmail.com>
On Thu, Mar 12, 2009 at 01:55, graff yang wrote:
> On Thu, Mar 12, 2009 at 12:59 PM, Mike Frysinger wrote:
>> On Thu, Mar 12, 2009 at 00:48, gyang wrote:
>>> On Thu, 2009-03-12 at 00:34 -0400, Mike Frysinger wrote:
>>>> On Thu, Mar 12, 2009 at 00:30, gyang wrote:
>>>> > On Thu, 2009-03-12 at 00:23 -0400, Mike Frysinger wrote:
>>>> >> On Thu, Mar 12, 2009 at 00:17, gyang wrote:
>>>> >> > On Wed, 2009-03-11 at 06:43 -0400, Mike Frysinger wrote:
>>>> >> >> On Wed, Mar 11, 2009 at 05:56, graff yang wrote:
>>>> >> >> > On Wed, Mar 11, 2009 at 3:57 PM, Mike Frysinger wrote:
>>>> >> >> >> On Wed, Mar 11, 2009 at 03:29, <graff.yang@gmail.com> wrote:
>>>> >> >> >>> +static int __devinit bfin_sir_probe(struct platform_device *pdev)
>>>> >> >> >>> +{
>>>> >> >> >>> + struct net_device *dev;
>>>> >> >> >>> + struct bfin_sir_self *self;
>>>> >> >> >>> + unsigned int baudrate_mask;
>>>> >> >> >>> + struct bfin_sir_port *sir_port;
>>>> >> >> >>> + int err;
>>>> >> >> >>> +
>>>> >> >> >>> + err = peripheral_request_list(per[pdev->id], DRIVER_NAME);
>>>> >> >> >>
>>>> >> >> >> what if pdev->id is set to 12512 ?
>>>> >> >> >
>>>> >> >> > The pdev->id is defined in board files, for example, uart0 should be 0.
>>>> >> >>
>>>> >> >> so ? what's to stop the user from setting it to 12415 ? the driver
>>>> >> >> must sanity check these things. you can never assume platform dev
>>>> >> >> resources always have valid pointers and valid values.
>>>> >> >
>>>> >> > How about to limit the pdev->id to be 0,1,2,3 ?
>>>> >> > I can extend the per to be
>>>> >> > static const unsigned short per[][4] = {
>>>> >> > {P_UART0_RX, P_UART0_TX, 0, 0},
>>>> >> > {P_UART1_RX, P_UART1_TX, 0, 1},
>>>> >> > {P_UART2_RX, P_UART2_TX, 0, 2},
>>>> >> > {P_UART3_RX, P_UART3_TX, 0, 3},
>>>> >> > };
>>>> >> >
>>>> >> > then check (pdev->id >= 0 && pdev->id < ARRAY_SIZE(per) &&
>>>> >> > per[pdev->id][3] == pdev->id)
>>>> >>
>>>> >> the last check is redundant. the first two should be added.
>>>> >
>>>> > I'm afraid of some cases such as uart0 uses id 1, will cause driver not
>>>> > work, and not any warning message.
>>>>
>>>> then the call to peripheral request would fail as expected
>>>
>>> For example, user want to enable irda on uart2 for bf548, he use id 0
>>> for uart2. In these case, peripheral request may not fail, but driver
>>> not work.
>>
>> the id is wrong then. if they want uart2, then they should use id 2.
>
> Such wrong case may existed for common users, and should be
> prohibited. Driver need make sanity check to prevent it.
i dont know what you're talking about. if the platform resource uses
id of 2, then they want uart2 which means irda2. the sanity check is
already in place because the peripheral_request() will fail when it
attempts to claim the pins of uart2 but the uart driver has already
been enabled for it.
-mike
next prev parent reply other threads:[~2009-03-12 6:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-11 7:29 graff.yang
2009-03-11 7:37 ` Bryan Wu
[not found] ` <7d86d44a0903110117m4fc28b8bl5011493428d5a348@mail.gmail.com>
2009-03-11 8:46 ` Bryan Wu
2009-03-11 7:57 ` Mike Frysinger
2009-03-11 9:56 ` graff yang
2009-03-11 10:43 ` Mike Frysinger
2009-03-12 4:17 ` gyang
2009-03-12 4:23 ` Mike Frysinger
2009-03-12 4:30 ` gyang
2009-03-12 4:34 ` Mike Frysinger
2009-03-12 4:48 ` gyang
2009-03-12 4:59 ` Mike Frysinger
2009-03-12 5:55 ` graff yang
2009-03-12 6:24 ` Mike Frysinger [this message]
2009-03-12 7:43 ` graff yang
-- strict thread matches above, loose matches on Subject: below --
2009-03-10 7:29 graff.yang
2009-03-10 8:03 ` Mike Frysinger
[not found] ` <7d86d44a0903100425y2ed41d72p3ec43021f554af96@mail.gmail.com>
2009-03-10 11:29 ` Mike Frysinger
2009-03-10 11:41 ` Alan Cox
2009-03-10 11:47 ` Mike Frysinger
2009-03-10 11:48 ` gyang
2009-03-10 11:53 ` Mike Frysinger
2009-03-06 6:44 Bryan Wu
2009-03-06 22:58 ` Andrew Morton
2009-03-09 4:35 ` gyang
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=8bd0f97a0903112324p3ecae9f9i44f9338f90cac85@mail.gmail.com \
--to=vapier.adi@gmail.com \
--cc=cooloney@kernel.org \
--cc=graf.yang@analog.com \
--cc=graff.yang@gmail.com \
--cc=irda-users@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=samuel@sortiz.org \
/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
all inboxes | Powered by JetHome®