RE: [PATCH] spi: spi-mem: Fix build error without CONFIG_SPI_MEM

From: Naga Sureshkumar Relli
Date: Wed Apr 10 2019 - 01:31:10 EST


Hi Vignesh,

> -----Original Message-----
> From: linux-spi-owner@xxxxxxxxxxxxxxx <linux-spi-owner@xxxxxxxxxxxxxxx> On Behalf Of
> Naga Sureshkumar Relli
> Sent: Wednesday, April 10, 2019 10:53 AM
> To: YueHaibing <yuehaibing@xxxxxxxxxx>; Vignesh Raghavendra <vigneshr@xxxxxx>;
> broonie@xxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx; linux-spi@xxxxxxxxxxxxxxx
> Subject: RE: [PATCH] spi: spi-mem: Fix build error without CONFIG_SPI_MEM
>
> Hi Vignesh,
>
> > -----Original Message-----
> > From: linux-spi-owner@xxxxxxxxxxxxxxx
> > <linux-spi-owner@xxxxxxxxxxxxxxx> On Behalf Of YueHaibing
> > Sent: Wednesday, April 10, 2019 9:03 AM
> > To: Vignesh Raghavendra <vigneshr@xxxxxx>; broonie@xxxxxxxxxx; Naga
> > Sureshkumar Relli <nagasure@xxxxxxxxxx>
> > Cc: linux-kernel@xxxxxxxxxxxxxxx; linux-spi@xxxxxxxxxxxxxxx
> > Subject: Re: [PATCH] spi: spi-mem: Fix build error without
> > CONFIG_SPI_MEM
> >
> > On 2019/4/10 0:30, Vignesh Raghavendra wrote:
> > > On 08/04/19 8:09 PM, Yue Haibing wrote:
> > >> From: YueHaibing <yuehaibing@xxxxxxxxxx>
> > >>
> > >> When building with CONFIG_SPI_MEM is not set gc warns this:
> > >>
> > >> drivers/spi/spi-zynq-qspi.o: In function `zynq_qspi_supports_op':
> > >> spi-zynq-qspi.c:(.text+0x1da): undefined reference to `spi_mem_default_supports_op'
> > >>
> > >> Fixes: 67dca5e580f1 ("spi: spi-mem: Add support for Zynq QSPI
> > >> controller")
> > >> Signed-off-by: YueHaibing <yuehaibing@xxxxxxxxxx>
> > >> ---
> > >> include/linux/spi/spi-mem.h | 14 +++++++++++---
> > >> 1 file changed, 11 insertions(+), 3 deletions(-)
> > >>
> > >> diff --git a/include/linux/spi/spi-mem.h
> > >> b/include/linux/spi/spi-mem.h index c845cd6..1941b84 100644
> > >> --- a/include/linux/spi/spi-mem.h
> > >> +++ b/include/linux/spi/spi-mem.h
> > >> @@ -295,6 +295,10 @@ int spi_controller_dma_map_mem_op_data(struct
> > >> spi_controller *ctlr, void
> > >> spi_controller_dma_unmap_mem_op_data(struct spi_controller
> > *ctlr,
> > >> const struct spi_mem_op *op,
> > >> struct sg_table *sg);
> > >> +
> > >> +bool spi_mem_default_supports_op(struct spi_mem *mem,
> > >> + const struct spi_mem_op *op);
> > >> +
> > >> #else
> > >> static inline int
> > >> spi_controller_dma_map_mem_op_data(struct spi_controller *ctlr, @@
> > >> -310,6 +314,13 @@ spi_controller_dma_unmap_mem_op_data(struct spi_controller
> *ctlr,
> > >> struct sg_table *sg)
> > >> {
> > >> }
> > >> +
> > >> +bool spi_mem_default_supports_op(struct spi_mem *mem,
> > >> + const struct spi_mem_op *op)
> > >
> > > This needs to be declared static inline to avoid multiple definitions.
> > > Right?
> >
> > Indeed, thanks!
Please ignore this. I did mistake in declaring.
It compiled with out any issues using static inline.

Thanks,
Naga Sureshkumar Relli

> If we declare this as static inline, then we can't access that in zynq-qspi driver.
> This is the error I am getting.
> In file included from drivers/spi/spi-zynq-qspi.c:19:0:
> ./include/linux/spi/spi-mem.h:298:20: warning: âspi_mem_default_supports_opâ used but
> never defined static inline bool spi_mem_default_supports_op(struct spi_mem *mem,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/spi/spi-zynq-qspi.c: In function âzynq_qspi_supports_opâ:
> ./include/linux/spi/spi-mem.h:298:20: error: inlining failed in call to always_inline
> âspi_mem_default_supports_opâ: function body not available
> drivers/spi/spi-zynq-qspi.c:223:7: note: called from here
> if (!spi_mem_default_supports_op(mem, op))
>
> Thanks,
> Naga Sureshkumar Relli
> >
> > >
> > >> +{
> > >> + return false;
> > >> +}
> > >> +
> > >> #endif /* CONFIG_SPI_MEM */
> > >>
> > >> int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op
> > >> *op); @@ -341,9 +352,6 @@ int
> > >> spi_mem_driver_register_with_owner(struct spi_mem_driver *drv,
> > >>
> > >> void spi_mem_driver_unregister(struct spi_mem_driver *drv);
> > >>
> > >> -bool spi_mem_default_supports_op(struct spi_mem *mem,
> > >> - const struct spi_mem_op *op);
> > >> -
> > >> #define spi_mem_driver_register(__drv) \
> > >> spi_mem_driver_register_with_owner(__drv, THIS_MODULE)
> > >>
> > >>
> > >