[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150512125832.GB4447@schokonusskuchen.bad>
Date: Tue, 12 May 2015 14:58:32 +0200
From: wsa@...-dreams.de
To: Eddie Huang <eddie.huang@...iatek.com>
Cc: Sascha Hauer <kernel@...gutronix.de>, srv_heupstream@...iatek.com,
Rob Herring <robh+dt@...nel.org>,
Pawel Moll <pawel.moll@....com>,
Mark Rutland <mark.rutland@....com>,
Ian Campbell <ijc+devicetree@...lion.org.uk>,
Kumar Gala <galak@...eaurora.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Jean Delvare <jdelvare@...e.de>,
David Box <david.e.box@...ux.intel.com>,
Doug Anderson <dianders@...omium.org>,
Zhangfei Gao <zhangfei.gao@...aro.org>,
Max Schwarz <max.schwarz@...ine.de>,
Boris BREZILLON <boris.brezillon@...e-electrons.com>,
Anders Berg <anders.berg@...gotech.com>,
Neelesh Gupta <neelegup@...ux.vnet.ibm.com>,
Lee Jones <lee.jones@...aro.org>,
Arnd Bergmann <arnd@...db.de>, Ray Jui <rjui@...adcom.com>,
Simon Glass <sjg@...omium.org>,
Wei Yan <sledge.yanwei@...wei.com>,
Beniamino Galvani <b.galvani@...il.com>,
Xudong Chen <xudong.chen@...iatek.com>,
Liguo Zhang <liguo.zhang@...iatek.com>,
linux-i2c@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH v7 2/3] I2C: mediatek: Add driver for MediaTek I2C
controller
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/slab.h>
> +#include <linux/i2c.h>
> +#include <linux/init.h>
> +#include <linux/interrupt.h>
> +#include <linux/sched.h>
> +#include <linux/delay.h>
> +#include <linux/errno.h>
> +#include <linux/err.h>
> +#include <linux/device.h>
> +#include <linux/platform_device.h>
> +#include <linux/mm.h>
> +#include <linux/dma-mapping.h>
> +#include <linux/scatterlist.h>
> +#include <linux/io.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +#include <linux/clk.h>
> +#include <linux/completion.h>
Please sort the includes to avoid duplicates.
> +struct mtk_i2c_compatible {
> + const struct i2c_adapter_quirks *quirks;
> + unsigned char pmic_i2c;
> + unsigned char dcm;
> +};
I wonder if the unsigned char options can be bits in a flags variable?
> +static const struct i2c_adapter_quirks mt6577_i2c_quirks = {
> + .flags = I2C_AQ_COMB_WRITE_THEN_READ,
> + .max_num_msgs = MAX_MSG_NUM_MT6577,
> + .max_write_len = MAX_DMA_TRANS_SIZE_MT6577,
> + .max_read_len = MAX_DMA_TRANS_SIZE_MT6577,
> + .max_comb_1st_msg_len = MAX_DMA_TRANS_SIZE_MT6577,
> + .max_comb_2nd_msg_len = MAX_WRRD_TRANS_SIZE_MT6577,
> +};
I would think plain numbers are much more readable than defines here.
They are used only once, too.
> +static const struct of_device_id mtk_i2c_of_match[] = {
> + { .compatible = "mediatek,mt6577-i2c", .data = (void *)&mt6577_compat },
> + { .compatible = "mediatek,mt6589-i2c", .data = (void *)&mt6589_compat },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, mtk_i2c_of_match);
No need for casts.
> +static inline void mtk_i2c_writew(u16 value, struct mtk_i2c *i2c, u8 offset)
> +{
> + writew(value, i2c->base + offset);
> +}
> +
> +static inline u16 mtk_i2c_readw(struct mtk_i2c *i2c, u8 offset)
> +{
> + return readw(i2c->base + offset);
> +}
I am not a big fan of such extremly thin wrappers, but if you like them...
> + rpaddr = dma_map_single(i2c->adap.dev.parent, msgs->buf,
> + msgs->len, DMA_FROM_DEVICE);
I think you shouldn't use the adapter device here and later, but the dma
channel device.
> + /* flush before sending start */
> + mb();
> + mtk_i2c_writel_dma(I2C_DMA_START_EN, i2c, OFFSET_EN);
Is mb() really needed when you use writel after that?
> + if (i2c->irq_stat & (I2C_HS_NACKERR | I2C_ACKERR)) {
> + dev_dbg(i2c->dev, "addr: %x, transfer ACK error\n", msgs->addr);
> + mtk_i2c_init_hw(i2c);
> + return -EREMOTEIO;
-ENXIO. Please check Documentation/i2c/fault-codes for a reference and
check all your error values.
> + ret = of_property_read_u32(np, "clock-div", clk_src_div);
> + if (ret < 0)
> + return ret;
Do we need a property for that in the i2c-block? Can't the clock
provider driver deliver a properly divided clock already?
And cppcheck says:
drivers/i2c/busses/i2c-mt65xx.c:133: style: struct or union member 'mtk_i2c_data::clk_frequency' is never used.
drivers/i2c/busses/i2c-mt65xx.c:135: style: struct or union member 'mtk_i2c_data::clk_src_div' is never used.
Rest looks good, thanks!
Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)
Powered by blists - more mailing lists