All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: mario.limonciello@amd.com, basavaraj.natikar@amd.com,
	jikos@kernel.org, bentiss@kernel.org
Cc: Basavaraj Natikar <Basavaraj.Natikar@amd.com>,
	linux-input@vger.kernel.org
Subject: [PATCH v2 2/2] HID: amd_sfh: Cleanup all sensors when init fails
Date: Thu,  3 Apr 2025 09:59:23 -0500	[thread overview]
Message-ID: <20250403150026.1657538-3-superm1@kernel.org> (raw)
In-Reply-To: <20250403150026.1657538-1-superm1@kernel.org>

From: Mario Limonciello <mario.limonciello@amd.com>

If any sensors have been started when a failure occurs during client
init they are left enabled by the firmware.

As part of the cleanup routine check all sensors and if they're enabled
stop them.

Suggested-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v2:
 * New patch
---
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
index c1bdf1e0d44af..c61cc42fa7a33 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
@@ -235,12 +235,20 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
 	return 0;
 
 cleanup:
-	amd_sfh_hid_client_deinit(privdata);
 	for (i = 0; i < cl_data->num_hid_devices; i++) {
+		if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
+			mp2_ops->stop(privdata, cl_data->sensor_idx[i]);
+			status = amd_sfh_wait_for_response
+					(privdata, cl_data->sensor_idx[i], DISABLE_SENSOR);
+			cl_data->sensor_sts[i] = (status == 0) ? SENSOR_ENABLED : SENSOR_DISABLED;
+		}
+		if (cl_data->sensor_idx[i] == SRA_IDX)
+			continue;
 		devm_kfree(dev, cl_data->feature_report[i]);
 		devm_kfree(dev, in_data->input_report[i]);
 		devm_kfree(dev, cl_data->report_descr[i]);
 	}
+	amd_sfh_hid_client_deinit(privdata);
 	return rc;
 }
 
-- 
2.43.0


  parent reply	other threads:[~2025-04-03 15:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03 14:59 [PATCH v2 0/2] Fixes for SRA sensor handling Mario Limonciello
2025-04-03 14:59 ` [PATCH v2 1/2] HID: amd_sfh: Fix SRA sensor when it's the only sensor Mario Limonciello
2025-04-03 14:59 ` Mario Limonciello [this message]
2025-04-07  9:22   ` [PATCH v2 2/2] HID: amd_sfh: Cleanup all sensors when init fails Basavaraj Natikar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250403150026.1657538-3-superm1@kernel.org \
    --to=superm1@kernel.org \
    --cc=basavaraj.natikar@amd.com \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.