From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B53C31F9BB for ; Wed, 11 Mar 2026 00:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773188498; cv=none; b=CZhVv/KOr9pN7QAQjSd88rK95B4Q//EieUHk4ygMdO8cAiSNvVmQq91qWjglZx4dPQzOLJZkHZbciofON6z442EDAK+/YPnpcj4NbPev0RrG3EBeCBkH4aZJVclxfEnmxNiARz7Xmj30PyyjEe04JeNkeAyO3qAPn9r2bSMfi1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773188498; c=relaxed/simple; bh=6FSfGjfEA7I/CqRKQXRkk4AHYuVTpiF3UrEghTud5sY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rlVR9F3HbP8Bsmkzcb6QOjo3tUg3syln01GorOSo4DcaV6liZY0xVIY+EDDq1eG+uIFSCfj0thRBdDmciE6d86mT3u8Lc7wATuE3DITFjutu19Ldz9eJWpHjmHSx0qV7g56SmJUJT1Stwr8Gt3X3lWInPPl1Lqsmjpo26V6bOu8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NdalJYfv; arc=none smtp.client-ip=74.125.82.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NdalJYfv" Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-2be26d11b95so13093905eec.0 for ; Tue, 10 Mar 2026 17:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773188495; x=1773793295; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=KZ1q6EFUHntWG4ZxMjM+nzdLiPNGdE6ZpSx+iizQ7CU=; b=NdalJYfv582qiyEDEi4EvAFTtEySq8+0oJ1q1s4QYBekSCOgBQp6ovSi27SJhXVP+3 RGIemkrP2T1ZPXJGFeCcCmvIlbID97JxErebvw2RNUE9aNGdLx1yNDwSeUoRrXrbzkE4 XgudbaA++ndxSwcBm8XwQTABFwZHCqSCCpZpvGuPLumVSCOjI1yeOPTv8+XwnEnanCj+ REznyaSDYkDjDdkngc36wEayMDdf9t2S1130QAt4GQ2HDFyIHtGXWjjdEtDUiN1FJI3h aaJhQR0/zxVhhyRrMicqCkV2+X9Blq8EgvwUMfVYZMNVtthy7MlSFxS4LAuFPvX37S6r e2MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773188495; x=1773793295; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KZ1q6EFUHntWG4ZxMjM+nzdLiPNGdE6ZpSx+iizQ7CU=; b=ww++JEDdodOyTEfbygLz+IvC5MGq4bqGRNyMzSiY42bNKfiXV8pBrVAMGZ12otXv1n be604P2Kgpjyz/yGjFyHpH61TyPe/ye8XGQARgkaz9hFK2i4tb6sPJh/b5U1fDK25JHv 180si5ZaTBMjwDrF0MC3nj3RPiWws2ZkV69DA6n7vTnecUssSBydUCZ1jObmXtCGnaRA FE9/1QDLWFoUjWmPZIwTQW9AKEKLT9AbdWev8xrAJAoFlc/blHgAytH7ta3ttbKvK6o6 cJDtmlOiIlTo1tvvU+HcPHlkSHyD2H23lnLhCTfM7b/rMnEnikCE2ZRCy8Eos05YGr5q E85g== X-Forwarded-Encrypted: i=1; AJvYcCUsn87NgOhzsnki7CW06SXKaz6LFUOYusczEsGNNMT5w+J3ghTWTkc/d8XV4incmlXuu6LchkSyrqOTDnU=@vger.kernel.org X-Gm-Message-State: AOJu0YykEkiGtDqRBTIkL2E1452MYRKt0DFgPZGhSnJCN/OVjnYP/Kyz Cl3SE7BG3TguMDeGsmjoQGxCfKc8/Md2u9VYTRBVHd79pi6Df8v+yj6s X-Gm-Gg: ATEYQzy8G54qW3KF8Y4C+iHPrWjixeGJ7N9CmjGsrMEtKRiXlKQjU1xjbCHZfjk0Cvm JuBFUuJE8kPkx2WTxSjHeMU+1casIvhCKiIx7xE8dtjCdWNzFcH93cHD8RPpXQAve4P0hOez8QP qzRgCw2OlPnUflL4UrGAMxmbb5W6x+BN9GXVk2kfo/Z1fIstz2s7hQvKKy9DPdmKmzviaaIRzV2 46j/vU7Kiwi/0sdmJkBD9cG1M+RYZl3EcjB5nfBwWtnefO2sigiIRuFBOFXagh4T06nzu/KpmjK UkYpa44zWBWY+RmnByRr7RiDuo++UImUu641Nod9xRfxlYZIq/FV8V+wv3TUdacJ2kruvVtL7cO ZLFLp8pJxAGTLFuU7nL4uRDvPoIcHUXtl1QCdWxAcwBhzAIg8xH0+IPBP967qqsaB2QrOspVsjN lX0A5LSxhGeEzBLWFwp+RehrBdS8EJdRJDQuo2HpKTjbjfJPZMp2jL0xj/D2cTdHse X-Received: by 2002:a05:7300:a59a:b0:2b7:24fc:f638 with SMTP id 5a478bee46e88-2be8a0f188fmr385401eec.0.1773188494956; Tue, 10 Mar 2026 17:21:34 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:6e17:9d84:ffa0:986b]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2be8a853840sm533327eec.8.2026.03.10.17.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2026 17:21:34 -0700 (PDT) Date: Tue, 10 Mar 2026 17:21:31 -0700 From: Dmitry Torokhov To: phucduc.bui@gmail.com Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ingo Molnar , Thomas Gleixner , Marek Vasut , Michael Welling , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C core Message-ID: References: <20260309110045.108209-1-phucduc.bui@gmail.com> <20260309110045.108209-3-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260309110045.108209-3-phucduc.bui@gmail.com> On Mon, Mar 09, 2026 at 06:00:44PM +0700, phucduc.bui@gmail.com wrote: > From: bui duc phuc > > The tsc200x driver supports both I2C (tsc2004) and SPI (tsc2005) > interfaces. > Currently, the driver attempts to manually manage the wakeup interrupt by > calling enable_irq_wake() and disable_irq_wake() during suspend and resume. > > However, for I2C devices, the I2C core already automatically handles the > wakeup source initialization and IRQ management if the "wakeup-source" > property is present in the device tree. Manually managing it again in the > driver is redundant and can lead to unbalanced IRQ wake reference counts. > > Clean up the wakeup IRQ handling by checking the bus type: > - For I2C (BUS_I2C): Rely entirely on the I2C core for wakeup management. > - For SPI (BUS_SPI): Explicitly call device_init_wakeup() in probe and > manually manage enable/disable_irq_wake() during suspend/resume. > > The ts->wake_irq_enabled flag is also updated accordingly to ensure the > driver accurately tracks the wakeup state across both buses. > > Note: This patch is based on code analysis of the I2C subsystem and > has not been verified on actual hardware yet. > > Signed-off-by: bui duc phuc > --- > drivers/input/touchscreen/tsc200x-core.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c > index eba53613b005..d14d967845c8 100644 > --- a/drivers/input/touchscreen/tsc200x-core.c > +++ b/drivers/input/touchscreen/tsc200x-core.c > @@ -465,6 +465,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, > ts->idev = input_dev; > ts->regmap = regmap; > ts->tsc200x_cmd = tsc200x_cmd; > + ts->bustype = tsc_id->bustype; > > error = device_property_read_u32(dev, "ti,x-plate-ohms", &x_plate_ohm); > ts->x_plate_ohm = error ? TSC200X_DEF_RESISTOR : x_plate_ohm; > @@ -547,8 +548,9 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, > return error; > } > > - device_init_wakeup(dev, > - device_property_read_bool(dev, "wakeup-source")); > + if (ts->bustype == BUS_SPI) > + device_init_wakeup(dev, > + device_property_read_bool(dev, "wakeup-source")); > > return 0; > } > @@ -565,8 +567,13 @@ static int tsc200x_suspend(struct device *dev) > > ts->suspended = true; > > - if (device_may_wakeup(dev)) > - ts->wake_irq_enabled = enable_irq_wake(ts->irq) == 0; > + if (device_may_wakeup(dev)) { > + if (ts->bustype == BUS_SPI) > + ts->wake_irq_enabled = enable_irq_wake(ts->irq) == 0; > + else > + ts->wake_irq_enabled = true; > + } else > + ts->wake_irq_enabled = false; Sorry, but this just makes it all worse. There is no downside from letting the driver to control wakeup if it wants to, so I'd rather leave it as it was, at least for now. Thanks. -- Dmitry