From patchwork Sun Jun 14 14:29:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 6604901 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 40AFAC0020 for ; Sun, 14 Jun 2015 14:29:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3385C20555 for ; Sun, 14 Jun 2015 14:29:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 37CDB20552 for ; Sun, 14 Jun 2015 14:29:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752207AbbFNO3q (ORCPT ); Sun, 14 Jun 2015 10:29:46 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:46340 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752183AbbFNO3q (ORCPT ); Sun, 14 Jun 2015 10:29:46 -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 1Z48uu-0007Ja-R6 from Vladimir_Zapolskiy@mentor.com ; Sun, 14 Jun 2015 07:29:45 -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.224.2; Sun, 14 Jun 2015 15:29:43 +0100 From: Vladimir Zapolskiy To: Lee Jones , Jingoo Han , Thierry Reding CC: , Subject: [PATCH] backlight: pwm: reject legacy pwm request for device defined in dt Date: Sun, 14 Jun 2015 17:29:32 +0300 Message-ID: <1434292172-22129-1-git-send-email-vladimir_zapolskiy@mentor.com> X-Mailer: git-send-email 2.1.4 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=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Platform PWM backlight data provided by board's device tree should be complete enough to successfully request a pwm device using pwm_get() API. This change fixes a bug, when an arbitrary (first found) PWM is connected to a "pwm-backlight" compatible device, when explicit PWM device reference is not given. Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt already describes "pwms" as a required property, instead of blind selection of a potentially wrong PWM reject legacy PWM device registration request, leave legacy API only for non-dt cases. Based on initial implementation done by Dmitry Eremin-Solenikov. Reported-by: Dmitry Eremin-Solenikov Signed-off-by: Vladimir Zapolskiy Acked-by: Thierry Reding --- drivers/video/backlight/pwm_bl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 57cb9ec..9991cdb 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -271,15 +271,16 @@ static int pwm_backlight_probe(struct platform_device *pdev) } pb->pwm = devm_pwm_get(&pdev->dev, NULL); - if (IS_ERR(pb->pwm)) { + 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"); - if (IS_ERR(pb->pwm)) { - dev_err(&pdev->dev, "unable to request legacy PWM\n"); - ret = PTR_ERR(pb->pwm); - goto err_alloc; - } + } + + if (IS_ERR(pb->pwm)) { + dev_err(&pdev->dev, "unable to request PWM\n"); + ret = PTR_ERR(pb->pwm); + goto err_alloc; } dev_dbg(&pdev->dev, "got pwm for backlight\n");