linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Alexander Shiyan <shc_work@mail.ru>
Cc: Wolfgang Grandegger <wg@grandegger.com>, linux-can@vger.kernel.org
Subject: Re: [PATCH 1/4] can: mcp251x: Check return value of spi_setup()
Date: Tue, 01 Apr 2014 14:49:30 +0200	[thread overview]
Message-ID: <533AB5DA.6040306@pengutronix.de> (raw)
In-Reply-To: <1396356451.825797457@f388.i.mail.ru>

[-- Attachment #1: Type: text/plain, Size: 2108 bytes --]

On 04/01/2014 02:47 PM, Alexander Shiyan wrote:
> Tue, 01 Apr 2014 13:56:41 +0200 от Marc Kleine-Budde <mkl@pengutronix.de>:
>> On 03/28/2014 11:14 AM, Alexander Shiyan wrote:
>>> This patch moves setup of SPI bus a bit earlier and adds check
>>> for spi_setup() result to be sure SPI bus is communicated with the
>>> device properly.
>>>
>>> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
>>> ---
>>>  drivers/net/can/mcp251x.c | 25 +++++++++++++------------
>>>  1 file changed, 13 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
>>> index 28c11f8..26879c7 100644
>>> --- a/drivers/net/can/mcp251x.c
>>> +++ b/drivers/net/can/mcp251x.c
>>> @@ -1032,8 +1032,8 @@ static int mcp251x_can_probe(struct spi_device *spi)
>>>  	struct mcp251x_platform_data *pdata = dev_get_platdata(&spi->dev);
>>>  	struct net_device *net;
>>>  	struct mcp251x_priv *priv;
>>> -	int freq, ret = -ENODEV;
>>>  	struct clk *clk;
>>> +	int freq, ret;
>>>  
>>>  	clk = devm_clk_get(&spi->dev, NULL);
>>>  	if (IS_ERR(clk)) {
>>> @@ -1076,6 +1076,18 @@ static int mcp251x_can_probe(struct spi_device *spi)
>>>  	priv->net = net;
>>>  	priv->clk = clk;
>>>  
>>> +	spi_set_drvdata(spi, priv);
>>> +
>>> +	/* Configure the SPI bus */
>>> +	spi->bits_per_word = 8;
>>> +	if (mcp251x_is_2510(spi))
>>> +		spi->max_speed_hz = spi->max_speed_hz ? : 5 * 1000 * 1000;
>>> +	else
>>> +		spi->max_speed_hz = spi->max_speed_hz ? : 10 * 1000 * 1000;
>>> +	ret = spi_setup(spi);
>>> +	if (ret)
>>> +		return ret;
>>
>> You're omitting the error handling here. I'll send a v2.
> 
> spi_setup() returns 0 or an error. What is wrong here?

You're not cleaning up the allocated resources.

-               return ret;
+               return out_clk;

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

  reply	other threads:[~2014-04-01 12:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-28 10:14 [PATCH 1/4] can: mcp251x: Check return value of spi_setup() Alexander Shiyan
2014-03-28 10:14 ` [PATCH 2/4] can: mcp251x: Improve mcp251x_hw_reset() Alexander Shiyan
2014-04-01 20:47   ` Marc Kleine-Budde
2014-03-28 10:14 ` [PATCH 3/4] can: mcp251x: Improve mcp251x_hw_probe() Alexander Shiyan
2014-04-01 20:46   ` Marc Kleine-Budde
2014-03-28 10:14 ` [PATCH 4/4] can: mcp251x: Remove unnecessary power disabling Alexander Shiyan
2014-04-01 20:36   ` Marc Kleine-Budde
2014-04-02  6:17     ` Alexander Shiyan
2014-04-02  7:05       ` Marc Kleine-Budde
2014-04-01 11:56 ` [PATCH 1/4] can: mcp251x: Check return value of spi_setup() Marc Kleine-Budde
2014-04-01 12:47   ` Alexander Shiyan
2014-04-01 12:49     ` Marc Kleine-Budde [this message]
2014-04-01 12:54       ` Alexander Shiyan
2014-04-01 20:40         ` Marc Kleine-Budde

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=533AB5DA.6040306@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=shc_work@mail.ru \
    --cc=wg@grandegger.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;
as well as URLs for NNTP newsgroup(s).