spi: introduce new helpers with using modern naming
PATCH 1/1 spi: introduce new helpers with using modern naming
For using modern names host/target to instead of all the legacy names, I think it takes 3 steps:
- step1: introduce new helpers with modern naming.
- step2: switch to use these new helpers in all drivers.
- step3: remove all legacy helpers and update all legacy names.
This patch is for step1, it introduces new helpers with host/target naming for drivers using.
--- drivers/spi/spi.c | 11 +++++++++++ include/linux/spi/spi.h | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)
drivers/spi/spi.c +11 -0
@@ -2692,6 +2692,17 @@ int spi_slave_abort(struct spi_device *spi) }EXPORT_SYMBOL_GPL (spi_slave_abort); +int spi_target_abort (struct spi_device *spi) +{ +struct spi_controller *ctlr = spi->controller; + +if (spi_controller_is_target (ctlr) && ctlr->target_abort) +return ctlr->target_abort (ctlr); + +return -ENOTSUPP ; +} +EXPORT_SYMBOL_GPL (spi_target_abort); +static ssize_t slave_show (struct device *dev,struct device_attribute *attr,char *buf) {
include/linux/spi/spi.h +41 -0
89 lines not on this page · raw message
Signature · 1 line
2.25.1
Hi Yang,
Quoted 10 lines · Yang Yingliang
For using modern names host/target to instead of all the legacy names, I think it takes 3 steps:
- step1: introduce new helpers with modern naming.
- step2: switch to use these new helpers in all drivers.
- step3: remove all legacy helpers and update all legacy names.This patch is for step1, it introduces new helpers with host/target naming for drivers using.
Signed-off-by Yang Yingliang <[email protected]>
Thanks for your patch!
Quoted 19 lines
include/linux/spi/spi.h +2
-0@@ -356,6 +356,7 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch* @max_speed_hz: Highest supported transfer speed * @flags: other constraints relevant to this driver * @slave: indicates that this is an SPI slave controller +* @target: indicates that this is an SPI target controller * @devm_allocated: whether the allocation of this struct is devres-managed * @max_transfer_size: function that returns the max transfer size for * a &spi_device; may be %NULL, so the default %SIZE_MAX will be used. @@ -438,6 +439,7 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch* @mem_caps: controller capabilities for the handling of memory operations. * @unprepare_message: undo any work done by prepare_message(). * @slave_abort: abort the ongoing transfer request on an SPI slave controller +* @target_abort: abort the ongoing transfer request on an SPI target controller * @cs_gpiods: Array of GPIO descs to use as chip select lines; one per CS * number. Any individual value may be NULL for CS lines that * are not GPIOs (driven by the SPI controller itself).
include/linux/spi/spi.h struct spi_controller { · line 541
Quoted 5 lines
include/linux/spi/spi.h +2
-0@@ -535,6 +537,8 @@ struct spi_controller {/* Flag indicating this is an SPI slave controller */ bool slave; +/* Flag indicating this is an SPI target controller */ +bool target;
To avoid subtle breakage when accessing these fields directly, this should be a union:
union {
bool slave;
bool target;
};include/linux/spi/spi.h struct spi_controller { · line 544
Quoted 3 lines
include/linux/spi/spi.h +0
-0/* * on some hardware transfer / message size may be constrained
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi,
Quoted 42 lines · Geert Uytterhoeven
Hi Yang,
Quoted 10 lines · Yang Yingliang
For using modern names host/target to instead of all the legacy names, I think it takes 3 steps:
- step1: introduce new helpers with modern naming.
- step2: switch to use these new helpers in all drivers.
- step3: remove all legacy helpers and update all legacy names.This patch is for step1, it introduces new helpers with host/target naming for drivers using.
Signed-off-by Yang Yingliang <[email protected]>Thanks for your patch!
Quoted 19 lines
include/linux/spi/spi.h +2
-0@@ -356,6 +356,7 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch* @max_speed_hz: Highest supported transfer speed * @flags: other constraints relevant to this driver * @slave: indicates that this is an SPI slave controller +* @target: indicates that this is an SPI target controller * @devm_allocated: whether the allocation of this struct is devres-managed * @max_transfer_size: function that returns the max transfer size for * a &spi_device; may be %NULL, so the default %SIZE_MAX will be used. @@ -438,6 +439,7 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch* @mem_caps: controller capabilities for the handling of memory operations. * @unprepare_message: undo any work done by prepare_message(). * @slave_abort: abort the ongoing transfer request on an SPI slave controller +* @target_abort: abort the ongoing transfer request on an SPI target controller * @cs_gpiods: Array of GPIO descs to use as chip select lines; one per CS * number. Any individual value may be NULL for CS lines that * are not GPIOs (driven by the SPI controller itself). include/linux/spi/spi.h struct spi_controller { · line 541
Quoted 5 lines
include/linux/spi/spi.h +2
-0@@ -535,6 +537,8 @@ struct spi_controller {/* Flag indicating this is an SPI slave controller */ bool slave; +/* Flag indicating this is an SPI target controller */ +bool target;To avoid subtle breakage when accessing these fields directly, this should be a union:
Quoted 4 lines
union {
bool slave;
bool target;
};Yes, we should initialize the 'target' member. I will change it in v2.
Thanks,
Yang
Quoted 14 lines
include/linux/spi/spi.h struct spi_controller { · line 544
Quoted 2 lines
include/linux/spi/spi.h +0
-0/* * on some hardware transfer / message size may be constrained Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds.