From: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
To: Laurent Pinchart
<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Magnus Damm <magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Simon Horman <horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>,
Geert Uytterhoeven
<geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Subject: Re: [PATCH 3/5] i2c: emev2: add driver
Date: Tue, 7 Jul 2015 21:49:32 +0200 [thread overview]
Message-ID: <20150707194931.GC1572@katana> (raw)
In-Reply-To: <8117172.9hfShvmdlS@avalon>
[-- Attachment #1: Type: text/plain, Size: 2249 bytes --]
> > +static inline void em_clear_set_bit(struct em_i2c_device *priv, u8 clear,
> > u8 set, u8 reg)
>
> Maybe em_i2c_clear_set_bit for consistency ? I'd prefer having the reg
> argument before clear and set, but maybe that's just me.
This is such a generic function that I decided to skip 'i2c' in the
function name. Can add it, don't have a strong preference.
> I would have also introduced em_i2c_read and em_i2c_write. That's entirely up
> to you.
I don't like such wrappers around standard read/write functions. What's
the gain?
> > + retr = 1000;
> > + while (readb(priv->base + I2C_OFS_IICACT0) == 1 && retr)
>
> How about adding a cpu_relax() here ?
Can do, but I think it is overkill.
>
> > + /* Extra setup for read transactions */
> > + if (!(status & I2C_BIT_TRC0)) {
>
> How about checking msg->flags & I2C_M_RD here ? It should be equivalent but
> would make the code more readable by not requiring knowledge of the hardware.
I buy this argument. Will change.
> > + priv = devm_kzalloc(&pdev->dev, sizeof(struct em_i2c_device),
> GFP_KERNEL);
>
> I'd use sizeof(*priv).
Yes, definately.
> > + irq = platform_get_irq(pdev, 0);
>
> I'd move this call right before devm_request_irq() below. devm_request_irq()
> should handle invalid IRQs, but won't print an error message. I'd let you
> decide whether that's a problem.
Will check.
>
> > + priv->adap.timeout = msecs_to_jiffies(100);
> > + priv->adap.retries = 5;
>
> Is there a particular reason for setting the number of retries to 5 ?
It should be non-zero at least, so bus access will be retried if -EAGAIN
is returned because of a busy bus.
> > + if (ret)
> > + goto exit_clk;
>
> Nitpicking, I'd call this error_clk to show that the label is used in case of
> error only. You could also just call it error as there's no other error-
> related label.
Yup.
> > + dev_info(&pdev->dev, "Added i2c controller %d irq %d @ 0x%p\n",
> > + priv->adap.nr, irq, priv->base);
>
> Is priv->base useful here ? The physical address of the registers block could
> be, but its kernel virtual address doesn't seem very interesting to me.
Agreed.
Thanks for the review!
Wolfram
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Wolfram Sang <wsa@the-dreams.de>
To: Laurent Pinchart
<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Magnus Damm <magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Simon Horman <horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>,
Geert Uytterhoeven
<geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Subject: Re: [PATCH 3/5] i2c: emev2: add driver
Date: Tue, 07 Jul 2015 19:49:32 +0000 [thread overview]
Message-ID: <20150707194931.GC1572@katana> (raw)
In-Reply-To: <8117172.9hfShvmdlS@avalon>
[-- Attachment #1: Type: text/plain, Size: 2249 bytes --]
> > +static inline void em_clear_set_bit(struct em_i2c_device *priv, u8 clear,
> > u8 set, u8 reg)
>
> Maybe em_i2c_clear_set_bit for consistency ? I'd prefer having the reg
> argument before clear and set, but maybe that's just me.
This is such a generic function that I decided to skip 'i2c' in the
function name. Can add it, don't have a strong preference.
> I would have also introduced em_i2c_read and em_i2c_write. That's entirely up
> to you.
I don't like such wrappers around standard read/write functions. What's
the gain?
> > + retr = 1000;
> > + while (readb(priv->base + I2C_OFS_IICACT0) == 1 && retr)
>
> How about adding a cpu_relax() here ?
Can do, but I think it is overkill.
>
> > + /* Extra setup for read transactions */
> > + if (!(status & I2C_BIT_TRC0)) {
>
> How about checking msg->flags & I2C_M_RD here ? It should be equivalent but
> would make the code more readable by not requiring knowledge of the hardware.
I buy this argument. Will change.
> > + priv = devm_kzalloc(&pdev->dev, sizeof(struct em_i2c_device),
> GFP_KERNEL);
>
> I'd use sizeof(*priv).
Yes, definately.
> > + irq = platform_get_irq(pdev, 0);
>
> I'd move this call right before devm_request_irq() below. devm_request_irq()
> should handle invalid IRQs, but won't print an error message. I'd let you
> decide whether that's a problem.
Will check.
>
> > + priv->adap.timeout = msecs_to_jiffies(100);
> > + priv->adap.retries = 5;
>
> Is there a particular reason for setting the number of retries to 5 ?
It should be non-zero at least, so bus access will be retried if -EAGAIN
is returned because of a busy bus.
> > + if (ret)
> > + goto exit_clk;
>
> Nitpicking, I'd call this error_clk to show that the label is used in case of
> error only. You could also just call it error as there's no other error-
> related label.
Yup.
> > + dev_info(&pdev->dev, "Added i2c controller %d irq %d @ 0x%p\n",
> > + priv->adap.nr, irq, priv->base);
>
> Is priv->base useful here ? The physical address of the registers block could
> be, but its kernel virtual address doesn't seem very interesting to me.
Agreed.
Thanks for the review!
Wolfram
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-07-07 19:49 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-06 21:46 [PATCH 0/5] enable I2C on Renesas EMEV2 and KZM9D board Wolfram Sang
2015-07-06 21:46 ` Wolfram Sang
2015-07-06 21:46 ` [PATCH 1/5] clk: shmobile: emev2: deassert reset for IIC0/1 Wolfram Sang
2015-07-06 21:46 ` Wolfram Sang
2015-07-06 21:57 ` Stephen Boyd
2015-07-06 21:57 ` Stephen Boyd
2015-07-06 21:46 ` [PATCH 2/5] i2c: emev2: add binding documentation Wolfram Sang
2015-07-06 21:46 ` Wolfram Sang
2015-07-07 8:41 ` Geert Uytterhoeven
2015-07-07 8:41 ` Geert Uytterhoeven
2015-07-07 9:17 ` Wolfram Sang
2015-07-07 9:17 ` Wolfram Sang
2015-07-07 9:22 ` Geert Uytterhoeven
2015-07-07 9:22 ` Geert Uytterhoeven
2015-07-07 17:26 ` Laurent Pinchart
2015-07-07 17:26 ` Laurent Pinchart
2015-07-07 19:43 ` Wolfram Sang
2015-07-07 19:43 ` Wolfram Sang
2015-07-07 19:47 ` Laurent Pinchart
2015-07-07 19:47 ` Laurent Pinchart
2015-07-07 19:53 ` Wolfram Sang
2015-07-07 19:53 ` Wolfram Sang
2015-07-09 0:35 ` Laurent Pinchart
2015-07-09 0:35 ` Laurent Pinchart
2015-07-09 15:20 ` Wolfram Sang
2015-07-09 15:20 ` Wolfram Sang
[not found] ` <1436219188-4325-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2015-07-06 21:46 ` [PATCH 3/5] i2c: emev2: add driver Wolfram Sang
2015-07-06 21:46 ` Wolfram Sang
2015-07-07 18:40 ` Laurent Pinchart
2015-07-07 18:40 ` Laurent Pinchart
2015-07-07 19:49 ` Wolfram Sang [this message]
2015-07-07 19:49 ` Wolfram Sang
2015-07-06 21:46 ` [PATCH 5/5] ARM: shmobile: emev2: kzm9d: enable IIC busses Wolfram Sang
2015-07-06 21:46 ` Wolfram Sang
2015-07-07 8:38 ` [PATCH 0/5] enable I2C on Renesas EMEV2 and KZM9D board Geert Uytterhoeven
2015-07-07 8:38 ` Geert Uytterhoeven
[not found] ` <CAMuHMdUwivjTgj-nOKnHhmmU2po0JMPDhHqW6z7ngiO-D+a6iA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-07 9:10 ` Wolfram Sang
2015-07-07 9:10 ` Wolfram Sang
2015-07-06 21:46 ` [PATCH 4/5] ARM: shmobile: emev2: add IIC cores to dtsi Wolfram Sang
2015-07-06 21:46 ` Wolfram Sang
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=20150707194931.GC1572@katana \
--to=wsa-z923lk4zbo2bacvfa/9k2g@public.gmane.org \
--cc=geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org \
--cc=horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org \
--cc=laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.