From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Levente Révész" <levente.revesz@eilabs.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Martyn Welch <martyn.welch@collabora.com>,
Haibo Chen <haibo.chen@nxp.com>, Puyou Lu <puyou.lu@gmail.com>,
Justin Chen <justinpopo6@gmail.com>,
Andrey Gusakov <andrey.gusakov@cogentembedded.com>,
Nate Drude <nate.d@variscite.com>,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH v2 1/6] gpio: pca953x: Convert PCA_TYPE from bits to number
Date: Wed, 26 Oct 2022 20:18:57 +0300 [thread overview]
Message-ID: <Y1lsAZX1vCOZkPCR@smile.fi.intel.com> (raw)
In-Reply-To: <0de783a2-d35c-6f20-4c22-86d6cd8dbc41@eilabs.com>
On Wed, Oct 26, 2022 at 01:18:57PM +0200, Levente Révész wrote:
> There are 3 chip types already in the driver:
>
> * PCA953X_TYPE (standard register set, + pcal chips have extended set)
PCAL
> * PCAL653X_TYPE (standard + extended register set, different spacing)
> * PCA957X_TYPE (standard + other registers, different addresses)
>
> A later patch in this series adds yet another type. This would take up all
> 4 bits allocated to chip type information in driver_data, leaving no space
> for new types in the future.
>
> Convert PCA_TYPE defines from bits to numbers.
>
> Replace if-else statements with cleaner switch statements. This makes it
> easier to add new types.
Suggested-by: ?
> Signed-off-by: Levente Révész <levente.revesz@eilabs.com>
...
> -#define PCA953X_TYPE BIT(12)
> -#define PCA957X_TYPE BIT(13)
> -#define PCAL653X_TYPE BIT(14)
> +#define PCA953X_TYPE (0x00 << 12)
> +#define PCAL653X_TYPE (0x02 << 12)
> +#define PCA957X_TYPE (0x03 << 12)
> #define PCA_TYPE_MASK GENMASK(15, 12)
Please, use decimal numbers and drop the shifts...
> #define PCA_CHIP_TYPE(x) ((x) & PCA_TYPE_MASK)
...instead add a shift here.
...
I think you can consider adding default case to each of the new switch-case.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-10-26 17:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-26 11:17 [PATCH v2 0/6] gpio: pca953x: Add interrupt mask support for pca953x chips Levente Révész
2022-10-26 11:18 ` [PATCH v2 1/6] gpio: pca953x: Convert PCA_TYPE from bits to number Levente Révész
2022-10-26 17:18 ` Andy Shevchenko [this message]
2022-10-26 17:21 ` Andy Shevchenko
2022-10-26 11:21 ` [PATCH v2 2/6] gpio: pca953x: Add PCAL953X as a separate chip type Levente Révész
2022-10-26 17:25 ` Andy Shevchenko
2022-10-26 17:28 ` Andy Shevchenko
2022-10-27 13:36 ` Levente Révész
2022-10-27 13:54 ` Martyn Welch
2022-10-27 17:03 ` Andy Shevchenko
2022-10-28 18:57 ` Levente Révész
2022-11-16 13:51 ` Levente Révész
2025-02-26 14:02 ` Andy Shevchenko
2022-10-26 11:22 ` [PATCH v2 3/6] gpio: pca953x: Add helper function to check if chip has interrupts Levente Révész
2022-10-26 11:23 ` [PATCH v2 4/6] gpio: pca953x: Generalize interrupt mask register handling Levente Révész
2022-10-26 17:31 ` Andy Shevchenko
2022-10-26 11:25 ` [PATCH v2 5/6] gpio: pca953x: Add interrupt mask support for chips with the standard register set Levente Révész
2022-10-26 16:49 ` kernel test robot
2022-10-26 17:32 ` Andy Shevchenko
2022-10-26 22:13 ` kernel test robot
2022-10-26 22:13 ` kernel test robot
2022-10-26 11:26 ` [PATCH v2 6/6] gpio: pca953x: Enable interrupt for pca9698 Levente Révész
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=Y1lsAZX1vCOZkPCR@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=andrey.gusakov@cogentembedded.com \
--cc=brgl@bgdev.pl \
--cc=haibo.chen@nxp.com \
--cc=justinpopo6@gmail.com \
--cc=levente.revesz@eilabs.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=martyn.welch@collabora.com \
--cc=nate.d@variscite.com \
--cc=puyou.lu@gmail.com \
/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).