diff mbox series

[v5,2/3] scsi: libsas: Move sas_add_parent_port() to sas_expander.c

Message ID 20231204122932.55741-3-yangxingui@huawei.com (mailing list archive)
State Changes Requested
Headers show
Series Fix the failure of adding phy with zero-address to port | expand

Commit Message

yangxingui Dec. 4, 2023, 12:29 p.m. UTC
Move sas_add_parent_port() to sas_expander.c since it is only used in this
file.

Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
 drivers/scsi/libsas/sas_expander.c | 15 +++++++++++++++
 drivers/scsi/libsas/sas_internal.h | 15 ---------------
 2 files changed, 15 insertions(+), 15 deletions(-)

Comments

John Garry Dec. 4, 2023, 1:17 p.m. UTC | #1
On 04/12/2023 12:29, Xingui Yang wrote:
> Move sas_add_parent_port() to sas_expander.c since it is only used in this
> file.
> 
> Signed-off-by: Xingui Yang <yangxingui@huawei.com>

Ignoring some comments, below:
Reviewed-by: John Garry <john.g.garry@oracle.com>

> ---
>   drivers/scsi/libsas/sas_expander.c | 15 +++++++++++++++
>   drivers/scsi/libsas/sas_internal.h | 15 ---------------
>   2 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
> index 1257f90130fb..7aa968b85e1e 100644
> --- a/drivers/scsi/libsas/sas_expander.c
> +++ b/drivers/scsi/libsas/sas_expander.c
> @@ -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_add_parent_port(struct domain_device *dev, int phy_id)

Can we have "_ex" in the name, like sas_ex_add_parent_port()

> +{
> +	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));

how about fixing these at some stage?

> +		sas_port_mark_backlink(ex->parent_port);
> +	}
> +	sas_port_add_phy(ex->parent_port, ex_phy->phy);
> +}
> +
>   /* ---------- SMP task management ---------- */
>   
>   /* Give it some long enough timeout. In seconds. */
> diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
> index 3804aef165ad..85948963fb97 100644
> --- a/drivers/scsi/libsas/sas_internal.h
> +++ b/drivers/scsi/libsas/sas_internal.h
> @@ -189,21 +189,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);
diff mbox series

Patch

diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 1257f90130fb..7aa968b85e1e 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -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_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 ---------- */
 
 /* Give it some long enough timeout. In seconds. */
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index 3804aef165ad..85948963fb97 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -189,21 +189,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);