Re: [PATCH v6 20/28] spi: spi-mem: Fill the spi-mem controller capabilities of all the drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> index c4da0c9b05e9..bfd5c6b2db0a 100644
> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -160,6 +160,9 @@ static bool spi_mem_check_buswidth(struct spi_mem *mem,
>  	return true;
>  }
>  
> +const struct spi_controller_mem_caps spi_mem_no_caps = {};
> +EXPORT_SYMBOL_GPL(spi_mem_no_caps);

As suggested by Boris on IRC, we might just find a way to avoid
defining this empty structure and requesting all drivers to provide one.

As it turns out, there is no per-controller spi-mem initialization
where we could provide a default set of capabilities, but I believe we
could hide the little extra complexity with something like:

#define spi_mem_controller_is_capable(mem, cap) \
	((mem)->ctlr->caps && (mem)->ctrl->caps->##cap)

And using the above helper in spi_mem_default_supports_op(), which
would transparently handle the !caps situation.

> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 57e2499ec1ed..58c5cb985431 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -2747,6 +2747,9 @@ static int spi_controller_check_ops(struct spi_controller *ctlr)
>  	if (ctlr->mem_ops) {
>  		if (!ctlr->mem_ops->exec_op)
>  			return -EINVAL;
> +
> +		if (!ctlr->mem_ops->caps)
> +			return -EINVAL;
>  	} else if (!ctlr->transfer && !ctlr->transfer_one &&
>  		   !ctlr->transfer_one_message) {
>  		return -EINVAL;
> diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
> index 42f3850610b5..5f728f3113bd 100644
> --- a/include/linux/spi/spi-mem.h
> +++ b/include/linux/spi/spi-mem.h
> @@ -366,6 +366,7 @@ bool spi_mem_dtr_supports_op(struct spi_mem *mem,
>  
>  int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op);
>  
> +const struct spi_controller_mem_caps spi_mem_no_caps;
>  bool spi_mem_supports_op(struct spi_mem *mem,
>  			 const struct spi_mem_op *op);
>  


Thanks,
Miquèl



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux