]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
scsi: hisi_sas: add to_hisi_sas_port()
authorJohn Garry <john.garry@huawei.com>
Wed, 22 Mar 2017 17:25:17 +0000 (01:25 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 23 Mar 2017 15:12:01 +0000 (11:12 -0400)
Introduce function to get hisi_sas_port from asd_sas_port.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hisi_sas/hisi_sas.h
drivers/scsi/hisi_sas/hisi_sas_main.c
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c

index 9216deaa3ff5fb2db49cfd786ee809b9426633c7..a018a8afa8943a18e12f4909fe0024ec2d8aa610 100644 (file)
@@ -346,6 +346,8 @@ union hisi_sas_command_table {
        struct hisi_sas_command_table_smp smp;
        struct hisi_sas_command_table_stp stp;
 };
+
+extern struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port);
 extern int hisi_sas_probe(struct platform_device *pdev,
                          const struct hisi_sas_hw *ops);
 extern int hisi_sas_remove(struct platform_device *pdev);
index 53637a941b94a918d5dc5b15d519d5476c9ba195..11f32d2c436a9ff77d37088aaf80e1e967d71c29 100644 (file)
@@ -27,6 +27,12 @@ static struct hisi_hba *dev_to_hisi_hba(struct domain_device *device)
        return device->port->ha->lldd_ha;
 }
 
+struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port)
+{
+       return container_of(sas_port, struct hisi_sas_port, sas_port);
+}
+EXPORT_SYMBOL_GPL(to_hisi_sas_port);
+
 static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx)
 {
        void *bitmap = hisi_hba->slot_index_tags;
@@ -178,10 +184,11 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba,
        struct hisi_sas_port *port;
        struct hisi_sas_slot *slot;
        struct hisi_sas_cmd_hdr *cmd_hdr_base;
+       struct asd_sas_port *sas_port = device->port;
        struct device *dev = &hisi_hba->pdev->dev;
        int dlvry_queue_slot, dlvry_queue, n_elem = 0, rc, slot_idx;
 
-       if (!device->port) {
+       if (!sas_port) {
                struct task_status_struct *ts = &task->task_status;
 
                ts->resp = SAS_TASK_UNDELIVERED;
@@ -206,7 +213,8 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba,
                rc = SAS_PHY_DOWN;
                return rc;
        }
-       port = device->port->lldd_port;
+
+       port = to_hisi_sas_port(sas_port);
        if (port && !port->port_attached) {
                dev_info(dev, "task prep: %s port%d not attach device\n",
                         (sas_protocol_ata(task->task_proto)) ?
@@ -545,7 +553,7 @@ static void hisi_sas_port_notify_formed(struct asd_sas_phy *sas_phy)
        struct hisi_hba *hisi_hba = sas_ha->lldd_ha;
        struct hisi_sas_phy *phy = sas_phy->lldd_phy;
        struct asd_sas_port *sas_port = sas_phy->port;
-       struct hisi_sas_port *port = &hisi_hba->port[phy->port_id];
+       struct hisi_sas_port *port = to_hisi_sas_port(sas_port);
        unsigned long flags;
 
        if (!sas_port)
@@ -990,13 +998,14 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, u64 device_id,
        struct device *dev = &hisi_hba->pdev->dev;
        struct hisi_sas_port *port;
        struct hisi_sas_slot *slot;
+       struct asd_sas_port *sas_port = device->port;
        struct hisi_sas_cmd_hdr *cmd_hdr_base;
        int dlvry_queue_slot, dlvry_queue, n_elem = 0, rc, slot_idx;
 
        if (!device->port)
                return -1;
 
-       port = device->port->lldd_port;
+       port = to_hisi_sas_port(sas_port);
 
        /* simply get a slot and send abort command */
        rc = hisi_sas_slot_index_alloc(hisi_hba, &slot_idx);
index 854fbeaade3e9c3010f6d2aa18d790e6a2b75fc6..022ad10e102ccf3ac21df92b831454090db9cb51 100644 (file)
@@ -508,6 +508,8 @@ static void setup_itct_v1_hw(struct hisi_hba *hisi_hba,
        struct device *dev = &hisi_hba->pdev->dev;
        u64 qw0, device_id = sas_dev->device_id;
        struct hisi_sas_itct *itct = &hisi_hba->itct[device_id];
+       struct asd_sas_port *sas_port = device->port;
+       struct hisi_sas_port *port = to_hisi_sas_port(sas_port);
 
        memset(itct, 0, sizeof(*itct));
 
@@ -528,7 +530,7 @@ static void setup_itct_v1_hw(struct hisi_hba *hisi_hba,
                (1 << ITCT_HDR_AWT_CONTROL_OFF) |
                (device->max_linkrate << ITCT_HDR_MAX_CONN_RATE_OFF) |
                (1 << ITCT_HDR_VALID_LINK_NUM_OFF) |
-               (device->port->id << ITCT_HDR_PORT_ID_OFF));
+               (port->id << ITCT_HDR_PORT_ID_OFF));
        itct->qw0 = cpu_to_le64(qw0);
 
        /* qw1 */
index 1b214450dcb5df485c89ecfe723957b4d3ae55ae..1590e2f6ac66fe1cddbf2812bd08d8782d51b0c6 100644 (file)
@@ -676,7 +676,8 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba,
        u64 qw0, device_id = sas_dev->device_id;
        struct hisi_sas_itct *itct = &hisi_hba->itct[device_id];
        struct domain_device *parent_dev = device->parent;
-       struct hisi_sas_port *port = device->port->lldd_port;
+       struct asd_sas_port *sas_port = device->port;
+       struct hisi_sas_port *port = to_hisi_sas_port(sas_port);
 
        memset(itct, 0, sizeof(*itct));
 
@@ -1920,7 +1921,8 @@ static int prep_ata_v2_hw(struct hisi_hba *hisi_hba,
        struct domain_device *parent_dev = device->parent;
        struct hisi_sas_device *sas_dev = device->lldd_dev;
        struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr;
-       struct hisi_sas_port *port = device->port->lldd_port;
+       struct asd_sas_port *sas_port = device->port;
+       struct hisi_sas_port *port = to_hisi_sas_port(sas_port);
        u8 *buf_cmd;
        int has_data = 0, rc = 0, hdr_tag = 0;
        u32 dw1 = 0, dw2 = 0;