From: "Sascha Hauer" <s.hauer@pengutronix.de>
To: "Giandomenico Rossi" <rossi@amelchem.com>
Cc: barebox@lists.infradead.org,
"Giandomenico Rossi" <rossi@amelchem.com>,
"Nicola Fontana" <ntd@entidi.it>
Subject: Re: [PATCH 2/4] usb: typec: stusb4500: add USB PD fixed supply driver
Date: Tue, 17 Nov 2026 11:27:56 +0000 [thread overview]
Message-ID: <971f258e-bd09-4523-861d-39090f62f00a@pengutronix.de> (raw)
In-Reply-To: <20261114161953.1457428-3-rossi@amelchem.com>
Hi Giandomenico,
On 2026-11-14 17:19, Giandomenico Rossi wrote:
> +
> +#include <common.h>
> +#include <init.h>
> +#include <driver.h>
> +#include <i2c/i2c.h>
> +#include <of.h>
> +#include <linux/err.h>
> +#include <linux/regmap.h>
> +#include <linux/bitfield.h>
> +#include <dt-bindings/usb/pd.h>
> +#include <asm/unaligned.h>
> +#include <linux/usb/typec.h>
> +#include <linux/usb/typec_altmode.h>
> +#include <linux/mutex.h>
> +#include <command.h>
> +#include <getopt.h>
> +#include <usb/stusb4500.h>
Please trim the inclusions. At least common.h, command.h and getopt.h
shouldn't be needed here.
> +
> +static int stusb4500_typec_register(struct stusb4500 *stusb,
> + struct device_node *connector)
> +{
> + stusb->cap.driver_data = stusb;
> + stusb->cap.ops = &stusb4500_typec_ops;
> + stusb->cap.of_node = connector;
> +
> + stusb->port = typec_register_port(stusb->dev, &stusb->cap);
We don't have typec_unregister_port() in barebox. This means you will
have a dangling port registered when you error out from probe after this
point.
Either add typec_unregister_port() and call it if you error out with a
registered port, or re-order the probe order to call
typec_register_port() as last step.
> +
> +static int stusb4500_probe(struct device *dev)
> +{
> + struct i2c_client *client = to_i2c_client(dev);
> + struct regmap_config config = {
> + .reg_bits = STUSB4500_REGSIZE,
> + .val_bits = STUSB4500_REGSIZE,
> + .max_register = STUSB4500_RDO_REG_STATUS + 3,
> + };
Should be const.
> + struct stusb4500_contract contract = {};
> + struct stusb4500 *stusb;
> + int ret;
> +
> + stusb = xzalloc(sizeof(*stusb));
> + stusb->dev = dev;
> +
> + ret = stusb4500_register(stusb);
> + if (ret)
> + goto err_free;
The probe order is strange, you register with the framework before
initializing the register map. Should be the other way round.
> +
> + stusb->map = regmap_init_i2c(client, &config);
> + if (IS_ERR(stusb->map)) {
> + ret = PTR_ERR(stusb->map);
> + goto err_free;
> + }
> +
> + ret = stusb4500_init(stusb);
> + if (ret)
> + goto err_regmap;
> +
> + dev->priv = stusb;
> +
> + ret = stusb4500_update_sink_pdos(stusb);
> + if (ret)
> + goto err_regmap;
> +
> + if (of_property_read_bool(dev->of_node, "st,renegotiate-on-probe")) {
> + ret = stusb4500_renegotiate(stusb);
> + if (ret < 0)
> + goto err_regmap;
> + }
> +
> + ret = stusb4500_read_contract(stusb, &contract);
> + if (ret)
> + goto err_regmap;
The data returned in &contract is not used. What is this call good for?
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2026-11-17 11:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 16:19 [PATCH 0/4] usb: typec: add STUSB4500 USB-C PD sink support Giandomenico Rossi
2026-11-14 16:19 ` [PATCH 1/4] usb: typec: add typec_port_from_device() Giandomenico Rossi
2026-11-14 16:19 ` [PATCH 2/4] usb: typec: stusb4500: add USB PD fixed supply driver Giandomenico Rossi
2026-11-17 11:27 ` Sascha Hauer [this message]
2026-11-14 16:19 ` [PATCH 3/4] dt-bindings: usb: add STUSB4500 USB PD sink controller binding Giandomenico Rossi
2026-11-14 16:19 ` [PATCH 4/4] commands: stusb4500: add USB-C PD control command Giandomenico Rossi
2026-11-17 11:46 ` Sascha Hauer
2026-11-17 13:12 ` Giandomenico Rossi
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=971f258e-bd09-4523-861d-39090f62f00a@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=ntd@entidi.it \
--cc=rossi@amelchem.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