[PATCH] i2c: add Atmel AT91 driver

Sascha Hauer s.hauer at pengutronix.de
Thu Jul 24 02:34:36 PDT 2014


Hi Raphaël,

Looks mostly fine to me. Two small comments:

On Wed, Jul 23, 2014 at 12:09:04PM -0700, Raphaël Poggi wrote:
> +
> +static int at91_twi_probe(struct device_d *dev)
> +{
> +	struct at91_twi_dev *i2c_at91;
> +	struct at91_twi_pdata *i2c_data;
> +	int rc;
> +	u32 bus_clk_rate;
> +
> +	i2c_at91 = kzalloc(sizeof(struct at91_twi_dev), GFP_KERNEL);
> +	if (!i2c_at91) {
> +	    rc = -ENOMEM;
> +	    goto out_free;
> +	}

You can safely use xzalloc here and skip the result check.

> +
> +	rc = dev_get_drvdata(dev, (unsigned long *)&i2c_data);
> +	if (rc)
> +		goto out_free;
> +
> +	i2c_at91->pdata = i2c_data;
> +
> +	i2c_at91->base = dev_request_mem_region(dev, 0);
> +	if (IS_ERR(i2c_at91->base))
> +		return PTR_ERR(i2c_at91->base);

dev_request_mem_region returns NULL on error, not an error pointer.

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 |



More information about the barebox mailing list