From: Krzysztof Kozlowski <krzk@kernel.org>
To: Chris Morgan <macroalpha82@gmail.com>
Cc: linux-rockchip@lists.infradead.org, linux-pm@vger.kernel.org,
dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
xsf@rock-chips.com, sre@kernel.org, simona@ffwll.ch,
airlied@gmail.com, tzimmermann@suse.de, mripard@kernel.org,
maarten.lankhorst@linux.intel.com, jesszhan0024@gmail.com,
neil.armstrong@linaro.org, heiko@sntech.de, conor+dt@kernel.org,
krzk+dt@kernel.org, robh@kernel.org,
Chris Morgan <macromorgan@hotmail.com>
Subject: Re: [PATCH 2/6] power: supply: sgm41542: Add SG Micro sgm41542 charger
Date: Tue, 28 Apr 2026 09:56:31 +0200 [thread overview]
Message-ID: <20260428-vivacious-fearless-monkey-fe433e@quoll> (raw)
In-Reply-To: <20260427170914.5062-3-macroalpha82@gmail.com>
On Mon, Apr 27, 2026 at 12:09:10PM -0500, Chris Morgan wrote:
> + strscpy(sgm->model_name, id->name, I2C_NAME_SIZE);
> +
> + sgm->regmap = devm_regmap_init_i2c(client, &sgm4154x_regmap_config);
> + if (IS_ERR(sgm->regmap))
> + return dev_err_probe(dev, PTR_ERR(sgm->regmap),
> + "Failed to allocate register map\n");
> +
> + i2c_set_clientdata(client, sgm);
> +
> + ret = sgm4154x_hw_chipid_detect(sgm);
> + if (ret)
> + dev_err_probe(dev, ret, "Unable to read HW ID\n");
> +
> + device_init_wakeup(dev, 1);
> +
> + if (client->irq) {
> + ret = devm_request_threaded_irq(dev, client->irq, NULL,
> + sgm4154x_irq_handler_thread,
> + IRQF_TRIGGER_FALLING |
> + IRQF_ONESHOT,
> + "sgm41542-irq", sgm);
Interrupt should be requested and enabled at the end or almost at the
end. If it is triggered now, which supply are you marking as "changed"?
Code looks at least correct in relation between interrupt and workqueue,
but it is not really obvious and thus not following established coding
practice. Practice is usually: first you allocate driver-like or
memory-like resources, then you request hardware related resources.
That's why every probe starts with devm_kzalloc(). Similarly with
workqueue, initializing power supply etc.
> + if (ret)
> + return ret;
> + enable_irq_wake(client->irq);
> + }
> +
> + ret = sgm4154x_power_supply_init(sgm, dev);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to register power supply\n");
> +
> + ret = sgm4154x_hw_init(sgm);
> + if (ret)
> + return dev_err_probe(dev, ret, "Cannot initialize the chip.\n");
> +
> + sgm->sgm_monitor_wq = alloc_ordered_workqueue("%s",
> + WQ_MEM_RECLAIM | WQ_FREEZABLE, "sgm-monitor-wq");
> + if (!sgm->sgm_monitor_wq)
> + return -EINVAL;
> +
> + ret = devm_add_action_or_reset(dev, sgm4154x_destroy_workqueue,
> + sgm->sgm_monitor_wq);
Use rather devm_alloc_ordered_workqueue().
Best regards,
Krzysztof
next prev parent reply other threads:[~2026-04-28 7:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 17:09 [PATCH 0/6] Add Anbernic RG Vita-Pro Chris Morgan
2026-04-27 17:09 ` [PATCH 1/6] dt-bindings: power: supply: sgm41542: document sgm41542 Chris Morgan
2026-04-28 7:47 ` Krzysztof Kozlowski
2026-04-28 14:09 ` Chris Morgan
2026-04-28 15:09 ` Krzysztof Kozlowski
2026-04-28 19:54 ` Chris Morgan
2026-04-27 17:09 ` [PATCH 2/6] power: supply: sgm41542: Add SG Micro sgm41542 charger Chris Morgan
2026-04-28 7:56 ` Krzysztof Kozlowski [this message]
2026-04-27 17:09 ` [PATCH 3/6] dt-bindings: display: panel: document Anbernic TD4310 panel Chris Morgan
2026-04-28 7:49 ` Krzysztof Kozlowski
2026-04-27 17:09 ` [PATCH 4/6] drm/panel: anbernic-td4310: Add RG Vita Pro panel Chris Morgan
2026-04-27 17:09 ` [PATCH 5/6] dt-bindings: arm: rockchip: Add Anbernic RG Vita-Pro Chris Morgan
2026-04-28 7:48 ` Krzysztof Kozlowski
2026-04-28 14:02 ` Chris Morgan
2026-04-27 17:09 ` [PATCH 6/6] arm64: dts: " Chris Morgan
2026-04-27 17:13 ` Chris Morgan
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=20260428-vivacious-fearless-monkey-fe433e@quoll \
--to=krzk@kernel.org \
--cc=airlied@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=heiko@sntech.de \
--cc=jesszhan0024@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=macroalpha82@gmail.com \
--cc=macromorgan@hotmail.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=sre@kernel.org \
--cc=tzimmermann@suse.de \
--cc=xsf@rock-chips.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox