All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Quentin Schulz <quentin.schulz@free-electrons.com>
Cc: jdelvare@suse.com, linux@roeck-us.net, jic23@kernel.org,
	knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
	maxime.ripard@free-electrons.com, wens@csie.org,
	thomas.petazzoni@free-electrons.com,
	antoine.tenart@free-electrons.com, linux-kernel@vger.kernel.org,
	linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 2/3] mfd: add support for Allwinner SoCs ADC
Date: Tue, 13 Sep 2016 09:21:26 +0100	[thread overview]
Message-ID: <20160913082126.GA22903@dell> (raw)
In-Reply-To: <a48580b4-1494-d474-b33c-007f898b29b7@free-electrons.com>

On Tue, 13 Sep 2016, Quentin Schulz wrote:
> On 12/09/2016 15:56, Lee Jones wrote:
> > On Mon, 12 Sep 2016, Quentin Schulz wrote:
> >> On 12/09/2016 11:59, Lee Jones wrote:
> >>> On Mon, 12 Sep 2016, Quentin Schulz wrote:
> >>>
> >>>> On 12/09/2016 11:18, Lee Jones wrote:
> >>>>> On Thu, 08 Sep 2016, Quentin Schulz wrote:
> >>>>> [...]
> >>>>>> +
> >>>>>> +MODULE_DEVICE_TABLE(of, sun4i_gpadc_mfd_of_match);
> >>>>>
> >>>>> Place this directly under the table.
> >>>>>
> >>>>>> +static struct platform_driver sun4i_gpadc_mfd_driver = {
> >>>>>> +	.driver = {
> >>>>>> +		.name = "sun4i-adc-mfd",
> >>>>>> +		.of_match_table = of_match_ptr(sun4i_gpadc_mfd_of_match),
> >>>>>> +	},
> >>>>>> +	.probe = sun4i_gpadc_mfd_probe,
> >>>>>
> >>>>> No .remove?
> >>>>>
> >>>>
> >>>> No, everything in probe is handled with devm functions.
> >>>
> >>> Don't you need to undo the register write you did?
> >>>
> >>
> >> The regmap_write I use is there to disable all interrupts on hardware
> >> side before the irq_chip handles all interrupts by itself. The
> >> interrupts are not used in the MFD driver.
> >>
> >> Thus, I chose to disable the hardware interrupts in the remove function
> >> of drivers using the interrupts (only the IIO yet but the touchscreen
> >> driver later also which will be using a third interrupt). When the MFD
> >> driver is removed, the MFD cells will all be removed, thus calling their
> >> own remove functions, thus disabling hardware interrupts used in each
> >> driver. So the hardware interrupts disabling would be called twice.
> > 
> > This does send some little alarm bells ringing.  I'd normally expect
> > the .remove function to undo everything you did in .probe.  So, if you
> > are disabling the IRQs from within the leaf drivers, shouldn't you be
> > initialising them in the leaf driver's respective .probes?
> > 
> 
> I use the regmap_write in the MFD driver's probe to disable all
> interrupts before requesting irq_chip to guarantee the interrupts are in
> a known state, being disabled. It is to insure no interrupt will occur
> unwittingly before we want the leaf drivers to handle them.
> 
> The disabling of irqs in the remove is handled rather by
> devm_regmap_del_irq_chip than by an explicit regmap_write in the
> driver's removal function. It performs the exact same thing.
> 
> I always use devm functions for requesting either an irq_chip or the
> irqs themselves. In that case, when the device is removed, the irqs are
> freed on leaf drivers' (where the irqs are requested) removal while the
> removal of irq_chip in the MFD driver will also free all irqs mapped to
> this irq_chip thanks to devm_regmap_del_irq_chip. Therefore, the
> interrupts are disabled by devm functions.
> 
> The regmap_update_bits in probe and removal of the ADC driver to disable
> irqs are actually redundant because the devm functions already handle
> the irqs disabling.

Okay.  So long as you've thought about it, I'm happy.

-- 
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@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 2/3] mfd: add support for Allwinner SoCs ADC
Date: Tue, 13 Sep 2016 09:21:26 +0100	[thread overview]
Message-ID: <20160913082126.GA22903@dell> (raw)
In-Reply-To: <a48580b4-1494-d474-b33c-007f898b29b7@free-electrons.com>

