2011-06-05 07:18:17

by Grant Likely

[permalink] [raw]
Subject: [PATCH] spi: reorganize drivers

[repost: I had a typo on the spi-devel-general mailing list address]

Sort the SPI makefile and enforce the naming convention spi_*.c for
spi drivers.

This change also rolls the contents of atmel_spi.h into the .c file
since there is only one user of that particular include file.

Signed-off-by: Grant Likely <[email protected]>
---
drivers/spi/Makefile | 80 ++++++++-----------
drivers/spi/atmel_spi.h | 167 ---------------------------------------
drivers/spi/spi_ath79.c | 0
drivers/spi/spi_atmel.c | 155 ++++++++++++++++++++++++++++++++++++
drivers/spi/spi_au1550.c | 0
drivers/spi/spi_coldfire_qspi.c | 0
drivers/spi/spi_davinci.c | 0
drivers/spi/spi_dw.c | 2
drivers/spi/spi_dw.h | 0
drivers/spi/spi_dw_mid.c | 2
drivers/spi/spi_dw_mmio.c | 2
drivers/spi/spi_dw_pci.c | 2
drivers/spi/spi_ep93xx.c | 0
drivers/spi/spi_mpc512x_psc.c | 0
drivers/spi/spi_mpc52xx.c | 0
drivers/spi/spi_mpc52xx_psc.c | 0
drivers/spi/spi_omap2_mcspi.c | 0
drivers/spi/spi_omap_100k.c | 0
drivers/spi/spi_omap_uwire.c | 0
drivers/spi/spi_orion.c | 0
drivers/spi/spi_pl022.c | 0
drivers/spi/spi_pxa2xx.c | 0
drivers/spi/spi_pxa2xx_pci.c | 0
drivers/spi/spi_ti_ssp.c | 0
drivers/spi/spi_tle62x0.c | 0
drivers/spi/spi_xilinx.c | 0
26 files changed, 192 insertions(+), 218 deletions(-)
delete mode 100644 drivers/spi/atmel_spi.h
rename drivers/spi/{ath79_spi.c => spi_ath79.c} (100%)
rename drivers/spi/{atmel_spi.c => spi_atmel.c} (85%)
rename drivers/spi/{au1550_spi.c => spi_au1550.c} (100%)
rename drivers/spi/{coldfire_qspi.c => spi_coldfire_qspi.c} (100%)
rename drivers/spi/{davinci_spi.c => spi_davinci.c} (100%)
rename drivers/spi/{dw_spi.c => spi_dw.c} (99%)
rename drivers/spi/{dw_spi.h => spi_dw.h} (100%)
rename drivers/spi/{dw_spi_mid.c => spi_dw_mid.c} (99%)
rename drivers/spi/{dw_spi_mmio.c => spi_dw_mmio.c} (99%)
rename drivers/spi/{dw_spi_pci.c => spi_dw_pci.c} (99%)
rename drivers/spi/{ep93xx_spi.c => spi_ep93xx.c} (100%)
rename drivers/spi/{mpc512x_psc_spi.c => spi_mpc512x_psc.c} (100%)
rename drivers/spi/{mpc52xx_spi.c => spi_mpc52xx.c} (100%)
rename drivers/spi/{mpc52xx_psc_spi.c => spi_mpc52xx_psc.c} (100%)
rename drivers/spi/{omap2_mcspi.c => spi_omap2_mcspi.c} (100%)
rename drivers/spi/{omap_spi_100k.c => spi_omap_100k.c} (100%)
rename drivers/spi/{omap_uwire.c => spi_omap_uwire.c} (100%)
rename drivers/spi/{orion_spi.c => spi_orion.c} (100%)
rename drivers/spi/{amba-pl022.c => spi_pl022.c} (100%)
rename drivers/spi/{pxa2xx_spi.c => spi_pxa2xx.c} (100%)
rename drivers/spi/{pxa2xx_spi_pci.c => spi_pxa2xx_pci.c} (100%)
rename drivers/spi/{ti-ssp-spi.c => spi_ti_ssp.c} (100%)
rename drivers/spi/{tle62x0.c => spi_tle62x0.c} (100%)
rename drivers/spi/{xilinx_spi.c => spi_xilinx.c} (100%)

diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 0f8c69b..39ab8e3 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -7,68 +7,56 @@ ccflags-$(CONFIG_SPI_DEBUG) := -DDEBUG
# small core, mostly translating board-specific
# config declarations into driver model code
obj-$(CONFIG_SPI_MASTER) += spi.o
+obj-$(CONFIG_SPI_SPIDEV) += spidev.o

# SPI master controller drivers (bus)
obj-$(CONFIG_SPI_ALTERA) += spi_altera.o
-obj-$(CONFIG_SPI_ATMEL) += atmel_spi.o
-obj-$(CONFIG_SPI_ATH79) += ath79_spi.o
+obj-$(CONFIG_SPI_ATMEL) += spi_atmel.o
+obj-$(CONFIG_SPI_ATH79) += spi_ath79.o
+obj-$(CONFIG_SPI_AU1550) += spi_au1550.o
obj-$(CONFIG_SPI_BFIN) += spi_bfin5xx.o
obj-$(CONFIG_SPI_BFIN_SPORT) += spi_bfin_sport.o
obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o
-obj-$(CONFIG_SPI_AU1550) += au1550_spi.o
obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o
-obj-$(CONFIG_SPI_COLDFIRE_QSPI) += coldfire_qspi.o
-obj-$(CONFIG_SPI_DAVINCI) += davinci_spi.o
-obj-$(CONFIG_SPI_DESIGNWARE) += dw_spi.o
-obj-$(CONFIG_SPI_DW_PCI) += dw_spi_midpci.o
-dw_spi_midpci-objs := dw_spi_pci.o dw_spi_mid.o
-obj-$(CONFIG_SPI_DW_MMIO) += dw_spi_mmio.o
-obj-$(CONFIG_SPI_EP93XX) += ep93xx_spi.o
+obj-$(CONFIG_SPI_COLDFIRE_QSPI) += spi_coldfire_qspi.o
+obj-$(CONFIG_SPI_DAVINCI) += spi_davinci.o
+obj-$(CONFIG_SPI_DESIGNWARE) += spi_dw.o
+obj-$(CONFIG_SPI_DW_MMIO) += spi_dw_mmio.o
+obj-$(CONFIG_SPI_DW_PCI) += spi_dw_midpci.o
+spi_dw_midpci-objs := spi_dw_pci.o spi_dw_mid.o
+obj-$(CONFIG_SPI_EP93XX) += spi_ep93xx.o
+obj-$(CONFIG_SPI_FSL_LIB) += spi_fsl_lib.o
+obj-$(CONFIG_SPI_FSL_ESPI) += spi_fsl_espi.o
+obj-$(CONFIG_SPI_FSL_SPI) += spi_fsl_spi.o
obj-$(CONFIG_SPI_GPIO) += spi_gpio.o
obj-$(CONFIG_SPI_IMX) += spi_imx.o
obj-$(CONFIG_SPI_LM70_LLP) += spi_lm70llp.o
-obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o
-obj-$(CONFIG_SPI_PXA2XX_PCI) += pxa2xx_spi_pci.o
+obj-$(CONFIG_SPI_MPC512x_PSC) += spi_mpc512x_psc.o
+obj-$(CONFIG_SPI_MPC52xx_PSC) += spi_mpc52xx_psc.o
+obj-$(CONFIG_SPI_MPC52xx) += spi_mpc52xx.o
+obj-$(CONFIG_SPI_NUC900) += spi_nuc900.o
obj-$(CONFIG_SPI_OC_TINY) += spi_oc_tiny.o
-obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o
-obj-$(CONFIG_SPI_OMAP24XX) += omap2_mcspi.o
-obj-$(CONFIG_SPI_OMAP_100K) += omap_spi_100k.o
-obj-$(CONFIG_SPI_ORION) += orion_spi.o
-obj-$(CONFIG_SPI_PL022) += amba-pl022.o
-obj-$(CONFIG_SPI_MPC512x_PSC) += mpc512x_psc_spi.o
-obj-$(CONFIG_SPI_MPC52xx_PSC) += mpc52xx_psc_spi.o
-obj-$(CONFIG_SPI_MPC52xx) += mpc52xx_spi.o
-obj-$(CONFIG_SPI_FSL_LIB) += spi_fsl_lib.o
-obj-$(CONFIG_SPI_FSL_ESPI) += spi_fsl_espi.o
-obj-$(CONFIG_SPI_FSL_SPI) += spi_fsl_spi.o
+obj-$(CONFIG_SPI_OMAP_UWIRE) += spi_omap_uwire.o
+obj-$(CONFIG_SPI_OMAP_100K) += spi_omap_100k.o
+obj-$(CONFIG_SPI_OMAP24XX) += spi_omap2_mcspi.o
+obj-$(CONFIG_SPI_ORION) += spi_orion.o
+obj-$(CONFIG_SPI_PL022) += spi_pl022.o
obj-$(CONFIG_SPI_PPC4xx) += spi_ppc4xx.o
+obj-$(CONFIG_SPI_PXA2XX) += spi_pxa2xx.o
+obj-$(CONFIG_SPI_PXA2XX_PCI) += spi_pxa2xx_pci.o
obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o
obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx_hw.o
+spi_s3c24xx_hw-y := spi_s3c24xx.o
+spi_s3c24xx_hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi_s3c24xx_fiq.o
obj-$(CONFIG_SPI_S3C64XX) += spi_s3c64xx.o
-obj-$(CONFIG_SPI_TEGRA) += spi_tegra.o
-obj-$(CONFIG_SPI_TI_SSP) += ti-ssp-spi.o
-obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi_topcliff_pch.o
-obj-$(CONFIG_SPI_TXX9) += spi_txx9.o
-obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o
obj-$(CONFIG_SPI_SH) += spi_sh.o
-obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o
obj-$(CONFIG_SPI_SH_MSIOF) += spi_sh_msiof.o
+obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o
obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o
-obj-$(CONFIG_SPI_NUC900) += spi_nuc900.o
-
-# special build for s3c24xx spi driver with fiq support
-spi_s3c24xx_hw-y := spi_s3c24xx.o
-spi_s3c24xx_hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi_s3c24xx_fiq.o
-
-# ... add above this line ...
-
-# SPI protocol drivers (device/link on bus)
-obj-$(CONFIG_SPI_SPIDEV) += spidev.o
-obj-$(CONFIG_SPI_TLE62X0) += tle62x0.o
-# ... add above this line ...
-
-# SPI slave controller drivers (upstream link)
-# ... add above this line ...
+obj-$(CONFIG_SPI_TEGRA) += spi_tegra.o
+obj-$(CONFIG_SPI_TI_SSP) += spi_ti_ssp.o
+obj-$(CONFIG_SPI_TLE62X0) += spi_tle62x0.o
+obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi_topcliff_pch.o
+obj-$(CONFIG_SPI_TXX9) += spi_txx9.o
+obj-$(CONFIG_SPI_XILINX) += spi_xilinx.o

