Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2320810rdb; Sun, 3 Dec 2023 11:35:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlSwDQeT+WR5W4QtSUXnUmgEB9hhQJsTc4svIO7i23upOtTGSzMljr6KCZMmbWvHb8eM/h X-Received: by 2002:a05:6a20:a415:b0:18f:97c:6173 with SMTP id z21-20020a056a20a41500b0018f097c6173mr2934987pzk.112.1701632132044; Sun, 03 Dec 2023 11:35:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701632132; cv=none; d=google.com; s=arc-20160816; b=tC003Pzgufvjbf5EWph9yogKh70U6KW3mx313SfdUth6m24kajlN8fvjnWQ/yLFGP6 S1s+4d72Ob3eiMgqFHwo+wMb4q58lunMWuphot/Aul3HFcpp1JVIKlYH4eUpt/WpSPx6 qCuaoS1/O4PHDYGSYp3tOexrDYvWM8wrsBNeYTuPHtSYLprs/PzzjC6nqNMEYfmd0Ala Or6CG0nh8QtLRZUw/fvqj/KwAKTbqgP2UExV3QHgSs44X5I+vg4zuFepmZyGN5UqetQa v7/rnIFq39U6+AmdaMAO/pHv0KJXoq8dwDvnNMLmeuln+aTlj0upfIu6Lnfo+5/1j1as TS4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4YGRNDAChzcpaz6DA4kFDpotF2uCzYOTR4dLduIm5dA=; fh=7e2H77IM3z2gCwKTAIdEciVF1SZF3XPSU6oX6OdLElo=; b=qCVPl+qGQeYxofaNvsmFSg1OWg25H0A1g6ypR02k8m+0Y2mP9wLtKGSF4+YmhbmSIX /dGFmLsRUyoqLpB5bmio11dKKUb+aFKUPuus7DprgQyyXhyEF1yOEGV/d6FR7oXOQ0mT VsG/GiqUkwl/hT34zBoJz0Td7bLpkNhlmM2WpZkmvBQf1ApFjDWenrlt3NQuOhGWc0ap Ojy+npXJ/B5RvYngaYfzPlKZBnLrzdnBX/ywcc+COc329joWNL26yuWe94e5OLzvGriE 2wtQV6n4iCoPkhQCapuL9Ai55k4SyX0We3FephpbX4/eAjcfxP3uJVVlTdHw56ppecib pWMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WEnlCspJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id l20-20020a056a00141400b006cd8567235bsi6611724pfu.237.2023.12.03.11.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 11:35:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WEnlCspJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id BF6EB806082F; Sun, 3 Dec 2023 11:35:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234272AbjLCTez (ORCPT + 99 others); Sun, 3 Dec 2023 14:34:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234175AbjLCTeY (ORCPT ); Sun, 3 Dec 2023 14:34:24 -0500 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E955810C2; Sun, 3 Dec 2023 11:34:01 -0800 (PST) Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6d875809921so1148172a34.3; Sun, 03 Dec 2023 11:34:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701632041; x=1702236841; darn=vger.kernel.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=4YGRNDAChzcpaz6DA4kFDpotF2uCzYOTR4dLduIm5dA=; b=WEnlCspJHIVcyo3FjFMMypzkEyoyDL1AhF/sQxLQoU16ClTrXre8cBNsOHrfBGrMUt DdaxGb23z/NqpklT+Y5dHWAtlUvaM38sHa6rlnFIxHY1l5Hdo9wZ298W2dkBfFy5M4vc J2CPOUxc7iP27k/joKKsOb6j720nz6sh2364t/MNk9nwifWPWrlUPDFb/XFHD2GwtKHg MEL3dbt4Q8stwYvYpShw09GX1/nFlnFUoj1Ce0ywFqNILdwOWGjvEB8U/f98gHV///sh j0TyN/uEQbiRdq8li6MlYC+IwG04ZkmOPVRmMDbP7/bBTZ4Zm3UnLvZE2mrRoMiBYFmZ iVdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701632041; x=1702236841; 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=4YGRNDAChzcpaz6DA4kFDpotF2uCzYOTR4dLduIm5dA=; b=JqxTGcDWiQ//WHKSvwWPGgZrr2XlkkBlKhDsrN4vlpGCzC/emQgoWyem2U6Xi7lp/o g4JqzverNpF+x6x2XgBE5S0FR9DGr+R4Kvnpm5VfPHU7sFaOJly9NF3DVSK7j5V4v+Zn HfruHjYIrbuN8mdyYOdnc8F4rhCYMvJ4gx4vGQA31AQyu1UgLuJBfbMOufUdUovTwlXt kTytbBV21EKrcUyhXuBQlz59/v5aCKfY8UGAIjsThvoewsZCsDa6mkB2glyPxOqe00ws xcdMpikp1ohC687Lr8GWA577V7Ucmonhy8atN18GouXqkMJuiRFKc+740X38vZFOMGTd srjw== X-Gm-Message-State: AOJu0YyLcCAd28ZUBQ7RhnD/MeT16CcICRcW9v//yu/i+A7pvbNm/jg7 Ulx2QCcQ7hxzoTTrYFXcEfaJH1FdFPwpJw== X-Received: by 2002:a9d:6186:0:b0:6d8:11ba:ed47 with SMTP id g6-20020a9d6186000000b006d811baed47mr2857309otk.14.1701632040714; Sun, 03 Dec 2023 11:34:00 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:cb98:c3e:57c:8191]) by smtp.gmail.com with ESMTPSA id z2-20020a816502000000b00597e912e67esm2759736ywb.131.2023.12.03.11.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 11:34:00 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , Hugo Villeneuve , Lech Perczak , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Andy Shevchenko , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Thomas Gleixner , Hui Wang , Isaac True , Yury Norov , linux-serial@vger.kernel.org Cc: Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov , Bart Van Assche , Sergey Shtylyov Subject: [PATCH v2 29/35] serial: sc12is7xx: optimize sc16is7xx_alloc_line() Date: Sun, 3 Dec 2023 11:33:01 -0800 Message-Id: <20231203193307.542794-28-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231203193307.542794-1-yury.norov@gmail.com> References: <20231203192422.539300-1-yury.norov@gmail.com> <20231203193307.542794-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sun, 03 Dec 2023 11:35:28 -0800 (PST) Instead of polling every bit in sc16is7xx_lines, switch it to using a dedicated find_and_set_bit(), and make the function a simple one-liner. Signed-off-by: Yury Norov --- drivers/tty/serial/sc16is7xx.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index db2bb1c0d36c..6a463988d5e0 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -427,15 +427,9 @@ static void sc16is7xx_port_update(struct uart_port *port, u8 reg, static int sc16is7xx_alloc_line(void) { - int i; - BUILD_BUG_ON(SC16IS7XX_MAX_DEVS > BITS_PER_LONG); - for (i = 0; i < SC16IS7XX_MAX_DEVS; i++) - if (!test_and_set_bit(i, &sc16is7xx_lines)) - break; - - return i; + return find_and_set_bit(&sc16is7xx_lines, SC16IS7XX_MAX_DEVS); } static void sc16is7xx_power(struct uart_port *port, int on) -- 2.40.1