]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
PCI: dwc: Small computation improvement
authorGustavo Pimentel <gustavo.pimentel@synopsys.com>
Mon, 14 May 2018 15:09:49 +0000 (16:09 +0100)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 14 May 2018 16:04:05 +0000 (17:04 +0100)
Replace a division by 2 operation for a right shift rotation of 1 bit.

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.

Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
Acked-by: Joao Pinto <jpinto@synopsys.com>
drivers/pci/dwc/pcie-designware-host.c

index 5a23f782851a025fd3c1aa7da40b613740fb9d86..fc55fde8742e2ddf7f7299b9d29a2bae510c9bae 100644 (file)
@@ -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;