Skip to content

Commit ac23d3c

Browse files
yishimatsudavem330
authored andcommitted
fjes: Do not load fjes driver if system does not have extended socket device.
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 a check that the server has a extended socket device or not. Signed-off-by: Yasuaki Ishimatsu <[email protected]> CC: Taku Izumi <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent efad54a commit ac23d3c

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

drivers/net/fjes/fjes_main.c

Lines changed: 47 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,21 @@ 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 fjes_acpi_add(struct acpi_device *device)
148+
{
149+
struct platform_device *plat_dev;
150+
acpi_status status;
151+
152+
if (!is_extended_socket_device(device))
153+
return -ENODEV;
154+
143155
status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
144156
fjes_get_acpi_resource, fjes_resource);
145157
if (ACPI_FAILURE(status))
@@ -1473,11 +1485,41 @@ static void fjes_watch_unshare_task(struct work_struct *work)
14731485
}
14741486
}
14751487

1488+
static acpi_status
1489+
acpi_find_extended_socket_device(acpi_handle obj_handle, u32 level,
1490+
void *context, void **return_value)
1491+
{
1492+
struct acpi_device *device;
1493+
bool *found = context;
1494+
int result;
1495+
1496+
result = acpi_bus_get_device(obj_handle, &device);
1497+
if (result)
1498+
return AE_OK;
1499+
1500+
if (strcmp(acpi_device_hid(device), ACPI_MOTHERBOARD_RESOURCE_HID))
1501+
return AE_OK;
1502+
1503+
if (!is_extended_socket_device(device))
1504+
return AE_OK;
1505+
1506+
*found = true;
1507+
return AE_CTRL_TERMINATE;
1508+
}
1509+
14761510
/* fjes_init_module - Driver Registration Routine */
14771511
static int __init fjes_init_module(void)
14781512
{
1513+
bool found = false;
14791514
int result;
14801515

1516+
acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1517+
acpi_find_extended_socket_device, NULL, &found,
1518+
NULL);
1519+
1520+
if (!found)
1521+
return -ENODEV;
1522+
14811523
pr_info("%s - version %s - %s\n",
14821524
fjes_driver_string, fjes_driver_version, fjes_copyright);
14831525

0 commit comments

Comments
 (0)