diff mbox series

[1/2] spi: Remove unnecessary #ifdefs in header file

Message ID 20200706021653.2146278-1-sjg@chromium.org
State New
Headers show
Series [1/2] spi: Remove unnecessary #ifdefs in header file | expand

Commit Message

Simon Glass July 6, 2020, 2:16 a.m. UTC
These prevent use of compile-time checks such as:

    if (CONFIG_IS_ENABLED(DM_SPI))

since, for example, if CONFIG_SPL_DM_SPI is not enabled then the
definitions are not included by spi.h and the C code will not build.

The #ifdefs are unnecessary since there are no conflicts with the pre-DM
code. In any case we have almost switched over to driver model for SPI.

Drop these #ifdefs from spi.h to fix a build warning on chromebook_coral
in the following patch.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 include/spi.h | 8 --------
 1 file changed, 8 deletions(-)

Comments

Bin Meng July 7, 2020, 7:56 a.m. UTC | #1
On Mon, Jul 6, 2020 at 10:16 AM Simon Glass <sjg at chromium.org> wrote:
>
> These prevent use of compile-time checks such as:
>
>     if (CONFIG_IS_ENABLED(DM_SPI))
>
> since, for example, if CONFIG_SPL_DM_SPI is not enabled then the
> definitions are not included by spi.h and the C code will not build.
>
> The #ifdefs are unnecessary since there are no conflicts with the pre-DM
> code. In any case we have almost switched over to driver model for SPI.
>
> Drop these #ifdefs from spi.h to fix a build warning on chromebook_coral
> in the following patch.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>  include/spi.h | 8 --------
>  1 file changed, 8 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
Bin Meng July 7, 2020, 7:58 a.m. UTC | #2
On Tue, Jul 7, 2020 at 3:56 PM Bin Meng <bmeng.cn at gmail.com> wrote:
>
> On Mon, Jul 6, 2020 at 10:16 AM Simon Glass <sjg at chromium.org> wrote:
> >
> > These prevent use of compile-time checks such as:
> >
> >     if (CONFIG_IS_ENABLED(DM_SPI))
> >
> > since, for example, if CONFIG_SPL_DM_SPI is not enabled then the
> > definitions are not included by spi.h and the C code will not build.
> >
> > The #ifdefs are unnecessary since there are no conflicts with the pre-DM
> > code. In any case we have almost switched over to driver model for SPI.
> >
> > Drop these #ifdefs from spi.h to fix a build warning on chromebook_coral
> > in the following patch.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> >  include/spi.h | 8 --------
> >  1 file changed, 8 deletions(-)
> >
>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>

applied to u-boot-x86, thanks!
Bin Meng July 8, 2020, 1:05 a.m. UTC | #3
Hi Simon,

On Tue, Jul 7, 2020 at 3:58 PM Bin Meng <bmeng.cn at gmail.com> wrote:
>
> On Tue, Jul 7, 2020 at 3:56 PM Bin Meng <bmeng.cn at gmail.com> wrote:
> >
> > On Mon, Jul 6, 2020 at 10:16 AM Simon Glass <sjg at chromium.org> wrote:
> > >
> > > These prevent use of compile-time checks such as:
> > >
> > >     if (CONFIG_IS_ENABLED(DM_SPI))
> > >
> > > since, for example, if CONFIG_SPL_DM_SPI is not enabled then the
> > > definitions are not included by spi.h and the C code will not build.
> > >
> > > The #ifdefs are unnecessary since there are no conflicts with the pre-DM
> > > code. In any case we have almost switched over to driver model for SPI.
> > >
> > > Drop these #ifdefs from spi.h to fix a build warning on chromebook_coral
> > > in the following patch.
> > >
> > > Signed-off-by: Simon Glass <sjg at chromium.org>
> > > ---
> > >
> > >  include/spi.h | 8 --------
> > >  1 file changed, 8 deletions(-)
> > >
> >
> > Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
>
> applied to u-boot-x86, thanks!

Unfortunately this breaks some boards. Could you please take a look?
https://dev.azure.com/bmeng/GitHub/_build/results?buildId=250&view=logs&j=ed3f42d9-8790-5c10-89c6-b1feb81eb957&t=aa0bab01-4da3-5dc7-7237-a00778129ead

