Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751570AbcCFNA5 (ORCPT ); Sun, 6 Mar 2016 08:00:57 -0500 Received: from mail-bl2on0079.outbound.protection.outlook.com ([65.55.169.79]:10512 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751407AbcCFNAz (ORCPT ); Sun, 6 Mar 2016 08:00:55 -0500 Authentication-Results: the-dreams.de; dkim=none (message not signed) header.d=none;the-dreams.de; dmarc=none action=none header.from=caviumnetworks.com; Date: Sun, 6 Mar 2016 14:00:38 +0100 From: Jan Glauber To: Wolfram Sang CC: , , David Daney Subject: Re: [PATCH v2 01/10] i2c-octeon: Cleanup i2c-octeon driver Message-ID: <20160306130038.GC4736@hardcore> References: <4b342427bdf6d7dc7cf9ded9172deadd24a53650.1457111729.git.jglauber@cavium.com> <20160305184731.GB1394@katana> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20160305184731.GB1394@katana> User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [46.223.156.55] X-ClientProxiedBy: AM3PR05CA014.eurprd05.prod.outlook.com (10.141.192.24) To SN2PR0701MB767.namprd07.prod.outlook.com (25.160.15.145) X-MS-Office365-Filtering-Correlation-Id: fadfdf41-a09f-4c97-4ab1-08d345bf5909 X-Microsoft-Exchange-Diagnostics: 1;SN2PR0701MB767;2:mA6OMttanpA8bHwq61S52gOUzn1aLFF0obNHbVH4rFiUd5WoN8K1mDu9GbCluioN9+rkvswTfYeSlAl9rUbhCrHY5bBQ9ZqUosVEm/ZosrzTlfYUjFq1dabkXRdjwIp2AILQN690TCzYfoN21Sc0vpkz1HSZ6DO9pLPh8HYlaj3P9J0HrJXUVb0FlmRtRMeS;3:1mnreyk02fdwkXK6wyhPWkRyoscdoVICzLXP7QfL7tVA3tlIFceOIJ1Kb+PfA9jAoowJeU4GkD5dfkVK3dZtIh8ay23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b5BXDAm1E3Mnsu5IEIG2Wa96Ut6E= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046);SRVR:SN2PR0701MB767;BCL:0;PCL:0;RULEID:;SRVR:SN2PR0701MB767; X-Microsoft-Exchange-Diagnostics: 1;SN2PR0701MB767;4:qlAxsT0zd6NgKRPAgDYtphADB8MI2LBjcXHhRFR2FpFxSM2YfiKmMHt0aiMVWzHN/8N3DQEX/fwA4Y2mPK8prw+WBVR5ujLfOTz/JiY4pLvJXXT1TmoCDdMSIhfoLF/rPvBmD8H0sZaDFyiEFoS/wrUy4gX5hM0EVhMRC/IOhgj22qqo807hYvMLFF41XtwC14syFY7jUpSVyxO7Zc5d0alpzTTj/Suc06NgNEqPb8u2jBzhJ+HOCG27fCaD/q42biPeCxH1bnTMNmGtXvrRP4Khq+UTcbUIBIoBk+dhbhyzLvlB0Uy2JT06s1UcKX0tfwxLt2oi6qhxvYHoXPOLu1fKL5cvBhQXcrI6pI4cjY5Ip3VV2Mu0mqvZeH2Kpe4N X-Forefront-PRVS: 087396016C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(52604005)(51694002)(24454002)(107886002)(110136002)(50466002)(33716001)(189998001)(77096005)(40100003)(4001350100001)(81166005)(122386002)(5004730100002)(92566002)(46406003)(87976001)(42186005)(6116002)(3846002)(586003)(4001430100002)(76176999)(1096002)(50986999)(1076002)(23726003)(54356999)(97756001)(66066001)(4326007)(2906002)(2950100001)(33656002)(5008740100001)(83506001)(86362001)(19580395003)(47776003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR0701MB767;H:hardcore;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR0701MB767;23:Av5qM83GOQRAOpVUu49HBx+6k/5inHdwNN579BSW?= =?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Prw8QDL4uFGiYyS5l8TBf7tMJ+TA?= =?us-ascii?Q?9jkDiAqmFDpMma5MEwclITLoVtu7IvgB4227wAGDG8HfvGpFnWbD9nqUMrvW?= =?us-ascii?Q?iyzTH+iu9Apa9Qchveh/eHkKnZS2l7fx+DJSFnBzMzrj9uatbQa+yfWkIkXV?= =?us-ascii?Q?XSWbfguXONdU3XOXtw7rUe1h1RU2JxPHcbqQhin8dfXqkrj2wQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;SN2PR0701MB767;5:Yx4MXqyF3BZifOgW6dA6dcCXdnBCpM9AGxJbGL8WUBwXFPwR/uZtVIkwR5bGvEMuH1Iw+VNLbfJCpn9Og0PS1nfHcDSBrXkTR1xOnl0DMtcwBNntqjQOaxrlQWHNa3Cr+VH9oMIUyuQwW0Y1d1rpIw==;24:B8UHZCZrauNPo2H8RJC9WKo51Ior+jNv6DgrvcD5BG8pyF17Ya/JvsMr9/v4NWCwlcLxmEnoKhtMXZ/pDqNMU8aJZKfMbNJB+Ra4qrwWV+c= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2016 13:00:51.2191 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR0701MB767 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6686 Lines: 236 On Sat, Mar 05, 2016 at 07:47:31PM +0100, Wolfram Sang wrote: > Hi Jan, > > The description is not enough. A list what kind of changes you applied > would be nice. OK. > 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); Fixed. Strange that checkpatch.pl -f (use on file) does not report these errors though. > CHECK: Prefer using the BIT_ULL macro > #52: FILE: drivers/i2c/busses/i2c-octeon.c:39: > +#define SW_TWSI_V (1ULL << 63) OK > Note: I don't care so much about the 80 char limit as long as the line > length is not too excessive. Fine, same opinion here. I'll try to limit the 80 char changes to a sane minimum then. > > > -#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. OK > > +#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. I'll move them to the thunderx patch. > > +/* 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. Agreed, I'll make these TWSI_INT_*. > > 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. Not sure I understand your argument. I find this form more readable but I can change that to one space. > > }; > > > -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! OK, I'll move that to the patch where it's used. > > +/* 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? Looks like a bug, I'll drop that. > > /** > > - * 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. I'll leave the function name as it is. Would it be possbile to address the refactoring in a follow-up patch after this series is finished? > > - 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. Agreed. > > 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? I'll drop these two, just noise from merging back and forth. > > -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? I'll move this to the patch where it's used. > > @@ -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? I'll move this to a later patch. > > 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? Hmm, it isn't for arm64 (HZ 250) but it would be for MIPS (HZ 100). I'll make it a seperate patch then. > > - 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. OK > 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... I'll split it into several patches then. Thanks for reviewing, Jan > Wolfram >