Commit b87ee307 authored by Dan Williams's avatar Dan Williams

isci: cleanup remote device construction and comments

The construction routines scic_remote_device_[de]a_construct both reference
the need to call scic_remote_device_construct first.  Delete that comment and
just have them call it explicitly, also:
* move the comments from header to source
* delete dead references to scic_[de]a_remote_device_add_phy
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 88f3b62a
...@@ -1438,15 +1438,14 @@ static const struct sci_base_state scic_sds_remote_device_state_table[] = { ...@@ -1438,15 +1438,14 @@ static const struct sci_base_state scic_sds_remote_device_state_table[] = {
}; };
/** /**
* scic_remote_device_construct() - This method will perform the construction * scic_remote_device_construct() - common construction
* common to all remote device objects.
* @sci_port: SAS/SATA port through which this device is accessed. * @sci_port: SAS/SATA port through which this device is accessed.
* @sci_dev: remote device to construct * @sci_dev: remote device to construct
* *
* It isn't necessary to call scic_remote_device_destruct() for device objects * This routine just performs benign initialization and does not
* that have only called this method for construction. Once subsequent * allocate the remote_node_context which is left to
* construction methods have been invoked (e.g. * scic_remote_device_[de]a_construct(). scic_remote_device_destruct()
* scic_remote_device_da_construct()), then destruction should occur. none * frees the remote_node_context(s) for the device.
*/ */
static void scic_remote_device_construct(struct scic_sds_port *sci_port, static void scic_remote_device_construct(struct scic_sds_port *sci_port,
struct scic_sds_remote_device *sci_dev) struct scic_sds_remote_device *sci_dev)
...@@ -1473,32 +1472,28 @@ static void scic_remote_device_construct(struct scic_sds_port *sci_port, ...@@ -1473,32 +1472,28 @@ static void scic_remote_device_construct(struct scic_sds_port *sci_port,
} }
/** /**
* scic_remote_device_da_construct() - This method will construct a * scic_remote_device_da_construct() - construct direct attached device.
* SCIC_REMOTE_DEVICE object for a direct attached (da) device. The *
* information (e.g. IAF, Signature FIS, etc.) necessary to build the device * The information (e.g. IAF, Signature FIS, etc.) necessary to build
* is known to the SCI Core since it is contained in the scic_phy object. * the device is known to the SCI Core since it is contained in the
* @remote_device: This parameter specifies the remote device to be destructed. * scic_phy object. Remote node context(s) is/are a global resource
* * allocated by this routine, freed by scic_remote_device_destruct().
* The user must have previously called scic_remote_device_construct() Remote *
* device objects are a limited resource. As such, they must be protected. * Returns:
* Thus calls to construct and destruct are mutually exclusive and * SCI_FAILURE_DEVICE_EXISTS - device has already been constructed.
* non-reentrant. Indicate if the remote device was successfully constructed. * SCI_FAILURE_UNSUPPORTED_PROTOCOL - e.g. sas device attached to
* SCI_SUCCESS Returned if the device was successfully constructed. * sata-only controller instance.
* SCI_FAILURE_DEVICE_EXISTS Returned if the device has already been * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted.
* constructed. If it's an additional phy for the target, then call
* scic_remote_device_da_add_phy(). SCI_FAILURE_UNSUPPORTED_PROTOCOL Returned
* if the supplied parameters necessitate creation of a remote device for which
* the protocol is not supported by the underlying controller hardware.
* SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if the core
* controller associated with the supplied parameters is unable to support
* additional remote devices.
*/ */
static enum sci_status scic_remote_device_da_construct(struct scic_sds_remote_device *sci_dev) static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci_port,
struct scic_sds_remote_device *sci_dev)
{ {
enum sci_status status; enum sci_status status;
u16 remote_node_index; u16 remote_node_index;
struct sci_sas_identify_address_frame_protocols protocols; struct sci_sas_identify_address_frame_protocols protocols;
scic_remote_device_construct(sci_port, sci_dev);
/* /*
* This information is request to determine how many remote node context * This information is request to determine how many remote node context
* entries will be needed to store the remote node. * entries will be needed to store the remote node.
...@@ -1567,34 +1562,26 @@ static void scic_sds_remote_device_get_info_from_smp_discover_response( ...@@ -1567,34 +1562,26 @@ static void scic_sds_remote_device_get_info_from_smp_discover_response(
} }
/** /**
* scic_remote_device_ea_construct() - This method will construct an * scic_remote_device_ea_construct() - construct expander attached device
* SCIC_REMOTE_DEVICE object for an expander attached (ea) device from an * @discover_response: data to build remote device
* SMP Discover Response. *
* @remote_device: This parameter specifies the remote device to be destructed. * Remote node context(s) is/are a global resource allocated by this
* @discover_response: This parameter specifies the SMP Discovery Response to * routine, freed by scic_remote_device_destruct().
* be used in device creation. *
* * Returns:
* The user must have previously called scic_remote_device_construct() Remote * SCI_FAILURE_DEVICE_EXISTS - device has already been constructed.
* device objects are a limited resource. As such, they must be protected. * SCI_FAILURE_UNSUPPORTED_PROTOCOL - e.g. sas device attached to
* Thus calls to construct and destruct are mutually exclusive and * sata-only controller instance.
* non-reentrant. Indicate if the remote device was successfully constructed. * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted.
* SCI_SUCCESS Returned if the device was successfully constructed.
* SCI_FAILURE_DEVICE_EXISTS Returned if the device has already been
* constructed. If it's an additional phy for the target, then call
* scic_ea_remote_device_add_phy(). SCI_FAILURE_UNSUPPORTED_PROTOCOL Returned
* if the supplied parameters necessitate creation of a remote device for which
* the protocol is not supported by the underlying controller hardware.
* SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if the core
* controller associated with the supplied parameters is unable to support
* additional remote devices.
*/ */
static enum sci_status scic_remote_device_ea_construct(struct scic_sds_remote_device *sci_dev, static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci_port,
struct scic_sds_remote_device *sci_dev,
struct smp_response_discover *discover_response) struct smp_response_discover *discover_response)
{ {
struct scic_sds_controller *scic = sci_port->owning_controller;
enum sci_status status; enum sci_status status;
struct scic_sds_controller *scic;
scic = scic_sds_port_get_controller(sci_dev->owning_port); scic_remote_device_construct(sci_port, sci_dev);
scic_sds_remote_device_get_info_from_smp_discover_response( scic_sds_remote_device_get_info_from_smp_discover_response(
sci_dev, discover_response); sci_dev, discover_response);
...@@ -1632,9 +1619,8 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_remote_de ...@@ -1632,9 +1619,8 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_remote_de
* physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay
* one another, so this code works for both situations. */ * one another, so this code works for both situations. */
sci_dev->connection_rate = min_t(u16, sci_dev->connection_rate = min_t(u16,
scic_sds_port_get_max_allowed_speed(sci_dev->owning_port), scic_sds_port_get_max_allowed_speed(sci_port),
discover_response->u2.sas1_1.negotiated_physical_link_rate discover_response->u2.sas1_1.negotiated_physical_link_rate);
);
/* / @todo Should I assign the port width by reading all of the phys on the port? */ /* / @todo Should I assign the port width by reading all of the phys on the port? */
sci_dev->device_port_width = 1; sci_dev->device_port_width = 1;
...@@ -1678,11 +1664,6 @@ static enum sci_status isci_remote_device_construct( ...@@ -1678,11 +1664,6 @@ static enum sci_status isci_remote_device_construct(
{ {
enum sci_status status = SCI_SUCCESS; enum sci_status status = SCI_SUCCESS;
/* let the core do it's common constuction. */
scic_remote_device_construct(port->sci_port_handle,
&isci_device->sci);
/* let the core do it's device specific constuction. */
if (isci_device->domain_dev->parent && if (isci_device->domain_dev->parent &&
(isci_device->domain_dev->parent->dev_type == EDGE_DEV)) { (isci_device->domain_dev->parent->dev_type == EDGE_DEV)) {
int i; int i;
...@@ -1746,11 +1727,13 @@ static enum sci_status isci_remote_device_construct( ...@@ -1746,11 +1727,13 @@ static enum sci_status isci_remote_device_construct(
"%s: parent->dev_type = EDGE_DEV\n", "%s: parent->dev_type = EDGE_DEV\n",
__func__); __func__);
status = scic_remote_device_ea_construct(&isci_device->sci, status = scic_remote_device_ea_construct(port->sci_port_handle,
&isci_device->sci,
(struct smp_response_discover *)&discover_response); (struct smp_response_discover *)&discover_response);
} else } else
status = scic_remote_device_da_construct(&isci_device->sci); status = scic_remote_device_da_construct(port->sci_port_handle,
&isci_device->sci);
if (status != SCI_SUCCESS) { if (status != SCI_SUCCESS) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment