Skip to contentSkip to conversation

spi/bcm63xx: cleanup and decouple from arch code

PATCH Superseded Jonas Gorski 3 participants 14 messages Sep 10, 2015 – Sep 14, 2015 8 messages not in the archive

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover spi/bcm63xx: cleanup and decouple from arch code

This patchset decouples spi-bcm63xx from any arch code to allow building it for more than MIPS/BCM63XX as well as allow compile testing it on any arch/platform.

Based on for-next, obviously 4.4 material.

Jonas Gorski (6):
spi/bcm63xx: remove unused rx_tail variable
spi/bcm63xx: always use a fixed number of CS
spi/bcm63xx: hardcode busnum to 0
spi/bcm63xx: replace custom io accessors with standard ones spi/bcm63xx: move register definitions into the driver spi/bcm63xx: move message control word description to register offsets

 drivers/spi/Kconfig       |   2 +-
 drivers/spi/spi-bcm63xx.c | 195 +++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 176 insertions(+), 21 deletions(-)
Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1441894304-22316-1-git-send-email-jogo-p3rKhJxN3npAfugRpC6u6w@public.gmane.org

#2 lore raw

PATCH 1/6 spi/bcm63xx: remove unused rx_tail variable

Fixes the following warning:
drivers/spi/spi-bcm63xx.c:125:5: warning: unused variable 'rx_tail' [-Wunused-variable]

  u8 rx_tail;
     ^
---
 drivers/spi/spi-bcm63xx.c | 1 -
 1 file changed, 1 deletion(-)
drivers/spi/spi-bcm63xx.c +0 -1
index e73e2b05..2b908db 100644
@@ -122,7 +122,6 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
 	struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
 	u16 msg_ctl;
 	u16 cmd;
-	u8 rx_tail;
 	unsigned int i, timeout = 0, prepend_len = 0, len = 0;
 	struct spi_transfer *t = first;
 	bool do_rx = false;
Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1441894304-22316-2-git-send-email-jogo-p3rKhJxN3npAfugRpC6u6w@public.gmane.org

#4 lore raw

Applied "spi/bcm63xx: remove unused rx_tail variable" to the spi tree

The patch

spi/bcm63xx: remove unused rx_tail variable

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 2bdf5151a3a9224d622f1f2bdd20f56bad5d2505 Mon Sep 17 00:00:00 2001

From: Jonas Gorski <[email protected]>
Date: Thu, 10 Sep 2015 16:11:39 +0200
Subject: [PATCH] spi/bcm63xx: remove unused rx_tail variable

Fixes the following warning:
drivers/spi/spi-bcm63xx.c:125:5: warning: unused variable 'rx_tail' [-Wunused-variable]

  u8 rx_tail;
     ^
---
 drivers/spi/spi-bcm63xx.c | 1 -
 1 file changed, 1 deletion(-)
drivers/spi/spi-bcm63xx.c +0 -1
index e73e2b05..2b908db 100644
@@ -122,7 +122,6 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
 	struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
 	u16 msg_ctl;
 	u16 cmd;
-	u8 rx_tail;
 	unsigned int i, timeout = 0, prepend_len = 0, len = 0;
 	struct spi_transfer *t = first;
 	bool do_rx = false;
Signature · 6 lines
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

PATCH 2/6 spi/bcm63xx: always use a fixed number of CS

In reply to a message not in the archive

We always pass 8 for the number of chip selects, so we can as well hardcode it to this number.

---
 drivers/spi/spi-bcm63xx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm63xx.c +3 -1
index 2b908db..a997c64 100644
@@ -31,6 +31,8 @@
 
 #define BCM63XX_SPI_MAX_PREPEND		15
 
+#define BCM63XX_SPI_MAX_CS		8
+
 struct bcm63xx_spi {
 	struct completion	done;
 
@@ -368,7 +370,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	}
 
 	master->bus_num = pdata->bus_num;
