Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp233804pxb; Thu, 14 Jan 2021 04:45:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+3yH+bThs6N6WSIQNSAR8BTIIs9/X99eU08zmAmMwKA3I3E/H8B4xpot/cajzVgh3G4Zy X-Received: by 2002:a17:906:a84a:: with SMTP id dx10mr5215338ejb.13.1610628306915; Thu, 14 Jan 2021 04:45:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610628306; cv=none; d=google.com; s=arc-20160816; b=VjTIyMmSrCtwjllcN2ebDUILZ9Tq27QZrDwtBZbqRK+afW43zGx/5XXZhso8f2qC6f Uyh/b9vQx+GgLfr10VhLmDkCaEF3Lk/1MoncmVTXNgi60xvHZ5mVh1jYcPGsqb5FhEgj fEiDSZ75mdlke9HBFY1Sn7n6BNqRxIrIoZl5L4nd/YQOJ5w2dVvu2ny9hONORNTlzBtm 4CUVVPQRjJve3nhGjfYu4XE/Ogs45UyrDCNE8LMwIUPFRzbr5dYJmggA/9cGt6JJMs51 +a7ZlcNncK3J4ceMAiZl1P1GiCALjc55rEIEMSqnnQJB4IwggtosPVS54aJpRcZVolfH WvLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2wfajKWyHjM8MAX659L6/jhdJIphUPqJ8uHpL4b+Ht0=; b=AAyQiaqqmKN9NttPvN2mFqV3VB00KLICAskZiEPkdTF6v+zqI5UJClFFWdDNcVS9Wi rPndtbjw32h1wwZG+tk0nc6t7CVZZrBX+S+4i6l49DOZhEg0I4T8QodeoHwAzAwlRaRk PZfOUOGpPiKSHRnxgMb2S8vmHwkDwPdt88G03cZt79qbWgE4bXnFLbjxG+ezXLa2elrH uYylw9m1i6C/RLK3LulvDlGBNUcQynHm97vZJuHJBkujx6DyCGuNyQTpxkdsUQdo1oCd mqb4u4X8ROP9eNTYZv2liCQ62EaigVHq3VExGlrbu4BWLwC4Wkgghe1t2JmBLCn3+aV8 vmfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uWgHalDW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u18si2634290edy.420.2021.01.14.04.44.42; Thu, 14 Jan 2021 04:45:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uWgHalDW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728944AbhANMmS (ORCPT + 99 others); Thu, 14 Jan 2021 07:42:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:59380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728900AbhANMmR (ORCPT ); Thu, 14 Jan 2021 07:42:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7CD4C23A68; Thu, 14 Jan 2021 12:40:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610628057; bh=0EacZozNqX5kdAE9JNs/z+ZT90LRoDz55sehFetkTE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uWgHalDW53zNdqiPkj2tk2NUjLZ1JP0c66HbPn2opZoo1wENNJ/h1qhBb2Oz1TcBc 7wl4l5kCO8KE3hD72Y2HZUtWtUJRhg3+JdpeESHtN+ObWiea15vkB8aFFwDv+5FPLN aLWBctsZvruwgu5UEgMUBL7wHDEdS8b3dS0RIByZPcYKXTGnv8SnuHcEu3IKKNT4uq VLh4VDWyl91VBrgXjENa+040sxqhobpAr8MiYZJPQE09xd5MjYEBwoP+DyFL+5s5qm 62l6n0qZEh5K2H9eMxS22rVRLB/wWKdetPmdeMdg4pexH2BK0Ny6rOELTLEM8tESa6 gYaKx6O/z0BQw== Received: by pali.im (Postfix) id 863C5B5F; Thu, 14 Jan 2021 13:40:55 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Gregory Clement , Andrew Lunn , Michael Turquette , Stephen Boyd , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Cc: =?UTF-8?q?Marek=20Beh=C3=BAn?= , "Miquel Raynal" , "Tomasz Maciej Nowak" , "Luka Perkov" , "Andre Heider" , "Vladimir Vid" , "Russell King" , =?UTF-8?q?G=C3=A9rald=20Kerma?= , "Konstantin Porotchkin" Subject: [PATCH mvebu v2 10/10] cpufreq: armada-37xx: Fix module unloading Date: Thu, 14 Jan 2021 13:40:32 +0100 Message-Id: <20210114124032.12765-11-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210114124032.12765-1-pali@kernel.org> References: <20210114124032.12765-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver is missing module_exit hook. Add proper driver exit function which unregisters the platform device and cleans up the data. Signed-off-by: Pali Rohár --- drivers/cpufreq/armada-37xx-cpufreq.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/cpufreq/armada-37xx-cpufreq.c b/drivers/cpufreq/armada-37xx-cpufreq.c index f13646d143de..565c40f536ef 100644 --- a/drivers/cpufreq/armada-37xx-cpufreq.c +++ b/drivers/cpufreq/armada-37xx-cpufreq.c @@ -85,6 +85,8 @@ static int avs_map[] = { }; struct armada37xx_cpufreq_state { + struct platform_device *pdev; + struct device *cpu_dev; struct regmap *regmap; u32 nb_l0l1; u32 nb_l2l3; @@ -495,6 +497,9 @@ static int __init armada37xx_cpufreq_driver_init(void) if (ret) goto disable_dvfs; + armada37xx_cpufreq_state->cpu_dev = cpu_dev; + armada37xx_cpufreq_state->pdev = pdev; + platform_set_drvdata(pdev, dvfs); return 0; disable_dvfs: @@ -513,6 +518,26 @@ static int __init armada37xx_cpufreq_driver_init(void) /* late_initcall, to guarantee the driver is loaded after A37xx clock driver */ late_initcall(armada37xx_cpufreq_driver_init); +static void __exit armada37xx_cpufreq_driver_exit(void) +{ + struct platform_device *pdev = armada37xx_cpufreq_state->pdev; + struct armada_37xx_dvfs *dvfs = platform_get_drvdata(pdev); + unsigned long freq; + int load_lvl; + + platform_device_unregister(pdev); + + armada37xx_cpufreq_disable_dvfs(armada37xx_cpufreq_state->regmap); + + for (load_lvl = ARMADA_37XX_DVFS_LOAD_0; load_lvl < LOAD_LEVEL_NR; load_lvl++) { + freq = dvfs->cpu_freq_max / dvfs->divider[load_lvl]; + dev_pm_opp_remove(armada37xx_cpufreq_state->cpu_dev, freq); + } + + kfree(armada37xx_cpufreq_state); +} +module_exit(armada37xx_cpufreq_driver_exit); + static const struct of_device_id __maybe_unused armada37xx_cpufreq_of_match[] = { { .compatible = "marvell,armada-3700-nb-pm" }, { }, -- 2.20.1