@@ -410,29 +410,21 @@ static int spi_probe(struct device *dev)
410410{
411411 const struct spi_driver * sdrv = to_spi_driver (dev -> driver );
412412 struct spi_device * spi = to_spi_device (dev );
413+ struct fwnode_handle * fwnode = dev_fwnode (dev );
413414 int ret ;
414415
415416 ret = of_clk_set_defaults (dev -> of_node , false);
416417 if (ret )
417418 return ret ;
418419
419- if (dev -> of_node ) {
420+ if (is_of_node ( fwnode ))
420421 spi -> irq = of_irq_get (dev -> of_node , 0 );
421- if (spi -> irq == - EPROBE_DEFER )
422- return dev_err_probe (dev , - EPROBE_DEFER , "Failed to get irq\n" );
423- if (spi -> irq < 0 )
424- spi -> irq = 0 ;
425- }
426-
427- if (has_acpi_companion (dev ) && spi -> irq < 0 ) {
428- struct acpi_device * adev = to_acpi_device_node (dev -> fwnode );
429-
430- spi -> irq = acpi_dev_gpio_irq_get (adev , 0 );
431- if (spi -> irq == - EPROBE_DEFER )
432- return - EPROBE_DEFER ;
433- if (spi -> irq < 0 )
434- spi -> irq = 0 ;
435- }
422+ else if (is_acpi_device_node (fwnode ) && spi -> irq < 0 )
423+ spi -> irq = acpi_dev_gpio_irq_get (to_acpi_device_node (fwnode ), 0 );
424+ if (spi -> irq == - EPROBE_DEFER )
425+ return dev_err_probe (dev , spi -> irq , "Failed to get irq\n" );
426+ if (spi -> irq < 0 )
427+ spi -> irq = 0 ;
436428
437429 ret = dev_pm_domain_attach (dev , true);
438430 if (ret )
@@ -874,15 +866,18 @@ EXPORT_SYMBOL_GPL(spi_new_device);
874866 */
875867void spi_unregister_device (struct spi_device * spi )
876868{
869+ struct fwnode_handle * fwnode ;
870+
877871 if (!spi )
878872 return ;
879873
880- if (spi -> dev .of_node ) {
881- of_node_clear_flag (spi -> dev .of_node , OF_POPULATED );
882- of_node_put (spi -> dev .of_node );
874+ fwnode = dev_fwnode (& spi -> dev );
875+ if (is_of_node (fwnode )) {
876+ of_node_clear_flag (to_of_node (fwnode ), OF_POPULATED );
877+ of_node_put (to_of_node (fwnode ));
878+ } else if (is_acpi_device_node (fwnode )) {
879+ acpi_device_clear_enumerated (to_acpi_device_node (fwnode ));
883880 }
884- if (ACPI_COMPANION (& spi -> dev ))
885- acpi_device_clear_enumerated (ACPI_COMPANION (& spi -> dev ));
886881 device_remove_software_node (& spi -> dev );
887882 device_del (& spi -> dev );
888883 spi_cleanup (spi );
@@ -1059,7 +1054,7 @@ static void spi_toggle_csgpiod(struct spi_device *spi, u8 idx, bool enable, bool
10591054 * ambiguity. That's why we use enable, that takes SPI_CS_HIGH
10601055 * into account.
10611056 */
1062- if (has_acpi_companion ( & spi -> dev ))
1057+ if (is_acpi_device_node ( dev_fwnode ( & spi -> dev ) ))
10631058 gpiod_set_value_cansleep (spi_get_csgpiod (spi , idx ), !enable );
10641059 else
10651060 /* Polarity handled by GPIO library */
@@ -4841,7 +4836,7 @@ extern struct notifier_block spi_of_notifier;
48414836#if IS_ENABLED (CONFIG_ACPI )
48424837static int spi_acpi_controller_match (struct device * dev , const void * data )
48434838{
4844- return ACPI_COMPANION (dev -> parent ) == data ;
4839+ return device_match_acpi_dev (dev -> parent , data ) ;
48454840}
48464841
48474842struct spi_controller * acpi_spi_find_controller_by_adev (struct acpi_device * adev )
0 commit comments