From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [PATCH 04/25] scsi: hisi_sas: add scsi host registration Date: Mon, 12 Oct 2015 17:21:34 +0200 Message-ID: <5053179.dHmgEztyeB@wuerfel> References: <1444663237-238302-1-git-send-email-john.garry@huawei.com> <1444663237-238302-5-git-send-email-john.garry@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Return-path: In-Reply-To: <1444663237-238302-5-git-send-email-john.garry-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: John Garry Cc: James.Bottomley-JuX6DAaQMKPCXq6kfMZ53/egYHeGw8Jk@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org, zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, xuwei5-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org, john.garry2-s/0ZXS5h9803lw97EnAbAg@public.gmane.org, hare-l3A5Bk7waGM@public.gmane.org List-Id: linux-scsi@vger.kernel.org On Monday 12 October 2015 23:20:16 John Garry wrote: > + > + shost = scsi_host_alloc(&hisi_sas_sht, sizeof(void *)); > + if (!shost) > + return -ENOMEM; > + > + hisi_hba = hisi_sas_hba_alloc(pdev, shost, np); > + if (!hisi_hba) { > + rc = -ENOMEM; > + goto err_out_ha; > + } You can collapse the allocations into one and just pass sizeof(*hisi_hba) instead of sizeof(void *) above. > + sha = SHOST_TO_SAS_HA(shost) = &hisi_hba->sha; > + platform_set_drvdata(pdev, sha); > + > + phy_nr = port_nr = HISI_SAS_MAX_PHYS; > + > + arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL); > + arr_port = devm_kcalloc(dev, port_nr, sizeof(void *), GFP_KERNEL); > + if (!arr_phy || !arr_port) > + return -ENOMEM; And since these are fixed-size arrays, they can be moved in there as well. Arnd -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752150AbbJLPVq (ORCPT ); Mon, 12 Oct 2015 11:21:46 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:52225 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752059AbbJLPVo (ORCPT ); Mon, 12 Oct 2015 11:21:44 -0400 From: Arnd Bergmann To: John Garry Cc: James.Bottomley@hansenpartnership.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linuxarm@huawei.com, zhangfei.gao@linaro.org, linux-scsi@vger.kernel.org, xuwei5@hisilicon.com, john.garry2@mail.dcu.ie, hare@suse.de Subject: Re: [PATCH 04/25] scsi: hisi_sas: add scsi host registration Date: Mon, 12 Oct 2015 17:21:34 +0200 Message-ID: <5053179.dHmgEztyeB@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1444663237-238302-5-git-send-email-john.garry@huawei.com> References: <1444663237-238302-1-git-send-email-john.garry@huawei.com> <1444663237-238302-5-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:Mi53tHx9m9+JhxUSbWCTt2gK5gmuN3KuZjRqnMg3HURLsjMPZX8 fYnJ+k+RVV/U71QloWxN1CM86OPLYCYy96cK7nw50pS/ZxID5hwuivNqoY1tyuJaWgmQcug V0UsOylxKlDhm7oB51miHMAxCzDQ/se6ImUiQa9hBjW6PNbvLB+HWxwub4BMLO8vlr/hUBI YeZJyJfx3z0mTZQRdl1hw== X-UI-Out-Filterresults: notjunk:1;V01:K0:+qC2RXA+1sU=:Xj3Gec007GaGRa8yLWyYou zUCsloWr5c9psDmY1S5bxvMsqB3akYdXgTRw2O74UKa6vnrNI1SXFMO91GNsAquJm0ogO99wY ffXSznEI66TKzwE1KmDITfuSTGHVifaPKukxxdL0fMr3dw2m3a8/lN6OVl7ujMTh5M9/e3rXR azIPjgQkhTN3mSx5WANosj5kqY8H+JfKfoxAz6ckUpJ6NXkdAbKOWeE/6mmiJ7DO17SrIFkky p1L50mOX9rxN1Yu3iXlI2OCuRp6NVQOekC4e4nazQuKWJ/gJWPyw2r1GK4n2Ir3GHAhIzjl/4 WyWfxJJhQDtEQTYe1oYJAi6/M+GJjHbO4/XVBEyDs5mshEqek28GnnXlcH8/z0FKjx/fzYn1l BGa1sW08n7Zike2AykpI6fpUGpyAhGDwTPiL3BV0PugcdEXGf4piqQJ6e3ysk0gUkcHfVFTAy JpL3WGg77dwMT44l2dCEQfKIsaiiOMXyaYdcmCdSagA+yEaZsAQU7E7cu6UL+s9v68xbtsu0k mdGoIxyGVkL2rcp/+W8t8BvG3szR53+aPx53Sse65tx+9cb+dg2HMZi7yzbAsyQm60nohfFY9 rDKyrPooE6BsphyACIaDhBQWMOOO/MbQdFCWwTq9y+IPyGKRwzApPRNbnAsCaku5Wt6smEYhB mU8qMkIcW3toagJnar/r+kvmFFpO9lx6gD7nyvg+DEy2DXz1Es+NGnT2vVPsESNeBmF6d27Bz f/zgw4b+MxdKzcu7 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 12 October 2015 23:20:16 John Garry wrote: > + > + shost = scsi_host_alloc(&hisi_sas_sht, sizeof(void *)); > + if (!shost) > + return -ENOMEM; > + > + hisi_hba = hisi_sas_hba_alloc(pdev, shost, np); > + if (!hisi_hba) { > + rc = -ENOMEM; > + goto err_out_ha; > + } You can collapse the allocations into one and just pass sizeof(*hisi_hba) instead of sizeof(void *) above. > + sha = SHOST_TO_SAS_HA(shost) = &hisi_hba->sha; > + platform_set_drvdata(pdev, sha); > + > + phy_nr = port_nr = HISI_SAS_MAX_PHYS; > + > + arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL); > + arr_port = devm_kcalloc(dev, port_nr, sizeof(void *), GFP_KERNEL); > + if (!arr_phy || !arr_port) > + return -ENOMEM; And since these are fixed-size arrays, they can be moved in there as well. Arnd