mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: oliver.facklam@zuehlke.com
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Benedict von Heyl <benedict.vonheyl@zuehlke.com>,
	Mathis Foerst <mathis.foerst@zuehlke.com>,
	Michael Glettig <michael.glettig@zuehlke.com>
Subject: Re: [PATCH 2/4] usb: typec: hd3ss3220: use typec_get_fw_cap() to fill typec_cap
Date: Thu, 7 Nov 2024 16:21:00 +0200	[thread overview]
Message-ID: <ZyzMzEHA9DPMc_z9@kuha.fi.intel.com> (raw)
In-Reply-To: <20241107-usb-typec-controller-enhancements-v1-2-3886c1acced2@zuehlke.com>

Hi Oliver,

On Thu, Nov 07, 2024 at 12:43:28PM +0100, Oliver Facklam via B4 Relay wrote:
> From: Oliver Facklam <oliver.facklam@zuehlke.com>
> 
> The type, data, and prefer_role properties were previously hard-coded
> when creating the struct typec_capability.
> 
> Use typec_get_fw_cap() to populate these fields based on the
> respective fwnode properties.
> 
> Signed-off-by: Oliver Facklam <oliver.facklam@zuehlke.com>
> ---
>  drivers/usb/typec/hd3ss3220.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c
> index 56f74bf70895ca701083bde44a5bbe0b691551e1..e6e4b1871b5d805f8c367131509f4e6ec0d2b5f0 100644
> --- a/drivers/usb/typec/hd3ss3220.c
> +++ b/drivers/usb/typec/hd3ss3220.c
> @@ -259,12 +259,12 @@ static int hd3ss3220_probe(struct i2c_client *client)
>  		goto err_put_fwnode;
>  	}
>  
> -	typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE;
> +	ret = typec_get_fw_cap(&typec_cap, connector);
> +	if (ret)
> +		goto err_put_role;

You are not leaving any fallback here. Are you sure all the existing
systems supply those properties?

There is another problem. At least "data-role" property is optional,
but that will in practice make it a requirement.

I think it would be safer to use the values from the device properties
only if they are available. Otherwise simply use default values.

>  	typec_cap.driver_data = hd3ss3220;
> -	typec_cap.type = TYPEC_PORT_DRP;
> -	typec_cap.data = TYPEC_PORT_DRD;
>  	typec_cap.ops = &hd3ss3220_ops;
> -	typec_cap.fwnode = connector;
>  
>  	hd3ss3220->port = typec_register_port(&client->dev, &typec_cap);
>  	if (IS_ERR(hd3ss3220->port)) {

thanks,

-- 
heikki

  reply	other threads:[~2024-11-07 14:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 11:43 [PATCH 0/4] usb: typec: hd3ss3220: enhance driver with port type, power opmode, and role preference settings Oliver Facklam via B4 Relay
2024-11-07 11:43 ` [PATCH 1/4] usb: typec: hd3ss3220: configure advertised power opmode based on fwnode property Oliver Facklam via B4 Relay
2024-11-07 11:43 ` [PATCH 2/4] usb: typec: hd3ss3220: use typec_get_fw_cap() to fill typec_cap Oliver Facklam via B4 Relay
2024-11-07 14:21   ` Heikki Krogerus [this message]
2024-11-07 15:24     ` Facklam, Olivér
2024-11-08  8:08       ` Heikki Krogerus
2024-11-08 10:29         ` Facklam, Olivér
2024-11-07 11:43 ` [PATCH 3/4] usb: typec: hd3ss3220: support configuring port type Oliver Facklam via B4 Relay
2024-11-07 11:43 ` [PATCH 4/4] usb: typec: hd3ss3220: support configuring role preference based on fwnode property and typec_operation Oliver Facklam via B4 Relay

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=ZyzMzEHA9DPMc_z9@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=benedict.vonheyl@zuehlke.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathis.foerst@zuehlke.com \
    --cc=michael.glettig@zuehlke.com \
    --cc=oliver.facklam@zuehlke.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

all inboxes | Powered by JetHome®