From: David Zeuthen Date: Fri, 4 Dec 2009 21:03:56 +0000 (-0500) Subject: Export connector type on Port objects X-Git-Tag: upstream/2.1.2~712 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d2ffbc27e1bb1257c2c0b054f65f72e820858bff;p=platform%2Fupstream%2Fudisks2.git Export connector type on Port objects Also add a quirk for my CardBus based eSATA controller. --- diff --git a/data/80-udisks.rules b/data/80-udisks.rules index d7b7740..206e37a 100644 --- a/data/80-udisks.rules +++ b/data/80-udisks.rules @@ -5,6 +5,18 @@ # SUBSYSTEM=="pci", ACTION=="add|change", ENV{ID_MODEL_FROM_DATABASE}=="", ATTR{class}=="0x01*", IMPORT{program}="pci-db %p" +# Set eSATA port type for known eSATA CardBus adapters - first we want to ensure +# the device is on a cardbus controller (upper PCI device) - then we check +# vid/pid (lower PCI device) +# +SUBSYSTEM=="scsi_host", ATTRS{class}=="0x060700", GOTO="ata_port_cardbus" +GOTO="ata_port_cardbus_end" +LABEL="ata_port_cardbus" +# Mass storage controller: Silicon Image, Inc. SiI 3512 [SATALink/SATARaid] Serial ATA Controller (rev 01) +# +ATTRS{vendor}=="0x1095", ATTRS{device}=="0x3512", ENV{UDISKS_ATA_PORT_CONNECTOR_TYPE}="ata_sata_external" +LABEL="ata_port_cardbus_end" + # probe SAS expanders # # (hmm, this might be racy, we might not have the BSG device just yet - if diff --git a/data/org.freedesktop.UDisks.Port.xml b/data/org.freedesktop.UDisks.Port.xml index 8e4820f..eaf4a5f 100644 --- a/data/org.freedesktop.UDisks.Port.xml +++ b/data/org.freedesktop.UDisks.Port.xml @@ -62,6 +62,60 @@ + + + The connector type for the port (or for wide connectors, that the port is part of) or blank if unknown. + + + ataSome kind of ATA connector + + + ata_pataParallel ATA + + + ata_sataSerial ATA - not sure whether it's an internal or external port. + + + ata_sata_internalInternal Serial ATA + + + ata_sata_externalExternal Serial ATA + + + scsiSome kind of SCSI connector + + + scsi_sasSome kind of SAS connector + + + scsi_sas_internalSAS (SFF-8482) + + + scsi_sas_2xSAS connector with 2 lanes + + + scsi_sas_2x_widebandSAS Hi-Density with 2 lanes (SFF-8484) + + + scsi_sas_4xSome kind of SAS connector with 4 lanes + + + scsi_sas_4x_widebandSAS Hi-Density with 4 lanes (SFF-8484) + + + scsi_sas_4x_miniMini-SAS with 4 lanes (SFF-8087, iPass) + + + scsi_sas_4x_mini_externalExternal Mini-SAS with 4 lanes (SFF-8088) + + + scsi_sas_4x_infibandInfiniband with 4 lanes (SFF-8470) + + + TODO: include other connector types + + + diff --git a/src/daemon.c b/src/daemon.c index 6a8c7fa..6492734 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -1060,8 +1060,7 @@ _device_changed (Daemon *daemon, } void -daemon_local_synthesize_changed (Daemon *daemon, - Device *device) +daemon_local_synthesize_changed (Daemon *daemon, Device *device) { g_object_ref (device->priv->d); _device_changed (daemon, device->priv->d, TRUE); diff --git a/src/daemon.h b/src/daemon.h index 621e734..170fd21 100644 --- a/src/daemon.h +++ b/src/daemon.h @@ -124,8 +124,7 @@ gboolean daemon_local_get_uid (Daemon *daemon, void daemon_local_synthesize_changed_on_all_devices (Daemon *daemon); -void daemon_local_synthesize_changed (Daemon *daemon, - Device *device); +void daemon_local_synthesize_changed (Daemon *daemon, Device *device); void daemon_local_update_poller (Daemon *daemon); diff --git a/src/port-private.c b/src/port-private.c index 7b28cf4..b868b92 100644 --- a/src/port-private.c +++ b/src/port-private.c @@ -89,6 +89,18 @@ port_set_parent (Port *port, } void +port_set_connector_type (Port *port, + const gchar *value) +{ + if (G_UNLIKELY (g_strcmp0 (port->priv->connector_type, value) != 0)) + { + g_free (port->priv->connector_type); + port->priv->connector_type = g_strdup (value); + emit_changed (port, "connector_type"); + } +} + +void port_set_number (Port *port, gint value) { diff --git a/src/port-private.h b/src/port-private.h index e83d151..cc48376 100644 --- a/src/port-private.h +++ b/src/port-private.h @@ -58,6 +58,7 @@ struct PortPrivate gchar *adapter; gchar *parent; + gchar *connector_type; gint number; }; @@ -67,6 +68,8 @@ void port_set_adapter (Port *port, const gchar *value); void port_set_parent (Port *port, const gchar *value); +void port_set_connector_type (Port *port, + const gchar *value); void port_set_number (Port *port, gint value); diff --git a/src/port.c b/src/port.c index c202991..f52ae51 100644 --- a/src/port.c +++ b/src/port.c @@ -43,15 +43,11 @@ /*--------------------------------------------------------------------------------------------------------------*/ #include "port-glue.h" -static void -port_class_init (PortClass *klass); -static void -port_init (Port *seat); -static void -port_finalize (GObject *object); +static void port_class_init (PortClass *klass); +static void port_init (Port *seat); +static void port_finalize (GObject *object); -static gboolean -update_info (Port *port); +static gboolean update_info (Port *port); static void drain_pending_changes (Port *port, @@ -65,6 +61,7 @@ enum PROP_ADAPTER, PROP_PARENT, PROP_NUMBER, + PROP_CONNECTOR_TYPE, }; enum @@ -112,6 +109,10 @@ get_property (GObject *object, g_value_set_int (value, port->priv->number); break; + case PROP_CONNECTOR_TYPE: + g_value_set_string (value, port->priv->connector_type); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -162,6 +163,11 @@ port_class_init (PortClass *klass) G_MAXINT, -1, G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_CONNECTOR_TYPE, g_param_spec_string ("connector-type", + NULL, + NULL, + NULL, + G_PARAM_READABLE)); } static void @@ -197,6 +203,7 @@ port_finalize (GObject *object) /* free properties */ g_free (port->priv->adapter); g_free (port->priv->parent); + g_free (port->priv->connector_type); G_OBJECT_CLASS (port_parent_class)->finalize (object); } @@ -577,6 +584,8 @@ update_info_ata (Port *port, const gchar *basename; gint port_host_number; gint port_number; + const gchar *adapter_fabric; + const gchar *connector_type; ret = FALSE; port_number = -1; @@ -642,7 +651,28 @@ update_info_ata (Port *port, } } + /* Third, guess the connector type. + * + * This can be overriden via the udev property UDISKS_ATA_PORT_CONNECTOR_TYPE - + * see the data/80-udisks.rules for an example. + */ + connector_type = g_udev_device_get_property (port->priv->d, "UDISKS_ATA_PORT_CONNECTOR_TYPE"); + if (connector_type == NULL) + { + connector_type = "ata"; + adapter_fabric = adapter_local_get_fabric (adapter); + if (g_strcmp0 (adapter_fabric, "ata_pata") == 0) + { + connector_type = "ata_pata"; + } + else if (g_strcmp0 (adapter_fabric, "ata_sata") == 0) + { + connector_type = "ata_sata"; + } + } + port_set_number (port, port_number); + port_set_connector_type (port, connector_type); port->priv->port_type = PORT_TYPE_ATA; ret = TRUE; @@ -666,6 +696,9 @@ update_info_sas_phy (Port *port, port_number = g_udev_device_get_sysfs_attr_as_int (port->priv->d, "phy_identifier"); port_set_number (port, port_number); + /* We can't get it any more precise than this until we read SES-2 or SAS-2.0 info */ + port_set_connector_type (port, "scsi_sas"); + port->priv->port_type = PORT_TYPE_SAS; return TRUE;