* [PATCH] max730x: Added setup/teardown hooks
@ 2011-02-11 12:00 stigge
2011-03-03 18:59 ` Grant Likely
0 siblings, 1 reply; 4+ messages in thread
From: stigge @ 2011-02-11 12:00 UTC (permalink / raw)
To: linux-kernel, info; +Cc: Roland Stigge
max730x: Added setup/teardown hooks
This patch adds setup and teardown hooks for configuration of GPIO lines via
platform_data, similar to the pca953x driver.
Signed-off-by: Roland Stigge <stigge@antcom.de>
diff --git a/drivers/gpio/max730x.c b/drivers/gpio/max730x.c
index 94ce773..ccd624d 100644
--- a/drivers/gpio/max730x.c
+++ b/drivers/gpio/max730x.c
@@ -219,6 +219,12 @@ int __devinit __max730x_probe(struct max7301 *ts)
if (ret)
goto exit_destroy;
+ if (pdata->setup) {
+ ret = pdata->setup(ts->chip.base,
+ ts->chip.ngpio, pdata->context);
+ if (ret < 0)
+ dev_warn(dev, "setup failed, %d\n", ret);
+ }
return ret;
exit_destroy:
@@ -230,12 +236,24 @@ EXPORT_SYMBOL_GPL(__max730x_probe);
int __devexit __max730x_remove(struct device *dev)
{
+ struct max7301_platform_data *pdata;
struct max7301 *ts = dev_get_drvdata(dev);
int ret;
if (ts == NULL)
return -ENODEV;
+ pdata = dev->platform_data;
+
+ if (pdata && pdata->teardown) {
+ ret = pdata->teardown(ts->chip.base,
+ ts->chip.ngpio, pdata->context);
+ if (ret < 0) {
+ dev_err(dev, "teardown failed, %d\n", ret);
+ return ret;
+ }
+ }
+
dev_set_drvdata(dev, NULL);
/* Power down the chip and disable IRQ output */
diff --git a/include/linux/spi/max7301.h b/include/linux/spi/max7301.h
index bcaa2f7..02d685a 100644
--- a/include/linux/spi/max7301.h
+++ b/include/linux/spi/max7301.h
@@ -28,6 +28,13 @@ struct max7301_platform_data {
* ports of the controller are not used, too.
*/
u32 input_pullup_active;
+
+ void *context; /* param to setup/teardown */
+
+ int (*setup)(unsigned gpio, unsigned ngpio,
+ void *context);
+ int (*teardown)(unsigned gpio, unsigned ngpio,
+ void *context);
};
extern int __max730x_remove(struct device *dev);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] max730x: Added setup/teardown hooks
2011-02-11 12:00 [PATCH] max730x: Added setup/teardown hooks stigge
@ 2011-03-03 18:59 ` Grant Likely
2011-03-03 19:26 ` Roland Stigge
0 siblings, 1 reply; 4+ messages in thread
From: Grant Likely @ 2011-03-03 18:59 UTC (permalink / raw)
To: stigge; +Cc: linux-kernel, info
On Fri, Feb 11, 2011 at 5:00 AM, <stigge@antcom.de> wrote:
> max730x: Added setup/teardown hooks
>
> This patch adds setup and teardown hooks for configuration of GPIO lines via
> platform_data, similar to the pca953x driver.
Why? What actions are these hooks going to perform?
g.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] max730x: Added setup/teardown hooks
2011-03-03 18:59 ` Grant Likely
@ 2011-03-03 19:26 ` Roland Stigge
2011-03-03 19:37 ` Grant Likely
0 siblings, 1 reply; 4+ messages in thread
From: Roland Stigge @ 2011-03-03 19:26 UTC (permalink / raw)
To: Grant Likely; +Cc: linux-kernel, info
On 03/03/2011 07:59 PM, Grant Likely wrote:
> On Fri, Feb 11, 2011 at 5:00 AM, <stigge@antcom.de> wrote:
>> max730x: Added setup/teardown hooks
>>
>> This patch adds setup and teardown hooks for configuration of GPIO lines via
>> platform_data, similar to the pca953x driver.
>
> Why? What actions are these hooks going to perform?
In board configurations, ARM systems are set up with GPIO lines
configured as Input or Output etc. See also arch/arm/*/*. See usage of
pca953x - how it is already done there.
Thanks,
Roland
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] max730x: Added setup/teardown hooks
2011-03-03 19:26 ` Roland Stigge
@ 2011-03-03 19:37 ` Grant Likely
0 siblings, 0 replies; 4+ messages in thread
From: Grant Likely @ 2011-03-03 19:37 UTC (permalink / raw)
To: Roland Stigge; +Cc: linux-kernel, info
On Thu, Mar 03, 2011 at 08:26:44PM +0100, Roland Stigge wrote:
> On 03/03/2011 07:59 PM, Grant Likely wrote:
> > On Fri, Feb 11, 2011 at 5:00 AM, <stigge@antcom.de> wrote:
> >> max730x: Added setup/teardown hooks
> >>
> >> This patch adds setup and teardown hooks for configuration of GPIO lines via
> >> platform_data, similar to the pca953x driver.
> >
> > Why? What actions are these hooks going to perform?
>
> In board configurations, ARM systems are set up with GPIO lines
> configured as Input or Output etc. See also arch/arm/*/*. See usage of
> pca953x - how it is already done there.
It appears to simply be notifying the platform code that the gpio chip
has been registered. My point is that it doesn't seem to make any
sense whatsoever to have driver specific hooks to inform platform code
that a gpio controller has shown up. It is something that should be
part of the infrastructure. I would much rather see this get
implemented with a notifier or something similar in gpiochip_add().
Other drivers may currently be doing driver-specific callbacks, but it
is a bad pattern and I don't want any more drivers to do so.
g.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-03 19:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-11 12:00 [PATCH] max730x: Added setup/teardown hooks stigge
2011-03-03 18:59 ` Grant Likely
2011-03-03 19:26 ` Roland Stigge
2011-03-03 19:37 ` Grant Likely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®