staging: gasket: use sizeof(*p) for memory allocation

Use sizeof(*p) instead of sizeof(struct P) for memory allocation. This
change complies with the Linux kernel coding style. It improves
readability and decreases the opportunity for bugs if the pointer
variable type is changed. Issue found by checkpatch.

Signed-off-by: Kimberly Brown <kimbrownkd@gmail.com>
Acked-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Kimberly Brown 2018-10-25 20:04:55 -04:00 committed by Greg Kroah-Hartman
parent 651022382c
commit cd27f56fce
2 changed files with 10 additions and 10 deletions

View File

@ -184,7 +184,7 @@ gasket_interrupt_msix_init(struct gasket_interrupt_data *interrupt_data)
interrupt_data->msix_entries =
kcalloc(interrupt_data->num_interrupts,
sizeof(struct msix_entry), GFP_KERNEL);
sizeof(*interrupt_data->msix_entries), GFP_KERNEL);
if (!interrupt_data->msix_entries)
return -ENOMEM;
@ -322,8 +322,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
const struct gasket_driver_desc *driver_desc =
gasket_get_driver_desc(gasket_dev);
interrupt_data = kzalloc(sizeof(struct gasket_interrupt_data),
GFP_KERNEL);
interrupt_data = kzalloc(sizeof(*interrupt_data), GFP_KERNEL);
if (!interrupt_data)
return -ENOMEM;
gasket_dev->interrupt_data = interrupt_data;
@ -336,17 +335,17 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
interrupt_data->pack_width = driver_desc->interrupt_pack_width;
interrupt_data->num_configured = 0;
interrupt_data->eventfd_ctxs = kcalloc(driver_desc->num_interrupts,
sizeof(struct eventfd_ctx *),
GFP_KERNEL);
interrupt_data->eventfd_ctxs =
kcalloc(driver_desc->num_interrupts,
sizeof(*interrupt_data->eventfd_ctxs), GFP_KERNEL);
if (!interrupt_data->eventfd_ctxs) {
kfree(interrupt_data);
return -ENOMEM;
}
interrupt_data->interrupt_counts = kcalloc(driver_desc->num_interrupts,
sizeof(ulong),
GFP_KERNEL);
interrupt_data->interrupt_counts =
kcalloc(driver_desc->num_interrupts,
sizeof(*interrupt_data->interrupt_counts), GFP_KERNEL);
if (!interrupt_data->interrupt_counts) {
kfree(interrupt_data->eventfd_ctxs);
kfree(interrupt_data);

View File

@ -1278,7 +1278,8 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
/* allocate the physical memory block */
gasket_dev->page_table[index]->coherent_pages =
kcalloc(num_pages, sizeof(struct gasket_coherent_page_entry),
kcalloc(num_pages,
sizeof(*gasket_dev->page_table[index]->coherent_pages),
GFP_KERNEL);
if (!gasket_dev->page_table[index]->coherent_pages)
goto nomem;