spi: fsl-espi: dont include irq.h
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): e5c7d6cd-0ba1-b1ec-60a8-72d6e2607217-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/23 spi: fsl-espi: dont include irq.h
irq.h isn't needed and it even shouldn't be included, see comment at the beginning of this header file.
--- drivers/spi/spi-fsl-espi.c | 1 - 1 file changed, 1 deletion(-)
drivers/spi/spi-fsl-espi.c +0 -1
@@ -12,7 +12,6 @@#include <linux/err.h> #include <linux/fsl_devices.h> #include <linux/interrupt.h> -#include <linux/irq.h> #include <linux/module.h> #include <linux/mm.h> #include <linux/of.h>
Signature · 7 lines
2.9.2 -- 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): 3a4b4e11-9283-5d52-d125-66c7565913d4-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: dont include irq.h" to the spi tree
The patch
spi: fsl-espi: dont include irq.h
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
6bdf03b30ed0ac72d309fe22aed8101f4cc6a2dfMon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Thu, 25 Aug 2016 06:43:17 +0200
Subject: [PATCH] spi: fsl-espi: dont include irq.h
irq.h isn't needed and it even shouldn't be included, see comment at the beginning of this header file.
--- drivers/spi/spi-fsl-espi.c | 1 - 1 file changed, 1 deletion(-)
drivers/spi/spi-fsl-espi.c +0 -1
@@ -12,7 +12,6 @@#include <linux/err.h> #include <linux/fsl_devices.h> #include <linux/interrupt.h> -#include <linux/irq.h> #include <linux/module.h> #include <linux/mm.h> #include <linux/of.h>
Signature · 6 lines
2.8.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
PATCH 3/23 spi: fsl-espi: remove unused elements n_rx and n_tx in struct fsl_espi_transfer
In reply to a message not in the archiveBoth elements are not used, so remove them.
--- drivers/spi/spi-fsl-espi.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -11
@@ -41,8 +41,6 @@ struct fsl_espi_transfer {const void *tx_buf;void *rx_buf;unsigned len; -unsigned n_tx; -unsigned n_rx;unsigned actual_length;int status; };
@@ -372,26 +370,18 @@ static int fsl_espi_do_one_msg(struct spi_master *master,struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ; -unsigned int n_tx =0 ; -unsigned int n_rx =0 ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans;memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX );list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) - n_tx += t->len; -if (t->rx_buf) { - n_rx += t->len; +if (t->rx_buf) rx_buf = t->rx_buf; - }if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len; } - espi_trans.n_tx = n_tx; - espi_trans.n_rx = n_rx; espi_trans.len = xfer_len; espi_trans.actual_length =0 ; espi_trans.status =0 ;
Signature · 7 lines
2.9.2 -- 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): b5777cc4-1ab7-d7cb-00be-c597060e7af6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 03/23] spi: fsl-espi: remove unused elements n_rx and n_tx in struct fsl_espi_transfer
Quoted 1 line · Heiner Kallweit
Both elements are not used, so remove them.
Mechanical changes like this are better done before more substantial optimisations and enhancements like the previous patch, that way they won't get blocked if there's a problem with the previous patch as is the case here.
PATCH 4/23 spi: fsl-espi: change return type of fsl_espi_setup_transfer to void
In reply to a message not in the archivefsl_espi_setup_transfer always returns 0, so change the return type to void.
--- drivers/spi/spi-fsl-espi.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/spi/spi-fsl-espi.c +4 -15
@@ -128,7 +128,7 @@ static u32 fsl_espi_tx_buf_lsb(struct mpc8xxx_spi *mpc8xxx_spi)return data; } -static int fsl_espi_setup_transfer (struct spi_device *spi, +static void fsl_espi_setup_transfer (struct spi_device *spi,struct spi_transfer *t) {struct mpc8xxx_spi *mpc8xxx_spi =spi_master_get_devdata (spi->master);
@@ -193,7 +193,6 @@ static int fsl_espi_setup_transfer(struct spi_device *spi, cs->hw_mode |=CSMODE_PM (pm);fsl_espi_change_mode (spi); -return 0 ; } static int fsl_espi_cpu_bufs(struct mpc8xxx_spi *mspi, struct spi_transfer *t,
@@ -290,13 +289,8 @@ static void fsl_espi_do_trans(struct spi_message *m,spi_message_add_tail (&trans, &message);list_for_each_entry (t, &message.transfers, transfer_list) { -if (t->bits_per_word || t->speed_hz) { - status = -EINVAL ; - - status =fsl_espi_setup_transfer (spi, t); -if (status <0 ) -break ; - } +if (t->bits_per_word || t->speed_hz) +fsl_espi_setup_transfer (spi, t);if (t->len) status =fsl_espi_bufs (spi, t);
@@ -401,7 +395,6 @@ static int fsl_espi_setup(struct spi_device *spi) {struct mpc8xxx_spi *mpc8xxx_spi;struct fsl_espi_reg *reg_base; -int retval;u32 hw_mode;u32 loop_mode;struct spi_mpc8xxx_cs *cs =spi_get_ctldata (spi);
@@ -442,15 +435,11 @@ static int fsl_espi_setup(struct spi_device *spi) loop_mode |=SPMODE_LOOP ;mpc8xxx_spi_write_reg (®_base->mode, loop_mode); - retval =fsl_espi_setup_transfer (spi,NULL ); +fsl_espi_setup_transfer (spi,NULL );pm_runtime_mark_last_busy (mpc8xxx_spi->dev);pm_runtime_put_autosuspend (mpc8xxx_spi->dev); -if (retval <0 ) { - cs->hw_mode = hw_mode;/* Restore settings */ -return retval; - }return 0 ; }
Signature · 7 lines
2.9.2 -- 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): 2800693b-704a-5530-2d58-8fd38d33dc10-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: change return type of fsl_espi_setup_transfer to void" to the spi tree
The patch
spi: fsl-espi: change return type of fsl_espi_setup_transfer to void
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
ea616ee220e70308cf33fa32496ae9c5ad18e190Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Thu, 25 Aug 2016 06:44:42 +0200
Subject: [PATCH] spi: fsl-espi: change return type of fsl_espi_setup_transfer
to void
fsl_espi_setup_transfer always returns 0, so change the return type to void.
--- drivers/spi/spi-fsl-espi.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/spi/spi-fsl-espi.c +4 -15
@@ -130,7 +130,7 @@ static u32 fsl_espi_tx_buf_lsb(struct mpc8xxx_spi *mpc8xxx_spi)return data; } -static int fsl_espi_setup_transfer (struct spi_device *spi, +static void fsl_espi_setup_transfer (struct spi_device *spi,struct spi_transfer *t) {struct mpc8xxx_spi *mpc8xxx_spi =spi_master_get_devdata (spi->master);
@@ -195,7 +195,6 @@ static int fsl_espi_setup_transfer(struct spi_device *spi, cs->hw_mode |=CSMODE_PM (pm);fsl_espi_change_mode (spi); -return 0 ; } static int fsl_espi_cpu_bufs(struct mpc8xxx_spi *mspi, struct spi_transfer *t,
@@ -292,13 +291,8 @@ static void fsl_espi_do_trans(struct spi_message *m,spi_message_add_tail (&trans, &message);list_for_each_entry (t, &message.transfers, transfer_list) { -if (t->bits_per_word || t->speed_hz) { - status = -EINVAL ; - - status =fsl_espi_setup_transfer (spi, t); -if (status <0 ) -break ; - } +if (t->bits_per_word || t->speed_hz) +fsl_espi_setup_transfer (spi, t);if (t->len) status =fsl_espi_bufs (spi, t);
@@ -425,7 +419,6 @@ static int fsl_espi_setup(struct spi_device *spi) {struct mpc8xxx_spi *mpc8xxx_spi;struct fsl_espi_reg *reg_base; -int retval;u32 hw_mode;u32 loop_mode;struct spi_mpc8xxx_cs *cs =spi_get_ctldata (spi);
@@ -466,15 +459,11 @@ static int fsl_espi_setup(struct spi_device *spi) loop_mode |=SPMODE_LOOP ;mpc8xxx_spi_write_reg (®_base->mode, loop_mode); - retval =fsl_espi_setup_transfer (spi,NULL ); +fsl_espi_setup_transfer (spi,NULL );pm_runtime_mark_last_busy (mpc8xxx_spi->dev);pm_runtime_put_autosuspend (mpc8xxx_spi->dev); -if (retval <0 ) { - cs->hw_mode = hw_mode;/* Restore settings */ -return retval; - }return 0 ; }
Signature · 6 lines
2.8.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
PATCH 5/23 spi: fsl-espi: change return type of fsl_espi_cpu_bufs to void
In reply to a message not in the archivefsl_espi_cpu_bufs always returns 0, so change the return type to void.
--- drivers/spi/spi-fsl-espi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-espi.c +2 -6
@@ -195,7 +195,7 @@ static void fsl_espi_setup_transfer(struct spi_device *spi,fsl_espi_change_mode (spi); } -static int fsl_espi_cpu_bufs (struct mpc8xxx_spi *mspi,struct spi_transfer *t, +static void fsl_espi_cpu_bufs (struct mpc8xxx_spi *mspi,struct spi_transfer *t,unsigned int len) {u32 word;
@@ -209,8 +209,6 @@ static int fsl_espi_cpu_bufs(struct mpc8xxx_spi *mspi, struct spi_transfer *t,/* transmit word */ word = mspi->get_tx (mspi);mpc8xxx_spi_write_reg (®_base->transmit, word); - -return 0 ; }static int fsl_espi_bufs (struct spi_device *spi,struct spi_transfer *t)
@@ -237,9 +235,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 ))); - ret =fsl_espi_cpu_bufs (mpc8xxx_spi, t, len); -if (ret) -return ret; +fsl_espi_cpu_bufs (mpc8xxx_spi, t, len);/* Won't hang up forever, SPI bus sometimes got lost interrupts... */ ret =wait_for_completion_timeout (&mpc8xxx_spi->done,2 *HZ );
Signature · 7 lines
2.9.2 -- 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): 40dcd903-fdae-6669-5c35-af4b9e9e953b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: change return type of fsl_espi_cpu_bufs to void" to the spi tree
The patch
spi: fsl-espi: change return type of fsl_espi_cpu_bufs to void
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
bbb55f6d6276b39a96b7bcd79f1159a1365bb318Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Thu, 25 Aug 2016 06:44:58 +0200
Subject: [PATCH] spi: fsl-espi: change return type of fsl_espi_cpu_bufs to
void
fsl_espi_cpu_bufs always returns 0, so change the return type to void.
--- drivers/spi/spi-fsl-espi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-espi.c +2 -6
@@ -197,7 +197,7 @@ static void fsl_espi_setup_transfer(struct spi_device *spi,fsl_espi_change_mode (spi); } -static int fsl_espi_cpu_bufs (struct mpc8xxx_spi *mspi,struct spi_transfer *t, +static void fsl_espi_cpu_bufs (struct mpc8xxx_spi *mspi,struct spi_transfer *t,unsigned int len) {u32 word;
@@ -211,8 +211,6 @@ static int fsl_espi_cpu_bufs(struct mpc8xxx_spi *mspi, struct spi_transfer *t,/* transmit word */ word = mspi->get_tx (mspi);mpc8xxx_spi_write_reg (®_base->transmit, word); - -return 0 ; }static int fsl_espi_bufs (struct spi_device *spi,struct spi_transfer *t)
@@ -239,9 +237,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 ))); - ret =fsl_espi_cpu_bufs (mpc8xxx_spi, t, len); -if (ret) -return ret; +fsl_espi_cpu_bufs (mpc8xxx_spi, t, len);/* Won't hang up forever, SPI bus sometimes got lost interrupts... */ ret =wait_for_completion_timeout (&mpc8xxx_spi->done,2 *HZ );
Signature · 6 lines
2.8.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
PATCH 6/23 spi: fsl-espi: add missing static declaration to fsl_espi_cpu_irq
In reply to a message not in the archiveAdd missing static declaration to fsl_espi_cpu_irq.
--- drivers/spi/spi-fsl-espi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-fsl-espi.c +1 -1
@@ -447,7 +447,7 @@ static void fsl_espi_cleanup(struct spi_device *spi)spi_set_ctldata (spi,NULL ); } -void fsl_espi_cpu_irq (struct mpc8xxx_spi *mspi,u32 events) +static void fsl_espi_cpu_irq (struct mpc8xxx_spi *mspi,u32 events) {struct fsl_espi_reg *reg_base = mspi->reg_base;
Signature · 7 lines
2.9.2 -- 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): aa542aba-e5b5-7851-f12b-1cf04b213bcf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: add missing static declaration to fsl_espi_cpu_irq" to the spi tree
The patch
spi: fsl-espi: add missing static declaration to fsl_espi_cpu_irq
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
10ed1e6d320ca01deef3bc36df91e04ecd69a60eMon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Thu, 25 Aug 2016 06:45:16 +0200
Subject: [PATCH] spi: fsl-espi: add missing static declaration to
fsl_espi_cpu_irq
Add missing static declaration to fsl_espi_cpu_irq.
--- drivers/spi/spi-fsl-espi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-fsl-espi.c +1 -1
@@ -471,7 +471,7 @@ static void fsl_espi_cleanup(struct spi_device *spi)spi_set_ctldata (spi,NULL ); } -void fsl_espi_cpu_irq (struct mpc8xxx_spi *mspi,u32 events) +static void fsl_espi_cpu_irq (struct mpc8xxx_spi *mspi,u32 events) {struct fsl_espi_reg *reg_base = mspi->reg_base;
Signature · 6 lines
2.8.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
PATCH 7/23 spi: fsl-espi: remove unneeded variable in fsl_espi_do_trans
In reply to a message not in the archiveCreating a message, adding one transfer, and then iterating over all transfers in the message doesn't make sense.
We can simply use the original transfer directly.
--- drivers/spi/spi-fsl-espi.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/spi/spi-fsl-espi.c +8 -15
@@ -256,11 +256,9 @@ static void fsl_espi_do_trans(struct spi_message *m,struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct fsl_espi_transfer *espi_trans = tr; -struct spi_message message;struct spi_transfer *t, *first, trans;int status =0 ; -spi_message_init (&message);memset (&trans,0 ,sizeof (trans)); first = list_first_entry(&m->transfers, struct spi_transfer,
@@ -282,23 +280,18 @@ static void fsl_espi_do_trans(struct spi_message *m, trans.len = espi_trans->len; trans.tx_buf = espi_trans->tx_buf; trans.rx_buf = espi_trans->rx_buf; -spi_message_add_tail (&trans, &message); -list_for_each_entry (t, &message.transfers, transfer_list) { -if (t->bits_per_word || t->speed_hz) -fsl_espi_setup_transfer (spi, t); +if (trans.bits_per_word || trans.speed_hz) +fsl_espi_setup_transfer (spi, &trans); -if (t->len) - status =fsl_espi_bufs (spi, t); +if (trans.len) + status =fsl_espi_bufs (spi, &trans); -if (status) { - status = -EMSGSIZE ; -break ; - } +if (status) + status = -EMSGSIZE ; -if (t->delay_usecs) -udelay (t->delay_usecs); - } +if (trans.delay_usecs) +udelay (trans.delay_usecs); espi_trans->status = status;fsl_espi_setup_transfer (spi,NULL );
Signature · 7 lines
2.9.2 -- 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): 683bca81-4522-78d7-338f-0e1a137f4f4f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: remove unneeded variable in fsl_espi_do_trans" to the spi tree
The patch
spi: fsl-espi: remove unneeded variable in fsl_espi_do_trans
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
dbd4fefb5b7cba19e3f89c097d93ad02049e38e3Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Thu, 25 Aug 2016 06:45:55 +0200
Subject: [PATCH] spi: fsl-espi: remove unneeded variable in fsl_espi_do_trans
Creating a message, adding one transfer, and then iterating over all transfers in the message doesn't make sense.
We can simply use the original transfer directly.
--- drivers/spi/spi-fsl-espi.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/spi/spi-fsl-espi.c +8 -15
@@ -258,11 +258,9 @@ static void fsl_espi_do_trans(struct spi_message *m,struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct fsl_espi_transfer *espi_trans = tr; -struct spi_message message;struct spi_transfer *t, *first, trans;int status =0 ; -spi_message_init (&message);memset (&trans,0 ,sizeof (trans)); first = list_first_entry(&m->transfers, struct spi_transfer,
@@ -284,23 +282,18 @@ static void fsl_espi_do_trans(struct spi_message *m, trans.len = espi_trans->len; trans.tx_buf = espi_trans->tx_buf; trans.rx_buf = espi_trans->rx_buf; -spi_message_add_tail (&trans, &message); -list_for_each_entry (t, &message.transfers, transfer_list) { -if (t->bits_per_word || t->speed_hz) -fsl_espi_setup_transfer (spi, t); +if (trans.bits_per_word || trans.speed_hz) +fsl_espi_setup_transfer (spi, &trans); -if (t->len) - status =fsl_espi_bufs (spi, t); +if (trans.len) + status =fsl_espi_bufs (spi, &trans); -if (status) { - status = -EMSGSIZE ; -break ; - } +if (status) + status = -EMSGSIZE ; -if (t->delay_usecs) -udelay (t->delay_usecs); - } +if (trans.delay_usecs) +udelay (trans.delay_usecs); espi_trans->status = status;fsl_espi_setup_transfer (spi,NULL );
Signature · 6 lines
2.8.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
PATCH 8/23 spi: fsl-espi: factor out filling the local buffer
In reply to a message not in the archiveBetter structure the code by factoring out filling the local buffer.
--- drivers/spi/spi-fsl-espi.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-)
drivers/spi/spi-fsl-espi.c +23 -22
@@ -85,6 +85,26 @@ struct fsl_espi_transfer {#define AUTOSUSPEND_TIMEOUT 2000 +static unsigned int fsl_espi_copy_to_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) +{ +unsigned int tx_only =0 ; +struct spi_transfer *t; +u8 *buf = mspi->local_buf; + +list_for_each_entry (t, &m->transfers, transfer_list) { +if (t->tx_buf) { +memcpy (buf, t->tx_buf, t->len); +if (!t->rx_buf) + tx_only += t->len; + }else +memset (buf,0 , t->len); + buf += t->len; + } + +return tx_only; +} +static void fsl_espi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -301,16 +321,9 @@ static void fsl_espi_cmd_trans(struct spi_message *m, struct fsl_espi_transfer *trans, u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); -struct spi_transfer *t; -int i =0 ;struct fsl_espi_transfer *espi_trans = trans; -list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { -memcpy (mspi->local_buf + i, t->tx_buf, t->len); - i += t->len; - } - } +fsl_espi_copy_to_buf (m, mspi); espi_trans->tx_buf = espi_trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, espi_trans);
@@ -322,18 +335,9 @@ static void fsl_espi_rw_trans(struct spi_message *m, struct fsl_espi_transfer *trans, u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); -struct spi_transfer *t; -unsigned int tx_only =0 ; -int i =0 ; +unsigned int tx_only; -list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { -memcpy (mspi->local_buf + i, t->tx_buf, t->len); - i += t->len; -if (!t->rx_buf) - tx_only += t->len; - } - } + tx_only =fsl_espi_copy_to_buf (m, mspi); trans->tx_buf = trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, trans);
@@ -350,14 +354,11 @@ static void fsl_espi_rw_trans(struct spi_message *m,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { -struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; -memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
Signature · 7 lines
2.9.2 -- 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): 41a045ab-2629-658f-cccd-23f7182a4bc2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 08/23] spi: fsl-espi: factor out filling the local buffer
drivers/spi/spi-fsl-espi.c struct fsl_espi_transfer { · line 101
Quoted 6 lines · Heiner Kallweit
drivers/spi/spi-fsl-espi.c +6
-0+if (t->tx_buf) { +memcpy (buf, t->tx_buf, t->len); +if (!t->rx_buf) + tx_only += t->len; + }else +memset (buf,0 , t->len);
Coding style, { } on both or neither side of the if.
drivers/spi/spi-fsl-espi.c static void fsl_espi_rw_trans(struct spi_message *m, · line 360
Quoted 2 lines
drivers/spi/spi-fsl-espi.c +0
-2-memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); -
This optimization wasn't mentioned in the changelog...
PATCH 9/23 spi: fsl-espi: remove element status from struct fsl_espi_transfer
In reply to a message not in the archiveUse the return values of the functions in the call chain to transport status information instead of using an element in struct fsl_espi_transfer for this.
This is more in line with the general approach how to handle status information and is one step further to eventually get rid of struct fsl_espi_transfer completely.
--- drivers/spi/spi-fsl-espi.c | 47 +++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-)
drivers/spi/spi-fsl-espi.c +26 -21
@@ -42,7 +42,6 @@ struct fsl_espi_transfer {void *rx_buf;unsigned len;unsigned actual_length; -int status; };/* eSPI Controller mode register definitions */
@@ -270,14 +269,14 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count; } -static void fsl_espi_do_trans (struct spi_message *m, -struct fsl_espi_transfer *tr) +static int fsl_espi_do_trans (struct spi_message *m, +struct fsl_espi_transfer *tr) {struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct fsl_espi_transfer *espi_trans = tr;struct spi_transfer *t, *first, trans; -int status =0 ; +int ret =0 ;memset (&trans,0 ,sizeof (trans));
@@ -286,10 +285,9 @@ static void fsl_espi_do_trans(struct spi_message *m,list_for_each_entry (t, &m->transfers, transfer_list) {if ((first->bits_per_word != t->bits_per_word) || (first->speed_hz != t->speed_hz)) { - espi_trans->status = -EINVAL ;dev_err (mspi->dev,"bits_per_word/speed_hz should be same for the same SPI transfer\n" ); -return ; +return -EINVAL ; } trans.speed_hz = t->speed_hz;
@@ -305,50 +303,57 @@ static void fsl_espi_do_trans(struct spi_message *m,fsl_espi_setup_transfer (spi, &trans);if (trans.len) - status =fsl_espi_bufs (spi, &trans); + ret =fsl_espi_bufs (spi, &trans); -if (status) - status = -EMSGSIZE ; +if (ret) + ret = -EMSGSIZE ;if (trans.delay_usecs)udelay (trans.delay_usecs); - espi_trans->status = status;fsl_espi_setup_transfer (spi,NULL ); + +return ret; } -static void fsl_espi_cmd_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +static int fsl_espi_cmd_trans (struct spi_message *m, +struct fsl_espi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct fsl_espi_transfer *espi_trans = trans; +int ret;fsl_espi_copy_to_buf (m, mspi); espi_trans->tx_buf = espi_trans->rx_buf = mspi->local_buf; -fsl_espi_do_trans (m, espi_trans); + ret =fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; + +return ret; } -static void fsl_espi_rw_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +static int fsl_espi_rw_trans (struct spi_message *m, +struct fsl_espi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only; +int ret; tx_only =fsl_espi_copy_to_buf (m, mspi); trans->tx_buf = trans->rx_buf = mspi->local_buf; -fsl_espi_do_trans (m, trans); + ret =fsl_espi_do_trans (m, trans); -if (!trans->status) { +if (!ret) {/* If there is at least one RX byte then copy it to rx_buff */ if (trans->len > tx_only)memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); trans->actual_length += trans->len; } + +return ret; } static int fsl_espi_do_one_msg(struct spi_master *master,
@@ -358,6 +363,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master,u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +int ret;list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf)
@@ -368,15 +374,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, espi_trans.len = xfer_len; espi_trans.actual_length =0 ; - espi_trans.status =0 ;if (!rx_buf) -fsl_espi_cmd_trans (m, &espi_trans,NULL ); + ret =fsl_espi_cmd_trans (m, &espi_trans,NULL );else -fsl_espi_rw_trans (m, &espi_trans, rx_buf); + ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); m->actual_length = espi_trans.actual_length; - m->status = espi_trans.status; + m->status = ret;spi_finalize_current_message (master);return 0 ; }
Signature · 7 lines
2.9.2 -- 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
PATCH 10/23 spi: fsl-espi: fix status handling in fsl_espi_do_one_msg
In reply to a message not in the archiveIf an error occurred during message handling return this error instead of always returning 0 and align the code with the generic implementation in spi_transfer_one_message.
--- drivers/spi/spi-fsl-espi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/spi/spi-fsl-espi.c +5 -2
@@ -381,9 +381,12 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); m->actual_length = espi_trans.actual_length; - m->status = ret; +if (m->status == -EINPROGRESS ) + m->status = ret; +spi_finalize_current_message (master); -return 0 ; + +return ret; }static int fsl_espi_setup (struct spi_device *spi)
Signature · 7 lines
2.9.2 -- 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): 212d80f1-e3d1-0065-7366-e509a30b9c6c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: fix status handling in fsl_espi_do_one_msg" to the spi tree
The patch
spi: fsl-espi: fix status handling in fsl_espi_do_one_msg
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
0319d4991ea6e7594f32843e1b47868737056799Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:51:29 +0200
Subject: [PATCH] spi: fsl-espi: fix status handling in fsl_espi_do_one_msg
If an error occurred during message handling return this error instead of always returning 0 and align the code with the generic implementation in spi_transfer_one_message.
--- drivers/spi/spi-fsl-espi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/spi/spi-fsl-espi.c +5 -2
@@ -381,9 +381,12 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); m->actual_length = espi_trans.actual_length; - m->status = ret; +if (m->status == -EINPROGRESS ) + m->status = ret; +spi_finalize_current_message (master); -return 0 ; + +return ret; }static int fsl_espi_setup (struct spi_device *spi)
Signature · 6 lines
2.8.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
PATCH 11/23 spi: fsl-espi: remove element actual_length from struct fsl_espi_trans
In reply to a message not in the archiveIf an error occurs during processing the message, then we don't have to populate the actual_length element of struct message. So we can get rid of element actual_length in struct fsl_espi_transfer.
--- drivers/spi/spi-fsl-espi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-espi.c +2 -6
@@ -41,7 +41,6 @@ struct fsl_espi_transfer {const void *tx_buf;void *rx_buf;unsigned len; -unsigned actual_length; };/* eSPI Controller mode register definitions */
@@ -328,8 +327,6 @@ static int fsl_espi_cmd_trans(struct spi_message *m, espi_trans->tx_buf = espi_trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, espi_trans); - espi_trans->actual_length = espi_trans->len; -return ret; }
@@ -350,7 +347,6 @@ static int fsl_espi_rw_trans(struct spi_message *m,if (trans->len > tx_only)memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); - trans->actual_length += trans->len; }return ret;
@@ -373,14 +369,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, } espi_trans.len = xfer_len; - espi_trans.actual_length =0 ;if (!rx_buf) ret =fsl_espi_cmd_trans (m, &espi_trans,NULL );else ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); - m->actual_length = espi_trans.actual_length; + m->actual_length = ret ?0 : espi_trans.len; +if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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
PATCH 12/23 spi: fsl-espi: eliminate struct fsl_espi_transfer
In reply to a message not in the archiveThe remaining elements of struct fsl_espi_transfer are part of struct spi_transfer anyway. So we can get rid of struct fsl_espi_transfer and use a struct spi_transfer only.
--- drivers/spi/spi-fsl-espi.c | 56 +++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 36 deletions(-)
drivers/spi/spi-fsl-espi.c +20 -36
@@ -37,12 +37,6 @@ struct fsl_espi_reg {__be32 csmode[4 ];/* 0x020 - 0x02c eSPI cs mode register */ }; -struct fsl_espi_transfer { -const void *tx_buf; -void *rx_buf; -unsigned len; -}; -/* eSPI Controller mode register definitions */ #define SPMODE_ENABLE (1 << 31)#define SPMODE_LOOP (1 << 30)
@@ -268,17 +262,13 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count; } -static int fsl_espi_do_trans (struct spi_message *m, -struct fsl_espi_transfer *tr) +static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master); -struct fsl_espi_transfer *espi_trans = tr; -struct spi_transfer *t, *first, trans; +struct spi_transfer *t, *first;int ret =0 ; -memset (&trans,0 ,sizeof (trans)); - first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list);list_for_each_entry (t, &m->transfers, transfer_list) {
@@ -289,26 +279,22 @@ static int fsl_espi_do_trans(struct spi_message *m,return -EINVAL ; } - trans.speed_hz = t->speed_hz; - trans.bits_per_word = t->bits_per_word; - trans.delay_usecs =max (first->delay_usecs, t->delay_usecs); + trans->speed_hz = t->speed_hz; + trans->bits_per_word = t->bits_per_word; + trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); } - trans.len = espi_trans->len; - trans.tx_buf = espi_trans->tx_buf; - trans.rx_buf = espi_trans->rx_buf; - -if (trans.bits_per_word || trans.speed_hz) -fsl_espi_setup_transfer (spi, &trans); +if (trans->bits_per_word || trans->speed_hz) +fsl_espi_setup_transfer (spi, trans); -if (trans.len) - ret =fsl_espi_bufs (spi, &trans); +if (trans->len) + ret =fsl_espi_bufs (spi, trans);if (ret) ret = -EMSGSIZE ; -if (trans.delay_usecs) -udelay (trans.delay_usecs); +if (trans->delay_usecs) +udelay (trans->delay_usecs);fsl_espi_setup_transfer (spi,NULL );
@@ -316,22 +302,21 @@ static int fsl_espi_do_trans(struct spi_message *m, }static int fsl_espi_cmd_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +struct spi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -struct fsl_espi_transfer *espi_trans = trans;int ret;fsl_espi_copy_to_buf (m, mspi); - espi_trans->tx_buf = espi_trans->rx_buf = mspi->local_buf; - ret =fsl_espi_do_trans (m, espi_trans); + trans->tx_buf = trans->rx_buf = mspi->local_buf; + ret =fsl_espi_do_trans (m, trans);return ret; }static int fsl_espi_rw_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +struct spi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only;
@@ -355,10 +340,9 @@ static int fsl_espi_rw_trans(struct spi_message *m,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { -struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ; -struct fsl_espi_transfer espi_trans; +struct spi_transfer *t, trans = {};int ret;list_for_each_entry (t, &m->transfers, transfer_list) {
@@ -368,14 +352,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, xfer_len += t->len; } - espi_trans.len = xfer_len; + trans.len = xfer_len;if (!rx_buf) - ret =fsl_espi_cmd_trans (m, &espi_trans,NULL ); + ret =fsl_espi_cmd_trans (m, &trans,NULL );else - ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); + ret =fsl_espi_rw_trans (m, &trans, rx_buf); - m->actual_length = ret ?0 : espi_trans.len; + m->actual_length = ret ?0 : trans.len;if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 1 line
2.9.2
Quoted 1 line
From
50844eb4dd9f76cf213ea3baa1ab742f09232c58Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Fri, 19 Aug 2016 20:59:01 +0200
Subject: [PATCH 12/23] remove struct fsl_espi_transfer
--- drivers/spi/spi-fsl-espi.c | 56 +++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 36 deletions(-)
drivers/spi/spi-fsl-espi.c +20 -36
121 lines not on this page · raw message
Signature · 7 lines
2.9.2 -- 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
PATCH 13/23 spi: fsl-espi: merge fsl_espi_cmd_trans and fsl_espi_rw_trans
In reply to a message not in the archivefsl_espi_cmd_trans and fsl_espi_rw_trans share most of the code so we can merge them.
--- drivers/spi/spi-fsl-espi.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-)
drivers/spi/spi-fsl-espi.c +6 -26
@@ -301,22 +301,8 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)return ret; } -static int fsl_espi_cmd_trans (struct spi_message *m, -struct spi_transfer *trans,u8 *rx_buff) -{ -struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -int ret; - -fsl_espi_copy_to_buf (m, mspi); - - trans->tx_buf = trans->rx_buf = mspi->local_buf; - ret =fsl_espi_do_trans (m, trans); - -return ret; -} - -static int fsl_espi_rw_trans (struct spi_message *m, -struct spi_transfer *trans,u8 *rx_buff) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans, +u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only;
@@ -327,12 +313,9 @@ static int fsl_espi_rw_trans(struct spi_message *m, trans->tx_buf = trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, trans); -if (!ret) { -/* If there is at least one RX byte then copy it to rx_buff */ -if (trans->len > tx_only) -memcpy (rx_buff, trans->rx_buf + tx_only, - trans->len - tx_only); - } +/* If there is at least one RX byte then copy it to rx_buff */ +if (!ret && rx_buff && trans->len > tx_only) +memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only);return ret; }
@@ -354,10 +337,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.len = xfer_len; -if (!rx_buf) - ret =fsl_espi_cmd_trans (m, &trans,NULL ); -else - ret =fsl_espi_rw_trans (m, &trans, rx_buf); + ret =fsl_espi_trans (m, &trans, rx_buf); m->actual_length = ret ?0 : trans.len;
Signature · 7 lines
2.9.2 -- 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
PATCH 14/23 spi: fsl-espi: remove unneeded check in fsl_espi_do_trans
In reply to a message not in the archiveSPI core takes care that both values are always populated.
--- drivers/spi/spi-fsl-espi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -2
@@ -284,8 +284,7 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans) trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); } -if (trans->bits_per_word || trans->speed_hz) -fsl_espi_setup_transfer (spi, trans); +fsl_espi_setup_transfer (spi, trans);if (trans->len) ret =fsl_espi_bufs (spi, trans);
Signature · 7 lines
2.9.2 -- 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
PATCH 15/23 spi: fsl-espi: improve return value handling in fsl_espi_bufs
In reply to a message not in the archiveReturn a proper status code from fsl_espi_bufs instead of returning the number of remaining words and let the caller evaluate it.
--- drivers/spi/spi-fsl-espi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -4
@@ -259,7 +259,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)/* disable rx ints */ mpc8xxx_spi_write_reg (®_base->mask,0 ); -return mpc8xxx_spi->count; +return mpc8xxx_spi->count >0 ? -EMSGSIZE :0 ; }static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans)
@@ -289,9 +289,6 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)if (trans->len) ret =fsl_espi_bufs (spi, trans); -if (ret) - ret = -EMSGSIZE ; -if (trans->delay_usecs)udelay (trans->delay_usecs);
Signature · 7 lines
2.9.2 -- 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): d8aa466c-1366-8aa0-5cf6-d0be7dbafa3a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: improve return value handling in fsl_espi_bufs" to the spi tree
The patch
spi: fsl-espi: improve return value handling in fsl_espi_bufs
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
84ccfc371f4a8d1ff86efd7ca7914e33b90325c2Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:52:43 +0200
Subject: [PATCH] spi: fsl-espi: improve return value handling in fsl_espi_bufs
Return a proper status code from fsl_espi_bufs instead of returning the number of remaining words and let the caller evaluate it.
--- drivers/spi/spi-fsl-espi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -4
@@ -258,7 +258,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)/* disable rx ints */ mpc8xxx_spi_write_reg (®_base->mask,0 ); -return mpc8xxx_spi->count; +return mpc8xxx_spi->count >0 ? -EMSGSIZE :0 ; }static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans)
@@ -288,9 +288,6 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)if (trans->len) ret =fsl_espi_bufs (spi, trans); -if (ret) - ret = -EMSGSIZE ; -if (trans->delay_usecs)udelay (trans->delay_usecs);
Signature · 6 lines
2.8.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
PATCH 16/23 spi: fsl-espi: merge fsl_espi_bufs and fsl_espi_cpu_bufs
In reply to a message not in the archivefsl_espi_bufs and fsl_espi_cpu_bufs are very small that we can merge them.
--- drivers/spi/spi-fsl-espi.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/spi/spi-fsl-espi.c +8 -19
@@ -207,31 +207,15 @@ static void fsl_espi_setup_transfer(struct spi_device *spi,fsl_espi_change_mode (spi); } -static void fsl_espi_cpu_bufs (struct mpc8xxx_spi *mspi,struct spi_transfer *t, -unsigned int len) -{ -u32 word; -struct fsl_espi_reg *reg_base = mspi->reg_base; - - mspi->count = len; - -/* enable rx ints */ -mpc8xxx_spi_write_reg (®_base->mask,SPIM_NE ); - -/* transmit word */ - word = mspi->get_tx (mspi); -mpc8xxx_spi_write_reg (®_base->transmit, word); -} -static int fsl_espi_bufs (struct spi_device *spi,struct spi_transfer *t) {struct mpc8xxx_spi *mpc8xxx_spi =spi_master_get_devdata (spi->master);struct fsl_espi_reg *reg_base = mpc8xxx_spi->reg_base; -unsigned int len = t->len; +u32 word;int ret; mpc8xxx_spi->len = t->len; - len =roundup (len,4 ) /4 ; + mpc8xxx_spi->count =roundup (t->len,4 ) /4 ; mpc8xxx_spi->tx = t->tx_buf; mpc8xxx_spi->rx = t->rx_buf;
@@ -247,7 +231,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 ))); -fsl_espi_cpu_bufs (mpc8xxx_spi, t, len); +/* enable rx ints */ +mpc8xxx_spi_write_reg (®_base->mask,SPIM_NE ); + +/* transmit word */ + word = mpc8xxx_spi->get_tx (mpc8xxx_spi); +mpc8xxx_spi_write_reg (®_base->transmit, word);/* Won't hang up forever, SPI bus sometimes got lost interrupts... */ ret =wait_for_completion_timeout (&mpc8xxx_spi->done,2 *HZ );
Signature · 7 lines
2.9.2 -- 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): 178b274d-2785-5f64-0334-40526c13d7f9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: merge fsl_espi_bufs and fsl_espi_cpu_bufs" to the spi tree
The patch
spi: fsl-espi: merge fsl_espi_bufs and fsl_espi_cpu_bufs
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
5bcc6a2f061266060e0b144302e83e614f683cd7Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:53:01 +0200
Subject: [PATCH] spi: fsl-espi: merge fsl_espi_bufs and fsl_espi_cpu_bufs
fsl_espi_bufs and fsl_espi_cpu_bufs are very small that we can merge them.
--- drivers/spi/spi-fsl-espi.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/spi/spi-fsl-espi.c +8 -19
@@ -206,31 +206,15 @@ static void fsl_espi_setup_transfer(struct spi_device *spi,fsl_espi_change_mode (spi); } -static void fsl_espi_cpu_bufs (struct mpc8xxx_spi *mspi,struct spi_transfer *t, -unsigned int len) -{ -u32 word; -struct fsl_espi_reg *reg_base = mspi->reg_base; - - mspi->count = len; - -/* enable rx ints */ -mpc8xxx_spi_write_reg (®_base->mask,SPIM_NE ); - -/* transmit word */ - word = mspi->get_tx (mspi); -mpc8xxx_spi_write_reg (®_base->transmit, word); -} -static int fsl_espi_bufs (struct spi_device *spi,struct spi_transfer *t) {struct mpc8xxx_spi *mpc8xxx_spi =spi_master_get_devdata (spi->master);struct fsl_espi_reg *reg_base = mpc8xxx_spi->reg_base; -unsigned int len = t->len; +u32 word;int ret; mpc8xxx_spi->len = t->len; - len =roundup (len,4 ) /4 ; + mpc8xxx_spi->count =roundup (t->len,4 ) /4 ; mpc8xxx_spi->tx = t->tx_buf; mpc8xxx_spi->rx = t->rx_buf;
@@ -246,7 +230,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 ))); -fsl_espi_cpu_bufs (mpc8xxx_spi, t, len); +/* enable rx ints */ +mpc8xxx_spi_write_reg (®_base->mask,SPIM_NE ); + +/* transmit word */ + word = mpc8xxx_spi->get_tx (mpc8xxx_spi); +mpc8xxx_spi_write_reg (®_base->transmit, word);/* Won't hang up forever, SPI bus sometimes got lost interrupts... */ ret =wait_for_completion_timeout (&mpc8xxx_spi->done,2 *HZ );
Signature · 6 lines
2.8.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
PATCH 17/23 spi: fsl-espi: improve the ISR frame
In reply to a message not in the archiveImprove the ISR frame:
- move resetting the event bits to the ISR frame
- change type of parameter irq to int
- make sure that the event bits match at least one bit in the interrupt mask register
--- drivers/spi/spi-fsl-espi.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/spi/spi-fsl-espi.c +10 -13
@@ -451,17 +451,11 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) ®_base->event)) & SPIE_NF), 1000, 0);if (!ret) {dev_err (mspi->dev,"tired waiting for SPIE_NF\n" ); - -/* Clear the SPIE bits */ -mpc8xxx_spi_write_reg (®_base->event, events);complete (&mspi->done);return ; } } -/* Clear the events */ -mpc8xxx_spi_write_reg (®_base->event, events); - mspi->count -=1 ;if (mspi->count) {u32 word = mspi->get_tx (mspi);
@@ -472,23 +466,26 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) } } -static irqreturn_t fsl_espi_irq (s32 irq,void *context_data) +static irqreturn_t fsl_espi_irq (int irq,void *context_data) {struct mpc8xxx_spi *mspi = context_data;struct fsl_espi_reg *reg_base = mspi->reg_base; -irqreturn_t ret =IRQ_NONE ; -u32 events; +u32 mask, events; -/* Get interrupt events(tx/rx) */ +/* Get interrupt mask and events and check that irq belongs to us */ + mask =mpc8xxx_spi_read_reg (®_base->mask); events =mpc8xxx_spi_read_reg (®_base->event); -if (events) - ret =IRQ_HANDLED ; +if (!(mask & events)) +return IRQ_NONE ;dev_vdbg (mspi->dev,"%s: events %x\n" , __func__, events);fsl_espi_cpu_irq (mspi, events); -return ret; +/* Clear the events */ +mpc8xxx_spi_write_reg (®_base->event, events); + +return IRQ_HANDLED ; }#ifdef CONFIG_PM
Signature · 7 lines
2.9.2 -- 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
PATCH 18/23 spi: fsl-espi: factor out initial message checking
In reply to a message not in the archiveChecking the message is currently done at diffrent places in the driver. Factor it out to fsl_espi_check_message.
--- drivers/spi/spi-fsl-espi.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-)
drivers/spi/spi-fsl-espi.c +29 -14
@@ -97,6 +97,30 @@ static unsigned int fsl_espi_copy_to_buf(struct spi_message *m,return tx_only; } +static int fsl_espi_check_message (struct spi_message *m) +{ +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); +struct spi_transfer *t, *first; + +if (m->frame_length >SPCOM_TRANLEN_MAX ) { +dev_err (mspi->dev,"message too long, size is %u bytes\n" , + m->frame_length); +return -EMSGSIZE ; + } + + first = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); +list_for_each_entry (t, &m->transfers, transfer_list) { +if (first->bits_per_word != t->bits_per_word || + first->speed_hz != t->speed_hz) { +dev_err (mspi->dev,"bits_per_word/speed_hz should be the same for all transfers\n" ); +return -EINVAL ; + } + } + +return 0 ; +} +static void fsl_espi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -223,11 +247,6 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)reinit_completion (&mpc8xxx_spi->done);/* Set SPCOM[CS] and SPCOM[TRANLEN] field */ -if (t->len >SPCOM_TRANLEN_MAX ) { -dev_err (mpc8xxx_spi->dev,"Transaction length (%d)" -" beyond the SPCOM[TRANLEN] field\n" , t->len); -return -EINVAL ; - }mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 )));
@@ -254,20 +273,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi; -struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct spi_transfer *t, *first;int ret =0 ; first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list);list_for_each_entry (t, &m->transfers, transfer_list) { -if ((first->bits_per_word != t->bits_per_word) || - (first->speed_hz != t->speed_hz)) { -dev_err (mspi->dev, -"bits_per_word/speed_hz should be same for the same SPI transfer\n" ); -return -EINVAL ; - } - trans->speed_hz = t->speed_hz; trans->bits_per_word = t->bits_per_word; trans->delay_usecs =max (first->delay_usecs, t->delay_usecs);
@@ -313,6 +324,10 @@ static int fsl_espi_do_one_msg(struct spi_master *master,struct spi_transfer *t, trans = {};int ret; + ret =fsl_espi_check_message (m); +if (ret) + goto out; +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
@@ -325,7 +340,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ret =fsl_espi_trans (m, &trans, rx_buf); m->actual_length = ret ?0 : trans.len; - +out:if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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): bbdff897-50b8-c4b5-5598-1c82c6e530af-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: factor out initial message checking" to the spi tree
The patch
spi: fsl-espi: factor out initial message checking
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
d3152cf1c8cf3f75d8eb82ae399ea4b35a0df8d4Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:53:38 +0200
Subject: [PATCH] spi: fsl-espi: factor out initial message checking
Checking the message is currently done at diffrent places in the driver. Factor it out to fsl_espi_check_message.
--- drivers/spi/spi-fsl-espi.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-)
drivers/spi/spi-fsl-espi.c +29 -14
@@ -98,6 +98,30 @@ static unsigned int fsl_espi_copy_to_buf(struct spi_message *m,return tx_only; } +static int fsl_espi_check_message (struct spi_message *m) +{ +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); +struct spi_transfer *t, *first; + +if (m->frame_length >SPCOM_TRANLEN_MAX ) { +dev_err (mspi->dev,"message too long, size is %u bytes\n" , + m->frame_length); +return -EMSGSIZE ; + } + + first = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); +list_for_each_entry (t, &m->transfers, transfer_list) { +if (first->bits_per_word != t->bits_per_word || + first->speed_hz != t->speed_hz) { +dev_err (mspi->dev,"bits_per_word/speed_hz should be the same for all transfers\n" ); +return -EINVAL ; + } + } + +return 0 ; +} +static void fsl_espi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -222,11 +246,6 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)reinit_completion (&mpc8xxx_spi->done);/* Set SPCOM[CS] and SPCOM[TRANLEN] field */ -if (t->len >SPCOM_TRANLEN_MAX ) { -dev_err (mpc8xxx_spi->dev,"Transaction length (%d)" -" beyond the SPCOM[TRANLEN] field\n" , t->len); -return -EINVAL ; - }mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 )));
@@ -253,20 +272,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi; -struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct spi_transfer *t, *first;int ret =0 ; first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list);list_for_each_entry (t, &m->transfers, transfer_list) { -if ((first->bits_per_word != t->bits_per_word) || - (first->speed_hz != t->speed_hz)) { -dev_err (mspi->dev, -"bits_per_word/speed_hz should be same for the same SPI transfer\n" ); -return -EINVAL ; - } - trans->speed_hz = t->speed_hz; trans->bits_per_word = t->bits_per_word; trans->delay_usecs =max (first->delay_usecs, t->delay_usecs);
@@ -313,6 +324,10 @@ static int fsl_espi_do_one_msg(struct spi_master *master,struct spi_transfer *t, trans = {};int ret; + ret =fsl_espi_check_message (m); +if (ret) + goto out; +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
@@ -325,7 +340,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ret =fsl_espi_trans (m, &trans, rx_buf); m->actual_length = ret ?0 : trans.len; - +out:if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 6 lines
2.8.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
PATCH 19/23 spi: fsl-espi: centralize populating struct spi_transfer
In reply to a message not in the archiveBetter structure the code by population all elements of struct spi_transfer in one place.
--- drivers/spi/spi-fsl-espi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/spi/spi-fsl-espi.c +11 -11
@@ -273,17 +273,8 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi; -struct spi_transfer *t, *first;int ret =0 ; - first = list_first_entry(&m->transfers, struct spi_transfer, - transfer_list); -list_for_each_entry (t, &m->transfers, transfer_list) { - trans->speed_hz = t->speed_hz; - trans->bits_per_word = t->bits_per_word; - trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); - } -fsl_espi_setup_transfer (spi, trans);if (trans->len)
@@ -306,7 +297,6 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans, tx_only =fsl_espi_copy_to_buf (m, mspi); - trans->tx_buf = trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, trans);/* If there is at least one RX byte then copy it to rx_buff */
@@ -319,8 +309,9 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);u8 *rx_buf =NULL ; -unsigned int xfer_len =0 ; +unsigned int delay_usecs =0 , xfer_len =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -333,9 +324,18 @@ static int fsl_espi_do_one_msg(struct spi_master *master, rx_buf = t->rx_buf;if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len; +if (t->delay_usecs > delay_usecs) + delay_usecs = t->delay_usecs; } + t = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); + trans.len = xfer_len; + trans.speed_hz = t->speed_hz; + trans.bits_per_word = t->bits_per_word; + trans.delay_usecs = delay_usecs; + trans.tx_buf = trans.rx_buf = mspi->local_buf; ret =fsl_espi_trans (m, &trans, rx_buf);
Signature · 7 lines
2.9.2 -- 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
PATCH 20/23 spi: fsl-espi: factor out handling of read data
In reply to a message not in the archiveFactor out copying read data to the read buffers in the original message to a new function fsl_espi_copy_from_buf.
This also allows to simplify fsl_espi_copy_to_buf.
--- drivers/spi/spi-fsl-espi.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
drivers/spi/spi-fsl-espi.c +21 -19
@@ -77,24 +77,32 @@ struct fsl_espi_reg {#define AUTOSUSPEND_TIMEOUT 2000 -static unsigned int fsl_espi_copy_to_buf (struct spi_message *m, -struct mpc8xxx_spi *mspi) +static void fsl_espi_copy_to_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) { -unsigned int tx_only =0 ;struct spi_transfer *t;u8 *buf = mspi->local_buf;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { +if (t->tx_buf)memcpy (buf, t->tx_buf, t->len); -if (!t->rx_buf) - tx_only += t->len; - }else +else memset (buf,0 , t->len); buf += t->len; } +} + +static void fsl_espi_copy_from_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) +{ +struct spi_transfer *t; +u8 *buf = mspi->local_buf; -return tx_only; +list_for_each_entry (t, &m->transfers, transfer_list) { +if (t->rx_buf) +memcpy (t->rx_buf, buf, t->len); + buf += t->len; + } }static int fsl_espi_check_message (struct spi_message *m)
@@ -288,20 +296,17 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)return ret; } -static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans, -u8 *rx_buff) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -unsigned int tx_only;int ret; - tx_only =fsl_espi_copy_to_buf (m, mspi); +fsl_espi_copy_to_buf (m, mspi); ret =fsl_espi_do_trans (m, trans); -/* If there is at least one RX byte then copy it to rx_buff */ -if (!ret && rx_buff && trans->len > tx_only) -memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); +if (!ret) +fsl_espi_copy_from_buf (m, mspi);return ret; }
@@ -310,7 +315,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -u8 *rx_buf =NULL ;unsigned int delay_usecs =0 , xfer_len =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -320,8 +324,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->rx_buf) - rx_buf = t->rx_buf;if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len;if (t->delay_usecs > delay_usecs)
@@ -337,7 +339,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.delay_usecs = delay_usecs; trans.tx_buf = trans.rx_buf = mspi->local_buf; - ret =fsl_espi_trans (m, &trans, rx_buf); + ret =fsl_espi_trans (m, &trans); m->actual_length = ret ?0 : trans.len; out:
Signature · 7 lines
2.9.2 -- 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
PATCH 21/23 spi: fsl-espi: simplify fsl_espi_setup_transfer
In reply to a message not in the archiveSimplify fsl_espi_setup_transfer a little.
--- drivers/spi/spi-fsl-espi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -3
@@ -210,12 +210,10 @@ static void fsl_espi_setup_transfer(struct spi_device *spi, mpc8xxx_spi->get_rx = cs->get_rx; mpc8xxx_spi->get_tx = cs->get_tx; - bits_per_word = bits_per_word -1 ; -/* mask out bits we are going to set */ cs->hw_mode &= ~(CSMODE_LEN (0xF ) |CSMODE_DIV16 |CSMODE_PM (0xF )); - cs->hw_mode |=CSMODE_LEN (bits_per_word); + cs->hw_mode |=CSMODE_LEN (bits_per_word -1 );if ((mpc8xxx_spi->spibrg / hz) >64 ) { cs->hw_mode |=CSMODE_DIV16 ;
Signature · 7 lines
2.9.2 -- 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): b65bdf36-d8cd-dc67-54ad-64672e367d2f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: simplify fsl_espi_setup_transfer" to the spi tree
The patch
spi: fsl-espi: simplify fsl_espi_setup_transfer
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
a755af52f8ef278985d1475070c0647f2e6e47a7Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Sun, 4 Sep 2016 09:56:57 +0200
Subject: [PATCH] spi: fsl-espi: simplify fsl_espi_setup_transfer
Simplify fsl_espi_setup_transfer a little.
--- drivers/spi/spi-fsl-espi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -3
@@ -166,12 +166,10 @@ static void fsl_espi_setup_transfer(struct spi_device *spi, mpc8xxx_spi->get_rx = cs->get_rx; mpc8xxx_spi->get_tx = cs->get_tx; - bits_per_word = bits_per_word -1 ; -/* mask out bits we are going to set */ cs->hw_mode &= ~(CSMODE_LEN (0xF ) |CSMODE_DIV16 |CSMODE_PM (0xF )); - cs->hw_mode |=CSMODE_LEN (bits_per_word); + cs->hw_mode |=CSMODE_LEN (bits_per_word -1 );if ((mpc8xxx_spi->spibrg / hz) >64 ) { cs->hw_mode |=CSMODE_DIV16 ;
Signature · 6 lines
2.9.3 -- 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
PATCH 22/23 spi: fsl-espi: improve message length handling
In reply to a message not in the archiveMove checking for a zero-length message up in the call chain and use m->frame_length instead of re-calculating the overall length of all transfers in the message.
--- drivers/spi/spi-fsl-espi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/spi/spi-fsl-espi.c +5 -7
@@ -283,8 +283,7 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)fsl_espi_setup_transfer (spi, trans); -if (trans->len) - ret =fsl_espi_bufs (spi, trans); + ret =fsl_espi_bufs (spi, trans);if (trans->delay_usecs)udelay (trans->delay_usecs);
@@ -313,7 +312,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -unsigned int delay_usecs =0 , xfer_len =0 ; +unsigned int delay_usecs =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -322,8 +321,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out;list_for_each_entry (t, &m->transfers, transfer_list) { -if ((t->tx_buf) || (t->rx_buf)) - xfer_len += t->len;if (t->delay_usecs > delay_usecs) delay_usecs = t->delay_usecs; }
@@ -331,13 +328,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, t = list_first_entry(&m->transfers, struct spi_transfer, transfer_list); - trans.len = xfer_len; + trans.len = m->frame_length; trans.speed_hz = t->speed_hz; trans.bits_per_word = t->bits_per_word; trans.delay_usecs = delay_usecs; trans.tx_buf = trans.rx_buf = mspi->local_buf; - ret =fsl_espi_trans (m, &trans); +if (trans.len) + ret =fsl_espi_trans (m, &trans); m->actual_length = ret ?0 : trans.len; out:
Signature · 7 lines
2.9.2 -- 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
PATCH 23/23 spi: fsl-espi: merge fsl_espi_trans and fsl_espi_do_trans
In reply to a message not in the archiveMerge both functions to reduce source code size and improve readability.
--- drivers/spi/spi-fsl-espi.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/spi/spi-fsl-espi.c +4 -14
@@ -276,11 +276,13 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count >0 ? -EMSGSIZE :0 ; } -static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_device *spi = m->spi; -int ret =0 ; +int ret; +fsl_espi_copy_to_buf (m, mspi);fsl_espi_setup_transfer (spi, trans); ret =fsl_espi_bufs (spi, trans);
@@ -290,18 +292,6 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)fsl_espi_setup_transfer (spi,NULL ); -return ret; -} - -static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) -{ -struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -int ret; - -fsl_espi_copy_to_buf (m, mspi); - - ret =fsl_espi_do_trans (m, trans); -if (!ret)fsl_espi_copy_from_buf (m, mspi);
Signature · 7 lines
2.9.2 -- 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): b8a3ee2d-b46a-2681-a11e-b5a773179589-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: merge fsl_espi_trans and fsl_espi_do_trans" to the spi tree
The patch
spi: fsl-espi: merge fsl_espi_trans and fsl_espi_do_trans
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
38d003f1a43f3afd6b5e0da728f06dad07a85687Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:54:51 +0200
Subject: [PATCH] spi: fsl-espi: merge fsl_espi_trans and fsl_espi_do_trans
Merge both functions to reduce source code size and improve readability.
--- drivers/spi/spi-fsl-espi.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/spi/spi-fsl-espi.c +4 -14
@@ -276,11 +276,13 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count >0 ? -EMSGSIZE :0 ; } -static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_device *spi = m->spi; -int ret =0 ; +int ret; +fsl_espi_copy_to_buf (m, mspi);fsl_espi_setup_transfer (spi, trans); ret =fsl_espi_bufs (spi, trans);
@@ -290,18 +292,6 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)fsl_espi_setup_transfer (spi,NULL ); -return ret; -} - -static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) -{ -struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -int ret; - -fsl_espi_copy_to_buf (m, mspi); - - ret =fsl_espi_do_trans (m, trans); -if (!ret)fsl_espi_copy_from_buf (m, mspi);
Signature · 6 lines
2.8.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
PATCH v2 2/23 spi: fsl-espi: remove unused elements n_rx and n_tx in struct fsl_espi_transfer
In reply to a message not in the archiveBoth elements are not used, so remove them.
---
v2:
- switch order of patches 2 and 3 to do the trivial changes first
--- drivers/spi/spi-fsl-espi.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -11
@@ -41,8 +41,6 @@ struct fsl_espi_transfer {const void *tx_buf;void *rx_buf;unsigned len; -unsigned n_tx; -unsigned n_rx;unsigned actual_length;int status; };
@@ -371,24 +369,16 @@ static int fsl_espi_do_one_msg(struct spi_master *master, {struct spi_transfer *t;u8 *rx_buf =NULL ; -unsigned int n_tx =0 ; -unsigned int n_rx =0 ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) - n_tx += t->len; -if (t->rx_buf) { - n_rx += t->len; +if (t->rx_buf) rx_buf = t->rx_buf; - }if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len; } - espi_trans.n_tx = n_tx; - espi_trans.n_rx = n_rx; espi_trans.len = xfer_len; espi_trans.actual_length =0 ; espi_trans.status =0 ;
Signature · 7 lines
2.9.2 -- 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): 52c5893a-5927-4c83-4838-d618d434922c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH v2 02/23] spi: fsl-espi: remove unused elements n_rx and n_tx in struct fsl_espi_transfer
Quoted 1 line · Heiner Kallweit
Both elements are not used, so remove them.
I'm missing a lot of patches from this series, at least the first one but there's a bunch of others too. Please check and resend.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 02/23] spi: fsl-espi: remove unused elements n_rx and n_tx in struct fsl_espi_transfer
Am 03.09.2016 um 02:09 schrieb Mark Brown:
Quoted 6 lines · Heiner Kallweit
Quoted 1 line
Both elements are not used, so remove them.
I'm missing a lot of patches from this series, at least the first one but there's a bunch of others too. Please check and resend.
Patches 1 and 4-7 of the series you applied already. Yesterday I sent a v2 of patches 2, 3 and about an hour later v2 of patches 8-23. Based on your review comments it's mainly about reordering patches (do trivial things first), smaller code style fixes, and mainly rebasing. Maybe some issue with referencing the mails correctly?
--
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): 226e54e5-98d9-75a7-5cfc-3f21492cd358-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH v2 02/23] spi: fsl-espi: remove unused elements n_rx and n_tx in struct fsl_espi_transfer
Quoted 7 lines · Heiner Kallweit
Am 03.09.2016 um 02:09 schrieb Mark Brown:
Quoted 2 lines
I'm missing a lot of patches from this series, at least the first one but there's a bunch of others too. Please check and resend.
Patches 1 and 4-7 of the series you applied already. Yesterday I sent a v2 of patches 2, 3 and about an hour later v2 of patches 8-23.
Patch numbering exists solely in order to sort the patches within the series you're sending. If you've previously sent patches that's totally irrelevant and confuses things, just number the patches in order without gaps.
Quoted 3 lines
Based on your review comments it's mainly about reordering patches (do trivial things first), smaller code style fixes, and mainly rebasing. Maybe some issue with referencing the mails correctly?
Not sure what you mean here but if you're trying to send the patches in reply to their versions in the earlier series that also confuses things.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 02/23] spi: fsl-espi: remove unused elements n_rx and n_tx in struct fsl_espi_transfer
Am 03.09.2016 um 23:59 schrieb Mark Brown:
Quoted 6 lines · Heiner Kallweit
Quoted 4 lines
Am 03.09.2016 um 02:09 schrieb Mark Brown:
Quoted 2 lines
I'm missing a lot of patches from this series, at least the first one but there's a bunch of others too. Please check and resend.
Quoted 8 lines
Quoted 2 lines
Patches 1 and 4-7 of the series you applied already. Yesterday I sent a v2 of patches 2, 3 and about an hour later v2 of patches 8-23.
Patch numbering exists solely in order to sort the patches within the series you're sending. If you've previously sent patches that's totally irrelevant and confuses things, just number the patches in order without gaps.
OK, so I'll resend the remaining 18 patches of the series with new numbering.
Quoted 7 lines
Quoted 3 lines
Based on your review comments it's mainly about reordering patches (do trivial things first), smaller code style fixes, and mainly rebasing. Maybe some issue with referencing the mails correctly?
Not sure what you mean here but if you're trying to send the patches in reply to their versions in the earlier series that also confuses things.
--
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
Applied "spi: fsl-espi: remove unused elements n_rx and n_tx in struct fsl_espi_transfer" to the spi tree
In reply to a message not in the archiveThe patch
spi: fsl-espi: remove unused elements n_rx and n_tx in struct fsl_espi_transfer
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
daae020ce9fe4324322c6ed18a840234a05d76b3Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Sun, 4 Sep 2016 09:53:01 +0200
Subject: [PATCH] spi: fsl-espi: remove unused elements n_rx and n_tx in struct
fsl_espi_transfer
Both elements are not used, so remove them.
--- drivers/spi/spi-fsl-espi.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -11
@@ -41,8 +41,6 @@ struct fsl_espi_transfer {const void *tx_buf;void *rx_buf;unsigned len; -unsigned n_tx; -unsigned n_rx;unsigned actual_length;int status; };
@@ -371,24 +369,16 @@ static int fsl_espi_do_one_msg(struct spi_master *master, {struct spi_transfer *t;u8 *rx_buf =NULL ; -unsigned int n_tx =0 ; -unsigned int n_rx =0 ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) - n_tx += t->len; -if (t->rx_buf) { - n_rx += t->len; +if (t->rx_buf) rx_buf = t->rx_buf; - }if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len; } - espi_trans.n_tx = n_tx; - espi_trans.n_rx = n_rx; espi_trans.len = xfer_len; espi_trans.actual_length =0 ; espi_trans.status =0 ;
Signature · 6 lines
2.9.3 -- 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
PATCH v2 8/23 spi: fsl-espi: factor out filling the local buffer
In reply to a message not in the archiveBetter structure the code by factoring out filling the local buffer.
In addition don't initialize the complete local buffer at the beginning of fsl_espi_do_one_msg. Instead move initialization of those parts of the local buffer to be used for transfers w/o tx_buf to fsl_espi_copy_to_buf.
---
v2:
- fixed coding style issue
- improved commit message
--- drivers/spi/spi-fsl-espi.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
drivers/spi/spi-fsl-espi.c +24 -22
@@ -85,6 +85,27 @@ struct fsl_espi_transfer {#define AUTOSUSPEND_TIMEOUT 2000 +static unsigned int fsl_espi_copy_to_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) +{ +unsigned int tx_only =0 ; +struct spi_transfer *t; +u8 *buf = mspi->local_buf; + +list_for_each_entry (t, &m->transfers, transfer_list) { +if (t->tx_buf) { +memcpy (buf, t->tx_buf, t->len); +if (!t->rx_buf) + tx_only += t->len; + }else { +memset (buf,0 , t->len); + } + buf += t->len; + } + +return tx_only; +} +static void fsl_espi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -301,16 +322,9 @@ static void fsl_espi_cmd_trans(struct spi_message *m, struct fsl_espi_transfer *trans, u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); -struct spi_transfer *t; -int i =0 ;struct fsl_espi_transfer *espi_trans = trans; -list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { -memcpy (mspi->local_buf + i, t->tx_buf, t->len); - i += t->len; - } - } +fsl_espi_copy_to_buf (m, mspi); espi_trans->tx_buf = mspi->local_buf; espi_trans->rx_buf = mspi->local_buf;
@@ -323,18 +337,9 @@ static void fsl_espi_rw_trans(struct spi_message *m, struct fsl_espi_transfer *trans, u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); -struct spi_transfer *t; -unsigned int tx_only =0 ; -int i =0 ; +unsigned int tx_only; -list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { -memcpy (mspi->local_buf + i, t->tx_buf, t->len); - i += t->len; -if (!t->rx_buf) - tx_only += t->len; - } - } + tx_only =fsl_espi_copy_to_buf (m, mspi); trans->tx_buf = mspi->local_buf; trans->rx_buf = mspi->local_buf;
@@ -352,14 +357,11 @@ static void fsl_espi_rw_trans(struct spi_message *m,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { -struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; -memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
Signature · 7 lines
2.9.2 -- 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): 75a01618-11f4-d54c-4cb7-21e1ed40951a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: factor out filling the local buffer" to the spi tree
The patch
spi: fsl-espi: factor out filling the local buffer
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
7c159aa8c103b02a8434ae18b22048952c796e6fMon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:50:53 +0200
Subject: [PATCH] spi: fsl-espi: factor out filling the local buffer
Better structure the code by factoring out filling the local buffer.
In addition don't initialize the complete local buffer at the beginning of fsl_espi_do_one_msg. Instead move initialization of those parts of the local buffer to be used for transfers w/o tx_buf to fsl_espi_copy_to_buf.
--- drivers/spi/spi-fsl-espi.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
drivers/spi/spi-fsl-espi.c +24 -22
@@ -85,6 +85,27 @@ struct fsl_espi_transfer {#define AUTOSUSPEND_TIMEOUT 2000 +static unsigned int fsl_espi_copy_to_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) +{ +unsigned int tx_only =0 ; +struct spi_transfer *t; +u8 *buf = mspi->local_buf; + +list_for_each_entry (t, &m->transfers, transfer_list) { +if (t->tx_buf) { +memcpy (buf, t->tx_buf, t->len); +if (!t->rx_buf) + tx_only += t->len; + }else { +memset (buf,0 , t->len); + } + buf += t->len; + } + +return tx_only; +} +static void fsl_espi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -298,16 +319,9 @@ static void fsl_espi_cmd_trans(struct spi_message *m, struct fsl_espi_transfer *trans, u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); -struct spi_transfer *t; -int i =0 ;struct fsl_espi_transfer *espi_trans = trans; -list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { -memcpy (mspi->local_buf + i, t->tx_buf, t->len); - i += t->len; - } - } +fsl_espi_copy_to_buf (m, mspi); espi_trans->tx_buf = mspi->local_buf; espi_trans->rx_buf = mspi->local_buf;
@@ -320,18 +334,9 @@ static void fsl_espi_rw_trans(struct spi_message *m, struct fsl_espi_transfer *trans, u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); -struct spi_transfer *t; -unsigned int tx_only =0 ; -int i =0 ; +unsigned int tx_only; -list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { -memcpy (mspi->local_buf + i, t->tx_buf, t->len); - i += t->len; -if (!t->rx_buf) - tx_only += t->len; - } - } + tx_only =fsl_espi_copy_to_buf (m, mspi); trans->tx_buf = mspi->local_buf; trans->rx_buf = mspi->local_buf;
@@ -349,14 +354,11 @@ static void fsl_espi_rw_trans(struct spi_message *m,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { -struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; -memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
Signature · 6 lines
2.8.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
PATCH v2 9/23 spi: fsl-espi: simplify fsl_espi_setup_transfer
In reply to a message not in the archiveSimplify fsl_espi_setup_transfer a little.
---
v2:
- changed order of patches to do trivial changes first (was patch 21 of the series before)
--- drivers/spi/spi-fsl-espi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -3
@@ -187,12 +187,10 @@ static void fsl_espi_setup_transfer(struct spi_device *spi, mpc8xxx_spi->get_rx = cs->get_rx; mpc8xxx_spi->get_tx = cs->get_tx; - bits_per_word = bits_per_word -1 ; -/* mask out bits we are going to set */ cs->hw_mode &= ~(CSMODE_LEN (0xF ) |CSMODE_DIV16 |CSMODE_PM (0xF )); - cs->hw_mode |=CSMODE_LEN (bits_per_word); + cs->hw_mode |=CSMODE_LEN (bits_per_word -1 );if ((mpc8xxx_spi->spibrg / hz) >64 ) { cs->hw_mode |=CSMODE_DIV16 ;
Signature · 7 lines
2.9.2 -- 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
PATCH v2 10/23 spi: fsl-espi: remove unneeded check in fsl_espi_do_trans
In reply to a message not in the archiveSPI core takes care that both values are always populated.
---
v2:
- switch order of patches to do trivial changes first (was patch 14 of the series before)
--- drivers/spi/spi-fsl-espi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -2
@@ -300,8 +300,7 @@ static void fsl_espi_do_trans(struct spi_message *m, trans.tx_buf = espi_trans->tx_buf; trans.rx_buf = espi_trans->rx_buf; -if (trans.bits_per_word || trans.speed_hz) -fsl_espi_setup_transfer (spi, &trans); +fsl_espi_setup_transfer (spi, &trans);if (trans.len) status =fsl_espi_bufs (spi, &trans);
Signature · 7 lines
2.9.2 -- 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): a246d482-9c6c-72ce-5179-f661de42cb5b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: remove unneeded check in fsl_espi_do_trans" to the spi tree
The patch
spi: fsl-espi: remove unneeded check in fsl_espi_do_trans
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
71581a1507e642bbc6f698a3f43355552ee8056fMon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Sun, 4 Sep 2016 09:57:18 +0200
Subject: [PATCH] spi: fsl-espi: remove unneeded check in fsl_espi_do_trans
SPI core takes care that both values are always populated.
--- drivers/spi/spi-fsl-espi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -2
@@ -279,8 +279,7 @@ static void fsl_espi_do_trans(struct spi_message *m, trans.tx_buf = espi_trans->tx_buf; trans.rx_buf = espi_trans->rx_buf; -if (trans.bits_per_word || trans.speed_hz) -fsl_espi_setup_transfer (spi, &trans); +fsl_espi_setup_transfer (spi, &trans);if (trans.len) status =fsl_espi_bufs (spi, &trans);
Signature · 6 lines
2.9.3 -- 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
PATCH v2 11/23 spi: fsl-espi: remove element status from struct fsl_espi_transfer
In reply to a message not in the archiveUse the return values of the functions in the call chain to transport status information instead of using an element in struct fsl_espi_transfer for this.
This is more in line with the general approach how to handle status information and is one step further to eventually get rid of struct fsl_espi_transfer completely.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 47 +++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-)
drivers/spi/spi-fsl-espi.c +26 -21
@@ -42,7 +42,6 @@ struct fsl_espi_transfer {void *rx_buf;unsigned len;unsigned actual_length; -int status; };/* eSPI Controller mode register definitions */
@@ -269,14 +268,14 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count; } -static void fsl_espi_do_trans (struct spi_message *m, -struct fsl_espi_transfer *tr) +static int fsl_espi_do_trans (struct spi_message *m, +struct fsl_espi_transfer *tr) {struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct fsl_espi_transfer *espi_trans = tr;struct spi_transfer *t, *first, trans; -int status =0 ; +int ret =0 ;memset (&trans,0 ,sizeof (trans));
@@ -285,10 +284,9 @@ static void fsl_espi_do_trans(struct spi_message *m,list_for_each_entry (t, &m->transfers, transfer_list) {if ((first->bits_per_word != t->bits_per_word) || (first->speed_hz != t->speed_hz)) { - espi_trans->status = -EINVAL ;dev_err (mspi->dev,"bits_per_word/speed_hz should be same for the same SPI transfer\n" ); -return ; +return -EINVAL ; } trans.speed_hz = t->speed_hz;
@@ -303,52 +301,59 @@ static void fsl_espi_do_trans(struct spi_message *m,fsl_espi_setup_transfer (spi, &trans);if (trans.len) - status =fsl_espi_bufs (spi, &trans); + ret =fsl_espi_bufs (spi, &trans); -if (status) - status = -EMSGSIZE ; +if (ret) + ret = -EMSGSIZE ;if (trans.delay_usecs)udelay (trans.delay_usecs); - espi_trans->status = status;fsl_espi_setup_transfer (spi,NULL ); + +return ret; } -static void fsl_espi_cmd_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +static int fsl_espi_cmd_trans (struct spi_message *m, +struct fsl_espi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct fsl_espi_transfer *espi_trans = trans; +int ret;fsl_espi_copy_to_buf (m, mspi); espi_trans->tx_buf = mspi->local_buf; espi_trans->rx_buf = mspi->local_buf; -fsl_espi_do_trans (m, espi_trans); + ret =fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; + +return ret; } -static void fsl_espi_rw_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +static int fsl_espi_rw_trans (struct spi_message *m, +struct fsl_espi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only; +int ret; tx_only =fsl_espi_copy_to_buf (m, mspi); trans->tx_buf = mspi->local_buf; trans->rx_buf = mspi->local_buf; -fsl_espi_do_trans (m, trans); + ret =fsl_espi_do_trans (m, trans); -if (!trans->status) { +if (!ret) {/* If there is at least one RX byte then copy it to rx_buff */ if (trans->len > tx_only)memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); trans->actual_length += trans->len; } + +return ret; } static int fsl_espi_do_one_msg(struct spi_master *master,
@@ -358,6 +363,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master,u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +int ret;list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf)
@@ -368,15 +374,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, espi_trans.len = xfer_len; espi_trans.actual_length =0 ; - espi_trans.status =0 ;if (!rx_buf) -fsl_espi_cmd_trans (m, &espi_trans,NULL ); + ret =fsl_espi_cmd_trans (m, &espi_trans,NULL );else -fsl_espi_rw_trans (m, &espi_trans, rx_buf); + ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); m->actual_length = espi_trans.actual_length; - m->status = espi_trans.status; + m->status = ret;spi_finalize_current_message (master);return 0 ; }
Signature · 7 lines
2.9.2 -- 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): c4fba201-a69d-faa5-c5c5-6c9f51caedb2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: remove element status from struct fsl_espi_transfer" to the spi tree
The patch
spi: fsl-espi: remove element status from struct fsl_espi_transfer
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
e33a3ade909194ec2ca633a53b428d4dac853f8aMon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:51:10 +0200
Subject: [PATCH] spi: fsl-espi: remove element status from struct
fsl_espi_transfer
Use the return values of the functions in the call chain to transport status information instead of using an element in struct fsl_espi_transfer for this.
This is more in line with the general approach how to handle status information and is one step further to eventually get rid of struct fsl_espi_transfer completely.
--- drivers/spi/spi-fsl-espi.c | 47 +++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-)
drivers/spi/spi-fsl-espi.c +26 -21
@@ -42,7 +42,6 @@ struct fsl_espi_transfer {void *rx_buf;unsigned len;unsigned actual_length; -int status; };/* eSPI Controller mode register definitions */
@@ -269,14 +268,14 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count; } -static void fsl_espi_do_trans (struct spi_message *m, -struct fsl_espi_transfer *tr) +static int fsl_espi_do_trans (struct spi_message *m, +struct fsl_espi_transfer *tr) {struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct fsl_espi_transfer *espi_trans = tr;struct spi_transfer *t, *first, trans; -int status =0 ; +int ret =0 ;memset (&trans,0 ,sizeof (trans));
@@ -285,10 +284,9 @@ static void fsl_espi_do_trans(struct spi_message *m,list_for_each_entry (t, &m->transfers, transfer_list) {if ((first->bits_per_word != t->bits_per_word) || (first->speed_hz != t->speed_hz)) { - espi_trans->status = -EINVAL ;dev_err (mspi->dev,"bits_per_word/speed_hz should be same for the same SPI transfer\n" ); -return ; +return -EINVAL ; } trans.speed_hz = t->speed_hz;
@@ -303,52 +301,59 @@ static void fsl_espi_do_trans(struct spi_message *m,fsl_espi_setup_transfer (spi, &trans);if (trans.len) - status =fsl_espi_bufs (spi, &trans); + ret =fsl_espi_bufs (spi, &trans); -if (status) - status = -EMSGSIZE ; +if (ret) + ret = -EMSGSIZE ;if (trans.delay_usecs)udelay (trans.delay_usecs); - espi_trans->status = status;fsl_espi_setup_transfer (spi,NULL ); + +return ret; } -static void fsl_espi_cmd_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +static int fsl_espi_cmd_trans (struct spi_message *m, +struct fsl_espi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct fsl_espi_transfer *espi_trans = trans; +int ret;fsl_espi_copy_to_buf (m, mspi); espi_trans->tx_buf = mspi->local_buf; espi_trans->rx_buf = mspi->local_buf; -fsl_espi_do_trans (m, espi_trans); + ret =fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; + +return ret; } -static void fsl_espi_rw_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +static int fsl_espi_rw_trans (struct spi_message *m, +struct fsl_espi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only; +int ret; tx_only =fsl_espi_copy_to_buf (m, mspi); trans->tx_buf = mspi->local_buf; trans->rx_buf = mspi->local_buf; -fsl_espi_do_trans (m, trans); + ret =fsl_espi_do_trans (m, trans); -if (!trans->status) { +if (!ret) {/* If there is at least one RX byte then copy it to rx_buff */ if (trans->len > tx_only)memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); trans->actual_length += trans->len; } + +return ret; } static int fsl_espi_do_one_msg(struct spi_master *master,
@@ -358,6 +363,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master,u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +int ret;list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf)
@@ -368,15 +374,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, espi_trans.len = xfer_len; espi_trans.actual_length =0 ; - espi_trans.status =0 ;if (!rx_buf) -fsl_espi_cmd_trans (m, &espi_trans,NULL ); + ret =fsl_espi_cmd_trans (m, &espi_trans,NULL );else -fsl_espi_rw_trans (m, &espi_trans, rx_buf); + ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); m->actual_length = espi_trans.actual_length; - m->status = espi_trans.status; + m->status = ret;spi_finalize_current_message (master);return 0 ; }
Signature · 6 lines
2.8.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
PATCH v2 12/23 spi: fsl-espi: fix status handling in fsl_espi_do_one_msg
In reply to a message not in the archiveIf an error occurred during message handling return this error instead of always returning 0 and align the code with the generic implementation in spi_transfer_one_message.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/spi/spi-fsl-espi.c +5 -2
@@ -381,9 +381,12 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); m->actual_length = espi_trans.actual_length; - m->status = ret; +if (m->status == -EINPROGRESS ) + m->status = ret; +spi_finalize_current_message (master); -return 0 ; + +return ret; }static int fsl_espi_setup (struct spi_device *spi)
Signature · 7 lines
2.9.2 -- 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
PATCH v2 13/23 spi: fsl-espi: remove element actual_length from struct fsl_espi_trans
In reply to a message not in the archiveIf an error occurs during processing the message, then we don't have to populate the actual_length element of struct message. So we can get rid of element actual_length in struct fsl_espi_transfer.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-espi.c +2 -6
@@ -41,7 +41,6 @@ struct fsl_espi_transfer {const void *tx_buf;void *rx_buf;unsigned len; -unsigned actual_length; };/* eSPI Controller mode register definitions */
@@ -327,8 +326,6 @@ static int fsl_espi_cmd_trans(struct spi_message *m, espi_trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, espi_trans); - espi_trans->actual_length = espi_trans->len; -return ret; }
@@ -350,7 +347,6 @@ static int fsl_espi_rw_trans(struct spi_message *m,if (trans->len > tx_only)memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); - trans->actual_length += trans->len; }return ret;
@@ -373,14 +369,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, } espi_trans.len = xfer_len; - espi_trans.actual_length =0 ;if (!rx_buf) ret =fsl_espi_cmd_trans (m, &espi_trans,NULL );else ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); - m->actual_length = espi_trans.actual_length; + m->actual_length = ret ?0 : espi_trans.len; +if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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): ebb38b20-1977-9980-9042-cefaac7ed765-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: remove element actual_length from struct fsl_espi_trans" to the spi tree
The patch
spi: fsl-espi: remove element actual_length from struct fsl_espi_trans
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
5cd7b8be6b7b4c4fb9e2bfbfba596d27357cc359Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:51:48 +0200
Subject: [PATCH] spi: fsl-espi: remove element actual_length from struct
fsl_espi_trans
If an error occurs during processing the message, then we don't have to populate the actual_length element of struct message. So we can get rid of element actual_length in struct fsl_espi_transfer.
--- drivers/spi/spi-fsl-espi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-espi.c +2 -6
@@ -41,7 +41,6 @@ struct fsl_espi_transfer {const void *tx_buf;void *rx_buf;unsigned len; -unsigned actual_length; };/* eSPI Controller mode register definitions */
@@ -327,8 +326,6 @@ static int fsl_espi_cmd_trans(struct spi_message *m, espi_trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, espi_trans); - espi_trans->actual_length = espi_trans->len; -return ret; }
@@ -350,7 +347,6 @@ static int fsl_espi_rw_trans(struct spi_message *m,if (trans->len > tx_only)memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); - trans->actual_length += trans->len; }return ret;
@@ -373,14 +369,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, } espi_trans.len = xfer_len; - espi_trans.actual_length =0 ;if (!rx_buf) ret =fsl_espi_cmd_trans (m, &espi_trans,NULL );else ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); - m->actual_length = espi_trans.actual_length; + m->actual_length = ret ?0 : espi_trans.len; +if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 6 lines
2.8.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
PATCH v2 14/23 spi: fsl-espi: eliminate struct fsl_espi_transfer
In reply to a message not in the archiveThe remaining elements of struct fsl_espi_transfer are part of struct spi_transfer anyway. So we can get rid of struct fsl_espi_transfer and use a struct spi_transfer only.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 56 +++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 36 deletions(-)
drivers/spi/spi-fsl-espi.c +20 -36
@@ -37,12 +37,6 @@ struct fsl_espi_reg {__be32 csmode[4 ];/* 0x020 - 0x02c eSPI cs mode register */ }; -struct fsl_espi_transfer { -const void *tx_buf; -void *rx_buf; -unsigned len; -}; -/* eSPI Controller mode register definitions */ #define SPMODE_ENABLE (1 << 31)#define SPMODE_LOOP (1 << 30)
@@ -267,17 +261,13 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count; } -static int fsl_espi_do_trans (struct spi_message *m, -struct fsl_espi_transfer *tr) +static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master); -struct fsl_espi_transfer *espi_trans = tr; -struct spi_transfer *t, *first, trans; +struct spi_transfer *t, *first;int ret =0 ; -memset (&trans,0 ,sizeof (trans)); - first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list);list_for_each_entry (t, &m->transfers, transfer_list) {
@@ -288,25 +278,21 @@ static int fsl_espi_do_trans(struct spi_message *m,return -EINVAL ; } - trans.speed_hz = t->speed_hz; - trans.bits_per_word = t->bits_per_word; - trans.delay_usecs =max (first->delay_usecs, t->delay_usecs); + trans->speed_hz = t->speed_hz; + trans->bits_per_word = t->bits_per_word; + trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); } - trans.len = espi_trans->len; - trans.tx_buf = espi_trans->tx_buf; - trans.rx_buf = espi_trans->rx_buf; - -fsl_espi_setup_transfer (spi, &trans); +fsl_espi_setup_transfer (spi, trans); -if (trans.len) - ret =fsl_espi_bufs (spi, &trans); +if (trans->len) + ret =fsl_espi_bufs (spi, trans);if (ret) ret = -EMSGSIZE ; -if (trans.delay_usecs) -udelay (trans.delay_usecs); +if (trans->delay_usecs) +udelay (trans->delay_usecs);fsl_espi_setup_transfer (spi,NULL );
@@ -314,23 +300,22 @@ static int fsl_espi_do_trans(struct spi_message *m, }static int fsl_espi_cmd_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +struct spi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -struct fsl_espi_transfer *espi_trans = trans;int ret;fsl_espi_copy_to_buf (m, mspi); - espi_trans->tx_buf = mspi->local_buf; - espi_trans->rx_buf = mspi->local_buf; - ret =fsl_espi_do_trans (m, espi_trans); + trans->tx_buf = mspi->local_buf; + trans->rx_buf = mspi->local_buf; + ret =fsl_espi_do_trans (m, trans);return ret; }static int fsl_espi_rw_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +struct spi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only;
@@ -355,10 +340,9 @@ static int fsl_espi_rw_trans(struct spi_message *m,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { -struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ; -struct fsl_espi_transfer espi_trans; +struct spi_transfer *t, trans = {};int ret;list_for_each_entry (t, &m->transfers, transfer_list) {
@@ -368,14 +352,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, xfer_len += t->len; } - espi_trans.len = xfer_len; + trans.len = xfer_len;if (!rx_buf) - ret =fsl_espi_cmd_trans (m, &espi_trans,NULL ); + ret =fsl_espi_cmd_trans (m, &trans,NULL );else - ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); + ret =fsl_espi_rw_trans (m, &trans, rx_buf); - m->actual_length = ret ?0 : espi_trans.len; + m->actual_length = ret ?0 : trans.len;if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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): 2872c612-a0c4-581f-4880-80bf7f8af9f9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: eliminate struct fsl_espi_transfer" to the spi tree
The patch
spi: fsl-espi: eliminate struct fsl_espi_transfer
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
faceef390702bad8bdf9c93554a3364253d9d943Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:52:06 +0200
Subject: [PATCH] spi: fsl-espi: eliminate struct fsl_espi_transfer
The remaining elements of struct fsl_espi_transfer are part of struct spi_transfer anyway. So we can get rid of struct fsl_espi_transfer and use a struct spi_transfer only.
--- drivers/spi/spi-fsl-espi.c | 56 +++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 36 deletions(-)
drivers/spi/spi-fsl-espi.c +20 -36
@@ -37,12 +37,6 @@ struct fsl_espi_reg {__be32 csmode[4 ];/* 0x020 - 0x02c eSPI cs mode register */ }; -struct fsl_espi_transfer { -const void *tx_buf; -void *rx_buf; -unsigned len; -}; -/* eSPI Controller mode register definitions */ #define SPMODE_ENABLE (1 << 31)#define SPMODE_LOOP (1 << 30)
@@ -267,17 +261,13 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count; } -static int fsl_espi_do_trans (struct spi_message *m, -struct fsl_espi_transfer *tr) +static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master); -struct fsl_espi_transfer *espi_trans = tr; -struct spi_transfer *t, *first, trans; +struct spi_transfer *t, *first;int ret =0 ; -memset (&trans,0 ,sizeof (trans)); - first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list);list_for_each_entry (t, &m->transfers, transfer_list) {
@@ -288,25 +278,21 @@ static int fsl_espi_do_trans(struct spi_message *m,return -EINVAL ; } - trans.speed_hz = t->speed_hz; - trans.bits_per_word = t->bits_per_word; - trans.delay_usecs =max (first->delay_usecs, t->delay_usecs); + trans->speed_hz = t->speed_hz; + trans->bits_per_word = t->bits_per_word; + trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); } - trans.len = espi_trans->len; - trans.tx_buf = espi_trans->tx_buf; - trans.rx_buf = espi_trans->rx_buf; - -fsl_espi_setup_transfer (spi, &trans); +fsl_espi_setup_transfer (spi, trans); -if (trans.len) - ret =fsl_espi_bufs (spi, &trans); +if (trans->len) + ret =fsl_espi_bufs (spi, trans);if (ret) ret = -EMSGSIZE ; -if (trans.delay_usecs) -udelay (trans.delay_usecs); +if (trans->delay_usecs) +udelay (trans->delay_usecs);fsl_espi_setup_transfer (spi,NULL );
@@ -314,23 +300,22 @@ static int fsl_espi_do_trans(struct spi_message *m, }static int fsl_espi_cmd_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +struct spi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -struct fsl_espi_transfer *espi_trans = trans;int ret;fsl_espi_copy_to_buf (m, mspi); - espi_trans->tx_buf = mspi->local_buf; - espi_trans->rx_buf = mspi->local_buf; - ret =fsl_espi_do_trans (m, espi_trans); + trans->tx_buf = mspi->local_buf; + trans->rx_buf = mspi->local_buf; + ret =fsl_espi_do_trans (m, trans);return ret; }static int fsl_espi_rw_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +struct spi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only;
@@ -355,10 +340,9 @@ static int fsl_espi_rw_trans(struct spi_message *m,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { -struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ; -struct fsl_espi_transfer espi_trans; +struct spi_transfer *t, trans = {};int ret;list_for_each_entry (t, &m->transfers, transfer_list) {
@@ -368,14 +352,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, xfer_len += t->len; } - espi_trans.len = xfer_len; + trans.len = xfer_len;if (!rx_buf) - ret =fsl_espi_cmd_trans (m, &espi_trans,NULL ); + ret =fsl_espi_cmd_trans (m, &trans,NULL );else - ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); + ret =fsl_espi_rw_trans (m, &trans, rx_buf); - m->actual_length = ret ?0 : espi_trans.len; + m->actual_length = ret ?0 : trans.len;if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 6 lines
2.8.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
PATCH v2 15/23 spi: fsl-espi: merge fsl_espi_cmd_trans and fsl_espi_rw_trans
In reply to a message not in the archivefsl_espi_cmd_trans and fsl_espi_rw_trans share most of the code so we can merge them.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-)
drivers/spi/spi-fsl-espi.c +6 -27
@@ -299,23 +299,8 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)return ret; } -static int fsl_espi_cmd_trans (struct spi_message *m, -struct spi_transfer *trans,u8 *rx_buff) -{ -struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -int ret; - -fsl_espi_copy_to_buf (m, mspi); - - trans->tx_buf = mspi->local_buf; - trans->rx_buf = mspi->local_buf; - ret =fsl_espi_do_trans (m, trans); - -return ret; -} - -static int fsl_espi_rw_trans (struct spi_message *m, -struct spi_transfer *trans,u8 *rx_buff) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans, +u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only;
@@ -327,12 +312,9 @@ static int fsl_espi_rw_trans(struct spi_message *m, trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, trans); -if (!ret) { -/* If there is at least one RX byte then copy it to rx_buff */ -if (trans->len > tx_only) -memcpy (rx_buff, trans->rx_buf + tx_only, - trans->len - tx_only); - } +/* If there is at least one RX byte then copy it to rx_buff */ +if (!ret && rx_buff && trans->len > tx_only) +memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only);return ret; }
@@ -354,10 +336,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.len = xfer_len; -if (!rx_buf) - ret =fsl_espi_cmd_trans (m, &trans,NULL ); -else - ret =fsl_espi_rw_trans (m, &trans, rx_buf); + ret =fsl_espi_trans (m, &trans, rx_buf); m->actual_length = ret ?0 : trans.len;
Signature · 7 lines
2.9.2 -- 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): 5cf9843f-11c0-4a14-d7ec-66522592ece9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: merge fsl_espi_cmd_trans and fsl_espi_rw_trans" to the spi tree
The patch
spi: fsl-espi: merge fsl_espi_cmd_trans and fsl_espi_rw_trans
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
809b1e017bbdaf40d35619e41c1dbc542a5449d2Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:52:25 +0200
Subject: [PATCH] spi: fsl-espi: merge fsl_espi_cmd_trans and fsl_espi_rw_trans
fsl_espi_cmd_trans and fsl_espi_rw_trans share most of the code so we can merge them.
--- drivers/spi/spi-fsl-espi.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-)
drivers/spi/spi-fsl-espi.c +6 -27
@@ -299,23 +299,8 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)return ret; } -static int fsl_espi_cmd_trans (struct spi_message *m, -struct spi_transfer *trans,u8 *rx_buff) -{ -struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -int ret; - -fsl_espi_copy_to_buf (m, mspi); - - trans->tx_buf = mspi->local_buf; - trans->rx_buf = mspi->local_buf; - ret =fsl_espi_do_trans (m, trans); - -return ret; -} - -static int fsl_espi_rw_trans (struct spi_message *m, -struct spi_transfer *trans,u8 *rx_buff) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans, +u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only;
@@ -327,12 +312,9 @@ static int fsl_espi_rw_trans(struct spi_message *m, trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, trans); -if (!ret) { -/* If there is at least one RX byte then copy it to rx_buff */ -if (trans->len > tx_only) -memcpy (rx_buff, trans->rx_buf + tx_only, - trans->len - tx_only); - } +/* If there is at least one RX byte then copy it to rx_buff */ +if (!ret && rx_buff && trans->len > tx_only) +memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only);return ret; }
@@ -354,10 +336,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.len = xfer_len; -if (!rx_buf) - ret =fsl_espi_cmd_trans (m, &trans,NULL ); -else - ret =fsl_espi_rw_trans (m, &trans, rx_buf); + ret =fsl_espi_trans (m, &trans, rx_buf); m->actual_length = ret ?0 : trans.len;
Signature · 6 lines
2.8.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
PATCH v2 16/23 spi: fsl-espi: improve return value handling in fsl_espi_bufs
In reply to a message not in the archiveReturn a proper status code from fsl_espi_bufs instead of returning the number of remaining words and let the caller evaluate it.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -4
@@ -258,7 +258,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)/* disable rx ints */ mpc8xxx_spi_write_reg (®_base->mask,0 ); -return mpc8xxx_spi->count; +return mpc8xxx_spi->count >0 ? -EMSGSIZE :0 ; }static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans)
@@ -288,9 +288,6 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)if (trans->len) ret =fsl_espi_bufs (spi, trans); -if (ret) - ret = -EMSGSIZE ; -if (trans->delay_usecs)udelay (trans->delay_usecs);
Signature · 7 lines
2.9.2 -- 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
PATCH v2 17/23 spi: fsl-espi: merge fsl_espi_bufs and fsl_espi_cpu_bufs
In reply to a message not in the archivefsl_espi_bufs and fsl_espi_cpu_bufs are very small that we can merge them.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/spi/spi-fsl-espi.c +8 -19
@@ -206,31 +206,15 @@ static void fsl_espi_setup_transfer(struct spi_device *spi,fsl_espi_change_mode (spi); } -static void fsl_espi_cpu_bufs (struct mpc8xxx_spi *mspi,struct spi_transfer *t, -unsigned int len) -{ -u32 word; -struct fsl_espi_reg *reg_base = mspi->reg_base; - - mspi->count = len; - -/* enable rx ints */ -mpc8xxx_spi_write_reg (®_base->mask,SPIM_NE ); - -/* transmit word */ - word = mspi->get_tx (mspi); -mpc8xxx_spi_write_reg (®_base->transmit, word); -} -static int fsl_espi_bufs (struct spi_device *spi,struct spi_transfer *t) {struct mpc8xxx_spi *mpc8xxx_spi =spi_master_get_devdata (spi->master);struct fsl_espi_reg *reg_base = mpc8xxx_spi->reg_base; -unsigned int len = t->len; +u32 word;int ret; mpc8xxx_spi->len = t->len; - len =roundup (len,4 ) /4 ; + mpc8xxx_spi->count =roundup (t->len,4 ) /4 ; mpc8xxx_spi->tx = t->tx_buf; mpc8xxx_spi->rx = t->rx_buf;
@@ -246,7 +230,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 ))); -fsl_espi_cpu_bufs (mpc8xxx_spi, t, len); +/* enable rx ints */ +mpc8xxx_spi_write_reg (®_base->mask,SPIM_NE ); + +/* transmit word */ + word = mpc8xxx_spi->get_tx (mpc8xxx_spi); +mpc8xxx_spi_write_reg (®_base->transmit, word);/* Won't hang up forever, SPI bus sometimes got lost interrupts... */ ret =wait_for_completion_timeout (&mpc8xxx_spi->done,2 *HZ );
Signature · 7 lines
2.9.2 -- 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
PATCH v2 18/23 spi: fsl-espi: improve the ISR frame
In reply to a message not in the archiveImprove the ISR frame:
- move resetting the event bits to the ISR frame
- change type of parameter irq to int
- make sure that the event bits match at least one bit in the interrupt mask register
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/spi/spi-fsl-espi.c +10 -13
@@ -451,17 +451,11 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) ®_base->event)) & SPIE_NF), 1000, 0);if (!ret) {dev_err (mspi->dev,"tired waiting for SPIE_NF\n" ); - -/* Clear the SPIE bits */ -mpc8xxx_spi_write_reg (®_base->event, events);complete (&mspi->done);return ; } } -/* Clear the events */ -mpc8xxx_spi_write_reg (®_base->event, events); - mspi->count -=1 ;if (mspi->count) {u32 word = mspi->get_tx (mspi);
@@ -472,23 +466,26 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) } } -static irqreturn_t fsl_espi_irq (s32 irq,void *context_data) +static irqreturn_t fsl_espi_irq (int irq,void *context_data) {struct mpc8xxx_spi *mspi = context_data;struct fsl_espi_reg *reg_base = mspi->reg_base; -irqreturn_t ret =IRQ_NONE ; -u32 events; +u32 mask, events; -/* Get interrupt events(tx/rx) */ +/* Get interrupt mask and events and check that irq belongs to us */ + mask =mpc8xxx_spi_read_reg (®_base->mask); events =mpc8xxx_spi_read_reg (®_base->event); -if (events) - ret =IRQ_HANDLED ; +if (!(mask & events)) +return IRQ_NONE ;dev_vdbg (mspi->dev,"%s: events %x\n" , __func__, events);fsl_espi_cpu_irq (mspi, events); -return ret; +/* Clear the events */ +mpc8xxx_spi_write_reg (®_base->event, events); + +return IRQ_HANDLED ; }#ifdef CONFIG_PM
Signature · 7 lines
2.9.2 -- 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
PATCH v2 19/23 spi: fsl-espi: factor out initial message checking
In reply to a message not in the archiveChecking the message is currently done at diffrent places in the driver. Factor it out to fsl_espi_check_message.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-)
drivers/spi/spi-fsl-espi.c +29 -14
@@ -98,6 +98,30 @@ static unsigned int fsl_espi_copy_to_buf(struct spi_message *m,return tx_only; } +static int fsl_espi_check_message (struct spi_message *m) +{ +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); +struct spi_transfer *t, *first; + +if (m->frame_length >SPCOM_TRANLEN_MAX ) { +dev_err (mspi->dev,"message too long, size is %u bytes\n" , + m->frame_length); +return -EMSGSIZE ; + } + + first = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); +list_for_each_entry (t, &m->transfers, transfer_list) { +if (first->bits_per_word != t->bits_per_word || + first->speed_hz != t->speed_hz) { +dev_err (mspi->dev,"bits_per_word/speed_hz should be the same for all transfers\n" ); +return -EINVAL ; + } + } + +return 0 ; +} +static void fsl_espi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -222,11 +246,6 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)reinit_completion (&mpc8xxx_spi->done);/* Set SPCOM[CS] and SPCOM[TRANLEN] field */ -if (t->len >SPCOM_TRANLEN_MAX ) { -dev_err (mpc8xxx_spi->dev,"Transaction length (%d)" -" beyond the SPCOM[TRANLEN] field\n" , t->len); -return -EINVAL ; - }mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 )));
@@ -253,20 +272,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi; -struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct spi_transfer *t, *first;int ret =0 ; first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list);list_for_each_entry (t, &m->transfers, transfer_list) { -if ((first->bits_per_word != t->bits_per_word) || - (first->speed_hz != t->speed_hz)) { -dev_err (mspi->dev, -"bits_per_word/speed_hz should be same for the same SPI transfer\n" ); -return -EINVAL ; - } - trans->speed_hz = t->speed_hz; trans->bits_per_word = t->bits_per_word; trans->delay_usecs =max (first->delay_usecs, t->delay_usecs);
@@ -313,6 +324,10 @@ static int fsl_espi_do_one_msg(struct spi_master *master,struct spi_transfer *t, trans = {};int ret; + ret =fsl_espi_check_message (m); +if (ret) + goto out; +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
@@ -325,7 +340,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ret =fsl_espi_trans (m, &trans, rx_buf); m->actual_length = ret ?0 : trans.len; - +out:if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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
PATCH v2 20/23 spi: fsl-espi: centralize populating struct spi_transfer
In reply to a message not in the archiveBetter structure the code by population all elements of struct spi_transfer in one place.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/spi/spi-fsl-espi.c +12 -12
@@ -272,17 +272,8 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi; -struct spi_transfer *t, *first;int ret =0 ; - first = list_first_entry(&m->transfers, struct spi_transfer, - transfer_list); -list_for_each_entry (t, &m->transfers, transfer_list) { - trans->speed_hz = t->speed_hz; - trans->bits_per_word = t->bits_per_word; - trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); - } -fsl_espi_setup_transfer (spi, trans);if (trans->len)
@@ -305,8 +296,6 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans, tx_only =fsl_espi_copy_to_buf (m, mspi); - trans->tx_buf = mspi->local_buf; - trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, trans);/* If there is at least one RX byte then copy it to rx_buff */
@@ -319,8 +308,9 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);u8 *rx_buf =NULL ; -unsigned int xfer_len =0 ; +unsigned int delay_usecs =0 , xfer_len =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -333,9 +323,19 @@ static int fsl_espi_do_one_msg(struct spi_master *master, rx_buf = t->rx_buf;if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len; +if (t->delay_usecs > delay_usecs) + delay_usecs = t->delay_usecs; } + t = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); + trans.len = xfer_len; + trans.speed_hz = t->speed_hz; + trans.bits_per_word = t->bits_per_word; + trans.delay_usecs = delay_usecs; + trans.tx_buf = mspi->local_buf; + trans.rx_buf = mspi->local_buf; ret =fsl_espi_trans (m, &trans, rx_buf);
Signature · 7 lines
2.9.2 -- 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): fc3ba27b-b7e1-a093-23d2-82956b8476c5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: centralize populating struct spi_transfer" to the spi tree
The patch
spi: fsl-espi: centralize populating struct spi_transfer
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
96361fafbbfc8a07b4c7ec09d96d742ef68bfbadMon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:54:00 +0200
Subject: [PATCH] spi: fsl-espi: centralize populating struct spi_transfer
Better structure the code by population all elements of struct spi_transfer in one place.
--- drivers/spi/spi-fsl-espi.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/spi/spi-fsl-espi.c +12 -12
@@ -272,17 +272,8 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi; -struct spi_transfer *t, *first;int ret =0 ; - first = list_first_entry(&m->transfers, struct spi_transfer, - transfer_list); -list_for_each_entry (t, &m->transfers, transfer_list) { - trans->speed_hz = t->speed_hz; - trans->bits_per_word = t->bits_per_word; - trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); - } -fsl_espi_setup_transfer (spi, trans);if (trans->len)
@@ -305,8 +296,6 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans, tx_only =fsl_espi_copy_to_buf (m, mspi); - trans->tx_buf = mspi->local_buf; - trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, trans);/* If there is at least one RX byte then copy it to rx_buff */
@@ -319,8 +308,9 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);u8 *rx_buf =NULL ; -unsigned int xfer_len =0 ; +unsigned int delay_usecs =0 , xfer_len =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -333,9 +323,19 @@ static int fsl_espi_do_one_msg(struct spi_master *master, rx_buf = t->rx_buf;if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len; +if (t->delay_usecs > delay_usecs) + delay_usecs = t->delay_usecs; } + t = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); + trans.len = xfer_len; + trans.speed_hz = t->speed_hz; + trans.bits_per_word = t->bits_per_word; + trans.delay_usecs = delay_usecs; + trans.tx_buf = mspi->local_buf; + trans.rx_buf = mspi->local_buf; ret =fsl_espi_trans (m, &trans, rx_buf);
Signature · 6 lines
2.8.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
PATCH v2 21/23 spi: fsl-espi: factor out handling of read data
In reply to a message not in the archiveFactor out copying read data to the read buffers in the original message to a new function fsl_espi_copy_from_buf.
This also allows to simplify fsl_espi_copy_to_buf.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-)
drivers/spi/spi-fsl-espi.c +21 -20
@@ -77,25 +77,32 @@ struct fsl_espi_reg {#define AUTOSUSPEND_TIMEOUT 2000 -static unsigned int fsl_espi_copy_to_buf (struct spi_message *m, -struct mpc8xxx_spi *mspi) +static void fsl_espi_copy_to_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) { -unsigned int tx_only =0 ;struct spi_transfer *t;u8 *buf = mspi->local_buf;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { +if (t->tx_buf)memcpy (buf, t->tx_buf, t->len); -if (!t->rx_buf) - tx_only += t->len; - }else { +else memset (buf,0 , t->len); - } buf += t->len; } +} + +static void fsl_espi_copy_from_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) +{ +struct spi_transfer *t; +u8 *buf = mspi->local_buf; -return tx_only; +list_for_each_entry (t, &m->transfers, transfer_list) { +if (t->rx_buf) +memcpy (t->rx_buf, buf, t->len); + buf += t->len; + } }static int fsl_espi_check_message (struct spi_message *m)
@@ -287,20 +294,17 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)return ret; } -static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans, -u8 *rx_buff) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -unsigned int tx_only;int ret; - tx_only =fsl_espi_copy_to_buf (m, mspi); +fsl_espi_copy_to_buf (m, mspi); ret =fsl_espi_do_trans (m, trans); -/* If there is at least one RX byte then copy it to rx_buff */ -if (!ret && rx_buff && trans->len > tx_only) -memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); +if (!ret) +fsl_espi_copy_from_buf (m, mspi);return ret; }
@@ -309,7 +313,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -u8 *rx_buf =NULL ;unsigned int delay_usecs =0 , xfer_len =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -319,8 +322,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->rx_buf) - rx_buf = t->rx_buf;if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len;if (t->delay_usecs > delay_usecs)
@@ -337,7 +338,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.tx_buf = mspi->local_buf; trans.rx_buf = mspi->local_buf; - ret =fsl_espi_trans (m, &trans, rx_buf); + ret =fsl_espi_trans (m, &trans); m->actual_length = ret ?0 : trans.len; out:
Signature · 7 lines
2.9.2 -- 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): 23b15e58-4833-7180-5c5d-81af382c54c0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: factor out handling of read data" to the spi tree
The patch
spi: fsl-espi: factor out handling of read data
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
cce7e3a2fe39a5b66162a3dc1463a1af598d0803Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:54:18 +0200
Subject: [PATCH] spi: fsl-espi: factor out handling of read data
Factor out copying read data to the read buffers in the original message to a new function fsl_espi_copy_from_buf.
This also allows to simplify fsl_espi_copy_to_buf.
--- drivers/spi/spi-fsl-espi.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-)
drivers/spi/spi-fsl-espi.c +21 -20
@@ -77,25 +77,32 @@ struct fsl_espi_reg {#define AUTOSUSPEND_TIMEOUT 2000 -static unsigned int fsl_espi_copy_to_buf (struct spi_message *m, -struct mpc8xxx_spi *mspi) +static void fsl_espi_copy_to_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) { -unsigned int tx_only =0 ;struct spi_transfer *t;u8 *buf = mspi->local_buf;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { +if (t->tx_buf)memcpy (buf, t->tx_buf, t->len); -if (!t->rx_buf) - tx_only += t->len; - }else { +else memset (buf,0 , t->len); - } buf += t->len; } +} + +static void fsl_espi_copy_from_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) +{ +struct spi_transfer *t; +u8 *buf = mspi->local_buf; -return tx_only; +list_for_each_entry (t, &m->transfers, transfer_list) { +if (t->rx_buf) +memcpy (t->rx_buf, buf, t->len); + buf += t->len; + } }static int fsl_espi_check_message (struct spi_message *m)
@@ -287,20 +294,17 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)return ret; } -static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans, -u8 *rx_buff) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -unsigned int tx_only;int ret; - tx_only =fsl_espi_copy_to_buf (m, mspi); +fsl_espi_copy_to_buf (m, mspi); ret =fsl_espi_do_trans (m, trans); -/* If there is at least one RX byte then copy it to rx_buff */ -if (!ret && rx_buff && trans->len > tx_only) -memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); +if (!ret) +fsl_espi_copy_from_buf (m, mspi);return ret; }
@@ -309,7 +313,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -u8 *rx_buf =NULL ;unsigned int delay_usecs =0 , xfer_len =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -319,8 +322,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->rx_buf) - rx_buf = t->rx_buf;if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len;if (t->delay_usecs > delay_usecs)
@@ -337,7 +338,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.tx_buf = mspi->local_buf; trans.rx_buf = mspi->local_buf; - ret =fsl_espi_trans (m, &trans, rx_buf); + ret =fsl_espi_trans (m, &trans); m->actual_length = ret ?0 : trans.len; out:
Signature · 6 lines
2.8.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
PATCH v2 22/23 spi: fsl-espi: improve message length handling
In reply to a message not in the archiveMove checking for a zero-length message up in the call chain and use m->frame_length instead of re-calculating the overall length of all transfers in the message.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/spi/spi-fsl-espi.c +5 -7
@@ -283,8 +283,7 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)fsl_espi_setup_transfer (spi, trans); -if (trans->len) - ret =fsl_espi_bufs (spi, trans); + ret =fsl_espi_bufs (spi, trans);if (trans->delay_usecs)udelay (trans->delay_usecs);
@@ -313,7 +312,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -unsigned int delay_usecs =0 , xfer_len =0 ; +unsigned int delay_usecs =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -322,8 +321,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out;list_for_each_entry (t, &m->transfers, transfer_list) { -if ((t->tx_buf) || (t->rx_buf)) - xfer_len += t->len;if (t->delay_usecs > delay_usecs) delay_usecs = t->delay_usecs; }
@@ -331,14 +328,15 @@ static int fsl_espi_do_one_msg(struct spi_master *master, t = list_first_entry(&m->transfers, struct spi_transfer, transfer_list); - trans.len = xfer_len; + trans.len = m->frame_length; trans.speed_hz = t->speed_hz; trans.bits_per_word = t->bits_per_word; trans.delay_usecs = delay_usecs; trans.tx_buf = mspi->local_buf; trans.rx_buf = mspi->local_buf; - ret =fsl_espi_trans (m, &trans); +if (trans.len) + ret =fsl_espi_trans (m, &trans); m->actual_length = ret ?0 : trans.len; out:
Signature · 7 lines
2.9.2 -- 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): aac7ea51-62ea-69b9-a149-2209e0766905-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: improve message length handling" to the spi tree
The patch
spi: fsl-espi: improve message length handling
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
06af115d6c6d8b3d7b6cbc8a46f0603e70b1be58Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:54:35 +0200
Subject: [PATCH] spi: fsl-espi: improve message length handling
Move checking for a zero-length message up in the call chain and use m->frame_length instead of re-calculating the overall length of all transfers in the message.
--- drivers/spi/spi-fsl-espi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/spi/spi-fsl-espi.c +5 -7
@@ -283,8 +283,7 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)fsl_espi_setup_transfer (spi, trans); -if (trans->len) - ret =fsl_espi_bufs (spi, trans); + ret =fsl_espi_bufs (spi, trans);if (trans->delay_usecs)udelay (trans->delay_usecs);
@@ -313,7 +312,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -unsigned int delay_usecs =0 , xfer_len =0 ; +unsigned int delay_usecs =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -322,8 +321,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out;list_for_each_entry (t, &m->transfers, transfer_list) { -if ((t->tx_buf) || (t->rx_buf)) - xfer_len += t->len;if (t->delay_usecs > delay_usecs) delay_usecs = t->delay_usecs; }
@@ -331,14 +328,15 @@ static int fsl_espi_do_one_msg(struct spi_master *master, t = list_first_entry(&m->transfers, struct spi_transfer, transfer_list); - trans.len = xfer_len; + trans.len = m->frame_length; trans.speed_hz = t->speed_hz; trans.bits_per_word = t->bits_per_word; trans.delay_usecs = delay_usecs; trans.tx_buf = mspi->local_buf; trans.rx_buf = mspi->local_buf; - ret =fsl_espi_trans (m, &trans); +if (trans.len) + ret =fsl_espi_trans (m, &trans); m->actual_length = ret ?0 : trans.len; out:
Signature · 6 lines
2.8.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
PATCH v2 23/23 spi: fsl-espi: merge fsl_espi_trans and fsl_espi_do_trans
In reply to a message not in the archiveMerge both functions to reduce source code size and improve readability.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/spi/spi-fsl-espi.c +4 -14
@@ -276,11 +276,13 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count >0 ? -EMSGSIZE :0 ; } -static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_device *spi = m->spi; -int ret =0 ; +int ret; +fsl_espi_copy_to_buf (m, mspi);fsl_espi_setup_transfer (spi, trans); ret =fsl_espi_bufs (spi, trans);
@@ -290,18 +292,6 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)fsl_espi_setup_transfer (spi,NULL ); -return ret; -} - -static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) -{ -struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -int ret; - -fsl_espi_copy_to_buf (m, mspi); - - ret =fsl_espi_do_trans (m, trans); -if (!ret)fsl_espi_copy_from_buf (m, mspi);
Signature · 7 lines
2.9.2 -- 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
PATCH v2 1/18 spi: fsl-espi: remove unused elements n_rx and n_tx in struct fsl_espi_transfer
In reply to a message not in the archiveBoth elements are not used, so remove them.
---
v2:
- switch order of patches to do the trivial changes first
--- drivers/spi/spi-fsl-espi.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -11
@@ -41,8 +41,6 @@ struct fsl_espi_transfer {const void *tx_buf;void *rx_buf;unsigned len; -unsigned n_tx; -unsigned n_rx;unsigned actual_length;int status; };
@@ -371,24 +369,16 @@ static int fsl_espi_do_one_msg(struct spi_master *master, {struct spi_transfer *t;u8 *rx_buf =NULL ; -unsigned int n_tx =0 ; -unsigned int n_rx =0 ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) - n_tx += t->len; -if (t->rx_buf) { - n_rx += t->len; +if (t->rx_buf) rx_buf = t->rx_buf; - }if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len; } - espi_trans.n_tx = n_tx; - espi_trans.n_rx = n_rx; espi_trans.len = xfer_len; espi_trans.actual_length =0 ; espi_trans.status =0 ;
Signature · 7 lines
2.9.2 -- 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
PATCH v2 2/18 spi: fsl-espi: simplify fsl_espi_setup_transfer
In reply to a message not in the archiveSimplify fsl_espi_setup_transfer a little.
---
v2:
- changed order of patches to do trivial changes first
--- drivers/spi/spi-fsl-espi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -3
@@ -187,12 +187,10 @@ static void fsl_espi_setup_transfer(struct spi_device *spi, mpc8xxx_spi->get_rx = cs->get_rx; mpc8xxx_spi->get_tx = cs->get_tx; - bits_per_word = bits_per_word -1 ; -/* mask out bits we are going to set */ cs->hw_mode &= ~(CSMODE_LEN (0xF ) |CSMODE_DIV16 |CSMODE_PM (0xF )); - cs->hw_mode |=CSMODE_LEN (bits_per_word); + cs->hw_mode |=CSMODE_LEN (bits_per_word -1 );if ((mpc8xxx_spi->spibrg / hz) >64 ) { cs->hw_mode |=CSMODE_DIV16 ;
Signature · 7 lines
2.9.2 -- 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
PATCH v2 3/18 spi: fsl-espi: remove unneeded check in fsl_espi_do_trans
In reply to a message not in the archiveSPI core takes care that both values are always populated.
---
v2:
- switch order of patches to do trivial changes first
--- drivers/spi/spi-fsl-espi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -2
@@ -300,8 +300,7 @@ static void fsl_espi_do_trans(struct spi_message *m, trans.tx_buf = espi_trans->tx_buf; trans.rx_buf = espi_trans->rx_buf; -if (trans.bits_per_word || trans.speed_hz) -fsl_espi_setup_transfer (spi, &trans); +fsl_espi_setup_transfer (spi, &trans);if (trans.len) status =fsl_espi_bufs (spi, &trans);
Signature · 7 lines
2.9.2 -- 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
PATCH v2 5/18 spi: fsl-espi: factor out filling the local buffer
In reply to a message not in the archiveBetter structure the code by factoring out filling the local buffer.
In addition don't initialize the complete local buffer at the beginning of fsl_espi_do_one_msg. Instead move initialization of those parts of the local buffer to be used for transfers w/o tx_buf to fsl_espi_copy_to_buf.
---
v2:
- fixed coding style issue
- improved commit message
--- drivers/spi/spi-fsl-espi.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
drivers/spi/spi-fsl-espi.c +24 -22
@@ -85,6 +85,27 @@ struct fsl_espi_transfer {#define AUTOSUSPEND_TIMEOUT 2000 +static unsigned int fsl_espi_copy_to_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) +{ +unsigned int tx_only =0 ; +struct spi_transfer *t; +u8 *buf = mspi->local_buf; + +list_for_each_entry (t, &m->transfers, transfer_list) { +if (t->tx_buf) { +memcpy (buf, t->tx_buf, t->len); +if (!t->rx_buf) + tx_only += t->len; + }else { +memset (buf,0 , t->len); + } + buf += t->len; + } + +return tx_only; +} +static void fsl_espi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -301,16 +322,9 @@ static void fsl_espi_cmd_trans(struct spi_message *m, struct fsl_espi_transfer *trans, u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); -struct spi_transfer *t; -int i =0 ;struct fsl_espi_transfer *espi_trans = trans; -list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { -memcpy (mspi->local_buf + i, t->tx_buf, t->len); - i += t->len; - } - } +fsl_espi_copy_to_buf (m, mspi); espi_trans->tx_buf = mspi->local_buf; espi_trans->rx_buf = mspi->local_buf;
@@ -323,18 +337,9 @@ static void fsl_espi_rw_trans(struct spi_message *m, struct fsl_espi_transfer *trans, u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); -struct spi_transfer *t; -unsigned int tx_only =0 ; -int i =0 ; +unsigned int tx_only; -list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { -memcpy (mspi->local_buf + i, t->tx_buf, t->len); - i += t->len; -if (!t->rx_buf) - tx_only += t->len; - } - } + tx_only =fsl_espi_copy_to_buf (m, mspi); trans->tx_buf = mspi->local_buf; trans->rx_buf = mspi->local_buf;
@@ -352,14 +357,11 @@ static void fsl_espi_rw_trans(struct spi_message *m,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { -struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; -memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
Signature · 7 lines
2.9.2 -- 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
PATCH v2 6/18 spi: fsl-espi: remove element status from struct fsl_espi_transfer
In reply to a message not in the archiveUse the return values of the functions in the call chain to transport status information instead of using an element in struct fsl_espi_transfer for this.
This is more in line with the general approach how to handle status information and is one step further to eventually get rid of struct fsl_espi_transfer completely.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 47 +++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-)
drivers/spi/spi-fsl-espi.c +26 -21
@@ -42,7 +42,6 @@ struct fsl_espi_transfer {void *rx_buf;unsigned len;unsigned actual_length; -int status; };/* eSPI Controller mode register definitions */
@@ -269,14 +268,14 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count; } -static void fsl_espi_do_trans (struct spi_message *m, -struct fsl_espi_transfer *tr) +static int fsl_espi_do_trans (struct spi_message *m, +struct fsl_espi_transfer *tr) {struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct fsl_espi_transfer *espi_trans = tr;struct spi_transfer *t, *first, trans; -int status =0 ; +int ret =0 ;memset (&trans,0 ,sizeof (trans));
@@ -285,10 +284,9 @@ static void fsl_espi_do_trans(struct spi_message *m,list_for_each_entry (t, &m->transfers, transfer_list) {if ((first->bits_per_word != t->bits_per_word) || (first->speed_hz != t->speed_hz)) { - espi_trans->status = -EINVAL ;dev_err (mspi->dev,"bits_per_word/speed_hz should be same for the same SPI transfer\n" ); -return ; +return -EINVAL ; } trans.speed_hz = t->speed_hz;
@@ -303,52 +301,59 @@ static void fsl_espi_do_trans(struct spi_message *m,fsl_espi_setup_transfer (spi, &trans);if (trans.len) - status =fsl_espi_bufs (spi, &trans); + ret =fsl_espi_bufs (spi, &trans); -if (status) - status = -EMSGSIZE ; +if (ret) + ret = -EMSGSIZE ;if (trans.delay_usecs)udelay (trans.delay_usecs); - espi_trans->status = status;fsl_espi_setup_transfer (spi,NULL ); + +return ret; } -static void fsl_espi_cmd_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +static int fsl_espi_cmd_trans (struct spi_message *m, +struct fsl_espi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct fsl_espi_transfer *espi_trans = trans; +int ret;fsl_espi_copy_to_buf (m, mspi); espi_trans->tx_buf = mspi->local_buf; espi_trans->rx_buf = mspi->local_buf; -fsl_espi_do_trans (m, espi_trans); + ret =fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; + +return ret; } -static void fsl_espi_rw_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +static int fsl_espi_rw_trans (struct spi_message *m, +struct fsl_espi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only; +int ret; tx_only =fsl_espi_copy_to_buf (m, mspi); trans->tx_buf = mspi->local_buf; trans->rx_buf = mspi->local_buf; -fsl_espi_do_trans (m, trans); + ret =fsl_espi_do_trans (m, trans); -if (!trans->status) { +if (!ret) {/* If there is at least one RX byte then copy it to rx_buff */ if (trans->len > tx_only)memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); trans->actual_length += trans->len; } + +return ret; } static int fsl_espi_do_one_msg(struct spi_master *master,
@@ -358,6 +363,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master,u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +int ret;list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf)
@@ -368,15 +374,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, espi_trans.len = xfer_len; espi_trans.actual_length =0 ; - espi_trans.status =0 ;if (!rx_buf) -fsl_espi_cmd_trans (m, &espi_trans,NULL ); + ret =fsl_espi_cmd_trans (m, &espi_trans,NULL );else -fsl_espi_rw_trans (m, &espi_trans, rx_buf); + ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); m->actual_length = espi_trans.actual_length; - m->status = espi_trans.status; + m->status = ret;spi_finalize_current_message (master);return 0 ; }
Signature · 7 lines
2.9.2 -- 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
PATCH v2 7/18 spi: fsl-espi: fix status handling in fsl_espi_do_one_msg
In reply to a message not in the archiveIf an error occurred during message handling return this error instead of always returning 0 and align the code with the generic implementation in spi_transfer_one_message.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/spi/spi-fsl-espi.c +5 -2
@@ -381,9 +381,12 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); m->actual_length = espi_trans.actual_length; - m->status = ret; +if (m->status == -EINPROGRESS ) + m->status = ret; +spi_finalize_current_message (master); -return 0 ; + +return ret; }static int fsl_espi_setup (struct spi_device *spi)
Signature · 7 lines
2.9.2 -- 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
PATCH v2 8/18 spi: fsl-espi: remove element actual_length from struct fsl_espi_trans
In reply to a message not in the archiveIf an error occurs during processing the message, then we don't have to populate the actual_length element of struct message. So we can get rid of element actual_length in struct fsl_espi_transfer.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-espi.c +2 -6
@@ -41,7 +41,6 @@ struct fsl_espi_transfer {const void *tx_buf;void *rx_buf;unsigned len; -unsigned actual_length; };/* eSPI Controller mode register definitions */
@@ -327,8 +326,6 @@ static int fsl_espi_cmd_trans(struct spi_message *m, espi_trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, espi_trans); - espi_trans->actual_length = espi_trans->len; -return ret; }
@@ -350,7 +347,6 @@ static int fsl_espi_rw_trans(struct spi_message *m,if (trans->len > tx_only)memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); - trans->actual_length += trans->len; }return ret;
@@ -373,14 +369,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, } espi_trans.len = xfer_len; - espi_trans.actual_length =0 ;if (!rx_buf) ret =fsl_espi_cmd_trans (m, &espi_trans,NULL );else ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); - m->actual_length = espi_trans.actual_length; + m->actual_length = ret ?0 : espi_trans.len; +if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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
PATCH v2 9/18 spi: fsl-espi: eliminate struct fsl_espi_transfer
In reply to a message not in the archiveThe remaining elements of struct fsl_espi_transfer are part of struct spi_transfer anyway. So we can get rid of struct fsl_espi_transfer and use a struct spi_transfer only.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 56 +++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 36 deletions(-)
drivers/spi/spi-fsl-espi.c +20 -36
@@ -37,12 +37,6 @@ struct fsl_espi_reg {__be32 csmode[4 ];/* 0x020 - 0x02c eSPI cs mode register */ }; -struct fsl_espi_transfer { -const void *tx_buf; -void *rx_buf; -unsigned len; -}; -/* eSPI Controller mode register definitions */ #define SPMODE_ENABLE (1 << 31)#define SPMODE_LOOP (1 << 30)
@@ -267,17 +261,13 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count; } -static int fsl_espi_do_trans (struct spi_message *m, -struct fsl_espi_transfer *tr) +static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master); -struct fsl_espi_transfer *espi_trans = tr; -struct spi_transfer *t, *first, trans; +struct spi_transfer *t, *first;int ret =0 ; -memset (&trans,0 ,sizeof (trans)); - first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list);list_for_each_entry (t, &m->transfers, transfer_list) {
@@ -288,25 +278,21 @@ static int fsl_espi_do_trans(struct spi_message *m,return -EINVAL ; } - trans.speed_hz = t->speed_hz; - trans.bits_per_word = t->bits_per_word; - trans.delay_usecs =max (first->delay_usecs, t->delay_usecs); + trans->speed_hz = t->speed_hz; + trans->bits_per_word = t->bits_per_word; + trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); } - trans.len = espi_trans->len; - trans.tx_buf = espi_trans->tx_buf; - trans.rx_buf = espi_trans->rx_buf; - -fsl_espi_setup_transfer (spi, &trans); +fsl_espi_setup_transfer (spi, trans); -if (trans.len) - ret =fsl_espi_bufs (spi, &trans); +if (trans->len) + ret =fsl_espi_bufs (spi, trans);if (ret) ret = -EMSGSIZE ; -if (trans.delay_usecs) -udelay (trans.delay_usecs); +if (trans->delay_usecs) +udelay (trans->delay_usecs);fsl_espi_setup_transfer (spi,NULL );
@@ -314,23 +300,22 @@ static int fsl_espi_do_trans(struct spi_message *m, }static int fsl_espi_cmd_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +struct spi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -struct fsl_espi_transfer *espi_trans = trans;int ret;fsl_espi_copy_to_buf (m, mspi); - espi_trans->tx_buf = mspi->local_buf; - espi_trans->rx_buf = mspi->local_buf; - ret =fsl_espi_do_trans (m, espi_trans); + trans->tx_buf = mspi->local_buf; + trans->rx_buf = mspi->local_buf; + ret =fsl_espi_do_trans (m, trans);return ret; }static int fsl_espi_rw_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +struct spi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only;
@@ -355,10 +340,9 @@ static int fsl_espi_rw_trans(struct spi_message *m,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { -struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ; -struct fsl_espi_transfer espi_trans; +struct spi_transfer *t, trans = {};int ret;list_for_each_entry (t, &m->transfers, transfer_list) {
@@ -368,14 +352,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, xfer_len += t->len; } - espi_trans.len = xfer_len; + trans.len = xfer_len;if (!rx_buf) - ret =fsl_espi_cmd_trans (m, &espi_trans,NULL ); + ret =fsl_espi_cmd_trans (m, &trans,NULL );else - ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); + ret =fsl_espi_rw_trans (m, &trans, rx_buf); - m->actual_length = ret ?0 : espi_trans.len; + m->actual_length = ret ?0 : trans.len;if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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
PATCH v2 10/18 spi: fsl-espi: merge fsl_espi_cmd_trans and fsl_espi_rw_trans
In reply to a message not in the archivefsl_espi_cmd_trans and fsl_espi_rw_trans share most of the code so we can merge them.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-)
drivers/spi/spi-fsl-espi.c +6 -27
@@ -299,23 +299,8 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)return ret; } -static int fsl_espi_cmd_trans (struct spi_message *m, -struct spi_transfer *trans,u8 *rx_buff) -{ -struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -int ret; - -fsl_espi_copy_to_buf (m, mspi); - - trans->tx_buf = mspi->local_buf; - trans->rx_buf = mspi->local_buf; - ret =fsl_espi_do_trans (m, trans); - -return ret; -} - -static int fsl_espi_rw_trans (struct spi_message *m, -struct spi_transfer *trans,u8 *rx_buff) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans, +u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only;
@@ -327,12 +312,9 @@ static int fsl_espi_rw_trans(struct spi_message *m, trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, trans); -if (!ret) { -/* If there is at least one RX byte then copy it to rx_buff */ -if (trans->len > tx_only) -memcpy (rx_buff, trans->rx_buf + tx_only, - trans->len - tx_only); - } +/* If there is at least one RX byte then copy it to rx_buff */ +if (!ret && rx_buff && trans->len > tx_only) +memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only);return ret; }
@@ -354,10 +336,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.len = xfer_len; -if (!rx_buf) - ret =fsl_espi_cmd_trans (m, &trans,NULL ); -else - ret =fsl_espi_rw_trans (m, &trans, rx_buf); + ret =fsl_espi_trans (m, &trans, rx_buf); m->actual_length = ret ?0 : trans.len;
Signature · 7 lines
2.9.2 -- 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
PATCH v2 11/18 spi: fsl-espi: improve return value handling in fsl_espi_bufs
In reply to a message not in the archiveReturn a proper status code from fsl_espi_bufs instead of returning the number of remaining words and let the caller evaluate it.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -4
@@ -258,7 +258,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)/* disable rx ints */ mpc8xxx_spi_write_reg (®_base->mask,0 ); -return mpc8xxx_spi->count; +return mpc8xxx_spi->count >0 ? -EMSGSIZE :0 ; }static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans)
@@ -288,9 +288,6 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)if (trans->len) ret =fsl_espi_bufs (spi, trans); -if (ret) - ret = -EMSGSIZE ; -if (trans->delay_usecs)udelay (trans->delay_usecs);
Signature · 7 lines
2.9.2 -- 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
PATCH v2 12/18 spi: fsl-espi: merge fsl_espi_bufs and fsl_espi_cpu_bufs
In reply to a message not in the archivefsl_espi_bufs and fsl_espi_cpu_bufs are very small that we can merge them.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/spi/spi-fsl-espi.c +8 -19
@@ -206,31 +206,15 @@ static void fsl_espi_setup_transfer(struct spi_device *spi,fsl_espi_change_mode (spi); } -static void fsl_espi_cpu_bufs (struct mpc8xxx_spi *mspi,struct spi_transfer *t, -unsigned int len) -{ -u32 word; -struct fsl_espi_reg *reg_base = mspi->reg_base; - - mspi->count = len; - -/* enable rx ints */ -mpc8xxx_spi_write_reg (®_base->mask,SPIM_NE ); - -/* transmit word */ - word = mspi->get_tx (mspi); -mpc8xxx_spi_write_reg (®_base->transmit, word); -} -static int fsl_espi_bufs (struct spi_device *spi,struct spi_transfer *t) {struct mpc8xxx_spi *mpc8xxx_spi =spi_master_get_devdata (spi->master);struct fsl_espi_reg *reg_base = mpc8xxx_spi->reg_base; -unsigned int len = t->len; +u32 word;int ret; mpc8xxx_spi->len = t->len; - len =roundup (len,4 ) /4 ; + mpc8xxx_spi->count =roundup (t->len,4 ) /4 ; mpc8xxx_spi->tx = t->tx_buf; mpc8xxx_spi->rx = t->rx_buf;
@@ -246,7 +230,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 ))); -fsl_espi_cpu_bufs (mpc8xxx_spi, t, len); +/* enable rx ints */ +mpc8xxx_spi_write_reg (®_base->mask,SPIM_NE ); + +/* transmit word */ + word = mpc8xxx_spi->get_tx (mpc8xxx_spi); +mpc8xxx_spi_write_reg (®_base->transmit, word);/* Won't hang up forever, SPI bus sometimes got lost interrupts... */ ret =wait_for_completion_timeout (&mpc8xxx_spi->done,2 *HZ );
Signature · 7 lines
2.9.2 -- 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
PATCH v2 13/18 spi: fsl-espi: improve the ISR frame
In reply to a message not in the archiveImprove the ISR frame:
- move resetting the event bits to the ISR frame
- change type of parameter irq to int
- make sure that the event bits match at least one bit in the interrupt mask register
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/spi/spi-fsl-espi.c +10 -13
@@ -451,17 +451,11 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) ®_base->event)) & SPIE_NF), 1000, 0);if (!ret) {dev_err (mspi->dev,"tired waiting for SPIE_NF\n" ); - -/* Clear the SPIE bits */ -mpc8xxx_spi_write_reg (®_base->event, events);complete (&mspi->done);return ; } } -/* Clear the events */ -mpc8xxx_spi_write_reg (®_base->event, events); - mspi->count -=1 ;if (mspi->count) {u32 word = mspi->get_tx (mspi);
@@ -472,23 +466,26 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) } } -static irqreturn_t fsl_espi_irq (s32 irq,void *context_data) +static irqreturn_t fsl_espi_irq (int irq,void *context_data) {struct mpc8xxx_spi *mspi = context_data;struct fsl_espi_reg *reg_base = mspi->reg_base; -irqreturn_t ret =IRQ_NONE ; -u32 events; +u32 mask, events; -/* Get interrupt events(tx/rx) */ +/* Get interrupt mask and events and check that irq belongs to us */ + mask =mpc8xxx_spi_read_reg (®_base->mask); events =mpc8xxx_spi_read_reg (®_base->event); -if (events) - ret =IRQ_HANDLED ; +if (!(mask & events)) +return IRQ_NONE ;dev_vdbg (mspi->dev,"%s: events %x\n" , __func__, events);fsl_espi_cpu_irq (mspi, events); -return ret; +/* Clear the events */ +mpc8xxx_spi_write_reg (®_base->event, events); + +return IRQ_HANDLED ; }#ifdef CONFIG_PM
Signature · 7 lines
2.9.2 -- 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
PATCH v2 14/18 spi: fsl-espi: factor out initial message checking
In reply to a message not in the archiveChecking the message is currently done at diffrent places in the driver. Factor it out to fsl_espi_check_message.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-)
drivers/spi/spi-fsl-espi.c +29 -14
@@ -98,6 +98,30 @@ static unsigned int fsl_espi_copy_to_buf(struct spi_message *m,return tx_only; } +static int fsl_espi_check_message (struct spi_message *m) +{ +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); +struct spi_transfer *t, *first; + +if (m->frame_length >SPCOM_TRANLEN_MAX ) { +dev_err (mspi->dev,"message too long, size is %u bytes\n" , + m->frame_length); +return -EMSGSIZE ; + } + + first = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); +list_for_each_entry (t, &m->transfers, transfer_list) { +if (first->bits_per_word != t->bits_per_word || + first->speed_hz != t->speed_hz) { +dev_err (mspi->dev,"bits_per_word/speed_hz should be the same for all transfers\n" ); +return -EINVAL ; + } + } + +return 0 ; +} +static void fsl_espi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -222,11 +246,6 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)reinit_completion (&mpc8xxx_spi->done);/* Set SPCOM[CS] and SPCOM[TRANLEN] field */ -if (t->len >SPCOM_TRANLEN_MAX ) { -dev_err (mpc8xxx_spi->dev,"Transaction length (%d)" -" beyond the SPCOM[TRANLEN] field\n" , t->len); -return -EINVAL ; - }mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 )));
@@ -253,20 +272,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi; -struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct spi_transfer *t, *first;int ret =0 ; first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list);list_for_each_entry (t, &m->transfers, transfer_list) { -if ((first->bits_per_word != t->bits_per_word) || - (first->speed_hz != t->speed_hz)) { -dev_err (mspi->dev, -"bits_per_word/speed_hz should be same for the same SPI transfer\n" ); -return -EINVAL ; - } - trans->speed_hz = t->speed_hz; trans->bits_per_word = t->bits_per_word; trans->delay_usecs =max (first->delay_usecs, t->delay_usecs);
@@ -313,6 +324,10 @@ static int fsl_espi_do_one_msg(struct spi_master *master,struct spi_transfer *t, trans = {};int ret; + ret =fsl_espi_check_message (m); +if (ret) + goto out; +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
@@ -325,7 +340,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ret =fsl_espi_trans (m, &trans, rx_buf); m->actual_length = ret ?0 : trans.len; - +out:if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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
PATCH v2 15/18 spi: fsl-espi: centralize populating struct spi_transfer
In reply to a message not in the archiveBetter structure the code by population all elements of struct spi_transfer in one place.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/spi/spi-fsl-espi.c +12 -12
@@ -272,17 +272,8 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi; -struct spi_transfer *t, *first;int ret =0 ; - first = list_first_entry(&m->transfers, struct spi_transfer, - transfer_list); -list_for_each_entry (t, &m->transfers, transfer_list) { - trans->speed_hz = t->speed_hz; - trans->bits_per_word = t->bits_per_word; - trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); - } -fsl_espi_setup_transfer (spi, trans);if (trans->len)
@@ -305,8 +296,6 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans, tx_only =fsl_espi_copy_to_buf (m, mspi); - trans->tx_buf = mspi->local_buf; - trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, trans);/* If there is at least one RX byte then copy it to rx_buff */
@@ -319,8 +308,9 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);u8 *rx_buf =NULL ; -unsigned int xfer_len =0 ; +unsigned int delay_usecs =0 , xfer_len =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -333,9 +323,19 @@ static int fsl_espi_do_one_msg(struct spi_master *master, rx_buf = t->rx_buf;if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len; +if (t->delay_usecs > delay_usecs) + delay_usecs = t->delay_usecs; } + t = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); + trans.len = xfer_len; + trans.speed_hz = t->speed_hz; + trans.bits_per_word = t->bits_per_word; + trans.delay_usecs = delay_usecs; + trans.tx_buf = mspi->local_buf; + trans.rx_buf = mspi->local_buf; ret =fsl_espi_trans (m, &trans, rx_buf);
Signature · 7 lines
2.9.2 -- 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
PATCH v2 16/18 spi: fsl-espi: factor out handling of read data
In reply to a message not in the archiveFactor out copying read data to the read buffers in the original message to a new function fsl_espi_copy_from_buf.
This also allows to simplify fsl_espi_copy_to_buf.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-)
drivers/spi/spi-fsl-espi.c +21 -20
@@ -77,25 +77,32 @@ struct fsl_espi_reg {#define AUTOSUSPEND_TIMEOUT 2000 -static unsigned int fsl_espi_copy_to_buf (struct spi_message *m, -struct mpc8xxx_spi *mspi) +static void fsl_espi_copy_to_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) { -unsigned int tx_only =0 ;struct spi_transfer *t;u8 *buf = mspi->local_buf;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { +if (t->tx_buf)memcpy (buf, t->tx_buf, t->len); -if (!t->rx_buf) - tx_only += t->len; - }else { +else memset (buf,0 , t->len); - } buf += t->len; } +} + +static void fsl_espi_copy_from_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) +{ +struct spi_transfer *t; +u8 *buf = mspi->local_buf; -return tx_only; +list_for_each_entry (t, &m->transfers, transfer_list) { +if (t->rx_buf) +memcpy (t->rx_buf, buf, t->len); + buf += t->len; + } }static int fsl_espi_check_message (struct spi_message *m)
@@ -287,20 +294,17 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)return ret; } -static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans, -u8 *rx_buff) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -unsigned int tx_only;int ret; - tx_only =fsl_espi_copy_to_buf (m, mspi); +fsl_espi_copy_to_buf (m, mspi); ret =fsl_espi_do_trans (m, trans); -/* If there is at least one RX byte then copy it to rx_buff */ -if (!ret && rx_buff && trans->len > tx_only) -memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); +if (!ret) +fsl_espi_copy_from_buf (m, mspi);return ret; }
@@ -309,7 +313,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -u8 *rx_buf =NULL ;unsigned int delay_usecs =0 , xfer_len =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -319,8 +322,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->rx_buf) - rx_buf = t->rx_buf;if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len;if (t->delay_usecs > delay_usecs)
@@ -337,7 +338,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.tx_buf = mspi->local_buf; trans.rx_buf = mspi->local_buf; - ret =fsl_espi_trans (m, &trans, rx_buf); + ret =fsl_espi_trans (m, &trans); m->actual_length = ret ?0 : trans.len; out:
Signature · 7 lines
2.9.2 -- 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
PATCH v2 17/18 spi: fsl-espi: improve message length handling
In reply to a message not in the archiveMove checking for a zero-length message up in the call chain and use m->frame_length instead of re-calculating the overall length of all transfers in the message.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/spi/spi-fsl-espi.c +5 -7
@@ -283,8 +283,7 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)fsl_espi_setup_transfer (spi, trans); -if (trans->len) - ret =fsl_espi_bufs (spi, trans); + ret =fsl_espi_bufs (spi, trans);if (trans->delay_usecs)udelay (trans->delay_usecs);
@@ -313,7 +312,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -unsigned int delay_usecs =0 , xfer_len =0 ; +unsigned int delay_usecs =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -322,8 +321,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out;list_for_each_entry (t, &m->transfers, transfer_list) { -if ((t->tx_buf) || (t->rx_buf)) - xfer_len += t->len;if (t->delay_usecs > delay_usecs) delay_usecs = t->delay_usecs; }
@@ -331,14 +328,15 @@ static int fsl_espi_do_one_msg(struct spi_master *master, t = list_first_entry(&m->transfers, struct spi_transfer, transfer_list); - trans.len = xfer_len; + trans.len = m->frame_length; trans.speed_hz = t->speed_hz; trans.bits_per_word = t->bits_per_word; trans.delay_usecs = delay_usecs; trans.tx_buf = mspi->local_buf; trans.rx_buf = mspi->local_buf; - ret =fsl_espi_trans (m, &trans); +if (trans.len) + ret =fsl_espi_trans (m, &trans); m->actual_length = ret ?0 : trans.len; out:
Signature · 7 lines
2.9.2 -- 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
PATCH v2 18/18 spi: fsl-espi: merge fsl_espi_trans and fsl_espi_do_trans
In reply to a message not in the archiveMerge both functions to reduce source code size and improve readability.
---
v2:
- rebased
--- drivers/spi/spi-fsl-espi.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/spi/spi-fsl-espi.c +4 -14
@@ -276,11 +276,13 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count >0 ? -EMSGSIZE :0 ; } -static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_device *spi = m->spi; -int ret =0 ; +int ret; +fsl_espi_copy_to_buf (m, mspi);fsl_espi_setup_transfer (spi, trans); ret =fsl_espi_bufs (spi, trans);
@@ -290,18 +292,6 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)fsl_espi_setup_transfer (spi,NULL ); -return ret; -} - -static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) -{ -struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -int ret; - -fsl_espi_copy_to_buf (m, mspi); - - ret =fsl_espi_do_trans (m, trans); -if (!ret)fsl_espi_copy_from_buf (m, mspi);
Signature · 7 lines
2.9.2 -- 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
PATCH v3 2/15 spi: fsl-espi: factor out filling the local buffer
In reply to a message not in the archiveBetter structure the code by factoring out filling the local buffer.
In addition don't initialize the complete local buffer at the beginning of fsl_espi_do_one_msg. Instead move initialization of those parts of the local buffer to be used for transfers w/o tx_buf to fsl_espi_copy_to_buf.
---
v2:
- fixed coding style issue
- improved commit message
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
drivers/spi/spi-fsl-espi.c +24 -22
@@ -85,6 +85,27 @@ struct fsl_espi_transfer {#define AUTOSUSPEND_TIMEOUT 2000 +static unsigned int fsl_espi_copy_to_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) +{ +unsigned int tx_only =0 ; +struct spi_transfer *t; +u8 *buf = mspi->local_buf; + +list_for_each_entry (t, &m->transfers, transfer_list) { +if (t->tx_buf) { +memcpy (buf, t->tx_buf, t->len); +if (!t->rx_buf) + tx_only += t->len; + }else { +memset (buf,0 , t->len); + } + buf += t->len; + } + +return tx_only; +} +static void fsl_espi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -301,16 +322,9 @@ static void fsl_espi_cmd_trans(struct spi_message *m, struct fsl_espi_transfer *trans, u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); -struct spi_transfer *t; -int i =0 ;struct fsl_espi_transfer *espi_trans = trans; -list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { -memcpy (mspi->local_buf + i, t->tx_buf, t->len); - i += t->len; - } - } +fsl_espi_copy_to_buf (m, mspi); espi_trans->tx_buf = mspi->local_buf; espi_trans->rx_buf = mspi->local_buf;
@@ -323,18 +337,9 @@ static void fsl_espi_rw_trans(struct spi_message *m, struct fsl_espi_transfer *trans, u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); -struct spi_transfer *t; -unsigned int tx_only =0 ; -int i =0 ; +unsigned int tx_only; -list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { -memcpy (mspi->local_buf + i, t->tx_buf, t->len); - i += t->len; -if (!t->rx_buf) - tx_only += t->len; - } - } + tx_only =fsl_espi_copy_to_buf (m, mspi); trans->tx_buf = mspi->local_buf; trans->rx_buf = mspi->local_buf;
@@ -352,14 +357,11 @@ static void fsl_espi_rw_trans(struct spi_message *m,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { -struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; -memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
Signature · 7 lines
2.9.2 -- 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
PATCH v3 3/15 spi: fsl-espi: remove element status from struct fsl_espi_transfer
In reply to a message not in the archiveUse the return values of the functions in the call chain to transport status information instead of using an element in struct fsl_espi_transfer for this.
This is more in line with the general approach how to handle status information and is one step further to eventually get rid of struct fsl_espi_transfer completely.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 47 +++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-)
drivers/spi/spi-fsl-espi.c +26 -21
@@ -42,7 +42,6 @@ struct fsl_espi_transfer {void *rx_buf;unsigned len;unsigned actual_length; -int status; };/* eSPI Controller mode register definitions */
@@ -269,14 +268,14 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count; } -static void fsl_espi_do_trans (struct spi_message *m, -struct fsl_espi_transfer *tr) +static int fsl_espi_do_trans (struct spi_message *m, +struct fsl_espi_transfer *tr) {struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct fsl_espi_transfer *espi_trans = tr;struct spi_transfer *t, *first, trans; -int status =0 ; +int ret =0 ;memset (&trans,0 ,sizeof (trans));
@@ -285,10 +284,9 @@ static void fsl_espi_do_trans(struct spi_message *m,list_for_each_entry (t, &m->transfers, transfer_list) {if ((first->bits_per_word != t->bits_per_word) || (first->speed_hz != t->speed_hz)) { - espi_trans->status = -EINVAL ;dev_err (mspi->dev,"bits_per_word/speed_hz should be same for the same SPI transfer\n" ); -return ; +return -EINVAL ; } trans.speed_hz = t->speed_hz;
@@ -303,52 +301,59 @@ static void fsl_espi_do_trans(struct spi_message *m,fsl_espi_setup_transfer (spi, &trans);if (trans.len) - status =fsl_espi_bufs (spi, &trans); + ret =fsl_espi_bufs (spi, &trans); -if (status) - status = -EMSGSIZE ; +if (ret) + ret = -EMSGSIZE ;if (trans.delay_usecs)udelay (trans.delay_usecs); - espi_trans->status = status;fsl_espi_setup_transfer (spi,NULL ); + +return ret; } -static void fsl_espi_cmd_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +static int fsl_espi_cmd_trans (struct spi_message *m, +struct fsl_espi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct fsl_espi_transfer *espi_trans = trans; +int ret;fsl_espi_copy_to_buf (m, mspi); espi_trans->tx_buf = mspi->local_buf; espi_trans->rx_buf = mspi->local_buf; -fsl_espi_do_trans (m, espi_trans); + ret =fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; + +return ret; } -static void fsl_espi_rw_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +static int fsl_espi_rw_trans (struct spi_message *m, +struct fsl_espi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only; +int ret; tx_only =fsl_espi_copy_to_buf (m, mspi); trans->tx_buf = mspi->local_buf; trans->rx_buf = mspi->local_buf; -fsl_espi_do_trans (m, trans); + ret =fsl_espi_do_trans (m, trans); -if (!trans->status) { +if (!ret) {/* If there is at least one RX byte then copy it to rx_buff */ if (trans->len > tx_only)memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); trans->actual_length += trans->len; } + +return ret; } static int fsl_espi_do_one_msg(struct spi_master *master,
@@ -358,6 +363,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master,u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +int ret;list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf)
@@ -368,15 +374,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, espi_trans.len = xfer_len; espi_trans.actual_length =0 ; - espi_trans.status =0 ;if (!rx_buf) -fsl_espi_cmd_trans (m, &espi_trans,NULL ); + ret =fsl_espi_cmd_trans (m, &espi_trans,NULL );else -fsl_espi_rw_trans (m, &espi_trans, rx_buf); + ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); m->actual_length = espi_trans.actual_length; - m->status = espi_trans.status; + m->status = ret;spi_finalize_current_message (master);return 0 ; }
Signature · 7 lines
2.9.2 -- 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
PATCH v3 4/15 spi: fsl-espi: fix status handling in fsl_espi_do_one_msg
In reply to a message not in the archiveIf an error occurred during message handling return this error instead of always returning 0 and align the code with the generic implementation in spi_transfer_one_message.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/spi/spi-fsl-espi.c +5 -2
@@ -381,9 +381,12 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); m->actual_length = espi_trans.actual_length; - m->status = ret; +if (m->status == -EINPROGRESS ) + m->status = ret; +spi_finalize_current_message (master); -return 0 ; + +return ret; }static int fsl_espi_setup (struct spi_device *spi)
Signature · 7 lines
2.9.2 -- 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
PATCH v3 5/15 spi: fsl-espi: remove element actual_length from struct fsl_espi_trans
In reply to a message not in the archiveIf an error occurs during processing the message, then we don't have to populate the actual_length element of struct message. So we can get rid of element actual_length in struct fsl_espi_transfer.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-espi.c +2 -6
@@ -41,7 +41,6 @@ struct fsl_espi_transfer {const void *tx_buf;void *rx_buf;unsigned len; -unsigned actual_length; };/* eSPI Controller mode register definitions */
@@ -327,8 +326,6 @@ static int fsl_espi_cmd_trans(struct spi_message *m, espi_trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, espi_trans); - espi_trans->actual_length = espi_trans->len; -return ret; }
@@ -350,7 +347,6 @@ static int fsl_espi_rw_trans(struct spi_message *m,if (trans->len > tx_only)memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); - trans->actual_length += trans->len; }return ret;
@@ -373,14 +369,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, } espi_trans.len = xfer_len; - espi_trans.actual_length =0 ;if (!rx_buf) ret =fsl_espi_cmd_trans (m, &espi_trans,NULL );else ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); - m->actual_length = espi_trans.actual_length; + m->actual_length = ret ?0 : espi_trans.len; +if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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
PATCH v3 6/15 spi: fsl-espi: eliminate struct fsl_espi_transfer
In reply to a message not in the archiveThe remaining elements of struct fsl_espi_transfer are part of struct spi_transfer anyway. So we can get rid of struct fsl_espi_transfer and use a struct spi_transfer only.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 56 +++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 36 deletions(-)
drivers/spi/spi-fsl-espi.c +20 -36
@@ -37,12 +37,6 @@ struct fsl_espi_reg {__be32 csmode[4 ];/* 0x020 - 0x02c eSPI cs mode register */ }; -struct fsl_espi_transfer { -const void *tx_buf; -void *rx_buf; -unsigned len; -}; -/* eSPI Controller mode register definitions */ #define SPMODE_ENABLE (1 << 31)#define SPMODE_LOOP (1 << 30)
@@ -267,17 +261,13 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count; } -static int fsl_espi_do_trans (struct spi_message *m, -struct fsl_espi_transfer *tr) +static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi;struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master); -struct fsl_espi_transfer *espi_trans = tr; -struct spi_transfer *t, *first, trans; +struct spi_transfer *t, *first;int ret =0 ; -memset (&trans,0 ,sizeof (trans)); - first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list);list_for_each_entry (t, &m->transfers, transfer_list) {
@@ -288,25 +278,21 @@ static int fsl_espi_do_trans(struct spi_message *m,return -EINVAL ; } - trans.speed_hz = t->speed_hz; - trans.bits_per_word = t->bits_per_word; - trans.delay_usecs =max (first->delay_usecs, t->delay_usecs); + trans->speed_hz = t->speed_hz; + trans->bits_per_word = t->bits_per_word; + trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); } - trans.len = espi_trans->len; - trans.tx_buf = espi_trans->tx_buf; - trans.rx_buf = espi_trans->rx_buf; - -fsl_espi_setup_transfer (spi, &trans); +fsl_espi_setup_transfer (spi, trans); -if (trans.len) - ret =fsl_espi_bufs (spi, &trans); +if (trans->len) + ret =fsl_espi_bufs (spi, trans);if (ret) ret = -EMSGSIZE ; -if (trans.delay_usecs) -udelay (trans.delay_usecs); +if (trans->delay_usecs) +udelay (trans->delay_usecs);fsl_espi_setup_transfer (spi,NULL );
@@ -314,23 +300,22 @@ static int fsl_espi_do_trans(struct spi_message *m, }static int fsl_espi_cmd_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +struct spi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -struct fsl_espi_transfer *espi_trans = trans;int ret;fsl_espi_copy_to_buf (m, mspi); - espi_trans->tx_buf = mspi->local_buf; - espi_trans->rx_buf = mspi->local_buf; - ret =fsl_espi_do_trans (m, espi_trans); + trans->tx_buf = mspi->local_buf; + trans->rx_buf = mspi->local_buf; + ret =fsl_espi_do_trans (m, trans);return ret; }static int fsl_espi_rw_trans (struct spi_message *m, -struct fsl_espi_transfer *trans,u8 *rx_buff) +struct spi_transfer *trans,u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only;
@@ -355,10 +340,9 @@ static int fsl_espi_rw_trans(struct spi_message *m,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { -struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ; -struct fsl_espi_transfer espi_trans; +struct spi_transfer *t, trans = {};int ret;list_for_each_entry (t, &m->transfers, transfer_list) {
@@ -368,14 +352,14 @@ static int fsl_espi_do_one_msg(struct spi_master *master, xfer_len += t->len; } - espi_trans.len = xfer_len; + trans.len = xfer_len;if (!rx_buf) - ret =fsl_espi_cmd_trans (m, &espi_trans,NULL ); + ret =fsl_espi_cmd_trans (m, &trans,NULL );else - ret =fsl_espi_rw_trans (m, &espi_trans, rx_buf); + ret =fsl_espi_rw_trans (m, &trans, rx_buf); - m->actual_length = ret ?0 : espi_trans.len; + m->actual_length = ret ?0 : trans.len;if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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
PATCH v3 7/15 spi: fsl-espi: merge fsl_espi_cmd_trans and fsl_espi_rw_trans
In reply to a message not in the archivefsl_espi_cmd_trans and fsl_espi_rw_trans share most of the code so we can merge them.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-)
drivers/spi/spi-fsl-espi.c +6 -27
@@ -299,23 +299,8 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)return ret; } -static int fsl_espi_cmd_trans (struct spi_message *m, -struct spi_transfer *trans,u8 *rx_buff) -{ -struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -int ret; - -fsl_espi_copy_to_buf (m, mspi); - - trans->tx_buf = mspi->local_buf; - trans->rx_buf = mspi->local_buf; - ret =fsl_espi_do_trans (m, trans); - -return ret; -} - -static int fsl_espi_rw_trans (struct spi_message *m, -struct spi_transfer *trans,u8 *rx_buff) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans, +u8 *rx_buff) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);unsigned int tx_only;
@@ -327,12 +312,9 @@ static int fsl_espi_rw_trans(struct spi_message *m, trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, trans); -if (!ret) { -/* If there is at least one RX byte then copy it to rx_buff */ -if (trans->len > tx_only) -memcpy (rx_buff, trans->rx_buf + tx_only, - trans->len - tx_only); - } +/* If there is at least one RX byte then copy it to rx_buff */ +if (!ret && rx_buff && trans->len > tx_only) +memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only);return ret; }
@@ -354,10 +336,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.len = xfer_len; -if (!rx_buf) - ret =fsl_espi_cmd_trans (m, &trans,NULL ); -else - ret =fsl_espi_rw_trans (m, &trans, rx_buf); + ret =fsl_espi_trans (m, &trans, rx_buf); m->actual_length = ret ?0 : trans.len;
Signature · 7 lines
2.9.2 -- 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
PATCH v3 8/15 spi: fsl-espi: improve return value handling in fsl_espi_bufs
In reply to a message not in the archiveReturn a proper status code from fsl_espi_bufs instead of returning the number of remaining words and let the caller evaluate it.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -4
@@ -258,7 +258,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)/* disable rx ints */ mpc8xxx_spi_write_reg (®_base->mask,0 ); -return mpc8xxx_spi->count; +return mpc8xxx_spi->count >0 ? -EMSGSIZE :0 ; }static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans)
@@ -288,9 +288,6 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)if (trans->len) ret =fsl_espi_bufs (spi, trans); -if (ret) - ret = -EMSGSIZE ; -if (trans->delay_usecs)udelay (trans->delay_usecs);
Signature · 7 lines
2.9.2 -- 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
PATCH v3 9/15 spi: fsl-espi: merge fsl_espi_bufs and fsl_espi_cpu_bufs
In reply to a message not in the archivefsl_espi_bufs and fsl_espi_cpu_bufs are very small that we can merge them.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/spi/spi-fsl-espi.c +8 -19
@@ -206,31 +206,15 @@ static void fsl_espi_setup_transfer(struct spi_device *spi,fsl_espi_change_mode (spi); } -static void fsl_espi_cpu_bufs (struct mpc8xxx_spi *mspi,struct spi_transfer *t, -unsigned int len) -{ -u32 word; -struct fsl_espi_reg *reg_base = mspi->reg_base; - - mspi->count = len; - -/* enable rx ints */ -mpc8xxx_spi_write_reg (®_base->mask,SPIM_NE ); - -/* transmit word */ - word = mspi->get_tx (mspi); -mpc8xxx_spi_write_reg (®_base->transmit, word); -} -static int fsl_espi_bufs (struct spi_device *spi,struct spi_transfer *t) {struct mpc8xxx_spi *mpc8xxx_spi =spi_master_get_devdata (spi->master);struct fsl_espi_reg *reg_base = mpc8xxx_spi->reg_base; -unsigned int len = t->len; +u32 word;int ret; mpc8xxx_spi->len = t->len; - len =roundup (len,4 ) /4 ; + mpc8xxx_spi->count =roundup (t->len,4 ) /4 ; mpc8xxx_spi->tx = t->tx_buf; mpc8xxx_spi->rx = t->rx_buf;
@@ -246,7 +230,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 ))); -fsl_espi_cpu_bufs (mpc8xxx_spi, t, len); +/* enable rx ints */ +mpc8xxx_spi_write_reg (®_base->mask,SPIM_NE ); + +/* transmit word */ + word = mpc8xxx_spi->get_tx (mpc8xxx_spi); +mpc8xxx_spi_write_reg (®_base->transmit, word);/* Won't hang up forever, SPI bus sometimes got lost interrupts... */ ret =wait_for_completion_timeout (&mpc8xxx_spi->done,2 *HZ );
Signature · 7 lines
2.9.2 -- 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
PATCH v3 10/15 spi: fsl-espi: improve the ISR frame
In reply to a message not in the archiveImprove the ISR frame:
- move resetting the event bits to the ISR frame
- change type of parameter irq to int
- make sure that the event bits match at least one bit in the interrupt mask register
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/spi/spi-fsl-espi.c +10 -13
@@ -451,17 +451,11 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) ®_base->event)) & SPIE_NF), 1000, 0);if (!ret) {dev_err (mspi->dev,"tired waiting for SPIE_NF\n" ); - -/* Clear the SPIE bits */ -mpc8xxx_spi_write_reg (®_base->event, events);complete (&mspi->done);return ; } } -/* Clear the events */ -mpc8xxx_spi_write_reg (®_base->event, events); - mspi->count -=1 ;if (mspi->count) {u32 word = mspi->get_tx (mspi);
@@ -472,23 +466,26 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) } } -static irqreturn_t fsl_espi_irq (s32 irq,void *context_data) +static irqreturn_t fsl_espi_irq (int irq,void *context_data) {struct mpc8xxx_spi *mspi = context_data;struct fsl_espi_reg *reg_base = mspi->reg_base; -irqreturn_t ret =IRQ_NONE ; -u32 events; +u32 mask, events; -/* Get interrupt events(tx/rx) */ +/* Get interrupt mask and events and check that irq belongs to us */ + mask =mpc8xxx_spi_read_reg (®_base->mask); events =mpc8xxx_spi_read_reg (®_base->event); -if (events) - ret =IRQ_HANDLED ; +if (!(mask & events)) +return IRQ_NONE ;dev_vdbg (mspi->dev,"%s: events %x\n" , __func__, events);fsl_espi_cpu_irq (mspi, events); -return ret; +/* Clear the events */ +mpc8xxx_spi_write_reg (®_base->event, events); + +return IRQ_HANDLED ; }#ifdef CONFIG_PM
Signature · 7 lines
2.9.2 -- 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): 7733dbde-1950-d6e3-6d71-975b25d6ded1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH v3 10/15] spi: fsl-espi: improve the ISR frame
Quoted 1 line · Heiner Kallweit
Improve the ISR frame:
I *think* that by "frame" you mean "function" here but it's really hard to tell. Please try to use normal technical terms, it makes things much easier to review.
Quoted 4 lines
- move resetting the event bits to the ISR frame
- change type of parameter irq to int
- make sure that the event bits match at least one bit in the interrupt mask register
This sounds like three separate changes and should therefore have been three patches.
PATCH v3 11/15 spi: fsl-espi: factor out initial message checking
In reply to a message not in the archiveChecking the message is currently done at diffrent places in the driver. Factor it out to fsl_espi_check_message.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-)
drivers/spi/spi-fsl-espi.c +29 -14
@@ -98,6 +98,30 @@ static unsigned int fsl_espi_copy_to_buf(struct spi_message *m,return tx_only; } +static int fsl_espi_check_message (struct spi_message *m) +{ +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); +struct spi_transfer *t, *first; + +if (m->frame_length >SPCOM_TRANLEN_MAX ) { +dev_err (mspi->dev,"message too long, size is %u bytes\n" , + m->frame_length); +return -EMSGSIZE ; + } + + first = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); +list_for_each_entry (t, &m->transfers, transfer_list) { +if (first->bits_per_word != t->bits_per_word || + first->speed_hz != t->speed_hz) { +dev_err (mspi->dev,"bits_per_word/speed_hz should be the same for all transfers\n" ); +return -EINVAL ; + } + } + +return 0 ; +} +static void fsl_espi_change_mode (struct spi_device *spi) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);
@@ -222,11 +246,6 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)reinit_completion (&mpc8xxx_spi->done);/* Set SPCOM[CS] and SPCOM[TRANLEN] field */ -if (t->len >SPCOM_TRANLEN_MAX ) { -dev_err (mpc8xxx_spi->dev,"Transaction length (%d)" -" beyond the SPCOM[TRANLEN] field\n" , t->len); -return -EINVAL ; - }mpc8xxx_spi_write_reg (®_base->command, (SPCOM_CS (spi->chip_select) |SPCOM_TRANLEN (t->len -1 )));
@@ -253,20 +272,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi; -struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master);struct spi_transfer *t, *first;int ret =0 ; first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list);list_for_each_entry (t, &m->transfers, transfer_list) { -if ((first->bits_per_word != t->bits_per_word) || - (first->speed_hz != t->speed_hz)) { -dev_err (mspi->dev, -"bits_per_word/speed_hz should be same for the same SPI transfer\n" ); -return -EINVAL ; - } - trans->speed_hz = t->speed_hz; trans->bits_per_word = t->bits_per_word; trans->delay_usecs =max (first->delay_usecs, t->delay_usecs);
@@ -313,6 +324,10 @@ static int fsl_espi_do_one_msg(struct spi_master *master,struct spi_transfer *t, trans = {};int ret; + ret =fsl_espi_check_message (m); +if (ret) + goto out; +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
@@ -325,7 +340,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ret =fsl_espi_trans (m, &trans, rx_buf); m->actual_length = ret ?0 : trans.len; - +out:if (m->status == -EINPROGRESS ) m->status = ret;
Signature · 7 lines
2.9.2 -- 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
PATCH v3 12/15 spi: fsl-espi: centralize populating struct spi_transfer
In reply to a message not in the archiveBetter structure the code by population all elements of struct spi_transfer in one place.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/spi/spi-fsl-espi.c +12 -12
@@ -272,17 +272,8 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) {struct spi_device *spi = m->spi; -struct spi_transfer *t, *first;int ret =0 ; - first = list_first_entry(&m->transfers, struct spi_transfer, - transfer_list); -list_for_each_entry (t, &m->transfers, transfer_list) { - trans->speed_hz = t->speed_hz; - trans->bits_per_word = t->bits_per_word; - trans->delay_usecs =max (first->delay_usecs, t->delay_usecs); - } -fsl_espi_setup_transfer (spi, trans);if (trans->len)
@@ -305,8 +296,6 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans, tx_only =fsl_espi_copy_to_buf (m, mspi); - trans->tx_buf = mspi->local_buf; - trans->rx_buf = mspi->local_buf; ret =fsl_espi_do_trans (m, trans);/* If there is at least one RX byte then copy it to rx_buff */
@@ -319,8 +308,9 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans,static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);u8 *rx_buf =NULL ; -unsigned int xfer_len =0 ; +unsigned int delay_usecs =0 , xfer_len =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -333,9 +323,19 @@ static int fsl_espi_do_one_msg(struct spi_master *master, rx_buf = t->rx_buf;if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len; +if (t->delay_usecs > delay_usecs) + delay_usecs = t->delay_usecs; } + t = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); + trans.len = xfer_len; + trans.speed_hz = t->speed_hz; + trans.bits_per_word = t->bits_per_word; + trans.delay_usecs = delay_usecs; + trans.tx_buf = mspi->local_buf; + trans.rx_buf = mspi->local_buf; ret =fsl_espi_trans (m, &trans, rx_buf);
Signature · 7 lines
2.9.2 -- 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
PATCH v3 13/15 spi: fsl-espi: factor out handling of read data
In reply to a message not in the archiveFactor out copying read data to the read buffers in the original message to a new function fsl_espi_copy_from_buf.
This also allows to simplify fsl_espi_copy_to_buf.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-)
drivers/spi/spi-fsl-espi.c +21 -20
@@ -77,25 +77,32 @@ struct fsl_espi_reg {#define AUTOSUSPEND_TIMEOUT 2000 -static unsigned int fsl_espi_copy_to_buf (struct spi_message *m, -struct mpc8xxx_spi *mspi) +static void fsl_espi_copy_to_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) { -unsigned int tx_only =0 ;struct spi_transfer *t;u8 *buf = mspi->local_buf;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->tx_buf) { +if (t->tx_buf)memcpy (buf, t->tx_buf, t->len); -if (!t->rx_buf) - tx_only += t->len; - }else { +else memset (buf,0 , t->len); - } buf += t->len; } +} + +static void fsl_espi_copy_from_buf (struct spi_message *m, +struct mpc8xxx_spi *mspi) +{ +struct spi_transfer *t; +u8 *buf = mspi->local_buf; -return tx_only; +list_for_each_entry (t, &m->transfers, transfer_list) { +if (t->rx_buf) +memcpy (t->rx_buf, buf, t->len); + buf += t->len; + } }static int fsl_espi_check_message (struct spi_message *m)
@@ -287,20 +294,17 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)return ret; } -static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans, -u8 *rx_buff) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -unsigned int tx_only;int ret; - tx_only =fsl_espi_copy_to_buf (m, mspi); +fsl_espi_copy_to_buf (m, mspi); ret =fsl_espi_do_trans (m, trans); -/* If there is at least one RX byte then copy it to rx_buff */ -if (!ret && rx_buff && trans->len > tx_only) -memcpy (rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); +if (!ret) +fsl_espi_copy_from_buf (m, mspi);return ret; }
@@ -309,7 +313,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -u8 *rx_buf =NULL ;unsigned int delay_usecs =0 , xfer_len =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -319,8 +322,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out;list_for_each_entry (t, &m->transfers, transfer_list) { -if (t->rx_buf) - rx_buf = t->rx_buf;if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len;if (t->delay_usecs > delay_usecs)
@@ -337,7 +338,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.tx_buf = mspi->local_buf; trans.rx_buf = mspi->local_buf; - ret =fsl_espi_trans (m, &trans, rx_buf); + ret =fsl_espi_trans (m, &trans); m->actual_length = ret ?0 : trans.len; out:
Signature · 7 lines
2.9.2 -- 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
PATCH v3 14/15 spi: fsl-espi: improve message length handling
In reply to a message not in the archiveMove checking for a zero-length message up in the call chain and use m->frame_length instead of re-calculating the overall length of all transfers in the message.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/spi/spi-fsl-espi.c +5 -7
@@ -283,8 +283,7 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)fsl_espi_setup_transfer (spi, trans); -if (trans->len) - ret =fsl_espi_bufs (spi, trans); + ret =fsl_espi_bufs (spi, trans);if (trans->delay_usecs)udelay (trans->delay_usecs);
@@ -313,7 +312,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) {struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -unsigned int delay_usecs =0 , xfer_len =0 ; +unsigned int delay_usecs =0 ;struct spi_transfer *t, trans = {};int ret;
@@ -322,8 +321,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out;list_for_each_entry (t, &m->transfers, transfer_list) { -if ((t->tx_buf) || (t->rx_buf)) - xfer_len += t->len;if (t->delay_usecs > delay_usecs) delay_usecs = t->delay_usecs; }
@@ -331,14 +328,15 @@ static int fsl_espi_do_one_msg(struct spi_master *master, t = list_first_entry(&m->transfers, struct spi_transfer, transfer_list); - trans.len = xfer_len; + trans.len = m->frame_length; trans.speed_hz = t->speed_hz; trans.bits_per_word = t->bits_per_word; trans.delay_usecs = delay_usecs; trans.tx_buf = mspi->local_buf; trans.rx_buf = mspi->local_buf; - ret =fsl_espi_trans (m, &trans); +if (trans.len) + ret =fsl_espi_trans (m, &trans); m->actual_length = ret ?0 : trans.len; out:
Signature · 7 lines
2.9.2 -- 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
PATCH v3 15/15 spi: fsl-espi: merge fsl_espi_trans and fsl_espi_do_trans
In reply to a message not in the archiveMerge both functions to reduce source code size and improve readability.
---
v2:
- rebased
v3:
- new numbering
--- drivers/spi/spi-fsl-espi.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/spi/spi-fsl-espi.c +4 -14
@@ -276,11 +276,13 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)return mpc8xxx_spi->count >0 ? -EMSGSIZE :0 ; } -static int fsl_espi_do_trans (struct spi_message *m,struct spi_transfer *trans) +static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_device *spi = m->spi; -int ret =0 ; +int ret; +fsl_espi_copy_to_buf (m, mspi);fsl_espi_setup_transfer (spi, trans); ret =fsl_espi_bufs (spi, trans);
@@ -290,18 +292,6 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)fsl_espi_setup_transfer (spi,NULL ); -return ret; -} - -static int fsl_espi_trans (struct spi_message *m,struct spi_transfer *trans) -{ -struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master); -int ret; - -fsl_espi_copy_to_buf (m, mspi); - - ret =fsl_espi_do_trans (m, trans); -if (!ret)fsl_espi_copy_from_buf (m, mspi);
Signature · 7 lines
2.9.2 -- 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]
A message that is not in the archive (sent off-list or not yet received): cabc3522-8ca9-516a-e0ef-5a2ed9ad8507-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 2/23 spi: fsl-espi: pre-allocate message buffer
Currently the driver allocates a 64kb buffer with each single message. On systems with little and fragmented memory this can result in memory allocation errors. Solve this by pre-allocating a buffer.
This patch was developed in OpenWRT long ago, however it never made it upstream. I slightly modified the original patch to re-initialize the buffer at the beginning of each transfer.
Original author: Gabor Juhos <[email protected]>
--- drivers/spi/spi-fsl-espi.c | 39 ++++++++++++++++----------------------- drivers/spi/spi-fsl-lib.h | 1 + 2 files changed, 17 insertions(+), 23 deletions(-)
drivers/spi/spi-fsl-espi.c +16 -23
@@ -319,57 +319,42 @@ static void fsl_espi_do_trans(struct spi_message *m,static void fsl_espi_cmd_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;int i =0 ;struct fsl_espi_transfer *espi_trans = trans; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - espi_trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len; } } - espi_trans->tx_buf = local_buf; - espi_trans->rx_buf = local_buf; + espi_trans->tx_buf = espi_trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; -kfree (local_buf); }static void fsl_espi_rw_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;unsigned int tx_only =0 ;int i =0 ; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len;if (!t->rx_buf) tx_only += t->len; } } - trans->tx_buf = local_buf; - trans->rx_buf = local_buf; + trans->tx_buf = trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, trans);if (!trans->status) {
@@ -379,13 +364,12 @@ static void fsl_espi_rw_trans(struct spi_message *m, trans->len - tx_only); trans->actual_length += trans->len; } - -kfree (local_buf); }static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int n_tx =0 ;
@@ -393,6 +377,8 @@ static int fsl_espi_do_one_msg(struct spi_master *master,unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) n_tx += t->len;
@@ -649,6 +635,13 @@ static struct spi_master * fsl_espi_probe(struct device *dev, mpc8xxx_spi =spi_master_get_devdata (master); + mpc8xxx_spi->local_buf = +devm_kmalloc (dev,SPCOM_TRANLEN_MAX ,GFP_KERNEL ); +if (!mpc8xxx_spi->local_buf) { + ret = -ENOMEM ; + goto err_probe; + } + mpc8xxx_spi->reg_base =devm_ioremap_resource (dev, mem);if (IS_ERR (mpc8xxx_spi->reg_base)) { ret =PTR_ERR (mpc8xxx_spi->reg_base);
drivers/spi/spi-fsl-lib.h +1 -0
@@ -30,6 +30,7 @@ struct mpc8xxx_spi {void *rx;#if IS_ENABLED (CONFIG_SPI_FSL_ESPI )int len; +u8 *local_buf;#endif int subblock;
Signature · 7 lines
2.9.2 -- 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): 448706fe-fd0a-7a56-b37e-0500c3ed4c18-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 02/23] spi: fsl-espi: pre-allocate message buffer
Quoted 3 lines · Heiner Kallweit
Original author: Gabor Juhos <[email protected]>
Signed-off-by Heiner Kallweit <[email protected]>
Why is this not a proper signoff?
drivers/spi/spi-fsl-espi.c static void fsl_espi_do_trans(struct spi_message *m, · line 334
Quoted 3 lines
drivers/spi/spi-fsl-espi.c +1
-2- espi_trans->tx_buf = local_buf; - espi_trans->rx_buf = local_buf; + espi_trans->tx_buf = espi_trans->rx_buf = mspi->local_buf;
This is regressing the coding style, please don't do multiple assignments in a single line as it makes things harder to understand - the original code was better here.
PATCH v2 3/23 spi: fsl-espi: pre-allocate message buffer
In reply to a message not in the archiveCurrently the driver allocates a 64kb buffer with each single message. On systems with little and fragmented memory this can result in memory allocation errors. Solve this by pre-allocating a buffer.
This patch was developed in OpenWRT long ago, however it never
made it upstream. Author: Gabor Juhos <[email protected]>
I slightly modified the original patch to re-initialize the buffer at the beginning of each transfer.
---
v2:
- changed order of patches 2 and 3 to do the trivial changes first
- fixed coding style issue
- fixed commit message
--- drivers/spi/spi-fsl-espi.c | 41 ++++++++++++++++++----------------------- drivers/spi/spi-fsl-lib.h | 1 + 2 files changed, 19 insertions(+), 23 deletions(-)
drivers/spi/spi-fsl-espi.c +18 -23
@@ -300,57 +300,44 @@ static void fsl_espi_do_trans(struct spi_message *m,static void fsl_espi_cmd_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;int i =0 ;struct fsl_espi_transfer *espi_trans = trans; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - espi_trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len; } } - espi_trans->tx_buf = local_buf; - espi_trans->rx_buf = local_buf; + espi_trans->tx_buf = mspi->local_buf; + espi_trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; -kfree (local_buf); }static void fsl_espi_rw_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;unsigned int tx_only =0 ;int i =0 ; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len;if (!t->rx_buf) tx_only += t->len; } } - trans->tx_buf = local_buf; - trans->rx_buf = local_buf; + trans->tx_buf = mspi->local_buf; + trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, trans);if (!trans->status) {
@@ -360,18 +347,19 @@ static void fsl_espi_rw_trans(struct spi_message *m, trans->len - tx_only); trans->actual_length += trans->len; } - -kfree (local_buf); }static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
@@ -617,6 +605,13 @@ static struct spi_master * fsl_espi_probe(struct device *dev, mpc8xxx_spi =spi_master_get_devdata (master); + mpc8xxx_spi->local_buf = +devm_kmalloc (dev,SPCOM_TRANLEN_MAX ,GFP_KERNEL ); +if (!mpc8xxx_spi->local_buf) { + ret = -ENOMEM ; + goto err_probe; + } + mpc8xxx_spi->reg_base =devm_ioremap_resource (dev, mem);if (IS_ERR (mpc8xxx_spi->reg_base)) { ret =PTR_ERR (mpc8xxx_spi->reg_base);
drivers/spi/spi-fsl-lib.h +1 -0
@@ -30,6 +30,7 @@ struct mpc8xxx_spi {void *rx;#if IS_ENABLED (CONFIG_SPI_FSL_ESPI )int len; +u8 *local_buf;#endif int subblock;
Signature · 7 lines
2.9.2 -- 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): c6fcea87-94b1-76e8-b8da-a7727a22282e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Applied "spi: fsl-espi: pre-allocate message buffer" to the spi tree
The patch
spi: fsl-espi: pre-allocate message buffer
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
1423877b73ed5f4982eaba8bed359605b9918a2bMon Sep 17 00:00:00 2001
From: Heiner Kallweit <[email protected]>
Date: Wed, 7 Sep 2016 22:50:22 +0200
Subject: [PATCH] spi: fsl-espi: pre-allocate message buffer
Currently the driver allocates a 64kb buffer for each single message. On systems with little and fragmented memory this can result in memory allocation errors. Solve this by pre-allocating a buffer.
This patch was developed in OpenWRT long ago, however it never made it upstream.
I slightly modified the original patch to re-initialize the buffer at the beginning of each transfer.
--- drivers/spi/spi-fsl-espi.c | 41 ++++++++++++++++++----------------------- drivers/spi/spi-fsl-lib.h | 1 + 2 files changed, 19 insertions(+), 23 deletions(-)
drivers/spi/spi-fsl-espi.c +18 -23
@@ -297,57 +297,44 @@ static void fsl_espi_do_trans(struct spi_message *m,static void fsl_espi_cmd_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;int i =0 ;struct fsl_espi_transfer *espi_trans = trans; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - espi_trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len; } } - espi_trans->tx_buf = local_buf; - espi_trans->rx_buf = local_buf; + espi_trans->tx_buf = mspi->local_buf; + espi_trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; -kfree (local_buf); }static void fsl_espi_rw_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;unsigned int tx_only =0 ;int i =0 ; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len;if (!t->rx_buf) tx_only += t->len; } } - trans->tx_buf = local_buf; - trans->rx_buf = local_buf; + trans->tx_buf = mspi->local_buf; + trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, trans);if (!trans->status) {
@@ -357,18 +344,19 @@ static void fsl_espi_rw_trans(struct spi_message *m, trans->len - tx_only); trans->actual_length += trans->len; } - -kfree (local_buf); }static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
@@ -614,6 +602,13 @@ static struct spi_master * fsl_espi_probe(struct device *dev, mpc8xxx_spi =spi_master_get_devdata (master); + mpc8xxx_spi->local_buf = +devm_kmalloc (dev,SPCOM_TRANLEN_MAX ,GFP_KERNEL ); +if (!mpc8xxx_spi->local_buf) { + ret = -ENOMEM ; + goto err_probe; + } + mpc8xxx_spi->reg_base =devm_ioremap_resource (dev, mem);if (IS_ERR (mpc8xxx_spi->reg_base)) { ret =PTR_ERR (mpc8xxx_spi->reg_base);
drivers/spi/spi-fsl-lib.h +1 -0
@@ -30,6 +30,7 @@ struct mpc8xxx_spi {void *rx;#if IS_ENABLED (CONFIG_SPI_FSL_ESPI )int len; +u8 *local_buf;#endif int subblock;
Signature · 6 lines
2.8.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
PATCH v2 4/18 spi: fsl-espi: pre-allocate message buffer
In reply to a message not in the archiveCurrently the driver allocates a 64kb buffer with each single message. On systems with little and fragmented memory this can result in memory allocation errors. Solve this by pre-allocating a buffer.
This patch was developed in OpenWRT long ago, however it never
made it upstream. Author: Gabor Juhos <[email protected]>
I slightly modified the original patch to re-initialize the buffer at the beginning of each transfer.
---
v2:
- fixed coding style issue
- fixed commit message
--- drivers/spi/spi-fsl-espi.c | 41 ++++++++++++++++++----------------------- drivers/spi/spi-fsl-lib.h | 1 + 2 files changed, 19 insertions(+), 23 deletions(-)
drivers/spi/spi-fsl-espi.c +18 -23
@@ -300,57 +300,44 @@ static void fsl_espi_do_trans(struct spi_message *m,static void fsl_espi_cmd_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;int i =0 ;struct fsl_espi_transfer *espi_trans = trans; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - espi_trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len; } } - espi_trans->tx_buf = local_buf; - espi_trans->rx_buf = local_buf; + espi_trans->tx_buf = mspi->local_buf; + espi_trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; -kfree (local_buf); }static void fsl_espi_rw_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;unsigned int tx_only =0 ;int i =0 ; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len;if (!t->rx_buf) tx_only += t->len; } } - trans->tx_buf = local_buf; - trans->rx_buf = local_buf; + trans->tx_buf = mspi->local_buf; + trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, trans);if (!trans->status) {
@@ -360,18 +347,19 @@ static void fsl_espi_rw_trans(struct spi_message *m, trans->len - tx_only); trans->actual_length += trans->len; } - -kfree (local_buf); }static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
@@ -617,6 +605,13 @@ static struct spi_master * fsl_espi_probe(struct device *dev, mpc8xxx_spi =spi_master_get_devdata (master); + mpc8xxx_spi->local_buf = +devm_kmalloc (dev,SPCOM_TRANLEN_MAX ,GFP_KERNEL ); +if (!mpc8xxx_spi->local_buf) { + ret = -ENOMEM ; + goto err_probe; + } + mpc8xxx_spi->reg_base =devm_ioremap_resource (dev, mem);if (IS_ERR (mpc8xxx_spi->reg_base)) { ret =PTR_ERR (mpc8xxx_spi->reg_base);
drivers/spi/spi-fsl-lib.h +1 -0
@@ -30,6 +30,7 @@ struct mpc8xxx_spi {void *rx;#if IS_ENABLED (CONFIG_SPI_FSL_ESPI )int len; +u8 *local_buf;#endif int subblock;
Signature · 7 lines
2.9.2 -- 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): 0e60b4b5-5016-e1c3-d29d-b81a41f64f48-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH v2 04/18] spi: fsl-espi: pre-allocate message buffer
Quoted 11 lines · Heiner Kallweit
Currently the driver allocates a 64kb buffer with each single message. On systems with little and fragmented memory this can result in memory allocation errors. Solve this by pre-allocating a buffer.
This patch was developed in OpenWRT long ago, however it never
made it upstream. Author: Gabor Juhos <[email protected]>I slightly modified the original patch to re-initialize the buffer at the beginning of each transfer.
Signed-off-by Heiner Kallweit <[email protected]>
When you sent this previously I asked what happened with the signoff from Gabor. A little Google tells me that he did in fact sign off the copy that's in OpenWRT. Please don't drop signoffs, they're important for tracking licensing - see SubmittingPatches for details. If the modifications you made really are slight as you say then I'd also expect Gabor's authorship to be preserved.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 04/18] spi: fsl-espi: pre-allocate message buffer
Am 06.09.2016 um 12:58 schrieb Mark Brown:
Quoted 11 lines · Heiner Kallweit
Quoted 10 lines
Currently the driver allocates a 64kb buffer with each single message. On systems with little and fragmented memory this can result in memory allocation errors. Solve this by pre-allocating a buffer.
This patch was developed in OpenWRT long ago, however it never
made it upstream. Author: Gabor Juhos <[email protected]>I slightly modified the original patch to re-initialize the buffer at the beginning of each transfer.
Quoted 9 lines
Quoted 1 line
Signed-off-by Heiner Kallweit <[email protected]>When you sent this previously I asked what happened with the signoff from Gabor. A little Google tells me that he did in fact sign off the copy that's in OpenWRT. Please don't drop signoffs, they're important for tracking licensing - see SubmittingPatches for details. If the modifications you made really are slight as you say then I'd also expect Gabor's authorship to be preserved.
Sorry, then I misunderstood your comment.
I'll resend the patch with Gabor's Signed-off-by. Do you want my Signed-off-by in addition?
--
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): f895014d-e8d6-9917-47a6-12f37b798b86-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH v2 04/18] spi: fsl-espi: pre-allocate message buffer
Quoted 3 lines · Heiner Kallweit
Sorry, then I misunderstood your comment.
I'll resend the patch with Gabor's Signed-off-by. Do you want my Signed-off-by in addition?
You need your signoff on anything you send including this - like I say see SubmittingPatches for what this is doing.
PATCH v3 4/18 spi: fsl-espi: pre-allocate message buffer
In reply to a message not in the archiveCurrently the driver allocates a 64kb buffer for each single message. On systems with little and fragmented memory this can result in memory allocation errors. Solve this by pre-allocating a buffer.
This patch was developed in OpenWRT long ago, however it never made it upstream.
I slightly modified the original patch to re-initialize the buffer at the beginning of each transfer.
---
v2:
- fixed coding style issue
- fixed commit message
v3:
- changed Signed-off-by to include original author
--- drivers/spi/spi-fsl-espi.c | 41 ++++++++++++++++++----------------------- drivers/spi/spi-fsl-lib.h | 1 + 2 files changed, 19 insertions(+), 23 deletions(-)
drivers/spi/spi-fsl-espi.c +18 -23
@@ -300,57 +300,44 @@ static void fsl_espi_do_trans(struct spi_message *m,static void fsl_espi_cmd_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;int i =0 ;struct fsl_espi_transfer *espi_trans = trans; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - espi_trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len; } } - espi_trans->tx_buf = local_buf; - espi_trans->rx_buf = local_buf; + espi_trans->tx_buf = mspi->local_buf; + espi_trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; -kfree (local_buf); }static void fsl_espi_rw_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;unsigned int tx_only =0 ;int i =0 ; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len;if (!t->rx_buf) tx_only += t->len; } } - trans->tx_buf = local_buf; - trans->rx_buf = local_buf; + trans->tx_buf = mspi->local_buf; + trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, trans);if (!trans->status) {
@@ -360,18 +347,19 @@ static void fsl_espi_rw_trans(struct spi_message *m, trans->len - tx_only); trans->actual_length += trans->len; } - -kfree (local_buf); }static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
@@ -617,6 +605,13 @@ static struct spi_master * fsl_espi_probe(struct device *dev, mpc8xxx_spi =spi_master_get_devdata (master); + mpc8xxx_spi->local_buf = +devm_kmalloc (dev,SPCOM_TRANLEN_MAX ,GFP_KERNEL ); +if (!mpc8xxx_spi->local_buf) { + ret = -ENOMEM ; + goto err_probe; + } + mpc8xxx_spi->reg_base =devm_ioremap_resource (dev, mem);if (IS_ERR (mpc8xxx_spi->reg_base)) { ret =PTR_ERR (mpc8xxx_spi->reg_base);
drivers/spi/spi-fsl-lib.h +1 -0
@@ -30,6 +30,7 @@ struct mpc8xxx_spi {void *rx;#if IS_ENABLED (CONFIG_SPI_FSL_ESPI )int len; +u8 *local_buf;#endif int subblock;
Signature · 7 lines
2.9.2 -- 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): 14371aa8-17f2-69a2-99d4-cd095a87545c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH v3 04/18] spi: fsl-espi: pre-allocate message buffer
Quoted 3 lines · Heiner Kallweit
Currently the driver allocates a 64kb buffer for each single message. On systems with little and fragmented memory this can result in memory allocation errors. Solve this by pre-allocating a buffer.
This is flagged as patch 4/18 but I only have this as a single patch. As previously discussed the purpose of the numbering in a patch series is to order things, if you're just sending a single patch it doesn't need numbering and if you're sending a series you need to send either the whole thing or at least a cover letter to everyone so they know what's going on.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 04/18] spi: fsl-espi: pre-allocate message buffer
Am 07.09.2016 um 20:56 schrieb Mark Brown:
Quoted 5 lines · Heiner Kallweit
Quoted 3 lines
Currently the driver allocates a 64kb buffer for each single message. On systems with little and fragmented memory this can result in memory allocation errors. Solve this by pre-allocating a buffer.
Quoted 7 lines
This is flagged as patch 4/18 but I only have this as a single patch. As previously discussed the purpose of the numbering in a patch series is to order things, if you're just sending a single patch it doesn't need numbering and if you're sending a series you need to send either the whole thing or at least a cover letter to everyone so they know what's going on.
OK, as you applied three further patches from the series already, I'll resend the remaining 15 with new numbering.
--
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
PATCH v3 1/15 spi: fsl-espi: pre-allocate message buffer
In reply to a message not in the archiveCurrently the driver allocates a 64kb buffer for each single message. On systems with little and fragmented memory this can result in memory allocation errors. Solve this by pre-allocating a buffer.
This patch was developed in OpenWRT long ago, however it never made it upstream.
I slightly modified the original patch to re-initialize the buffer at the beginning of each transfer.
---
v2:
- fixed coding style issue
- fixed commit message
v3:
- changed Signed-off-by to include original author
--- drivers/spi/spi-fsl-espi.c | 41 ++++++++++++++++++----------------------- drivers/spi/spi-fsl-lib.h | 1 + 2 files changed, 19 insertions(+), 23 deletions(-)
drivers/spi/spi-fsl-espi.c +18 -23
@@ -300,57 +300,44 @@ static void fsl_espi_do_trans(struct spi_message *m,static void fsl_espi_cmd_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;int i =0 ;struct fsl_espi_transfer *espi_trans = trans; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - espi_trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len; } } - espi_trans->tx_buf = local_buf; - espi_trans->rx_buf = local_buf; + espi_trans->tx_buf = mspi->local_buf; + espi_trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, espi_trans); espi_trans->actual_length = espi_trans->len; -kfree (local_buf); }static void fsl_espi_rw_trans (struct spi_message *m,struct fsl_espi_transfer *trans,u8 *rx_buff) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (m->spi->master);struct spi_transfer *t; -u8 *local_buf;unsigned int tx_only =0 ;int i =0 ; - local_buf =kzalloc (SPCOM_TRANLEN_MAX ,GFP_KERNEL ); -if (!local_buf) { - trans->status = -ENOMEM ; -return ; - } -list_for_each_entry (t, &m->transfers, transfer_list) {if (t->tx_buf) { -memcpy (local_buf + i, t->tx_buf, t->len); +memcpy (mspi->local_buf + i, t->tx_buf, t->len); i += t->len;if (!t->rx_buf) tx_only += t->len; } } - trans->tx_buf = local_buf; - trans->rx_buf = local_buf; + trans->tx_buf = mspi->local_buf; + trans->rx_buf = mspi->local_buf;fsl_espi_do_trans (m, trans);if (!trans->status) {
@@ -360,18 +347,19 @@ static void fsl_espi_rw_trans(struct spi_message *m, trans->len - tx_only); trans->actual_length += trans->len; } - -kfree (local_buf); }static int fsl_espi_do_one_msg (struct spi_master *master,struct spi_message *m) { +struct mpc8xxx_spi *mspi =spi_master_get_devdata (master);struct spi_transfer *t;u8 *rx_buf =NULL ;unsigned int xfer_len =0 ;struct fsl_espi_transfer espi_trans; +memset (mspi->local_buf,0 ,SPCOM_TRANLEN_MAX ); +list_for_each_entry (t, &m->transfers, transfer_list) {if (t->rx_buf) rx_buf = t->rx_buf;
@@ -617,6 +605,13 @@ static struct spi_master * fsl_espi_probe(struct device *dev, mpc8xxx_spi =spi_master_get_devdata (master); + mpc8xxx_spi->local_buf = +devm_kmalloc (dev,SPCOM_TRANLEN_MAX ,GFP_KERNEL ); +if (!mpc8xxx_spi->local_buf) { + ret = -ENOMEM ; + goto err_probe; + } + mpc8xxx_spi->reg_base =devm_ioremap_resource (dev, mem);if (IS_ERR (mpc8xxx_spi->reg_base)) { ret =PTR_ERR (mpc8xxx_spi->reg_base);
drivers/spi/spi-fsl-lib.h +1 -0
@@ -30,6 +30,7 @@ struct mpc8xxx_spi {void *rx;#if IS_ENABLED (CONFIG_SPI_FSL_ESPI )int len; +u8 *local_buf;#endif int subblock;
Signature · 7 lines
2.9.2 -- 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