All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	od@opendingux.net,
	"open list:BROADCOM NVRAM DRIVER" <linux-mips@vger.kernel.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pinctrl: ingenic: Garbage-collect code paths for SoCs disabled by config
Date: Wed, 16 Mar 2022 16:47:24 +0200	[thread overview]
Message-ID: <CAHp75Vfas=H7Vb+mJor-LWckUpE8QUdD8Yauq4mdG4OY+7dfMg@mail.gmail.com> (raw)
In-Reply-To: <20220315173922.153389-1-paul@crapouillou.net>

On Wed, Mar 16, 2022 at 4:11 AM Paul Cercueil <paul@crapouillou.net> wrote:
>
> By being a bit smarter about how the SoC version checks are performed,
> it is possible to have all the code paths that correspond to SoCs
> disabled in the kernel config automatically marked as dead code by the
> compiler, and therefore garbage-collected.
>
> With this patch, when compiling a kernel that only targets the JZ4760
> for instance, the driver is now about 4.5 KiB smaller.

...

> +static const u32 enabled_socs =

If you make it unsigned long, it would be easier to switch to bitmap
APIs if needed in the future.

> +       IS_ENABLED(CONFIG_MACH_JZ4730) << ID_JZ4730 |
> +       IS_ENABLED(CONFIG_MACH_JZ4740) << ID_JZ4740 |
> +       IS_ENABLED(CONFIG_MACH_JZ4725B) << ID_JZ4725B |
> +       IS_ENABLED(CONFIG_MACH_JZ4750) << ID_JZ4750 |
> +       IS_ENABLED(CONFIG_MACH_JZ4755) << ID_JZ4755 |
> +       IS_ENABLED(CONFIG_MACH_JZ4760) << ID_JZ4760 |
> +       IS_ENABLED(CONFIG_MACH_JZ4770) << ID_JZ4770 |
> +       IS_ENABLED(CONFIG_MACH_JZ4775) << ID_JZ4775 |
> +       IS_ENABLED(CONFIG_MACH_JZ4780) << ID_JZ4780 |
> +       IS_ENABLED(CONFIG_MACH_X1000) << ID_X1000 |
> +       IS_ENABLED(CONFIG_MACH_X1500) << ID_X1500 |
> +       IS_ENABLED(CONFIG_MACH_X1830) << ID_X1830 |
> +       IS_ENABLED(CONFIG_MACH_X2000) << ID_X2000 |
> +       IS_ENABLED(CONFIG_MACH_X2100) << ID_X2100;

...

> +is_soc_or_above(const struct ingenic_pinctrl *jzpc, enum jz_version version)
> +{
> +       return (enabled_socs >> version) &&
> +               (!(enabled_socs & GENMASK((unsigned int)version - 1, 0))

Why casting? Why not use BIT()?

But these two lines seem like a very interesting way to reinvent the test_bit().

If I'm mistaken, this all version code needs a good comment.

> +                || jzpc->info->version >= version);
> +}

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2022-03-16 14:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 17:39 [PATCH] pinctrl: ingenic: Garbage-collect code paths for SoCs disabled by config Paul Cercueil
2022-03-16 14:47 ` Andy Shevchenko [this message]
2022-03-16 15:05   ` Paul Cercueil
2022-03-16 15:37     ` Andy Shevchenko
2022-03-16 16:03       ` Paul Cercueil
2022-03-16 16:20         ` Andy Shevchenko
2022-03-16 16:45           ` Paul Cercueil

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='CAHp75Vfas=H7Vb+mJor-LWckUpE8QUdD8Yauq4mdG4OY+7dfMg@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=od@opendingux.net \
    --cc=paul@crapouillou.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 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.