Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1368586ybj; Thu, 7 May 2020 23:02:02 -0700 (PDT) X-Google-Smtp-Source: APiQypJqug2rtBCE1ll67IvXhKjjTxZ5RDmNeChmmYyQhBH7n1W2yXeGcpT3BQi19Jm9i1rgowox X-Received: by 2002:a17:906:8609:: with SMTP id o9mr511819ejx.361.1588917722255; Thu, 07 May 2020 23:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588917722; cv=none; d=google.com; s=arc-20160816; b=QR1YCJEa/na9t9cUsu9LUoamxE+yHzrqAKxEdgGPN/gA0ycDeij/Pkbos8jTFNhR85 uhZ4tJH+ZZ4AL3QG8Hog8xk28c0usVGU2nvNxddyl9BoeWhTng0xzAyinwjx4xIUC/f2 ipuvpdaWMsnvKQqU6PJsjE2u8jtTPkXQY1oP+1AWvGGyvYA3IDamOXF2CxzrDEAR76rh P+6Y8tf5EGeMQ3ZFSI37LY+n51TBt3tpML81A3yNng2lHPeGg9Z85nPIaWfpkQDNIs1e mY4p9JrJmcoPyY0NBxMpNhEl604bY578xewg/ZQ7VG4+j0lbbhOx4qq799YJ6HvPeH1s iuWA== 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=rA/KyUhjdYPjweucPB65lEk8jLNZmYDC3uMP7fx95FA=; b=alKTOIX/dRcoddyoG6agTchICKAMXHcbaBqg+3vQCLtdQf3ukCxxN56AELfD0Jcxsd /GLIx8BXETzYGoI9dVDABT9O9xrTjqiKGQY8VN8QMx3NAHRPsMp3WByiLmlM/QK3p066 wmCAuvr6yNyx8HjL5Sbw3piHDEoN6XFo71a51xZ8bt6a/OeQ5iAlf7EXMTLFfH80xx2d wnioubTSvImBjMO6IW3OlVU1V4B24oI/ETa8vIFEqzcO+darwe8Y0ZIsPWsWmqmZ7c67 klx8dDV7w2jY/0WF6D70dw737BGEsJZ/fF3AmlIrEVEyLxj5qXTW/34nsVxJUv4uFIiR n9VA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn7si491006ejc.39.2020.05.07.23.01.40; Thu, 07 May 2020 23:02:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728199AbgEHF7b (ORCPT + 99 others); Fri, 8 May 2020 01:59:31 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:22062 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726689AbgEHF73 (ORCPT ); Fri, 8 May 2020 01:59:29 -0400 IronPort-SDR: fDjjMm5weOm8Qf1YIK3TAvi++tdmFCIOfdR+KT1x/4yX0d5e8Pyk2TjT4Tn+MWP9uSQXCmeIb7 hGIgZvc/cevbDs5G7kNF/4gH7Nyqhl0FEHTOZAUL2pC2HS2J+sLCE8qf1hNr3MRY+KWGoQoS86 hFuA4krw0aUSyDQ5FbY0LGU20cAhwwPDikknqKDrxTRhIzdepULTqtFlufL6OclTV5w+IfRYKu 8PaAjSOwjlVV3JNpSLgCOqQpwMv4VfkU8RHheFrdgJpx0CBLi/p1koxzprjsvCZU4bsnJi80Pf UCE= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48589128" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 07 May 2020 21:59:28 -0800 IronPort-SDR: 7VJ5xFQXTU4nGcCbOETYIz2S58b0p4CZMF5CuPO37JlZBJVqjOf+bBDDOCv7F6bsMkMXaXn++4 iCeioDdfSQOJezwQKFnjS/rRRSOKZIDEEP15BWzoZAAvmKS6gSjbZhkQoZcXWuVUAkDH2ANncq 3LGTdQ61sfRXecmPqe2Pye9tCyFlKLqoIl8Y7PRl7dnvS9xzeHPi4B0ohd4HIoMS1bunn7sTnn yYwP/VpC3BOAdG1JDR8U+4SJ947RlZ10B8s4+Znxu2GvQ1P13ZLl9m0meXEdEZlDoLqZgy2/yV Llo= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 39/56] Input: atmel_mxt_ts - Change call-points of mxt_free_* functions Date: Thu, 7 May 2020 22:56:39 -0700 Message-ID: <20200508055656.96389-40-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-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 a92ad9a103a1..9281a574ca80 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3317,21 +3317,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"); } @@ -3339,10 +3339,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 */ @@ -4093,16 +4089,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