Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: add devm_spi_new_ancillary_device()

Merge series from Antoniu Miclaus <antoniu.miclaus@analog.com>:

Add a devres-managed version of spi_new_ancillary_device() that
automatically unregisters the ancillary SPI device when the parent
device is removed.

+41
+40
drivers/spi/spi.c
··· 2747 2747 } 2748 2748 EXPORT_SYMBOL_GPL(spi_new_ancillary_device); 2749 2749 2750 + static void devm_spi_unregister_device(void *spi) 2751 + { 2752 + spi_unregister_device(spi); 2753 + } 2754 + 2755 + /** 2756 + * devm_spi_new_ancillary_device() - Register managed ancillary SPI device 2757 + * @spi: Pointer to the main SPI device registering the ancillary device 2758 + * @chip_select: Chip Select of the ancillary device 2759 + * 2760 + * Register an ancillary SPI device; for example some chips have a chip-select 2761 + * for normal device usage and another one for setup/firmware upload. 2762 + * 2763 + * This is the managed version of spi_new_ancillary_device(). The ancillary 2764 + * device will be unregistered automatically when the parent SPI device is 2765 + * unregistered. 2766 + * 2767 + * This may only be called from main SPI device's probe routine. 2768 + * 2769 + * Return: Pointer to new ancillary device on success; ERR_PTR on failure 2770 + */ 2771 + struct spi_device *devm_spi_new_ancillary_device(struct spi_device *spi, 2772 + u8 chip_select) 2773 + { 2774 + struct spi_device *ancillary; 2775 + int ret; 2776 + 2777 + ancillary = spi_new_ancillary_device(spi, chip_select); 2778 + if (IS_ERR(ancillary)) 2779 + return ancillary; 2780 + 2781 + ret = devm_add_action_or_reset(&spi->dev, devm_spi_unregister_device, 2782 + ancillary); 2783 + if (ret) 2784 + return ERR_PTR(ret); 2785 + 2786 + return ancillary; 2787 + } 2788 + EXPORT_SYMBOL_GPL(devm_spi_new_ancillary_device); 2789 + 2750 2790 #ifdef CONFIG_ACPI 2751 2791 struct acpi_spi_lookup { 2752 2792 struct spi_controller *ctlr;
+1
include/linux/spi/spi.h
··· 387 387 } 388 388 389 389 extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 chip_select); 390 + extern struct spi_device *devm_spi_new_ancillary_device(struct spi_device *spi, u8 chip_select); 390 391 391 392 /* Use a define to avoid include chaining to get THIS_MODULE */ 392 393 #define spi_register_driver(driver) \