From patchwork Mon Feb 19 07:46:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 202924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1135161dyc; Sun, 18 Feb 2024 23:49:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWN8N/k0dd5DZfwj1V2lcfWbieMqQIyWPh8m8ofgqADSL1W9kFc1yub99/T012Wa7T5SLzn9phtvUEjbnBawIUXatrrPQ== X-Google-Smtp-Source: AGHT+IHw0y/00koEgA2H/WotDOJ61dC4D9lmwrcZ9IWMkJTYyAlLHscGKf2kbpCdKh0AppE/0YSx X-Received: by 2002:a0c:e0d0:0:b0:68f:4b3c:6448 with SMTP id x16-20020a0ce0d0000000b0068f4b3c6448mr5317410qvk.11.1708328985738; Sun, 18 Feb 2024 23:49:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708328985; cv=pass; d=google.com; s=arc-20160816; b=qvEwgOlkNtBUs/MpIoKG68TQEhf5CMGyB5/h4CjBeifvRxpPcjNPOXNE6IHPBgVaJJ StUC8jO5hY50aJfDI/pEYRpTQxGuTyCkkjMInP3TlT2m6gN5vN7LyzWk7EQ6V1OGym2J ArNX15exmg/HggYUPQLckTBVpxiaplYazoDLfD5w0wj7OI81YnQ/l9y+YAr/wZ1q+4C/ w3ilhZD9Xpec67e9HReHDYJpOAuAjWH6+uRnJAVf7ndg3soCvubmeWB9oK3SIL2KstRF wLdoo6Fr3ER9pd5bvYxIhh9dvuKyEuhmM/DZfyfRndk81H4bhTYn7hsXpkP84E1d+9q/ aH6g== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Tz+o3vI9KlvHiRG29EdJARxLzt+Yvz/b+TvJFHIdhXw=; fh=9JZBrvtwCG5066tN718e69nt6/Z/miRqupfdz0ojAcY=; b=g7y5ZkB+XXAemB4FottGuWLj6bAqTZSdkVvmOxHZUECQS1IqjjEYhGjM5ZIWtul0/3 1uUPmY+OGT5jEYi8xfv/eA3YpznNo4IGYyM0jFno7WK+vJE56Z35d9vsW2bV7jKaiR9p qOV0wuryYg6dGYg7JI9o7y+11geUCDrAhIVVqeFOOE1EWjqARmHEiCIIGbRQpD0aj5gH 6T1xRAuJiAmpA1lqU3BcqoXedp6r8wDcsSKCxX1aX7kD0neeFDgFQ3JTeimPelibf0c6 I6k89Qkss3EvZefSQEpJyO/XBN+mUeT9zGbMRvgumD9ROPiprIbw0lh68V2K5I2cYwAv sgZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-70862-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70862-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a7-20020ad45c47000000b0068f30acaec5si5997304qva.607.2024.02.18.23.49.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 23:49:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70862-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; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-70862-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70862-ouuuleilei=gmail.com@vger.kernel.org" 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 872611C21CA8 for ; Mon, 19 Feb 2024 07:49:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D065E28E2B; Mon, 19 Feb 2024 07:46:43 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 0753C20DC3 for ; Mon, 19 Feb 2024 07:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708328802; cv=none; b=hd3RTLJuPv18c0uzimDjAIKPX3XdqsbBeqetFh1Ik1h6hdskJzRXYjn4u6pbzX4fLuVikyUjSsZTtGthcHeSXupjeLNN3K050spMnX3O93FvCxmSCHDDKYquZCwAzCYpqz3UD68aH+y27y9bHrGnIFjWv+m58Vp+5MTBQ2lotW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708328802; c=relaxed/simple; bh=m49ew6tZDWmkpcYRR5eY0qxk5vXybz95BmqhredgINc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UQOva2PeUrpVmOJoeF1DLHce6tmCgSgrc2OiJ/Zwww91mvMAjWLc4JOnEC9mcAOxXBYNkaR8AMHTGjDFpirQ+d1y/+4b55aQSyT3oWDmq9+rVqWzrx+kXy1za9V75P357jHCPewE2kneQg5q0VjD+Uts0/L4O6gWk6xXVEtXiEk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rbyMI-0000QL-3c; Mon, 19 Feb 2024 08:46:38 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rbyMH-001bHx-MP; Mon, 19 Feb 2024 08:46:37 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rbyMH-007bvZ-1v; Mon, 19 Feb 2024 08:46:37 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thorsten Scherer Cc: Pengutronix Kernel Team , linux-kernel@vger.kernel.org Subject: [PATCH 2/4] siox: Provide a devm variant of siox_master_alloc() Date: Mon, 19 Feb 2024 08:46:30 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1597; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=m49ew6tZDWmkpcYRR5eY0qxk5vXybz95BmqhredgINc=; b=owGbwMvMwMXY3/A7olbonx/jabUkhtTL7OF+bGLK5TNznuVIxMWvfO/Iy1z88lvj5NopNl8nL Dh67/qqTkZjFgZGLgZZMUUW+8Y1mVZVcpGda/9dhhnEygQyhYGLUwAm0qzL/s+S8dgEt9XVrFZf 7rGm/5n71kR59Zwba40iCsptfeTfne9aUci9ctvZvRJq25PjmJ+Y5YdO+PjqhgJr/seDu0y01BY H1xd0Z9V9Ez9fwhwR25ap51KYs9g3X/hA3wSeuNTi+QGORox8s+7Jebj2Ot5U4k7yU0hhiZnKso X3tNUqXkXLk5xlzyM6Ns+4fWLqGl83heutwnMlpmdXyLHPt1LITBERNY/at75z5SXbzb4NgvqvF yzivjg1UnizatiHVwdmmWY3f9tvwaM5pVSjpeT5a2FbTpbFc17JLZ7K7igWl53Tns1U12jCc8M4 +cjupROv/w/4uMk4aaX1xbts+/5ZWs98teLAiqMt5ltbAA== X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791312774625490492 X-GMAIL-MSGID: 1791312774625490492 This allows to simplify siox master drivers in the next step. Signed-off-by: Uwe Kleine-König --- drivers/siox/siox-core.c | 24 ++++++++++++++++++++++++ drivers/siox/siox.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c index d4acab7036d6..9dd0bda03db3 100644 --- a/drivers/siox/siox-core.c +++ b/drivers/siox/siox-core.c @@ -707,6 +707,30 @@ struct siox_master *siox_master_alloc(struct device *dev, } EXPORT_SYMBOL_GPL(siox_master_alloc); +static void devm_siox_master_put(void *data) +{ + struct siox_master *smaster = data; + + siox_master_put(smaster); +} + +struct siox_master *devm_siox_master_alloc(struct device *dev, + size_t size) +{ + struct siox_master *smaster; + int ret; + + smaster = siox_master_alloc(dev, size); + if (!smaster) + return NULL; + + ret = devm_add_action_or_reset(dev, devm_siox_master_put, smaster); + if (ret) + return NULL; + + return smaster; +} + int siox_master_register(struct siox_master *smaster) { int ret; diff --git a/drivers/siox/siox.h b/drivers/siox/siox.h index f08b43b713c5..b227e18b697a 100644 --- a/drivers/siox/siox.h +++ b/drivers/siox/siox.h @@ -45,5 +45,7 @@ static inline void siox_master_put(struct siox_master *smaster) put_device(&smaster->dev); } +struct siox_master *devm_siox_master_alloc(struct device *dev, size_t size); + int siox_master_register(struct siox_master *smaster); void siox_master_unregister(struct siox_master *smaster);