diff options
author | David Milburn <dmilburn@redhat.com> | 2013-05-14 14:48:40 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-05-14 14:44:07 -0400 |
commit | e628dc999e43a9dd51fb6bd810772c277f934484 (patch) | |
tree | d950d81c8a2351ae0f12cc5cb45a7f6222dadc98 | |
parent | f722406faae2d073cc1d01063d1123c35425939e (diff) |
libata: export ata_port port_no attribute via /sys
While registering host controller track port number based upon number
of ports available on the controller, export port_no attribute through
/sys. This patch is needed by udev for composing persistent links in
/dev/disk/by-path.
/sys/devices/pci0000:00/0000:00:1f.2/ata8/ata_port/ata8
total 0
lrwxrwxrwx. 1 root root 0 Mar 6 12:43 device -> ../../../ata8
-r--r--r--. 1 root root 4096 Mar 6 12:43 idle_irq
-r--r--r--. 1 root root 4096 Mar 6 12:43 nr_pmp_links
-r--r--r--. 1 root root 4096 Mar 6 12:43 port_no
drwxr-xr-x. 2 root root 0 Mar 6 12:42 power
lrwxrwxrwx. 1 root root 0 Mar 6 12:41 subsystem -> ../../../../../../class/ata_port
-rw-r--r--. 1 root root 4096 Mar 6 12:40 uevent
1
Signed-off-by: David Milburn <dmilburn@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r-- | drivers/ata/libata-core.c | 6 | ||||
-rw-r--r-- | drivers/ata/libata-transport.c | 4 | ||||
-rw-r--r-- | include/linux/libata.h | 1 |
3 files changed, 8 insertions, 3 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 63c743baf920..5f7d5f9ee820 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -5636,6 +5636,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host) | |||
5636 | ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN; | 5636 | ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN; |
5637 | ap->lock = &host->lock; | 5637 | ap->lock = &host->lock; |
5638 | ap->print_id = -1; | 5638 | ap->print_id = -1; |
5639 | ap->local_port_no = -1; | ||
5639 | ap->host = host; | 5640 | ap->host = host; |
5640 | ap->dev = host->dev; | 5641 | ap->dev = host->dev; |
5641 | 5642 | ||
@@ -6126,9 +6127,10 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
6126 | kfree(host->ports[i]); | 6127 | kfree(host->ports[i]); |
6127 | 6128 | ||
6128 | /* give ports names and add SCSI hosts */ | 6129 | /* give ports names and add SCSI hosts */ |
6129 | for (i = 0; i < host->n_ports; i++) | 6130 | for (i = 0; i < host->n_ports; i++) { |
6130 | host->ports[i]->print_id = atomic_inc_return(&ata_print_id); | 6131 | host->ports[i]->print_id = atomic_inc_return(&ata_print_id); |
6131 | 6132 | host->ports[i]->local_port_no = i + 1; | |
6133 | } | ||
6132 | 6134 | ||
6133 | /* Create associated sysfs transport objects */ | 6135 | /* Create associated sysfs transport objects */ |
6134 | for (i = 0; i < host->n_ports; i++) { | 6136 | for (i = 0; i < host->n_ports; i++) { |
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c index c04d393d20c1..077a856f5fd0 100644 --- a/drivers/ata/libata-transport.c +++ b/drivers/ata/libata-transport.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include "libata.h" | 37 | #include "libata.h" |
38 | #include "libata-transport.h" | 38 | #include "libata-transport.h" |
39 | 39 | ||
40 | #define ATA_PORT_ATTRS 2 | 40 | #define ATA_PORT_ATTRS 3 |
41 | #define ATA_LINK_ATTRS 3 | 41 | #define ATA_LINK_ATTRS 3 |
42 | #define ATA_DEV_ATTRS 9 | 42 | #define ATA_DEV_ATTRS 9 |
43 | 43 | ||
@@ -216,6 +216,7 @@ static DEVICE_ATTR(name, S_IRUGO, show_ata_port_##name, NULL) | |||
216 | 216 | ||
217 | ata_port_simple_attr(nr_pmp_links, nr_pmp_links, "%d\n", int); | 217 | ata_port_simple_attr(nr_pmp_links, nr_pmp_links, "%d\n", int); |
218 | ata_port_simple_attr(stats.idle_irq, idle_irq, "%ld\n", unsigned long); | 218 | ata_port_simple_attr(stats.idle_irq, idle_irq, "%ld\n", unsigned long); |
219 | ata_port_simple_attr(local_port_no, port_no, "%u\n", unsigned int); | ||
219 | 220 | ||
220 | static DECLARE_TRANSPORT_CLASS(ata_port_class, | 221 | static DECLARE_TRANSPORT_CLASS(ata_port_class, |
221 | "ata_port", NULL, NULL, NULL); | 222 | "ata_port", NULL, NULL, NULL); |
@@ -709,6 +710,7 @@ struct scsi_transport_template *ata_attach_transport(void) | |||
709 | count = 0; | 710 | count = 0; |
710 | SETUP_PORT_ATTRIBUTE(nr_pmp_links); | 711 | SETUP_PORT_ATTRIBUTE(nr_pmp_links); |
711 | SETUP_PORT_ATTRIBUTE(idle_irq); | 712 | SETUP_PORT_ATTRIBUTE(idle_irq); |
713 | SETUP_PORT_ATTRIBUTE(port_no); | ||
712 | BUG_ON(count > ATA_PORT_ATTRS); | 714 | BUG_ON(count > ATA_PORT_ATTRS); |
713 | i->port_attrs[count] = NULL; | 715 | i->port_attrs[count] = NULL; |
714 | 716 | ||
diff --git a/include/linux/libata.h b/include/linux/libata.h index eae7a053dc51..47e029236f6e 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -746,6 +746,7 @@ struct ata_port { | |||
746 | /* Flags that change dynamically, protected by ap->lock */ | 746 | /* Flags that change dynamically, protected by ap->lock */ |
747 | unsigned int pflags; /* ATA_PFLAG_xxx */ | 747 | unsigned int pflags; /* ATA_PFLAG_xxx */ |
748 | unsigned int print_id; /* user visible unique port ID */ | 748 | unsigned int print_id; /* user visible unique port ID */ |
749 | unsigned int local_port_no; /* host local port num */ | ||
749 | unsigned int port_no; /* 0 based port no. inside the host */ | 750 | unsigned int port_no; /* 0 based port no. inside the host */ |
750 | 751 | ||
751 | #ifdef CONFIG_ATA_SFF | 752 | #ifdef CONFIG_ATA_SFF |