From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53CC3C197A0 for ; Mon, 20 Nov 2023 16:18:36 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 81F2DE0E; Mon, 20 Nov 2023 17:17:44 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 81F2DE0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1700497114; bh=tJmQqOQ9JthaexzNbKAtvsYq2RSg1QnwuHNN76E+htA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=VEPcP0VQsPbWgO7f3g+Q5E61kV5IhJ9ELvwiNxjDPqqlD5mRYODqtsqnlxlf5O/5X 2WB0lPVTW7Ia+FKoLB9II2YsbqEq2sDtNLEv2XTNzV6dxkR1Zt918DMNKd5nqKwE6K Q6L5Bva53tqowBphpZ55k/ROyuAYexEsCxCQe/lQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B185AF805B1; Mon, 20 Nov 2023 17:16:28 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 16DE2F805B0; Mon, 20 Nov 2023 17:16:28 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5A972F801D5; Sat, 18 Nov 2023 16:52:00 +0100 (CET) Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AA933F80093 for ; Sat, 18 Nov 2023 16:51:55 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AA933F80093 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=iFI79q4B Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-5ac376d311aso32139847b3.1 for ; Sat, 18 Nov 2023 07:51:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700322713; x=1700927513; darn=alsa-project.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pqvvn3jC6Vz8bzOhTQHPcM8ndCOZ4pDWuw3ZxWJvphM=; b=iFI79q4BWQIp9TWtkqVNG9vMw1EMvWUK+j+58N1qJlbofx+ws+us1DraTyeSXwHqAD Irl6GM64FpJAvGaMs7Bsf4URMOcQ275SmJ8bltroh74VCDXvrUHr5OfpyjULC6GcOpNF kyfXFxGGrojxTQs5L/I/rccDQihJ1+C2fIOcNUfmTTX6FYcx+M7LaVqaDsImg8ykPNm3 SK87I5l86UipYJs47TPF5l+CLyArsAbVUQDQp8fLH4VZs+iTytQRr0cEWVpx48VxIM4o qpVpYtd0Duh/QgXr7+zOk4KhmE9YWB95VZ9X+vPMTgOODGHdOC84ezTUhyb7gIhzcVen Zqtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700322713; x=1700927513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pqvvn3jC6Vz8bzOhTQHPcM8ndCOZ4pDWuw3ZxWJvphM=; b=Q0kUdGPPoDLLIlMD+90zzKU1ksEEZDhcFkKHuZm0CkumSHYRMmSoVSLIK9uJhe5kzp 7y/UFfAkbiYoPqX9GA/Z+BmyWm3vD5Xf7tni3qW1xBY71TnOvsoVpit/A4kOdu/9aZNj SpGF4kfsnreJWkq2Y8zHfZ7xX27ziwrKLARVO/Y+3iBLjfWM0aejJZptvCG3NyOabHeX MPCOKrZSAnWorMBLvkjFi+RFB3fGvabLUTmG5MCKp+SP7AwAPR4lu33MjsEYoa6l2RqA 0AeHXCwb5TFmnNNEQMCb3ZOsaF5X3U5H0uhIkRBSaEm4+Gffjbk7F61YaCwYqAD8Ov7o pWPQ== X-Gm-Message-State: AOJu0YwG0TPLBdAtqX+ZfBluek1wA5j2TYCvlc0mmYA+cfG1YoG2fbvz 5UqVrmGhGohnYxY7AAa4oBA= X-Google-Smtp-Source: AGHT+IHi1UfS8eoFXkfozWsLdq/Iqyn0m7FQM2MTep2E1EPNYtNXp8LEwhBmcZHJxn/bgTZr34eiJg== X-Received: by 2002:a81:f202:0:b0:5c9:9097:6427 with SMTP id i2-20020a81f202000000b005c990976427mr546580ywm.44.1700322713616; Sat, 18 Nov 2023 07:51:53 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:48a9:bd4c:868d:dc97]) by smtp.gmail.com with ESMTPSA id b65-20020a0dd944000000b005a8c392f498sm1167875ywe.82.2023.11.18.07.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 07:51:52 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, Jaroslav Kysela , Takashi Iwai , Daniel Mack , Cezary Rojewski , Kai Vehmanen , Yury Norov , Kees Cook , linux-sound@vger.kernel.org, alsa-devel@alsa-project.org Cc: Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov Subject: [PATCH 30/34] ALSA: use atomic find_bit() functions where applicable Date: Sat, 18 Nov 2023 07:51:01 -0800 Message-Id: <20231118155105.25678-31-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231118155105.25678-1-yury.norov@gmail.com> References: <20231118155105.25678-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MailFrom: yury.norov@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: KBUDORW3AAX4NLASHHPXO2RL2XISIZPB X-Message-ID-Hash: KBUDORW3AAX4NLASHHPXO2RL2XISIZPB X-Mailman-Approved-At: Mon, 20 Nov 2023 16:16:23 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: ALSA code tests each bit in bitmaps in a for() loop. Switch it to dedicated atomic find_bit() API. Signed-off-by: Yury Norov --- sound/pci/hda/hda_codec.c | 7 +++---- sound/usb/caiaq/audio.c | 13 +++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 01718b1fc9a7..29254005f394 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3275,10 +3275,9 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type) #ifdef CONFIG_SND_DYNAMIC_MINORS /* non-fixed slots starting from 10 */ - for (i = 10; i < 32; i++) { - if (!test_and_set_bit(i, bus->pcm_dev_bits)) - return i; - } + i = find_and_set_next_bit(bus->pcm_dev_bits, 32, 10); + if (i < 32) + return i; #endif dev_warn(bus->card->dev, "Too many %s devices\n", diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 4981753652a7..74dfcf32b439 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c @@ -610,7 +610,7 @@ static void read_completed(struct urb *urb) struct snd_usb_caiaq_cb_info *info = urb->context; struct snd_usb_caiaqdev *cdev; struct device *dev; - struct urb *out = NULL; + struct urb *out; int i, frame, len, send_it = 0, outframe = 0; unsigned long flags; size_t offset = 0; @@ -625,17 +625,14 @@ static void read_completed(struct urb *urb) return; /* find an unused output urb that is unused */ - for (i = 0; i < N_URBS; i++) - if (test_and_set_bit(i, &cdev->outurb_active_mask) == 0) { - out = cdev->data_urbs_out[i]; - break; - } - - if (!out) { + i = find_and_set_bit(&cdev->outurb_active_mask, N_URBS); + if (i >= N_URBS) { dev_err(dev, "Unable to find an output urb to use\n"); goto requeue; } + out = cdev->data_urbs_out[i]; + /* read the recently received packet and send back one which has * the same layout */ for (frame = 0; frame < FRAMES_PER_URB; frame++) { -- 2.39.2