From: Wolfram Sang <wsa@the-dreams.de>
To: Jan Glauber <jglauber@cavium.com>
Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
David Daney <ddaney@caviumnetworks.com>
Subject: Re: [PATCH v2 01/10] i2c-octeon: Cleanup i2c-octeon driver
Date: Sat, 5 Mar 2016 19:47:31 +0100 [thread overview]
Message-ID: <20160305184731.GB1394@katana> (raw)
In-Reply-To: <4b342427bdf6d7dc7cf9ded9172deadd24a53650.1457111729.git.jglauber@cavium.com>
[-- Attachment #1: Type: text/plain, Size: 5545 bytes --]
Hi Jan,
The description is not enough. A list what kind of changes you applied
would be nice.
I'd like to have these checkpatch issues fixed:
ERROR: trailing statements should be on next line
#177: FILE: drivers/i2c/busses/i2c-octeon.c:133:
+ while ((tmp & SW_TWSI_V) != 0);
ERROR: trailing statements should be on next line
#202: FILE: drivers/i2c/busses/i2c-octeon.c:152:
+ while ((tmp & SW_TWSI_V) != 0);
CHECK: Prefer using the BIT_ULL macro
#52: FILE: drivers/i2c/busses/i2c-octeon.c:39:
+#define SW_TWSI_V (1ULL << 63)
Note: I don't care so much about the 80 char limit as long as the line
length is not too excessive.
> -#define DRV_NAME "i2c-octeon"
> +#define DRV_NAME "i2c-octeon"
I'm in favor for indenting register and bit defines, but other than that
I think one space is enough. I won't force my opinion on you, though.
Just wanted to let you know.
> +#define INT_ENA_ST 0x1
> +#define INT_ENA_TS 0x2
> +#define INT_ENA_CORE 0x4
I assume those are bits? Then, they shouldn't be in the registers
section.
> +/* TWSI_INT values */
> +#define ST_INT 0x01
> +#define TS_INT 0x02
> +#define CORE_INT 0x04
> +#define ST_EN 0x10
> +#define TS_EN 0x20
> +#define CORE_EN 0x40
> +#define SDA_OVR 0x100
> +#define SCL_OVR 0x200
> +#define SDA 0x400
> +#define SCL 0x800
I think those should have a prefix. SDA and SCL are dangerously generic.
> struct octeon_i2c {
> - wait_queue_head_t queue;
> - struct i2c_adapter adap;
> - int irq;
> - u32 twsi_freq;
> - int sys_freq;
> - resource_size_t twsi_phys;
> - void __iomem *twsi_base;
> - resource_size_t regsize;
> - struct device *dev;
> + wait_queue_head_t queue;
> + struct i2c_adapter adap;
> + int irq;
> + u32 twsi_freq;
> + int sys_freq;
> + void __iomem *twsi_base;
> + struct device *dev;
NAK. structs change often, and then one needs to fix the whole
indentation. One space is enough here.
> };
> -static u8 octeon_i2c_read_sw(struct octeon_i2c *i2c, u64 eop_reg)
> +static u64 octeon_i2c_read_sw64(struct octeon_i2c *i2c, u64 eop_reg)
...
> - return tmp & 0xFF;
> + return tmp;
> +}
...
> +
> +/**
> + * octeon_i2c_read_sw - read lower bits of an I2C core register
> + * @i2c: The struct octeon_i2c
> + * @eop_reg: Register selector
> + *
> + * Returns the data.
> + *
> + * The I2C core registers are accessed indirectly via the SW_TWSI CSR.
> + */
> +static u8 octeon_i2c_read_sw(struct octeon_i2c *i2c, u64 eop_reg)
> +{
> + return octeon_i2c_read_sw64(i2c, eop_reg);
> }
This is not a cleanup!
> +/* disable the CORE interrupt */
> static void octeon_i2c_int_disable(struct octeon_i2c *i2c)
> {
> - octeon_i2c_write_int(i2c, 0);
> + /* clear TS/ST/IFLG events */
> + octeon_i2c_write_int(i2c, TS_INT | ST_INT);
> }
Isn't this a functional change?
> /**
> - * octeon_i2c_unblock - unblock the bus.
> - * @i2c: The struct octeon_i2c.
> + * bitbang_unblock - unblock the bus
> + * @i2c: The struct octeon_i2c
> *
> - * If there was a reset while a device was driving 0 to bus,
> - * bus is blocked. We toggle it free manually by some clock
> - * cycles and send a stop.
> + * If there was a reset while a device was driving 0 to bus, bus is blocked.
> + * We toggle it free manually by some clock cycles and send a stop.
> */
> -static void octeon_i2c_unblock(struct octeon_i2c *i2c)
> +static void bitbang_unblock(struct octeon_i2c *i2c)
I dunno understand the change of the function name. However, this should
be refactored to use the i2c_bus_recovery infrastructure anyhow.
> - result = wait_event_timeout(i2c->queue,
> - octeon_i2c_test_iflg(i2c),
> - i2c->adap.timeout);
> -
> + result = wait_event_timeout(i2c->queue, octeon_i2c_test_iflg(i2c),
> + i2c->adap.timeout);
You could rename this variable to 'time_left' to make the code even
easier to read.
> static int octeon_i2c_write(struct octeon_i2c *i2c, int target,
> - const u8 *data, int length)
> + u8 *data, int length)
Why this change?
> {
> - int i, result;
> + int result, i;
And this?
> -static int octeon_i2c_read(struct octeon_i2c *i2c, int target,
> - u8 *data, int length)
> +static int octeon_i2c_read(struct octeon_i2c *i2c, int target, u8 *data,
> + u16 *rlength)
> {
> + int length = *rlength;
And this?
> @@ -353,15 +411,14 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target,
> if (result)
> return result;
>
> - octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, (target<<1) | 1);
> - octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB);
> -
> + octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, TWSI_CTL_ENAB);
Is this really the same?
> static u32 octeon_i2c_functionality(struct i2c_adapter *adap)
> @@ -435,13 +490,10 @@ static struct i2c_adapter octeon_i2c_ops = {
> .owner = THIS_MODULE,
> .name = "OCTEON adapter",
> .algo = &octeon_i2c_algo,
> - .timeout = HZ / 50,
This is a functional change, or?
> - i2c->twsi_phys = res_mem->start;
> - i2c->regsize = resource_size(res_mem);
Those are removed which is okay in general, but should be in a seperate
patch.
This patch was hard to review because so many changes were overlapping.
It really should have been broken out. Like one patch only removing the
trailing "." in the kernel-doc. One fixing the indentation issues. One
removing the now superfluous fields in struct octeon_i2c, etc...
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-03-05 18:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 17:57 [PATCH v2 00/10] i2c-octeon and i2c-thunderx drivers Jan Glauber
2016-03-04 17:57 ` [PATCH v2 01/10] i2c-octeon: Cleanup i2c-octeon driver Jan Glauber
2016-03-05 18:47 ` Wolfram Sang [this message]
2016-03-06 13:00 ` Jan Glauber
2016-03-06 14:35 ` Wolfram Sang
2016-03-04 17:57 ` [PATCH v2 02/10] i2c-octeon: Support I2C_M_RECV_LEN Jan Glauber
2016-03-04 17:57 ` [PATCH v2 03/10] i2c-octeon: Enable high-level controller and improve on bus contention Jan Glauber
2016-03-04 17:57 ` [PATCH v2 04/10] dt-bindings: i2c: add Octeon cn78xx TWSI Jan Glauber
2016-03-04 17:57 ` [PATCH v2 05/10] i2c-octeon: Add support for cn78XX chips Jan Glauber
2016-03-04 17:57 ` [PATCH v2 06/10] i2c-octeon: Flush TWSI writes with readback Jan Glauber
2016-03-04 17:57 ` [PATCH v2 07/10] i2c-octeon: Faster operation when IFLG signals late Jan Glauber
2016-03-04 17:57 ` [PATCH v2 08/10] i2c-octeon: Add workaround for chips with broken irqs Jan Glauber
2016-03-04 17:57 ` [PATCH v2 09/10] i2c: split i2c-octeon driver and add ThunderX support Jan Glauber
2016-03-04 17:57 ` [PATCH v2 10/10] i2c: thunderx: add smbus support Jan Glauber
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=20160305184731.GB1394@katana \
--to=wsa@the-dreams.de \
--cc=ddaney@caviumnetworks.com \
--cc=jglauber@cavium.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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