On Tue, 13 Sep 2016, Quentin Schulz wrote:
> On 12/09/2016 15:56, Lee Jones wrote:
> > On Mon, 12 Sep 2016, Quentin Schulz wrote:
> >> On 12/09/2016 11:59, Lee Jones wrote:
> >>> On Mon, 12 Sep 2016, Quentin Schulz wrote:
> >>>
> >>>> On 12/09/2016 11:18, Lee Jones wrote:
> >>>>> On Thu, 08 Sep 2016, Quentin Schulz wrote:
> >>>>> [...]
> >>>>>> +
> >>>>>> +MODULE_DEVICE_TABLE(of, sun4i_gpadc_mfd_of_match);
> >>>>>
> >>>>> Place this directly under the table.
> >>>>>
> >>>>>> +static struct platform_driver sun4i_gpadc_mfd_driver = {
> >>>>>> +	.driver = {
> >>>>>> +		.name = "sun4i-adc-mfd",
> >>>>>> +		.of_match_table = of_match_ptr(sun4i_gpadc_mfd_of_match),
> >>>>>> +	},
> >>>>>> +	.probe = sun4i_gpadc_mfd_probe,
> >>>>>
> >>>>> No .remove?
> >>>>>
> >>>>
> >>>> No, everything in probe is handled with devm functions.
> >>>
> >>> Don't you need to undo the register write you did?
> >>>
> >>
> >> The regmap_write I use is there to disable all interrupts on hardware
> >> side before the irq_chip handles all interrupts by itself. The
> >> interrupts are not used in the MFD driver.
> >>
> >> Thus, I chose to disable the hardware interrupts in the remove function
> >> of drivers using the interrupts (only the IIO yet but the touchscreen
> >> driver later also which will be using a third interrupt). When the MFD
> >> driver is removed, the MFD cells will all be removed, thus calling their
> >> own remove functions, thus disabling hardware interrupts used in each
> >> driver. So the hardware interrupts disabling would be called twice.
> > 
> > This does send some little alarm bells ringing.  I'd normally expect
> > the .remove function to undo everything you did in .probe.  So, if you
> > are disabling the IRQs from within the leaf drivers, shouldn't you be
> > initialising them in the leaf driver's respective .probes?
> > 
> 
> I use the regmap_write in the MFD driver's probe to disable all
> interrupts before requesting irq_chip to guarantee the interrupts are in
> a known state, being disabled. It is to insure no interrupt will occur
> unwittingly before we want the leaf drivers to handle them.
> 
> The disabling of irqs in the remove is handled rather by
> devm_regmap_del_irq_chip than by an explicit regmap_write in the
> driver's removal function. It performs the exact same thing.
> 
> I always use devm functions for requesting either an irq_chip or the
> irqs themselves. In that case, when the device is removed, the irqs are
> freed on leaf drivers' (where the irqs are requested) removal while the
> removal of irq_chip in the MFD driver will also free all irqs mapped to
> this irq_chip thanks to devm_regmap_del_irq_chip. Therefore, the
> interrupts are disabled by devm functions.
> 
> The regmap_update_bits in probe and removal of the ADC driver to disable
> irqs are actually redundant because the devm functions already handle
> the irqs disabling.

Okay.  So long as you've thought about it, I'm happy.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2016-09-13  8:19 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08 14:28 [PATCH v5 0/3] add support for Allwinner SoCs ADC Quentin Schulz
2016-09-08 14:28 ` Quentin Schulz
2016-09-08 14:28 ` [PATCH v5 1/3] hwmon: iio_hwmon: defer probe when no channel is found Quentin Schulz
2016-09-08 14:28   ` Quentin Schulz
2016-09-09  4:26   ` Guenter Roeck
2016-09-09  4:26     ` Guenter Roeck
2016-09-10 15:02     ` Jonathan Cameron
2016-09-10 15:02       ` Jonathan Cameron
2016-09-08 14:28 ` [PATCH v5 2/3] mfd: add support for Allwinner SoCs ADC Quentin Schulz
2016-09-08 14:28   ` Quentin Schulz
2016-09-09 14:38   ` Maxime Ripard
2016-09-09 14:38     ` Maxime Ripard
2016-09-10 15:07   ` Jonathan Cameron
2016-09-10 15:07     ` Jonathan Cameron
2016-09-12  9:18   ` Lee Jones
2016-09-12  9:18     ` Lee Jones
2016-09-12  9:43     ` Quentin Schulz
2016-09-12  9:43       ` Quentin Schulz
2016-09-12  9:59       ` Lee Jones
2016-09-12  9:59         ` Lee Jones
2016-09-12 10:07         ` Maxime Ripard
2016-09-12 10:07           ` Maxime Ripard
2016-09-12 10:49           ` Lee Jones
2016-09-12 10:49             ` Lee Jones
2016-09-12 10:58             ` Quentin Schulz
2016-09-12 10:58               ` Quentin Schulz
2016-09-12 13:56               ` Lee Jones
2016-09-12 13:56                 ` Lee Jones
2016-09-12 14:35                 ` Maxime Ripard
2016-09-12 14:35                   ` Maxime Ripard
2016-09-12 15:07                   ` Lee Jones
2016-09-12 15:07                     ` Lee Jones
2016-09-12 11:08         ` Quentin Schulz
2016-09-12 11:08           ` Quentin Schulz
2016-09-12 13:56           ` Lee Jones
2016-09-12 13:56             ` Lee Jones
2016-09-13  7:06             ` Quentin Schulz
2016-09-13  7:06               ` Quentin Schulz
2016-09-13  8:21               ` Lee Jones [this message]
2016-09-13  8:21                 ` Lee Jones
2016-09-08 14:28 ` [PATCH v5 3/3] iio: adc: " Quentin Schulz
2016-09-08 14:28   ` Quentin Schulz
2016-09-09 14:50   ` Maxime Ripard
2016-09-09 14:50     ` Maxime Ripard
2016-09-10 15:09   ` Jonathan Cameron
2016-09-10 15:09     ` Jonathan Cameron

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=20160913082126.GA22903@dell \
    --to=lee.jones@linaro.org \
    --cc=antoine.tenart@free-electrons.com \
    --cc=jdelvare@suse.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=maxime.ripard@free-electrons.com \
    --cc=pmeerw@pmeerw.net \
    --cc=quentin.schulz@free-electrons.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=wens@csie.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.