Commit f46faf97 authored by Xingui Yang's avatar Xingui Yang Committed by chenyi
Browse files

scsi: libsas: Move sas_add_parent_port() to sas_expander.c

mainline inclusion
from mainline-v6.10-rc1
commit 48032c0be6c7659f5019acd1403e17928dc27f52
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAWN9V

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=48032c0be6c7659f5019acd1403e17928dc27f52



----------------------------------------------------

Move sas_add_parent_port() to sas_expander.c and rename it to
sas_ex_add_parent_port() as it is only used in this file.

Signed-off-by: default avatarXingui Yang <yangxingui@huawei.com>
Link: https://lore.kernel.org/r/20240312141103.31358-3-yangxingui@huawei.com


Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarchenyi <chenyi211@huawei.com>
parent 7b91ddd4
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -33,6 +33,21 @@ static void sas_port_add_ex_phy(struct sas_port *port, struct ex_phy *ex_phy)
	ex_phy->phy_state = PHY_DEVICE_DISCOVERED;
}

static void sas_ex_add_parent_port(struct domain_device *dev, int phy_id)
{
	struct expander_device *ex = &dev->ex_dev;
	struct ex_phy *ex_phy = &ex->ex_phy[phy_id];

	if (!ex->parent_port) {
		ex->parent_port = sas_port_alloc(&dev->rphy->dev, phy_id);
		/* FIXME: error handling */
		BUG_ON(!ex->parent_port);
		BUG_ON(sas_port_add(ex->parent_port));
		sas_port_mark_backlink(ex->parent_port);
	}
	sas_port_add_phy(ex->parent_port, ex_phy->phy);
}

/* ---------- SMP task management ---------- */

static void smp_task_timedout(struct timer_list *t)
@@ -1039,12 +1054,12 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
	/* Parent and domain coherency */
	if (!dev->parent && (SAS_ADDR(ex_phy->attached_sas_addr) ==
			     SAS_ADDR(dev->port->sas_addr))) {
		sas_add_parent_port(dev, phy_id);
		sas_ex_add_parent_port(dev, phy_id);
		return 0;
	}
	if (dev->parent && (SAS_ADDR(ex_phy->attached_sas_addr) ==
			    SAS_ADDR(dev->parent->sas_addr))) {
		sas_add_parent_port(dev, phy_id);
		sas_ex_add_parent_port(dev, phy_id);
		if (ex_phy->routing_attr == TABLE_ROUTING)
			sas_configure_phy(dev, phy_id, dev->port->sas_addr, 1);
		return 0;
+0 −15
Original line number Diff line number Diff line
@@ -159,21 +159,6 @@ static inline void sas_phy_set_target(struct asd_sas_phy *p, struct domain_devic
	}
}

static inline void sas_add_parent_port(struct domain_device *dev, int phy_id)
{
	struct expander_device *ex = &dev->ex_dev;
	struct ex_phy *ex_phy = &ex->ex_phy[phy_id];

	if (!ex->parent_port) {
		ex->parent_port = sas_port_alloc(&dev->rphy->dev, phy_id);
		/* FIXME: error handling */
		BUG_ON(!ex->parent_port);
		BUG_ON(sas_port_add(ex->parent_port));
		sas_port_mark_backlink(ex->parent_port);
	}
	sas_port_add_phy(ex->parent_port, ex_phy->phy);
}

static inline struct domain_device *sas_alloc_device(void)
{
	struct domain_device *dev = kzalloc(sizeof(*dev), GFP_KERNEL);