From patchwork Sat Oct 11 13:46:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 5069021 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B370B9F2F1 for ; Sat, 11 Oct 2014 13:46:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A9A65201C0 for ; Sat, 11 Oct 2014 13:46:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F2E6201DD for ; Sat, 11 Oct 2014 13:46:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752152AbaJKNqp (ORCPT ); Sat, 11 Oct 2014 09:46:45 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:61172 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752162AbaJKNql (ORCPT ); Sat, 11 Oct 2014 09:46:41 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Xcx0K-0005tW-CE from Vladimir_Zapolskiy@mentor.com ; Sat, 11 Oct 2014 06:46:40 -0700 Received: from eyas.fin.mentorg.com (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server (TLS) id 14.3.181.6; Sat, 11 Oct 2014 14:46:39 +0100 From: Vladimir Zapolskiy To: , CC: Thierry Reding , Jingoo Han , Bryan Wu , Lee Jones , Subject: [PATCH 2/2] backlight: pwm: clean up pwm requested using legacy API Date: Sat, 11 Oct 2014 16:46:26 +0300 Message-ID: <1413035186-11771-3-git-send-email-vladimir_zapolskiy@mentor.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1413035186-11771-1-git-send-email-vladimir_zapolskiy@mentor.com> References: <1413035186-11771-1-git-send-email-vladimir_zapolskiy@mentor.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.76] Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If PWM device is requested by means of legacy API pwm_request(), its resources are not freed on module unbind, which may cause an oops on access, e.g. by reading /sys/kernel/debug/pwm. Reported-by: Dmitry Eremin-Solenikov Signed-off-by: Vladimir Zapolskiy Acked-by: Thierry Reding --- drivers/video/backlight/pwm_bl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index dd7aaf7..40770dd 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -34,6 +34,7 @@ struct pwm_bl_data { struct regulator *power_supply; struct gpio_desc *enable_gpio; unsigned int scale; + bool legacy; int (*notify)(struct device *, int brightness); void (*notify_after)(struct device *, @@ -274,6 +275,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->pwm = devm_pwm_get(&pdev->dev, NULL); if (IS_ERR(pb->pwm) && !pdev->dev.of_node) { dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n"); + pb->legacy = true; pb->pwm = pwm_request(data->pwm_id, "pwm-backlight"); } @@ -339,6 +341,8 @@ static int pwm_backlight_remove(struct platform_device *pdev) if (pb->exit) pb->exit(&pdev->dev); + if (pb->legacy) + pwm_free(pb->pwm); return 0; }