From patchwork Fri Feb 1 08:11:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kurtz X-Patchwork-Id: 2077611 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 13864DFE75 for ; Fri, 1 Feb 2013 08:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756058Ab3BAIM0 (ORCPT ); Fri, 1 Feb 2013 03:12:26 -0500 Received: from mail-pb0-f48.google.com ([209.85.160.48]:53190 "EHLO mail-pb0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755976Ab3BAIMX (ORCPT ); Fri, 1 Feb 2013 03:12:23 -0500 Received: by mail-pb0-f48.google.com with SMTP id wy12so2050198pbc.35 for ; Fri, 01 Feb 2013 00:12:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=nZ2cgzBdtfLhvb1b6Nxmfum26DtcI8rATkBcIOCOuM0=; b=Es/d+1DvWOLKbZeIV4Kma0Vo2Ioan/6skpfeCPrzdOVxilAMI4ec+ReliKa9vS6rPI OY30qtiVARyi31kFn8T8hozjP+NVlXGbCicSyVBzYmLYIV6eRQ2RhjWLxRswpTe6csog XFfi1nZHh6sUuviFMaFrQdCSBurox7Kj5YzLE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=nZ2cgzBdtfLhvb1b6Nxmfum26DtcI8rATkBcIOCOuM0=; b=Hvbx80HDkRps51ZWrilX6G9rn93cOmjo34lrvi6cSdNY97Stia3Rj3+JLbKIWYVAk5 0GxTt0qszu3akMbTzo59uI74UaPCRbURZOpbGO0ca5dR5v7R9JhlRxy3s60zW0QkOkyj vNMMnYoliQdFNHY6hc+/WlAitz+lZo3ibVEdaaGhQbYkS5fra96D1sj6AFlRKUTcnJrG bh1BcRQHzANKT4fJz3SZyO7iEPUXqkqtLaN5wuVUt7qpOHCaCOEZ4NpHNU7AsDdG8Im5 GRuQSU8Bv9EpyuQUEExxzenvpLGG89egRgvzB+hU5pRapwQT52s+LHRdz8t6QVr+y/8t faiQ== X-Received: by 10.68.135.99 with SMTP id pr3mr30016118pbb.151.1359706342544; Fri, 01 Feb 2013 00:12:22 -0800 (PST) Received: from djkurtz-z620.tpe.corp.google.com (djkurtz-z620.tpe.corp.google.com [172.30.210.61]) by mx.google.com with ESMTPS id bi8sm8398002pab.15.2013.02.01.00.12.18 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Feb 2013 00:12:21 -0800 (PST) From: Daniel Kurtz To: Dmitry Torokhov , Henrik Rydberg , Benson Leung , Yufeng Shen , Nick Dyer Cc: Joonyoung Shim , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, olofj@chromium.org, Daniel Kurtz Subject: [PATCH 06/10] Input: atmel_mxt_ts - destroy state before fw update and restore after Date: Fri, 1 Feb 2013 16:11:48 +0800 Message-Id: <1359706312-24642-7-git-send-email-djkurtz@chromium.org> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1359706312-24642-1-git-send-email-djkurtz@chromium.org> References: <1359706312-24642-1-git-send-email-djkurtz@chromium.org> X-Gm-Message-State: ALoCoQlcwKbZPGe3V9Nx3PsGR9uu22YU+R7NQHLFF0zKbHhtKZiRkTa8EHgRAGiwxnojOMIWQYaQ Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org After firmware update, the device may have a completely different object table which corresponds to an input device with different properties. So, destroy the old state before firmware update, and completely reinitialize the driver afterward. Two benefits of this: 1) Since there is no input device during fw update, no need to worry about device open/close events. 2) If firmware update fails, the device and driver will still be in bootloader mode and an improperly configured input device will not exist. Signed-off-by: Daniel Kurtz --- drivers/input/touchscreen/atmel_mxt_ts.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 76a25d3..c74f5a5 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -1001,6 +1001,13 @@ static int mxt_load_fw(struct device *dev, const char *fn) client->addr = MXT_BOOT_HIGH; bootloader_ready: + /* Free any driver state. It will get reinitialized after fw update. */ + mxt_free_object_table(data); + if (data->input_dev) { + input_unregister_device(data->input_dev); + data->input_dev = NULL; + } + ret = mxt_check_bootloader(client, MXT_WAITING_BOOTLOAD_CMD); if (ret) goto out; @@ -1068,9 +1075,8 @@ static ssize_t mxt_update_fw_store(struct device *dev, /* Wait for reset */ msleep(MXT_FWRESET_TIME); - mxt_free_object_table(data); - mxt_initialize(data); + mxt_input_dev_create(data); } enable_irq(data->irq);