Skip to content

Commit 36f20ee

Browse files
committed
Merge tag 'platform-drivers-x86-v4.15-2' of git://git.infradead.org/linux-platform-drivers-x86
Pull x86 platform driver fixes from Darren Hart: "Fix two issues resulting from the dell-smbios refactoring and introduction of the dell-smbios-wmi dispatcher. The first ensures a proper error code is returned when kzalloc fails. The second avoids an issue in older Dell BIOS implementations which would fail if the more complex calls were made by limiting those platforms to the simple calls such as those used by the existing dell-laptop and dell-wmi drivers, preserving their functionality prior to the addition of the dell-smbios-wmi dispatcher" * tag 'platform-drivers-x86-v4.15-2' of git://git.infradead.org/linux-platform-drivers-x86: platform/x86: dell-laptop: fix error return code in dell_init() platform/x86: dell-smbios-wmi: Disable userspace interface if missing hotfix
2 parents 06c9440 + c6f9288 commit 36f20ee

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

drivers/platform/x86/dell-laptop.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,8 +2074,10 @@ static int __init dell_init(void)
20742074
goto fail_platform_device2;
20752075

20762076
buffer = kzalloc(sizeof(struct calling_interface_buffer), GFP_KERNEL);
2077-
if (!buffer)
2077+
if (!buffer) {
2078+
ret = -ENOMEM;
20782079
goto fail_buffer;
2080+
}
20792081

20802082

20812083
ret = dell_setup_rfkill();

drivers/platform/x86/dell-smbios-wmi.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ static long dell_smbios_wmi_filter(struct wmi_device *wdev, unsigned int cmd,
147147

148148
static int dell_smbios_wmi_probe(struct wmi_device *wdev)
149149
{
150+
struct wmi_driver *wdriver =
151+
container_of(wdev->dev.driver, struct wmi_driver, driver);
150152
struct wmi_smbios_priv *priv;
153+
u32 hotfix;
151154
int count;
152155
int ret;
153156

@@ -164,6 +167,16 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev)
164167
if (!dell_wmi_get_size(&priv->req_buf_size))
165168
return -EPROBE_DEFER;
166169

170+
/* some SMBIOS calls fail unless BIOS contains hotfix */
171+
if (!dell_wmi_get_hotfix(&hotfix))
172+
return -EPROBE_DEFER;
173+
if (!hotfix) {
174+
dev_warn(&wdev->dev,
175+
"WMI SMBIOS userspace interface not supported(%u), try upgrading to a newer BIOS\n",
176+
hotfix);
177+
wdriver->filter_callback = NULL;
178+
}
179+
167180
/* add in the length object we will use internally with ioctl */
168181
priv->req_buf_size += sizeof(u64);
169182
ret = set_required_buffer_size(wdev, priv->req_buf_size);

drivers/platform/x86/dell-wmi-descriptor.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct descriptor_priv {
2727
struct list_head list;
2828
u32 interface_version;
2929
u32 size;
30+
u32 hotfix;
3031
};
3132
static int descriptor_valid = -EPROBE_DEFER;
3233
static LIST_HEAD(wmi_list);
@@ -77,6 +78,24 @@ bool dell_wmi_get_size(u32 *size)
7778
}
7879
EXPORT_SYMBOL_GPL(dell_wmi_get_size);
7980

81+
bool dell_wmi_get_hotfix(u32 *hotfix)
82+
{
83+
struct descriptor_priv *priv;
84+
bool ret = false;
85+
86+
mutex_lock(&list_mutex);
87+
priv = list_first_entry_or_null(&wmi_list,
88+
struct descriptor_priv,
89+
list);
90+
if (priv) {
91+
*hotfix = priv->hotfix;
92+
ret = true;
93+
}
94+
mutex_unlock(&list_mutex);
95+
return ret;
96+
}
97+
EXPORT_SYMBOL_GPL(dell_wmi_get_hotfix);
98+
8099
/*
81100
* Descriptor buffer is 128 byte long and contains:
82101
*
@@ -85,6 +104,7 @@ EXPORT_SYMBOL_GPL(dell_wmi_get_size);
85104
* Object Signature 4 4 " WMI"
86105
* WMI Interface Version 8 4 <version>
87106
* WMI buffer length 12 4 <length>
107+
* WMI hotfix number 16 4 <hotfix>
88108
*/
89109
static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
90110
{
@@ -144,15 +164,17 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
144164

145165
priv->interface_version = buffer[2];
146166
priv->size = buffer[3];
167+
priv->hotfix = buffer[4];
147168
ret = 0;
148169
dev_set_drvdata(&wdev->dev, priv);
149170
mutex_lock(&list_mutex);
150171
list_add_tail(&priv->list, &wmi_list);
151172
mutex_unlock(&list_mutex);
152173

153-
dev_dbg(&wdev->dev, "Detected Dell WMI interface version %lu and buffer size %lu\n",
174+
dev_dbg(&wdev->dev, "Detected Dell WMI interface version %lu, buffer size %lu, hotfix %lu\n",
154175
(unsigned long) priv->interface_version,
155-
(unsigned long) priv->size);
176+
(unsigned long) priv->size,
177+
(unsigned long) priv->hotfix);
156178

157179
out:
158180
kfree(obj);

drivers/platform/x86/dell-wmi-descriptor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ int dell_wmi_get_descriptor_valid(void);
2323

2424
bool dell_wmi_get_interface_version(u32 *version);
2525
bool dell_wmi_get_size(u32 *size);
26+
bool dell_wmi_get_hotfix(u32 *hotfix);
2627

2728
#endif

0 commit comments

Comments
 (0)