Regards,
Bin
Simon Glass July 8, 2020, 3:01 p.m. UTC | #4
Hi Bin,

On Tue, 7 Jul 2020 at 19:05, Bin Meng <bmeng.cn at gmail.com> wrote:
>
> Hi Simon,
>
> On Tue, Jul 7, 2020 at 3:58 PM Bin Meng <bmeng.cn at gmail.com> wrote:
> >
> > On Tue, Jul 7, 2020 at 3:56 PM Bin Meng <bmeng.cn at gmail.com> wrote:
> > >
> > > On Mon, Jul 6, 2020 at 10:16 AM Simon Glass <sjg at chromium.org> wrote:
> > > >
> > > > These prevent use of compile-time checks such as:
> > > >
> > > >     if (CONFIG_IS_ENABLED(DM_SPI))
> > > >
> > > > since, for example, if CONFIG_SPL_DM_SPI is not enabled then the
> > > > definitions are not included by spi.h and the C code will not build.
> > > >
> > > > The #ifdefs are unnecessary since there are no conflicts with the pre-DM
> > > > code. In any case we have almost switched over to driver model for SPI.
> > > >
> > > > Drop these #ifdefs from spi.h to fix a build warning on chromebook_coral
> > > > in the following patch.
> > > >
> > > > Signed-off-by: Simon Glass <sjg at chromium.org>
> > > > ---
> > > >
> > > >  include/spi.h | 8 --------
> > > >  1 file changed, 8 deletions(-)
> > > >
> > >
> > > Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> >
> > applied to u-boot-x86, thanks!
>
> Unfortunately this breaks some boards. Could you please take a look?
> https://dev.azure.com/bmeng/GitHub/_build/results?buildId=250&view=logs&j=ed3f42d9-8790-5c10-89c6-b1feb81eb957&t=aa0bab01-4da3-5dc7-7237-a00778129ead

Oh dear, the pre-DM functions conflict. I'll send a v2.

Regards,
SImon
diff mbox series

Patch

diff --git a/include/spi.h b/include/spi.h
index 9b4fb8dc0b..7fca646759 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -39,7 +39,6 @@ 
 
 #define SPI_DEFAULT_WORDLEN	8
 
-#if CONFIG_IS_ENABLED(DM_SPI)
 /* TODO(sjg at chromium.org): Remove this and use max_hz from struct spi_slave */
 struct dm_spi_bus {
 	uint max_hz;
@@ -65,8 +64,6 @@  struct dm_spi_slave_platdata {
 	uint mode;
 };
 
-#endif /* CONFIG_DM_SPI */
-
 /**
  * enum spi_clock_phase - indicates  the clock phase to use for SPI (CPHA)
  *
@@ -317,7 +314,6 @@  void spi_flash_copy_mmap(void *data, void *offset, size_t len);
  */
 int spi_cs_is_valid(unsigned int bus, unsigned int cs);
 
-#if !CONFIG_IS_ENABLED(DM_SPI)
 /**
  * Activate a SPI chipselect.
  * This function is provided by the board code when using a driver
@@ -343,7 +339,6 @@  void spi_cs_deactivate(struct spi_slave *slave);
  * @hz:		The transfer speed
  */
 void spi_set_speed(struct spi_slave *slave, uint hz);
-#endif
 
 /**
  * Write 8 bits, then read 8 bits.
@@ -367,8 +362,6 @@  static inline int spi_w8r8(struct spi_slave *slave, unsigned char byte)
 	return ret < 0 ? ret : din[1];
 }
 
-#if CONFIG_IS_ENABLED(DM_SPI)
-
 /**
  * struct spi_cs_info - Information about a bus chip select
  *
@@ -717,6 +710,5 @@  int dm_spi_get_mmap(struct udevice *dev, ulong *map_basep, uint *map_sizep,
 /* Access the operations for a SPI device */
 #define spi_get_ops(dev)	((struct dm_spi_ops *)(dev)->driver->ops)
 #define spi_emul_get_ops(dev)	((struct dm_spi_emul_ops *)(dev)->driver->ops)
-#endif /* CONFIG_DM_SPI */
 
 #endif	/* _SPI_H_ */