From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 09/13] ARM: tegra: use clrsetbits_le32 in pinmux driver
Date: Tue, 25 Mar 2014 09:54:30 -0600 [thread overview]
Message-ID: <5331A6B6.8090805@wwwdotorg.org> (raw)
In-Reply-To: <CAPnjgZ262kWYJEuwEL-+WYKVTd9XxWgT6mzH-XhLirpEKen59Q@mail.gmail.com>
On 03/24/2014 08:27 PM, Simon Glass wrote:
> Hi Stephen,
>
> On 21 March 2014 11:28, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> This removes a bunch of open-coded register IO, masking, and shifting.
>> I would have squashed this into "ARM: tegra: pinctrl: remove duplication"
>> except that keeping it a separate commit allows easier bisection of any
>> issues that are introduced by this patch. I also wrote this patch on top
>> of the series, and pushing it any lower in the series results in some
>> conflicts I didn't feel like fixing.
>>
>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>
> Acked-by: Simon Glass <sjg@chromium.org>
>
> But see comment below.
>> diff --git a/arch/arm/cpu/tegra-common/pinmux-common.c b/arch/arm/cpu/tegra-common/pinmux-common.c
>> +static inline void update_field(u32 *reg, u32 mask, u32 shift, u32 val)
>> +{
>> + clrsetbits_le32(reg, mask << shift, val << shift);
>
> I wonder if it would be better to write this out explicitly in each site.
>
>> +}
>> +
>> void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func)
>> {
>> u32 *reg = MUX_REG(pin);
>> int i, mux = -1;
>> - u32 val;
>>
>> /* Error check on pin and func */
>> assert(pmux_pingrp_isvalid(pin));
>> @@ -110,42 +114,29 @@ void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func)
>> }
>> assert(mux != -1);
>>
>> - val = readl(reg);
>> - val &= ~(3 << MUX_SHIFT(pin));
>> - val |= (mux << MUX_SHIFT(pin));
>> - writel(val, reg);
>> + update_field(reg, 3, MUX_SHIFT(pin), mux);
>
> Because here you are obscuring the shift - the parameter order is by
> no means obvious.
Well, for pretty much no function is it obvious from the function name
what the parameter order is; it's just one of those things you memorize
or look up. The exact same issue exists for clrsetbits_le32() itself IMHO.
> Or perhaps update_reg_mask_shift_val()?
Still, I can rename the function if you want; it certainly does make it
obvious. It's rather a long name though, but I guess wrapping the
parameters isn't too bad.
next prev parent reply other threads:[~2014-03-25 15:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-21 18:28 [U-Boot] [PATCH V2 00/13] ARM: tegra: pinmux driver cleanup Stephen Warren
2014-03-21 18:28 ` [U-Boot] [PATCH V2 01/13] ARM: tegra: pinctrl: remove func_safe Stephen Warren
2014-03-21 18:28 ` [U-Boot] [PATCH V2 02/13] ARM: tegra: pinctrl: remove vddio Stephen Warren
2014-03-21 18:28 ` [U-Boot] [PATCH V2 03/13] ARM: tegra: pinctrl: make pmux_func values consistent on Tegra20 Stephen Warren
2014-03-21 18:28 ` [U-Boot] [PATCH V2 04/13] ARM: tegra: prototype pinmux_init() in board.h Stephen Warren
2014-03-21 18:28 ` [U-Boot] [PATCH V2 05/13] ARM: tegra: use apb_misc.h in more places Stephen Warren
2014-03-25 2:17 ` Simon Glass
2014-03-21 18:28 ` [U-Boot] [PATCH V2 06/13] ARM: tegra: pinctrl: remove duplication Stephen Warren
2014-03-25 2:23 ` Simon Glass
2014-03-21 18:28 ` [U-Boot] [PATCH V2 07/13] ARM: tegra: reduce public pinmux API Stephen Warren
2014-03-21 18:28 ` [U-Boot] [PATCH V2 08/13] ARM: tegra: pinmux naming consistency fixes Stephen Warren
2014-03-25 2:24 ` Simon Glass
2014-03-21 18:28 ` [U-Boot] [PATCH V2 09/13] ARM: tegra: use clrsetbits_le32 in pinmux driver Stephen Warren
2014-03-25 2:27 ` Simon Glass
2014-03-25 15:54 ` Stephen Warren [this message]
2014-03-25 16:04 ` Simon Glass
2014-03-25 16:28 ` Stephen Warren
2014-03-25 16:51 ` Wolfgang Denk
2014-03-25 16:55 ` Stephen Warren
2014-03-25 17:03 ` Wolfgang Denk
2014-03-25 17:26 ` Stephen Warren
2014-03-25 19:11 ` Wolfgang Denk
2014-03-21 18:28 ` [U-Boot] [PATCH V2 10/13] ARM: tegra: Tegra20 pinmux cleanup Stephen Warren
2014-03-25 2:29 ` Simon Glass
2014-03-21 18:28 ` [U-Boot] [PATCH V2 11/13] ARM: tegra: Tegra30 " Stephen Warren
2014-03-25 2:30 ` Simon Glass
2014-03-21 18:29 ` [U-Boot] [PATCH V2 12/13] ARM: tegra: Tegra114 " Stephen Warren
2014-03-21 18:29 ` [U-Boot] [PATCH V2 13/13] ARM: tegra: Tegra124 " Stephen Warren
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=5331A6B6.8090805@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--cc=u-boot@lists.denx.de \
/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.