Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp278475lql; Mon, 11 Mar 2024 02:21:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXHy/KB4frg5aIOm6TrSXJbF0lGIalrmU2Wq832IVUh4oPbAQCxxPTDqy6ddWeliUmA54uxhsuRNLG211zXCHykjoS5LaA6Ck3PwShz9Q== X-Google-Smtp-Source: AGHT+IFG/D8bXooHz9EPxFfuJ2t7fpfCzVtBwugsURpY6WQUuGGAtneBT9l74sOUO3OfKdjE5gex X-Received: by 2002:a05:620a:3b81:b0:788:2525:d2f1 with SMTP id ye1-20020a05620a3b8100b007882525d2f1mr6625637qkn.65.1710148884379; Mon, 11 Mar 2024 02:21:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710148884; cv=pass; d=google.com; s=arc-20160816; b=DhSQCV01SHUGTzcwYbvqI1eRdug6mo2KMn/Uxf5xN9+fXXZ/mVP4HNkIt/P7nlvHtx sML3B3R+bWVr+AF8sZAR43qERDW1ZVObpKqOe5n6YODKJCZg6fftUki0grBum3OSa+Ct Or4xGMmPgXHcWuFbev70Ia5h9788iUzfyffg0ImtT2MFDQls5wpMYRWIn3363uys8yZm ISO7ix6ERjLp8lJbwE6ebmV43KEJOdbO5HWwsc3hbFlZjtX3MhNNtHJBzoXOhKo4Imzf gzYQqPxnPRa3aKQJBJp5A4lLUo2PlOFLE79mlCjIk30j9hdwWLErlLEsNkB/4fXGxGU2 9tVQ== 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=MvrNB1vjlyglGsDHgQXajdb9Gf1WVPwiADdBQtMXZkU=; fh=b9A/EHi9urc8goWNsmcb0c8z89UNxcg3hLpH67j70P4=; b=0FEqc0ly7ueNERVeb1fwXyDiSI5btJMqkrpqB+gXQjPLwtQdiRdXqVljp3euhGugNz gC61DHjixRbhWywAuXIJgiDBj4eg827vCa5nzD7p5NbNqB0MgbeizdpAaDXsVB5c/a+p a2hge02iJQidO1GAqncY8aAUh0kUi51X6RxQ4Tla5ajc8uTA/kLIrnTl8IRqYWxkkVmM m8L2yQE5XMEB3PilzDExZkzkiJHmhWSohE3dxGDVTWIcrQ9LNGRKFwMvSAJ9biLCmbBB aKMOn1oliAS4gkDS8jYwyuHUcey/X8jsQXAKFJLKTEMSAxDvXl0oSDKuD18lKQ9tqd9u ryBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=H2QXL4op; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-98603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98603-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y7-20020a05620a09c700b0078838c48ccasi4782304qky.630.2024.03.11.02.21.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 02:21:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=H2QXL4op; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-98603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98603-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.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 0C37C1C20F55 for ; Mon, 11 Mar 2024 09:21:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3766D1755F; Mon, 11 Mar 2024 09:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="H2QXL4op" Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 BCC1B12E48; Mon, 11 Mar 2024 09:21:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710148874; cv=none; b=d84sBBRStYHjavB6kcr1jlJCJNYtLE2BGguTha/xunxNXa8bdW7oelZK/04L+qAMG0h+wIrdy0NhFohasAThiIkH3ZUEWo+wfDyehYkl8KAHU7m/WB4p33rZC1LyI1Mv0nhepw4DohYt0B6FJSUu1zAh7Jd4+QPXcYLdYJYMIBQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710148874; c=relaxed/simple; bh=/hIauNCwOFr9GvZ1GLOdhxActQlNhMaVI4JUq639/L8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=nlefkK+g4JJRPxy5ZM4eqh/Ejw9FB+wRPxs364RjqomryOcRCeJNAIAr4mlXR0CB+eEp5NkhM4SecBMbYESBGdPo4LZCv9kyp6ZyCg3VHgYCqxukw2TjO4dePteVH9RHkth+8e0hSJmhUhQSMtJMBzZmhDwm4EWzUGl/uxTWTYg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=H2QXL4op; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 7C5E0FF806; Mon, 11 Mar 2024 09:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710148863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MvrNB1vjlyglGsDHgQXajdb9Gf1WVPwiADdBQtMXZkU=; b=H2QXL4opmZYFbaUOWr9UTc7MgjztMfmCZq/K2E9iWv1x6544XITdkjjgaQM4fQUUsIoYnx JwLOPk7OKA/7iMa3c7+uHWmL8lH8AZ/YFxrr8t6JY4Zdq20fLczpGVX3g/hMN24Nj3htNK rK74orgXDgOwacFqPfJ7oOVZS9jzQLnbER0H7/kTQV7Wa+BIZ4jtwG/K6VVnMslgorzX8h JwLyFpTpIsMpecmadie9eq7l6SRBb891LiWj5z+F2XDJ3SECNAUnPDub43GN0ZqlM9DeNy nHZ4AdHPqoIFmunV+v4vGkzW0x+HjA+lCzBa7ejILHp2CFZD6n+RW77PbjPMlw== From: Kory Maincent To: Jakub Kicinski , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: thomas.petazzoni@bootlin.com, Richard Cochran Subject: [PATCH v2 net-next] ptp: Move from simple ida to xarray Date: Mon, 11 Mar 2024 10:21:01 +0100 Message-Id: <20240311092101.1114687-1-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: kory.maincent@bootlin.com Move from simple ida to xarray for storing and loading the ptp_clock pointer. This prepares support for future hardware timestamp selection by being able to link the ptp clock index to its pointer. Signed-off-by: Kory Maincent --- Change in v2: - Update an err value missing --- drivers/ptp/ptp_clock.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index 3aaf1a3430c5..9339fd475df0 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -31,7 +31,7 @@ struct class *ptp_class; static dev_t ptp_devt; -static DEFINE_IDA(ptp_clocks_map); +static DEFINE_XARRAY_ALLOC(ptp_clocks_map); /* time stamp event queue operations */ @@ -201,7 +201,7 @@ static void ptp_clock_release(struct device *dev) bitmap_free(tsevq->mask); kfree(tsevq); debugfs_remove(ptp->debugfs_root); - ida_free(&ptp_clocks_map, ptp->index); + xa_erase(&ptp_clocks_map, ptp->index); kfree(ptp); } @@ -246,12 +246,12 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info, if (ptp == NULL) goto no_memory; - index = ida_alloc_max(&ptp_clocks_map, MINORMASK, GFP_KERNEL); - if (index < 0) { - err = index; + err = xa_alloc(&ptp_clocks_map, &index, ptp, xa_limit_31b, + GFP_KERNEL); + if (err) goto no_slot; - } + err = -ENOMEM; ptp->clock.ops = ptp_clock_ops; ptp->info = info; ptp->devid = MKDEV(major, index); @@ -378,7 +378,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info, list_del(&queue->qlist); kfree(queue); no_memory_queue: - ida_free(&ptp_clocks_map, index); + xa_erase(&ptp_clocks_map, index); no_slot: kfree(ptp); no_memory: @@ -511,7 +511,7 @@ static void __exit ptp_exit(void) { class_destroy(ptp_class); unregister_chrdev_region(ptp_devt, MINORMASK + 1); - ida_destroy(&ptp_clocks_map); + xa_destroy(&ptp_clocks_map); } static int __init ptp_init(void) -- 2.25.1