On Wed, Apr 15, 2020 at 09:25:23AM -0400, Suganath Prabu wrote: > From: Suganath Prabu S <suganath-prabu.subramani@xxxxxxxxxxxx> > > For readability separate out RDPQ allocations to new function > base_alloc_rdpq_dma_pool(). > > Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@xxxxxxxxxxxx> > --- > drivers/scsi/mpt3sas/mpt3sas_base.c | 85 ++++++++++++++++++++++--------------- > 1 file changed, 51 insertions(+), 34 deletions(-) > > diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c > index 7f7b5af..27c829e 100644 > --- a/drivers/scsi/mpt3sas/mpt3sas_base.c > +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c > @@ -4944,6 +4944,55 @@ mpt3sas_check_same_4gb_region(long reply_pool_start_address, u32 pool_sz) > } > > /** > + * base_alloc_rdpq_dma_pool - Allocating DMA'able memory > + * for reply queues. > + * @ioc: per adapter object > + * @sz: DMA Pool size > + * Return: 0 for success, non-zero for failure. > + */ > +static int > +base_alloc_rdpq_dma_pool(struct MPT3SAS_ADAPTER *ioc, int sz) > +{ > + int i; > + > + ioc->reply_post = kcalloc((ioc->rdpq_array_enable) ? > + (ioc->reply_queue_count):1, > + sizeof(struct reply_post_struct), GFP_KERNEL); Odd use of whitespaces. Also this would benefit from a little untangling as well: int count = ioc->rdpq_array_enable ? ioc->reply_queue_count : 1; ioc->reply_post = kcalloc(count, sizeof(struct reply_post_struct), GFP_KERNEL); > + > + if (!ioc->reply_post) { > + ioc_err(ioc, "reply_post_free pool: kcalloc failed\n"); > + return -ENOMEM; > + } > + ioc->reply_post_free_dma_pool = dma_pool_create("reply_post_free pool", > + &ioc->pdev->dev, sz, 16, 0); > + if (!ioc->reply_post_free_dma_pool) { > + ioc_err(ioc, "reply_post_free pool: dma_pool_create failed\n"); > + return -ENOMEM; We normally don't print error messages for memory allocation failures, as the allocator already prints one including a stack trace. Same for additional allocations below. > + } while (ioc->rdpq_array_enable && (++i < ioc->reply_queue_count)); no need for the inner braces. > + total_sz += sz * (!ioc->rdpq_array_enable ? 1 : ioc->reply_queue_count); if (ioc->rdpq_array_enable) total_sz += sz * ioc->reply_queue_count; else total_sz += sz;