Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756298AbcCCCoU (ORCPT ); Wed, 2 Mar 2016 21:44:20 -0500 Received: from smtprelay0174.hostedemail.com ([216.40.44.174]:55952 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756008AbcCCCoR (ORCPT ); Wed, 2 Mar 2016 21:44:17 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3355:3622:3866:3867:3868:3870:3871:3872:4321:5007:6261:7903:10004:10400:10848:11026:11232:11473:11658:11914:12043:12048:12217:12296:12438:12517:12519:12534:12740:13095:13439:13894:14659:21080:30007:30054:30083:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: day48_7b903cc4f855 X-Filterd-Recvd-Size: 3673 Message-ID: <1456973050.4044.81.camel@perches.com> Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver From: Joe Perches To: "jeffrey.lin" , dmitry.torokhov@gmail.com, rydberg@euromail.se, grant.likely@linaro.org, robh+dt@kernel.org, jeesw@melfas.com, bleung@chromium.org, scott.liu@emc.com.tw Cc: jeffrey.lin@rad-ic.com, roger.yang@rad-ic.com, KP.li@rad-ic.com, albert.shieh@rad-ic.com, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, devicetree@vger.kernel.org Date: Wed, 02 Mar 2016 18:44:10 -0800 In-Reply-To: <1456972150-32303-1-git-send-email-jeffrey.lin@rad-ic.com> References: <1456972150-32303-1-git-send-email-jeffrey.lin@rad-ic.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2487 Lines: 101 On Thu, 2016-03-03 at 10:29 +0800, jeffrey.lin wrote: > This patch is porting Raydium I2C touch driver. Developer can enable raydium touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS". trivial comments: > diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c [] > +static int raydium_i2c_send(struct i2c_client *client, > + u8 addr, u8 *data, size_t len) > +{ > + u8 buf[MAX_PACKET_SIZE + 1]; > + int i, tries = 0; > + > + if (len > MAX_PACKET_SIZE) > + return -EINVAL; > + > + buf[0] = addr & 0xff; Seems pointless to use & 0xff when both buf and addr are u8 > + for (i = 0; i < len; i++) > + buf[i + 1] = *data++; memcpy. ?Maybe: buf[0] = addr; memcpy(&buf[1], data, len); > +static int raydium_i2c_send_message(struct i2c_client *client, > + size_t len, void *data) > +{ > + int error; > + u8 buf[HEADER_SIZE], ii; > + > + for (ii = 0; ii < HEADER_SIZE; ii++) > + buf[ii] = ((u8 *)data)[3 - ii]; > + /*set data bank*/ > + error = raydium_i2c_send(client, CMD_BANK_SWITCH, > + (u8 *)buf, HEADER_SIZE); > + > + /*send messange*/ typo, message > + if (!error) > + error = raydium_i2c_send(client, buf[ADDR_INDEX], buf, len); > + > + return error; > +} > + > +static int raydium_i2c_sw_reset(struct i2c_client *client) > +{ > + const u8 soft_rst_cmd[] = { 0x01, 0x04, 0x00, 0x00, 0x40}; static > + int error; > + > + error = raydium_i2c_send_message(client, > + 1, (void *)soft_rst_cmd); could be better on a single line > +static int raydium_i2c_fastboot(struct i2c_client *client) > +{ > + const u8 boot_cmd[] = { 0x20, 0x06, 0x00, 0x50 }; > + u8 buf[HEADER_SIZE]; > + int error; > + > + error = raydium_i2c_read_message(client, > + get_unaligned_be32(boot_cmd), > + sizeof(boot_cmd), > + buf); > + > + if (error) { > + dev_err(&client->dev, "boot failed: %d\n", error); > + return error; > + } else if (buf[0] == RM_BOOT_BLDR) { unnecessary else > + dev_dbg(&client->dev, "boot in fastboot mode\n"); > + return -EINVAL; > + } > + > + dev_dbg(&client->dev, "boot success -- 0x%x\n", client->addr); > + return 0; > +} > + > +static int raydium_i2c_initialize(struct raydium_data *ts) > +{ > + struct i2c_client *client = ts->client; > + int error, retry_cnt; > + const u8 recov_packet[] = { 0x04, 0x81 }; static and etc... generally, it'd be nice to align to open parenthesis and to more maximally fill lines to 80 chars instead of using relatively short line lengths and multiple line statements.