Re: [PATCH -next 1/2] spi: introduce devm_spi_alloc_controller()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2022/9/28 4:22, Mark Brown wrote:
On Tue, Sep 27, 2022 at 10:19:01PM +0200, Lukas Wunner wrote:
On Tue, Sep 27, 2022 at 06:01:39PM +0100, Mark Brown wrote:
On Tue, Sep 27, 2022 at 03:31:29PM +0200, Lukas Wunner wrote:
On Tue, Sep 27, 2022 at 07:57:05PM +0800, Yang Yingliang wrote:
Do you mean to introduce two more proper wrappers to instead of
devm_spi_alloc_master/slave() ?
Honestly I don't think there's room for (or a need for) improvement here.
The issue here is that we're trying to get rid of the master/slave
terminology.
Converting drivers to use spi_controller everywhere in lieu of
spi_master is fine, but drivers need to specify whether the
spi_controller is a master or a slave and Geert's design is
to specify that on allocation.  Which makes sense because
that's the moment the spi_controller comes to life, there's
no earlier moment where one could specify the type.
Sure, but since the current wrappers use the legacy names this means
that we need new wrappers with more modern names hence there is
something to improve here.

How about using primary/secondary, introduce two wrappers like this:

diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h

index 6ea889df0813..c41654fb069b 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -778,6 +778,21 @@ static inline struct spi_controller *devm_spi_alloc_slave(struct device *dev,
     return __devm_spi_alloc_controller(dev, size, true);
 }

+static inline struct spi_controller *devm_spi_alloc_primary(struct device *dev,
+                                unsigned int size)
+{
+    return __devm_spi_alloc_controller(dev, size, false);
+}
+
+static inline struct spi_controller *devm_spi_alloc_secondary(struct device *dev,
+                                  unsigned int size)
+{
+    if (!IS_ENABLED(CONFIG_SPI_SLAVE))
+        return NULL;
+
+    return __devm_spi_alloc_controller(dev, size, true);
+}
+
 extern int spi_register_controller(struct spi_controller *ctlr);
 extern int devm_spi_register_controller(struct device *dev,
                     struct spi_controller *ctlr);

Thanks,
Yang



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux