@@ -71,6 +71,8 @@ enum bochs_types {
71
71
};
72
72
73
73
struct bochs_device {
74
+ struct drm_device dev ;
75
+
74
76
/* hw */
75
77
void __iomem * mmio ;
76
78
int ioports ;
@@ -87,14 +89,13 @@ struct bochs_device {
87
89
u32 bpp ;
88
90
89
91
/* drm */
90
- struct drm_device * dev ;
91
92
struct drm_simple_display_pipe pipe ;
92
93
struct drm_connector connector ;
93
94
};
94
95
95
96
static struct bochs_device * to_bochs_device (const struct drm_device * dev )
96
97
{
97
- return ( struct bochs_device * ) dev -> dev_private ;
98
+ return container_of ( dev , struct bochs_device , dev ) ;
98
99
}
99
100
100
101
/* ---------------------------------------------------------------------- */
@@ -211,7 +212,7 @@ static const struct drm_edid *bochs_hw_read_edid(struct drm_connector *connector
211
212
212
213
static int bochs_hw_init (struct bochs_device * bochs )
213
214
{
214
- struct drm_device * dev = bochs -> dev ;
215
+ struct drm_device * dev = & bochs -> dev ;
215
216
struct pci_dev * pdev = to_pci_dev (dev -> dev );
216
217
unsigned long addr , size , mem , ioaddr , iosize ;
217
218
u16 id ;
@@ -306,7 +307,7 @@ static void bochs_hw_setmode(struct bochs_device *bochs, struct drm_display_mode
306
307
{
307
308
int idx ;
308
309
309
- if (!drm_dev_enter (bochs -> dev , & idx ))
310
+ if (!drm_dev_enter (& bochs -> dev , & idx ))
310
311
return ;
311
312
312
313
bochs -> xres = mode -> hdisplay ;
@@ -342,7 +343,7 @@ static void bochs_hw_setformat(struct bochs_device *bochs, const struct drm_form
342
343
{
343
344
int idx ;
344
345
345
- if (!drm_dev_enter (bochs -> dev , & idx ))
346
+ if (!drm_dev_enter (& bochs -> dev , & idx ))
346
347
return ;
347
348
348
349
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
373
374
unsigned long offset ;
374
375
unsigned int vx , vy , vwidth , idx ;
375
376
376
- if (!drm_dev_enter (bochs -> dev , & idx ))
377
+ if (!drm_dev_enter (& bochs -> dev , & idx ))
377
378
return ;
378
379
379
380
bochs -> stride = stride ;
@@ -488,7 +489,7 @@ static const struct drm_connector_funcs bochs_connector_connector_funcs = {
488
489
489
490
static void bochs_connector_init (struct bochs_device * bochs )
490
491
{
491
- struct drm_device * dev = bochs -> dev ;
492
+ struct drm_device * dev = & bochs -> dev ;
492
493
struct drm_connector * connector = & bochs -> connector ;
493
494
494
495
drm_connector_init (dev , connector , & bochs_connector_connector_funcs ,
@@ -506,49 +507,44 @@ static const struct drm_mode_config_funcs bochs_mode_funcs = {
506
507
507
508
static int bochs_kms_init (struct bochs_device * bochs )
508
509
{
510
+ struct drm_device * dev = & bochs -> dev ;
509
511
int ret ;
510
512
511
- ret = drmm_mode_config_init (bochs -> dev );
513
+ ret = drmm_mode_config_init (dev );
512
514
if (ret )
513
515
return ret ;
514
516
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 ;
517
519
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;
521
523
522
- bochs -> dev -> mode_config .funcs = & bochs_mode_funcs ;
524
+ dev -> mode_config .funcs = & bochs_mode_funcs ;
523
525
524
526
bochs_connector_init (bochs );
525
- drm_simple_display_pipe_init (bochs -> dev ,
527
+ drm_simple_display_pipe_init (dev ,
526
528
& bochs -> pipe ,
527
529
& bochs_pipe_funcs ,
528
530
bochs_formats ,
529
531
ARRAY_SIZE (bochs_formats ),
530
532
NULL ,
531
533
& bochs -> connector );
532
534
533
- drm_mode_config_reset (bochs -> dev );
535
+ drm_mode_config_reset (dev );
534
536
535
537
return 0 ;
536
538
}
537
539
538
540
/* ---------------------------------------------------------------------- */
539
541
/* drm interface */
540
542
541
- static int bochs_load (struct drm_device * dev )
543
+ static int bochs_load (struct bochs_device * bochs )
542
544
{
543
- struct bochs_device * bochs ;
545
+ struct drm_device * dev = & bochs -> dev ;
544
546
int ret ;
545
547
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
-
552
548
ret = bochs_hw_init (bochs );
553
549
if (ret )
554
550
return ret ;
@@ -606,6 +602,7 @@ static const struct dev_pm_ops bochs_pm_ops = {
606
602
607
603
static int bochs_pci_probe (struct pci_dev * pdev , const struct pci_device_id * ent )
608
604
{
605
+ struct bochs_device * bochs ;
609
606
struct drm_device * dev ;
610
607
unsigned long fbsize ;
611
608
int ret ;
@@ -620,17 +617,18 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
620
617
if (ret )
621
618
return ret ;
622
619
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 ))
625
622
return PTR_ERR (dev );
623
+ dev = & bochs -> dev ;
626
624
627
625
ret = pcim_enable_device (pdev );
628
626
if (ret )
629
627
goto err_free_dev ;
630
628
631
629
pci_set_drvdata (pdev , dev );
632
630
633
- ret = bochs_load (dev );
631
+ ret = bochs_load (bochs );
634
632
if (ret )
635
633
goto err_free_dev ;
636
634
0 commit comments