From patchwork Tue Feb 25 09:12:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 25245 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EFD4820558 for ; Tue, 25 Feb 2014 09:13:18 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf314907iec.4 for ; Tue, 25 Feb 2014 01:13:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=3Em+11V3nIiMxmYDxv4F5TVCtq4U6hbGtDG3GVkJr1M=; b=Xb12KmkFRvdkkqtflUWHjj6d/jd/m5I3rkJ/xl+TWLjPimlatWy2x5urATsyGF6Fv9 wGu+vQOicYlfiqr/LHG8Gb2Tiy6gZ+PEfaz+HjQXhDLxorgiwBFNqcjUj1D7aoW7hzbn VAci/tCNbmV7t2AuLkCHM1QMGEmgihxP8z77P+VFw7YLGVtSLM+QhBOVRDGSo+9NqSsu 5TPb+Q2N6ZItyFIPZKgFqOn9WpH1ct+6hrtERLnylYTYcoD5mzAKhWMBIeQFDVh5+urq 0Vjdc2bGlg4mOA+tB7GEiM3lxNIQVm5+Onj6tyeg/aN9XF2GPSA1NdQiSL4cy+hkycNy kuoQ== X-Gm-Message-State: ALoCoQkw0I5fOPepiYeagQDF79+wVR372SeUrq8Lj/nIOV7s9DBRjOv5SiNguu9ZgL8wRozUysit X-Received: by 10.50.124.33 with SMTP id mf1mr11565178igb.6.1393319598443; Tue, 25 Feb 2014 01:13:18 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.116 with SMTP id g107ls2256750qgg.49.gmail; Tue, 25 Feb 2014 01:13:18 -0800 (PST) X-Received: by 10.58.249.228 with SMTP id yx4mr161192vec.50.1393319598288; Tue, 25 Feb 2014 01:13:18 -0800 (PST) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id p9si6645160vdv.44.2014.02.25.01.13.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 01:13:18 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id im17so7042119vcb.19 for ; Tue, 25 Feb 2014 01:13:18 -0800 (PST) X-Received: by 10.220.67.18 with SMTP id p18mr185588vci.14.1393319598185; Tue, 25 Feb 2014 01:13:18 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp123348vcz; Tue, 25 Feb 2014 01:13:17 -0800 (PST) X-Received: by 10.68.178.66 with SMTP id cw2mr5184241pbc.89.1393319596663; Tue, 25 Feb 2014 01:13:16 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iy3si2915946pbb.244.2014.02.25.01.13.15; Tue, 25 Feb 2014 01:13:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599AbaBYJNG (ORCPT + 26 others); Tue, 25 Feb 2014 04:13:06 -0500 Received: from mail-ob0-f173.google.com ([209.85.214.173]:33356 "EHLO mail-ob0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750744AbaBYJNA convert rfc822-to-8bit (ORCPT ); Tue, 25 Feb 2014 04:13:00 -0500 Received: by mail-ob0-f173.google.com with SMTP id wp18so1807950obc.32 for ; Tue, 25 Feb 2014 01:12:59 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.83.140 with SMTP id q12mr338651oey.10.1393319579796; Tue, 25 Feb 2014 01:12:59 -0800 (PST) Received: by 10.60.117.42 with HTTP; Tue, 25 Feb 2014 01:12:59 -0800 (PST) In-Reply-To: <1393318071-13524-1-git-send-email-philippe.retornaz@epfl.ch> References: <1393318071-13524-1-git-send-email-philippe.retornaz@epfl.ch> Date: Tue, 25 Feb 2014 14:42:59 +0530 Message-ID: Subject: Re: [PATCH 1/1] regulator: mc13xxx: check if DT is enabled From: Sachin Kamat To: =?ISO-8859-1?Q?Philippe_R=E9tornaz?= Cc: Mark Brown , LKML , Liam Girdwood Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 25 February 2014 14:17, Philippe Rétornaz wrote: > This fix a regression on non-DT board booted with a DT enabled kernel > > Signed-off-by: Philippe Rétornaz > --- > drivers/regulator/mc13xxx-regulator-core.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c > index 4498a3f..a10c999 100644 > --- a/drivers/regulator/mc13xxx-regulator-core.c > +++ b/drivers/regulator/mc13xxx-regulator-core.c > @@ -167,6 +167,9 @@ int mc13xxx_get_num_regulators_dt(struct platform_device *pdev) > struct device_node *parent; > int num; > > + if(!pdev->dev.parent->of_node) > + return -ENODEV; > + > of_node_get(pdev->dev.parent->of_node); > parent = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); > if (!parent) > @@ -187,6 +190,9 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( > struct device_node *parent, *child; > int i, parsed = 0; > > + if(!pdev->dev.parent->of_node) > + return NULL; > + > of_node_get(pdev->dev.parent->of_node); > parent = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); > if (!parent) > -- > 1.7.9.5 > Thanks for the patch. I was about to send a similar patch which also does a little more cleanup. If you could test it in DT and non-DT modes that would be great. I attach the diff below. You can even fold it into your patch if you wish. ------------------ @@ -187,8 +189,10 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( struct device_node *parent, *child; int i, parsed = 0; - of_node_get(pdev->dev.parent->of_node); - parent = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); + if (!pdev->dev.of_node) + return NULL; + + parent = of_get_child_by_name(pdev->dev.of_node, "regulators"); if (!parent) return NULL; diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c index 4498a3f0733d..bf75fcabfa3c 100644 --- a/drivers/regulator/mc13xxx-regulator-core.c +++ b/drivers/regulator/mc13xxx-regulator-core.c @@ -167,8 +167,10 @@ int mc13xxx_get_num_regulators_dt(struct platform_device *pdev) struct device_node *parent; int num; - of_node_get(pdev->dev.parent->of_node); - parent = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); + if (!pdev->dev.of_node) + return -ENODEV; + + parent = of_get_child_by_name(pdev->dev.of_node, "regulators"); if (!parent) return -ENODEV;