From patchwork Fri Jan 24 08:52:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= X-Patchwork-Id: 13949084 Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (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 206EE1DB134; Fri, 24 Jan 2025 08:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737709004; cv=none; b=gtj2OOofPFG/yEoYUWvhpajUtpjXtrRn75TeMAPnRzHQWSDum5o3r8ohpJt2dSgPgY+snQ3d/8y+nUw4IimFk30iCQt04qRiM02yqP73a2s7D/iWaJz2yMwvioqdTvUiiNN/JVDenw9XBDqdkPeGjshK3p3aJb4ydHObrg5BGrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737709004; c=relaxed/simple; bh=x39wM5IEXku0agPTtfPWYboyk7mBbtqeLmPY+Swh07A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e7xiDU7m+v3iKHTsHgi8Fkrp9z9QfCLmtVBCi3Nh58vg6n3ZV+jK9jSfHXuVn2qG+g5GZ7Te78eRdAMLyVLVJ8+kqmWcCuaQnykeqlAmTYzzEH7Jn37zva6QG3KyhklDCbuOLShjiEvB4DYAcUBXrTbcNR1BVKuRam2VOWTuk7k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=HRJ3XRli; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="HRJ3XRli" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id DCBF1A09FF; Fri, 24 Jan 2025 09:56:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=/dPRX9W95wzwQTmmvdwr EPqh/JERYDW6ukU8wyxlrOs=; b=HRJ3XRli0bJqmqEkA5XizKxZ08cudSvu96Iw VumzdC99vsEJnvFL4SgTXbOd837Y795TwlVsW0Dk9j4J6GL1oxG9Eb+aPUHMo77L jGtLasYkWxk6enfuuSjXEiRjLNQr+efAuhn6RVLpe76HEWGbgVDYFtAZGohE8pw/ vPdLzKhHsnpPXqEv5jU0MXPDdGL7/Uf1tgb92HDTAgLBfXhZsOm/ro605IOmy6is Pu8e/3b1ITFXd7ORkYXaWRdDO5SEdxzfqDsTQ5D3K3yMbaIag9h0Ya50RfXFVWfe Gj1DF7GRZ1QOgeLYkGZfpRQLe1IYxstFPYZzc60gW1jNwmpii57++Kq7Py2w/HNp Ci8HVZr9mxIPCL3bW4Ml8wW7llqrsnriL4UutQpgmmq/kF8ctA5i5XWIfqDd9OnA /fkhiYKYk5ry8T0OdRBWgWzXpGRAlv0CLdFBmQBsXxjzwZnpCzSeaMpEzrv/3AhJ VAG3XQIeKQBmDYGKVUlOlumZOrw6gRFvCxArevfYiV2SbbKzIteCw+a+LY2+L6lv P+2FLybnzYO/0SFJdw7HqRTyqktRu5i8LOaEG/5X0twYCOd3ZhGzIPNbN849NGn1 mCB6pgKe8RyVjBrQ8kTHXaOIvF8vAs9OYP5qWjZt5magzJ82FiwLRMYM5aEbBiq1 XboyO1Y= From: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= To: , CC: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= , Mark Brown , Vinod Koul , "Rafael J . Wysocki" , , , Subject: [PATCH v2 1/4] dma: Add devm_dma_request_chan() Date: Fri, 24 Jan 2025 09:52:20 +0100 Message-ID: <20250124085221.766303-8-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250124085221.766303-4-csokas.bence@prolan.hu> References: <20250124085221.766303-4-csokas.bence@prolan.hu> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1737708998;VERSION=7984;MC=241928571;ID=70499;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A29ACD94852677063 Expand the arsenal of devm functions for DMA devices, this time for requesting channels. Signed-off-by: Bence Csókás --- drivers/dma/dmaengine.c | 30 ++++++++++++++++++++++++++++++ include/linux/dmaengine.h | 7 +++++++ 2 files changed, 37 insertions(+) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index c1357d7f3dc6..02c29d26ac85 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -926,6 +926,36 @@ void dma_release_channel(struct dma_chan *chan) } EXPORT_SYMBOL_GPL(dma_release_channel); +static void dmaenginem_release_channel(void *chan) +{ + dma_release_channel(chan); +} + +/** + * devm_dma_request_chan - try to allocate an exclusive slave channel + * @dev: pointer to client device structure + * @name: slave channel name + * + * Returns pointer to appropriate DMA channel on success or an error pointer. + * + * The operation is managed and will be undone on driver detach. + */ + +struct dma_chan *devm_dma_request_chan(struct device *dev, const char *name) +{ + struct dma_chan *chan = dma_request_chan(dev, name); + int ret = 0; + + if (!IS_ERR(chan)) + ret = devm_add_action_or_reset(dev, dmaenginem_release_channel, chan); + + if (ret) + return ERR_PTR(ret); + + return chan; +} +EXPORT_SYMBOL_GPL(devm_dma_request_chan); + /** * dmaengine_get - register interest in dma_channels */ diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 346251bf1026..ffb54b52ef0c 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -1528,6 +1528,7 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask, struct dma_chan *dma_request_chan(struct device *dev, const char *name); struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask); +struct dma_chan *devm_dma_request_chan(struct device *dev, const char *name); void dma_release_channel(struct dma_chan *chan); int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps); @@ -1564,6 +1565,12 @@ static inline struct dma_chan *dma_request_chan_by_mask( { return ERR_PTR(-ENODEV); } + +static inline struct dma_chan *devm_dma_request_chan(struct device *dev, const char *name) +{ + return ERR_PTR(-ENODEV); +} + static inline void dma_release_channel(struct dma_chan *chan) { } From patchwork Fri Jan 24 08:52:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= X-Patchwork-Id: 13949085 Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (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 5292A1F7907; Fri, 24 Jan 2025 08:56:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737709019; cv=none; b=uw8tsZAHn25YOpZFGtmozVjxl/mCcPmWALdqCrUWFf4pZ3S+XOm8S991VzrN74XnGAahlqC9P35i+F0l+3BwlVMGoxIAdHEP3cDm08Pq9gIBU9C3fo+ZuKrIwEqck/+FQTkrQVqqsJTvbeoIxSegPgcNiFk5xq0Uzs7cwHJeLGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737709019; c=relaxed/simple; bh=hMjK0JKCLQkifVL6xcp5SP3Txd+JKmmgLvrhO1+qQ0Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FlWTyAtS78lhIBhxnKL9LSPZq5I8xlT0HZoJOBiELbzvIioYH/IZXjNFJ9lHlRjnopd6JIvEwVw5xDTSh78MDeJufJtOecrK70j+OsvkSD2joIl36OqAWxooWnrnedxX+UnkGe+eXWRjU9rT13+qpHOSjkAfHvRGPrEhChWkoKE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=g7rLjC7w; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="g7rLjC7w" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id 836E3A09FF; Fri, 24 Jan 2025 09:56:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=ZlOzh0yVdNtO9Xo4eTT0 ptUq5hK7+DDJWK0WMdAATE0=; b=g7rLjC7w1RWLE5CXrEPJAknMGKmzbtUJde/P EOew21O+3aI3OSgdhlz38WMoJdJNw6DfoiAPVpLFB9ZsULv8zLLwwh8gamVjrrqD gXazlAdLmKevEOFooxcn86Pvwl6Zr7dgXBvdnnUDc8oNk6tGMeeczHTZZDuXwMCA oXLLdORXZkS5o+atOk7SUL0q0rJieS8zbA6UFmHu9Ehj2wM8rEzPwF2oFFPIEWBI tT8lakaDiPUMdSG4oNW6p0Sclmkv10z9EnqXDDhUQYWJahYT0J9kN7NkBmefAPr6 xC6fCtcpLEgYs9mOYlHKmSVQhzO5JNxm2KdnRocHYNJrhqHR+zmuJECHgizGw0Kb ZezsjwDdP2tgs4XQgWnRnIGCKTF+WnWzi6byuUdQgvo3+V9R1YoG4zJ443bEfrTD t7UyfrZ1stEVqhK+3IJ21+/omyu1k9buRONbsLvygY0bfza6Ypdk3AHFFP3D2hUJ zfafYq+wSH5agjXRBCcPDBpOd+3Rkn9fa2RiSllG00LgBABCl6K3aSaca7Q4cxkF 0oYHWRctUCaAU174CKNd1DnvvEMblOEzN7MvV9uS19L7ws0T3g7eO9yCa1fMhMcj LaIYEamaYI8ccVYa2svsDosOaa68e66fiN2MjZgjzFxGTVneb9oDQm65hFRAQRvN ajDlf74= From: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= To: , CC: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= , Mark Brown , Vinod Koul , "Rafael J . Wysocki" , , , , "Pavel Machek" , Len Brown , Greg Kroah-Hartman Subject: [PATCH v2 2/4] pm: runtime: Add new devm functions Date: Fri, 24 Jan 2025 09:52:22 +0100 Message-ID: <20250124085221.766303-10-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250124085221.766303-4-csokas.bence@prolan.hu> References: <20250124085221.766303-4-csokas.bence@prolan.hu> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1737709014;VERSION=7984;MC=2223755251;ID=70500;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A29ACD94852677063 Add `devm_pm_runtime_set_active()` and `devm_pm_runtime_get_noresume()` for simplifying common use cases in drivers. Signed-off-by: Bence Csókás --- drivers/base/power/runtime.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/pm_runtime.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 2ee45841486b..f0a6c64bec19 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1545,6 +1545,24 @@ void pm_runtime_enable(struct device *dev) } EXPORT_SYMBOL_GPL(pm_runtime_enable); +static void pm_runtime_set_suspended_action(void *data) +{ + pm_runtime_set_suspended(data); +} + +/** + * devm_pm_runtime_set_active - devres-enabled version of pm_runtime_set_active. + * + * @dev: Device to handle. + */ +int devm_pm_runtime_set_active(struct device *dev) +{ + pm_runtime_set_active(dev); + + return devm_add_action_or_reset(dev, pm_runtime_set_suspended_action, dev); +} +EXPORT_SYMBOL_GPL(devm_pm_runtime_set_active); + static void pm_runtime_disable_action(void *data) { pm_runtime_dont_use_autosuspend(data); @@ -1567,6 +1585,24 @@ int devm_pm_runtime_enable(struct device *dev) } EXPORT_SYMBOL_GPL(devm_pm_runtime_enable); +static void pm_runtime_put_noidle_action(void *data) +{ + pm_runtime_put_noidle(data); +} + +/** + * devm_pm_runtime_get_noresume - devres-enabled version of pm_runtime_get_noresume. + * + * @dev: Device to handle. + */ +int devm_pm_runtime_get_noresume(struct device *dev) +{ + pm_runtime_get_noresume(dev); + + return devm_add_action_or_reset(dev, pm_runtime_put_noidle_action, dev); +} +EXPORT_SYMBOL_GPL(devm_pm_runtime_get_noresume); + /** * pm_runtime_forbid - Block runtime PM of a device. * @dev: Device to handle. diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index d39dc863f612..d7eca86150b8 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h @@ -93,7 +93,9 @@ extern void pm_runtime_new_link(struct device *dev); extern void pm_runtime_drop_link(struct device_link *link); extern void pm_runtime_release_supplier(struct device_link *link); +int devm_pm_runtime_set_active(struct device *dev); extern int devm_pm_runtime_enable(struct device *dev); +int devm_pm_runtime_get_noresume(struct device *dev); /** * pm_suspend_ignore_children - Set runtime PM behavior regarding children. @@ -276,7 +278,9 @@ static inline void __pm_runtime_disable(struct device *dev, bool c) {} static inline void pm_runtime_allow(struct device *dev) {} static inline void pm_runtime_forbid(struct device *dev) {} +static inline int devm_pm_runtime_set_active(struct device *dev) { return 0; } static inline int devm_pm_runtime_enable(struct device *dev) { return 0; } +static inline int devm_pm_runtime_get_noresume(struct device *dev) { return 0; } static inline void pm_suspend_ignore_children(struct device *dev, bool enable) {} static inline void pm_runtime_get_noresume(struct device *dev) {} From patchwork Fri Jan 24 08:52:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= X-Patchwork-Id: 13949086 Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (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 A8D5A1F7907; Fri, 24 Jan 2025 08:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737709032; cv=none; b=fjZtaBpnlMhTw75ecIfFVL8riawPYxI9sTaHg6B2lx0ZcSqevUihetfcDeYHJnxoLa6LVAGMdTt6KFAyf/KP26IKyyeggHD7vlvgoTqhmyUbBQleO8JaytRXrEPOIKg4jjwQOohrrHbahw3n/q7As+2lauhiXBsko/WQvoaphtE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737709032; c=relaxed/simple; bh=epku/j8X4GjSIG5flo+ZN8vsdWinTiQ7kI3SLzVqYIA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ETnugMnuFDtaaTcsNbJes4f1u1daEG/uThNGQWSY+36xZ/Ehnfc76IdyJEz/B4f9amHWtl6Cz0x4o8REoAzk+O9Y9tL5RFmt5LTTeBXBHXmnIYmGBWEDrZmXLrP98/cSdx5Z8FRgKBVomO34stlb19eeXaztg5J7OJNveasuBiQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=NOnkj78n; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="NOnkj78n" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id 1757FA09FF; Fri, 24 Jan 2025 09:57:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=EN5uKDKBs2TFBzx+EqNY KD0FORICT1RtSymVEFjrtcw=; b=NOnkj78nMFZDSybAQ1VSb7yo6OtwjQaC1SzN M2cr03zkRx1yMFn/jpNlCNPT50hn78pYdDGLtxvIcJ/0SZ+6GyJAM5NuppP1myL/ Sp6Gp0tSXEj7hym6uVNBh+SW4ZfIhhA5QvjEwV9TlMTVmaWQXDOod56UagV82n9N 3CLf5TelIVcjZKLPtuYEpGG1urEtohkLnnHn6A0sD2IgGHLVGJmBqiPYY/ELunUQ VqaagED+gwbJppHqOLrcgqq6OPT8v5rNDXi51tFumxNsgQFMANgJdJzsPA36Q18n ptjomAFd1/iVhvT6185pojO9N6Gr4LFLms4kXANQAb8BaznQd+GPdxy0RUwF5h8L cunaSwhKFLu3SDDnjFVwhPRqOQGgFdRZ8DBUkl4E1IagDOaKc80EAMky44G78WQU en2o461VXVRVEW3DoG6GGf1gRvtlPU9Z8QeNsazaOMiwdDApnpeFzUZOeVKzr7/b XP9RneJ48xBtQbMCyvKcxZU5m1qUaFZT21PuoBI8ioUslmguw7dWGqQu+xHVnjPd mELz6xZJpctnxoETHphizukDIOr115QLTQvpefUGnbYD2PTnHMICx4D2fEzlBk8o fLxKqNWjX9g09SsQ1jw/+uCoCUtV0/UZZBbzqv+IyBY5TZcLL7hYxOUQtpB5L5WZ mc2seKA= From: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= To: , , CC: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= , Mark Brown , Vinod Koul , "Rafael J . Wysocki" , , , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Subject: [PATCH v2 3/4] spi: atmel-quadspi: Use `devm_dma_request_chan()` Date: Fri, 24 Jan 2025 09:52:24 +0100 Message-ID: <20250124085221.766303-12-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250124085221.766303-4-csokas.bence@prolan.hu> References: <20250124085221.766303-4-csokas.bence@prolan.hu> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1737709027;VERSION=7984;MC=3511041741;ID=70502;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A29ACD94852677063 Leave releasing of DMA channels up to the devm facilities. This way we can eliminate the rest of the "goto ladder". Signed-off-by: Bence Csókás --- drivers/spi/atmel-quadspi.c | 44 ++++++++++--------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c index abdc49d9d940..b1fb4426c78d 100644 --- a/drivers/spi/atmel-quadspi.c +++ b/drivers/spi/atmel-quadspi.c @@ -1288,18 +1288,20 @@ static int atmel_qspi_dma_init(struct spi_controller *ctrl) struct atmel_qspi *aq = spi_controller_get_devdata(ctrl); int ret; - aq->rx_chan = dma_request_chan(&aq->pdev->dev, "rx"); + aq->rx_chan = devm_dma_request_chan(&aq->pdev->dev, "rx"); if (IS_ERR(aq->rx_chan)) { aq->rx_chan = NULL; return dev_err_probe(&aq->pdev->dev, PTR_ERR(aq->rx_chan), "RX DMA channel is not available\n"); } - aq->tx_chan = dma_request_chan(&aq->pdev->dev, "tx"); + aq->tx_chan = devm_dma_request_chan(&aq->pdev->dev, "tx"); if (IS_ERR(aq->tx_chan)) { ret = dev_err_probe(&aq->pdev->dev, PTR_ERR(aq->tx_chan), "TX DMA channel is not available\n"); - goto release_rx_chan; + aq->rx_chan = NULL; + aq->tx_chan = NULL; + return ret; } ctrl->dma_rx = aq->rx_chan; @@ -1310,20 +1312,6 @@ static int atmel_qspi_dma_init(struct spi_controller *ctrl) dma_chan_name(aq->tx_chan), dma_chan_name(aq->rx_chan)); return 0; - -release_rx_chan: - dma_release_channel(aq->rx_chan); - aq->rx_chan = NULL; - aq->tx_chan = NULL; - return ret; -} - -static void atmel_qspi_dma_release(struct atmel_qspi *aq) -{ - if (aq->rx_chan) - dma_release_channel(aq->rx_chan); - if (aq->tx_chan) - dma_release_channel(aq->tx_chan); } static const struct atmel_qspi_ops atmel_qspi_ops = { @@ -1428,14 +1416,13 @@ static int atmel_qspi_probe(struct platform_device *pdev) /* Request the IRQ */ irq = platform_get_irq(pdev, 0); - if (irq < 0) { - err = irq; - goto dma_release; - } + if (irq < 0) + return irq; + err = devm_request_irq(&pdev->dev, irq, atmel_qspi_interrupt, 0, dev_name(&pdev->dev), aq); if (err) - goto dma_release; + return err; pm_runtime_set_autosuspend_delay(&pdev->dev, 500); pm_runtime_use_autosuspend(&pdev->dev); @@ -1445,7 +1432,7 @@ static int atmel_qspi_probe(struct platform_device *pdev) err = atmel_qspi_init(aq); if (err) - goto dma_release; + return err; err = spi_register_controller(ctrl); if (err) { @@ -1453,18 +1440,12 @@ static int atmel_qspi_probe(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); - goto dma_release; + return err; } pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev); return 0; - -dma_release: - if (aq->caps->has_dma) - atmel_qspi_dma_release(aq); - - return err; } static int atmel_qspi_sama7g5_suspend(struct atmel_qspi *aq) @@ -1514,9 +1495,6 @@ static void atmel_qspi_remove(struct platform_device *pdev) ret = pm_runtime_get_sync(&pdev->dev); if (ret >= 0) { - if (aq->caps->has_dma) - atmel_qspi_dma_release(aq); - if (aq->caps->has_gclk) { ret = atmel_qspi_sama7g5_suspend(aq); if (ret) From patchwork Fri Jan 24 08:52:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= X-Patchwork-Id: 13949090 Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (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 3D10421A424; Fri, 24 Jan 2025 08:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737709120; cv=none; b=evIoaBi/gECFiA6iE9nQla50RZ2/hz8Y9AU5CSLp543dSN585FTcVufiCz1iwvf1iEacRdyEFMn2qqZaY8dBNg6n5Ou0V2dEYNVwjXaJ8tTTYkADPoX2pJpwVF7W+YF3DqnoqEQlrNejtKwcyVsso2tg/kCF+NIcVmX2QcbDbEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737709120; c=relaxed/simple; bh=00BIKWjEFdesAJiVHawtYMPiLZHbdAdarr4Sl8y0DgI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uVEM10RjCzsbnq4fjBmTcPqn3gjTfsuXjVoVHhl8WzADKvk+Xo9C3RzNS1gFKIMnuqSL/I6EH2ha2W8wtT14EeoB61q1RVKpOUi4Da55OIT6EOqyzt/p3zrOl+58ENGU5iSFGjm+RU/+1Oh2w3vUFEGgwFRbyPv1LGWR+TPjOSY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=bWYdEBiI; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="bWYdEBiI" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id 67C1FA09FF; Fri, 24 Jan 2025 09:58:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=91vGKH59fvOB6uF7f30s PCflWM08DH4/8R/h6OH+xOk=; b=bWYdEBiIDfkr5t2LBwXOpExJcaNdyEpjr3q2 ujGRpZDepB+Fx3X3FYnLbdlDmMxfY3wHv0NYj6BUtLajCg44fS555JfAKXu/+f49 qu9A574fniGVyIevXemx7T1caMjd6NJr+sZSb/2sW315WOaAuQMgB9x2MqhTNkU5 On4CKaM4B/ep3/QMX9gY8i9nJJSoKN8pajGpyixUlc5blKLnoIFkc4lHc3rmBIdg rQWc+cKNU99krC1xf8pOMHpVXaRbB7XDlK55Ek5GU1uS9GieGzhqx0PRzduawBUU sgr59jdZzZHacGyk9t0Tyr6zLp1tYoHB1trhaDB4UnsWhaKoirFEwnHtvhntNpTG 7k/APjH6FD3pfQWHiG78iYXuFVQ9r0gdCZ4sE/Vz98Vv/lUpemkky1sKAYu0XjkS TVBNa2Z7F8vb1MgrF3DMe3hBUvgl8R9TtNM+FAvBBNayDlgrroxxA/FKQO/BXh3e 3aljHpxEVc0tyUJx1t+gu78iZTUPVELAE3NbEk1ncS/zoilz1InQAfMz7oaQSFZE VKZ+lXImIMm4fM2U542tYqr6Er0Ni1im0U9lzAJuycrW88k4LVyM/zEpPYA7DV0J 86WA0YFH+JE9KQkZfJw2C9vdjQrmup3iGmI+qNdrOump5JWjQLZlIIAm+UpK1VIq yTsUm3g= From: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= To: =?utf-8?b?Q3PDs2vDoXMsIEJlbmNl?= , "Mark Brown" , Varshini Rajendran , Tudor Ambarus , , , CC: Vinod Koul , "Rafael J . Wysocki" , Krzysztof Kozlowski , , , Alexander Dahl , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Subject: [PATCH v2 4/4] spi: atmel-quadspi: Fix unbalanced pm_runtime by using devm_ API Date: Fri, 24 Jan 2025 09:52:27 +0100 Message-ID: <20250124085221.766303-15-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250124085221.766303-4-csokas.bence@prolan.hu> References: <20250124085221.766303-4-csokas.bence@prolan.hu> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1737709115;VERSION=7984;MC=139577634;ID=70505;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A29ACD94852677063 Fix unbalanced PM in error path of `atmel_qspi_probe()` by using `devm_pm_runtime_*()` functions. Reported-by: Alexander Dahl Closes: https://lore.kernel.org/linux-spi/20250110-paycheck-irregular-bcddab1276c7@thorsis.com/ Fixes: 5af42209a4d2 ("spi: atmel-quadspi: Add support for sama7g5 QSPI") Signed-off-by: Bence Csókás --- drivers/spi/atmel-quadspi.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c index b1fb4426c78d..f2164685d3d5 100644 --- a/drivers/spi/atmel-quadspi.c +++ b/drivers/spi/atmel-quadspi.c @@ -1426,22 +1426,18 @@ static int atmel_qspi_probe(struct platform_device *pdev) pm_runtime_set_autosuspend_delay(&pdev->dev, 500); pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - pm_runtime_get_noresume(&pdev->dev); + devm_pm_runtime_set_active(&pdev->dev); + devm_pm_runtime_enable(&pdev->dev); + devm_pm_runtime_get_noresume(&pdev->dev); err = atmel_qspi_init(aq); if (err) return err; err = spi_register_controller(ctrl); - if (err) { - pm_runtime_put_noidle(&pdev->dev); - pm_runtime_disable(&pdev->dev); - pm_runtime_set_suspended(&pdev->dev); - pm_runtime_dont_use_autosuspend(&pdev->dev); + if (err) return err; - } + pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev); @@ -1511,10 +1507,6 @@ static void atmel_qspi_remove(struct platform_device *pdev) */ dev_warn(&pdev->dev, "Failed to resume device on remove\n"); } - - pm_runtime_disable(&pdev->dev); - pm_runtime_dont_use_autosuspend(&pdev->dev); - pm_runtime_put_noidle(&pdev->dev); } static int __maybe_unused atmel_qspi_suspend(struct device *dev)