Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4316536ybc; Fri, 22 Nov 2019 00:30:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxynoeoxGzT09um41+UgpzVr4AEr4IwNUOF0fzZWtRkEEWy0XqJyybeuCrJbzschZRsZohW X-Received: by 2002:a17:906:9248:: with SMTP id c8mr21173309ejx.47.1574411411372; Fri, 22 Nov 2019 00:30:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574411411; cv=none; d=google.com; s=arc-20160816; b=siPpJxKxzFcJ9XvupSqErZ2JWj1iqbEMa0FcU++m6BF/U1xjavZsSS7l8J4EAft1Gc dbLUqzEL05t8k6aezeE0KxGg+YjVELlHg2lmA6T+oDzZVIGFwJlkh4MU6HG3jlufMWzA gmbrJvJ+pnnJ31xYVAcsBSuEJ75LUUJYxplIZr92LWgwkTWtTGRV7iG7q8qg1Sp/9jkc ciozxOirQJ8kCUEuV4uOPQlvchM+UJiRnkGYgbhBniz2bVaJgq3LnovNYec7Woo/s/+6 ZVeP6IYg/AcsoliIpqJQ6ZjLoh/ns1ZPjNOTvuQb8p85FuelueZMm3DctvdP8qMvAqxT mRPg== 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=fYa6jQfXYUQ6EvW6rU7cH3m3+tF/pW07jiG6OYt6P/c=; b=xIp51oKbRbVgP5NWKAz6i5gZJ8g4ygSWaQXmL2w2vL6O7zqnENNKqZIXf3ke74vOg4 vc0M+5z5iePa74mi3Jj0An9zYGcsjR4bbdiPmyyvZkUeAuCHoHw1YXjT4Bnw2NBHu6uV nwOyw7WjA7sJPcW0bQyQ/x8hcwPNUtjpKGn7YaXdMJ0zQgYGZEbIxHFOPdV2E4sFUQPB hoZ97msyBTI6liuUxlWtjHd4CaimpVD8YqvWYJrxBytmhhDfXf4dy3WXoIIA0r+j96zk SOuBeW4N8/Cmpz0h9bxgE8UJrwR3J7zc7zUO8v/SoxDKKsAuZ+BDRexXTUDXdsqfvbDo XLrQ== 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 q6si4347000edr.194.2019.11.22.00.29.47; Fri, 22 Nov 2019 00:30:11 -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 S1727608AbfKVI0D (ORCPT + 99 others); Fri, 22 Nov 2019 03:26:03 -0500 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:62576 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727007AbfKVIZ6 (ORCPT ); Fri, 22 Nov 2019 03:25:58 -0500 IronPort-SDR: GSERgvB5Cmb10KfzY9WfM7Dkb+El5A5WPYUSB5Pq8vZbQUY31GMF6tpIu2+5rSJkwv3Wf9sM+T Bw6AGM2RfqlABpxxBfefSQyIpRshtKHNi9kgMOl/CoEXLTM+m6jtHAO1G9EpJa2m3ntm7194MU ZDM+VaPoGPMRPtX5Q3X/8jLFqxL9zzN/EpSdEtM+RLjIclZkLGSC2J0pcgdheKz6e/tBukqDJE /cFOgHQgasty3/SgWrrBiJ1SK44ZnF8yX0B98z1aHrGVrv0YN4Cf8v8WAZT/RaN0nBCE9jsJIz QTc= X-IronPort-AV: E=Sophos;i="5.69,229,1571731200"; d="scan'208";a="43457614" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 22 Nov 2019 00:25:58 -0800 IronPort-SDR: afcT+dPclJ7XnbNAcQBEKVouhsrmrrcNR1SizvifURcMGIglyvQNWSHNwqkL579z6TVAGsNoDV 7zgrTrUhFZUapZRvZFjEz0Hso0IaahWKN8nsAvWTUh8rAZv6XfvxANYzi8ajbedI2l4m+cZrf4 zS/YWGDctssG0WYR2FaGsho1TnRAv/t8l6odBhsH+fEH4FOkl0a0j02VNxvlM9qFTbhsLo5H5b gqnP68HPnm78YRZQmWoFLda97bUaCLTOtbKGQpuokGmXIS3pi92Plq0bnQec+8JMfvUdlXzWlJ AmU= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v6 31/48] Input: atmel_mxt_ts - Change call-points of mxt_free_* functions Date: Fri, 22 Nov 2019 17:23:45 +0900 Message-ID: <20191122082402.18173-32-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191122082402.18173-1-jiada_wang@mentor.com> References: <20191122082402.18173-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 54e2d5f81af9..acbba44d604c 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3339,21 +3339,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"); } @@ -3361,10 +3361,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 */ @@ -4100,16 +4096,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