Re: [PATCH v2 1/3] drm/loongson: Add a helper for creating child devices

From: Markus Elfring
Date: Mon May 27 2024 - 05:08:14 EST


> In some display subsystems, the functionality of a PCIe device may too

might be?



> into child devices can helpful to …

be?


> Another benefit is that we could migrate the dependency on exterinal

external?



> and rising cyclic dependency problems if not process correctly.

processed?



> driver to create sub-devices for it. The manually created decice acts as

device?


> agents for the principal part, migrate the potential issue to submodule.

an agent?


Please improve your change descriptions considerably.



> +++ b/drivers/gpu/drm/loongson/loongson_device.c

> @@ -100,3 +101,44 @@ lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip_id)
> {
> return __chip_id_desc_table[chip_id];
> }
> +
> +int loongson_create_platform_device(struct device *parent,
> + const char *name, int id,
> + struct resource *pres,
> + void *data,
> + struct platform_device **ppdev)
> +{

> + ret = platform_device_add_resources(pdev, pres, 1);
> + if (ret) {
> + platform_device_put(pdev);
> + return ret;
> + }

> + ret = platform_device_add(pdev);
> + if (ret) {
> + platform_device_put(pdev);
> + return ret;
> + }


Please use a goto chain for common exception handling.
https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources

Regards,
Markus