Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 32721
b: refs/heads/master
c: c9fefeb
h: refs/heads/master
i:
  32719: 01446fb
v: v3
  • Loading branch information
James Bottomley authored and James Bottomley committed Jul 9, 2006
1 parent d450db8 commit d69b28b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 24f6d2fd314f8580fcfd96391ce9689727d55572
refs/heads/master: c9fefeb26457b87f4a767faefcf77321bb90db52
36 changes: 35 additions & 1 deletion trunk/drivers/scsi/scsi_transport_sas.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct sas_host_attrs {
struct mutex lock;
u32 next_target_id;
u32 next_expander_id;
int next_port_id;
};
#define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data)

Expand Down Expand Up @@ -146,6 +147,7 @@ static int sas_host_setup(struct transport_container *tc, struct device *dev,
mutex_init(&sas_host->lock);
sas_host->next_target_id = 0;
sas_host->next_expander_id = 0;
sas_host->next_port_id = 0;
return 0;
}

Expand Down Expand Up @@ -327,7 +329,7 @@ sas_phy_protocol_attr(identify.target_port_protocols,
sas_phy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n",
unsigned long long);
sas_phy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8);
//sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", u8);
//sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", int);
sas_phy_linkspeed_attr(negotiated_linkrate);
sas_phy_linkspeed_attr(minimum_linkrate_hw);
sas_phy_linkspeed_attr(minimum_linkrate);
Expand Down Expand Up @@ -590,6 +592,38 @@ struct sas_port *sas_port_alloc(struct device *parent, int port_id)
}
EXPORT_SYMBOL(sas_port_alloc);

/** sas_port_alloc_num - allocate and initialize a SAS port structure
*
* @parent: parent device
*
* Allocates a SAS port structure and a number to go with it. This
* interface is really for adapters where the port number has no
* meansing, so the sas class should manage them. It will be added to
* the device tree below the device specified by @parent which must be
* either a Scsi_Host or a sas_expander_device.
*
* Returns %NULL on error
*/
struct sas_port *sas_port_alloc_num(struct device *parent)
{
int index;
struct Scsi_Host *shost = dev_to_shost(parent);
struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);

/* FIXME: use idr for this eventually */
mutex_lock(&sas_host->lock);
if (scsi_is_sas_expander_device(parent)) {
struct sas_rphy *rphy = dev_to_rphy(parent);
struct sas_expander_device *exp = rphy_to_expander_device(rphy);

index = exp->next_port_id++;
} else
index = sas_host->next_port_id++;
mutex_unlock(&sas_host->lock);
return sas_port_alloc(parent, index);
}
EXPORT_SYMBOL(sas_port_alloc_num);

/**
* sas_port_add - add a SAS port to the device hierarchy
*
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/scsi/scsi_transport_sas.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ struct sas_end_device {

struct sas_expander_device {
int level;
int next_port_id;

#define SAS_EXPANDER_VENDOR_ID_LEN 8
char vendor_id[SAS_EXPANDER_VENDOR_ID_LEN+1];
Expand All @@ -127,7 +128,7 @@ struct sas_expander_device {
struct sas_port {
struct device dev;

u8 port_identifier;
int port_identifier;
int num_phys;

/* the other end of the link */
Expand Down Expand Up @@ -168,6 +169,7 @@ extern void sas_rphy_delete(struct sas_rphy *);
extern int scsi_is_sas_rphy(const struct device *);

struct sas_port *sas_port_alloc(struct device *, int);
struct sas_port *sas_port_alloc_num(struct device *);
int sas_port_add(struct sas_port *);
void sas_port_free(struct sas_port *);
void sas_port_delete(struct sas_port *);
Expand Down

0 comments on commit d69b28b

Please sign in to comment.