[v2,06/10] drm/bochs: Allocate DRM device in struct bochs_device

Kees Bakker kees at ijzerbout.nl
Wed Oct 2 20:00:07 UTC 2024


Op 02-09-2024 om 12:53 schreef Thomas Zimmermann:
> Allocate an instance of struct drm_device in struct bochs_device. Also
> remove all uses of dev_private from bochs and upcast from the embedded
> instance if necessary.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> Acked-by: Gerd Hoffmann <kraxel at redhat.com>
> ---
>   drivers/gpu/drm/tiny/bochs.c | 52 +++++++++++++++++-------------------
>   1 file changed, 25 insertions(+), 27 deletions(-)
>
> [...]
> @@ -606,6 +602,7 @@ static const struct dev_pm_ops bochs_pm_ops = {
>   
>   static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   {
> +	struct bochs_device *bochs;
>   	struct drm_device *dev;
>   	unsigned long fbsize;
>   	int ret;
> @@ -620,9 +617,10 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
>   	if (ret)
>   		return ret;
>   
> -	dev = drm_dev_alloc(&bochs_driver, &pdev->dev);
> -	if (IS_ERR(dev))
> +	bochs = devm_drm_dev_alloc(&pdev->dev, &bochs_driver, struct bochs_device, dev);
> +	if (IS_ERR(bochs))
>   		return PTR_ERR(dev);
> +	dev = &bochs->dev;
The assignment of dev comes after potential use of dev in PTR_ERR(dev).
Did you perhaps meant to have PTR_ERR(&pdev->dev) ?
>   
>   	ret = pcim_enable_device(pdev);
>   	if (ret)
> @@ -630,7 +628,7 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
>   
>   	pci_set_drvdata(pdev, dev);
>   
> -	ret = bochs_load(dev);
> +	ret = bochs_load(bochs);
>   	if (ret)
>   		goto err_free_dev;
>   



More information about the dri-devel mailing list