Skip to contentSkip to conversation

i2c: add Atmel AT91 driver

PATCH Superseded Raphaël Poggi 3 participants 3 messages Jul 23, 2014 – Jul 24, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: add Atmel AT91 driver

---
 drivers/i2c/busses/Kconfig    |   4 +
 drivers/i2c/busses/Makefile   |   1 +
 drivers/i2c/busses/i2c-at91.c | 438 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 443 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-at91.c
drivers/i2c/busses/Kconfig +4 -0
index 370abb0..5b75449 100644
@@ -12,6 +12,10 @@ config I2C_GPIO
 	  This is a very simple bitbanging I2C driver utilizing the
 	  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_AT91
+	bool "AT91 I2C Master driver"
+	depends on ARCH_AT91
+
 config I2C_IMX
 	bool "MPC85xx/i.MX I2C Master driver"
 	depends on (ARCH_IMX && !ARCH_IMX1) || ARCH_MPC85XX
drivers/i2c/busses/Makefile +1 -0
index 9823d1b..cc72b7c 100644
@@ -1,3 +1,4 @@
+obj-$(CONFIG_I2C_AT91)		+= i2c-at91.o
 obj-$(CONFIG_I2C_GPIO)		+= i2c-gpio.o
 obj-$(CONFIG_I2C_IMX) += i2c-imx.o
 obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
drivers/i2c/busses/i2c-at91.c new file +438 -0

438 lines not on this page · raw message

Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

Hi Raphaël,

Looks mostly fine to me. Two small comments:

drivers/i2c/busses/i2c-at91.c line 381

Quoted 13 lines · Raphaël Poggi
drivers/i2c/busses/i2c-at91.c new file +13 -0
+
+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.

drivers/i2c/busses/i2c-at91.c line 391

Quoted 10 lines
drivers/i2c/busses/i2c-at91.c new file +10 -0
+
+	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

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Hi Sascha,

Thanks for your review, I'll correct these and send a v2.

Raphaël

2014-07-24 11:34 GMT+02:00 Sascha Hauer <[email protected]>:

Quoted 42 lines

Hi Raphaël,

Looks mostly fine to me. Two small comments:

drivers/i2c/busses/i2c-at91.c line 381

Quoted 13 lines · Raphaël Poggi
drivers/i2c/busses/i2c-at91.c new file +13 -0
+
+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.

drivers/i2c/busses/i2c-at91.c line 391

Quoted 10 lines
drivers/i2c/busses/i2c-at91.c new file +10 -0
+
+     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 |
Quoted 4 lines

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox