From patchwork Mon May 11 21:33:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 6384211 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 850AC9F374 for ; Mon, 11 May 2015 21:33:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9226020CAE for ; Mon, 11 May 2015 21:33:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 856A620CAB for ; Mon, 11 May 2015 21:33:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752081AbbEKVds (ORCPT ); Mon, 11 May 2015 17:33:48 -0400 Received: from bhuna.collabora.co.uk ([93.93.135.160]:43473 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751414AbbEKVdr (ORCPT ); Mon, 11 May 2015 17:33:47 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: javier) with ESMTPSA id 741DE600088 Message-ID: <55512034.3000206@collabora.co.uk> Date: Mon, 11 May 2015 23:33:40 +0200 From: Javier Martinez Canillas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 MIME-Version: 1.0 To: Gwendal Grignou CC: Lee Jones , Samuel Ortiz , Olof Johansson , Doug Anderson , Bill Richardson , Simon Glass , Stephen Barber , Filipe Brandenburger , Todd Broch , Alexandru M Stan , Heiko Stuebner , linux-samsung-soc@vger.kernel.org, Linux Kernel Subject: Re: [PATCH v2 04/10] mfd: cros_ec: Use a zero-length array for command data References: <1431166241-15775-1-git-send-email-javier.martinez@collabora.co.uk> <1431166241-15775-5-git-send-email-javier.martinez@collabora.co.uk> In-Reply-To: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello, Thanks all for testing and sorry for this issue. On 05/11/2015 10:19 PM, Gwendal Grignou wrote: > On Sat, May 9, 2015 at 3:10 AM, Javier Martinez Canillas > wrote: [snip] >> >> static u32 ec_i2c_functionality(struct i2c_adapter *adap) >> diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c >> index b50c5b8b8a4d..090f8a75412a 100644 >> --- a/drivers/input/keyboard/cros_ec_keyb.c >> +++ b/drivers/input/keyboard/cros_ec_keyb.c >> @@ -149,16 +149,19 @@ static void cros_ec_keyb_process(struct cros_ec_keyb *ckdev, >> static int cros_ec_keyb_get_state(struct cros_ec_keyb *ckdev, uint8_t *kb_state) >> { >> int ret; >> - struct cros_ec_command msg = { >> - .command = EC_CMD_MKBP_STATE, >> - .insize = ckdev->cols, >> - }; >> + struct cros_ec_command *msg = (struct cros_ec_command *)kb_state; > Following amstan@ comments in 00/10 patch, > I think there is something wrong here: > kb_state should already have a cros_ec_command header, so that the > lower layer can > copy into the 'old' kb_state array directly. > There will be no need for the memcpy later. > True, the memcpy should not be needed but I copied at the beginning of kb_state to avoid having to compute the kb_state + sizeof(struct cros_ec_command) offset in cros_ec_keyb_process(). > Gwendal. >> >> - ret = cros_ec_cmd_xfer(ckdev->ec, &msg); >> - if (ret < 0) >> + msg->command = EC_CMD_MKBP_STATE; >> + msg->insize = ckdev->cols; >> + msg->outsize = 0; >> + As Alexandru said, the EC is returning EC_RES_INVALID_VERSION and looking at this code I see that there is a difference since v1 was using designated initializers when declaring the struct cros_ec_command as a local variable in the stack. But in v2 the struct members are explicitly initialized since kb_state is not initialized and I missed the version field so now it has an undefined value. Heiko, Alexandru, I don't have access to my Chromebooks right now but could you please test the following patch [0] to see if that is the problem? It seems I got it working on my test just out of luck since it happened that version was initialized to 0 due the data it was on the stack. Tomorrow when I've access to the Chromebooks I'll do more extensive testing and see if I can reproduce the issue and if my assumption is correct. Best regards, Javier [0] --- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c index ef3ba20f4560..4f233e248a4d 100644 --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c @@ -151,6 +151,7 @@ static int cros_ec_keyb_get_state(struct cros_ec_keyb *ckdev, uint8_t *kb_state) int ret; struct cros_ec_command *msg = (struct cros_ec_command *)kb_state; + msg->version = 0; msg->command = EC_CMD_MKBP_STATE; msg->insize = ckdev->cols; msg->outsize = 0;