diff mbox series

[v3,4.19.y-cip,08/17] spi: spi-mem: export spi_mem_default_supports_op()

Message ID 20210105135757.11069-9-prabhakar.mahadev-lad.rj@bp.renesas.com (mailing list archive)
State Accepted
Headers show
Series Add Renesas RPC-IF driver | expand

Commit Message

Lad Prabhakar Jan. 5, 2021, 1:57 p.m. UTC
From: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>

commit 46109648052fe778c75f199d72255c899578d6f7 upstream.

Export spi_mem_default_supports_op(), so that controller drivers
can use this.
spi-mem driver already exports this using EXPORT_SYMBOL,
but not declared it in spi-mem.h.
This patch declares spi_mem_default_supports_op() in spi-mem.h and
also removes the static from the function prototype.

This patch also squashes upstream commit 72e6841608b9 ("spi: spi-mem: Fix
build error without CONFIG_SPI_MEM")' in the current patch as commit
46109648052f ("spi: spi-mem: export spi_mem_default_supports_op()")'
introduced below build error when built without CONFIG_SPI_MEM:

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'

Signed-off-by: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
[PL: manually applied the changes, squashed commit 72e6841608b9
("spi: spi-mem: Fix build error without CONFIG_SPI_MEM")' in current patch]
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/spi/spi-mem.c       |  4 ++--
 include/linux/spi/spi-mem.h | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

Comments

Pavel Machek Jan. 5, 2021, 4:51 p.m. UTC | #1
Hi!

> From: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>
 
> This patch also squashes upstream commit 72e6841608b9 ("spi: spi-mem: Fix
> build error without CONFIG_SPI_MEM")' in the current patch as commit
> 46109648052f ("spi: spi-mem: export spi_mem_default_supports_op()")'
> introduced below build error when built without CONFIG_SPI_MEM:

This puts function definition directly into header file; I don't think
that will work when multiple files include it.

Adding "static inline" is the usual solution for this.

Best regards,
								Pavel

> diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
> index 80db2de83402..253a8d451d4c 100644
> --- a/include/linux/spi/spi-mem.h
> +++ b/include/linux/spi/spi-mem.h
> @@ -239,6 +243,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)
> +{
> +	return false;
> +}
> +
>  #endif /* CONFIG_SPI_MEM */
>  
>  int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op);
Lad Prabhakar Jan. 5, 2021, 5:07 p.m. UTC | #2
Hi Pavel,

Thank you for the review.

> -----Original Message-----
> From: Pavel Machek <pavel@denx.de>
> Sent: 05 January 2021 16:52
> To: Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Cc: cip-dev@lists.cip-project.org; Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>; Pavel Machek
> <pavel@denx.de>; Biju Das <biju.das.jz@bp.renesas.com>
> Subject: Re: [PATCH v3 4.19.y-cip 08/17] spi: spi-mem: export spi_mem_default_supports_op()
> 
> Hi!
> 
> > From: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>
> 
> > This patch also squashes upstream commit 72e6841608b9 ("spi: spi-mem: Fix
> > build error without CONFIG_SPI_MEM")' in the current patch as commit
> > 46109648052f ("spi: spi-mem: export spi_mem_default_supports_op()")'
> > introduced below build error when built without CONFIG_SPI_MEM:
> 
> This puts function definition directly into header file; I don't think
> that will work when multiple files include it.
> 
> Adding "static inline" is the usual solution for this.
> 
Agreed will fix this.

Cheers,
Prabhakar

> Best regards,
> 								Pavel
> 
> > diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
> > index 80db2de83402..253a8d451d4c 100644
> > --- a/include/linux/spi/spi-mem.h
> > +++ b/include/linux/spi/spi-mem.h
> > @@ -239,6 +243,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)
> > +{
> > +	return false;
> > +}
> > +
> >  #endif /* CONFIG_SPI_MEM */
> >
> >  int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op);
> 
> --
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#6037): https://lists.cip-project.org/g/cip-dev/message/6037
Mute This Topic: https://lists.cip-project.org/mt/79450068/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/727948398/xyzzy [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-
Sudip Mukherjee Jan. 5, 2021, 5:47 p.m. UTC | #3
On 05/01/2021 16:51, Pavel Machek wrote:
> Hi!
> 
>> From: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>
>  
>> This patch also squashes upstream commit 72e6841608b9 ("spi: spi-mem: Fix
>> build error without CONFIG_SPI_MEM")' in the current patch as commit
>> 46109648052f ("spi: spi-mem: export spi_mem_default_supports_op()")'
>> introduced below build error when built without CONFIG_SPI_MEM:
> 
> This puts function definition directly into header file; I don't think
> that will work when multiple files include it.
> 
> Adding "static inline" is the usual solution for this.

Has been done upstream by b5881b153bc8 ("spi: spi-mem: Make
spi_mem_default_supports_op() static inline")

I was once raising this concern internally that when commits are
backported not all of them are backported but since I did not know
enough about how CIP wants to do the backporting so never raised the
issue. But this is an example what I was concerned about.
Pavel Machek Jan. 6, 2021, 1:19 p.m. UTC | #4
Hi!

> >> From: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>
> >  
> >> This patch also squashes upstream commit 72e6841608b9 ("spi: spi-mem: Fix
> >> build error without CONFIG_SPI_MEM")' in the current patch as commit
> >> 46109648052f ("spi: spi-mem: export spi_mem_default_supports_op()")'
> >> introduced below build error when built without CONFIG_SPI_MEM:
> > 
> > This puts function definition directly into header file; I don't think
> > that will work when multiple files include it.
> > 
> > Adding "static inline" is the usual solution for this.
> 
> Has been done upstream by b5881b153bc8 ("spi: spi-mem: Make
> spi_mem_default_supports_op() static inline")
> 
> I was once raising this concern internally that when commits are
> backported not all of them are backported but since I did not know
> enough about how CIP wants to do the backporting so never raised the
> issue. But this is an example what I was concerned about.

We can probably create a simple script that goes through commits,
collects their "upstream" commit ids, and searches linux-next for
Fixes: xxx... So we'd have simple way of checking if we are missing
any fixes.

If Renesas could submit b5881b153bc8 ("spi: spi-mem: Make 
spi_mem_default_supports_op() static inline") for 4.19-cip, it would
be nice :-).

Best regards,
								Pavel
diff mbox series

Patch

diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 967f581bca4f..b319a9f0138c 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -128,8 +128,8 @@  static int spi_check_buswidth_req(struct spi_mem *mem, u8 buswidth, bool tx)
 	return -ENOTSUPP;
 }
 
-static bool spi_mem_default_supports_op(struct spi_mem *mem,
-					const struct spi_mem_op *op)
+bool spi_mem_default_supports_op(struct spi_mem *mem,
+				 const struct spi_mem_op *op)
 {
 	if (spi_check_buswidth_req(mem, op->cmd.buswidth, true))
 		return false;
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index 80db2de83402..253a8d451d4c 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -224,6 +224,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,
@@ -239,6 +243,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)
+{
+	return false;
+}
+
 #endif /* CONFIG_SPI_MEM */
 
 int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op);