Skip to content

Commit 1af29b3

Browse files
committed
Merge tag 'chrome-platform-firmware-for-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform firmware updates from Tzung-Bi Shih: - Do not double register "simple-framebuffer" platform device if Generic System Framebuffers (sysfb) already did that - Fix a missing of unregistering platform driver in error handling path * tag 'chrome-platform-firmware-for-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: firmware: google: Unregister driver_info on failure firmware: coreboot: Don't register a pdev if screen_info data is present firmware: sysfb: Add a sysfb_handles_screen_info() helper function
2 parents 78516f4 + 32b0901 commit 1af29b3

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

drivers/firmware/google/framebuffer-coreboot.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/module.h>
1616
#include <linux/platform_data/simplefb.h>
1717
#include <linux/platform_device.h>
18+
#include <linux/sysfb.h>
1819

1920
#include "coreboot_table.h"
2021

@@ -36,6 +37,19 @@ static int framebuffer_probe(struct coreboot_device *dev)
3637
.format = NULL,
3738
};
3839

40+
/*
41+
* On coreboot systems, the advertised LB_TAG_FRAMEBUFFER entry
42+
* in the coreboot table should only be used if the payload did
43+
* not pass a framebuffer information to the Linux kernel.
44+
*
45+
* If the global screen_info data has been filled, the Generic
46+
* System Framebuffers (sysfb) will already register a platform
47+
* device and pass that screen_info as platform_data to a driver
48+
* that can scan-out using the system provided framebuffer.
49+
*/
50+
if (sysfb_handles_screen_info())
51+
return -ENODEV;
52+
3953
if (!fb->physical_address)
4054
return -ENODEV;
4155

drivers/firmware/google/gsmi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,8 @@ static __init int gsmi_init(void)
918918
gsmi_dev.pdev = platform_device_register_full(&gsmi_dev_info);
919919
if (IS_ERR(gsmi_dev.pdev)) {
920920
printk(KERN_ERR "gsmi: unable to register platform device\n");
921-
return PTR_ERR(gsmi_dev.pdev);
921+
ret = PTR_ERR(gsmi_dev.pdev);
922+
goto out_unregister;
922923
}
923924

924925
/* SMI access needs to be serialized */
@@ -1056,10 +1057,11 @@ static __init int gsmi_init(void)
10561057
gsmi_buf_free(gsmi_dev.name_buf);
10571058
kmem_cache_destroy(gsmi_dev.mem_pool);
10581059
platform_device_unregister(gsmi_dev.pdev);
1059-
pr_info("gsmi: failed to load: %d\n", ret);
1060+
out_unregister:
10601061
#ifdef CONFIG_PM
10611062
platform_driver_unregister(&gsmi_driver_info);
10621063
#endif
1064+
pr_info("gsmi: failed to load: %d\n", ret);
10631065
return ret;
10641066
}
10651067

drivers/firmware/sysfb.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,25 @@ void sysfb_disable(struct device *dev)
7979
}
8080
EXPORT_SYMBOL_GPL(sysfb_disable);
8181

82+
/**
83+
* sysfb_handles_screen_info() - reports if sysfb handles the global screen_info
84+
*
85+
* Callers can use sysfb_handles_screen_info() to determine whether the Generic
86+
* System Framebuffers (sysfb) can handle the global screen_info data structure
87+
* or not. Drivers might need this information to know if they have to setup the
88+
* system framebuffer, or if they have to delegate this action to sysfb instead.
89+
*
90+
* Returns:
91+
* True if sysfb handles the global screen_info data structure.
92+
*/
93+
bool sysfb_handles_screen_info(void)
94+
{
95+
const struct screen_info *si = &screen_info;
96+
97+
return !!screen_info_video_type(si);
98+
}
99+
EXPORT_SYMBOL_GPL(sysfb_handles_screen_info);
100+
82101
#if defined(CONFIG_PCI)
83102
static bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev)
84103
{

include/linux/sysfb.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,19 @@ struct efifb_dmi_info {
6060

6161
void sysfb_disable(struct device *dev);
6262

63+
bool sysfb_handles_screen_info(void);
64+
6365
#else /* CONFIG_SYSFB */
6466

6567
static inline void sysfb_disable(struct device *dev)
6668
{
6769
}
6870

71+
static inline bool sysfb_handles_screen_info(void)
72+
{
73+
return false;
74+
}
75+
6976
#endif /* CONFIG_SYSFB */
7077

7178
#ifdef CONFIG_EFI

0 commit comments

Comments
 (0)