Skip to contentSkip to conversation

spi/bcm63xx: fixes and cleanups

PATCH Applied Jonas Gorski 2 participants 6 messages Dec 17, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover spi/bcm63xx: fixes and cleanups

Hi Mark,

These four patches aim to improve the bcm63xx spi driver and fix various small issues.

The first two are actually a resend. I accidentially took an old (not working anymore) email address from you, I suspect they went under the radar. They are the same except that I added Florian's Acks.

These might be stable/3.13 material.

The latter two just do some smallish cleanups, and don't necessarily need backporting I think.

Patch 3 depends on Jingoo Han's devm_clk_get() patch, because that one makes sense and I wanted to do the same anyway (actually did, but he was faster ;-).

Regards
Jonas

Jonas Gorski (4):
spi/bcm63xx: don't substract prepend length from total length spi/bcm63xx: don't reject reads >= 256 bytes spi/bcm63xx: check return value of clk_prepare_enable spi/bcm63xx: fix pm sleep support

 drivers/spi/spi-bcm63xx.c | 33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)
Signature · 5 lines
1.8.5.1
--
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): 1387312930-22436-1-git-send-email-jogo-p3rKhJxN3npAfugRpC6u6w@public.gmane.org

#2 lore raw

PATCH 1/4 spi/bcm63xx: don't substract prepend length from total length

The spi command must include the full message length including any prepended writes, else transfers larger than 256 bytes will be incomplete.

---
 drivers/spi/spi-bcm63xx.c | 2 --
 1 file changed, 2 deletions(-)
drivers/spi/spi-bcm63xx.c +0 -2
index f44a9eb..5693b4f 100644
@@ -169,8 +169,6 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
 			       transfer_list);
 	}
 
-	len -= prepend_len;
-
 	init_completion(&bs->done);
 
 	/* Fill in the Message control register */
Signature · 5 lines
1.8.5.1
--
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
#3 lore raw

PATCH 2/4 spi/bcm63xx: don't reject reads >= 256 bytes

In reply to a message not in the archive

The rx_tail register is only 8 bit wide, so it will wrap around after 256 read bytes. This makes it rather meaningless, so drop any usage of it to not treat reads over 256 as failed.

---
 drivers/spi/spi-bcm63xx.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/spi/spi-bcm63xx.c +1 -7
index 5693b4f..ae60731 100644
@@ -203,13 +203,7 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
 	if (!timeout)
 		return -ETIMEDOUT;
 
-	/* read out all data */
-	rx_tail = bcm_spi_readb(bs, SPI_RX_TAIL);
-
-	if (do_rx && rx_tail != len)
-		return -EIO;
-
-	if (!rx_tail)
+	if (!do_rx)
 		return 0;
 
 	len = 0;
Signature · 5 lines
1.8.5.1
--
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
#4 lore raw

PATCH 3/4 spi/bcm63xx: check return value of clk_prepare_enable

In reply to a message not in the archive

Ensure we notice if the clock cannot be enabled for any reason and pass the error down.

---
 drivers/spi/spi-bcm63xx.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/spi/spi-bcm63xx.c +8 -2
index ae60731..0c8c68a 100644
@@ -397,7 +397,10 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	}
 
 	/* Initialize hardware */
-	clk_prepare_enable(bs->clk);
+	ret = clk_prepare_enable(bs->clk);
+	if (ret)
+		goto out_err;
+
 	bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS);
 
 	/* register and we are done */
@@ -450,8 +453,11 @@ static int bcm63xx_spi_resume(struct device *dev)
 {
 	struct spi_master *master = dev_get_drvdata(dev);
 	struct bcm63xx_spi *bs = spi_master_get_devdata(master);
+	int ret;
 
-	clk_prepare_enable(bs->clk);
+	ret = clk_prepare_enable(bs->clk);
+	if (ret)
+		return ret;
 
 	spi_master_resume(master);
 
Signature · 5 lines
1.8.5.1
--
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 4/4 spi/bcm63xx: fix pm sleep support

In reply to a message not in the archive

Use the correct symbol to guard the callbacks and use appropriate defines for setting up the ops struct.

---
 drivers/spi/spi-bcm63xx.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/spi/spi-bcm63xx.c +4 -9
index 0c8c68a..77286ae 100644
@@ -436,7 +436,7 @@ static int bcm63xx_spi_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int bcm63xx_spi_suspend(struct device *dev)
 {
 	struct spi_master *master = dev_get_drvdata(dev);
@@ -463,22 +463,17 @@ static int bcm63xx_spi_resume(struct device *dev)
 
 	return 0;
 }
+#endif
 
 static const struct dev_pm_ops bcm63xx_spi_pm_ops = {
-	.suspend	= bcm63xx_spi_suspend,
-	.resume		= bcm63xx_spi_resume,
+	SET_SYSTEM_SLEEP_PM_OPS(bcm63xx_spi_suspend, bcm63xx_spi_resume)
 };
 
-#define BCM63XX_SPI_PM_OPS	(&bcm63xx_spi_pm_ops)
-#else
-#define BCM63XX_SPI_PM_OPS	NULL
-#endif
-
 static struct platform_driver bcm63xx_spi_driver = {
 	.driver = {
 		.name	= "bcm63xx-spi",
 		.owner	= THIS_MODULE,
-		.pm	= BCM63XX_SPI_PM_OPS,
+		.pm	= &bcm63xx_spi_pm_ops,
 	},
 	.probe		= bcm63xx_spi_probe,
 	.remove		= bcm63xx_spi_remove,
Signature · 5 lines
1.8.5.1
--
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