-	master->num_chipselect = pdata->num_chipselect;
+	master->num_chipselect = BCM63XX_SPI_MAX_CS;
 	master->transfer_one_message = bcm63xx_spi_transfer_one;
 	master->mode_bits = MODEBITS;
 	master->bits_per_word_mask = SPI_BPW_MASK(8);
Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1441894304-22316-3-git-send-email-jogo-p3rKhJxN3npAfugRpC6u6w@public.gmane.org

#7 lore raw

Applied "spi/bcm63xx: always use a fixed number of CS" to the spi tree

The patch

spi/bcm63xx: always use a fixed number of CS

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 65059997306901f4da1f5168db65de8225d5d04c Mon Sep 17 00:00:00 2001

From: Jonas Gorski <[email protected]>
Date: Thu, 10 Sep 2015 16:11:40 +0200
Subject: [PATCH] spi/bcm63xx: always use a fixed number of CS

We always pass 8 for the number of chip selects, so we can as well hardcode it to this number.

---
 drivers/spi/spi-bcm63xx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm63xx.c +3 -1
index 2b908db..a997c64 100644
@@ -31,6 +31,8 @@
 
 #define BCM63XX_SPI_MAX_PREPEND		15
 
+#define BCM63XX_SPI_MAX_CS		8
+
 struct bcm63xx_spi {
 	struct completion	done;
 
@@ -368,7 +370,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	}
 
 	master->bus_num = pdata->bus_num;
-	master->num_chipselect = pdata->num_chipselect;
+	master->num_chipselect = BCM63XX_SPI_MAX_CS;
 	master->transfer_one_message = bcm63xx_spi_transfer_one;
 	master->mode_bits = MODEBITS;
 	master->bits_per_word_mask = SPI_BPW_MASK(8);
Signature · 6 lines
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

PATCH 3/6 spi/bcm63xx: hardcode busnum to 0

In reply to a message not in the archive

We always pass 0 as the spi bus number, so we might as well hard code it.

---
 drivers/spi/spi-bcm63xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm63xx.c +2 -1
index a997c64..c1364a8 100644
@@ -32,6 +32,7 @@
 #define BCM63XX_SPI_MAX_PREPEND		15
 
 #define BCM63XX_SPI_MAX_CS		8
+#define BCM63XX_SPI_BUS_NUM		0
 
 struct bcm63xx_spi {
 	struct completion	done;
@@ -369,7 +370,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 		goto out_err;
 	}
 
-	master->bus_num = pdata->bus_num;
+	master->bus_num = BCM63XX_SPI_BUS_NUM;
 	master->num_chipselect = BCM63XX_SPI_MAX_CS;
 	master->transfer_one_message = bcm63xx_spi_transfer_one;
 	master->mode_bits = MODEBITS;
Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1441894304-22316-4-git-send-email-jogo-p3rKhJxN3npAfugRpC6u6w@public.gmane.org

#10 lore raw

Applied "spi/bcm63xx: hardcode busnum to 0" to the spi tree

The patch

spi/bcm63xx: hardcode busnum to 0

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From a45fcea5b20f1dcc2abb08aa29ecb2feacae60f2 Mon Sep 17 00:00:00 2001

From: Jonas Gorski <[email protected]>
Date: Thu, 10 Sep 2015 16:11:41 +0200
Subject: [PATCH] spi/bcm63xx: hardcode busnum to 0

We always pass 0 as the spi bus number, so we might as well hard code it.

---
 drivers/spi/spi-bcm63xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm63xx.c +2 -1
index a997c64..c1364a8 100644
@@ -32,6 +32,7 @@
 #define BCM63XX_SPI_MAX_PREPEND		15
 
 #define BCM63XX_SPI_MAX_CS		8
+#define BCM63XX_SPI_BUS_NUM		0
 
 struct bcm63xx_spi {
 	struct completion	done;
@@ -369,7 +370,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 		goto out_err;
 	}
 
