Skip to content

Commit 1b33c0d

Browse files
committed
Merge branch 'fjes-fixes'
YASUAKI ISHIMATSU says: ==================== fjes: Do not load fjes driver The fjes driver is used only by FUJITSU servers and almost of all servers in the world never use it. But currently if ACPI PNP0C02 is defined in the ACPI table, the following message is always shown: "FUJITSU Extended Socket Network Device Driver - version 1.2 - Copyright (c) 2015 FUJITSU LIMITED" The message makes users confused because there is no reason that the message is shown in other vendor servers. To avoid the confusion, the patch adds several checks. v3: - Rebase on latest net tree. - Add _STA method check to avoid loading fjes driver. v2: - Order local variable declarations from longest to shortest line ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents efad54a + 2b396d3 commit 1b33c0d

File tree

1 file changed

+71
-5
lines changed

1 file changed

+71
-5
lines changed

drivers/net/fjes/fjes_main.c

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ MODULE_DESCRIPTION("FUJITSU Extended Socket Network Device Driver");
4545
MODULE_LICENSE("GPL");
4646
MODULE_VERSION(DRV_VERSION);
4747

48+
#define ACPI_MOTHERBOARD_RESOURCE_HID "PNP0C02"
49+
4850
static int fjes_request_irq(struct fjes_adapter *);
4951
static void fjes_free_irq(struct fjes_adapter *);
5052

@@ -78,7 +80,7 @@ static void fjes_rx_irq(struct fjes_adapter *, int);
7880
static int fjes_poll(struct napi_struct *, int);
7981

8082
static const struct acpi_device_id fjes_acpi_ids[] = {
81-
{"PNP0C02", 0},
83+
{ACPI_MOTHERBOARD_RESOURCE_HID, 0},
8284
{"", 0},
8385
};
8486
MODULE_DEVICE_TABLE(acpi, fjes_acpi_ids);
@@ -115,18 +117,17 @@ static struct resource fjes_resource[] = {
115117
},
116118
};
117119

118-
static int fjes_acpi_add(struct acpi_device *device)
120+
static bool is_extended_socket_device(struct acpi_device *device)
119121
{
120122
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL};
121123
char str_buf[sizeof(FJES_ACPI_SYMBOL) + 1];
122-
struct platform_device *plat_dev;
123124
union acpi_object *str;
124125
acpi_status status;
125126
int result;
126127

127128
status = acpi_evaluate_object(device->handle, "_STR", NULL, &buffer);
128129
if (ACPI_FAILURE(status))
129-
return -ENODEV;
130+
return false;
130131

131132
str = buffer.pointer;
132133
result = utf16s_to_utf8s((wchar_t *)str->string.pointer,
@@ -136,10 +137,42 @@ static int fjes_acpi_add(struct acpi_device *device)
136137

137138
if (strncmp(FJES_ACPI_SYMBOL, str_buf, strlen(FJES_ACPI_SYMBOL)) != 0) {
138139
kfree(buffer.pointer);
139-
return -ENODEV;
140+
return false;
140141
}
141142
kfree(buffer.pointer);
142143

144+
return true;
145+
}
146+
147+
static int acpi_check_extended_socket_status(struct acpi_device *device)
148+
{
149+
unsigned long long sta;
150+
acpi_status status;
151+
152+
status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
153+
if (ACPI_FAILURE(status))
154+
return -ENODEV;
155+
156+
if (!((sta & ACPI_STA_DEVICE_PRESENT) &&
157+
(sta & ACPI_STA_DEVICE_ENABLED) &&
158+
(sta & ACPI_STA_DEVICE_UI) &&
159+
(sta & ACPI_STA_DEVICE_FUNCTIONING)))
160+
return -ENODEV;
161+
162+
return 0;
163+
}
164+
165+
static int fjes_acpi_add(struct acpi_device *device)
166+
{
167+
struct platform_device *plat_dev;
168+
acpi_status status;
169+
170+
if (!is_extended_socket_device(device))
171+
return -ENODEV;
172+
173+
if (acpi_check_extended_socket_status(device))
174+
return -ENODEV;
175+
143176
status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
144177
fjes_get_acpi_resource, fjes_resource);
145178
if (ACPI_FAILURE(status))
@@ -1473,11 +1506,44 @@ static void fjes_watch_unshare_task(struct work_struct *work)
14731506
}
14741507
}
14751508

1509+
static acpi_status
1510+
acpi_find_extended_socket_device(acpi_handle obj_handle, u32 level,
1511+
void *context, void **return_value)
1512+
{
1513+
struct acpi_device *device;
1514+
bool *found = context;
1515+
int result;
1516+
1517+
result = acpi_bus_get_device(obj_handle, &device);
1518+
if (result)
1519+
return AE_OK;
1520+
1521+
if (strcmp(acpi_device_hid(device), ACPI_MOTHERBOARD_RESOURCE_HID))
1522+
return AE_OK;
1523+
1524+
if (!is_extended_socket_device(device))
1525+
return AE_OK;
1526+
1527+
if (acpi_check_extended_socket_status(device))
1528+
return AE_OK;
1529+
1530+
*found = true;
1531+
return AE_CTRL_TERMINATE;
1532+
}
1533+
14761534
/* fjes_init_module - Driver Registration Routine */
14771535
static int __init fjes_init_module(void)
14781536
{
1537+
bool found = false;
14791538
int result;
14801539

1540+
acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1541+
acpi_find_extended_socket_device, NULL, &found,
1542+
NULL);
1543+
1544+
if (!found)
1545+
return -ENODEV;
1546+
14811547
pr_info("%s - version %s - %s\n",
14821548
fjes_driver_string, fjes_driver_version, fjes_copyright);
14831549

0 commit comments

Comments
 (0)