Skip to content

Commit 04826f5

Browse files
author
Thomas Zimmermann
committed
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 <[email protected]> Acked-by: Gerd Hoffmann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1d614a4 commit 04826f5

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

drivers/gpu/drm/tiny/bochs.c

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ enum bochs_types {
7171
};
7272

7373
struct bochs_device {
74+
struct drm_device dev;
75+
7476
/* hw */
7577
void __iomem *mmio;
7678
int ioports;
@@ -87,14 +89,13 @@ struct bochs_device {
8789
u32 bpp;
8890

8991
/* drm */
90-
struct drm_device *dev;
9192
struct drm_simple_display_pipe pipe;
9293
struct drm_connector connector;
9394
};
9495

9596
static struct bochs_device *to_bochs_device(const struct drm_device *dev)
9697
{
97-
return (struct bochs_device *)dev->dev_private;
98+
return container_of(dev, struct bochs_device, dev);
9899
}
99100

100101
/* ---------------------------------------------------------------------- */
@@ -211,7 +212,7 @@ static const struct drm_edid *bochs_hw_read_edid(struct drm_connector *connector
211212

212213
static int bochs_hw_init(struct bochs_device *bochs)
213214
{
214-
struct drm_device *dev = bochs->dev;
215+
struct drm_device *dev = &bochs->dev;
215216
struct pci_dev *pdev = to_pci_dev(dev->dev);
216217
unsigned long addr, size, mem, ioaddr, iosize;
217218
u16 id;
@@ -306,7 +307,7 @@ static void bochs_hw_setmode(struct bochs_device *bochs, struct drm_display_mode
306307
{
307308
int idx;
308309

309-
if (!drm_dev_enter(bochs->dev, &idx))
310+
if (!drm_dev_enter(&bochs->dev, &idx))
310311
return;
311312

312313
bochs->xres = mode->hdisplay;
@@ -342,7 +343,7 @@ static void bochs_hw_setformat(struct bochs_device *bochs, const struct drm_form
342343
{
343344
int idx;
344345

345-
if (!drm_dev_enter(bochs->dev, &idx))
346+
if (!drm_dev_enter(&bochs->dev, &idx))
346347
return;
347348

348349
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
373374
unsigned long offset;
374375
unsigned int vx, vy, vwidth, idx;
375376

376-
if (!drm_dev_enter(bochs->dev, &idx))
377+
if (!drm_dev_enter(&bochs->dev, &idx))
377378
return;
378379

379380
bochs->stride = stride;
@@ -488,7 +489,7 @@ static const struct drm_connector_funcs bochs_connector_connector_funcs = {
488489

489490
static void bochs_connector_init(struct bochs_device *bochs)
490491
{
491-
struct drm_device *dev = bochs->dev;
492+
struct drm_device *dev = &bochs->dev;
492493
struct drm_connector *connector = &bochs->connector;
493494

494495
drm_connector_init(dev, connector, &bochs_connector_connector_funcs,
@@ -506,49 +507,44 @@ static const struct drm_mode_config_funcs bochs_mode_funcs = {
506507

507508
static int bochs_kms_init(struct bochs_device *bochs)
508509
{
510+
struct drm_device *dev = &bochs->dev;
509511
int ret;
510512

511-
ret = drmm_mode_config_init(bochs->dev);
513+
ret = drmm_mode_config_init(dev);
512514
if (ret)
513515
return ret;
514516

515-
bochs->dev->mode_config.max_width = 8192;
516-
bochs->dev->mode_config.max_height = 8192;
517+
dev->mode_config.max_width = 8192;
518+
dev->mode_config.max_height = 8192;
517519

518-
bochs->dev->mode_config.preferred_depth = 24;
519-
bochs->dev->mode_config.prefer_shadow = 0;
520-
bochs->dev->mode_config.quirk_addfb_prefer_host_byte_order = true;
520+
dev->mode_config.preferred_depth = 24;
521+
dev->mode_config.prefer_shadow = 0;
522+
dev->mode_config.quirk_addfb_prefer_host_byte_order = true;
521523

522-
bochs->dev->mode_config.funcs = &bochs_mode_funcs;
524+
dev->mode_config.funcs = &bochs_mode_funcs;
523525

524526
bochs_connector_init(bochs);
525-
drm_simple_display_pipe_init(bochs->dev,
527+
drm_simple_display_pipe_init(dev,
526528
&bochs->pipe,
527529
&bochs_pipe_funcs,
528530
bochs_formats,
529531
ARRAY_SIZE(bochs_formats),
530532
NULL,
531533
&bochs->connector);
532534

533-
drm_mode_config_reset(bochs->dev);
535+
drm_mode_config_reset(dev);
534536

535537
return 0;
536538
}
537539

538540
/* ---------------------------------------------------------------------- */
539541
/* drm interface */
540542

541-
static int bochs_load(struct drm_device *dev)
543+
static int bochs_load(struct bochs_device *bochs)
542544
{
543-
struct bochs_device *bochs;
545+
struct drm_device *dev = &bochs->dev;
544546
int ret;
545547

546-
bochs = drmm_kzalloc(dev, sizeof(*bochs), GFP_KERNEL);
547-
if (bochs == NULL)
548-
return -ENOMEM;
549-
dev->dev_private = bochs;
550-
bochs->dev = dev;
551-
552548
ret = bochs_hw_init(bochs);
553549
if (ret)
554550
return ret;
@@ -606,6 +602,7 @@ static const struct dev_pm_ops bochs_pm_ops = {
606602

607603
static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
608604
{
605+
struct bochs_device *bochs;
609606
struct drm_device *dev;
610607
unsigned long fbsize;
611608
int ret;
@@ -620,17 +617,18 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
620617
if (ret)
621618
return ret;
622619

623-
dev = drm_dev_alloc(&bochs_driver, &pdev->dev);
624-
if (IS_ERR(dev))
620+
bochs = devm_drm_dev_alloc(&pdev->dev, &bochs_driver, struct bochs_device, dev);
621+
if (IS_ERR(bochs))
625622
return PTR_ERR(dev);
623+
dev = &bochs->dev;
626624

627625
ret = pcim_enable_device(pdev);
628626
if (ret)
629627
goto err_free_dev;
630628

631629
pci_set_drvdata(pdev, dev);
632630

633-
ret = bochs_load(dev);
631+
ret = bochs_load(bochs);
634632
if (ret)
635633
goto err_free_dev;
636634

0 commit comments

Comments
 (0)