lkml.org 
[lkml]   [2020]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4 2/2] spi: Add generic SPI multiplexer
On Fri, Jan 31, 2020 at 4:34 AM Chris Packham
<chris.packham@alliedtelesis.co.nz> wrote:
>
> Add a SPI device driver that sits in-band and provides a SPI controller
> which supports chip selects via a mux-control. This enables extra SPI
> devices to be connected with limited native chip selects.

Thanks for an update, my comments below.

...

> #
> # Add new SPI master controllers in alphabetical order above this line
> #

> +#

Redundant line.

...

> +/*
> + * General Purpose SPI multiplexer
> + */

I think Mark wants to have this in one line with C++ style of comments.

...

> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/err.h>
> +#include <linux/slab.h>
> +#include <linux/spi/spi.h>
> +#include <linux/mux/consumer.h>

Perhaps sorted?

...

> + /* do the transfer */
> + ret = spi_async(priv->spi, m);
> + return ret;

return spi_async(...);

...


> + priv->mux = devm_mux_control_get(&spi->dev, NULL);

> + ret = PTR_ERR_OR_ZERO(priv->mux);

This is a bit complicated.

> + if (ret) {

Why not simple do

if (IS_ERR(priv->mux)) {
ret = PTR_ERR(...);
...
}

?

> + if (ret != -EPROBE_DEFER)
> + dev_err(&spi->dev, "failed to get control-mux\n");
> + goto err_put_ctlr;
> + }

> + ctlr->dev.of_node = spi->dev.of_node;

I'm wondering why SPI core can't handle this by default (like GPIO
subsystem does).

> + ret = devm_spi_register_controller(&spi->dev, ctlr);
> + if (ret)
> + goto err_put_ctlr;
> +

> + return ret;

return 0;

...

> +static const struct of_device_id spi_mux_of_match[] = {
> + { .compatible = "spi-mux" },
> + { },

Comma is not needed in terminator line.

> +};

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2020-02-03 10:51    [W:0.058 / U:24.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site