Commit f261172d authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mark Brown

spi: bitbang: Use typedef for txrx_*() callbacks

With a typedef for the txrx_*() callbacks the code looks neater.
Note that typedef for a function is okay to have.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://msgid.link/r/20240517194104.747328-2-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f44b3730
...@@ -38,26 +38,19 @@ ...@@ -38,26 +38,19 @@
* working quickly, or testing for differences that aren't speed related. * 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 { struct spi_bitbang_cs {
unsigned nsecs; /* (clock cycle time)/2 */ unsigned nsecs; /* (clock cycle time)/2 */
u32 (*txrx_word)(struct spi_device *spi, unsigned nsecs, spi_bb_txrx_word_fn txrx_word;
u32 word, u8 bits, unsigned flags); spi_bb_txrx_bufs_fn txrx_bufs;
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);
}; };
static unsigned bitbang_txrx_8( static unsigned bitbang_txrx_8(
struct spi_device *spi, struct spi_device *spi,
u32 (*txrx_word)(struct spi_device *spi, spi_bb_txrx_word_fn txrx_word,
unsigned nsecs,
u32 word, u8 bits,
unsigned flags),
unsigned ns, unsigned ns,
struct spi_transfer *t, struct spi_transfer *t,
unsigned flags unsigned flags
...@@ -83,10 +76,7 @@ static unsigned bitbang_txrx_8( ...@@ -83,10 +76,7 @@ static unsigned bitbang_txrx_8(
static unsigned bitbang_txrx_16( static unsigned bitbang_txrx_16(
struct spi_device *spi, struct spi_device *spi,
u32 (*txrx_word)(struct spi_device *spi, spi_bb_txrx_word_fn txrx_word,
unsigned nsecs,
u32 word, u8 bits,
unsigned flags),
unsigned ns, unsigned ns,
struct spi_transfer *t, struct spi_transfer *t,
unsigned flags unsigned flags
...@@ -112,10 +102,7 @@ static unsigned bitbang_txrx_16( ...@@ -112,10 +102,7 @@ static unsigned bitbang_txrx_16(
static unsigned bitbang_txrx_32( static unsigned bitbang_txrx_32(
struct spi_device *spi, struct spi_device *spi,
u32 (*txrx_word)(struct spi_device *spi, spi_bb_txrx_word_fn txrx_word,
unsigned nsecs,
u32 word, u8 bits,
unsigned flags),
unsigned ns, unsigned ns,
struct spi_transfer *t, struct spi_transfer *t,
unsigned flags unsigned flags
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
typedef u32 (*spi_bb_txrx_word_fn)(struct spi_device *, unsigned int, u32, u8, unsigned int);
struct spi_bitbang { struct spi_bitbang {
struct mutex lock; struct mutex lock;
u8 busy; u8 busy;
...@@ -28,9 +30,8 @@ struct spi_bitbang { ...@@ -28,9 +30,8 @@ struct spi_bitbang {
int (*txrx_bufs)(struct spi_device *spi, struct spi_transfer *t); int (*txrx_bufs)(struct spi_device *spi, struct spi_transfer *t);
/* txrx_word[SPI_MODE_*]() just looks like a shift register */ /* txrx_word[SPI_MODE_*]() just looks like a shift register */
u32 (*txrx_word[4])(struct spi_device *spi, spi_bb_txrx_word_fn txrx_word[4];
unsigned nsecs,
u32 word, u8 bits, unsigned flags);
int (*set_line_direction)(struct spi_device *spi, bool output); int (*set_line_direction)(struct spi_device *spi, bool output);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment