All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: <robh+dt@kernel.org>, <gregkh@linuxfoundation.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <devicetree@vger.kernel.org>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<amelie.delaunay@foss.st.com>, <alexandre.torgue@foss.st.com>
Subject: Re: [PATCH 2/4] usb: typec: ucsi: stm32g0: add support for stm32g0 i2c controller
Date: Tue, 28 Jun 2022 09:21:12 +0200	[thread overview]
Message-ID: <bd35eb19-cfda-4799-1ab0-0578d3c79466@foss.st.com> (raw)
In-Reply-To: <YrmtzDfFm17PFl2r@kuha.fi.intel.com>

On 6/27/22 15:17, Heikki Krogerus wrote:
> Hi,
> 
> On Fri, Jun 24, 2022 at 05:54:11PM +0200, Fabrice Gasnier wrote:
>> +static int ucsi_stm32g0_probe(struct i2c_client *client, const struct i2c_device_id *id)
>> +{
>> +	struct device *dev = &client->dev;
>> +	struct ucsi_stm32g0 *g0;
>> +	int ret;
>> +
>> +	g0 = devm_kzalloc(dev, sizeof(*g0), GFP_KERNEL);
>> +	if (!g0)
>> +		return -ENOMEM;
>> +
>> +	g0->dev = dev;
>> +	g0->client = client;
>> +	init_completion(&g0->complete);
>> +	i2c_set_clientdata(client, g0);
>> +
>> +	g0->ucsi = ucsi_create(dev, &ucsi_stm32g0_ops);
>> +	if (IS_ERR(g0->ucsi))
>> +		return PTR_ERR(g0->ucsi);
>> +
>> +	ucsi_set_drvdata(g0->ucsi, g0);
>> +
>> +	/* Request alert interrupt */
>> +	ret = request_threaded_irq(client->irq, NULL, ucsi_stm32g0_irq_handler, IRQF_ONESHOT,
>> +				   dev_name(&client->dev), g0);
>> +	if (ret) {
>> +		dev_err_probe(dev, ret, "request IRQ failed\n");
>> +		goto destroy;
>> +	}
>> +
>> +	ret = ucsi_register(g0->ucsi);
>> +	if (ret) {
>> +		dev_err_probe(dev, ret, "ucsi_register failed\n");
>> +		goto freeirq;
>> +	}
> 
> If there isn't UCSI firmware, then ucsi_register() will always safely
> fail here, right?

Hi Heikki,

Yes, in such a case, the first i2c read (UCSI_VERSION) in
ucsi_register() will return an error and safely fail here.

Thanks for reviewing,
Best Regards,
Fabrice

> 
> 
>> +	return 0;
>> +
>> +freeirq:
>> +	free_irq(client->irq, g0);
>> +destroy:
>> +	ucsi_destroy(g0->ucsi);
>> +
>> +	return ret;
>> +}
> 
> 
> thanks,
> 

  reply	other threads:[~2022-06-28  7:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24 15:54 [PATCH 0/4] usb: typec: ucsi: add support for stm32g0 Fabrice Gasnier
2022-06-24 15:54 ` [PATCH 1/4] dt-bindings: usb: typec: add bindings for stm32g0 controller Fabrice Gasnier
2022-06-24 16:16   ` Krzysztof Kozlowski
2022-06-27 14:21     ` Fabrice Gasnier
2022-06-28 10:28       ` Krzysztof Kozlowski
2022-06-28 17:01         ` Fabrice Gasnier
2022-06-29  5:54           ` Krzysztof Kozlowski
2022-07-01 10:04             ` Fabrice Gasnier
2022-07-04  7:55               ` Krzysztof Kozlowski
2022-07-04  9:08                 ` Fabrice Gasnier
2022-07-06  7:06                   ` Krzysztof Kozlowski
2022-06-24 15:54 ` [PATCH 2/4] usb: typec: ucsi: stm32g0: add support for stm32g0 i2c controller Fabrice Gasnier
2022-06-25  6:37   ` Christophe JAILLET
2022-06-27 13:17   ` Heikki Krogerus
2022-06-28  7:21     ` Fabrice Gasnier [this message]
2022-06-28  9:56       ` Heikki Krogerus
2022-06-24 15:54 ` [PATCH 3/4] usb: typec: ucsi: stm32g0: add bootloader support Fabrice Gasnier
2022-06-24 15:54 ` [PATCH 4/4] usb: typec: ucsi: stm32g0: add support for power management Fabrice Gasnier

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=bd35eb19-cfda-4799-1ab0-0578d3c79466@foss.st.com \
    --to=fabrice.gasnier@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=amelie.delaunay@foss.st.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.