drm/bochs: Allocate DRM device in struct bochs_device
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@suse.de> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240902105546.792625-7-tzimmermann@suse.de
This commit is contained in:
parent
1d614a4674
commit
04826f5886
1 changed files with 25 additions and 27 deletions
|
@ -71,6 +71,8 @@ enum bochs_types {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bochs_device {
|
struct bochs_device {
|
||||||
|
struct drm_device dev;
|
||||||
|
|
||||||
/* hw */
|
/* hw */
|
||||||
void __iomem *mmio;
|
void __iomem *mmio;
|
||||||
int ioports;
|
int ioports;
|
||||||
|
@ -87,14 +89,13 @@ struct bochs_device {
|
||||||
u32 bpp;
|
u32 bpp;
|
||||||
|
|
||||||
/* drm */
|
/* drm */
|
||||||
struct drm_device *dev;
|
|
||||||
struct drm_simple_display_pipe pipe;
|
struct drm_simple_display_pipe pipe;
|
||||||
struct drm_connector connector;
|
struct drm_connector connector;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct bochs_device *to_bochs_device(const struct drm_device *dev)
|
static struct bochs_device *to_bochs_device(const struct drm_device *dev)
|
||||||
{
|
{
|
||||||
return (struct bochs_device *)dev->dev_private;
|
return container_of(dev, struct bochs_device, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
@ -211,7 +212,7 @@ static const struct drm_edid *bochs_hw_read_edid(struct drm_connector *connector
|
||||||
|
|
||||||
static int bochs_hw_init(struct bochs_device *bochs)
|
static int bochs_hw_init(struct bochs_device *bochs)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = bochs->dev;
|
struct drm_device *dev = &bochs->dev;
|
||||||
struct pci_dev *pdev = to_pci_dev(dev->dev);
|
struct pci_dev *pdev = to_pci_dev(dev->dev);
|
||||||
unsigned long addr, size, mem, ioaddr, iosize;
|
unsigned long addr, size, mem, ioaddr, iosize;
|
||||||
u16 id;
|
u16 id;
|
||||||
|
@ -306,7 +307,7 @@ static void bochs_hw_setmode(struct bochs_device *bochs, struct drm_display_mode
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
if (!drm_dev_enter(bochs->dev, &idx))
|
if (!drm_dev_enter(&bochs->dev, &idx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bochs->xres = mode->hdisplay;
|
bochs->xres = mode->hdisplay;
|
||||||
|
@ -342,7 +343,7 @@ static void bochs_hw_setformat(struct bochs_device *bochs, const struct drm_form
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
if (!drm_dev_enter(bochs->dev, &idx))
|
if (!drm_dev_enter(&bochs->dev, &idx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DRM_DEBUG_DRIVER("format %c%c%c%c\n",
|
DRM_DEBUG_DRIVER("format %c%c%c%c\n",
|
||||||
|
@ -373,7 +374,7 @@ static void bochs_hw_setbase(struct bochs_device *bochs, int x, int y, int strid
|
||||||
unsigned long offset;
|
unsigned long offset;
|
||||||
unsigned int vx, vy, vwidth, idx;
|
unsigned int vx, vy, vwidth, idx;
|
||||||
|
|
||||||
if (!drm_dev_enter(bochs->dev, &idx))
|
if (!drm_dev_enter(&bochs->dev, &idx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bochs->stride = stride;
|
bochs->stride = stride;
|
||||||
|
@ -488,7 +489,7 @@ static const struct drm_connector_funcs bochs_connector_connector_funcs = {
|
||||||
|
|
||||||
static void bochs_connector_init(struct bochs_device *bochs)
|
static void bochs_connector_init(struct bochs_device *bochs)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = bochs->dev;
|
struct drm_device *dev = &bochs->dev;
|
||||||
struct drm_connector *connector = &bochs->connector;
|
struct drm_connector *connector = &bochs->connector;
|
||||||
|
|
||||||
drm_connector_init(dev, connector, &bochs_connector_connector_funcs,
|
drm_connector_init(dev, connector, &bochs_connector_connector_funcs,
|
||||||
|
@ -506,23 +507,24 @@ static const struct drm_mode_config_funcs bochs_mode_funcs = {
|
||||||
|
|
||||||
static int bochs_kms_init(struct bochs_device *bochs)
|
static int bochs_kms_init(struct bochs_device *bochs)
|
||||||
{
|
{
|
||||||
|
struct drm_device *dev = &bochs->dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = drmm_mode_config_init(bochs->dev);
|
ret = drmm_mode_config_init(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
bochs->dev->mode_config.max_width = 8192;
|
dev->mode_config.max_width = 8192;
|
||||||
bochs->dev->mode_config.max_height = 8192;
|
dev->mode_config.max_height = 8192;
|
||||||
|
|
||||||
bochs->dev->mode_config.preferred_depth = 24;
|
dev->mode_config.preferred_depth = 24;
|
||||||
bochs->dev->mode_config.prefer_shadow = 0;
|
dev->mode_config.prefer_shadow = 0;
|
||||||
bochs->dev->mode_config.quirk_addfb_prefer_host_byte_order = true;
|
dev->mode_config.quirk_addfb_prefer_host_byte_order = true;
|
||||||
|
|
||||||
bochs->dev->mode_config.funcs = &bochs_mode_funcs;
|
dev->mode_config.funcs = &bochs_mode_funcs;
|
||||||
|
|
||||||
bochs_connector_init(bochs);
|
bochs_connector_init(bochs);
|
||||||
drm_simple_display_pipe_init(bochs->dev,
|
drm_simple_display_pipe_init(dev,
|
||||||
&bochs->pipe,
|
&bochs->pipe,
|
||||||
&bochs_pipe_funcs,
|
&bochs_pipe_funcs,
|
||||||
bochs_formats,
|
bochs_formats,
|
||||||
|
@ -530,7 +532,7 @@ static int bochs_kms_init(struct bochs_device *bochs)
|
||||||
NULL,
|
NULL,
|
||||||
&bochs->connector);
|
&bochs->connector);
|
||||||
|
|
||||||
drm_mode_config_reset(bochs->dev);
|
drm_mode_config_reset(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -538,17 +540,11 @@ static int bochs_kms_init(struct bochs_device *bochs)
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
/* drm interface */
|
/* drm interface */
|
||||||
|
|
||||||
static int bochs_load(struct drm_device *dev)
|
static int bochs_load(struct bochs_device *bochs)
|
||||||
{
|
{
|
||||||
struct bochs_device *bochs;
|
struct drm_device *dev = &bochs->dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
bochs = drmm_kzalloc(dev, sizeof(*bochs), GFP_KERNEL);
|
|
||||||
if (bochs == NULL)
|
|
||||||
return -ENOMEM;
|
|
||||||
dev->dev_private = bochs;
|
|
||||||
bochs->dev = dev;
|
|
||||||
|
|
||||||
ret = bochs_hw_init(bochs);
|
ret = bochs_hw_init(bochs);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -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)
|
static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||||
{
|
{
|
||||||
|
struct bochs_device *bochs;
|
||||||
struct drm_device *dev;
|
struct drm_device *dev;
|
||||||
unsigned long fbsize;
|
unsigned long fbsize;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -620,9 +617,10 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
dev = drm_dev_alloc(&bochs_driver, &pdev->dev);
|
bochs = devm_drm_dev_alloc(&pdev->dev, &bochs_driver, struct bochs_device, dev);
|
||||||
if (IS_ERR(dev))
|
if (IS_ERR(bochs))
|
||||||
return PTR_ERR(dev);
|
return PTR_ERR(dev);
|
||||||
|
dev = &bochs->dev;
|
||||||
|
|
||||||
ret = pcim_enable_device(pdev);
|
ret = pcim_enable_device(pdev);
|
||||||
if (ret)
|
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);
|
pci_set_drvdata(pdev, dev);
|
||||||
|
|
||||||
ret = bochs_load(dev);
|
ret = bochs_load(bochs);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_free_dev;
|
goto err_free_dev;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue