Re: [PATCH 07/21] PCI: designware: Make use of IS_ALIGNED()

From: Gustavo Pimentel
Date: Wed Jan 02 2019 - 04:37:51 EST


Hi,

On 21/12/2018 07:27, Andrey Smirnov wrote:
> Make the intent a bit more clear as well as get rid of explicit
> arithmetic by using IS_ALIGNED() to determine if "addr" is aligned to
> "size". No functional change intended.
>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@xxxxxxx>
> Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
> Cc: Fabio Estevam <fabio.estevam@xxxxxxx>
> Cc: Chris Healy <cphealy@xxxxxxxxx>
> Cc: Lucas Stach <l.stach@xxxxxxxxxxxxxx>
> Cc: Leonard Crestez <leonard.crestez@xxxxxxx>
> Cc: "A.s. Dong" <aisheng.dong@xxxxxxx>
> Cc: Richard Zhu <hongxing.zhu@xxxxxxx>
> Cc: linux-imx@xxxxxxx
> Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
> Cc: linux-pci@xxxxxxxxxxxxxxx
> Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
> ---
> drivers/pci/controller/dwc/pcie-designware.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 93ef8c31fb39..67236379c61a 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -22,7 +22,7 @@
>
> int dw_pcie_read(void __iomem *addr, int size, u32 *val)
> {
> - if ((uintptr_t)addr & (size - 1)) {
> + if (!IS_ALIGNED((uintptr_t)addr, size)) {
> *val = 0;
> return PCIBIOS_BAD_REGISTER_NUMBER;
> }
> @@ -43,7 +43,7 @@ int dw_pcie_read(void __iomem *addr, int size, u32 *val)
>
> int dw_pcie_write(void __iomem *addr, int size, u32 val)
> {
> - if ((uintptr_t)addr & (size - 1))
> + if (!IS_ALIGNED((uintptr_t)addr, size))
> return PCIBIOS_BAD_REGISTER_NUMBER;
>
> if (size == 4)
>

Sounds good.

Acked-by: Gustavo Pimentel <gustavo.pimentel@xxxxxxxxxxxx>