Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5827217ybv; Wed, 12 Feb 2020 00:47:07 -0800 (PST) X-Google-Smtp-Source: APXvYqyoXMfImwEwt4LXOX13l/2FwOA89MI9Czbw+yQOPmBS2MJTOgre2m0mW+go14aX1kRdTZ5U X-Received: by 2002:a9d:7f16:: with SMTP id j22mr8380668otq.256.1581497227167; Wed, 12 Feb 2020 00:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581497227; cv=none; d=google.com; s=arc-20160816; b=enLvXVJkEEcw6iKnUVfSN5skOp+hMCgnVhUmJy3NWN5FqVccqWGqYsgGX/HlCqlmhi T5OuGAUhTvlisuxzopEqhZ1dKfrDku2QdgrqhwBEYz6YIP8FItFJ4wMKBd1Le7FCT+TR BMjT+TJPoLo9hEj3kOUJLzC/Ag1GOFlluaQQlDMaaW21z1BJIIHULY4EFC+L/7R1zHO0 ZKgxDbfinU+Xk8tE2e7EGL01/5qESLUBNJusYUFKm6i2aQryEs9SK0CJv5WsRTiid1VN VBaE0ZVS+NUYnDOmA3lTUFivgWOs5HLLHc6zLCaJOzuJkxGJvtmE0LDWUfzoivv2esMJ k1fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=qhgPMEVlD6j/F42u1GuEaI9DQi6AKBHWI3s89MMZIvI=; b=PqbsHE5BxaU60VNA3lYuQdyDzwxqjhGIbmx7xqWdAGAK92N7cwz2oOQRvan9ZpUXv2 3sb0aySE+OMl6rvICKxn632SBwbQkcRQoNH62Jxxa8haZJFz00bLO2FeCIrVi0lRTujj eY4KyZkYBJxGVKSe26WvSjRzHCXuK0RR92kOIHdo2bw6EZFLSkCPzGG4CtV9ZwUd7k+n QYBA99rsyCAQzL7EGOguAvfHsCR4dwf8h4I5ChKHMSn07y9uRkWx1M/RUohgqE52nfb6 d+MTSNbXptU3u6eGbOHIXQDXQb2IVQIh4krkfrSVVzStRoHKWYawGXP7URqDVJqsG+Jv t+cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a22si2902117oii.98.2020.02.12.00.46.55; Wed, 12 Feb 2020 00:47:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728775AbgBLIqQ (ORCPT + 99 others); Wed, 12 Feb 2020 03:46:16 -0500 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:64389 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728519AbgBLIqP (ORCPT ); Wed, 12 Feb 2020 03:46:15 -0500 IronPort-SDR: CtuHyuxn7R+bKRAuJpxaoIw8Orjvo8ZSOYM/5YBICdNyeoKQqC8oAqylajISZwT46RysxX7Scd zdJB0+q3Xa2Z66MGDjWiBxJavYWg2qiMPGG7sFxOVGgjvF0viO2nd4eeJilj6zhu30Jx+aQueD Uror4JRHvVPKDdUpLg9ZYBRMcdb2/4BRamL6RIh8tmxkjO5sU+aDBXzwCsJMbsey8pjKeAYygO SKtuJcpeqOWveJGz9Ft15ExJ4dG0GwOF7npb72HcLM4/AilQft1bHTqP0L0u1PYQtEqwYV3cuN xPg= X-IronPort-AV: E=Sophos;i="5.70,428,1574150400"; d="scan'208";a="47667075" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 12 Feb 2020 00:46:14 -0800 IronPort-SDR: 9dAan7zc/5AO2pjZ+RJSx5nIRUw5r/JI2xhQmxPg0J8PPiAtDv1dT6VdpPY0DE8k+x5SVo5YDe HApuB29wIOHaxWpFD/dIxw47Umh4LaP6Wz8jSX2dp+CNBjuKLVOtnupFvcRviozndDt2H9lBCT s9DXCxPCp9ETB6bhalOSz9uaEkAkhq3NEGGvJxAZw3jDQaLLKkTYO/BJVLScCzEZfDJd23Yv8W WyQgMy5iB0w9ojNfcTZxaWp6LyAIJJf1mf11NxvXBLfJFMGIvVkSbnTiR5CHsvwtUWYx4LDCph QoI= From: Jiada Wang To: , , , , , CC: , , , , Subject: [PATCH v7 31/48] Input: atmel_mxt_ts - Change call-points of mxt_free_* functions Date: Wed, 12 Feb 2020 00:42:01 -0800 Message-ID: <20200212084218.32344-32-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200212084218.32344-1-jiada_wang@mentor.com> References: <20200212084218.32344-1-jiada_wang@mentor.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 a64793281ae8..7316a7613041 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 */ @@ -4097,16 +4093,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) -- 2.17.1