]> www.infradead.org Git - users/hch/misc.git/commitdiff
Bluetooth: MGMT: convert timeouts to secs_to_jiffies()
authorEaswar Hariharan <eahariha@linux.microsoft.com>
Wed, 19 Feb 2025 22:51:30 +0000 (22:51 +0000)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 25 Mar 2025 16:40:15 +0000 (12:40 -0400)
Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced
secs_to_jiffies().  As the value here is a multiple of 1000, use
secs_to_jiffies() instead of msecs_to_jiffies to avoid the multiplication.

This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with
the following Coccinelle rules:

@depends on patch@
expression E;
@@

-msecs_to_jiffies(E * 1000)
+secs_to_jiffies(E)

-msecs_to_jiffies(E * MSEC_PER_SEC)
+secs_to_jiffies(E)

Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_sync.c
net/bluetooth/mgmt.c

index dd770ef5ec36840add2fa0549aa1689135a21e4c..a43749aebf76e83f3541deb346015c5e5a620eda 100644 (file)
@@ -1910,7 +1910,7 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
                hdev->adv_instance_timeout = timeout;
                queue_delayed_work(hdev->req_workqueue,
                                   &hdev->adv_instance_expire,
-                                  msecs_to_jiffies(timeout * 1000));
+                                  secs_to_jiffies(timeout));
        }
 
        /* If we're just re-scheduling the same instance again then do not
index 12835e5054bedd9efcda87c0022e6993c522a550..4fd30ba243be5fb8b68188c8fd9d1235fd24e1d2 100644 (file)
@@ -1533,7 +1533,7 @@ static void mgmt_set_discoverable_complete(struct hci_dev *hdev, void *data,
 
        if (hci_dev_test_flag(hdev, HCI_DISCOVERABLE) &&
            hdev->discov_timeout > 0) {
-               int to = msecs_to_jiffies(hdev->discov_timeout * 1000);
+               int to = secs_to_jiffies(hdev->discov_timeout);
                queue_delayed_work(hdev->req_workqueue, &hdev->discov_off, to);
        }
 
@@ -1641,7 +1641,7 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
                hdev->discov_timeout = timeout;
 
                if (cp->val && hdev->discov_timeout > 0) {
-                       int to = msecs_to_jiffies(hdev->discov_timeout * 1000);
+                       int to = secs_to_jiffies(hdev->discov_timeout);
                        queue_delayed_work(hdev->req_workqueue,
                                           &hdev->discov_off, to);
                }
@@ -2534,7 +2534,7 @@ static int send_hci_cmd_sync(struct hci_dev *hdev, void *data)
        skb = __hci_cmd_sync_ev(hdev, le16_to_cpu(cp->opcode),
                                le16_to_cpu(cp->params_len), cp->params,
                                cp->event, cp->timeout ?
-                               msecs_to_jiffies(cp->timeout * 1000) :
+                               secs_to_jiffies(cp->timeout) :
                                HCI_CMD_TIMEOUT);
        if (IS_ERR(skb)) {
                mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_HCI_CMD_SYNC,