From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752880AbbGGG6R (ORCPT ); Tue, 7 Jul 2015 02:58:17 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:34933 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751388AbbGGG6G (ORCPT ); Tue, 7 Jul 2015 02:58:06 -0400 Date: Tue, 7 Jul 2015 07:58:01 +0100 From: Lee Jones To: "Opensource [Adam Thomson]" Cc: Samuel Ortiz , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , "linux-pm@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Support Opensource , jic23@cam.ac.uk Subject: Re: [PATCH v2 3/4] power: Add support for DA9150 Fuel-Gauge Message-ID: <20150707065801.GG3182@x1> References: <596f44407759e2047a02594367116f9c92afee56.1435308209.git.Adam.Thomson.Opensource@diasemi.com> <20150703152217.GC10500@x1> <2E89032DDAA8B9408CB92943514A0337AB55C839@SW-EX-MBX01.diasemi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2E89032DDAA8B9408CB92943514A0337AB55C839@SW-EX-MBX01.diasemi.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 06 Jul 2015, Opensource [Adam Thomson] wrote: > On July 3, 2015 16:22, Lee Jones wrote: > > > > +/* > > > + * Function template to provide battery temperature. Should provide > > > + * 0.1 degrees C resolution return values. > > > + */ > > > +typedef int (*da9150_read_temp_t)(void *context); > > > + > > > +/* Register temp callback function */ > > > +void da9150_fg_register_temp_cb(struct power_supply *psy, > > da9150_read_temp_t cb, > > > + void *cb_context); > > > + > > > #endif /* __DA9150_FG_H */ > > > > I still don't get why you think pointers are better than just calling > > the function directly. Can the *fn() ever point to different functions? > > Here, the intention is to cover the scenario where a battery has no internal > thermistor, and cannot provide temperature readings to the DA9150 device. In > that scenario I've allowed for the option of providing an external function > which can give the temperature reading instead as DA9150 will not be able to > provide a correct reading in that scenario. This would be platform dependent and > such a platform using a battery not employing an NTC in their battery can > register its own call-back function to provide battery temperature instead. > > So, in answer to your question, yes. Before you add this scenario, I would like to see the code which utilises it. I'm not a fan of coding-up 'just-in-case's. Please re-submit when you have a user in the same patch-set. This whole idea will need a discussion with Jonathan (the IIO Maintainer), now CC'ed. -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog