Message ID | 20221117211143.3817381-4-u.kleine-koenig@pengutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp627302wrr; Thu, 17 Nov 2022 13:18:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf58ACECZ78Zz/CE0PrNAPqOFh17bhciqruJHZgHIq+y2jtarU/mfbWUleNZqDBwvZpI1Ohf X-Received: by 2002:a17:906:39c8:b0:7ad:79c0:5482 with SMTP id i8-20020a17090639c800b007ad79c05482mr3468153eje.730.1668719927336; Thu, 17 Nov 2022 13:18:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668719927; cv=none; d=google.com; s=arc-20160816; b=id9efDS5XAfu3D5/MeVBXy+Ppp9SD2ri51LNmwkQzHLLA+WjP//JDoet9G/yMXg4ba okVa5IL0J8pAfkUdHt0LW8+1AQWpOim8oJJcRCU7e9MzvdzpC2bPBlRGsfjwFoDGNYZW 79AtezM+ZXO4LOliofsOI3h5w4vnxyvLIZr4p3YT5Ik4oJmQWA4WQlu0a7QZ9fldnUjp TCY7j8xM25hn9csy7YN7A8HvcDaV3EMVMYHScSGI5Ckx8Jf5KKQ/RwKlEKRRO9B9+hpq q5KBrMacNgwwHPKdwbcWaiPo9M7oKo/qQ3T48d4MXY/3pT5G8uPYPk5mlBtYxtafwFr+ X7Gg== 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; bh=oxQKWJfMcrJ6vm0tvEa1wVhFRh9DrseAbumDA9b25Nk=; b=aEj4CHNa39KXG6gRgwd5DofKumhOuLxCuhvfQ2J3zTnu8pFmxUgJfMKpqCh3v7p/yJ pije6un0NU2reN2WL7EOMIe1dYci32LyWauJP9uyEWhnbHn3OpOTK3IozBMy8wEeg5UE THnCyDnKoZP/nRMf8lYZD4JG9BYiK+VI5UXcVz1h+LsZCd69H9HmLx419oYxtdyV/q9a CkGD1itNQD5cQ0rdY9GtEewTqyvvjL3ruuGo+A5kM2vonxGBu0oqPRs8V3er92let1TU PL0F7aVJge8q4k8PKnPH+XPifVCvZ3YXV2++/fXY5ue1IOUf+ZiFPibyqV6tzdQ4/v3b Q8Sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa31-20020a170907869f00b007aaf5a45f5asi1542268ejc.47.2022.11.17.13.18.17; Thu, 17 Nov 2022 13:18:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240822AbiKQVMY (ORCPT <rfc822;a1648639935@gmail.com> + 99 others); Thu, 17 Nov 2022 16:12:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240743AbiKQVL5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 17 Nov 2022 16:11:57 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10BE06150F for <linux-kernel@vger.kernel.org>; Thu, 17 Nov 2022 13:11:57 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <ukl@pengutronix.de>) id 1ovmAq-0007P1-Gt; Thu, 17 Nov 2022 22:11:52 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from <ukl@pengutronix.de>) id 1ovmAo-004v5t-Un; Thu, 17 Nov 2022 22:11:51 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from <ukl@pengutronix.de>) id 1ovmAo-00HN0L-RH; Thu, 17 Nov 2022 22:11:50 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de> To: Thierry Reding <thierry.reding@gmail.com> Cc: linux-pwm@vger.kernel.org, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v2 3/4] pwm: Mark free pwm IDs as used in alloc_pwms() Date: Thu, 17 Nov 2022 22:11:42 +0100 Message-Id: <20221117211143.3817381-4-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117211143.3817381-1-u.kleine-koenig@pengutronix.de> References: <20221117211143.3817381-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1158; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=ZlStsEzR95pbO/ZmKK1BH2TWL3+UitzetoByqrewymQ=; b=owEBbQGS/pANAwAKAcH8FHityuwJAcsmYgBjdqOFnLAl+llZa8VfE8hGENgCr2OBorW+EwWwj6Sc hxVKKIWJATMEAAEKAB0WIQR+cioWkBis/z50pAvB/BR4rcrsCQUCY3ajhQAKCRDB/BR4rcrsCQvECA CODszKvUNGCAramGpOaGYzlu1hv/odKmef2JzgxlizzQv+z1poDO3IeRXSiuE7ybsHKdBuZvDVbQcY 1xGQQefeaKCttbIHkgWK6IICO/9tAGFpXAR94Ib5V6lJtD/KuDiq8slejxKqM7hsg4cp2zbdOd0Lh5 +bb/PFYPrZqdzjpgDNux7hnMXaoqSQqXTPWU349JUOul1vS3/NFdmzbp3s17/5kI8U+8jqWzOGQ9cO H1msrkwSlSspKerk+msMJKtsWsd/BDa/mH48HsXwy3+6b/S8stWqfNW08FohfLc2dsAOEyDOB1sqSA uT43cx+lM3hdfI+guzKUQrYK4Zq4Pm X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749779666826760805?= X-GMAIL-MSGID: =?utf-8?q?1749779666826760805?= |
Series |
pwm: Some refactoring of pwmchip_add()
|
|
Commit Message
Uwe Kleine-König
Nov. 17, 2022, 9:11 p.m. UTC
alloc_pwms() only identified a free range of IDs and this range was marked as used only later by pwmchip_add(). Instead let alloc_pwms() already do the marking (which makes the function actually allocating the range and so justifies the function name). This way access to the allocated_pwms bitfield is limited to two functions only. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 2338119a09d8..b43b24bd3c9f 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -51,6 +51,8 @@ static int alloc_pwms(unsigned int count) if (start + count > MAX_PWMS) return -ENOSPC; + bitmap_set(allocated_pwms, start, count); + return start; } @@ -297,8 +299,6 @@ int pwmchip_add(struct pwm_chip *chip) radix_tree_insert(&pwm_tree, pwm->pwm, pwm); } - bitmap_set(allocated_pwms, chip->base, chip->npwm); - INIT_LIST_HEAD(&chip->list); list_add(&chip->list, &pwm_chips);