From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793863870; b=Zu9jalMAt0HXjMHIyihT1hxOcfTB4VaeTuHQYQCaAuCAFY8Qo3p34+Qu/5YhGhcuNiE6 AqfeivbJ0JCD8VRECOkp9J7svC7PfS6z9qMshmZA2BFV5xYEd36eFqdDQo2ZQs33cjps2 Hmf/5DuTTRhajjglaZlY0CyLc2PO6rc12gC4VCHyAjFz8f/zHpM4THeWUKYD7koaUuBgj LU1wQRneBKMOpZIE3FxspXHVJ0JfgFVc4br5nR2T+xDs+MkxUlJLG3+komi+H4s0AxiLC qKAG6hViJnRNKt+VPc0hHdSnXQcEjJ55RQkfGNYp0TdMWP6+v4CUjnItWjOS/oD6vmA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793863870; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=2KTLKxxRm/mTERWifE6NdSkq/id0fx4CDjmOeHHWEQI=; b=GQOAHIpxQOhQ8t2L/AXO85xrtXzXZuGrF4eidYX7btGM2ke8Ps1XL71hb+WhP5F10g1N o5alaPyGbYEwz5fkpd1wdURKbFLf9LmXvGq7TiMBU/MFa+vZ4Rp4rMQUl8uRl4IqSlcne LYrk+6htFQaVv7YPTiG9vs/leCS+ufIcZUA2Sk3fkRP0lFgN0Jh+QdKylVRjyGJoUiVYV uCws42DR43u31tSHMFfTMYvN51bi7Z9iVKmu1LBHkjjpTaF8N4af0w/vRHI7hp/yxjclA irebaYh2dFy8falFDmSKy5j+PJEE6CTA7V7/JFFiw6E/OLOYp3uEbTdp/4SRCFrC3NQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--sgsatyam.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Zvod0mn1; arc=none smtp.remote-ip=209.85.215.197 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D29A3606A328 for ; Thu, 5 Nov 2026 07:31:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D29A3606A328 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sgsatyam.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Zvod0mn1 Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cc7e92f36f9so1289520a12.3 for ; Wed, 04 Nov 2026 23:31:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1793863869; x=1794468669; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=2KTLKxxRm/mTERWifE6NdSkq/id0fx4CDjmOeHHWEQI=; b=Zvod0mn1IZAlM3wRbo+lioh8nSp6PG7DU8Oy1C15e/nIWL91IVZY4G1ggBOOxOrZYO ROrpsb4YgSH+74/eMHI+YrFqa46PYlrPNknPwWjVkxd7pTkkUngGObPrEHzr8JeOIMT2 v0piVBh8DrXXH94x2ZOlquMyoRW5yYJa5/QofrUlne1K/hExnfKli1862iUYBUgS5jfw BBXEInDrsBMDiAK0mUsjw69jf6G2aRPGOqDDdc2oMp0e6L2D5pJcLQz8Bh1J9PuhbtNk jlW5Zr9oycBf8x1RhEMeCFnxhswyLdH3d4M0XTgD0leKSpEuezb3YDUFgNBCi8TyrjxN /ZcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793863869; x=1794468669; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=2KTLKxxRm/mTERWifE6NdSkq/id0fx4CDjmOeHHWEQI=; b=pdlo5otUvz0a0Zvn11ad6h1CwRAVB0L3BmDKY15a/OZMqkgBcEtEZ3uOW0nA8qQjw8 2MqelAtC7hNyRfIaC7obqOudD4sOkbdeg2FHx0bz9AlIOGGuW80taeVh83odPvSnQ/hm U79BFj66SJywyN52zpr38ozLXYKyhfrqYDzGPvv3o4m3Bqm9k8iHynTgp789HIhzA4TR Di6zPTC4ir/RA7Nywn6x2Oaq9kobiMG5k3OocylvLZHvbkziOH7BEbwPm4OSGaT2pTWY 2UWaAPx6V9a1bkfl//jqRdLoz+T2XHvYvzUIUpjUfe9AdQwBDUHQ1ciWrkjCDD0wsPpN cL0Q== X-Forwarded-Encrypted: i=1; AKwUvBzultALf84pVT+YLzt721DLnyrySvDFTDB3WXBV55GNcjy/y62o21YWfpXAV7/FkxrQs+K2TpDptz/gGKc=@vger.kernel.org X-Gm-Message-State: APuU4Z/8Mxq6LAuo3BHHzaoiUxguxPL7i8cOg04f1F2Ga+B0+lZDZpcX gwdnYR0y3ZCUCKu4LB39FNQsxqQkwjbwBHaATOyN3w3yVRnwc9laDjXfgDKBYVzkL8hahs39qVl XyTCgScFow4kPIQ== X-Received: from pgdo3-n1.prod.google.com ([2002:a05:6a02:6203:10b0:cca:c02e:bfd6]) (user=sgsatyam job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:8901:b0:3e2:99ef:ae90 with SMTP id adf61e73a8af0-3e928a0b2a1mr12244927637.53.1793863869003; Wed, 04 Nov 2026 23:31:09 -0800 (PST) Date: Thu, 5 Nov 2026 07:31:07 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Mailer: git-send-email 2.56.0.398.g882cbad275-goog Message-ID: <20261105073107.172121-1-sgsatyam@google.com> Subject: [PATCH] iio: cros_ec: Use platform sensor_num to unregister FIFO callback From: Satyam Gupta To: Jonathan Cameron Cc: David Lechner , "=?UTF-8?q?Nuno=20S=C3=A1?=" , Andy Shevchenko , Benson Leung , Guenter Roeck , Tzung-Bi Shih , Gwendal Grignou , linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" cros_ec_sensors_core_register() registers the FIFO callback for the sensor number found in the platform data. The matching cleanup action, cros_ec_sensors_core_clean(), reads the number back from st->param.info.sensor_num instead. st->param is the EC host command buffer. Drivers fill it in under cmd_lock before each command, while the cleanup action reads it without that lock. It is also set only for physical sensors. If the field holds another value when the device is unbound, the cleanup clears the wrong slot and leaves the callback in place, still pointing to the iio_dev that is about to be freed. Use the platform data in the cleanup action too, so it always unregisters the slot that cros_ec_sensors_core_register() registered. Signed-off-by: Satyam Gupta --- Tested on an Android desktop device (6.18, Intel) with two accelerometers and a lid angle sensor: each sensor was unbound and bound 20 times while a reader kept EC commands in flight, then FIFO samples were streamed. Also tested on a ChromeOS device (6.6) with an RGB light sensor, together with downstream changes to that driver. drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c index d03e40c91582..4d019132cd78 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c @@ -216,11 +216,11 @@ static void cros_ec_sensors_core_clean(void *arg) struct platform_device *pdev = (struct platform_device *)arg; struct cros_ec_sensorhub *sensor_hub = dev_get_drvdata(pdev->dev.parent); - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - struct cros_ec_sensors_core_state *st = iio_priv(indio_dev); - u8 sensor_num = st->param.info.sensor_num; + struct cros_ec_sensor_platform *sensor_platform = + dev_get_platdata(&pdev->dev); - cros_ec_sensorhub_unregister_push_data(sensor_hub, sensor_num); + cros_ec_sensorhub_unregister_push_data(sensor_hub, + sensor_platform->sensor_num); } /** -- 2.56.0.398.g882cbad275-goog