From patchwork Thu Feb 8 16:51:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 198492 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp312990dyd; Thu, 8 Feb 2024 09:06:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVKM0jrIWXLJdv8EwRl/fiJxg69L7D3t+6SBZimRbVOeKX23eExd8NOrbHH8B+C9f1VMCjznAt2D2k1uO1NWtqdatSgXg== X-Google-Smtp-Source: AGHT+IELqVEMkly3SnDIzGe8NxY2MDvRR7r+3D1rrnCXKRcZxxmB9AomQatdrbspKlI9DjGyXHCt X-Received: by 2002:a17:902:ed04:b0:1d8:ee41:de89 with SMTP id b4-20020a170902ed0400b001d8ee41de89mr7047962pld.69.1707411983966; Thu, 08 Feb 2024 09:06:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707411983; cv=pass; d=google.com; s=arc-20160816; b=MqiQbeOXSKWQFY1MSFXEEn3trflR7ntHxq1YY+wuPC+Dk6fn1F6uziAqnl6pALXkAF zf/9q6cayvas4s+h0E9ifLbYONIO/vzhG/cpOk05Yx0QQx+zx3VI1pI9ZlGsnt4Ead/J NlI+JFIxuqC9Wocm+B4xn1ZqSbb70KDV0+TYS5y83Px+LNI84krPzx43LGF9d4Y95p9g snKmng91Y5NZRGRy4DjhQMVX4HDFMQDlRYmTr3Xl6Tf6ylblykc2SgJkSiAvaaJS4QME USBE8BBp1UfbO0v84YLSbRy0+Hcbn3i7Ufhp+2UVgeBoIWwI9K38PwtH3WS6nIpVwymf W/dw== 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:dkim-signature; bh=XgXkhbX2RXhlkR64jmiumGzBiNiAvpSx9IeblZh65dQ=; fh=2inIT5MYMK1SaM9rNgm2mqpea4c9wcTXM2VGtABhP04=; b=ioN5GueP7rGILqAMe1CbALefNI6JYg5MNPnq86fvsc8+Rz6BECLh4JQDjYGP3yyoja wZ8pgc72iAgva329DLRnMHhTCfC2FIb4vnhjeDH8xnhQMbC1mUSE32gD/9ZhePp4QFEb TgBt6S+6NDbFUZXZOzWUemAgxGtOHLK1v1aqQSLvsqLmhAInFhntOCckrh00V0R34TJU nPWz5LAvfj19l8Jeub0+NWJzMYTr2Gfwh0DUaEr58kkyIAfqO/qhE2KrtdEVT9bCXwAM rvm63h9duww9PbKIBSDuhc14DynMIAiiq6nVc8KJgf6VHmVUl3juo49SORjiW0mQpX5x YeHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=W94LrZvj; 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-58381-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58381-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=2; AJvYcCWKW5vj5RsQLL9ExTBgs2VlpKq0+7OQe29Eiyxk5nmkpn4g1LJwp80Knekn4ZKPG4sl53PRHDqZz7X0bjAKD77S/ydH9g== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t3-20020a170902e84300b001d9e1ab2acbsi34434plg.356.2024.02.08.09.06.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 09:06:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58381-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=W94LrZvj; 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-58381-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58381-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8BF91B2801D for ; Thu, 8 Feb 2024 16:52:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC6D87F7FC; Thu, 8 Feb 2024 16:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="W94LrZvj" Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 21F83823D4; Thu, 8 Feb 2024 16:51:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707411091; cv=none; b=TjhXLwIikWIIOm32lTwbgGq5WqkvSklFdPHfeFBW7+2pnnKmtK+/M4bMPDH7woPZUuk3RB7dq8qNiZfDmVGR0CMDM2vtSKLwzEZ1xf1mmlmasZSUiSASi5gZYEL9sb+w51FEayV4RaWYyRIN+oYT3GCf9tDsD8EhYvQ5IZ/ol0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707411091; c=relaxed/simple; bh=/bgoFQj8jLPHiXib2qrTtT2gzomVqVTRO7+L5T8TMP0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f5WcDMLZN4fIDxKBYhMtM4CrY5QlXJzfilb61jFDUqwHhHvauxlbfpSjBbbgWFVYDN4cjugMOwqrZbVdJLdoPb2Mby2Pjn0gjd+qt+Gh17OAQSGNeqtTQFaZZ1RQejhyNmJWmneGf+vQeTT7LAFJ/wDpQNJi7Ey6JfW9UnP0+kI= 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=W94LrZvj; arc=none smtp.client-ip=198.47.19.142 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 lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 418GpGZl048968; Thu, 8 Feb 2024 10:51:16 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707411076; bh=XgXkhbX2RXhlkR64jmiumGzBiNiAvpSx9IeblZh65dQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=W94LrZvjxTwSugcfGEB7lJIzvj3Bj+caEnV2WbbOxhPLfGdEoI4twDuwW+MfzkQTn aNo+xk/SxMNxvSH76Atll2dieR1/ByTTdamKH2ng0ip5mpdrqIKochZrOxoXeKOHUi ajxjXv5ATEo/riafph9Awy3GDxxI80btQc8hbzwQ= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 418GpGMv028648 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 8 Feb 2024 10:51:16 -0600 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 8 Feb 2024 10:51:16 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE103.ent.ti.com (157.170.170.33) 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; Thu, 8 Feb 2024 10:51:16 -0600 Received: from lelvsmtp5.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 418GpFwD063394; Thu, 8 Feb 2024 10:51:16 -0600 From: Andrew Davis To: Bjorn Andersson , Baolin Wang CC: , , , Andrew Davis Subject: [PATCH v2 2/4] hwspinlock: omap: Use devm_pm_runtime_enable() helper Date: Thu, 8 Feb 2024 10:51:12 -0600 Message-ID: <20240208165114.63148-2-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240208165114.63148-1-afd@ti.com> References: <20240208165114.63148-1-afd@ti.com> 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: 1790351228923240892 X-GMAIL-MSGID: 1790351228923240892 This disables runtime PM on module exit automatically for us, currently we manually disable runtime PM which can be error-prone if not done in the right order or missed in some exit path. This also allows us to simplify the probe exit path and remove callbacks. Do that here. While here, as we can now return right after registering our hwspinlock, simply return directly and remove the extra debug message. Signed-off-by: Andrew Davis --- Changes for v2: - Return directly from register as suggested on v1 - Clarify commit message drivers/hwspinlock/omap_hwspinlock.c | 33 +++++++--------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap_hwspinlock.c index cca55143d24d4..3bd3ffab92100 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -89,10 +89,10 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) * make sure the module is enabled and clocked before reading * the module SYSSTATUS register */ - pm_runtime_enable(&pdev->dev); + devm_pm_runtime_enable(&pdev->dev); ret = pm_runtime_resume_and_get(&pdev->dev); if (ret < 0) - goto runtime_err; + return ret; /* Determine number of locks */ i = readl(io_base + SYSSTATUS_OFFSET); @@ -104,41 +104,26 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) */ ret = pm_runtime_put(&pdev->dev); if (ret < 0) - goto runtime_err; + return ret; /* one of the four lsb's must be set, and nothing else */ - if (hweight_long(i & 0xf) != 1 || i > 8) { - ret = -EINVAL; - goto runtime_err; - } + if (hweight_long(i & 0xf) != 1 || i > 8) + return -EINVAL; num_locks = i * 32; /* actual number of locks in this device */ bank = devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks), GFP_KERNEL); - if (!bank) { - ret = -ENOMEM; - goto runtime_err; - } + if (!bank) + return -ENOMEM; platform_set_drvdata(pdev, bank); for (i = 0, hwlock = &bank->lock[0]; i < num_locks; i++, hwlock++) hwlock->priv = io_base + LOCK_BASE_OFFSET + sizeof(u32) * i; - ret = hwspin_lock_register(bank, &pdev->dev, &omap_hwspinlock_ops, + return hwspin_lock_register(bank, &pdev->dev, &omap_hwspinlock_ops, base_id, num_locks); - if (ret) - goto runtime_err; - - dev_dbg(&pdev->dev, "Registered %d locks with HwSpinlock core\n", - num_locks); - - return 0; - -runtime_err: - pm_runtime_disable(&pdev->dev); - return ret; } static void omap_hwspinlock_remove(struct platform_device *pdev) @@ -151,8 +136,6 @@ static void omap_hwspinlock_remove(struct platform_device *pdev) dev_err(&pdev->dev, "%s failed: %d\n", __func__, ret); return; } - - pm_runtime_disable(&pdev->dev); } static const struct of_device_id omap_hwspinlock_of_match[] = {