lkml.org 
[lkml]   [2018]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 8/9] PCI: dwc: Small computation improvement
From
Date
Hi Jingoo,

On 11/04/2018 01:01, Jingoo Han wrote:
> On Monday, April 9, 2018 5:41 AM, Gustavo Pimentel wrote:
>>
>> Replaces a simple division by 2 to a right shift rotation of 1 bit.
>
> It looks good. However, would you add a simple reason to the commit
> message?

Sure.

Can be this one?

Probably any recent and decent compiler does this kind of substitution
in order to improve code performance. Nevertheless it's a coding good
practice whenever there is a division / multiplication by multiple of 2
to replace it by the equivalent operation in this case, the shift
rotation.

>
> Best regards,
> Jingoo Han
>
>>
>> Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
>> ---
>> Change v1->v2:
>> - Nothing changed, just to follow the patch set version.
>>
>> drivers/pci/dwc/pcie-designware-host.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/pci/dwc/pcie-designware-host.c
>> b/drivers/pci/dwc/pcie-designware-host.c
>> index 03e9b82..8e6fed4 100644
>> --- a/drivers/pci/dwc/pcie-designware-host.c
>> +++ b/drivers/pci/dwc/pcie-designware-host.c
>> @@ -332,8 +332,8 @@ int dw_pcie_host_init(struct pcie_port *pp)
>>
>> cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
>> "config");
>> if (cfg_res) {
>> - pp->cfg0_size = resource_size(cfg_res) / 2;
>> - pp->cfg1_size = resource_size(cfg_res) / 2;
>> + pp->cfg0_size = resource_size(cfg_res) >> 1;
>> + pp->cfg1_size = resource_size(cfg_res) >> 1;
>> pp->cfg0_base = cfg_res->start;
>> pp->cfg1_base = cfg_res->start + pp->cfg0_size;
>> } else if (!pp->va_cfg0_base) {
>> @@ -377,8 +377,8 @@ int dw_pcie_host_init(struct pcie_port *pp)
>> break;
>> case 0:
>> pp->cfg = win->res;
>> - pp->cfg0_size = resource_size(pp->cfg) / 2;
>> - pp->cfg1_size = resource_size(pp->cfg) / 2;
>> + pp->cfg0_size = resource_size(pp->cfg) >> 1;
>> + pp->cfg1_size = resource_size(pp->cfg) >> 1;
>> pp->cfg0_base = pp->cfg->start;
>> pp->cfg1_base = pp->cfg->start + pp->cfg0_size;
>> break;
>> --
>> 2.7.4
>>
>
>

Regards,
Gustavo

\
 
 \ /
  Last update: 2018-04-11 09:41    [W:0.469 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site