@@ -830,36 +830,62 @@ void *__devm_drm_dev_alloc(struct device *parent,
830830EXPORT_SYMBOL (__devm_drm_dev_alloc );
831831
832832/**
833- * drm_dev_alloc - Allocate new DRM device
834- * @driver: DRM driver to allocate device for
833+ * __drm_dev_alloc - Allocation of a &drm_device instance
835834 * @parent: Parent device object
835+ * @driver: DRM driver
836+ * @size: the size of the struct which contains struct drm_device
837+ * @offset: the offset of the &drm_device within the container.
836838 *
837- * This is the deprecated version of devm_drm_dev_alloc(), which does not support
838- * subclassing through embedding the struct &drm_device in a driver private
839- * structure, and which does not support automatic cleanup through devres.
839+ * This should *NOT* be by any drivers, but is a dedicated interface for the
840+ * corresponding Rust abstraction.
840841 *
841- * RETURNS:
842- * Pointer to new DRM device, or ERR_PTR on failure.
842+ * This is the same as devm_drm_dev_alloc(), but without the corresponding
843+ * resource management through the parent device, but not the same as
844+ * drm_dev_alloc(), since the latter is the deprecated version, which does not
845+ * support subclassing.
846+ *
847+ * Returns: A pointer to new DRM device, or an ERR_PTR on failure.
843848 */
844- struct drm_device * drm_dev_alloc (const struct drm_driver * driver ,
845- struct device * parent )
849+ void * __drm_dev_alloc (struct device * parent ,
850+ const struct drm_driver * driver ,
851+ size_t size , size_t offset )
846852{
847- struct drm_device * dev ;
853+ void * container ;
854+ struct drm_device * drm ;
848855 int ret ;
849856
850- dev = kzalloc (sizeof ( * dev ) , GFP_KERNEL );
851- if (!dev )
857+ container = kzalloc (size , GFP_KERNEL );
858+ if (!container )
852859 return ERR_PTR (- ENOMEM );
853860
854- ret = drm_dev_init (dev , driver , parent );
861+ drm = container + offset ;
862+ ret = drm_dev_init (drm , driver , parent );
855863 if (ret ) {
856- kfree (dev );
864+ kfree (container );
857865 return ERR_PTR (ret );
858866 }
867+ drmm_add_final_kfree (drm , container );
859868
860- drmm_add_final_kfree (dev , dev );
869+ return container ;
870+ }
871+ EXPORT_SYMBOL (__drm_dev_alloc );
861872
862- return dev ;
873+ /**
874+ * drm_dev_alloc - Allocate new DRM device
875+ * @driver: DRM driver to allocate device for
876+ * @parent: Parent device object
877+ *
878+ * This is the deprecated version of devm_drm_dev_alloc(), which does not support
879+ * subclassing through embedding the struct &drm_device in a driver private
880+ * structure, and which does not support automatic cleanup through devres.
881+ *
882+ * RETURNS:
883+ * Pointer to new DRM device, or ERR_PTR on failure.
884+ */
885+ struct drm_device * drm_dev_alloc (const struct drm_driver * driver ,
886+ struct device * parent )
887+ {
888+ return __drm_dev_alloc (parent , driver , sizeof (struct drm_device ), 0 );
863889}
864890EXPORT_SYMBOL (drm_dev_alloc );
865891
0 commit comments