[PATCH 1/1] [U-Boot, v4, 1/1]net: phy: Add the Airoha EN8811H PHY driver
Marek Vasut
marek.vasut at mailbox.org
Mon Sep 22 00:40:36 CEST 2025
On 9/15/25 4:35 PM, Lucien.Jheng wrote:
Hi,
sorry for the late reply.
>>> +__weak int en8811h_read_fw(void **addr)
>>
>> Does this still have to be a __weak function, now that it uses generic
>> fw loader ?
>>
>>> +{
>>> + void *buffer;
>>> + int ret;
>>> +
>>> + if (!IS_ENABLED(CONFIG_FS_LOADER))
>>> + return -EOPNOTSUPP;
>>> +
>>> + buffer = malloc(EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE);
>>> + if (!buffer) {
>>> + printf("Failed to allocate memory for firmware\n");
>>> + return -ENOMEM;
>>> + }
>>> +
>>> + ret = request_firmware_into_buf_via_script(&buffer,
>>
>> I think 'buffer' without the & should be used here.
>
> Regarding buffer,
>
> I've reviewed the function definition for
> request_firmware_into_buf_via_script.
> The first parameter is void **buf, which is a pointer to a pointer.
>
> I think passing &buffer is the correct way to call this function.
>
> If we were to pass just buffer (a void *), the function would receive a
> copy of the pointer's value, and any memory allocation inside the
> function would not be reflected in our original buffer variable.
>
> Please let me know if my understanding is incorrect, as I want to ensure
> I'm using the function as intended.
I was confused by the current request_firmware_into_buf_via_script()
interface.
In the current design, passing pointer to pointer into
request_firmware_into_buf_via_script() is not necessary, because the
request_firmware_into_buf_via_script() function internally does memcpy()
into the 'buf' buffer, and for that to work, pointer to pointer is not
necessary, plain pointer to buffer would do just fine.
I think this current interface which does memcpy() is actually better
than the one I originally suggested which would use memdup(), so let's
keep it.
I now sent an update patch to remove the pointer to pointer:
[PATCH] misc: fs_loader: Use buffer pointer in
request_firmware_into_buf_via_script()
That should be all I hope.
More information about the U-Boot
mailing list