OSDN Git Service

spi: Add support for software nodes
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Wed, 3 Mar 2021 15:28:11 +0000 (18:28 +0300)
committerMark Brown <broonie@kernel.org>
Tue, 16 Mar 2021 13:29:41 +0000 (13:29 +0000)
Making it possible for the drivers to assign complete
software fwnodes to the devices instead of only the device
properties in those nodes.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20210303152814.35070-2-heikki.krogerus@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c
include/linux/spi/spi.h

index b08efe8..9b46998 100644 (file)
@@ -686,6 +686,15 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,
                }
        }
 
+       if (chip->swnode) {
+               status = device_add_software_node(&proxy->dev, chip->swnode);
+               if (status) {
+                       dev_err(&ctlr->dev, "failed to add softwade node to '%s': %d\n",
+                               chip->modalias, status);
+                       goto err_remove_props;
+               }
+       }
+
        status = spi_add_device(proxy);
        if (status < 0)
                goto err_remove_props;
@@ -693,8 +702,7 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,
        return proxy;
 
 err_remove_props:
-       if (chip->properties)
-               device_remove_properties(&proxy->dev);
+       device_remove_software_node(&proxy->dev);
 err_dev_put:
        spi_dev_put(proxy);
        return NULL;
@@ -719,6 +727,7 @@ void spi_unregister_device(struct spi_device *spi)
        }
        if (ACPI_COMPANION(&spi->dev))
                acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev));
+       device_remove_software_node(&spi->dev);
        device_unregister(&spi->dev);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_device);
index 592897f..f47f94e 100644 (file)
@@ -20,6 +20,7 @@
 
 struct dma_chan;
 struct property_entry;
+struct software_node;
 struct spi_controller;
 struct spi_transfer;
 struct spi_controller_mem_ops;
@@ -1409,7 +1410,8 @@ static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd)
  * @modalias: Initializes spi_device.modalias; identifies the driver.
  * @platform_data: Initializes spi_device.platform_data; the particular
  *     data stored there is driver-specific.
- * @properties: Additional device properties for the device.
+ * @properties: Deprecated - use software node instead.
+ * @swnode: Software node for the device.
  * @controller_data: Initializes spi_device.controller_data; some
  *     controllers need hints about hardware setup, e.g. for DMA.
  * @irq: Initializes spi_device.irq; depends on how the board is wired.
@@ -1448,6 +1450,7 @@ struct spi_board_info {
        char            modalias[SPI_NAME_SIZE];
        const void      *platform_data;
        const struct property_entry *properties;
+       const struct software_node *swnode;
        void            *controller_data;
        int             irq;