From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Alexander Shiyan <shc_work@mail.ru>, linux-can@vger.kernel.org
Cc: Wolfgang Grandegger <wg@grandegger.com>
Subject: Re: [PATCH 1/4] can: mcp251x: Check return value of spi_setup()
Date: Tue, 01 Apr 2014 13:56:41 +0200 [thread overview]
Message-ID: <533AA979.9060201@pengutronix.de> (raw)
In-Reply-To: <1396001687-7092-1-git-send-email-shc_work@mail.ru>
[-- Attachment #1: Type: text/plain, Size: 2675 bytes --]
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.
> +
> priv->power = devm_regulator_get(&spi->dev, "vdd");
> priv->transceiver = devm_regulator_get(&spi->dev, "xceiver");
> if ((PTR_ERR(priv->power) == -EPROBE_DEFER) ||
> @@ -1088,8 +1100,6 @@ static int mcp251x_can_probe(struct spi_device *spi)
> if (ret)
> goto out_clk;
>
> - spi_set_drvdata(spi, priv);
> -
> priv->spi = spi;
> mutex_init(&priv->mcp_lock);
>
> @@ -1134,15 +1144,6 @@ static int mcp251x_can_probe(struct spi_device *spi)
>
> SET_NETDEV_DEV(net, &spi->dev);
>
> - /* Configure the SPI bus */
> - spi->mode = spi->mode ? : SPI_MODE_0;
> - 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;
> - spi->bits_per_word = 8;
> - spi_setup(spi);
> -
> /* Here is OK to not lock the MCP, no one knows about it yet */
> if (!mcp251x_hw_probe(spi)) {
> ret = -ENODEV;
>
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 --]
next prev parent reply other threads:[~2014-04-01 11:56 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 ` Marc Kleine-Budde [this message]
2014-04-01 12:47 ` [PATCH 1/4] can: mcp251x: Check return value of spi_setup() Alexander Shiyan
2014-04-01 12:49 ` Marc Kleine-Budde
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=533AA979.9060201@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).