From patchwork Tue Dec 24 02:20:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 3399921 Return-Path: X-Original-To: patchwork-linux-omap@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 6C6C59F169 for ; Tue, 24 Dec 2013 02:26:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97185201F4 for ; Tue, 24 Dec 2013 02:26:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8BEF20131 for ; Tue, 24 Dec 2013 02:26:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757912Ab3LXCZ6 (ORCPT ); Mon, 23 Dec 2013 21:25:58 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:38617 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753139Ab3LXCZ5 (ORCPT ); Mon, 23 Dec 2013 21:25:57 -0500 Received: by mail-pa0-f50.google.com with SMTP id kp14so4069777pab.23 for ; Mon, 23 Dec 2013 18:25:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=r6+TZ7x7d075nfxFLO7GILtOHD9cF7RM3VYdilj++Hg=; b=miTCwsu5nQPlClFvwtG20lUDhMtXXYqbbnQF3PsVdTlNcbY9UhW9HhfBOSbv49xGfk wGlDPDQzbrqN+21vUsdSyFFOGR+j6FOFQberfMPADDdKr/UMJbaQ9wBkkBRaNSB+53fF DJzDr+2BvDRzsvPxf2QOpvABMOtyEQp+d6/nrk46sVA88HBDSSNXf/HALwEwKhAJ40tb FYam1dUdLoCGxgwG98kNfttCl4MEeYwW3rZ8ylx+1woBEHRwsJDignwgypUkQ4rjtdzu +Na60YHXHo6Js8sghwEL5M8Qi0sUc0g1T0KcqI1YtCSLPiw7qyEVP1C0QMJZY/zlF6in T6Rw== X-Gm-Message-State: ALoCoQnu0DSa7iiP5EWqC69iXWzDUSJqdRTIQP9ldq6DGdpawrDl7A4nJsJ5MQom7YBz5omDSAtO X-Received: by 10.68.193.233 with SMTP id hr9mr29800159pbc.26.1387851956354; Mon, 23 Dec 2013 18:25:56 -0800 (PST) Received: from localhost (69-170-40-3.static-ip.telepacific.net. [69.170.40.3]) by mx.google.com with ESMTPSA id gv10sm37592117pbd.0.2013.12.23.18.25.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2013 18:25:55 -0800 (PST) Date: Mon, 23 Dec 2013 18:20:36 -0800 From: Anton Vorontsov To: Sebastian Reichel Cc: Sebastian Reichel , David Woodhouse , Rob Herring , Pawel Moll , Mark Rutland , Stephen Warren , Ian Campbell , Rob Landley , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, devicetree@vger.kernel.org, Pali =?utf-8?B?Um9ow6Fy?= , freemangordon@abv.bg, aaro.koskinen@iki.fi, pavel@ucw.cz Subject: Re: [PATCH 1/3] power_supply: add power_supply_get_by_phandle Message-ID: <20131224022035.GA25939@lizard> References: <1385311771-447-1-git-send-email-sre@debian.org> <1385311771-447-2-git-send-email-sre@debian.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1385311771-447-2-git-send-email-sre@debian.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 On Sun, Nov 24, 2013 at 05:49:29PM +0100, Sebastian Reichel wrote: > Add method to get power supply by device tree phandle. > > Signed-off-by: Sebastian Reichel > --- > drivers/power/power_supply_core.c | 24 ++++++++++++++++++++++++ > include/linux/power_supply.h | 2 ++ > 2 files changed, 26 insertions(+) > > diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c > index 08bce22..99e4b41 100644 > --- a/drivers/power/power_supply_core.c > +++ b/drivers/power/power_supply_core.c > @@ -340,6 +340,30 @@ struct power_supply *power_supply_get_by_name(const char *name) ... > + > + dev = class_find_device(power_supply_class, NULL, power_supply_np, > + power_supply_match_device_node); > + > + of_node_put(power_supply_np); > + > + return dev ? dev_get_drvdata(dev) : NULL; > +} > +EXPORT_SYMBOL_GPL(power_supply_get_by_phandle); The code had no !CONFIG_OF protection so I had to make the following changes to this patch: --- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 23cd055..2660664 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -341,6 +341,7 @@ struct power_supply *power_supply_get_by_name(const char *name) } EXPORT_SYMBOL_GPL(power_supply_get_by_name); +#ifdef CONFIG_OF static int power_supply_match_device_node(struct device *dev, const void *data) { return dev->parent && dev->parent->of_node == data; @@ -364,6 +365,7 @@ struct power_supply *power_supply_get_by_phandle(struct device_node *np, return dev ? dev_get_drvdata(dev) : NULL; } EXPORT_SYMBOL_GPL(power_supply_get_by_phandle); +#endif /* CONFIG_OF */ int power_supply_powers(struct power_supply *psy, struct device *dev) { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 8d06537..c9dc4e0 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -244,8 +244,14 @@ extern struct atomic_notifier_head power_supply_notifier; extern int power_supply_reg_notifier(struct notifier_block *nb); extern void power_supply_unreg_notifier(struct notifier_block *nb); extern struct power_supply *power_supply_get_by_name(const char *name); +#ifdef CONFIG_OF extern struct power_supply *power_supply_get_by_phandle(struct device_node *np, const char *property); +#else /* !CONFIG_OF */ +static inline struct power_supply * +power_supply_get_by_phandle(struct device_node *np, const char *property) +{ return NULL; } +#endif /* CONFIG_OF */ extern void power_supply_changed(struct power_supply *psy); extern int power_supply_am_i_supplied(struct power_supply *psy); extern int power_supply_set_battery_charged(struct power_supply *psy);