@@ -598,6 +598,12 @@ EXPORT_SYMBOL_GPL(spi_alloc_device);
static void spi_dev_set_name(struct spi_device *spi)
{
struct acpi_device *adev = ACPI_COMPANION(&spi->dev);
+ struct fwnode_handle *fwnode = dev_fwnode(&spi->dev);
+
+ if (spi->use_fwnode_name && fwnode) {
+ dev_set_name(&spi->dev, "spi-%s", fwnode_get_name(fwnode));
+ return;
+ }
if (adev) {
dev_set_name(&spi->dev, "spi-%s", acpi_dev_name(adev));
@@ -830,6 +836,7 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,
* spi->cs_index_mask as 0x01.
*/
proxy->cs_index_mask = 0x01;
+ proxy->use_fwnode_name = chip->use_fwnode_name;
if (chip->swnode) {
status = device_add_software_node(&proxy->dev, chip->swnode);
@@ -222,6 +222,7 @@ struct spi_device {
struct spi_delay cs_setup;
struct spi_delay cs_hold;
struct spi_delay cs_inactive;
+ bool use_fwnode_name;
/* The statistics */
struct spi_statistics __percpu *pcpu_statistics;
@@ -1608,6 +1609,7 @@ struct spi_board_info {
char modalias[SPI_NAME_SIZE];
const void *platform_data;
const struct software_node *swnode;
+ bool use_fwnode_name;
void *controller_data;
int irq;
Add a mechanism to force the use of the fwnode name for the name of the SPI device itself. This is useful when devices need to be manually added within the kernel. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> --- drivers/spi/spi.c | 7 +++++++ include/linux/spi/spi.h | 2 ++ 2 files changed, 9 insertions(+)