-# SPI slave drivers (protocol for that link)
-# ... add above this line ...
diff --git a/drivers/spi/atmel_spi.h b/drivers/spi/atmel_spi.h
deleted file mode 100644
index 6e06b6a..0000000
--- a/drivers/spi/atmel_spi.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Register definitions for Atmel Serial Peripheral Interface (SPI)
- *
- * Copyright (C) 2006 Atmel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#ifndef __ATMEL_SPI_H__
-#define __ATMEL_SPI_H__
-
-/* SPI register offsets */
-#define SPI_CR 0x0000
-#define SPI_MR 0x0004
-#define SPI_RDR 0x0008
-#define SPI_TDR 0x000c
-#define SPI_SR 0x0010
-#define SPI_IER 0x0014
-#define SPI_IDR 0x0018
-#define SPI_IMR 0x001c
-#define SPI_CSR0 0x0030
-#define SPI_CSR1 0x0034
-#define SPI_CSR2 0x0038
-#define SPI_CSR3 0x003c
-#define SPI_RPR 0x0100
-#define SPI_RCR 0x0104
-#define SPI_TPR 0x0108
-#define SPI_TCR 0x010c
-#define SPI_RNPR 0x0110
-#define SPI_RNCR 0x0114
-#define SPI_TNPR 0x0118
-#define SPI_TNCR 0x011c
-#define SPI_PTCR 0x0120
-#define SPI_PTSR 0x0124
-
-/* Bitfields in CR */
-#define SPI_SPIEN_OFFSET 0
-#define SPI_SPIEN_SIZE 1
-#define SPI_SPIDIS_OFFSET 1
-#define SPI_SPIDIS_SIZE 1
-#define SPI_SWRST_OFFSET 7
-#define SPI_SWRST_SIZE 1
-#define SPI_LASTXFER_OFFSET 24
-#define SPI_LASTXFER_SIZE 1
-
-/* Bitfields in MR */
-#define SPI_MSTR_OFFSET 0
-#define SPI_MSTR_SIZE 1
-#define SPI_PS_OFFSET 1
-#define SPI_PS_SIZE 1
-#define SPI_PCSDEC_OFFSET 2
-#define SPI_PCSDEC_SIZE 1
-#define SPI_FDIV_OFFSET 3
-#define SPI_FDIV_SIZE 1
-#define SPI_MODFDIS_OFFSET 4
-#define SPI_MODFDIS_SIZE 1
-#define SPI_LLB_OFFSET 7
-#define SPI_LLB_SIZE 1
-#define SPI_PCS_OFFSET 16
-#define SPI_PCS_SIZE 4
-#define SPI_DLYBCS_OFFSET 24
-#define SPI_DLYBCS_SIZE 8
-
-/* Bitfields in RDR */
-#define SPI_RD_OFFSET 0
-#define SPI_RD_SIZE 16
-
-/* Bitfields in TDR */
-#define SPI_TD_OFFSET 0
-#define SPI_TD_SIZE 16
-
-/* Bitfields in SR */
-#define SPI_RDRF_OFFSET 0
-#define SPI_RDRF_SIZE 1
-#define SPI_TDRE_OFFSET 1
-#define SPI_TDRE_SIZE 1
-#define SPI_MODF_OFFSET 2
-#define SPI_MODF_SIZE 1
-#define SPI_OVRES_OFFSET 3
-#define SPI_OVRES_SIZE 1
-#define SPI_ENDRX_OFFSET 4
-#define SPI_ENDRX_SIZE 1
-#define SPI_ENDTX_OFFSET 5
-#define SPI_ENDTX_SIZE 1
-#define SPI_RXBUFF_OFFSET 6
-#define SPI_RXBUFF_SIZE 1
-#define SPI_TXBUFE_OFFSET 7
-#define SPI_TXBUFE_SIZE 1
-#define SPI_NSSR_OFFSET 8
-#define SPI_NSSR_SIZE 1
-#define SPI_TXEMPTY_OFFSET 9
-#define SPI_TXEMPTY_SIZE 1
-#define SPI_SPIENS_OFFSET 16
-#define SPI_SPIENS_SIZE 1
-
-/* Bitfields in CSR0 */
-#define SPI_CPOL_OFFSET 0
-#define SPI_CPOL_SIZE 1
-#define SPI_NCPHA_OFFSET 1
-#define SPI_NCPHA_SIZE 1
-#define SPI_CSAAT_OFFSET 3
-#define SPI_CSAAT_SIZE 1
-#define SPI_BITS_OFFSET 4
-#define SPI_BITS_SIZE 4
-#define SPI_SCBR_OFFSET 8
-#define SPI_SCBR_SIZE 8
-#define SPI_DLYBS_OFFSET 16
-#define SPI_DLYBS_SIZE 8
-#define SPI_DLYBCT_OFFSET 24
-#define SPI_DLYBCT_SIZE 8
-
-/* Bitfields in RCR */
-#define SPI_RXCTR_OFFSET 0
-#define SPI_RXCTR_SIZE 16
-
-/* Bitfields in TCR */
-#define SPI_TXCTR_OFFSET 0
-#define SPI_TXCTR_SIZE 16
-
-/* Bitfields in RNCR */
-#define SPI_RXNCR_OFFSET 0
-#define SPI_RXNCR_SIZE 16
-
-/* Bitfields in TNCR */
-#define SPI_TXNCR_OFFSET 0
-#define SPI_TXNCR_SIZE 16
-
-/* Bitfields in PTCR */
-#define SPI_RXTEN_OFFSET 0
-#define SPI_RXTEN_SIZE 1
-#define SPI_RXTDIS_OFFSET 1
-#define SPI_RXTDIS_SIZE 1
-#define SPI_TXTEN_OFFSET 8
-#define SPI_TXTEN_SIZE 1
-#define SPI_TXTDIS_OFFSET 9
-#define SPI_TXTDIS_SIZE 1
-
-/* Constants for BITS */
-#define SPI_BITS_8_BPT 0
-#define SPI_BITS_9_BPT 1
-#define SPI_BITS_10_BPT 2
-#define SPI_BITS_11_BPT 3
-#define SPI_BITS_12_BPT 4
-#define SPI_BITS_13_BPT 5
-#define SPI_BITS_14_BPT 6
-#define SPI_BITS_15_BPT 7
-#define SPI_BITS_16_BPT 8
-
-/* Bit manipulation macros */
-#define SPI_BIT(name) \
- (1 << SPI_##name##_OFFSET)
-#define SPI_BF(name,value) \
- (((value) & ((1 << SPI_##name##_SIZE) - 1)) << SPI_##name##_OFFSET)
-#define SPI_BFEXT(name,value) \
- (((value) >> SPI_##name##_OFFSET) & ((1 << SPI_##name##_SIZE) - 1))
-#define SPI_BFINS(name,value,old) \
- ( ((old) & ~(((1 << SPI_##name##_SIZE) - 1) << SPI_##name##_OFFSET)) \
- | SPI_BF(name,value))
-
-/* Register access macros */
-#define spi_readl(port,reg) \
- __raw_readl((port)->regs + SPI_##reg)
-#define spi_writel(port,reg,value) \
- __raw_writel((value), (port)->regs + SPI_##reg)
-
-#endif /* __ATMEL_SPI_H__ */
diff --git a/drivers/spi/ath79_spi.c b/drivers/spi/spi_ath79.c
similarity index 100%
rename from drivers/spi/ath79_spi.c
rename to drivers/spi/spi_ath79.c
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/spi_atmel.c
similarity index 85%
rename from drivers/spi/atmel_spi.c
rename to drivers/spi/spi_atmel.c
index 08711e9..82dee9a 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/spi_atmel.c
@@ -25,7 +25,160 @@
#include <mach/gpio.h>
#include <mach/cpu.h>

-#include "atmel_spi.h"
+/* SPI register offsets */
+#define SPI_CR 0x0000
+#define SPI_MR 0x0004
+#define SPI_RDR 0x0008
+#define SPI_TDR 0x000c
+#define SPI_SR 0x0010
+#define SPI_IER 0x0014
+#define SPI_IDR 0x0018
+#define SPI_IMR 0x001c
+#define SPI_CSR0 0x0030
+#define SPI_CSR1 0x0034
+#define SPI_CSR2 0x0038
+#define SPI_CSR3 0x003c
+#define SPI_RPR 0x0100
+#define SPI_RCR 0x0104
+#define SPI_TPR 0x0108
+#define SPI_TCR 0x010c
+#define SPI_RNPR 0x0110
+#define SPI_RNCR 0x0114
+#define SPI_TNPR 0x0118
+#define SPI_TNCR 0x011c
+#define SPI_PTCR 0x0120
+#define SPI_PTSR 0x0124
+
+/* Bitfields in CR */
+#define SPI_SPIEN_OFFSET 0
+#define SPI_SPIEN_SIZE 1
+#define SPI_SPIDIS_OFFSET 1
+#define SPI_SPIDIS_SIZE 1
+#define SPI_SWRST_OFFSET 7
+#define SPI_SWRST_SIZE 1
+#define SPI_LASTXFER_OFFSET 24
+#define SPI_LASTXFER_SIZE 1
+
+/* Bitfields in MR */
+#define SPI_MSTR_OFFSET 0
+#define SPI_MSTR_SIZE 1
+#define SPI_PS_OFFSET 1
+#define SPI_PS_SIZE 1
+#define SPI_PCSDEC_OFFSET 2
+#define SPI_PCSDEC_SIZE 1
+#define SPI_FDIV_OFFSET 3
+#define SPI_FDIV_SIZE 1
+#define SPI_MODFDIS_OFFSET 4
+#define SPI_MODFDIS_SIZE 1
+#define SPI_LLB_OFFSET 7
+#define SPI_LLB_SIZE 1
+#define SPI_PCS_OFFSET 16
+#define SPI_PCS_SIZE 4
+#define SPI_DLYBCS_OFFSET 24
+#define SPI_DLYBCS_SIZE 8
+
+/* Bitfields in RDR */
+#define SPI_RD_OFFSET 0
+#define SPI_RD_SIZE 16
+
+/* Bitfields in TDR */
+#define SPI_TD_OFFSET 0
+#define SPI_TD_SIZE 16
+
+/* Bitfields in SR */
+#define SPI_RDRF_OFFSET 0
+#define SPI_RDRF_SIZE 1
+#define SPI_TDRE_OFFSET 1
+#define SPI_TDRE_SIZE 1
+#define SPI_MODF_OFFSET 2
+#define SPI_MODF_SIZE 1
+#define SPI_OVRES_OFFSET 3
+#define SPI_OVRES_SIZE 1
+#define SPI_ENDRX_OFFSET 4
+#define SPI_ENDRX_SIZE 1
+#define SPI_ENDTX_OFFSET 5
+#define SPI_ENDTX_SIZE 1
+#define SPI_RXBUFF_OFFSET 6
+#define SPI_RXBUFF_SIZE 1
+#define SPI_TXBUFE_OFFSET 7
+#define SPI_TXBUFE_SIZE 1
+#define SPI_NSSR_OFFSET 8
+#define SPI_NSSR_SIZE 1
+#define SPI_TXEMPTY_OFFSET 9
+#define SPI_TXEMPTY_SIZE 1
+#define SPI_SPIENS_OFFSET 16
+#define SPI_SPIENS_SIZE 1
+
+/* Bitfields in CSR0 */
+#define SPI_CPOL_OFFSET 0
+#define SPI_CPOL_SIZE 1
+#define SPI_NCPHA_OFFSET 1
+#define SPI_NCPHA_SIZE 1
+#define SPI_CSAAT_OFFSET 3
+#define SPI_CSAAT_SIZE 1
+#define SPI_BITS_OFFSET 4
+#define SPI_BITS_SIZE 4
+#define SPI_SCBR_OFFSET 8
+#define SPI_SCBR_SIZE 8
+#define SPI_DLYBS_OFFSET 16
+#define SPI_DLYBS_SIZE 8
+#define SPI_DLYBCT_OFFSET 24
+#define SPI_DLYBCT_SIZE 8
+
+/* Bitfields in RCR */
+#define SPI_RXCTR_OFFSET 0
+#define SPI_RXCTR_SIZE 16
+
+/* Bitfields in TCR */
+#define SPI_TXCTR_OFFSET 0
+#define SPI_TXCTR_SIZE 16
+
+/* Bitfields in RNCR */
+#define SPI_RXNCR_OFFSET 0
+#define SPI_RXNCR_SIZE 16
+
+/* Bitfields in TNCR */
+#define SPI_TXNCR_OFFSET 0
+#define SPI_TXNCR_SIZE 16
+
+/* Bitfields in PTCR */
+#define SPI_RXTEN_OFFSET 0
+#define SPI_RXTEN_SIZE 1
+#define SPI_RXTDIS_OFFSET 1
+#define SPI_RXTDIS_SIZE 1
+#define SPI_TXTEN_OFFSET 8
+#define SPI_TXTEN_SIZE 1
+#define SPI_TXTDIS_OFFSET 9
+#define SPI_TXTDIS_SIZE 1
+
+/* Constants for BITS */
+#define SPI_BITS_8_BPT 0
+#define SPI_BITS_9_BPT 1
+#define SPI_BITS_10_BPT 2
+#define SPI_BITS_11_BPT 3
+#define SPI_BITS_12_BPT 4
+#define SPI_BITS_13_BPT 5
+#define SPI_BITS_14_BPT 6
+#define SPI_BITS_15_BPT 7
+#define SPI_BITS_16_BPT 8
+
+/* Bit manipulation macros */
+#define SPI_BIT(name) \
+ (1 << SPI_##name##_OFFSET)
+#define SPI_BF(name,value) \
+ (((value) & ((1 << SPI_##name##_SIZE) - 1)) << SPI_##name##_OFFSET)
+#define SPI_BFEXT(name,value) \
+ (((value) >> SPI_##name##_OFFSET) & ((1 << SPI_##name##_SIZE) - 1))
+#define SPI_BFINS(name,value,old) \
+ ( ((old) & ~(((1 << SPI_##name##_SIZE) - 1) << SPI_##name##_OFFSET)) \
+ | SPI_BF(name,value))
+
+/* Register access macros */
+#define spi_readl(port,reg) \
+ __raw_readl((port)->regs + SPI_##reg)
+#define spi_writel(port,reg,value) \
+ __raw_writel((value), (port)->regs + SPI_##reg)
+

/*
* The core SPI transfer engine just talks to a register bank to set up
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/spi_au1550.c
similarity index 100%
rename from drivers/spi/au1550_spi.c
rename to drivers/spi/spi_au1550.c
diff --git a/drivers/spi/coldfire_qspi.c b/drivers/spi/spi_coldfire_qspi.c
similarity index 100%
rename from drivers/spi/coldfire_qspi.c
rename to drivers/spi/spi_coldfire_qspi.c
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/spi_davinci.c
similarity index 100%
rename from drivers/spi/davinci_spi.c
rename to drivers/spi/spi_davinci.c
diff --git a/drivers/spi/dw_spi.c b/drivers/spi/spi_dw.c
similarity index 99%
rename from drivers/spi/dw_spi.c
rename to drivers/spi/spi_dw.c
index 919fa9d..33b2b76 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/spi_dw.c
@@ -24,7 +24,7 @@
#include <linux/slab.h>
#include <linux/spi/spi.h>

-#include "dw_spi.h"
+#include "spi_dw.h"

#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
diff --git a/drivers/spi/dw_spi.h b/drivers/spi/spi_dw.h
similarity index 100%
rename from drivers/spi/dw_spi.h
rename to drivers/spi/spi_dw.h
diff --git a/drivers/spi/dw_spi_mid.c b/drivers/spi/spi_dw_mid.c
similarity index 99%
rename from drivers/spi/dw_spi_mid.c
rename to drivers/spi/spi_dw_mid.c
index 4891782..83311f8 100644
--- a/drivers/spi/dw_spi_mid.c
+++ b/drivers/spi/spi_dw_mid.c
@@ -23,7 +23,7 @@
#include <linux/slab.h>
#include <linux/spi/spi.h>

-#include "dw_spi.h"
+#include "spi_dw.h"

#ifdef CONFIG_SPI_DW_MID_DMA
#include <linux/intel_mid_dma.h>
diff --git a/drivers/spi/dw_spi_mmio.c b/drivers/spi/spi_dw_mmio.c
similarity index 99%
rename from drivers/spi/dw_spi_mmio.c
rename to drivers/spi/spi_dw_mmio.c
index e0e813d..9f0a2ce 100644
--- a/drivers/spi/dw_spi_mmio.c
+++ b/drivers/spi/spi_dw_mmio.c
@@ -16,7 +16,7 @@
#include <linux/spi/spi.h>
#include <linux/scatterlist.h>

-#include "dw_spi.h"
+#include "spi_dw.h"

#define DRIVER_NAME "dw_spi_mmio"

diff --git a/drivers/spi/dw_spi_pci.c b/drivers/spi/spi_dw_pci.c
similarity index 99%
rename from drivers/spi/dw_spi_pci.c
rename to drivers/spi/spi_dw_pci.c
index ad260aa..4877d1a 100644
--- a/drivers/spi/dw_spi_pci.c
+++ b/drivers/spi/spi_dw_pci.c
@@ -22,7 +22,7 @@
#include <linux/slab.h>
#include <linux/spi/spi.h>

-#include "dw_spi.h"
+#include "spi_dw.h"

#define DRIVER_NAME "dw_spi_pci"

diff --git a/drivers/spi/ep93xx_spi.c b/drivers/spi/spi_ep93xx.c
similarity index 100%
rename from drivers/spi/ep93xx_spi.c
rename to drivers/spi/spi_ep93xx.c
diff --git a/drivers/spi/mpc512x_psc_spi.c b/drivers/spi/spi_mpc512x_psc.c
similarity index 100%
rename from drivers/spi/mpc512x_psc_spi.c
rename to drivers/spi/spi_mpc512x_psc.c
diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/spi_mpc52xx.c
similarity index 100%
rename from drivers/spi/mpc52xx_spi.c
rename to drivers/spi/spi_mpc52xx.c
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/spi_mpc52xx_psc.c
similarity index 100%
rename from drivers/spi/mpc52xx_psc_spi.c
rename to drivers/spi/spi_mpc52xx_psc.c
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/spi_omap2_mcspi.c
similarity index 100%
rename from drivers/spi/omap2_mcspi.c
rename to drivers/spi/spi_omap2_mcspi.c
diff --git a/drivers/spi/omap_spi_100k.c b/drivers/spi/spi_omap_100k.c
similarity index 100%
rename from drivers/spi/omap_spi_100k.c
rename to drivers/spi/spi_omap_100k.c
diff --git a/drivers/spi/omap_uwire.c b/drivers/spi/spi_omap_uwire.c
similarity index 100%
rename from drivers/spi/omap_uwire.c
rename to drivers/spi/spi_omap_uwire.c
diff --git a/drivers/spi/orion_spi.c b/drivers/spi/spi_orion.c
similarity index 100%
rename from drivers/spi/orion_spi.c
rename to drivers/spi/spi_orion.c
diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/spi_pl022.c
similarity index 100%
rename from drivers/spi/amba-pl022.c
rename to drivers/spi/spi_pl022.c
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/spi_pxa2xx.c
similarity index 100%
rename from drivers/spi/pxa2xx_spi.c
rename to drivers/spi/spi_pxa2xx.c
diff --git a/drivers/spi/pxa2xx_spi_pci.c b/drivers/spi/spi_pxa2xx_pci.c
similarity index 100%
rename from drivers/spi/pxa2xx_spi_pci.c
rename to drivers/spi/spi_pxa2xx_pci.c
diff --git a/drivers/spi/ti-ssp-spi.c b/drivers/spi/spi_ti_ssp.c
similarity index 100%
rename from drivers/spi/ti-ssp-spi.c
rename to drivers/spi/spi_ti_ssp.c
diff --git a/drivers/spi/tle62x0.c b/drivers/spi/spi_tle62x0.c
similarity index 100%
rename from drivers/spi/tle62x0.c
rename to drivers/spi/spi_tle62x0.c
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/spi_xilinx.c
similarity index 100%
rename from drivers/spi/xilinx_spi.c
rename to drivers/spi/spi_xilinx.c


2011-06-05 07:43:30

by Jassi Brar

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Sun, Jun 5, 2011 at 12:48 PM, Grant Likely <[email protected]> wrote:
> [repost: I had a typo on the spi-devel-general mailing list address]
>
> Sort the SPI makefile and enforce the naming convention spi_*.c for
> spi drivers.
>
> This change also rolls the contents of atmel_spi.h into the .c file
> since there is only one user of that particular include file.
>
> Signed-off-by: Grant Likely <[email protected]>
> ---
>  drivers/spi/Makefile            |   80 ++++++++-----------
>  drivers/spi/atmel_spi.h         |  167 ---------------------------------------
>  drivers/spi/spi_ath79.c         |    0
>  drivers/spi/spi_atmel.c         |  155 ++++++++++++++++++++++++++++++++++++
>  drivers/spi/spi_au1550.c        |    0
>  drivers/spi/spi_coldfire_qspi.c |    0
>  drivers/spi/spi_davinci.c       |    0
>  drivers/spi/spi_dw.c            |    2
>  drivers/spi/spi_dw.h            |    0
>  drivers/spi/spi_dw_mid.c        |    2
>  drivers/spi/spi_dw_mmio.c       |    2
>  drivers/spi/spi_dw_pci.c        |    2
>  drivers/spi/spi_ep93xx.c        |    0
>  drivers/spi/spi_mpc512x_psc.c   |    0
>  drivers/spi/spi_mpc52xx.c       |    0
>  drivers/spi/spi_mpc52xx_psc.c   |    0
>  drivers/spi/spi_omap2_mcspi.c   |    0
>  drivers/spi/spi_omap_100k.c     |    0
>  drivers/spi/spi_omap_uwire.c    |    0
>  drivers/spi/spi_orion.c         |    0
>  drivers/spi/spi_pl022.c         |    0
>  drivers/spi/spi_pxa2xx.c        |    0
>  drivers/spi/spi_pxa2xx_pci.c    |    0
>  drivers/spi/spi_ti_ssp.c        |    0
>  drivers/spi/spi_tle62x0.c       |    0
>  drivers/spi/spi_xilinx.c        |    0

Though the spi_ prefix seems redundant considering the files are in
'spi' directory.
Just a thought, no objection.

2011-06-05 08:42:02

by Baruch Siach

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

Hi Jassi,

On Sun, Jun 05, 2011 at 01:13:28PM +0530, Jassi Brar wrote:
> On Sun, Jun 5, 2011 at 12:48 PM, Grant Likely <[email protected]> wrote:
> > [repost: I had a typo on the spi-devel-general mailing list address]
> >
> > Sort the SPI makefile and enforce the naming convention spi_*.c for
> > spi drivers.

[snip]

> Though the spi_ prefix seems redundant considering the files are in
> 'spi' directory.
> Just a thought, no objection.

When looking at the list of loaded modules (e.g. in an Oops message), the name
"spi_xilinx" is much more meaningful than just "xilinx", for example.

baruch

--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -

2011-06-05 08:15:50

by Mika Westerberg

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Sun, Jun 05, 2011 at 01:18:14AM -0600, Grant Likely wrote:
> [repost: I had a typo on the spi-devel-general mailing list address]
>
> Sort the SPI makefile and enforce the naming convention spi_*.c for
> spi drivers.
>
> This change also rolls the contents of atmel_spi.h into the .c file
> since there is only one user of that particular include file.
>
> Signed-off-by: Grant Likely <[email protected]>
> ---
> drivers/spi/Makefile | 80 ++++++++-----------
> drivers/spi/atmel_spi.h | 167 ---------------------------------------
> drivers/spi/spi_ath79.c | 0
> drivers/spi/spi_atmel.c | 155 ++++++++++++++++++++++++++++++++++++
> drivers/spi/spi_au1550.c | 0
> drivers/spi/spi_coldfire_qspi.c | 0
> drivers/spi/spi_davinci.c | 0
> drivers/spi/spi_dw.c | 2
> drivers/spi/spi_dw.h | 0
> drivers/spi/spi_dw_mid.c | 2
> drivers/spi/spi_dw_mmio.c | 2
> drivers/spi/spi_dw_pci.c | 2
> drivers/spi/spi_ep93xx.c | 0
> drivers/spi/spi_mpc512x_psc.c | 0
> drivers/spi/spi_mpc52xx.c | 0
> drivers/spi/spi_mpc52xx_psc.c | 0
> drivers/spi/spi_omap2_mcspi.c | 0
> drivers/spi/spi_omap_100k.c | 0
> drivers/spi/spi_omap_uwire.c | 0
> drivers/spi/spi_orion.c | 0
> drivers/spi/spi_pl022.c | 0
> drivers/spi/spi_pxa2xx.c | 0
> drivers/spi/spi_pxa2xx_pci.c | 0
> drivers/spi/spi_ti_ssp.c | 0
> drivers/spi/spi_tle62x0.c | 0
> drivers/spi/spi_xilinx.c | 0
> 26 files changed, 192 insertions(+), 218 deletions(-)
> delete mode 100644 drivers/spi/atmel_spi.h
> rename drivers/spi/{ath79_spi.c => spi_ath79.c} (100%)
> rename drivers/spi/{atmel_spi.c => spi_atmel.c} (85%)
> rename drivers/spi/{au1550_spi.c => spi_au1550.c} (100%)
> rename drivers/spi/{coldfire_qspi.c => spi_coldfire_qspi.c} (100%)
> rename drivers/spi/{davinci_spi.c => spi_davinci.c} (100%)
> rename drivers/spi/{dw_spi.c => spi_dw.c} (99%)
> rename drivers/spi/{dw_spi.h => spi_dw.h} (100%)
> rename drivers/spi/{dw_spi_mid.c => spi_dw_mid.c} (99%)
> rename drivers/spi/{dw_spi_mmio.c => spi_dw_mmio.c} (99%)
> rename drivers/spi/{dw_spi_pci.c => spi_dw_pci.c} (99%)
> rename drivers/spi/{ep93xx_spi.c => spi_ep93xx.c} (100%)
> rename drivers/spi/{mpc512x_psc_spi.c => spi_mpc512x_psc.c} (100%)
> rename drivers/spi/{mpc52xx_spi.c => spi_mpc52xx.c} (100%)
> rename drivers/spi/{mpc52xx_psc_spi.c => spi_mpc52xx_psc.c} (100%)
> rename drivers/spi/{omap2_mcspi.c => spi_omap2_mcspi.c} (100%)
> rename drivers/spi/{omap_spi_100k.c => spi_omap_100k.c} (100%)
> rename drivers/spi/{omap_uwire.c => spi_omap_uwire.c} (100%)
> rename drivers/spi/{orion_spi.c => spi_orion.c} (100%)
> rename drivers/spi/{amba-pl022.c => spi_pl022.c} (100%)
> rename drivers/spi/{pxa2xx_spi.c => spi_pxa2xx.c} (100%)
> rename drivers/spi/{pxa2xx_spi_pci.c => spi_pxa2xx_pci.c} (100%)
> rename drivers/spi/{ti-ssp-spi.c => spi_ti_ssp.c} (100%)
> rename drivers/spi/{tle62x0.c => spi_tle62x0.c} (100%)
> rename drivers/spi/{xilinx_spi.c => spi_xilinx.c} (100%)

We also have things like this in drivers/spi/Kconfig:

config SPI_DAVINCI
...

This driver can also be built as a module. The module will
be called davinci_spi <--- This is now wrong

should these be converted as well?

2011-06-05 11:49:58

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Sun, Jun 5, 2011 at 09:54, Baruch Siach <[email protected]> wrote:
> On Sun, Jun 05, 2011 at 01:13:28PM +0530, Jassi Brar wrote:
>> On Sun, Jun 5, 2011 at 12:48 PM, Grant Likely <[email protected]> wrote:
>> > [repost: I had a typo on the spi-devel-general mailing list address]
>> >
>> > Sort the SPI makefile and enforce the naming convention spi_*.c for
>> > spi drivers.
>
> [snip]
>
>> Though the spi_ prefix seems redundant considering the files are in
>> 'spi' directory.
>> Just a thought, no objection.
>
> When looking at the list of loaded modules (e.g. in an Oops message), the name
> "spi_xilinx" is much more meaningful than just "xilinx", for example.

Plus, when dropping the prefix, spi_xilinx.ko and gpio-xilinx.ko
become the same...

So now we have spi_<name>.c (with underscore) and gpio-<name>.c (with dash)?
And other subsystems go with <name>-<type>.c instead, e.g.
drivers/mfd/wm831x-spi.c?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

2011-06-05 13:08:35

by Stefan Richter

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Jun 05 Geert Uytterhoeven wrote:
> On Sun, Jun 5, 2011 at 09:54, Baruch Siach <[email protected]> wrote:
> > On Sun, Jun 05, 2011 at 01:13:28PM +0530, Jassi Brar wrote:
> >> On Sun, Jun 5, 2011 at 12:48 PM, Grant Likely <[email protected]> wrote:
> >> > [repost: I had a typo on the spi-devel-general mailing list address]
> >> >
> >> > Sort the SPI makefile and enforce the naming convention spi_*.c for
> >> > spi drivers.
> >
> > [snip]
> >
> >> Though the spi_ prefix seems redundant considering the files are in
> >> 'spi' directory.
> >> Just a thought, no objection.
> >
> > When looking at the list of loaded modules (e.g. in an Oops message), the name
> > "spi_xilinx" is much more meaningful than just "xilinx", for example.
>
> Plus, when dropping the prefix, spi_xilinx.ko and gpio-xilinx.ko
> become the same...

In drivers/firewire/Makefile for example, there is this:

firewire-core-y += core-card.o core-cdev.o core-device.o \
core-iso.o core-topology.o core-transaction.o
firewire-ohci-y += ohci.o
firewire-sbp2-y += sbp2.o
firewire-net-y += net.o

Which is impractical though if there are more than a handful of drivers
involved.
--
Stefan Richter
-=====-==-== -==- --=-=
http://arcgraph.de/sr/

2011-06-05 13:12:48

by Jassi Brar

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

Hi Baruch,

On Sun, Jun 5, 2011 at 1:24 PM, Baruch Siach <[email protected]> wrote:
>> Though the spi_ prefix seems redundant considering the files are in
>> 'spi' directory.
>> Just a thought, no objection.
>
> When looking at the list of loaded modules (e.g. in an Oops message), the name
> "spi_xilinx" is much more meaningful than just "xilinx", for example.
Good catch.
Perhaps we could get Makefile to build modules with spi_ prefix. Just
like USB gadgets do ?

2011-06-05 14:37:22

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Sun, Jun 5, 2011 at 2:13 AM, Mika Westerberg <[email protected]> wrote:
> On Sun, Jun 05, 2011 at 01:18:14AM -0600, Grant Likely wrote:
>> [repost: I had a typo on the spi-devel-general mailing list address]
>>
>> Sort the SPI makefile and enforce the naming convention spi_*.c for
>> spi drivers.
>>
>> This change also rolls the contents of atmel_spi.h into the .c file
>> since there is only one user of that particular include file.
>>
>> Signed-off-by: Grant Likely <[email protected]>
>> ---
>> ?drivers/spi/Makefile ? ? ? ? ? ?| ? 80 ++++++++-----------
>> ?drivers/spi/atmel_spi.h ? ? ? ? | ?167 ---------------------------------------
>> ?drivers/spi/spi_ath79.c ? ? ? ? | ? ?0
>> ?drivers/spi/spi_atmel.c ? ? ? ? | ?155 ++++++++++++++++++++++++++++++++++++
>> ?drivers/spi/spi_au1550.c ? ? ? ?| ? ?0
>> ?drivers/spi/spi_coldfire_qspi.c | ? ?0
>> ?drivers/spi/spi_davinci.c ? ? ? | ? ?0
>> ?drivers/spi/spi_dw.c ? ? ? ? ? ?| ? ?2
>> ?drivers/spi/spi_dw.h ? ? ? ? ? ?| ? ?0
>> ?drivers/spi/spi_dw_mid.c ? ? ? ?| ? ?2
>> ?drivers/spi/spi_dw_mmio.c ? ? ? | ? ?2
>> ?drivers/spi/spi_dw_pci.c ? ? ? ?| ? ?2
>> ?drivers/spi/spi_ep93xx.c ? ? ? ?| ? ?0
>> ?drivers/spi/spi_mpc512x_psc.c ? | ? ?0
>> ?drivers/spi/spi_mpc52xx.c ? ? ? | ? ?0
>> ?drivers/spi/spi_mpc52xx_psc.c ? | ? ?0
>> ?drivers/spi/spi_omap2_mcspi.c ? | ? ?0
>> ?drivers/spi/spi_omap_100k.c ? ? | ? ?0
>> ?drivers/spi/spi_omap_uwire.c ? ?| ? ?0
>> ?drivers/spi/spi_orion.c ? ? ? ? | ? ?0
>> ?drivers/spi/spi_pl022.c ? ? ? ? | ? ?0
>> ?drivers/spi/spi_pxa2xx.c ? ? ? ?| ? ?0
>> ?drivers/spi/spi_pxa2xx_pci.c ? ?| ? ?0
>> ?drivers/spi/spi_ti_ssp.c ? ? ? ?| ? ?0
>> ?drivers/spi/spi_tle62x0.c ? ? ? | ? ?0
>> ?drivers/spi/spi_xilinx.c ? ? ? ?| ? ?0
>> ?26 files changed, 192 insertions(+), 218 deletions(-)
>> ?delete mode 100644 drivers/spi/atmel_spi.h
>> ?rename drivers/spi/{ath79_spi.c => spi_ath79.c} (100%)
>> ?rename drivers/spi/{atmel_spi.c => spi_atmel.c} (85%)
>> ?rename drivers/spi/{au1550_spi.c => spi_au1550.c} (100%)
>> ?rename drivers/spi/{coldfire_qspi.c => spi_coldfire_qspi.c} (100%)
>> ?rename drivers/spi/{davinci_spi.c => spi_davinci.c} (100%)
>> ?rename drivers/spi/{dw_spi.c => spi_dw.c} (99%)
>> ?rename drivers/spi/{dw_spi.h => spi_dw.h} (100%)
>> ?rename drivers/spi/{dw_spi_mid.c => spi_dw_mid.c} (99%)
>> ?rename drivers/spi/{dw_spi_mmio.c => spi_dw_mmio.c} (99%)
>> ?rename drivers/spi/{dw_spi_pci.c => spi_dw_pci.c} (99%)
>> ?rename drivers/spi/{ep93xx_spi.c => spi_ep93xx.c} (100%)
>> ?rename drivers/spi/{mpc512x_psc_spi.c => spi_mpc512x_psc.c} (100%)
>> ?rename drivers/spi/{mpc52xx_spi.c => spi_mpc52xx.c} (100%)
>> ?rename drivers/spi/{mpc52xx_psc_spi.c => spi_mpc52xx_psc.c} (100%)
>> ?rename drivers/spi/{omap2_mcspi.c => spi_omap2_mcspi.c} (100%)
>> ?rename drivers/spi/{omap_spi_100k.c => spi_omap_100k.c} (100%)
>> ?rename drivers/spi/{omap_uwire.c => spi_omap_uwire.c} (100%)
>> ?rename drivers/spi/{orion_spi.c => spi_orion.c} (100%)
>> ?rename drivers/spi/{amba-pl022.c => spi_pl022.c} (100%)
>> ?rename drivers/spi/{pxa2xx_spi.c => spi_pxa2xx.c} (100%)
>> ?rename drivers/spi/{pxa2xx_spi_pci.c => spi_pxa2xx_pci.c} (100%)
>> ?rename drivers/spi/{ti-ssp-spi.c => spi_ti_ssp.c} (100%)
>> ?rename drivers/spi/{tle62x0.c => spi_tle62x0.c} (100%)
>> ?rename drivers/spi/{xilinx_spi.c => spi_xilinx.c} (100%)
>
> We also have things like this in drivers/spi/Kconfig:
>
> config SPI_DAVINCI
> ? ? ? ?...
>
> ? ? ? ?This driver can also be built as a module. The module will
> ? ? ? ?be called davinci_spi <--- This is now wrong
>
> should these be converted as well?

yes.

g.

2011-06-05 20:55:59

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Sun, Jun 5, 2011 at 5:49 AM, Geert Uytterhoeven <[email protected]> wrote:
> On Sun, Jun 5, 2011 at 09:54, Baruch Siach <[email protected]> wrote:
>> On Sun, Jun 05, 2011 at 01:13:28PM +0530, Jassi Brar wrote:
>>> On Sun, Jun 5, 2011 at 12:48 PM, Grant Likely <[email protected]> wrote:
>>> > [repost: I had a typo on the spi-devel-general mailing list address]
>>> >
>>> > Sort the SPI makefile and enforce the naming convention spi_*.c for
>>> > spi drivers.
>>
>> [snip]
>>
>>> Though the spi_ prefix seems redundant considering the files are in
>>> 'spi' directory.
>>> Just a thought, no objection.
>>
>> When looking at the list of loaded modules (e.g. in an Oops message), the name
>> "spi_xilinx" is much more meaningful than just "xilinx", for example.
>
> Plus, when dropping the prefix, spi_xilinx.ko and gpio-xilinx.ko
> become the same...

Exactly. We essentially have a flat namespace for modules, despite
the fact of them being organized into directories. At least for the
subsystems I maintain, I'd like to have a consistent prefix for that
reason.

> So now we have spi_<name>.c (with underscore) and gpio-<name>.c (with dash)?
> And other subsystems go with <name>-<type>.c instead, e.g.
> drivers/mfd/wm831x-spi.c?

On a brief survey of drivers:

apci: *.c
ata: pata_*.c, sata_*.c
atm: *.c
block: *.c
bluetooth: *.c
crypto: *.c
dma: *dma.c
gpio: gpio-*.c (after applying my patch)
hid: hid-*.c
hwmon: *.c
i2c: i2c-*.c
ide: *.c and ide-*.c
input: *.c
leds: leds-*.c
mca: mca-*.c
md: largely dm-*.c
mfd: *.c
mmc: *.c
mtd: *.c
net: *.c
rtc: rtc-*.c
scsi: *.c and scsi_*.c for core code
spi: (before patch) mix of spi_*.c and *_spi.c and *.c
uio: uio_*.c
virtio: virtio_*.c
wdt: *wdt.c and *_wdt.c

So, in this (admittedly incomplete) survey, I see 5 users of the
"prefix_" pattern, 8 of the "prefix-" pattern, a small number using a
suffix, and a whole lot without any pattern at all. Personally, I
prefer the using a prefix with a '-', but in the spi directory there
was already a number of drivers using '_', so it was smaller impact to
change to using that instead of a dash. If people don't think it is a
big deal though, then I'll change it to '-' to match the gpio change.

g.

2011-06-05 20:58:11

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Sun, Jun 5, 2011 at 7:12 AM, Jassi Brar <[email protected]> wrote:
> Hi Baruch,
>
> On Sun, Jun 5, 2011 at 1:24 PM, Baruch Siach <[email protected]> wrote:
>>> Though the spi_ prefix seems redundant considering the files are in
>>> 'spi' directory.
>>> Just a thought, no objection.
>>
>> When looking at the list of loaded modules (e.g. in an Oops message), the name
>> "spi_xilinx" is much more meaningful than just "xilinx", for example.
> Good catch.
> Perhaps we could get Makefile to build modules with spi_ prefix. Just
> like USB gadgets do ?

I don't think it's worth mucking about with <module_name>-y :=
filename.o when the filename can just be made the same as the module
name.

g.

--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

2011-06-05 21:19:38

by Jassi Brar

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

> On Sun, Jun 5, 2011 at 5:49 AM, Geert Uytterhoeven <[email protected]> wrote:
>>>> Though the spi_ prefix seems redundant considering the files are in
>>>> 'spi' directory.
>>>> Just a thought, no objection.
>>>
>>> When looking at the list of loaded modules (e.g. in an Oops message), the name
>>> "spi_xilinx" is much more meaningful than just "xilinx", for example.
>>
>> Plus, when dropping the prefix, spi_xilinx.ko and gpio-xilinx.ko
>> become the same...
As I said, the modules could still be made spi_xilinx.ko from
drivers/spi/xilinx.c
and gpio_xilinx.ko from drivers/gpio/xilinx.c


On Mon, Jun 6, 2011 at 2:25 AM, Grant Likely <[email protected]> wrote:
>> Perhaps we could get Makefile to build modules with spi_ prefix. Just
>> like USB gadgets do ?
> I don't think it's worth mucking about with <module_name>-y :=
> filename.o when the filename can just be made the same as the module
> name.
Well, the solution was for discarding the 'redundant' prefix and yet
have device specific
module names. Not just for the sake of it.

Anyways, I don't wanna be bitchy about it. I can buy at face value
from a maintainer.
I am ok with the proposed naming.

Cheers!
-j

2011-06-06 09:01:51

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Sunday 05 June 2011, Grant Likely wrote:
> rename drivers/spi/{omap2_mcspi.c => spi_omap2_mcspi.c} (100%)
> rename drivers/spi/{omap_spi_100k.c => spi_omap_100k.c} (100%)
> rename drivers/spi/{omap_uwire.c => spi_omap_uwire.c} (100%)
> rename drivers/spi/{orion_spi.c => spi_orion.c} (100%)
> rename drivers/spi/{amba-pl022.c => spi_pl022.c} (100%)
> rename drivers/spi/{pxa2xx_spi.c => spi_pxa2xx.c} (100%)
> rename drivers/spi/{pxa2xx_spi_pci.c => spi_pxa2xx_pci.c} (100%)
> rename drivers/spi/{ti-ssp-spi.c => spi_ti_ssp.c} (100%)
> rename drivers/spi/{tle62x0.c => spi_tle62x0.c} (100%)
> rename drivers/spi/{xilinx_spi.c => spi_xilinx.c} (100%)

I recently looked at the directory structure in drivers/ and found a lot
of bus drivers with very few files, plus a few bus drivers with a lot
of files in them besides directories for non-bus specific subsystems.

I think it would be good to move them into a deeper directory drivers/bus/
if we have support from the maintainers, and it's probably better if we
only have to move the files once to reduce the amount of churn on the
MAINTAINERS file and any out of tree patches.

Specifically, I'd like to do these moves:

drivers/{ => bus}/amba
drivers/{ => bus}/dio
drivers/{ => bus}/eisa
drivers/{ => bus}/firewire
drivers/{ => bus}/i2c
drivers/{ => bus}/mca
drivers/{ => bus}/nubus
drivers/{ => bus}/pcmcia
drivers/{ => bus}/rapidio
drivers/{ => bus}/sbus
drivers/{ => bus}/spi
drivers/{ => bus}/ssb
drivers/{ => bus}/tc
drivers/{ => bus}/uwb
drivers/{ => bus}/virtio
drivers/{ => bus}/vlync
drivers/{ => bus}/w1
drivers/{ => bus}/zorro

This leaves out the two most common buses, USB and PCI, mostly because
the directories contain a lot of stuff that is not really bus code
but actual drivers. It does include i2c and spi, which stick out by
being a lot larger than most others.

Opinions? Move or don't move?

Arnd

2011-06-06 09:08:12

by Dominik Brodowski

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Mon, Jun 06, 2011 at 11:00:38AM +0200, Arnd Bergmann wrote:
> On Sunday 05 June 2011, Grant Likely wrote:
> > rename drivers/spi/{omap2_mcspi.c => spi_omap2_mcspi.c} (100%)
> > rename drivers/spi/{omap_spi_100k.c => spi_omap_100k.c} (100%)
> > rename drivers/spi/{omap_uwire.c => spi_omap_uwire.c} (100%)
> > rename drivers/spi/{orion_spi.c => spi_orion.c} (100%)
> > rename drivers/spi/{amba-pl022.c => spi_pl022.c} (100%)
> > rename drivers/spi/{pxa2xx_spi.c => spi_pxa2xx.c} (100%)
> > rename drivers/spi/{pxa2xx_spi_pci.c => spi_pxa2xx_pci.c} (100%)
> > rename drivers/spi/{ti-ssp-spi.c => spi_ti_ssp.c} (100%)
> > rename drivers/spi/{tle62x0.c => spi_tle62x0.c} (100%)
> > rename drivers/spi/{xilinx_spi.c => spi_xilinx.c} (100%)
>
> I recently looked at the directory structure in drivers/ and found a lot
> of bus drivers with very few files, plus a few bus drivers with a lot
> of files in them besides directories for non-bus specific subsystems.
>
> I think it would be good to move them into a deeper directory drivers/bus/
> if we have support from the maintainers, and it's probably better if we
> only have to move the files once to reduce the amount of churn on the
> MAINTAINERS file and any out of tree patches.
>
> Specifically, I'd like to do these moves:
>
> drivers/{ => bus}/amba
> drivers/{ => bus}/dio
> drivers/{ => bus}/eisa
> drivers/{ => bus}/firewire
> drivers/{ => bus}/i2c
> drivers/{ => bus}/mca
> drivers/{ => bus}/nubus
> drivers/{ => bus}/pcmcia
> drivers/{ => bus}/rapidio
> drivers/{ => bus}/sbus
> drivers/{ => bus}/spi
> drivers/{ => bus}/ssb
> drivers/{ => bus}/tc
> drivers/{ => bus}/uwb
> drivers/{ => bus}/virtio
> drivers/{ => bus}/vlync
> drivers/{ => bus}/w1
> drivers/{ => bus}/zorro
>
> This leaves out the two most common buses, USB and PCI, mostly because
> the directories contain a lot of stuff that is not really bus code
> but actual drivers. It does include i2c and spi, which stick out by
> being a lot larger than most others.
>
> Opinions? Move or don't move?

For PCMCIA, you'd have my Acked-by, if it doesn't end up being the only
directory being moved ;)

Best
Dominik

2011-06-06 09:10:37

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Mon, Jun 06, 2011 at 11:00:38AM +0200, Arnd Bergmann wrote:
> This leaves out the two most common buses, USB and PCI, mostly because
> the directories contain a lot of stuff that is not really bus code
> but actual drivers. It does include i2c and spi, which stick out by
> being a lot larger than most others.
>
> Opinions? Move or don't move?

I don't see much point in adding an additional level of directories.
All that it'll do is add to the shell filename completion workload
and wear out our tab keys faster...

We'll still have these directories with not a lot under them.

2011-06-06 09:18:31

by Jean Delvare

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Mon, 6 Jun 2011 11:00:38 +0200, Arnd Bergmann wrote:
> On Sunday 05 June 2011, Grant Likely wrote:
> > rename drivers/spi/{omap2_mcspi.c => spi_omap2_mcspi.c} (100%)
> > rename drivers/spi/{omap_spi_100k.c => spi_omap_100k.c} (100%)
> > rename drivers/spi/{omap_uwire.c => spi_omap_uwire.c} (100%)
> > rename drivers/spi/{orion_spi.c => spi_orion.c} (100%)
> > rename drivers/spi/{amba-pl022.c => spi_pl022.c} (100%)
> > rename drivers/spi/{pxa2xx_spi.c => spi_pxa2xx.c} (100%)
> > rename drivers/spi/{pxa2xx_spi_pci.c => spi_pxa2xx_pci.c} (100%)
> > rename drivers/spi/{ti-ssp-spi.c => spi_ti_ssp.c} (100%)
> > rename drivers/spi/{tle62x0.c => spi_tle62x0.c} (100%)
> > rename drivers/spi/{xilinx_spi.c => spi_xilinx.c} (100%)
>
> I recently looked at the directory structure in drivers/ and found a lot
> of bus drivers with very few files, plus a few bus drivers with a lot
> of files in them besides directories for non-bus specific subsystems.
>
> I think it would be good to move them into a deeper directory drivers/bus/
> if we have support from the maintainers, and it's probably better if we
> only have to move the files once to reduce the amount of churn on the
> MAINTAINERS file and any out of tree patches.
>
> Specifically, I'd like to do these moves:
>
> drivers/{ => bus}/amba
> drivers/{ => bus}/dio
> drivers/{ => bus}/eisa
> drivers/{ => bus}/firewire
> drivers/{ => bus}/i2c
> drivers/{ => bus}/mca
> drivers/{ => bus}/nubus
> drivers/{ => bus}/pcmcia
> drivers/{ => bus}/rapidio
> drivers/{ => bus}/sbus
> drivers/{ => bus}/spi
> drivers/{ => bus}/ssb
> drivers/{ => bus}/tc
> drivers/{ => bus}/uwb
> drivers/{ => bus}/virtio
> drivers/{ => bus}/vlync
> drivers/{ => bus}/w1
> drivers/{ => bus}/zorro
>
> This leaves out the two most common buses, USB and PCI, mostly because
> the directories contain a lot of stuff that is not really bus code
> but actual drivers. It does include i2c and spi, which stick out by
> being a lot larger than most others.
>
> Opinions? Move or don't move?

No opinion, I just don't care.

--
Jean Delvare

2011-06-06 09:29:13

by James Bottomley

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Mon, 2011-06-06 at 11:00 +0200, Arnd Bergmann wrote:
> On Sunday 05 June 2011, Grant Likely wrote:
> > rename drivers/spi/{omap2_mcspi.c => spi_omap2_mcspi.c} (100%)
> > rename drivers/spi/{omap_spi_100k.c => spi_omap_100k.c} (100%)
> > rename drivers/spi/{omap_uwire.c => spi_omap_uwire.c} (100%)
> > rename drivers/spi/{orion_spi.c => spi_orion.c} (100%)
> > rename drivers/spi/{amba-pl022.c => spi_pl022.c} (100%)
> > rename drivers/spi/{pxa2xx_spi.c => spi_pxa2xx.c} (100%)
> > rename drivers/spi/{pxa2xx_spi_pci.c => spi_pxa2xx_pci.c} (100%)
> > rename drivers/spi/{ti-ssp-spi.c => spi_ti_ssp.c} (100%)
> > rename drivers/spi/{tle62x0.c => spi_tle62x0.c} (100%)
> > rename drivers/spi/{xilinx_spi.c => spi_xilinx.c} (100%)
>
> I recently looked at the directory structure in drivers/ and found a lot
> of bus drivers with very few files, plus a few bus drivers with a lot
> of files in them besides directories for non-bus specific subsystems.
>
> I think it would be good to move them into a deeper directory drivers/bus/
> if we have support from the maintainers, and it's probably better if we
> only have to move the files once to reduce the amount of churn on the
> MAINTAINERS file and any out of tree patches.
>
> Specifically, I'd like to do these moves:
>
> drivers/{ => bus}/amba
> drivers/{ => bus}/dio
> drivers/{ => bus}/eisa
> drivers/{ => bus}/firewire
> drivers/{ => bus}/i2c
> drivers/{ => bus}/mca
> drivers/{ => bus}/nubus
> drivers/{ => bus}/pcmcia
> drivers/{ => bus}/rapidio
> drivers/{ => bus}/sbus
> drivers/{ => bus}/spi
> drivers/{ => bus}/ssb
> drivers/{ => bus}/tc
> drivers/{ => bus}/uwb
> drivers/{ => bus}/virtio
> drivers/{ => bus}/vlync
> drivers/{ => bus}/w1
> drivers/{ => bus}/zorro
>
> This leaves out the two most common buses, USB and PCI, mostly because
> the directories contain a lot of stuff that is not really bus code
> but actual drivers. It does include i2c and spi, which stick out by
> being a lot larger than most others.
>
> Opinions? Move or don't move?

I'd say it only makes sense if we do it for all busses ... so USB and
PCI would have to move too. Logically, the bus code should move and we
should be left with the drivers in both of those directories. I'd also
say that we don't have to deepen the tree: /bus would be fine. That
way, /drivers/<bus> would be only for <bus> specific drivers, with non
bus specific drivers we just group them by function as now.

What about the half busses (like SCSI)?

Finally, is there any real point (other than we can do it)? what is
actually helped by having the bus code obviously separated from the
driver code (assuming we sort out what is bus and what is driver)?

James

2011-06-06 10:01:40

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Mon, Jun 6, 2011 at 11:00, Arnd Bergmann <[email protected]> wrote:
> I recently looked at the directory structure in drivers/ and found a lot
> of bus drivers with very few files, plus a few bus drivers with a lot
> of files in them besides directories for non-bus specific subsystems.
>
> I think it would be good to move them into a deeper directory drivers/bus/
> if we have support from the maintainers, and it's probably better if we
> only have to move the files once to reduce the amount of churn on the
> MAINTAINERS file and any out of tree patches.
>
> Specifically, I'd like to do these moves:
>
> drivers/{ => bus}/zorro

(if we go that way in general)

Acked-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

2011-06-06 11:22:34

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Monday 06 June 2011, James Bottomley wrote:
> I'd say it only makes sense if we do it for all busses ... so USB and
> PCI would have to move too. Logically, the bus code should move and we
> should be left with the drivers in both of those directories. I'd also
> say that we don't have to deepen the tree: /bus would be fine. That
> way, /drivers/<bus> would be only for <bus> specific drivers, with non
> bus specific drivers we just group them by function as now.

A top-level /bus would work for me, and I guess would also address Russell's
concern. Regarding bus-specific drivers, we're gradually moving those out
of the bus specific directories anyway, basically the only bus directory
that really has device driver in it is USB at this point. It makes some
sense to have a bus-specific low-level user space interface driver like
sg or uio in the bus directory, but everything else should really belong
into some other subsystem.

> What about the half busses (like SCSI)?

I think SCSI is a really special case, not just because of its size
of more than twice the code than everything else I would suggest to
move, but also because it contains mostly host drivers but very few
device drivers (sd, sr, osst, st, and sg). In that sense it's more
a class of devices than a bus and fits in the same category as
mmc and ata than a bus like pci or i2c that have a multitude of
device drivers.

> Finally, is there any real point (other than we can do it)? what is
> actually helped by having the bus code obviously separated from the
> driver code (assuming we sort out what is bus and what is driver)?

Mostly I think the drivers/ subdirectory is getting a bit cluttered with
stuff that doesn't really fit together, and bus drivers are typically
directories with less than five files in them, apart from the few
exceptions that already came up.

This is about to get worse as we introduce new subsystems (e.g. iommu,
irq, clocksource, eeprom, nvram, ...) into which we are moving
code from arch/arm, drivers/char and drivers/misc. Having buses and
drivers in a separate hierarchy would make the drivers directory and
the respective menuconfig list more clearly structured IMHO.

Arnd

2011-06-06 12:17:40

by Jean Delvare

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Mon, 6 Jun 2011 13:21:07 +0200, Arnd Bergmann wrote:
> On Monday 06 June 2011, James Bottomley wrote:
> > I'd say it only makes sense if we do it for all busses ... so USB and
> > PCI would have to move too. Logically, the bus code should move and we
> > should be left with the drivers in both of those directories. I'd also
> > say that we don't have to deepen the tree: /bus would be fine. That
> > way, /drivers/<bus> would be only for <bus> specific drivers, with non
> > bus specific drivers we just group them by function as now.
>
> A top-level /bus would work for me, and I guess would also address Russell's
> concern. Regarding bus-specific drivers, we're gradually moving those out
> of the bus specific directories anyway, basically the only bus directory
> that really has device driver in it is USB at this point. It makes some
> sense to have a bus-specific low-level user space interface driver like
> sg or uio in the bus directory, but everything else should really belong
> into some other subsystem.

Err, what about I2C and SPI? Aren't drivers/i2c/busses and drivers/spi
full of "device drivers"? Or are these what you call "bus-specific
drivers"? Maybe we need to define all the terms before the discussion
continues further.

> (...)
> This is about to get worse as we introduce new subsystems (e.g. iommu,
> irq, clocksource, eeprom, nvram, ...) into which we are moving
> code from arch/arm, drivers/char and drivers/misc. Having buses and
> drivers in a separate hierarchy would make the drivers directory and
> the respective menuconfig list more clearly structured IMHO.

This gets interesting. Would you suggest for example that i2c-core.c
goes to bus/i2c, and drivers/i2c/busses becomes drivers/i2c? And that
CONFIG_I2C is somewhere in menuconfig, and the hardware driver
selection for drivers/i2c is in a totally different place?

While I am surprised, I am not necessarily objecting. But it seems that
you should better define what your actual plan is, before asking us if
we agree with it.

--
Jean Delvare

2011-06-06 12:35:12

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Mon, Jun 6, 2011 at 14:16, Jean Delvare <[email protected]> wrote:
> On Mon, 6 Jun 2011 13:21:07 +0200, Arnd Bergmann wrote:
>> On Monday 06 June 2011, James Bottomley wrote:
>> > I'd say it only makes sense if we do it for all busses ... so USB and
>> > PCI would have to move too.  Logically, the bus code should move and we
>> > should be left with the drivers in both of those directories.  I'd also
>> > say that we don't have to deepen the tree: /bus would be fine.  That
>> > way, /drivers/<bus> would be only for <bus> specific drivers, with non
>> > bus specific drivers we just group them by function as now.
>>
>> A top-level /bus would work for me, and I guess would also address Russell's
>> concern. Regarding bus-specific drivers, we're gradually moving those out
>> of the bus specific directories anyway, basically the only bus directory
>> that really has device driver in it is USB at this point. It makes some
>> sense to have a bus-specific low-level user space interface driver like
>> sg or uio in the bus directory, but everything else should really belong
>> into some other subsystem.
>
> Err, what about I2C and SPI? Aren't drivers/i2c/busses and drivers/spi
> full of "device drivers"? Or are these what you call "bus-specific
> drivers"? Maybe we need to define all the terms before the discussion
> continues further.

Arnd did write:

| It does include i2c and spi, which stick out by being a lot larger
than most others.

>> (...)
>> This is about to get worse as we introduce new subsystems (e.g. iommu,
>> irq, clocksource, eeprom, nvram, ...) into which we are moving
>> code from arch/arm, drivers/char and drivers/misc. Having buses and
>> drivers in a separate hierarchy would make the drivers directory and
>> the respective menuconfig list more clearly structured IMHO.
>
> This gets interesting. Would you suggest for example that i2c-core.c
> goes to bus/i2c, and drivers/i2c/busses becomes drivers/i2c? And that
> CONFIG_I2C is somewhere in menuconfig, and the hardware driver
> selection for drivers/i2c is in a totally different place?
>
> While I am surprised, I am not necessarily objecting. But it seems that
> you should better define what your actual plan is, before asking us if
> we agree with it.

Most other drivers are located based use case, i.e. from the user's
point of view,
e.g. drivers/net/ and drivers/video.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

2011-06-06 12:59:18

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Monday 06 June 2011, Jean Delvare wrote:
> On Mon, 6 Jun 2011 13:21:07 +0200, Arnd Bergmann wrote:
> > A top-level /bus would work for me, and I guess would also address Russell's
> > concern. Regarding bus-specific drivers, we're gradually moving those out
> > of the bus specific directories anyway, basically the only bus directory
> > that really has device driver in it is USB at this point. It makes some
> > sense to have a bus-specific low-level user space interface driver like
> > sg or uio in the bus directory, but everything else should really belong
> > into some other subsystem.
>
> Err, what about I2C and SPI? Aren't drivers/i2c/busses and drivers/spi
> full of "device drivers"? Or are these what you call "bus-specific
> drivers"? Maybe we need to define all the terms before the discussion
> continues further.

drivers/i2c/busses and drivers/spi are full of what I would call "bus
drivers" or "host drivers". They bind to a device from another bus
(platform, pci, ...) and export devices of their own type (i2c, spi, ...).
This is what all bus drivers do.

An i2c or spi device driver would in turn bind to that device and
provide a functionality not specific to that bus (e.g. hwmon, input,
leds, rtc or media).

> > (...)
> > This is about to get worse as we introduce new subsystems (e.g. iommu,
> > irq, clocksource, eeprom, nvram, ...) into which we are moving
> > code from arch/arm, drivers/char and drivers/misc. Having buses and
> > drivers in a separate hierarchy would make the drivers directory and
> > the respective menuconfig list more clearly structured IMHO.
>
> This gets interesting. Would you suggest for example that i2c-core.c
> goes to bus/i2c, and drivers/i2c/busses becomes drivers/i2c? And that
> CONFIG_I2C is somewhere in menuconfig, and the hardware driver
> selection for drivers/i2c is in a totally different place?

No, all of drivers/i2c would go into bus/i2c or drivers/bus/i2c, there
is no point splitting that. The part that would no go there is the various
drivers that are already not under drivers/i2c but are for devices
connected to an i2c bus.

The confusion is probably that in case of drivers/scsi and drivers/usb,
both bus and device drivers are in the same subdirectories. If we move
drivers/usb to bus/usb, I would probably recommend to split
drivers/usb/{serial,storage,atm,misc} out of it and move it to
drivers/{tty/usb-serial,block/usb,net/usb/atm,misc/usb} though, to
make it look more like PCI or i2c that already have a clean split.

> While I am surprised, I am not necessarily objecting. But it seems that
> you should better define what your actual plan is, before asking us if
> we agree with it.

My original plan was to think this through a bit more, but Grant posted
the big spi reorganization, so I jumped in on that because it wouldn't
be nice to have to move all those drivers again.

Arnd

2011-06-06 13:46:24

by Stefan Richter

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Jun 06 Arnd Bergmann wrote:
> On Monday 06 June 2011, Jean Delvare wrote:
> > On Mon, 6 Jun 2011 13:21:07 +0200, Arnd Bergmann wrote:
> > > A top-level /bus would work for me, and I guess would also address Russell's
> > > concern. Regarding bus-specific drivers, we're gradually moving those out
> > > of the bus specific directories anyway, basically the only bus directory
> > > that really has device driver in it is USB at this point. It makes some
> > > sense to have a bus-specific low-level user space interface driver like
> > > sg or uio in the bus directory, but everything else should really belong
> > > into some other subsystem.
> >
> > Err, what about I2C and SPI? Aren't drivers/i2c/busses and drivers/spi
> > full of "device drivers"? Or are these what you call "bus-specific
> > drivers"? Maybe we need to define all the terms before the discussion
> > continues further.
>
> drivers/i2c/busses and drivers/spi are full of what I would call "bus
> drivers" or "host drivers". They bind to a device from another bus
> (platform, pci, ...) and export devices of their own type (i2c, spi, ...).
> This is what all bus drivers do.
>
> An i2c or spi device driver would in turn bind to that device and
> provide a functionality not specific to that bus (e.g. hwmon, input,
> leds, rtc or media).
>
> > > (...)
> > > This is about to get worse as we introduce new subsystems (e.g. iommu,
> > > irq, clocksource, eeprom, nvram, ...) into which we are moving
> > > code from arch/arm, drivers/char and drivers/misc. Having buses and
> > > drivers in a separate hierarchy would make the drivers directory and
> > > the respective menuconfig list more clearly structured IMHO.
> >
> > This gets interesting. Would you suggest for example that i2c-core.c
> > goes to bus/i2c, and drivers/i2c/busses becomes drivers/i2c? And that
> > CONFIG_I2C is somewhere in menuconfig, and the hardware driver
> > selection for drivers/i2c is in a totally different place?
>
> No, all of drivers/i2c would go into bus/i2c or drivers/bus/i2c, there
> is no point splitting that. The part that would no go there is the various
> drivers that are already not under drivers/i2c but are for devices
> connected to an i2c bus.
>
> The confusion is probably that in case of drivers/scsi and drivers/usb,
> both bus and device drivers are in the same subdirectories. If we move
> drivers/usb to bus/usb, I would probably recommend to split
> drivers/usb/{serial,storage,atm,misc} out of it and move it to
> drivers/{tty/usb-serial,block/usb,net/usb/atm,misc/usb} though, to
> make it look more like PCI or i2c that already have a clean split.

On drivers/firewire/:

FireWire drivers are currently spread over drivers/firewire (three
link-layer controller drivers + the IEEE 1394 core + two IEEE 1394
application layer drivers), drivers/media/dvb/firewire/ (one 1394
application layer driver), sound/firewire/ (two 1394 application layer
drivers, more are planned to be added there).

>From the Linux driver model POV,
1. the IEEE 1394 core driver implements the firewire bus,
2. the link-layer controller drivers implement pci bus based devices,
3. the IEEE 1394 application layer drivers implement firewire bus based
devices. The two of them that are located in drivers/firewire/
expose a SCSI LLD (a transport in SCSI Architecture Model terms, but
a host rather than a transport in Linux implementation terms) and a
networking interface driver.

Number 2 is something one would expect to find in a hypothetical
drivers/bus/ directory. But where do the others belong?

Would type 1 drivers be kept in drivers/bus/firewire/? I understand your
above response to Jean that this is what you have in mind.

firewire-sbp2 could be moved into drivers/scsi/, and firewire-net could be
moved into drivers/net/. But what about maintenance? They could still be
maintained via linux1394-2.6.git because this worked so far, but then the
directory structure might irritate people who don't use
scripts/get_maintainer.pl all the time. Well, I could actually picture
firewire-net to be maintained via the net development tree, but I do
wonder how well firewire-sbp2 maintenance through the scsi tree would work.

PS,
these are the same questions like with USB, only on a smaller scale. (The
usb-storage driver is maintained through the usb tree as well, not the
scsi tree. drivers/net/usb/ has got T: git .../gregkh/usb-2.6.git
assigned in MAINTAINERS but most of the commits there are actually done by
DaveM.)

PPS,
besides association of source files with development trees, there is also
the association with developer mailing lists and user mailing lists and
web resources, e.g. wiki. How logical the directory layout is in this
sense could be approximately measured by means of the count of necessary
entries in MAINTAINERS.
--
Stefan Richter
-=====-==-== -==- --==-
http://arcgraph.de/sr/

2011-06-06 14:39:25

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Mon, Jun 6, 2011 at 3:00 AM, Arnd Bergmann <[email protected]> wrote:
> On Sunday 05 June 2011, Grant Likely wrote:
>> ?rename drivers/spi/{omap2_mcspi.c => spi_omap2_mcspi.c} (100%)
>> ?rename drivers/spi/{omap_spi_100k.c => spi_omap_100k.c} (100%)
>> ?rename drivers/spi/{omap_uwire.c => spi_omap_uwire.c} (100%)
>> ?rename drivers/spi/{orion_spi.c => spi_orion.c} (100%)
>> ?rename drivers/spi/{amba-pl022.c => spi_pl022.c} (100%)
>> ?rename drivers/spi/{pxa2xx_spi.c => spi_pxa2xx.c} (100%)
>> ?rename drivers/spi/{pxa2xx_spi_pci.c => spi_pxa2xx_pci.c} (100%)
>> ?rename drivers/spi/{ti-ssp-spi.c => spi_ti_ssp.c} (100%)
>> ?rename drivers/spi/{tle62x0.c => spi_tle62x0.c} (100%)
>> ?rename drivers/spi/{xilinx_spi.c => spi_xilinx.c} (100%)
>
> I recently looked at the directory structure in drivers/ and found a lot
> of bus drivers with very few files, plus a few bus drivers with a lot
> of files in them besides directories for non-bus specific subsystems.
>
> I think it would be good to move them into a deeper directory drivers/bus/
> if we have support from the maintainers, and it's probably better if we
> only have to move the files once to reduce the amount of churn on the
> MAINTAINERS file and any out of tree patches.

I had this thought too when I was looking at reorganizing the gpio and
spi directories, but ultimately I came to the conclusion that it
didn't really make much sense to move them. Bus drivers are just
another kind of device driver. In general, the organization of having
a directory (like spi or i2c) containing both the common bus
infrastructure and a set of drivers using it, and this isn't even
unlike what we do for non-bus drivers. I don't see much need to move
these.

However, there are a number of bus types that have infrastructure, but
no actual drivers associated with them, like mca, amba and clk. It
might make sense to move those bus types into drivers/base alongside
the platform_bus_type implementation.

g.

2011-06-06 15:05:44

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Monday 06 June 2011, Stefan Richter wrote:
> On Jun 06 Arnd Bergmann wrote:
> > On Monday 06 June 2011, Jean Delvare wrote:
> On drivers/firewire/:
>
> FireWire drivers are currently spread over drivers/firewire (three
> link-layer controller drivers + the IEEE 1394 core + two IEEE 1394
> application layer drivers), drivers/media/dvb/firewire/ (one 1394
> application layer driver), sound/firewire/ (two 1394 application layer
> drivers, more are planned to be added there).
>
> From the Linux driver model POV,
> 1. the IEEE 1394 core driver implements the firewire bus,
> 2. the link-layer controller drivers implement pci bus based devices,
> 3. the IEEE 1394 application layer drivers implement firewire bus based
> devices. The two of them that are located in drivers/firewire/
> expose a SCSI LLD (a transport in SCSI Architecture Model terms, but
> a host rather than a transport in Linux implementation terms) and a
> networking interface driver.
>
> Number 2 is something one would expect to find in a hypothetical
> drivers/bus/ directory. But where do the others belong?
>
> Would type 1 drivers be kept in drivers/bus/firewire/? I understand your
> above response to Jean that this is what you have in mind.

Correct.

> firewire-sbp2 could be moved into drivers/scsi/, and firewire-net could be
> moved into drivers/net/. But what about maintenance? They could still be
> maintained via linux1394-2.6.git because this worked so far, but then the
> directory structure might irritate people who don't use
> scripts/get_maintainer.pl all the time. Well, I could actually picture
> firewire-net to be maintained via the net development tree, but I do
> wonder how well firewire-sbp2 maintenance through the scsi tree would work.

I guess the real question is whether firewire should be considered a bus
like USB or a device class like SCSI, and it's abit of a grey area (SCSI
is too). If you declare it to be a bus, I'd suggest moving the sbp2 and
network drivers to drivers/scsi and drivers/net. If you like to think
of firewire as a closed subsystem instead, it's probably better to leave
all of it in drivers/firewire.

> PS,
> these are the same questions like with USB, only on a smaller scale. (The
> usb-storage driver is maintained through the usb tree as well, not the
> scsi tree. drivers/net/usb/ has got T: git .../gregkh/usb-2.6.git
> assigned in MAINTAINERS but most of the commits there are actually done by
> DaveM.)

The difference that I see with usb-storage is that this one is really
a set of different drivers for all sorts of devices, while the firewire sbp2
driver feels more like a single driver that includes a few special
cases. Also, USB is generally perceived as a generic interconnect, while
firewire is seen primarily as a way to attach disk drives.

The differences are of course gradual.

Arnd

2011-06-06 15:17:05

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH] spi: reorganize drivers

On Mon, Jun 06, 2011 at 08:39:04AM -0600, Grant Likely wrote:
> However, there are a number of bus types that have infrastructure, but
> no actual drivers associated with them, like mca, amba and clk. It
> might make sense to move those bus types into drivers/base alongside
> the platform_bus_type implementation.

More or less agreed - I'm not sure we should think about clk just yet
because we don't know what that'll end up looking like yet...