From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (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 E9F90322B69 for ; Wed, 14 Jan 2026 10:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768385986; cv=none; b=aswGiMDELmWW6v5TvtaNFXPyjXsI9M4fNe2+0Pq07Z22qQ9lS8JrPB9iZrCClEUYu9fKv3TuP/bJYAvvF9z7fxALJb7H7PaVHi4Ra7nRSfecQG54alovFTN8SzXPqzttTJRf+LWczAAay9KH4gWPm8QiiQfgPLgjUAv1tBZCNPU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768385986; c=relaxed/simple; bh=8eibjd2N5XiVRRI4N4yeokngezFp8SvzkItH6b1iECM=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=g/qs139s6NpwE6Kdidl9Du7p5sFH/6sPIXK4z8eKVvZrJU3xWgvr1i4jIB++aBiJQnegVLLF0X3QXsHH0lnpYjlwNBb95RiG1JgaD8PsyJizLJjKmHWLz07yGC5R6CQZv85osQZjiD87Mw+cqvKA7A5bApGGQSH1BIVkJ6HynPc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=UC6xqira; arc=none smtp.client-ip=74.125.82.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UC6xqira" Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-2b04a410f42so7631404eec.0 for ; Wed, 14 Jan 2026 02:19:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1768385984; x=1768990784; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=8eibjd2N5XiVRRI4N4yeokngezFp8SvzkItH6b1iECM=; b=UC6xqirahJ9gIyGufYimhxLA6Qge3YzR1jHRVEXuZM51fue2fvFOv8G5b9KYJ5bO4c BPx99f6iUwAgMmT6Ng9+Dflyc3QW/gdhkF0Tuly113EhLxRKFOkI/cEpN5Ioq5OFqKNq rQfAk0MDMTpXeQSJGQ7ZNZUR2BPm1M5jWhPoRKO2TUGNR8g1EprTBwT1g+GiB2wZF0AG /LyJjIhtaNqplsPIQVsadRu/wBFgTaIvyJf+LbzedsazhGGn4Ap8caKW4ch6eYC65zkk xDKNyBoqfhT1Kb3hXv5BIIdqqeoNNz1Bx4pMljmJtgqyGVE41J0E1qyvGF7X6qvaGW9D DFhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768385984; x=1768990784; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8eibjd2N5XiVRRI4N4yeokngezFp8SvzkItH6b1iECM=; b=oorUbjn9p3/13sW4GSaXP8u5H6opau3mc4pbIw2wze7EaxmhH/a33Zij+K/rcbiCfz UGUd7Yf+PXDmJS1gvKRTDpuSl1KMkL3l2FwFc61bLlZLHJkda+oidDcKTyqdnnCBxKCD kUSQy0ChQHoO/xFcAT9O2bHegHwhxXWNpYNj+L+0KabPiuD7v+bIzszOkMdZ1C42Uvlu XGIyjIyNTsU48LOHv6CKUkESGv7VOU2a3CBzbe8UTce/5llLT5cz9FiC4ADoAWTcN17n LRQyXeMGrnpzHOcHsyFYgK5AgCIfEGM5quq+Vqw0ASJF2MJQldyEH/KmNpW3yBjoWP4K jAAg== X-Gm-Message-State: AOJu0YwrrjhgAaJLZ2CeS+ioCYx8TXYAumGS8RZ8413NeXnzatT0KrBf 3MuHcRs5IWyg7iSZiYOatxbaKGJ2+SjJ7eVY8eYDmjgrnGOos5YG0OFAhO8xh0+6Shg= X-Gm-Gg: AY/fxX5/0sGo0/gnEhf2zeLSSLKQU/qTEbspLyLtaaARwlcMtMf1IRYnotpg9tlY0eH +KsuNyEs6KD2kn8c+rFhP6rJWZJppS1JyJbXkhmH1Cr/Vf382RNgz3mMgqk8otuD6EDYAJLbA6c 7/Xvy1lXnuF3YyrFWTmOWugA2SsUTkx7b+T3E8RVcr8+tHI3A7TIQF3tYjnQVB25K79tVH6y/v6 ps9h57A+gKsnNKGtAhw811c3swNmaZZ13LtZZ/XVHSV3osKmwnXgt07wqBUixrHLkIMT+oEVp9E +PDWYunTQRec/6tchkXBgudyQ6czl+tCKYnuyu9HQACXGh1UP5P+1qhpSNgyCxU/4idnefXAlHK kRgOfxgyaSlVjumKQosRM7DULYWsizn7oOm3NzcZsxqfp8obUQ+w09WxcINAtri9vrlOpzkOxfI E/+9z+roN2+66OjIH7 X-Received: by 2002:a05:693c:3008:b0:2a4:3593:ddf3 with SMTP id 5a478bee46e88-2b4871d0cc3mr3162205eec.32.1768385983766; Wed, 14 Jan 2026 02:19:43 -0800 (PST) Received: from draszik.lan ([212.129.75.26]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b170673b2esm19824293eec.6.2026.01.14.02.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 02:19:42 -0800 (PST) Message-ID: <48d52ef389ee0e878c36184efbfaa85071f5549a.camel@linaro.org> Subject: Re: [PATCH v3 4/5] power: supply: max77759: add charger driver From: =?ISO-8859-1?Q?Andr=E9?= Draszik To: Amit Sunil Dhamne , Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Greg Kroah-Hartman , Badhri Jagan Sridharan , Heikki Krogerus , Peter Griffin , Tudor Ambarus , Alim Akhtar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, RD Babiera , Kyle Tso Date: Wed, 14 Jan 2026 10:20:17 +0000 In-Reply-To: <378ee786-2b44-44e7-a3f6-0cd1db3c0481@google.com> References: <20251227-max77759-charger-v3-0-54e664f5ca92@google.com> <20251227-max77759-charger-v3-4-54e664f5ca92@google.com> <298ca35590d2180fdcf334f94964b6110e17c606.camel@linaro.org> <50c29a62-1fdb-4de2-8887-0d551eee5ec0@google.com> <255d7726-6758-43ed-b35f-db14726bcc9b@google.com> <2869d309358f27652289c40810ca36b2ec155d1d.camel@linaro.org> <6b37b88e9b7ee57eb1c006916fd995c813ab5e6e.camel@linaro.org> <378ee786-2b44-44e7-a3f6-0cd1db3c0481@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-2+build3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2026-01-13 at 16:47 -0800, Amit Sunil Dhamne wrote: > Hi Andre', >=20 > On 1/13/26 2:02 AM, Andr=C3=A9 Draszik wrote: > > Hi Amit, > >=20 > > On Mon, 2026-01-12 at 11:37 -0800, Amit Sunil Dhamne wrote: > > > Hi Andre', > > >=20 > > > On 1/12/26 5:47 AM, Andr=C3=A9 Draszik wrote: > > > > Hi Amit, > > > >=20 > > > > On Tue, 2026-01-06 at 17:14 -0800, Amit Sunil Dhamne wrote: > > > > > On 1/6/26 3:41 PM, Amit Sunil Dhamne wrote: > > > > > > Hi Andre', > > > > > >=20 > > > > > > On 1/5/26 9:32 AM, Andr=C3=A9 Draszik wrote: > > > > > > > Hi Amit, > > > > > > >=20 > > > > > > > I haven't done a full review, but a few things caught my eye. > > > > > > >=20 > > > > > > > On Sat, 2025-12-27 at 00:04 +0000, Amit Sunil Dhamne via B4 R= elay wrote: > > > > > > > > diff --git a/drivers/power/supply/Makefile > > > > > > > > b/drivers/power/supply/Makefile > > > > > > > > index 4b79d5abc49a..6af905875ad5 100644 > > > > > > > > --- a/drivers/power/supply/Makefile > > > > > > > > +++ b/drivers/power/supply/Makefile > > > > > > > > [...] > > > > > > > > + > > > > > > > > +static irqreturn_t irq_handler(int irq, void *data) > > > > > > > > +{ > > > > > > > > +=C2=A0=C2=A0=C2=A0 struct max77759_charger *chg =3D data; > > > > > > > > +=C2=A0=C2=A0=C2=A0 struct device *dev =3D chg->dev; > > > > > > > > +=C2=A0=C2=A0=C2=A0 u32 chgint_ok; > > > > > > > > +=C2=A0=C2=A0=C2=A0 int i; > > > > > > > > + > > > > > > > > +=C2=A0=C2=A0=C2=A0 regmap_read(chg->regmap, MAX77759_CHGR_= REG_CHG_INT_OK, > > > > > > > > &chgint_ok); > > > > > > > You might want to check the return value and return IRQ_NONE = if it > > > > > > > didn't > > > > > > > work? > > > > > > >=20 > > > > > > > > + > > > > > > > > +=C2=A0=C2=A0=C2=A0 for (i =3D 0; i < ARRAY_SIZE(irqs); i++= ) { > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (irqs[i] =3D= =3D irq) > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 break; > > > > > > > > +=C2=A0=C2=A0=C2=A0 } > > > > > > > > + > > > > > > > > +=C2=A0=C2=A0=C2=A0 switch (i) { > > > > > > > > +=C2=A0=C2=A0=C2=A0 case AICL: > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_dbg(dev, "A= ICL mode: %s", > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 str_no_yes(chgint_ok & MAX77759_CHGR_REG_CHG_INT_AICL)); > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > > > > > > +=C2=A0=C2=A0=C2=A0 case CHGIN: > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_dbg(dev, "C= HGIN input valid: %s", > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 str_yes_no(chgint_ok & MAX77759_CHGR_REG_CHG_INT_CHGIN)); > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > > > > > > +=C2=A0=C2=A0=C2=A0 case CHG: > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_dbg(dev, "C= HG status okay/off: %s", > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 str_yes_no(chgint_ok & MAX77759_CHGR_REG_CHG_INT_CHG)); > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > > > > > > +=C2=A0=C2=A0=C2=A0 case INLIM: > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_dbg(dev, "C= urrent Limit reached: %s", > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 str_no_yes(chgint_ok & MAX77759_CHGR_REG_CHG_INT_INLIM)); > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > > > > > > +=C2=A0=C2=A0=C2=A0 case BAT_OILO: > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_dbg(dev, "B= attery over-current threshold crossed"); > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > > > > > > +=C2=A0=C2=A0=C2=A0 case CHG_STA_CC: > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_dbg(dev, "C= harger reached CC stage"); > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > > > > > > +=C2=A0=C2=A0=C2=A0 case CHG_STA_CV: > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_dbg(dev, "C= harger reached CV stage"); > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > > > > > > +=C2=A0=C2=A0=C2=A0 case CHG_STA_TO: > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_dbg(dev, "C= harger reached TO stage"); > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > > > > > > +=C2=A0=C2=A0=C2=A0 case CHG_STA_DONE: > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_dbg(dev, "C= harger reached TO stage"); > > > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > > > > > Are the above debug messages really all needed? > > > > > I forgot to respond to this comment in my previous email. > > > > >=20 > > > > > I think we can keep AICL, BAT_OILO, INLIM. They're either special > > > > > conditions (AICL) or faulty conditions (like BAT_OILO) and we can= in > > > > > fact keep them at dev_info level. Rest can be removed and a > > > > > power_supply_changed() is sufficient. > > > > >=20 > > > > > Let me know what you think? > > > > I don't think dev_info() in an interrupt handler is appropriate. At > > > > least it should be ratelimited. > > > >=20 > > > > If it's something special / unexpected that needs attention, having > > > > a dev_dbg() message only will usually not be visible to anybody. > > > I agree. I can change the prints to dev_info_ratelimited for the stuf= f > > > we care about. > > If it's an erroneous condition, maybe warn or even err are more appropr= iate? > >=20 > > But then, what is the expectation upon the user observing these message= s? > > What can or should they do? Who is going to look at these and can do > > something sensible based on them? >=20 > The logging will help in postmortem analysis which may or may not=20 > possible with just publishing uevents to userspace hoping that they log= =20 > the psy properties. Illustrating a situation: >=20 > 1. Over current situation happened where the Battery to System current= =20 > exceeds the BAT_OILO threshold. This would also generate an interrupt. >=20 > 2. The MAX77759 takes protective measures if the condition lasts for a= =20 > certain specified time and reset. Resetting will cause Vsys to collapse= =20 > to 0 if the system is only battery powered. >=20 > 3. It'd be better that the BAT_OILO interrupt is logged in dmesg,=20 > instead of just delegating it to user space as user can debug this=20 > condition by looking at last_kmsg or pstore. >=20 > 4. This signal can help the user debug conditions such as moisture (this= =20 > signal + contaminant detection) or indicative of a mechanical failure. >=20 > I do agree though that this is a hypothetical or very rare situation and= =20 > if you have a strong opinion against this I am okay with removing the=20 > prints completely. Thanks for details. OK, they sound useful in this case, but should still be warn, not dbg. > > >=20 >=20 >=20 > >=20 > > Also, I just noticed there is a max77705 charger driver. It seems quite > > similar to this one, maybe it can be leveraged / extended? >=20 > Thanks for the feedback. I reviewed the max77705 charger driver. . >=20 > Here is a breakdown of why I believe a separate driver may be a better= =20 > approach: [...] Thanks for the analysis, I agree with your conclusion. Mainly I noticed tha= t as part of AICL interrupt handling that driver does a bit of work, while he= re we don't. I am wondering if that is applicable here is well. Cheers, Andre'