-	master->bus_num = pdata->bus_num;
+	master->bus_num = BCM63XX_SPI_BUS_NUM;
 	master->num_chipselect = BCM63XX_SPI_MAX_CS;
 	master->transfer_one_message = bcm63xx_spi_transfer_one;
 	master->mode_bits = MODEBITS;
Signature · 6 lines
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

PATCH 4/6 spi/bcm63xx: replace custom io accessors with standard ones

In reply to a message not in the archive

Replace all bcm_read* with (io)read. Due to this block following system endianness, make sure we match that.

---
 drivers/spi/spi-bcm63xx.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/spi/spi-bcm63xx.c +12 -4
index c1364a8..ef05387 100644
@@ -56,25 +56,33 @@ struct bcm63xx_spi {
 static inline u8 bcm_spi_readb(struct bcm63xx_spi *bs,
 				unsigned int offset)
 {
-	return bcm_readb(bs->regs + bcm63xx_spireg(offset));
+	return readb(bs->regs + bcm63xx_spireg(offset));
 }
 
 static inline u16 bcm_spi_readw(struct bcm63xx_spi *bs,
 				unsigned int offset)
 {
-	return bcm_readw(bs->regs + bcm63xx_spireg(offset));
+#ifdef CONFIG_BIG_ENDIAN
+	return ioread16(bs->regs + bcm63xx_spireg(offset));
+#else
+	return readw(bs->regs + bcm63xx_spireg(offset));
+#endif
 }
 
 static inline void bcm_spi_writeb(struct bcm63xx_spi *bs,
 				  u8 value, unsigned int offset)
 {
-	bcm_writeb(value, bs->regs + bcm63xx_spireg(offset));
+	writeb(value, bs->regs + bcm63xx_spireg(offset));
 }
 
 static inline void bcm_spi_writew(struct bcm63xx_spi *bs,
 				  u16 value, unsigned int offset)
 {
-	bcm_writew(value, bs->regs + bcm63xx_spireg(offset));
+#ifdef CONFIG_BIG_ENDIAN
+	iowrite16(value, bs->regs + bcm63xx_spireg(offset));
+#else
+	writew(value, bs->regs + bcm63xx_spireg(offset));
+#endif
 }
 
 static const unsigned bcm63xx_spi_freq_table[SPI_CLK_MASK][2] = {
Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1441894304-22316-5-git-send-email-jogo-p3rKhJxN3npAfugRpC6u6w@public.gmane.org

#13 lore raw

Applied "spi/bcm63xx: replace custom io accessors with standard ones" to the spi tree

The patch

spi/bcm63xx: replace custom io accessors with standard ones

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 158fcc4e050a75b609bbef1007cf7bf2a01ca043 Mon Sep 17 00:00:00 2001

From: Jonas Gorski <[email protected]>
Date: Thu, 10 Sep 2015 16:11:42 +0200
Subject: [PATCH] spi/bcm63xx: replace custom io accessors with standard ones

Replace all bcm_read* with (io)read. Due to this block following system endianness, make sure we match that.

---
 drivers/spi/spi-bcm63xx.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/spi/spi-bcm63xx.c +12 -4
index c1364a8..ef05387 100644
@@ -56,25 +56,33 @@ struct bcm63xx_spi {
 static inline u8 bcm_spi_readb(struct bcm63xx_spi *bs,
 				unsigned int offset)
 {
-	return bcm_readb(bs->regs + bcm63xx_spireg(offset));
+	return readb(bs->regs + bcm63xx_spireg(offset));
 }
 
 static inline u16 bcm_spi_readw(struct bcm63xx_spi *bs,
 				unsigned int offset)
 {
-	return bcm_readw(bs->regs + bcm63xx_spireg(offset));
+#ifdef CONFIG_BIG_ENDIAN
+	return ioread16(bs->regs + bcm63xx_spireg(offset));
+#else
+	return readw(bs->regs + bcm63xx_spireg(offset));
+#endif
 }
 
 static inline void bcm_spi_writeb(struct bcm63xx_spi *bs,
 				  u8 value, unsigned int offset)
 {
-	bcm_writeb(value, bs->regs + bcm63xx_spireg(offset));
+	writeb(value, bs->regs + bcm63xx_spireg(offset));
 }
 
 static inline void bcm_spi_writew(struct bcm63xx_spi *bs,
 				  u16 value, unsigned int offset)
 {
-	bcm_writew(value, bs->regs + bcm63xx_spireg(offset));
+#ifdef CONFIG_BIG_ENDIAN
+	iowrite16(value, bs->regs + bcm63xx_spireg(offset));
+#else
+	writew(value, bs->regs + bcm63xx_spireg(offset));
+#endif
 }
 
 static const unsigned bcm63xx_spi_freq_table[SPI_CLK_MASK][2] = {
Signature · 6 lines
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#14 lore raw

PATCH 5/6 spi/bcm63xx: move register definitions into the driver

In reply to a message not in the archive

Move all register definitions and structs into the driver. This allows us dropping the platform_data struct and drop any arch specific includes.

Since we now have full control over the message width, we can drop the size check, which was broken anyway, since it never set ret to any error code.

Also since we now have no arch depedendent resources, we can now allow compiling it for any arch, hidding behind COMPILE_TEST.

---
 drivers/spi/Kconfig       |   2 +-
 drivers/spi/spi-bcm63xx.c | 176 +++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 158 insertions(+), 20 deletions(-)
drivers/spi/Kconfig +1 -1
index 4887f31..5c1db98 100644
@@ -125,7 +125,7 @@ config SPI_BCM53XX
 
 config SPI_BCM63XX
 	tristate "Broadcom BCM63xx SPI controller"
-	depends on BCM63XX
+	depends on BCM63XX || COMPILE_TEST
 	help
           Enable support for the SPI controller on the Broadcom BCM63xx SoCs.
 
drivers/spi/spi-bcm63xx.c +157 -19

244 lines not on this page · raw message

Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1441894304-22316-6-git-send-email-jogo-p3rKhJxN3npAfugRpC6u6w@public.gmane.org

#16 lore raw

Re: [PATCH 5/6] spi/bcm63xx: move register definitions into the driver

Quoted 13 lines · Jonas Gorski

Move all register definitions and structs into the driver. This allows us dropping the platform_data struct and drop any arch specific includes.

Since we now have full control over the message width, we can drop the size check, which was broken anyway, since it never set ret to any error code.

Also since we now have no arch depedendent resources, we can now allow compiling it for any arch, hidding behind COMPILE_TEST.

---

[snip]

drivers/spi/spi-bcm63xx.c static int bcm63xx_spi_probe(struct platform_device *pdev) · line 529

Quoted 13 lines
drivers/spi/spi-bcm63xx.c +12 -0
+	switch (resource_size(r)) {
+	case SPI_6348_RSET_SIZE:
+		bs->reg_offsets = bcm6348_spi_reg_offsets;
+		bs->msg_type_shift = SPI_6348_MSG_TYPE_SHIFT;
+		bs->msg_ctl_width = SPI_6348_MSG_CTL_WIDTH;
+		bs->fifo_size = SPI_6348_MSG_DATA_SIZE;
+		break;
+	case SPI_6358_RSET_SIZE:
+		bs->reg_offsets = bcm6358_spi_reg_offsets;
+		bs->msg_type_shift = SPI_6358_MSG_TYPE_SHIFT;
+		bs->msg_ctl_width = SPI_6358_MSG_CTL_WIDTH;
+		bs->fifo_size = SPI_6358_MSG_DATA_SIZE;
 		break;

This is a little fragile, I would rather create more specialized platform_id names, like "bcm6348-spi" and "bcm6358-spi", very much like what the FEC driver does, such that:

- you could directly pass this information as part of an additional structure which specializes the instance of the driver
- the conversion to Device Tree in your other patches would make this more natural or nearly identical

What do you think?
--
Florian
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#18 lore raw

Re: [PATCH 5/6] spi/bcm63xx: move register definitions into the driver

Hi,

Quoted 35 lines · Florian Fainelli
Quoted 13 lines · Jonas Gorski

Move all register definitions and structs into the driver. This allows us dropping the platform_data struct and drop any arch specific includes.

Since we now have full control over the message width, we can drop the size check, which was broken anyway, since it never set ret to any error code.

Also since we now have no arch depedendent resources, we can now allow compiling it for any arch, hidding behind COMPILE_TEST.

---

[snip]

drivers/spi/spi-bcm63xx.c static int bcm63xx_spi_probe(struct platform_device *pdev) · line 529

Quoted 13 lines
drivers/spi/spi-bcm63xx.c +12 -0
+     switch (resource_size(r)) {
+     case SPI_6348_RSET_SIZE:
+             bs->reg_offsets = bcm6348_spi_reg_offsets;
+             bs->msg_type_shift = SPI_6348_MSG_TYPE_SHIFT;
+             bs->msg_ctl_width = SPI_6348_MSG_CTL_WIDTH;
+             bs->fifo_size = SPI_6348_MSG_DATA_SIZE;
+             break;
+     case SPI_6358_RSET_SIZE:
+             bs->reg_offsets = bcm6358_spi_reg_offsets;
+             bs->msg_type_shift = SPI_6358_MSG_TYPE_SHIFT;
+             bs->msg_ctl_width = SPI_6358_MSG_CTL_WIDTH;
+             bs->fifo_size = SPI_6358_MSG_DATA_SIZE;
              break;

This is a little fragile, I would rather create more specialized platform_id names, like "bcm6348-spi" and "bcm6358-spi", very much like what the FEC driver does, such that:

Quoted 6 lines

- you could directly pass this information as part of an additional structure which specializes the instance of the driver
- the conversion to Device Tree in your other patches would make this more natural or nearly identical

What do you think?

Can we even associate more than one name with a driver? Else I would need to split this driver into two, and that sounds like a lot more work for IMHO not much gain, and a lot more opportunities to accidentially break things ;-)

I'm also trying to not touch arch stuff, to keep the changes local to spi (easier merging). Apart from that, this is the legacy platform device registration route where we know exactly which values to expect, and the device tree path won't go there, so I would think this is okay for devices where we have full control over this (i.e. within the kernel).

Of course if mark says I should do it I will.

Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAOiHx=mXBnfMx1SO+iG=BB6038c99YS8MkM8Nn-itHOoHzAJiQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#20 lore raw

Re: [PATCH 5/6] spi/bcm63xx: move register definitions into the driver

Quoted 10 lines · Jonas Gorski
Quoted 3 lines · Florian Fainelli

This is a little fragile, I would rather create more specialized platform_id names, like "bcm6348-spi" and "bcm6358-spi", very much like what the FEC driver does, such that:

Can we even associate more than one name with a driver? Else I would need to split this driver into two, and that sounds like a lot more work for IMHO not much gain, and a lot more opportunities to accidentially break things ;-)

Yes, of course - like Florian says look at the FEC driver for one example. Just set id_table.

Quoted 6 lines

I'm also trying to not touch arch stuff, to keep the changes local to spi (easier merging). Apart from that, this is the legacy platform device registration route where we know exactly which values to expect, and the device tree path won't go there, so I would think this is okay for devices where we have full control over this (i.e. within the kernel).

Making the code more obscure and fragile to avoid such a minor issue with integrating changes sounds like it's going in the wrong direction - it creates long term complexity for a short term gain.

#21 lore raw

PATCH 6/6 spi/bcm63xx: move message control word description to register offsets

In reply to a message not in the archive

Make the message control word parameters part of the register offsets array so we have them all in one struct.

---
 drivers/spi/spi-bcm63xx.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/spi/spi-bcm63xx.c +13 -6
index 6353607..42f33bc 100644
@@ -128,6 +128,9 @@ enum bcm63xx_regs_spi {
 	SPI_MSG_CTL,
 	SPI_MSG_DATA,
 	SPI_RX_DATA,
+	SPI_MSG_TYPE_SHIFT,
+	SPI_MSG_CTL_WIDTH,
+	SPI_MSG_DATA_SIZE,
 };
 
 #define BCM63XX_SPI_MAX_PREPEND		15
@@ -439,6 +442,9 @@ static const unsigned long bcm6348_spi_reg_offsets[] = {
 	[SPI_MSG_CTL]		= SPI_6348_MSG_CTL,
 	[SPI_MSG_DATA]		= SPI_6348_MSG_DATA,
 	[SPI_RX_DATA]		= SPI_6348_RX_DATA,
+	[SPI_MSG_TYPE_SHIFT]	= SPI_6348_MSG_TYPE_SHIFT,
+	[SPI_MSG_CTL_WIDTH]	= SPI_6348_MSG_CTL_WIDTH,
+	[SPI_MSG_DATA_SIZE]	= SPI_6348_MSG_DATA_SIZE,
 };
 
 static const unsigned long bcm6358_spi_reg_offsets[] = {
@@ -454,6 +460,9 @@ static const unsigned long bcm6358_spi_reg_offsets[] = {
 	[SPI_MSG_CTL]		= SPI_6358_MSG_CTL,
 	[SPI_MSG_DATA]		= SPI_6358_MSG_DATA,
 	[SPI_RX_DATA]		= SPI_6358_RX_DATA,
+	[SPI_MSG_TYPE_SHIFT]	= SPI_6358_MSG_TYPE_SHIFT,
+	[SPI_MSG_CTL_WIDTH]	= SPI_6358_MSG_CTL_WIDTH,
+	[SPI_MSG_DATA_SIZE]	= SPI_6358_MSG_DATA_SIZE,
 };
 
 static int bcm63xx_spi_probe(struct platform_device *pdev)
@@ -517,15 +526,9 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	switch (resource_size(r)) {
 	case SPI_6348_RSET_SIZE:
 		bs->reg_offsets = bcm6348_spi_reg_offsets;
-		bs->msg_type_shift = SPI_6348_MSG_TYPE_SHIFT;
-		bs->msg_ctl_width = SPI_6348_MSG_CTL_WIDTH;
-		bs->fifo_size = SPI_6348_MSG_DATA_SIZE;
 		break;
 	case SPI_6358_RSET_SIZE:
 		bs->reg_offsets = bcm6358_spi_reg_offsets;
-		bs->msg_type_shift = SPI_6358_MSG_TYPE_SHIFT;
-		bs->msg_ctl_width = SPI_6358_MSG_CTL_WIDTH;
-		bs->fifo_size = SPI_6358_MSG_DATA_SIZE;
 		break;
 	default:
 		ret = -EINVAL;
@@ -534,6 +537,10 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 		goto out_err;
 	}
 
+	bs->msg_type_shift = bs->reg_offsets[SPI_MSG_TYPE_SHIFT];
+	bs->msg_ctl_width = bs->reg_offsets[SPI_MSG_CTL_WIDTH];
+	bs->fifo_size = bs->reg_offsets[SPI_MSG_DATA_SIZE];
+
 	bs->tx_io = (u8 *)(bs->regs + bs->reg_offsets[SPI_MSG_DATA]);
 	bs->rx_io = (const u8 *)(bs->regs + bs->reg_offsets[SPI_RX_DATA]);
 
Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html