]> www.infradead.org Git - users/hch/misc.git/commitdiff
scsi: pm80xx: Use dev_parent_is_expander() helper
authorNiklas Cassel <cassel@kernel.org>
Thu, 14 Aug 2025 17:32:22 +0000 (19:32 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 19 Aug 2025 02:08:30 +0000 (22:08 -0400)
Make use of the dev_parent_is_expander() helper.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Link: https://lore.kernel.org/r/20250814173215.1765055-19-cassel@kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Igor Pylypiv <ipylypiv@google.com>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/pm8001/pm8001_hwi.c
drivers/scsi/pm8001/pm8001_sas.c
drivers/scsi/pm8001/pm80xx_hwi.c

index 42a4eeac24c941c4477cd8799dd0641cc28ee0df..fb4913547b00fc9c2f44d7b5ac77188d16878ac2 100644 (file)
@@ -2163,8 +2163,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
        /* Print sas address of IO failed device */
        if ((status != IO_SUCCESS) && (status != IO_OVERFLOW) &&
                (status != IO_UNDERFLOW)) {
-               if (!((t->dev->parent) &&
-                       (dev_is_expander(t->dev->parent->dev_type)))) {
+               if (!dev_parent_is_expander(t->dev)) {
                        for (i = 0, j = 4; j <= 7 && i <= 3; i++, j++)
                                sata_addr_low[i] = pm8001_ha->sas_addr[j];
                        for (i = 0, j = 0; j <= 3 && i <= 3; i++, j++)
@@ -4168,7 +4167,6 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
        u16 firstBurstSize = 0;
        u16 ITNT = 2000;
        struct domain_device *dev = pm8001_dev->sas_device;
-       struct domain_device *parent_dev = dev->parent;
        struct pm8001_port *port = dev->port->lldd_port;
 
        memset(&payload, 0, sizeof(payload));
@@ -4186,8 +4184,8 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
                        dev_is_expander(pm8001_dev->dev_type))
                        stp_sspsmp_sata = 0x01; /*ssp or smp*/
        }
-       if (parent_dev && dev_is_expander(parent_dev->dev_type))
-               phy_id = parent_dev->ex_dev.ex_phy->phy_id;
+       if (dev_parent_is_expander(dev))
+               phy_id = dev->parent->ex_dev.ex_phy->phy_id;
        else
                phy_id = pm8001_dev->attached_phy;
        opc = OPC_INB_REG_DEV;
index 3e1dac4b820feaad4a6ada4184ce7ab460dedc79..2bdeace6c6bfeb3c031a7f3b1b9d85ed5f643ec9 100644 (file)
@@ -700,7 +700,7 @@ static int pm8001_dev_found_notify(struct domain_device *dev)
        dev->lldd_dev = pm8001_device;
        pm8001_device->dev_type = dev->dev_type;
        pm8001_device->dcompletion = &completion;
-       if (parent_dev && dev_is_expander(parent_dev->dev_type)) {
+       if (dev_parent_is_expander(dev)) {
                int phy_id;
 
                phy_id = sas_find_attached_phy_id(&parent_dev->ex_dev, dev);
@@ -749,7 +749,6 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)
        unsigned long flags = 0;
        struct pm8001_hba_info *pm8001_ha;
        struct pm8001_device *pm8001_dev = dev->lldd_dev;
-       struct domain_device *parent_dev = dev->parent;
 
        pm8001_ha = pm8001_find_ha_by_dev(dev);
        spin_lock_irqsave(&pm8001_ha->lock, flags);
@@ -771,7 +770,7 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)
                 * The phy array only contains local phys. Thus, we cannot clear
                 * phy_attached for a device behind an expander.
                 */
-               if (!(parent_dev && dev_is_expander(parent_dev->dev_type)))
+               if (!dev_parent_is_expander(dev))
                        pm8001_ha->phy[pm8001_dev->attached_phy].phy_attached = 0;
                pm8001_free_dev(pm8001_dev);
        } else {
index c1bae995a412844081682da71af96bec447ce7d7..546d0d26f7a1710e527311a2445665ea8b9bb2ca 100644 (file)
@@ -2340,8 +2340,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha,
        /* Print sas address of IO failed device */
        if ((status != IO_SUCCESS) && (status != IO_OVERFLOW) &&
                (status != IO_UNDERFLOW)) {
-               if (!((t->dev->parent) &&
-                       (dev_is_expander(t->dev->parent->dev_type)))) {
+               if (!dev_parent_is_expander(t->dev)) {
                        for (i = 0, j = 4; i <= 3 && j <= 7; i++, j++)
                                sata_addr_low[i] = pm8001_ha->sas_addr[j];
                        for (i = 0, j = 0; i <= 3 && j <= 3; i++, j++)
@@ -4780,7 +4779,6 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
        u16 firstBurstSize = 0;
        u16 ITNT = 2000;
        struct domain_device *dev = pm8001_dev->sas_device;
-       struct domain_device *parent_dev = dev->parent;
        struct pm8001_port *port = dev->port->lldd_port;
 
        memset(&payload, 0, sizeof(payload));
@@ -4799,8 +4797,8 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
                        dev_is_expander(pm8001_dev->dev_type))
                        stp_sspsmp_sata = 0x01; /*ssp or smp*/
        }
-       if (parent_dev && dev_is_expander(parent_dev->dev_type))
-               phy_id = parent_dev->ex_dev.ex_phy->phy_id;
+       if (dev_parent_is_expander(dev))
+               phy_id = dev->parent->ex_dev.ex_phy->phy_id;
        else
                phy_id = pm8001_dev->attached_phy;