From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751885AbdKKRvF (ORCPT ); Sat, 11 Nov 2017 12:51:05 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:52884 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751737AbdKKRvC (ORCPT ); Sat, 11 Nov 2017 12:51:02 -0500 X-Google-Smtp-Source: AGs4zMY9qYhwfTzZsmpbCqKcVNgxXBNPj9QBTVx2EH7axvxtK8oSIZFQ0h2osjwTlqVayC7p4vSCqQ== Date: Sat, 11 Nov 2017 09:50:59 -0800 From: Dmitry Torokhov To: Johan Hovold Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable , Peter Ujfalusi , Marek Belisko Subject: Re: [PATCH 1/3] Input: twl4030-vibra: fix sibling-node lookup Message-ID: <20171111175059.lwfhw2wdhlj5yxhc@dtor-ws> References: <20171111154339.16875-1-johan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171111154339.16875-1-johan@kernel.org> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 11, 2017 at 04:43:37PM +0100, Johan Hovold wrote: > A helper purported to look up a child node based on its name was using > the wrong of-helper and ended up prematurely freeing the parent of-node > while searching the whole device tree depth-first starting at the parent > node. Ugh, this all is pretty ugly business. Can we teach MFD to allow specifying firmware node to be attached to the platform devices it creates in mfd_add_device() so that the leaf drivers simply call device_property_read_XXX() on their own device and not be bothered with weird OF refcount issues or what node they need to locate and parse? Thanks! > > Fixes: 64b9e4d803b1 ("input: twl4030-vibra: Support for DT booted kernel") > Fixes: e661d0a04462 ("Input: twl4030-vibra - fix ERROR: Bad of_node_put() warning") > Cc: stable # 3.7 > Cc: Peter Ujfalusi > Cc: Marek Belisko > Signed-off-by: Johan Hovold > --- > drivers/input/misc/twl4030-vibra.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c > index 6c51d404874b..c37aea9ac272 100644 > --- a/drivers/input/misc/twl4030-vibra.c > +++ b/drivers/input/misc/twl4030-vibra.c > @@ -178,12 +178,14 @@ static SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops, > twl4030_vibra_suspend, twl4030_vibra_resume); > > static bool twl4030_vibra_check_coexist(struct twl4030_vibra_data *pdata, > - struct device_node *node) > + struct device_node *parent) > { > + struct device_node *node; > + > if (pdata && pdata->coexist) > return true; > > - node = of_find_node_by_name(node, "codec"); > + node = of_get_child_by_name(parent, "codec"); > if (node) { > of_node_put(node); > return true; > -- > 2.15.0 > -- Dmitry