linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH V2 #for-3.10] libata: export ata_port port_no attribute via /sys
  2013-05-14 18:48 [PATCH V2 #for-3.10] libata: export ata_port port_no attribute via /sys David Milburn
@ 2013-05-14 18:44 ` Tejun Heo
  2013-05-15  5:37 ` Hannes Reinecke
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2013-05-14 18:44 UTC (permalink / raw)
  To: David Milburn
  Cc: linux-ide, kay.sievers, coughlan, fengguang.wu, gwendal, hare

On Tue, May 14, 2013 at 01:48:40PM -0500, David Milburn wrote:
> 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.
> 
> # pwd
> /sys/devices/pci0000:00/0000:00:1f.2/ata8/ata_port/ata8
> # ll
> 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
> # cat port_no
> 1
> 
> Signed-off-by: David Milburn <dmilburn@redhat.com>

Applied to libata/for-3.11.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH V2 #for-3.10] libata: export ata_port port_no attribute via /sys
@ 2013-05-14 18:48 David Milburn
  2013-05-14 18:44 ` Tejun Heo
  2013-05-15  5:37 ` Hannes Reinecke
  0 siblings, 2 replies; 3+ messages in thread
From: David Milburn @ 2013-05-14 18:48 UTC (permalink / raw)
  To: tj; +Cc: linux-ide, kay.sievers, coughlan, fengguang.wu, gwendal, hare

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.

# pwd
/sys/devices/pci0000:00/0000:00:1f.2/ata8/ata_port/ata8
# ll
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
# cat port_no
1

Signed-off-by: David Milburn <dmilburn@redhat.com>
---

V2: Tejun suggested adding use case in commit message.

 drivers/ata/libata-core.c      |    6 ++++--
 drivers/ata/libata-transport.c |    4 +++-
 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 63c743b..5f7d5f9 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)
 	ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN;
 	ap->lock = &host->lock;
 	ap->print_id = -1;
+	ap->local_port_no = -1;
 	ap->host = host;
 	ap->dev = host->dev;
 
@@ -6126,9 +6127,10 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
 		kfree(host->ports[i]);
 
 	/* give ports names and add SCSI hosts */
-	for (i = 0; i < host->n_ports; i++)
+	for (i = 0; i < host->n_ports; i++) {
 		host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
-
+		host->ports[i]->local_port_no = i + 1;
+	}
 
 	/* Create associated sysfs transport objects  */
 	for (i = 0; i < host->n_ports; i++) {
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
index c04d393..077a856 100644
--- a/drivers/ata/libata-transport.c
+++ b/drivers/ata/libata-transport.c
@@ -37,7 +37,7 @@
 #include "libata.h"
 #include "libata-transport.h"
 
-#define ATA_PORT_ATTRS		2
+#define ATA_PORT_ATTRS		3
 #define ATA_LINK_ATTRS		3
 #define ATA_DEV_ATTRS		9
 
@@ -216,6 +216,7 @@ static DEVICE_ATTR(name, S_IRUGO, show_ata_port_##name, NULL)
 
 ata_port_simple_attr(nr_pmp_links, nr_pmp_links, "%d\n", int);
 ata_port_simple_attr(stats.idle_irq, idle_irq, "%ld\n", unsigned long);
+ata_port_simple_attr(local_port_no, port_no, "%u\n", unsigned int);
 
 static DECLARE_TRANSPORT_CLASS(ata_port_class,
 			       "ata_port", NULL, NULL, NULL);
@@ -709,6 +710,7 @@ struct scsi_transport_template *ata_attach_transport(void)
 	count = 0;
 	SETUP_PORT_ATTRIBUTE(nr_pmp_links);
 	SETUP_PORT_ATTRIBUTE(idle_irq);
+	SETUP_PORT_ATTRIBUTE(port_no);
 	BUG_ON(count > ATA_PORT_ATTRS);
 	i->port_attrs[count] = NULL;
 
diff --git a/include/linux/libata.h b/include/linux/libata.h
index eae7a05..47e0292 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -746,6 +746,7 @@ struct ata_port {
 	/* Flags that change dynamically, protected by ap->lock */
 	unsigned int		pflags; /* ATA_PFLAG_xxx */
 	unsigned int		print_id; /* user visible unique port ID */
+	unsigned int            local_port_no; /* host local port num */
 	unsigned int		port_no; /* 0 based port no. inside the host */
 
 #ifdef CONFIG_ATA_SFF

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2 #for-3.10] libata: export ata_port port_no attribute via /sys
  2013-05-14 18:48 [PATCH V2 #for-3.10] libata: export ata_port port_no attribute via /sys David Milburn
  2013-05-14 18:44 ` Tejun Heo
@ 2013-05-15  5:37 ` Hannes Reinecke
  1 sibling, 0 replies; 3+ messages in thread
From: Hannes Reinecke @ 2013-05-15  5:37 UTC (permalink / raw)
  To: David Milburn; +Cc: tj, linux-ide, kay.sievers, coughlan, fengguang.wu, gwendal

On 05/14/2013 08:48 PM, David Milburn wrote:
> 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.
> 
> # pwd
> /sys/devices/pci0000:00/0000:00:1f.2/ata8/ata_port/ata8
> # ll
> 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
> # cat port_no
> 1
> 
> Signed-off-by: David Milburn <dmilburn@redhat.com>
Acked-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-15  5:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-14 18:48 [PATCH V2 #for-3.10] libata: export ata_port port_no attribute via /sys David Milburn
2013-05-14 18:44 ` Tejun Heo
2013-05-15  5:37 ` Hannes Reinecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).