aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpacpi/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/pnpacpi/core.c')
-rw-r--r--drivers/pnp/pnpacpi/core.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 86aea1ebfee..fd3fca6dddd 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -152,7 +152,6 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
152{ 152{
153 acpi_handle temp = NULL; 153 acpi_handle temp = NULL;
154 acpi_status status; 154 acpi_status status;
155 struct pnp_id *dev_id;
156 struct pnp_dev *dev; 155 struct pnp_dev *dev;
157 156
158 status = acpi_get_handle(device->handle, "_CRS", &temp); 157 status = acpi_get_handle(device->handle, "_CRS", &temp);
@@ -160,11 +159,10 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
160 is_exclusive_device(device)) 159 is_exclusive_device(device))
161 return 0; 160 return 0;
162 161
163 dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); 162 dev = pnp_alloc_dev(&pnpacpi_protocol, num, acpi_device_hid(device));
164 if (!dev) { 163 if (!dev)
165 pnp_err("Out of memory");
166 return -ENOMEM; 164 return -ENOMEM;
167 } 165
168 dev->data = device->handle; 166 dev->data = device->handle;
169 /* .enabled means the device can decode the resources */ 167 /* .enabled means the device can decode the resources */
170 dev->active = device->status.enabled; 168 dev->active = device->status.enabled;
@@ -180,19 +178,11 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
180 if (ACPI_SUCCESS(status)) 178 if (ACPI_SUCCESS(status))
181 dev->capabilities |= PNP_DISABLE; 179 dev->capabilities |= PNP_DISABLE;
182 180
183 dev->protocol = &pnpacpi_protocol;
184
185 if (strlen(acpi_device_name(device))) 181 if (strlen(acpi_device_name(device)))
186 strncpy(dev->name, acpi_device_name(device), sizeof(dev->name)); 182 strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
187 else 183 else
188 strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name)); 184 strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
189 185
190 dev->number = num;
191
192 dev_id = pnp_add_id(dev, acpi_device_hid(device));
193 if (!dev_id)
194 goto err;
195
196 if (dev->active) { 186 if (dev->active) {
197 /* parse allocated resource */ 187 /* parse allocated resource */
198 status = pnpacpi_parse_allocated_resource(device->handle, 188 status = pnpacpi_parse_allocated_resource(device->handle,
@@ -230,9 +220,6 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
230 num++; 220 num++;
231 221
232 return AE_OK; 222 return AE_OK;
233err:
234 kfree(dev);
235 return -EINVAL;
236} 223}
237 224
238static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, 225static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,