From patchwork Wed Mar 25 13:33:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 11457837 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 475991668 for ; Wed, 25 Mar 2020 13:36:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 310112076A for ; Wed, 25 Mar 2020 13:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727955AbgCYNgK (ORCPT ); Wed, 25 Mar 2020 09:36:10 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:4463 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727948AbgCYNgK (ORCPT ); Wed, 25 Mar 2020 09:36:10 -0400 IronPort-SDR: VnlIIkIznCUr4o5T+oseVSnWa8G1KUj/OtBqIA2zppijgv4fwhSoG6zRR9JCKVTxkv3nyIh7jR DrXur5RoZColw9VHTpL/oEXm85TFyt2AFVTpUT0WtZ2pd7ck0rGR4sAEZQlu/bO2QJc1lvld2r 1zR48u+FwrFh8pLqQqmKfaewJcaTLsglGEYCxsUCTilb8ldsZjg98WRCoAtzgN0lzjI+DKBcvC iCsXpxmbzDxASjYBEAK56AmZhi0zwVlaamff6pq1xDSpaK8vicsaPhV9888cmk5d7vP4UI52FF sKc= X-IronPort-AV: E=Sophos;i="5.72,304,1580803200"; d="scan'208";a="49060139" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 25 Mar 2020 05:36:08 -0800 IronPort-SDR: LAF+UUivNXHcV3L+e0zxYfQOcHfbT4ndWu4Ml54qCbV/K54szAccifGT9f+E9LPMBnxuTdio3n M+ASexPnDUvo6TeIfiFcuwW62Q3SK6jaucPluU2mKvkkP9K59uH/69JIllDYTQKW6wtBa8HrHu pwv9BrOvWuUci8oqYKVfNFvAnO1ruSJoMl9TJpnkbxMU+5LeSYH3bkL5yFWWUT5uG/L3iRzdky VOo3ANldjD3FjdAmbfP073aShFZvtUruWjnlAMAjXn96DCpUGaQSyRrTnrgGCopvFwfqeQ5NwH tt4= From: Jiada Wang To: , , , , , CC: , , , , Subject: [PATCH v9 37/55] Input: atmel_mxt_ts - Change call-points of mxt_free_* functions Date: Wed, 25 Mar 2020 06:33:16 -0700 Message-ID: <20200325133334.19346-38-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200325133334.19346-1-jiada_wang@mentor.com> References: <20200325133334.19346-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Kautuk Consul Revamping the code to call mxt_free_object_table and mxt_free_input_device functions only in the following scenarios and code paths: 1) The error path of the mxt_probe() entry point 2) The mxt_remove de-init path entry point 3) All paths which definitely expect to populate the object table like: - the mxt_update_fw_store path which first calls mxt_load_fw and then resorts to calling mxt_initialize itself. - the mxt_read_info_block function which attempts to fill in the object table itself as the main non-error part of the logic. 4) All paths in the code expected to definitely allocate and register the input device such as: - the mxt_update_fw_store path which first calls mxt_load_fw and then resorts to calling mxt_initialize itself. - the mxt_update_cfg_store function which will call mxt_configure_objects. Signed-off-by: Kautuk Consul Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 36a87d9b9c83..860e8ddd4c6b 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3336,21 +3336,21 @@ static int mxt_configure_objects(struct mxt_data *data, error = mxt_init_t7_power_cfg(data); if (error) { dev_err(dev, "Failed to initialize power cfg\n"); - goto err_free_object_table; + return error; } if (cfg) { error = mxt_update_cfg(data, cfg); if (error) { dev_warn(dev, "Error %d updating config\n", error); - goto err_free_object_table; + return error; } } if (data->multitouch) { error = mxt_initialize_input_device(data); if (error) - goto err_free_object_table; + return error; } else { dev_warn(dev, "No touch object detected\n"); } @@ -3358,10 +3358,6 @@ static int mxt_configure_objects(struct mxt_data *data, mxt_debug_init(data); return 0; - -err_free_object_table: - mxt_free_object_table(data); - return error; } /* Configuration crc check sum is returned as hex xxxxxx */ @@ -4106,16 +4102,21 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) error = mxt_initialize(data); if (error) - return error; + goto err_free_object; error = sysfs_create_group(&client->dev.kobj, &mxt_fw_attr_group); if (error) { dev_err(&client->dev, "Failure %d creating fw sysfs group\n", error); - return error; + goto err_free_object; } return 0; + +err_free_object: + mxt_free_input_device(data); + mxt_free_object_table(data); + return error; } static int mxt_remove(struct i2c_client *client)