From: Mark Brown <broonie@kernel.org>
To: masonccyang@mxic.com.tw
Cc: tpiepho@impinj.com, linux-kernel@vger.kernel.org,
linux-spi@vger.kernel.org, boris.brezillon@bootlin.com,
juliensu@mxic.com.tw, zhengxunli@mxic.com.tw
Subject: Re: [PATCH v3 1/2] spi: Add MXIC controller driver
Date: Mon, 1 Oct 2018 16:35:01 +0100 [thread overview]
Message-ID: <20181001153501.GD19099@sirena.org.uk> (raw)
In-Reply-To: <1538120112-15530-2-git-send-email-masonccyang@mxic.com.tw>
[-- Attachment #1: Type: text/plain, Size: 1471 bytes --]
On Fri, Sep 28, 2018 at 03:35:11PM +0800, masonccyang@mxic.com.tw wrote:
This looks mostly good, a couple of fairly small things:
> +static int mxic_spi_clk_enable(struct mxic_spi *mxic)
> +{
> + int ret;
> +
> + ret = clk_prepare_enable(mxic->send_clk);
> + if (ret)
> + goto err_send_clk;
> +
> + ret = clk_prepare_enable(mxic->send_dly_clk);
> + if (ret)
> + goto err_send_dly_clk;
> +
> + return ret;
> +
> +err_send_dly_clk:
> + clk_disable_unprepare(mxic->send_dly_clk);
> +err_send_clk:
> + clk_disable_unprepare(mxic->send_clk);
You should only undo operations that succeeded in the error path, if
something failed you don't need to revert it.
> +static int mxic_spi_setup(struct spi_device *spi)
> +{
> + struct mxic_spi *mxic = spi_master_get_devdata(spi->master);
> + unsigned long freq = spi->max_speed_hz;
> + int ret;
> +
> + ret = clk_set_rate(mxic->send_clk, freq);
> + if (ret)
> + return ret;
> +
> + ret = clk_set_rate(mxic->send_dly_clk, freq);
> + if (ret)
> + return ret;
> +
> + /*
> + * A constant delay range from 0x0 ~ 0x1F for input delay,
> + * the unit is 78 ps, the max input delay is 2.418 ns.
> + */
> + mxic_spi_set_input_delay_dqs(mxic, 0xf);
This is changing the hardware state for all slaves, not just the device
being configured - setup() isn't supposed to do that (yes, it's a
confusing API but unfortunately a legacy one that'll be a pain to clean
up). prepare_transfer_hardware() is usually a better place to do this.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2018-10-01 15:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-28 7:35 [PATCH v3 0/2] spi: Add Macronix controller driver masonccyang
2018-09-28 7:35 ` [PATCH v3 1/2] spi: Add MXIC " masonccyang
2018-10-01 15:35 ` Mark Brown [this message]
2018-09-28 7:35 ` [PATCH v3 2/2] dt-bindings: spi: Document Macronix controller bindings masonccyang
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=20181001153501.GD19099@sirena.org.uk \
--to=broonie@kernel.org \
--cc=boris.brezillon@bootlin.com \
--cc=juliensu@mxic.com.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=masonccyang@mxic.com.tw \
--cc=tpiepho@impinj.com \
--cc=zhengxunli@mxic.com.tw \
/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).