mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: "Facklam, Olivér" <oliver.facklam@zuehlke.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"von Heyl, Benedict" <benedict.vonheyl@zuehlke.com>,
	"Först, Mathis" <mathis.foerst@zuehlke.com>,
	"Glettig, Michael" <Michael.Glettig@zuehlke.com>
Subject: Re: [PATCH 2/4] usb: typec: hd3ss3220: use typec_get_fw_cap() to fill typec_cap
Date: Fri, 8 Nov 2024 10:08:09 +0200	[thread overview]
Message-ID: <Zy3G6dyvvpU4A6NO@kuha.fi.intel.com> (raw)
In-Reply-To: <ZR1P278MB102298AE3011962AEE1BC91E9F5C2@ZR1P278MB1022.CHEP278.PROD.OUTLOOK.COM>

On Thu, Nov 07, 2024 at 03:24:44PM +0000, Facklam, Olivér wrote:
> Hello Heikki,
> 
> > -----Original Message-----
> > From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Sent: Thursday, November 7, 2024 3:21 PM
> > To: Facklam, Olivér <oliver.facklam@zuehlke.com>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>; linux-
> > usb@vger.kernel.org; linux-kernel@vger.kernel.org; von Heyl, Benedict
> > <benedict.vonheyl@zuehlke.com>; Först, Mathis
> > <mathis.foerst@zuehlke.com>; Glettig, Michael
> > <Michael.Glettig@zuehlke.com>
> > Subject: Re: [PATCH 2/4] usb: typec: hd3ss3220: use typec_get_fw_cap() to fill
> > typec_cap
> > 
> > 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..e6e4b1871b5d805f8c3671
> > 31509f
> > > 4e6ec0d2b5f0 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 missed that typec_get_fw_cap() was not setting a default if the property is absent.
> 
> > 
> > I think it would be safer to use the values from the device properties only if
> > they are available. Otherwise simply use default values.
> 
> I'll add back the previous values as defaults before calling typec_get_fw_cap().
> That will make data-role and try-power-role optional again, as intended.
> 
> However, "power-role" seems to be required by the function. Is this expected?

Yes.

> Or should I write my own fwnode parsing logic?

No, don't do that.

You can check the return value. If it's -EINVAL or -ENXIO, the
properties are not there, and you can safely use the defaults.
Otherwise, consider the failure as critical.

thanks,

-- 
heikki

  reply	other threads:[~2024-11-08  8:08 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
2024-11-07 15:24     ` Facklam, Olivér
2024-11-08  8:08       ` Heikki Krogerus [this message]
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=Zy3G6dyvvpU4A6NO@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=Michael.Glettig@zuehlke.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=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®