mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v3 1/2] mfd: add stmpe-i2c driver
Date: Wed, 5 Sep 2012 08:32:18 +0200	[thread overview]
Message-ID: <20120905063218.GC26594@pengutronix.de> (raw)
In-Reply-To: <1346752726-27051-2-git-send-email-s.trumtrar@pengutronix.de>

On Tue, Sep 04, 2012 at 11:58:45AM +0200, Steffen Trumtrar wrote:
> The stmpe mfds can be connected via i2c and spi. This driver provides the basic
> infrastructure for the i2c kind. It can be added as a normal i2c-device in the
> board code. To enable functions a platform_data struct has to be provided, that
> describes what parts of the chip are to be used.
> 
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
> +static struct stmpe_client_info i2c_ci = {
> +	.read_reg = stmpe_reg_read,
> +	.write_reg = stmpe_reg_write,
> +};
> +
> +static int stmpe_probe(struct device_d *dev)
> +{
> +	struct stmpe_platform_data *pdata = dev->platform_data;
> +	struct stmpe *stmpe_dev;
> +
> +	if (!pdata) {
> +		dev_dbg(dev, "no platform data\n");
> +		return -ENODEV;
> +	}
> +
> +	stmpe_dev = xzalloc(sizeof(struct stmpe));
> +	stmpe_dev->cdev.name = DRIVERNAME;
> +	stmpe_dev->client = to_i2c_client(dev);
> +	stmpe_dev->cdev.size = 191;		/* 191 known registers */
> +	stmpe_dev->cdev.dev = dev;
> +	stmpe_dev->cdev.ops = &stmpe_fops;
> +	stmpe_dev->pdata = pdata;
> +	dev->priv = stmpe_dev;
> +	i2c_ci.stmpe = stmpe_dev;

This breaks for multiple instances of a stmpe device. You have to
allocate a static struct stmpe_client_info dynamically.

> +
> +	if (pdata->blocks &= STMPE_BLOCK_GPIO)
> +		add_generic_device("stmpe-gpio", 0, NULL, pdata->base, 0x10, IORESOURCE_MEM, &i2c_ci);

This issues:

drivers/mfd/stmpe-i2c.c: In function 'stmpe_probe':
drivers/mfd/stmpe-i2c.c:135:3: warning: passing argument 4 of 'add_generic_device' makes integer from pointer without a cast [enabled by default]
include/driver.h:197:18: note: expected 'resource_size_t' but argument is of type 'void *'

The base and size refer to the iomem space. As an i2c device we do not
have iomem here, so this is wrong.

Looking further at it it seems to be unused by the gpio driver anyway,
so you can just pass 0, 0 as iomem and size.


> +struct stmpe_platform_data {
> +	enum	stmpe_revision	revision;
> +	enum	stmpe_blocks	blocks;
> +	void	__iomem		*base;

This is unused, please remove.

> +	int			gpio_base;
> +};
> +
> +
> +extern int stmpe_reg_read(struct stmpe *priv, u32 reg, u8 *val);
> +extern int stmpe_reg_write(struct stmpe *priv, u32 reg, u8 val);
> +extern int stmpe_set_bits(struct stmpe *priv, u32 reg, u8 mask, u8 val);

no 'extern' for function prototypes please.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-09-05  6:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-04  9:58 [PATCH v3 0/2] Add stmpe mfd Steffen Trumtrar
2012-09-04  9:58 ` [PATCH v3 1/2] mfd: add stmpe-i2c driver Steffen Trumtrar
2012-09-04 11:26   ` Marc Kleine-Budde
2012-09-05  6:32   ` Sascha Hauer [this message]
2012-09-04  9:58 ` [PATCH v3 2/2] gpio: add driver for stmpe io-expander Steffen Trumtrar

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=20120905063218.GC26594@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.trumtrar@pengutronix.de \
    /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