From: Lee Jones <lee.jones@linaro.org>
To: "Opensource [Adam Thomson]" <Adam.Thomson.Opensource@diasemi.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
Jonathan Cameron <jic23@kernel.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
Sebastian Reichel <sre@kernel.org>,
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
David Woodhouse <dwmw2@infradead.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Joe Perches <joe@perches.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Support Opensource <Support.Opensource@diasemi.com>
Subject: Re: [PATCH v2 1/7] mfd: Add support for DA9150 combined charger & fuel-gauge device
Date: Tue, 16 Sep 2014 15:07:40 -0700 [thread overview]
Message-ID: <20140916220740.GQ25162@lee--X1> (raw)
In-Reply-To: <2E89032DDAA8B9408CB92943514A0337AB514E7C@SW-EX-MBX01.diasemi.com>
On Tue, 16 Sep 2014, Opensource [Adam Thomson] wrote:
> On September 15, 2014 23:39, Lee Jones wrote:
>
> > On Wed, 10 Sep 2014, Opensource [Adam Thomson] wrote:
> > > On September 10, 2014 10:50, Lee Jones wrote:
> > > > On Tue, 09 Sep 2014, Opensource [Adam Thomson] wrote:
> > > >
> > > > > On August 28, 2014 17:36, Lee Jones wrote:
> > > > >
> > > > > Thanks for the feedback. As a general comment a couple of the items you've
> > > > > identified relate to future updates (additional functionality being added).
> > > > > I already have code in place for this but have stripped out a couple of the
> > > > > drivers just to reduce the churn and size of patch submission. These will be
> > > > > added once these patches have been accepted.
> > > > >
> > > > > Where this is the case, I have added notes in-line against the relevant
> > > > > comments you made.
> > > > >
> > > > > > On Thu, 28 Aug 2014, Adam Thomson wrote:
> > > > > >
> > > > > > > DA9150 is a combined Charger and Fuel-Gauge IC, with additional
> > > > > > > GPIO and GPADC functionality.
> > > > > > >
> > > > > > > Signed-off-by: Adam Thomson
> > <Adam.Thomson.Opensource@diasemi.com>
> > > > > > > ---
> > > > > > > drivers/mfd/Kconfig | 12 +
> > > > > > > drivers/mfd/Makefile | 2 +
> > > > > > > drivers/mfd/da9150-core.c | 332 ++++++++++
> > > > > > > drivers/mfd/da9150-i2c.c | 176 ++++++
> >
> > [...]
> >
> > > > > > > +/* Helper functions for sub-devices to request/free IRQs */
> > > > > > > +int da9150_register_irq(struct platform_device *pdev, void *dev_id,
> > > > > > > + irq_handler_t handler, const char *name)
> > > > > > > +{
> > > > > > > + int irq, ret;
> > > > > > > +
> > > > > > > + irq = platform_get_irq_byname(pdev, name);
> > > > > > > + if (irq < 0)
> > > > > > > + return irq;
> > > > > > > +
> > > > > > > + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, handler,
> > > > > > > + IRQF_ONESHOT, name, dev_id);
> > > > > > > + if (ret)
> > > > > > > + dev_err(&pdev->dev, "Failed to request IRQ %d: %d\n", irq,
> > ret);
> > > > > > > +
> > > > > > > + return ret;
> > > > > > > +}
> > > > > > > +EXPORT_SYMBOL_GPL(da9150_register_irq);
> > > > > >
> > > > > > Why do they need help? What problem does adding these layers solve?
> > > > >
> > > > > Means I don't have to keep adding print error lines everywhere else if this
> > > > > function takes care of it. Thought that would be cleaner.
> > > >
> > > > You only need to request each IRQ once. It's just more abstraction
> > > > for the sake of it. I would prefer if you removed them.
> > >
> > > Yes, but in the charger driver for example, there are 4 IRQs to request. If
> > > I don't use this approach the IRQ requesting becomes bloated, hence why I went
> > > for a common function like this. Thought generally the intention was to cut
> > > down on repeated code?
> >
> > If you're worried about bloat in .probe() it's okay to define a new
> > function within the charger driver; however, creating a call-back into
> > the MFD driver like this I think it over-kill for 4 requests.
>
> I could do something just in the charger, but why not have something which can
> be used for all sub-devices? There is also an IRQ used in the IIO ADC driver and
> there will be another in the later fuel-gauge driver too. Doesn't make sense to
> me not to do in the MFD code when that will provide a simple common call for all
> sub-devices. What is your concern with adding something like this, just so I'm
> clear?
I guess my last response wasn't as descriptive as it could have been.
I don't think that any helper function is required at all. No need to
abstract/obfuscate how the IRQ is obtained and registered. What I
meant by 'do it in the charger driver' was, copy and paste all of the
platform_get_irq_byname() and devm_request_threaded_irq() calls from
.probe() into a separate function, but only if you are worried about a
bloated .probe(). Personally I'd just leave them in there.
Bottom line is; I don't feel there is a necessity for any helper
function here. I think it adds unnecessary complexity for the sake of
saving a few lines of code.
If you still think there is a requirement for it, perhaps a more
system-wide devm_request_threaded_irq_byname() is in order instead?
> > > > > > > +void da9150_release_irq(struct platform_device *pdev, void *dev_id,
> > > > > > > + const char *name)
> > > > > > > +{
> > > > > > > + int irq;
> > > > > > > +
> > > > > > > + irq = platform_get_irq_byname(pdev, name);
> > > > > > > + if (irq < 0)
> > > > > > > + return;
> > > > > > > +
> > > > > > > + devm_free_irq(&pdev->dev, irq, dev_id);
> > > > > > > +}
> > > > > > > +EXPORT_SYMBOL_GPL(da9150_release_irq);
> > > > > >
> > > > > > Do you ever release the IRQ and not unbind the driver?
> > > > > >
> > > > > > Are there ordering issues at play here?
> > > > > >
> > > > > > If not, there's no need to conduct a manual free.
> > > > >
> > > > > In the charger driver, in the remove function there is a need I believe to
> > > > > free the IRQs before other items are cleared up (e.g. power_supply classes),
> > > > > so this is why I have added this in here.
> > > >
> > > > Can you handle this separately in the Charger driver then please?
> > > >
> > > > [...]
> > >
> > > If I have to remove the IRQ register function, then yes, otherwise it makes more
> > > sense to have the pair of functions in the MFD core I would say.
> >
> > I would prefer you to remove the call-back please.
>
> Right.
>
> >
> > > > > > > + if (pdata)
> > > > > > > + da9150->irq_base = pdata->irq_base;
> > > > > > > + else
> > > > > > > + da9150->irq_base = -1;
> > > > > >
> > > > > > pdata ? pdata->irq_base : -1;
> > > > >
> > > > > This is left this way as later updates to add additional functionality will
> > > > > require addtional work to be done with the platform data. Seemed pointless
> > > > > changing it here just to change it back later.
> > > >
> > > > You're not changing anything, as this is the introduction of the code.
> > > > I can't tell you how many times I've heard "I will change it later",
> > > > or "doing it this way will support subsequent submissions", then
> > > > received no more patches. It's okay to do it nicely now and expand
> > > > it back out in the new patches.
> > > >
> > > > [...]
> > >
> > > It appears that way to you but I have to modify my code for sumbission as the
> > > local code I have covers all functionality. Am having to refactor again and
> > > again just to suit this initial submission, and then I have to revert it back
> > > again when submitting the last couple of drivers. Time consuming, and quite
> > > frustrating when the intention was to make the whole process easier. Anyway,
> > > will update for now and revert in subsequent patches.
> >
> > I sincerely hope the refactorings won't add too much effort, but it's
> > difficult to have one rule for the masses and different ones for
> > others.
>
> I do understand that, and that's fair enough. Is just frustrating when you're
> trying to do a proper job. Anyway, am sure I'll live. :)
I know how you feel, as I've been on the receiving end of such rules
more than once, but you could have probably re-factored twice in the
time it's taken us to have this conversation. :)
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: "Opensource [Adam Thomson]"
<Adam.Thomson.Opensource-WBD+wuPFNBhBDgjK7y7TUQ@public.gmane.org>
Cc: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Sebastian Reichel <sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Dmitry Eremin-Solenikov
<dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
"linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Ian Campbell
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Support Opensource
<Support.Opensource-WBD+wuPFNBhBDgjK7y7TUQ@public.gmane.org>
Subject: Re: [PATCH v2 1/7] mfd: Add support for DA9150 combined charger & fuel-gauge device
Date: Tue, 16 Sep 2014 15:07:40 -0700 [thread overview]
Message-ID: <20140916220740.GQ25162@lee--X1> (raw)
In-Reply-To: <2E89032DDAA8B9408CB92943514A0337AB514E7C-68WUHU125fLLPO1uwJ3ImwLouzNaz+3S@public.gmane.org>
On Tue, 16 Sep 2014, Opensource [Adam Thomson] wrote:
> On September 15, 2014 23:39, Lee Jones wrote:
>
> > On Wed, 10 Sep 2014, Opensource [Adam Thomson] wrote:
> > > On September 10, 2014 10:50, Lee Jones wrote:
> > > > On Tue, 09 Sep 2014, Opensource [Adam Thomson] wrote:
> > > >
> > > > > On August 28, 2014 17:36, Lee Jones wrote:
> > > > >
> > > > > Thanks for the feedback. As a general comment a couple of the items you've
> > > > > identified relate to future updates (additional functionality being added).
> > > > > I already have code in place for this but have stripped out a couple of the
> > > > > drivers just to reduce the churn and size of patch submission. These will be
> > > > > added once these patches have been accepted.
> > > > >
> > > > > Where this is the case, I have added notes in-line against the relevant
> > > > > comments you made.
> > > > >
> > > > > > On Thu, 28 Aug 2014, Adam Thomson wrote:
> > > > > >
> > > > > > > DA9150 is a combined Charger and Fuel-Gauge IC, with additional
> > > > > > > GPIO and GPADC functionality.
> > > > > > >
> > > > > > > Signed-off-by: Adam Thomson
> > <Adam.Thomson.Opensource-WBD+wuPFNBhBDgjK7y7TUQ@public.gmane.org>
> > > > > > > ---
> > > > > > > drivers/mfd/Kconfig | 12 +
> > > > > > > drivers/mfd/Makefile | 2 +
> > > > > > > drivers/mfd/da9150-core.c | 332 ++++++++++
> > > > > > > drivers/mfd/da9150-i2c.c | 176 ++++++
> >
> > [...]
> >
> > > > > > > +/* Helper functions for sub-devices to request/free IRQs */
> > > > > > > +int da9150_register_irq(struct platform_device *pdev, void *dev_id,
> > > > > > > + irq_handler_t handler, const char *name)
> > > > > > > +{
> > > > > > > + int irq, ret;
> > > > > > > +
> > > > > > > + irq = platform_get_irq_byname(pdev, name);
> > > > > > > + if (irq < 0)
> > > > > > > + return irq;
> > > > > > > +
> > > > > > > + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, handler,
> > > > > > > + IRQF_ONESHOT, name, dev_id);
> > > > > > > + if (ret)
> > > > > > > + dev_err(&pdev->dev, "Failed to request IRQ %d: %d\n", irq,
> > ret);
> > > > > > > +
> > > > > > > + return ret;
> > > > > > > +}
> > > > > > > +EXPORT_SYMBOL_GPL(da9150_register_irq);
> > > > > >
> > > > > > Why do they need help? What problem does adding these layers solve?
> > > > >
> > > > > Means I don't have to keep adding print error lines everywhere else if this
> > > > > function takes care of it. Thought that would be cleaner.
> > > >
> > > > You only need to request each IRQ once. It's just more abstraction
> > > > for the sake of it. I would prefer if you removed them.
> > >
> > > Yes, but in the charger driver for example, there are 4 IRQs to request. If
> > > I don't use this approach the IRQ requesting becomes bloated, hence why I went
> > > for a common function like this. Thought generally the intention was to cut
> > > down on repeated code?
> >
> > If you're worried about bloat in .probe() it's okay to define a new
> > function within the charger driver; however, creating a call-back into
> > the MFD driver like this I think it over-kill for 4 requests.
>
> I could do something just in the charger, but why not have something which can
> be used for all sub-devices? There is also an IRQ used in the IIO ADC driver and
> there will be another in the later fuel-gauge driver too. Doesn't make sense to
> me not to do in the MFD code when that will provide a simple common call for all
> sub-devices. What is your concern with adding something like this, just so I'm
> clear?
I guess my last response wasn't as descriptive as it could have been.
I don't think that any helper function is required at all. No need to
abstract/obfuscate how the IRQ is obtained and registered. What I
meant by 'do it in the charger driver' was, copy and paste all of the
platform_get_irq_byname() and devm_request_threaded_irq() calls from
.probe() into a separate function, but only if you are worried about a
bloated .probe(). Personally I'd just leave them in there.
Bottom line is; I don't feel there is a necessity for any helper
function here. I think it adds unnecessary complexity for the sake of
saving a few lines of code.
If you still think there is a requirement for it, perhaps a more
system-wide devm_request_threaded_irq_byname() is in order instead?
> > > > > > > +void da9150_release_irq(struct platform_device *pdev, void *dev_id,
> > > > > > > + const char *name)
> > > > > > > +{
> > > > > > > + int irq;
> > > > > > > +
> > > > > > > + irq = platform_get_irq_byname(pdev, name);
> > > > > > > + if (irq < 0)
> > > > > > > + return;
> > > > > > > +
> > > > > > > + devm_free_irq(&pdev->dev, irq, dev_id);
> > > > > > > +}
> > > > > > > +EXPORT_SYMBOL_GPL(da9150_release_irq);
> > > > > >
> > > > > > Do you ever release the IRQ and not unbind the driver?
> > > > > >
> > > > > > Are there ordering issues at play here?
> > > > > >
> > > > > > If not, there's no need to conduct a manual free.
> > > > >
> > > > > In the charger driver, in the remove function there is a need I believe to
> > > > > free the IRQs before other items are cleared up (e.g. power_supply classes),
> > > > > so this is why I have added this in here.
> > > >
> > > > Can you handle this separately in the Charger driver then please?
> > > >
> > > > [...]
> > >
> > > If I have to remove the IRQ register function, then yes, otherwise it makes more
> > > sense to have the pair of functions in the MFD core I would say.
> >
> > I would prefer you to remove the call-back please.
>
> Right.
>
> >
> > > > > > > + if (pdata)
> > > > > > > + da9150->irq_base = pdata->irq_base;
> > > > > > > + else
> > > > > > > + da9150->irq_base = -1;
> > > > > >
> > > > > > pdata ? pdata->irq_base : -1;
> > > > >
> > > > > This is left this way as later updates to add additional functionality will
> > > > > require addtional work to be done with the platform data. Seemed pointless
> > > > > changing it here just to change it back later.
> > > >
> > > > You're not changing anything, as this is the introduction of the code.
> > > > I can't tell you how many times I've heard "I will change it later",
> > > > or "doing it this way will support subsequent submissions", then
> > > > received no more patches. It's okay to do it nicely now and expand
> > > > it back out in the new patches.
> > > >
> > > > [...]
> > >
> > > It appears that way to you but I have to modify my code for sumbission as the
> > > local code I have covers all functionality. Am having to refactor again and
> > > again just to suit this initial submission, and then I have to revert it back
> > > again when submitting the last couple of drivers. Time consuming, and quite
> > > frustrating when the intention was to make the whole process easier. Anyway,
> > > will update for now and revert in subsequent patches.
> >
> > I sincerely hope the refactorings won't add too much effort, but it's
> > difficult to have one rule for the masses and different ones for
> > others.
>
> I do understand that, and that's fair enough. Is just frustrating when you're
> trying to do a proper job. Anyway, am sure I'll live. :)
I know how you feel, as I've been on the receiving end of such rules
more than once, but you could have probably re-factored twice in the
time it's taken us to have this conversation. :)
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-09-16 22:08 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-28 10:48 [PATCH v2 0/7] Add initial support for DA9150 Charger & Fuel-Gauge IC Adam Thomson
2014-08-28 10:48 ` Adam Thomson
2014-08-28 10:48 ` [PATCH v2 1/7] mfd: Add support for DA9150 combined charger & fuel-gauge device Adam Thomson
2014-08-28 10:48 ` Adam Thomson
2014-08-28 11:47 ` Varka Bhadram
2014-09-09 10:32 ` Opensource [Adam Thomson]
2014-09-09 10:32 ` Opensource [Adam Thomson]
2014-09-09 10:32 ` Opensource [Adam Thomson]
2014-09-10 9:51 ` Lee Jones
2014-08-28 16:36 ` Lee Jones
2014-09-09 10:37 ` Opensource [Adam Thomson]
2014-09-09 10:37 ` Opensource [Adam Thomson]
2014-09-09 10:37 ` Opensource [Adam Thomson]
2014-09-10 9:49 ` Lee Jones
2014-09-10 15:58 ` Opensource [Adam Thomson]
2014-09-10 15:58 ` Opensource [Adam Thomson]
2014-09-10 15:58 ` Opensource [Adam Thomson]
2014-09-15 22:39 ` Lee Jones
2014-09-16 10:50 ` Opensource [Adam Thomson]
2014-09-16 10:50 ` Opensource [Adam Thomson]
2014-09-16 10:50 ` Opensource [Adam Thomson]
2014-09-16 22:07 ` Lee Jones [this message]
2014-09-16 22:07 ` Lee Jones
2014-08-28 10:48 ` [PATCH v2 2/7] mfd: da9150: Add DT binding documentation for core Adam Thomson
2014-08-28 10:48 ` Adam Thomson
2014-08-28 10:48 ` [PATCH v2 3/7] iio: Add support for DA9150 GPADC Adam Thomson
2014-08-28 10:48 ` Adam Thomson
2014-08-28 11:28 ` Peter Meerwald
2014-08-30 20:01 ` Jonathan Cameron
2014-09-09 10:53 ` Opensource [Adam Thomson]
2014-09-14 17:26 ` Jonathan Cameron
2014-09-15 10:32 ` Opensource [Adam Thomson]
2014-09-09 10:51 ` Opensource [Adam Thomson]
2014-08-28 10:49 ` [PATCH v2 4/7] iio: da9150: Add DT binding documentation for GPADC Adam Thomson
2014-08-28 10:49 ` Adam Thomson
2014-08-28 10:49 ` [PATCH v2 5/7] power: Add support for DA9150 Charger Adam Thomson
2014-08-28 10:49 ` Adam Thomson
2014-08-28 10:49 ` [PATCH v2 6/7] power: da9150: Add DT binding documentation for charger Adam Thomson
2014-08-28 10:49 ` Adam Thomson
2014-08-28 10:49 ` [PATCH v2 7/7] MAINTAINERS: Include DA9150 files in Dialog Semiconductor support list Adam Thomson
2014-08-28 10:49 ` Adam Thomson
2014-08-28 11:17 ` Lee Jones
2014-08-28 11:17 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140916220740.GQ25162@lee--X1 \
--to=lee.jones@linaro.org \
--cc=Adam.Thomson.Opensource@diasemi.com \
--cc=Support.Opensource@diasemi.com \
--cc=akpm@linux-foundation.org \
--cc=dbaryshkov@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=galak@codeaurora.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jic23@kernel.org \
--cc=joe@perches.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=sameo@linux.intel.com \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.