Skip to content

Commit 9eac534

Browse files
committed
firmware/sysfb: Set firmware-framebuffer parent device
Set the firmware framebuffer's parent device, which usually is the graphics hardware's physical device. Integrates the framebuffer in the Linux device hierarchy and lets Linux handle dependencies among devices. For example, the graphics hardware won't be suspended while the firmware device is still active. v4: * fix build for CONFIG_SYSFB_SIMPLEFB=n, again v3: * fix build for CONFIG_SYSFB_SIMPLEFB=n (Sui) * test result of screen_info_pci_dev() for errors (Sui) v2: * detect parent device in sysfb_parent_dev() Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240212090736.11464-4-tzimmermann@suse.de
1 parent 036105e commit 9eac534

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

drivers/firmware/sysfb.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/init.h>
3030
#include <linux/kernel.h>
3131
#include <linux/mm.h>
32+
#include <linux/pci.h>
3233
#include <linux/platform_data/simplefb.h>
3334
#include <linux/platform_device.h>
3435
#include <linux/screen_info.h>
@@ -69,9 +70,23 @@ void sysfb_disable(void)
6970
}
7071
EXPORT_SYMBOL_GPL(sysfb_disable);
7172

73+
static __init struct device *sysfb_parent_dev(const struct screen_info *si)
74+
{
75+
struct pci_dev *pdev;
76+
77+
pdev = screen_info_pci_dev(si);
78+
if (IS_ERR(pdev))
79+
return ERR_CAST(pdev);
80+
else if (pdev)
81+
return &pdev->dev;
82+
83+
return NULL;
84+
}
85+
7286
static __init int sysfb_init(void)
7387
{
7488
struct screen_info *si = &screen_info;
89+
struct device *parent;
7590
struct simplefb_platform_data mode;
7691
const char *name;
7792
bool compatible;
@@ -83,10 +98,12 @@ static __init int sysfb_init(void)
8398

8499
sysfb_apply_efi_quirks();
85100

101+
parent = sysfb_parent_dev(si);
102+
86103
/* try to create a simple-framebuffer device */
87104
compatible = sysfb_parse_mode(si, &mode);
88105
if (compatible) {
89-
pd = sysfb_create_simplefb(si, &mode);
106+
pd = sysfb_create_simplefb(si, &mode, parent);
90107
if (!IS_ERR(pd))
91108
goto unlock_mutex;
92109
}
@@ -109,6 +126,8 @@ static __init int sysfb_init(void)
109126
goto unlock_mutex;
110127
}
111128

129+
pd->dev.parent = parent;
130+
112131
sysfb_set_efifb_fwnode(pd);
113132

114133
ret = platform_device_add_data(pd, si, sizeof(*si));

drivers/firmware/sysfb_simplefb.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ __init bool sysfb_parse_mode(const struct screen_info *si,
9191
}
9292

9393
__init struct platform_device *sysfb_create_simplefb(const struct screen_info *si,
94-
const struct simplefb_platform_data *mode)
94+
const struct simplefb_platform_data *mode,
95+
struct device *parent)
9596
{
9697
struct platform_device *pd;
9798
struct resource res;
@@ -143,6 +144,8 @@ __init struct platform_device *sysfb_create_simplefb(const struct screen_info *s
143144
if (!pd)
144145
return ERR_PTR(-ENOMEM);
145146

147+
pd->dev.parent = parent;
148+
146149
sysfb_set_efifb_fwnode(pd);
147150

148151
ret = platform_device_add_resources(pd, &res, 1);

include/linux/sysfb.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ static inline void sysfb_set_efifb_fwnode(struct platform_device *pd)
9191
bool sysfb_parse_mode(const struct screen_info *si,
9292
struct simplefb_platform_data *mode);
9393
struct platform_device *sysfb_create_simplefb(const struct screen_info *si,
94-
const struct simplefb_platform_data *mode);
94+
const struct simplefb_platform_data *mode,
95+
struct device *parent);
9596

9697
#else /* CONFIG_SYSFB_SIMPLE */
9798

@@ -102,7 +103,8 @@ static inline bool sysfb_parse_mode(const struct screen_info *si,
102103
}
103104

104105
static inline struct platform_device *sysfb_create_simplefb(const struct screen_info *si,
105-
const struct simplefb_platform_data *mode)
106+
const struct simplefb_platform_data *mode,
107+
struct device *parent)
106108
{
107109
return ERR_PTR(-EINVAL);
108110
}

0 commit comments

Comments
 (0)