[PATCH 2/2] libata: CONFIG_ATA_SYSFS_COMPAT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a config option 'ATA_SYSFS_COMPAT' to create a compability
'ata' symlink in the PCI device sysfs directory.

Signed-off-by: Hannes Reinecke <hare@xxxxxxx>
---
 drivers/ata/Kconfig            | 10 ++++++++++
 drivers/ata/libata-transport.c | 20 ++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index e5641e6c52ee..f27b12ba2ce7 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -51,6 +51,16 @@ config ATA_VERBOSE_ERROR
 
 	  If unsure, say Y.
 
+config ATA_SYSFS_COMPAT
+	bool "Keep original sysfs layout"
+	default y
+	help
+	  This option retains the original sysfs layout by adding an
+	  additional ata_port object with the name of 'ataX' in
+	  to the ATA objects like 'ata_port', 'ata_link', and 'ata_device'.
+
+	  If unsure, say Y.
+
 config ATA_FORCE
 	bool "\"libata.force=\" kernel parameter support" if EXPERT
 	default y
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
index 555fe6e2293d..a66c3480bdcf 100644
--- a/drivers/ata/libata-transport.c
+++ b/drivers/ata/libata-transport.c
@@ -260,7 +260,13 @@ static int ata_tport_match(struct attribute_container *cont,
 void ata_tport_delete(struct ata_port *ap)
 {
 	struct device *dev = &ap->tdev;
+#ifdef CONFIG_ATA_SYSFS_COMPAT
+	struct device *parent = dev->parent;
+	char compat_name[64];
 
+	sprintf(compat_name, "ata%d", ap->print_id);
+	sysfs_remove_link(&parent->kobj, compat_name);
+#endif
 	ata_tlink_delete(&ap->link);
 
 	transport_remove_device(dev);
@@ -284,6 +290,9 @@ int ata_tport_add(struct device *parent,
 {
 	int error;
 	struct device *dev = &ap->tdev;
+#ifdef CONFIG_ATA_SYSFS_COMPAT
+	char compat_name[64];
+#endif
 
 	device_initialize(dev);
 	dev->type = &ata_port_type;
@@ -313,8 +322,19 @@ int ata_tport_add(struct device *parent,
 	if (error) {
 		goto tport_link_err;
 	}
+
+#ifdef CONFIG_ATA_SYSFS_COMPAT
+	sprintf(compat_name, "ata%d", ap->print_id);
+	error = sysfs_create_link(&parent->kobj, &dev->kobj, compat_name);
+	if (error)
+		goto compat_link_err;
+#endif
 	return 0;
 
+#ifdef CONFIG_ATA_SYSFS_COMPAT
+ compat_link_err:
+	ata_tlink_delete(&ap->link);
+#endif
  tport_link_err:
 	transport_remove_device(dev);
 	device_del(dev);
-- 
2.29.2




[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux