All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: valentina.manea.m@gmail.com, shuah@kernel.org,
	gregkh@linuxfoundation.org, keescook@chromium.org,
	peterz@infradead.org
Cc: Shuah Khan <skhan@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 10/13] usb: usbip/vhci: convert seqno to seqnum_ops
Date: Fri, 13 Nov 2020 10:46:12 -0700	[thread overview]
Message-ID: <8c22e939de78436afc6112d8022771121d438a83.1605287778.git.skhan@linuxfoundation.org> (raw)
In-Reply-To: <cover.1605287778.git.skhan@linuxfoundation.org>

Sequence Number api provides interfaces for unsigned atomic up counters
leveraging atomic_t and atomic64_t ops underneath. Convert it to use
seqnum_ops.

atomic_t variables used for stats are atomic counters. Convert them to
use seqnum_ops.

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
 drivers/usb/usbip/vhci.h     | 3 ++-
 drivers/usb/usbip/vhci_hcd.c | 7 ++++---
 drivers/usb/usbip/vhci_rx.c  | 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/usbip/vhci.h b/drivers/usb/usbip/vhci.h
index 5659dce1526e..cb76747f423b 100644
--- a/drivers/usb/usbip/vhci.h
+++ b/drivers/usb/usbip/vhci.h
@@ -15,6 +15,7 @@
 #include <linux/usb.h>
 #include <linux/usb/hcd.h>
 #include <linux/wait.h>
+#include <linux/seqnum_ops.h>
 
 struct vhci_device {
 	struct usb_device *udev;
@@ -108,7 +109,7 @@ struct vhci_hcd {
 	unsigned resuming:1;
 	unsigned long re_timeout;
 
-	atomic_t seqnum;
+	struct seqnum32 seqnum;
 
 	/*
 	 * NOTE:
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 66cde5e5f796..57287165537c 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/seqnum_ops.h>
 
 #include "usbip_common.h"
 #include "vhci.h"
@@ -665,7 +666,7 @@ static void vhci_tx_urb(struct urb *urb, struct vhci_device *vdev)
 
 	spin_lock_irqsave(&vdev->priv_lock, flags);
 
-	priv->seqnum = atomic_inc_return(&vhci_hcd->seqnum);
+	priv->seqnum = seqnum32_inc_return(&vhci_hcd->seqnum);
 	if (priv->seqnum == 0xffff)
 		dev_info(&urb->dev->dev, "seqnum max\n");
 
@@ -921,7 +922,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 			return -ENOMEM;
 		}
 
-		unlink->seqnum = atomic_inc_return(&vhci_hcd->seqnum);
+		unlink->seqnum = seqnum32_inc_return(&vhci_hcd->seqnum);
 		if (unlink->seqnum == 0xffff)
 			pr_info("seqnum max\n");
 
@@ -1181,7 +1182,7 @@ static int vhci_start(struct usb_hcd *hcd)
 		vdev->rhport = rhport;
 	}
 
-	atomic_set(&vhci_hcd->seqnum, 0);
+	seqnum32_init(&vhci_hcd->seqnum);
 
 	hcd->power_budget = 0; /* no limit */
 	hcd->uses_new_polling = 1;
diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
index 266024cbb64f..84620538093f 100644
--- a/drivers/usb/usbip/vhci_rx.c
+++ b/drivers/usb/usbip/vhci_rx.c
@@ -5,6 +5,7 @@
 
 #include <linux/kthread.h>
 #include <linux/slab.h>
+#include <linux/seqnum_ops.h>
 
 #include "usbip_common.h"
 #include "vhci.h"
@@ -66,9 +67,9 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
 	spin_unlock_irqrestore(&vdev->priv_lock, flags);
 
 	if (!urb) {
-		pr_err("cannot find a urb of seqnum %u max seqnum %d\n",
+		pr_err("cannot find a urb of seqnum %u max seqnum %u\n",
 			pdu->base.seqnum,
-			atomic_read(&vhci_hcd->seqnum));
+			seqnum32_fetch(&vhci_hcd->seqnum));
 		usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
 		return;
 	}
-- 
2.27.0


  parent reply	other threads:[~2020-11-13 17:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 17:46 [PATCH v2 00/13] Introduce seqnum_ops Shuah Khan
2020-11-13 17:46 ` [PATCH v2 01/13] seqnum_ops: Introduce Sequence Number Ops Shuah Khan
2020-11-13 21:03   ` Matthew Wilcox
2020-11-16 14:49     ` Peter Zijlstra
2020-11-16 14:58       ` Peter Zijlstra
2020-11-17 14:50         ` Shuah Khan
2020-11-17 15:21           ` Peter Zijlstra
2020-11-17 16:34     ` Shuah Khan
2020-11-17 17:38       ` Matthew Wilcox
2020-11-17 18:23         ` Shuah Khan
2020-11-17 18:24         ` Shuah Khan
2020-11-16 14:53   ` Peter Zijlstra
2020-11-17 16:15     ` Shuah Khan
2020-11-13 17:46 ` [PATCH v2 02/13] selftests: lib:test_seqnum_ops: add new test for seqnum_ops Shuah Khan
2020-11-13 17:46 ` [PATCH v2 03/13] drivers/acpi: convert seqno seqnum_ops Shuah Khan
2020-11-13 17:46 ` [PATCH v2 04/13] drivers/acpi/apei: convert seqno to seqnum_ops Shuah Khan
2020-11-13 17:46 ` [PATCH v2 05/13] drivers/base/test/test_async_driver_probe: convert to use seqnum_ops Shuah Khan
2020-11-13 17:46 ` [PATCH v2 06/13] drivers/char/ipmi: convert stats " Shuah Khan
2020-11-13 17:46 ` [PATCH v2 07/13] drivers/edac: convert pci counters to seqnum_ops Shuah Khan
2020-11-13 17:46 ` [PATCH v2 08/13] drivers/oprofile: convert stats to use seqnum_ops Shuah Khan
2020-11-13 17:46 ` [PATCH v2 09/13] drivers/staging/rtl8723bs: " Shuah Khan
2020-11-13 17:46   ` Shuah Khan
2020-11-13 17:46 ` Shuah Khan [this message]
2020-11-13 17:46 ` [PATCH v2 11/13] drivers/staging/rtl8188eu: " Shuah Khan
2020-11-13 17:46   ` Shuah Khan
2020-11-13 17:46 ` [PATCH v2 12/13] drivers/staging/unisys/visorhba: " Shuah Khan
2020-11-13 17:46   ` Shuah Khan
2020-11-13 17:46 ` [PATCH v2 13/13] security/integrity/ima: converts stats to seqnum_ops Shuah Khan
2020-11-14 16:11   ` kernel test robot
2020-11-14 16:11     ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c22e939de78436afc6112d8022771121d438a83.1605287778.git.skhan@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=shuah@kernel.org \
    --cc=valentina.manea.m@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.