Skip to content

Commit b7db04d

Browse files
computersforpeaceJeff Garzik
authored andcommitted
libata: implement ata_platform_remove_one()
This relatively simple boiler-plate code is repeated in several platform drivers. We should implement a common version in libata. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
1 parent 1896b15 commit b7db04d

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎drivers/ata/libata-core.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include <linux/cdrom.h>
6868
#include <linux/ratelimit.h>
6969
#include <linux/pm_runtime.h>
70+
#include <linux/platform_device.h>
7071

7172
#include "libata.h"
7273
#include "libata-transport.h"
@@ -6382,6 +6383,26 @@ int ata_pci_device_resume(struct pci_dev *pdev)
63826383

63836384
#endif /* CONFIG_PCI */
63846385

6386+
/**
6387+
* ata_platform_remove_one - Platform layer callback for device removal
6388+
* @pdev: Platform device that was removed
6389+
*
6390+
* Platform layer indicates to libata via this hook that hot-unplug or
6391+
* module unload event has occurred. Detach all ports. Resource
6392+
* release is handled via devres.
6393+
*
6394+
* LOCKING:
6395+
* Inherited from platform layer (may sleep).
6396+
*/
6397+
int ata_platform_remove_one(struct platform_device *pdev)
6398+
{
6399+
struct ata_host *host = platform_get_drvdata(pdev);
6400+
6401+
ata_host_detach(host);
6402+
6403+
return 0;
6404+
}
6405+
63856406
static int __init ata_parse_force_one(char **cur,
63866407
struct ata_force_ent *force_ent,
63876408
const char **reason)
@@ -6877,6 +6898,8 @@ EXPORT_SYMBOL_GPL(ata_pci_device_resume);
68776898
#endif /* CONFIG_PM */
68786899
#endif /* CONFIG_PCI */
68796900

6901+
EXPORT_SYMBOL_GPL(ata_platform_remove_one);
6902+
68806903
EXPORT_SYMBOL_GPL(__ata_ehi_push_desc);
68816904
EXPORT_SYMBOL_GPL(ata_ehi_push_desc);
68826905
EXPORT_SYMBOL_GPL(ata_ehi_clear_desc);

‎include/linux/libata.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,10 @@ extern int ata_pci_device_resume(struct pci_dev *pdev);
11151115
#endif /* CONFIG_PM */
11161116
#endif /* CONFIG_PCI */
11171117

1118+
struct platform_device;
1119+
1120+
extern int ata_platform_remove_one(struct platform_device *pdev);
1121+
11181122
/*
11191123
* ACPI - drivers/ata/libata-acpi.c
11201124
*/

0 commit comments

Comments
 (0)