From: wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org
To: Eddie Huang <eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Cc: Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
srv_heupstream-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Ian Campbell
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
Matthias Brugger
<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Jean Delvare <jdelvare-l3A5Bk7waGM@public.gmane.org>,
David Box <david.e.box-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
Doug Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
Zhangfei Gao
<zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Max Schwarz <max.schwarz-BGeptl67XyCzQB+pC5nmwQ@public.gmane.org>,
Boris BREZILLON
<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Anders Berg <anders.berg-1wcpHE2jlwO1Z/+hSey0Gg@public.gmane.org>,
Neelesh Gupta
<neelegup-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
Ray Jui <rjui-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
Wei Yan <sledge.yanwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
Beniamino Galvani
<b.galvani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Xudong Chen <xudong.chen-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>,
Liguo
Subject: Re: [PATCH v7 2/3] I2C: mediatek: Add driver for MediaTek I2C controller
Date: Tue, 12 May 2015 14:58:32 +0200 [thread overview]
Message-ID: <20150512125832.GB4447@schokonusskuchen.bad> (raw)
In-Reply-To: <1430901427-65146-3-git-send-email-eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 3041 bytes --]
> +#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!
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2015-05-12 12:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 8:37 [PATCH v7 0/3] ARM: mediatek: Add driver for Mediatek I2C Eddie Huang
[not found] ` <1430901427-65146-1-git-send-email-eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-05-06 8:37 ` [PATCH v7 1/3] dt-bindings: Add I2C bindings for mt65xx/mt81xx Eddie Huang
[not found] ` <1430901427-65146-2-git-send-email-eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-05-12 12:37 ` wsa-z923LK4zBo2bacvFa/9K2g
[not found] ` <20150512123709.GA4447-oo5tB6JMkjKRinMKxDlMNPwbnWRJjS81@public.gmane.org>
2015-05-12 12:45 ` Sascha Hauer
2015-05-06 8:37 ` [PATCH v7 2/3] I2C: mediatek: Add driver for MediaTek I2C controller Eddie Huang
[not found] ` <1430901427-65146-3-git-send-email-eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-05-12 12:58 ` wsa-z923LK4zBo2bacvFa/9K2g [this message]
[not found] ` <20150512125832.GB4447-oo5tB6JMkjKRinMKxDlMNPwbnWRJjS81@public.gmane.org>
2015-05-18 5:58 ` Eddie Huang
2015-05-18 6:37 ` Wolfram Sang
2015-05-18 7:42 ` Eddie Huang
2015-05-18 9:05 ` Wolfram Sang
2015-05-06 8:37 ` [PATCH v7 3/3] I2C: mediatek: Add driver for MediaTek MT8173 " Eddie Huang
[not found] ` <1430901427-65146-4-git-send-email-eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-05-12 13:00 ` wsa-z923LK4zBo2bacvFa/9K2g
2015-05-07 7:39 ` [PATCH v7 0/3] ARM: mediatek: Add driver for Mediatek I2C Lee Jones
2015-05-07 7:54 ` Eddie Huang
2015-05-07 8:27 ` Lee Jones
2015-05-12 12:45 ` Sascha Hauer
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=20150512125832.GB4447@schokonusskuchen.bad \
--to=wsa-z923lk4zbo2bacvfa/9k2g@public.gmane.org \
--cc=anders.berg-1wcpHE2jlwO1Z/+hSey0Gg@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=b.galvani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=david.e.box-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=jdelvare-l3A5Bk7waGM@public.gmane.org \
--cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=max.schwarz-BGeptl67XyCzQB+pC5nmwQ@public.gmane.org \
--cc=neelegup-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=rjui-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=sledge.yanwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=srv_heupstream-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=xudong.chen-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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