* [PATCH] scsi: qedi: tidy up a size caculation
@ 2018-06-28 9:23 Dan Carpenter
2018-06-28 15:15 ` Rangankar, Manish
2018-07-02 20:17 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2018-06-28 9:23 UTC (permalink / raw)
To: kernel-janitors
The id_tbl->table pointer points to unsigned long so static checkers
complain that instead of 4 we should be allocating sizeof(long) bytes.
We're trying to allocate enough bits for the bitmap. The size variable
is always 1024. (1024 / 32 * 4) is the same as (1024 / 64 * 8) so this
doesn't change runtime, but this is the more idiomatic way to do it and
makes the static checker happy.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index cf274a79e77a..682f3ce31014 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -524,7 +524,7 @@ static int qedi_init_id_tbl(struct qedi_portid_tbl *id_tbl, u16 size,
id_tbl->max = size;
id_tbl->next = next;
spin_lock_init(&id_tbl->lock);
- id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL);
+ id_tbl->table = kcalloc(BITS_TO_LONGS(size), sizeof(long), GFP_KERNEL);
if (!id_tbl->table)
return -ENOMEM;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] scsi: qedi: tidy up a size caculation
2018-06-28 9:23 [PATCH] scsi: qedi: tidy up a size caculation Dan Carpenter
@ 2018-06-28 15:15 ` Rangankar, Manish
2018-07-02 20:17 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Rangankar, Manish @ 2018-06-28 15:15 UTC (permalink / raw)
To: kernel-janitors
> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@oracle.com>
> Sent: Thursday, June 28, 2018 2:53 PM
> To: Dept-Eng QLogic Storage Upstream <QLogic-Storage-
> Upstream@cavium.com>; Rangankar, Manish
> <Manish.Rangankar@cavium.com>
> Cc: James E.J. Bottomley <jejb@linux.vnet.ibm.com>; Martin K. Petersen
> <martin.petersen@oracle.com>; linux-scsi@vger.kernel.org; kernel-
> janitors@vger.kernel.org
> Subject: [PATCH] scsi: qedi: tidy up a size caculation
>
> External Email
>
> The id_tbl->table pointer points to unsigned long so static checkers complain
> that instead of 4 we should be allocating sizeof(long) bytes.
>
> We're trying to allocate enough bits for the bitmap. The size variable is always
> 1024. (1024 / 32 * 4) is the same as (1024 / 64 * 8) so this doesn't change
> runtime, but this is the more idiomatic way to do it and makes the static checker
> happy.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index
> cf274a79e77a..682f3ce31014 100644
> --- a/drivers/scsi/qedi/qedi_main.c
> +++ b/drivers/scsi/qedi/qedi_main.c
> @@ -524,7 +524,7 @@ static int qedi_init_id_tbl(struct qedi_portid_tbl *id_tbl,
> u16 size,
> id_tbl->max = size;
> id_tbl->next = next;
> spin_lock_init(&id_tbl->lock);
> - id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL);
> + id_tbl->table = kcalloc(BITS_TO_LONGS(size), sizeof(long),
> + GFP_KERNEL);
> if (!id_tbl->table)
> return -ENOMEM;
Thanks,
Acked-by: Manish Rangankar <Manish.Rangankar@cavium.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: qedi: tidy up a size caculation
2018-06-28 9:23 [PATCH] scsi: qedi: tidy up a size caculation Dan Carpenter
2018-06-28 15:15 ` Rangankar, Manish
@ 2018-07-02 20:17 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2018-07-02 20:17 UTC (permalink / raw)
To: kernel-janitors
Dan,
> The id_tbl->table pointer points to unsigned long so static checkers
> complain that instead of 4 we should be allocating sizeof(long) bytes.
>
> We're trying to allocate enough bits for the bitmap. The size variable
> is always 1024. (1024 / 32 * 4) is the same as (1024 / 64 * 8) so this
> doesn't change runtime, but this is the more idiomatic way to do it and
> makes the static checker happy.
Applied to 4.19/scsi-queue, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-02 20:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-28 9:23 [PATCH] scsi: qedi: tidy up a size caculation Dan Carpenter
2018-06-28 15:15 ` Rangankar, Manish
2018-07-02 20:17 ` Martin K. Petersen
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).