mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: stigge@antcom.de
To: linux-kernel@vger.kernel.org, info@pengutronix.de
Cc: Roland Stigge <stigge@antcom.de>
Subject: [PATCH] max730x: Added setup/teardown hooks
Date: Fri, 11 Feb 2011 13:00:06 +0100	[thread overview]
Message-ID: <1297425606-13290-1-git-send-email-stigge@antcom.de> (raw)

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);

             reply	other threads:[~2011-02-11 12:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-11 12:00 stigge [this message]
2011-03-03 18:59 ` Grant Likely
2011-03-03 19:26   ` Roland Stigge
2011-03-03 19:37     ` Grant Likely

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=1297425606-13290-1-git-send-email-stigge@antcom.de \
    --to=stigge@antcom.de \
    --cc=info@pengutronix.de \
    --cc=linux-kernel@vger.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 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®