From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
To: broonie@kernel.org
Cc: gregkh@linuxfoundation.org, rafael@kernel.org,
andy.shevchenko@gmail.com, mazziesaccount@gmail.com,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 03/12] regmap-irq: Cleanup sizeof(...) use in memory allocation
Date: Thu, 23 Jun 2022 22:14:11 +0100 [thread overview]
Message-ID: <20220623211420.918875-4-aidanmacdonald.0x0@gmail.com> (raw)
In-Reply-To: <20220623211420.918875-1-aidanmacdonald.0x0@gmail.com>
Instead of mentioning unsigned int directly, use a sizeof(...)
involving the buffer we're allocating to ensure the types don't
get out of sync.
Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
---
drivers/base/regmap/regmap-irq.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 475a959e2b8b..dca27b4e29d3 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -670,30 +670,30 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
if (chip->num_main_regs) {
d->main_status_buf = kcalloc(chip->num_main_regs,
- sizeof(unsigned int),
+ sizeof(*d->main_status_buf),
GFP_KERNEL);
if (!d->main_status_buf)
goto err_alloc;
}
- d->status_buf = kcalloc(chip->num_regs, sizeof(unsigned int),
+ d->status_buf = kcalloc(chip->num_regs, sizeof(*d->status_buf),
GFP_KERNEL);
if (!d->status_buf)
goto err_alloc;
- d->mask_buf = kcalloc(chip->num_regs, sizeof(unsigned int),
+ d->mask_buf = kcalloc(chip->num_regs, sizeof(*d->mask_buf),
GFP_KERNEL);
if (!d->mask_buf)
goto err_alloc;
- d->mask_buf_def = kcalloc(chip->num_regs, sizeof(unsigned int),
+ d->mask_buf_def = kcalloc(chip->num_regs, sizeof(*d->mask_buf_def),
GFP_KERNEL);
if (!d->mask_buf_def)
goto err_alloc;
if (chip->wake_base) {
- d->wake_buf = kcalloc(chip->num_regs, sizeof(unsigned int),
+ d->wake_buf = kcalloc(chip->num_regs, sizeof(*d->wake_buf),
GFP_KERNEL);
if (!d->wake_buf)
goto err_alloc;
@@ -702,11 +702,11 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
num_type_reg = chip->type_in_mask ? chip->num_regs : chip->num_type_reg;
if (num_type_reg) {
d->type_buf_def = kcalloc(num_type_reg,
- sizeof(unsigned int), GFP_KERNEL);
+ sizeof(*d->type_buf_def), GFP_KERNEL);
if (!d->type_buf_def)
goto err_alloc;
- d->type_buf = kcalloc(num_type_reg, sizeof(unsigned int),
+ d->type_buf = kcalloc(num_type_reg, sizeof(*d->type_buf),
GFP_KERNEL);
if (!d->type_buf)
goto err_alloc;
@@ -723,7 +723,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
for (i = 0; i < chip->num_virt_regs; i++) {
d->virt_buf[i] = kcalloc(chip->num_regs,
- sizeof(unsigned int),
+ sizeof(**d->virt_buf),
GFP_KERNEL);
if (!d->virt_buf[i])
goto err_alloc;
--
2.35.1
next prev parent reply other threads:[~2022-06-23 21:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-23 21:14 [PATCH v2 00/12] regmap-irq cleanups and refactoring Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 01/12] regmap-irq: Convert bool bitfields to unsigned int Aidan MacDonald
2022-06-23 21:26 ` Andy Shevchenko
2022-06-24 12:11 ` Mark Brown
2022-06-24 12:46 ` Joe Perches
2022-06-24 12:56 ` Mark Brown
2022-06-24 13:05 ` Aidan MacDonald
2022-06-24 13:45 ` Joe Perches
2022-06-24 14:28 ` David Laight
2022-06-24 14:31 ` Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 02/12] regmap-irq: Remove unused type_reg_stride field Aidan MacDonald
2022-06-23 21:14 ` Aidan MacDonald [this message]
2022-06-23 21:14 ` [PATCH v2 04/12] regmap-irq: Remove an unnecessary restriction on type_in_mask Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 05/12] regmap-irq: Remove inappropriate uses of regmap_irq_update_bits() Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 06/12] regmap-irq: Remove mask_writeonly and regmap_irq_update_bits() Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 07/12] regmap-irq: Refactor checks for status bulk read support Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 08/12] regmap-irq: Introduce config registers for irq types Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 09/12] regmap-irq: Deprecate type registers and virtual registers Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 10/12] regmap-irq: Fix inverted handling of unmask registers Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 11/12] regmap-irq: Add get_irq_reg() callback Aidan MacDonald
[not found] ` <CGME20220701163330eucas1p13456e7757d9d2bc8d0aa35c16f143590@eucas1p1.samsung.com>
2022-07-01 16:33 ` Marek Szyprowski
2022-07-03 11:06 ` Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 12/12] regmap-irq: Deprecate the not_fixed_stride flag Aidan MacDonald
2022-06-30 17:27 ` [PATCH v2 00/12] regmap-irq cleanups and refactoring Mark Brown
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=20220623211420.918875-4-aidanmacdonald.0x0@gmail.com \
--to=aidanmacdonald.0x0@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=rafael@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 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).