[PATCH v7 2/5] IB/rxe: Reuse code which sets port state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Same code is executed in both rxe_param_set_add and rxe_notify functions.
Make one function and call it from both places.

Note that the code that checks validity of rxe object is omitted since
both callers already make sure it is valid.

Signed-off-by: Yuval Shaia <yuval.shaia@xxxxxxxxxx>
Reviewed-by: Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx> 
Reviewed-by: Bart Van Assche <bart.vanassche@xxxxxxx>
---
 drivers/infiniband/sw/rxe/rxe.h       |  1 +
 drivers/infiniband/sw/rxe/rxe_net.c   | 13 +++++++++----
 drivers/infiniband/sw/rxe/rxe_sysfs.c | 12 +-----------
 3 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe.h b/drivers/infiniband/sw/rxe/rxe.h
index 75e7113a756d..4ff33d921865 100644
--- a/drivers/infiniband/sw/rxe/rxe.h
+++ b/drivers/infiniband/sw/rxe/rxe.h
@@ -112,5 +112,6 @@ static inline struct rxe_dev *rxe_get_dev_from_net(struct net_device *ndev)
 
 void rxe_port_up(struct rxe_dev *rxe);
 void rxe_port_down(struct rxe_dev *rxe);
+void rxe_set_port_state(struct net_device *ndev, struct rxe_dev *rxe);
 
 #endif /* RXE_H */
diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
index c7637ad5e584..6a25b514d448 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -577,6 +577,14 @@ void rxe_port_down(struct rxe_dev *rxe)
 	dev_info(&rxe->ib_dev.dev, "set down\n");
 }
 
+void rxe_set_port_state(struct net_device *ndev, struct rxe_dev *rxe)
+{
+	if (netif_running(ndev) && netif_carrier_ok(ndev))
+		rxe_port_up(rxe);
+	else
+		rxe_port_down(rxe);
+}
+
 static int rxe_notify(struct notifier_block *not_blk,
 		      unsigned long event,
 		      void *arg)
@@ -603,10 +611,7 @@ static int rxe_notify(struct notifier_block *not_blk,
 		rxe_set_mtu(rxe, ndev->mtu);
 		break;
 	case NETDEV_CHANGE:
-		if (netif_running(ndev) && netif_carrier_ok(ndev))
-			rxe_port_up(rxe);
-		else
-			rxe_port_down(rxe);
+		rxe_set_port_state(ndev, rxe);
 		break;
 	case NETDEV_REBOOT:
 	case NETDEV_GOING_DOWN:
diff --git a/drivers/infiniband/sw/rxe/rxe_sysfs.c b/drivers/infiniband/sw/rxe/rxe_sysfs.c
index 87c17675cf9d..de9f51056f52 100644
--- a/drivers/infiniband/sw/rxe/rxe_sysfs.c
+++ b/drivers/infiniband/sw/rxe/rxe_sysfs.c
@@ -53,16 +53,6 @@ static int sanitize_arg(const char *val, char *intf, int intf_len)
 	return len;
 }
 
-static void rxe_set_port_state(struct rxe_dev *rxe, struct net_device *ndev)
-{
-	bool is_up = netif_running(ndev) && netif_carrier_ok(ndev);
-
-	if (is_up)
-		rxe_port_up(rxe);
-	else
-		rxe_port_down(rxe); /* down for unknown state */
-}
-
 static int rxe_param_set_add(const char *val, const struct kernel_param *kp)
 {
 	int len;
@@ -99,7 +89,7 @@ static int rxe_param_set_add(const char *val, const struct kernel_param *kp)
 		goto err;
 	}
 
-	rxe_set_port_state(rxe, ndev);
+	rxe_set_port_state(ndev, rxe);
 	dev_info(&rxe->ib_dev.dev, "added %s\n", intf);
 
 err:
-- 
1.8.3.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux