From: Stephen Boyd <sboyd@codeaurora.org>
To: Bjorn Andersson <bjorn@kryo.se>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
David Brown <davidb@codeaurora.org>,
linux-serial@vger.kernel.org
Subject: Re: [PATCH 3/4] msm_serial: Make baud_code detection more dynamic
Date: Fri, 26 Jul 2013 10:05:21 -0700 [thread overview]
Message-ID: <20130726170521.GA11922@codeaurora.org> (raw)
In-Reply-To: <CAJAp7Og1jwyAn0sGbb_1Bk5_fvBWa1AuDNsRV1b17S0Tijk9kg@mail.gmail.com>
On 07/25, Bjorn Andersson wrote:
> On Wed, Jul 24, 2013 at 10:37 AM, Stephen Boyd <sboyd@codeaurora.org> wrote:
> > [snip]
> > + unsigned int i, divisor;
> > + const struct msm_baud_map *entry;
> > + static const struct msm_baud_map table[] = {
> > + { 1536, 0x00, 1 },
> > + { 768, 0x11, 1 },
> > + { 384, 0x22, 1 },
> > + { 192, 0x33, 1 },
> > + { 96, 0x44, 1 },
> > + { 48, 0x55, 1 },
> > + { 32, 0x66, 1 },
> > + { 24, 0x77, 1 },
> > + { 16, 0x88, 1 },
> > + { 12, 0x99, 6 },
> > + { 8, 0xaa, 6 },
> > + { 6, 0xbb, 6 },
> > + { 4, 0xcc, 6 },
> > + { 3, 0xdd, 8 },
> > + { 2, 0xee, 16 },
> > + { 1, 0xff, 31 },
> > + };
> > +
> > + divisor = uart_get_divisor(port, baud);
> > +
> > + for (i = 0, entry = table; i < ARRAY_SIZE(table); i++, entry++)
> > + if (entry->divisor <= divisor)
> > + break;
> > +
> > + return entry; /* Default to smallest divider */
>
> Shouldn't matter, but you're not defaulting to the smallest divider.
> Your are defaulting to an undefined value, as `entry` will be off the
> array once i == ARRAY_SIZE().
>
Yes because the if condition will always be true. Perhaps that's
too confusing? We could add a subtraction by 1 to make it more
obvious.
for (i = 0; entry = table; i < ARRAY_SIZE(table) - 1; i++, entry++)
if (entry->divisor <= divisor)
break;
return entry; /* Default to smallest divider*/
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
WARNING: multiple messages have this Message-ID (diff)
From: sboyd@codeaurora.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] msm_serial: Make baud_code detection more dynamic
Date: Fri, 26 Jul 2013 10:05:21 -0700 [thread overview]
Message-ID: <20130726170521.GA11922@codeaurora.org> (raw)
In-Reply-To: <CAJAp7Og1jwyAn0sGbb_1Bk5_fvBWa1AuDNsRV1b17S0Tijk9kg@mail.gmail.com>
On 07/25, Bjorn Andersson wrote:
> On Wed, Jul 24, 2013 at 10:37 AM, Stephen Boyd <sboyd@codeaurora.org> wrote:
> > [snip]
> > + unsigned int i, divisor;
> > + const struct msm_baud_map *entry;
> > + static const struct msm_baud_map table[] = {
> > + { 1536, 0x00, 1 },
> > + { 768, 0x11, 1 },
> > + { 384, 0x22, 1 },
> > + { 192, 0x33, 1 },
> > + { 96, 0x44, 1 },
> > + { 48, 0x55, 1 },
> > + { 32, 0x66, 1 },
> > + { 24, 0x77, 1 },
> > + { 16, 0x88, 1 },
> > + { 12, 0x99, 6 },
> > + { 8, 0xaa, 6 },
> > + { 6, 0xbb, 6 },
> > + { 4, 0xcc, 6 },
> > + { 3, 0xdd, 8 },
> > + { 2, 0xee, 16 },
> > + { 1, 0xff, 31 },
> > + };
> > +
> > + divisor = uart_get_divisor(port, baud);
> > +
> > + for (i = 0, entry = table; i < ARRAY_SIZE(table); i++, entry++)
> > + if (entry->divisor <= divisor)
> > + break;
> > +
> > + return entry; /* Default to smallest divider */
>
> Shouldn't matter, but you're not defaulting to the smallest divider.
> Your are defaulting to an undefined value, as `entry` will be off the
> array once i == ARRAY_SIZE().
>
Yes because the if condition will always be true. Perhaps that's
too confusing? We could add a subtraction by 1 to make it more
obvious.
for (i = 0; entry = table; i < ARRAY_SIZE(table) - 1; i++, entry++)
if (entry->divisor <= divisor)
break;
return entry; /* Default to smallest divider*/
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
next prev parent reply other threads:[~2013-07-26 17:05 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-24 18:37 [PATCH 0/4] msm_serial fixes and improvements Stephen Boyd
2013-07-24 18:37 ` Stephen Boyd
2013-07-24 18:37 ` [PATCH 1/4] msm_serial: Fix NUL byte output on UARTDM Stephen Boyd
2013-07-24 18:37 ` Stephen Boyd
2013-07-24 20:29 ` David Brown
2013-07-24 20:29 ` David Brown
2013-07-24 18:37 ` [PATCH 2/4] msm_serial: Fix sparse warnings Stephen Boyd
2013-07-24 18:37 ` Stephen Boyd
2013-07-24 20:30 ` David Brown
2013-07-24 20:30 ` David Brown
2013-07-24 18:37 ` [PATCH 3/4] msm_serial: Make baud_code detection more dynamic Stephen Boyd
2013-07-24 18:37 ` Stephen Boyd
2013-07-24 20:30 ` David Brown
2013-07-24 20:30 ` David Brown
2013-07-26 4:30 ` Bjorn Andersson
2013-07-26 4:30 ` Bjorn Andersson
2013-07-26 17:05 ` Stephen Boyd [this message]
2013-07-26 17:05 ` Stephen Boyd
2013-07-24 18:37 ` [PATCH 4/4] msm_serial: Send more than 1 character at a time on UARTDM Stephen Boyd
2013-07-24 18:37 ` Stephen Boyd
2013-07-24 20:31 ` David Brown
2013-07-24 20:31 ` David Brown
2013-07-24 20:31 ` [PATCH 0/4] msm_serial fixes and improvements David Brown
2013-07-24 20:31 ` David Brown
2013-07-29 9:31 ` Ivan T. Ivanov
2013-07-29 9:31 ` Ivan T. Ivanov
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=20130726170521.GA11922@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=bjorn@kryo.se \
--cc=davidb@codeaurora.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.