On 01/07/2022 10:43, Yang Yingliang wrote:[...]
+
Please send any updated version cc'ing Rafael, who kindly offered to pick up this patch
OK@@ -503,13 +503,13 @@ static int hisi_lpc_acpi_probe(struct device *hostdev)
{
struct acpi_device *adev = ACPI_COMPANION(hostdev);
struct acpi_device *child;
+ struct platform_device *pdev;
nit: please maintain reverse-firtree ordering
The resource allocated in platform_device_add_resources() is inserted by platform_device_add(), if platform_device_add() is not called successfully, freeing the resource in platform_device_release() is enough.
int ret;
/* Only consider the children of the host */
list_for_each_entry(child, &adev->children, node) {
const char *hid = acpi_device_hid(child);
const struct hisi_lpc_acpi_cell *cell;
- struct platform_device *pdev;
const struct resource *res;
bool found = false;
int num_res;
@@ -571,22 +571,24 @@ static int hisi_lpc_acpi_probe(struct device *hostdev)
ret = platform_device_add_resources(pdev, res, num_res);
if (ret)
- goto fail;
+ goto fail_put_device;
ret = platform_device_add_data(pdev, cell->pdata,
cell->pdata_size);
if (ret)
- goto fail;
+ goto fail_put_device;
ret = platform_device_add(pdev);
if (ret)
- goto fail;
+ goto fail_put_device;
acpi_device_set_enumerated(child);
}
return 0;
+fail_put_device:
+ platform_device_put(pdev);
is this enough? As I see, this invokes platform_device_release(), but we would still need platform_device_del() to drop the pdev resources. hisi_lpc_acpi_remove_subdev() calls platform_device_unregister(), so it seems proper to do that here also. Please check it.
Thanks,
John
fail:
hisi_lpc_acpi_remove(hostdev);
return ret;
.