From patchwork Tue Jan 23 15:09:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 190997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp398146dyi; Tue, 23 Jan 2024 07:09:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5rp4ZST2/a0NiPVQMdD3lmeiOhU/JwX+eonyItdAZicOEqwE6wc94m+9cB3TmCT8R9LH4 X-Received: by 2002:ac8:794c:0:b0:42a:5060:8e27 with SMTP id r12-20020ac8794c000000b0042a50608e27mr1005093qtt.48.1706022597252; Tue, 23 Jan 2024 07:09:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706022597; cv=pass; d=google.com; s=arc-20160816; b=IDTJr57NsZInNUIGaiX3ACoqA9HSTWr62bnmea0xaHoLznx4fuLkBhx6GuDUHG4wXy f1Ki7HoyRP9JGbkmFVuNpH5zP975qgMVSX2viq6TZHTIuoZlDhrbIf63a47dzJr1zqoE N3nqjOyAFwKSihU/oMxP1PNQ2RGVjw+kjWIV3k89kHbwQL1Bwp1+LqgaNIL1Db4GntPG miCJiPjcPo0hWqbCm6d4bXYjUK9Dgf5SiLuQ1pQ95oTcdtk44jB2Fl2hU9y5uHMDt7A2 vAf5ggvtT3+WA/cihTcmeyDOH/mVLv9Y7PceM1AKuFeu0iDjyq7eu3iMZ6vQvacD7wfO OwjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=VbxBxCWrIh0zrQFy85sWtt5gQmurWQ5SJD+FOeS70nI=; fh=6h784S57cSWbC/QCurcAvBvZChdyzW5HGNlWMF29gjU=; b=xQftgGOmDIZs8t/S9JtIgyShb8pOKTpsZaOcdYajJ789IeA4DWujkgNSCrH3+QNf40 B95e9hnyQBCRfxJAymMz4mBTPa5x2abYmiVn1Cem/cdnCFQSl+NOw4MaffB9XrwaPZPJ nCMvOmiJEbTVRqrgObt7PO9vrY2PCzw3R0mr3GfUGihlJ3iqbP+HwEPSepXN0M5KGJ3T eeKm/XWm56Kgg1zuLAdIgQGqTGnTJdAgidChSgG0+6uCgw7QThI0tI3f322Izv6Q1mgQ jDIEqFm1h4psWx4JgFNFpA7rywpr4BDckDiKVs39cqKF+mh4cGrolwy6qswseidkURBv SDAQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KsEleuV8; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-35506-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35506-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n11-20020a05622a040b00b0042a1c757654si8185477qtx.626.2024.01.23.07.09.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 07:09:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35506-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KsEleuV8; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-35506-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35506-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0E2B91C20F44 for ; Tue, 23 Jan 2024 15:09:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE9665FEE7; Tue, 23 Jan 2024 15:09:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="KsEleuV8" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCD045F55B; Tue, 23 Jan 2024 15:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706022568; cv=none; b=KMu+X4/wT22jiDF0EuHeT+x7qVwaAZ4d5DI3ZaDufIm/kzVu0wqY8YjAptojR8/O5TA1hTpbWj7VQgBqp567za2nmAmW9YzzXzyAKxo/oBQ6oRTlcVZdbI9+2ELJUm6h1MfrwKzxciVskvPeFdemGrwodCMGFsBGqPcf0XZyTvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706022568; c=relaxed/simple; bh=zdN9AWx3mn6BQG7Qefn2YsGqa539WPtGvVDiINeK+1o=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=tCpLz3zkHmZUB4mJTHPYkqO70Ak2qPjMfKdvwO2Ii3Lvz2nO6xWWyKUiCajHgAaEM+bt0fjEWNwEh0Q94oV64vSbuPSqXUTqzdc1z/pHilOScsK56wuyzQfMG8y1D4KUGeoB5++KTDfz5hpPEWPEZNjp3j0l6riP1mcV4AR7M0E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=KsEleuV8; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NF9Gib071713; Tue, 23 Jan 2024 09:09:16 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706022556; bh=VbxBxCWrIh0zrQFy85sWtt5gQmurWQ5SJD+FOeS70nI=; h=From:To:CC:Subject:Date; b=KsEleuV8lZ0JP71WGyWQW8tp/ZhZn9xB7Rkc3M30j3hDMr7v9mYrpAeN3lcsA+aLH WFW3bYSUBmV3bU7Vh1rpLum/vsZrxFqlnxfuxdASeHQXDBE+4gOdp3n6NpsBJo2+EH I89aPTQyzMfRB3PzRvRWTPHHaJq2szyMWVGBWtz4= Received: from DLEE111.ent.ti.com (dlee111.ent.ti.com [157.170.170.22]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NF9GiO075195 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 09:09:16 -0600 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 23 Jan 2024 09:09:16 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 23 Jan 2024 09:09:16 -0600 Received: from lelvsmtp5.itg.ti.com ([10.249.42.149]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 40NF9FE4128205; Tue, 23 Jan 2024 09:09:15 -0600 From: Andrew Davis To: =?utf-8?q?Pali_Roh=C3=A1r?= , Sebastian Reichel CC: , , Andrew Davis Subject: [PATCH 1/5] power: supply: bq27xxx: Switch to a simpler IDA interface Date: Tue, 23 Jan 2024 09:09:10 -0600 Message-ID: <20240123150914.308510-1-afd@ti.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788894350815286696 X-GMAIL-MSGID: 1788894350815286696 We don't need to specify any ranges when allocating IDs so we can switch to ida_alloc() and ida_free() instead of the ida_simple_ counterparts. Signed-off-by: Andrew Davis --- drivers/power/supply/bq27xxx_battery_i2c.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c index 3a1798b0c1a79..86ce13a8ab9dd 100644 --- a/drivers/power/supply/bq27xxx_battery_i2c.c +++ b/drivers/power/supply/bq27xxx_battery_i2c.c @@ -13,8 +13,7 @@ #include -static DEFINE_IDR(battery_id); -static DEFINE_MUTEX(battery_mutex); +static DEFINE_IDA(battery_id); static irqreturn_t bq27xxx_battery_irq_handler_thread(int irq, void *data) { @@ -145,9 +144,7 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client) int num; /* Get new ID for the new battery device */ - mutex_lock(&battery_mutex); - num = idr_alloc(&battery_id, client, 0, 0, GFP_KERNEL); - mutex_unlock(&battery_mutex); + num = ida_alloc(&battery_id, GFP_KERNEL); if (num < 0) return num; @@ -198,9 +195,7 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client) ret = -ENOMEM; err_failed: - mutex_lock(&battery_mutex); - idr_remove(&battery_id, num); - mutex_unlock(&battery_mutex); + ida_free(&battery_id, num); return ret; } @@ -212,9 +207,7 @@ static void bq27xxx_battery_i2c_remove(struct i2c_client *client) free_irq(client->irq, di); bq27xxx_battery_teardown(di); - mutex_lock(&battery_mutex); - idr_remove(&battery_id, di->id); - mutex_unlock(&battery_mutex); + ida_free(&battery_id, di->id); } static const struct i2c_device_id bq27xxx_i2c_id_table[] = {