A few cleanups to the driver. No functional change intended.
Andy Shevchenko (3):
spi: bitbang: Use typedef for txrx_*() callbacks
spi: bitbang: Convert unsigned to unsigned int
spi: bitbang: Replace hard coded number of SPI modes
drivers/spi/spi-bitbang.c | 73 ++++++++++++---------------------
include/linux/spi/spi_bitbang.h | 7 ++--
2 files changed, 31 insertions(+), 49 deletions(-)
--
2.43.0.rc1.1336.g36b5255a03ac
With a typedef for the txrx_*() callbacks the code looks neater.
Note that typedef for a function is okay to have.
Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/spi/spi-bitbang.c | 31 +++++++++----------------------
include/linux/spi/spi_bitbang.h | 7 ++++---
2 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c
index ca5cc67555c5..d88110acdc5f 100644
--- a/drivers/spi/spi-bitbang.c
+++ b/drivers/spi/spi-bitbang.c
@@ -38,26 +38,19 @@
* working quickly, or testing for differences that aren't speed related.
*/
+typedef unsigned int (*spi_bb_txrx_bufs_fn)(struct spi_device *, spi_bb_txrx_word_fn,
+ unsigned int, struct spi_transfer *,
+ unsigned int);
+
struct spi_bitbang_cs {
unsigned nsecs; /* (clock cycle time)/2 */
- u32 (*txrx_word)(struct spi_device *spi, unsigned nsecs,
- u32 word, u8 bits, unsigned flags);
- unsigned (*txrx_bufs)(struct spi_device *,
- u32 (*txrx_word)(
- struct spi_device *spi,
- unsigned nsecs,
- u32 word, u8 bits,
- unsigned flags),
- unsigned, struct spi_transfer *,
- unsigned);
+ spi_bb_txrx_word_fn txrx_word;
+ spi_bb_txrx_bufs_fn txrx_bufs;
};
static unsigned bitbang_txrx_8(
struct spi_device *spi,
- u32 (*txrx_word)(struct spi_device *spi,
- unsigned nsecs,
- u32 word, u8 bits,
- unsigned flags),
+ spi_bb_txrx_word_fn txrx_word,
unsigned ns,
struct spi_transfer *t,
unsigned flags
@@ -83,10 +76,7 @@ static unsigned bitbang_txrx_8(
static unsigned bitbang_txrx_16(
struct spi_device *spi,
- u32 (*txrx_word)(struct spi_device *spi,
- unsigned nsecs,
- u32 word, u8 bits,
- unsigned flags),
+ spi_bb_txrx_word_fn txrx_word,
unsigned ns,
struct spi_transfer *t,
unsigned flags
@@ -112,10 +102,7 @@ static unsigned bitbang_txrx_16(
static unsigned bitbang_txrx_32(
struct spi_device *spi,
- u32 (*txrx_word)(struct spi_device *spi,
- unsigned nsecs,
- u32 word, u8 bits,
- unsigned flags),
+ spi_bb_txrx_word_fn txrx_word,
unsigned ns,
struct spi_transfer *t,
unsigned flags
diff --git a/include/linux/spi/spi_bitbang.h b/include/linux/spi/spi_bitbang.h
index b930eca2ef7b..7ca08b430ed5 100644
--- a/include/linux/spi/spi_bitbang.h
+++ b/include/linux/spi/spi_bitbang.h
@@ -4,6 +4,8 @@
#include <linux/workqueue.h>
+typedef u32 (*spi_bb_txrx_word_fn)(struct spi_device *, unsigned int, u32, u8, unsigned int);
+
struct spi_bitbang {
struct mutex lock;
u8 busy;
@@ -28,9 +30,8 @@ struct spi_bitbang {
int (*txrx_bufs)(struct spi_device *spi, struct spi_transfer *t);
/* txrx_word[SPI_MODE_*]() just looks like a shift register */
- u32 (*txrx_word[4])(struct spi_device *spi,
- unsigned nsecs,
- u32 word, u8 bits, unsigned flags);
+ spi_bb_txrx_word_fn txrx_word[4];
+
int (*set_line_direction)(struct spi_device *spi, bool output);
};
--
2.43.0.rc1.1336.g36b5255a03ac
Simple type conversion with no functional change implied.
While at it, adjust indentation where it makes sense.
Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/spi/spi-bitbang.c | 42 +++++++++++++++++----------------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c
index d88110acdc5f..afb1b1105ec2 100644
--- a/drivers/spi/spi-bitbang.c
+++ b/drivers/spi/spi-bitbang.c
@@ -43,21 +43,19 @@ typedef unsigned int (*spi_bb_txrx_bufs_fn)(struct spi_device *, spi_bb_txrx_wor
unsigned int);
struct spi_bitbang_cs {
- unsigned nsecs; /* (clock cycle time)/2 */
+ unsigned int nsecs; /* (clock cycle time) / 2 */
spi_bb_txrx_word_fn txrx_word;
spi_bb_txrx_bufs_fn txrx_bufs;
};
-static unsigned bitbang_txrx_8(
- struct spi_device *spi,
+static unsigned int bitbang_txrx_8(struct spi_device *spi,
spi_bb_txrx_word_fn txrx_word,
- unsigned ns,
+ unsigned int ns,
struct spi_transfer *t,
- unsigned flags
-)
+ unsigned int flags)
{
- unsigned bits = t->bits_per_word;
- unsigned count = t->len;
+ unsigned int bits = t->bits_per_word;
+ unsigned int count = t->len;
const u8 *tx = t->tx_buf;
u8 *rx = t->rx_buf;
@@ -74,16 +72,14 @@ static unsigned bitbang_txrx_8(
return t->len - count;
}
-static unsigned bitbang_txrx_16(
- struct spi_device *spi,
+static unsigned int bitbang_txrx_16(struct spi_device *spi,
spi_bb_txrx_word_fn txrx_word,
- unsigned ns,
+ unsigned int ns,
struct spi_transfer *t,
- unsigned flags
-)
+ unsigned int flags)
{
- unsigned bits = t->bits_per_word;
- unsigned count = t->len;
+ unsigned int bits = t->bits_per_word;
+ unsigned int count = t->len;
const u16 *tx = t->tx_buf;
u16 *rx = t->rx_buf;
@@ -100,16 +96,14 @@ static unsigned bitbang_txrx_16(
return t->len - count;
}
-static unsigned bitbang_txrx_32(
- struct spi_device *spi,
+static unsigned int bitbang_txrx_32(struct spi_device *spi,
spi_bb_txrx_word_fn txrx_word,
- unsigned ns,
+ unsigned int ns,
struct spi_transfer *t,
- unsigned flags
-)
+ unsigned int flags)
{
- unsigned bits = t->bits_per_word;
- unsigned count = t->len;
+ unsigned int bits = t->bits_per_word;
+ unsigned int count = t->len;
const u32 *tx = t->tx_buf;
u32 *rx = t->rx_buf;
@@ -221,7 +215,7 @@ EXPORT_SYMBOL_GPL(spi_bitbang_cleanup);
static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
{
struct spi_bitbang_cs *cs = spi->controller_state;
- unsigned nsecs = cs->nsecs;
+ unsigned int nsecs = cs->nsecs;
struct spi_bitbang *bitbang;
bitbang = spi_controller_get_devdata(spi->controller);
@@ -234,7 +228,7 @@ static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
}
if (spi->mode & SPI_3WIRE) {
- unsigned flags;
+ unsigned int flags;
flags = t->tx_buf ? SPI_CONTROLLER_NO_RX : SPI_CONTROLLER_NO_TX;
return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t, flags);
--
2.43.0.rc1.1336.g36b5255a03ac
Instead of using hard coded number of modes, replace it with
SPI_MODE_X_MASK + 1 to show relation to the SPI modes.
Signed-off-by: Andy Shevchenko <[email protected]>
---
include/linux/spi/spi_bitbang.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/spi/spi_bitbang.h b/include/linux/spi/spi_bitbang.h
index 7ca08b430ed5..d4cb83195f7a 100644
--- a/include/linux/spi/spi_bitbang.h
+++ b/include/linux/spi/spi_bitbang.h
@@ -30,7 +30,7 @@ struct spi_bitbang {
int (*txrx_bufs)(struct spi_device *spi, struct spi_transfer *t);
/* txrx_word[SPI_MODE_*]() just looks like a shift register */
- spi_bb_txrx_word_fn txrx_word[4];
+ spi_bb_txrx_word_fn txrx_word[SPI_MODE_X_MASK + 1];
int (*set_line_direction)(struct spi_device *spi, bool output);
};
--
2.43.0.rc1.1336.g36b5255a03ac
On Fri, May 17, 2024 at 10:40:19PM +0300, Andy Shevchenko wrote:
> A few cleanups to the driver. No functional change intended.
>
> Andy Shevchenko (3):
> spi: bitbang: Use typedef for txrx_*() callbacks
> spi: bitbang: Convert unsigned to unsigned int
> spi: bitbang: Replace hard coded number of SPI modes
Hmm... It's not the first time I noticed that the series
(despite even appearing in the CI, but then disappearing)
left abandoned without clear feedback,
Should I do something here?
--
With Best Regards,
Andy Shevchenko
On Thu, Jun 06, 2024 at 12:07:14AM +0300, Andy Shevchenko wrote:
> On Fri, May 17, 2024 at 10:40:19PM +0300, Andy Shevchenko wrote:
> > A few cleanups to the driver. No functional change intended.
> >
> > Andy Shevchenko (3):
> > spi: bitbang: Use typedef for txrx_*() callbacks
> > spi: bitbang: Convert unsigned to unsigned int
> > spi: bitbang: Replace hard coded number of SPI modes
>
> Hmm... It's not the first time I noticed that the series
> (despite even appearing in the CI, but then disappearing)
> left abandoned without clear feedback,
> Should I do something here?
Please don't send content free pings and please allow a reasonable time
for review. People get busy, go on holiday, attend conferences and so
on so unless there is some reason for urgency (like critical bug fixes)
please allow at least a couple of weeks for review. If there have been
review comments then people may be waiting for those to be addressed.
Sending content free pings adds to the mail volume (if they are seen at
all) which is often the problem and since they can't be reviewed
directly if something has gone wrong you'll have to resend the patches
anyway, so sending again is generally a better approach though there are
some other maintainers who like them - if in doubt look at how patches
for the subsystem are normally handled.
On Wed, Jun 05, 2024 at 10:21:35PM +0100, Mark Brown wrote:
> On Thu, Jun 06, 2024 at 12:07:14AM +0300, Andy Shevchenko wrote:
> > On Fri, May 17, 2024 at 10:40:19PM +0300, Andy Shevchenko wrote:
> > > A few cleanups to the driver. No functional change intended.
> > >
> > > Andy Shevchenko (3):
> > > spi: bitbang: Use typedef for txrx_*() callbacks
> > > spi: bitbang: Convert unsigned to unsigned int
> > > spi: bitbang: Replace hard coded number of SPI modes
> >
> > Hmm... It's not the first time I noticed that the series
> > (despite even appearing in the CI, but then disappearing)
> > left abandoned without clear feedback,
>
> > Should I do something here?
Okay, it's just an announce is missing.
I found them in the repository. Thanks!
--
With Best Regards,
Andy Shevchenko