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

From: Joe Perches
Date: Fri Jan 04 2019 - 13:38:04 EST


On Wed, 2019-01-02 at 09:33 +0000, Gustavo Pimentel wrote:
> 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.
[]
> > diff --git 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)) {

The (uintptr_t) cast could probably be removed as well.

> > @@ -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;

here too