On 3/17/21 10:12 AM, Pratyush Yadav wrote:
> On 17/03/21 09:19AM, Michal Simek wrote:
>> From: T Karthik Reddy <t.karthik.re...@xilinx.com>
>>
>> Add spi memory operations to relocate manually when
>> CONFIG_NEEDS_MANUAL_RELOC is enabled.
>>
>> Signed-off-by: T Karthik Reddy <t.karthik.re...@xilinx.com>
>> Acked-by: Ashok Reddy Soma <ashok.reddy.s...@xilinx.com>
>> Signed-off-by: Michal Simek <michal.si...@xilinx.com>
>> ---
>>
>> drivers/spi/spi-uclass.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
>> index 7155d4aebd6d..e24a0ff9544b 100644
>> --- a/drivers/spi/spi-uclass.c
>> +++ b/drivers/spi/spi-uclass.c
>> @@ -11,6 +11,7 @@
>> #include <log.h>
>> #include <malloc.h>
>> #include <spi.h>
>> +#include <spi-mem.h>
>> #include <dm/device_compat.h>
>> #include <asm/global_data.h>
>> #include <dm/device-internal.h>
>> @@ -182,6 +183,8 @@ static int spi_post_probe(struct udevice *bus)
>> #endif
>> #if defined(CONFIG_NEEDS_MANUAL_RELOC)
>> struct dm_spi_ops *ops = spi_get_ops(bus);
>> + struct spi_controller_mem_ops *mem_ops =
>> + (struct spi_controller_mem_ops *)ops->mem_ops;
>> static int reloc_done;
>>
>> if (!reloc_done) {
>> @@ -199,6 +202,12 @@ static int spi_post_probe(struct udevice *bus)
>> ops->set_mode += gd->reloc_off;
>> if (ops->cs_info)
>> ops->cs_info += gd->reloc_off;
>> + if (mem_ops->adjust_op_size)
>> + mem_ops->adjust_op_size += gd->reloc_off;
>> + if (mem_ops->supports_op)
>> + mem_ops->supports_op += gd->reloc_off;
>> + if (mem_ops->exec_op)
>> + mem_ops->exec_op += gd->reloc_off;
>
> The comment above mem_ops says "This field is optional and should only
> be implemented if the controller has native support for memory-like
> operations". So you should do a NULL check before accessing it.
Karthik: Can you please take a look and retest?
M