Blame view
drivers/firmware/dcdbas.c
15.9 KB
90563ec41 [PATCH] dcdbas: a... |
1 2 3 4 5 6 7 8 9 10 |
/* * dcdbas.c: Dell Systems Management Base Driver * * The Dell Systems Management Base Driver provides a sysfs interface for * systems management software to perform System Management Interrupts (SMIs) * and Host Control Actions (power cycle or power off after OS shutdown) on * Dell systems. * * See Documentation/dcdbas.txt for more information. * |
b95936cb9 [PATCH] firmware/... |
11 |
* Copyright (C) 1995-2006 Dell Inc. |
90563ec41 [PATCH] dcdbas: a... |
12 13 14 15 16 17 18 19 20 21 |
* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License v2.0 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ |
d052d1bef Create platform_d... |
22 |
#include <linux/platform_device.h> |
90563ec41 [PATCH] dcdbas: a... |
23 24 |
#include <linux/dma-mapping.h> #include <linux/errno.h> |
5a0e3ad6a include cleanup: ... |
25 |
#include <linux/gfp.h> |
90563ec41 [PATCH] dcdbas: a... |
26 27 28 29 30 31 32 33 34 35 |
#include <linux/init.h> #include <linux/kernel.h> #include <linux/mc146818rtc.h> #include <linux/module.h> #include <linux/reboot.h> #include <linux/sched.h> #include <linux/smp.h> #include <linux/spinlock.h> #include <linux/string.h> #include <linux/types.h> |
8ed965d61 [PATCH] sem2mutex... |
36 |
#include <linux/mutex.h> |
90563ec41 [PATCH] dcdbas: a... |
37 |
#include <asm/io.h> |
90563ec41 [PATCH] dcdbas: a... |
38 39 40 41 |
#include "dcdbas.h" #define DRIVER_NAME "dcdbas" |
b95936cb9 [PATCH] firmware/... |
42 |
#define DRIVER_VERSION "5.6.0-3.2" |
90563ec41 [PATCH] dcdbas: a... |
43 44 45 46 47 48 49 50 |
#define DRIVER_DESCRIPTION "Dell Systems Management Base Driver" static struct platform_device *dcdbas_pdev; static u8 *smi_data_buf; static dma_addr_t smi_data_buf_handle; static unsigned long smi_data_buf_size; static u32 smi_data_buf_phys_addr; |
8ed965d61 [PATCH] sem2mutex... |
51 |
static DEFINE_MUTEX(smi_data_lock); |
90563ec41 [PATCH] dcdbas: a... |
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
static unsigned int host_control_action; static unsigned int host_control_smi_type; static unsigned int host_control_on_shutdown; /** * smi_data_buf_free: free SMI data buffer */ static void smi_data_buf_free(void) { if (!smi_data_buf) return; dev_dbg(&dcdbas_pdev->dev, "%s: phys: %x size: %lu ", |
eecd58536 firmware: replace... |
67 |
__func__, smi_data_buf_phys_addr, smi_data_buf_size); |
90563ec41 [PATCH] dcdbas: a... |
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
dma_free_coherent(&dcdbas_pdev->dev, smi_data_buf_size, smi_data_buf, smi_data_buf_handle); smi_data_buf = NULL; smi_data_buf_handle = 0; smi_data_buf_phys_addr = 0; smi_data_buf_size = 0; } /** * smi_data_buf_realloc: grow SMI data buffer if needed */ static int smi_data_buf_realloc(unsigned long size) { void *buf; dma_addr_t handle; if (smi_data_buf_size >= size) return 0; if (size > MAX_SMI_DATA_BUF_SIZE) return -EINVAL; /* new buffer is needed */ buf = dma_alloc_coherent(&dcdbas_pdev->dev, size, &handle, GFP_KERNEL); if (!buf) { dev_dbg(&dcdbas_pdev->dev, "%s: failed to allocate memory size %lu ", |
eecd58536 firmware: replace... |
97 |
__func__, size); |
90563ec41 [PATCH] dcdbas: a... |
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
return -ENOMEM; } /* memory zeroed by dma_alloc_coherent */ if (smi_data_buf) memcpy(buf, smi_data_buf, smi_data_buf_size); /* free any existing buffer */ smi_data_buf_free(); /* set up new buffer for use */ smi_data_buf = buf; smi_data_buf_handle = handle; smi_data_buf_phys_addr = (u32) virt_to_phys(buf); smi_data_buf_size = size; dev_dbg(&dcdbas_pdev->dev, "%s: phys: %x size: %lu ", |
eecd58536 firmware: replace... |
116 |
__func__, smi_data_buf_phys_addr, smi_data_buf_size); |
90563ec41 [PATCH] dcdbas: a... |
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
return 0; } static ssize_t smi_data_buf_phys_addr_show(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%x ", smi_data_buf_phys_addr); } static ssize_t smi_data_buf_size_show(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%lu ", smi_data_buf_size); } static ssize_t smi_data_buf_size_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned long buf_size; ssize_t ret; buf_size = simple_strtoul(buf, NULL, 10); /* make sure SMI data buffer is at least buf_size */ |
8ed965d61 [PATCH] sem2mutex... |
147 |
mutex_lock(&smi_data_lock); |
90563ec41 [PATCH] dcdbas: a... |
148 |
ret = smi_data_buf_realloc(buf_size); |
8ed965d61 [PATCH] sem2mutex... |
149 |
mutex_unlock(&smi_data_lock); |
90563ec41 [PATCH] dcdbas: a... |
150 151 152 153 154 |
if (ret) return ret; return count; } |
2c3c8bea6 sysfs: add struct... |
155 |
static ssize_t smi_data_read(struct file *filp, struct kobject *kobj, |
91a690295 sysfs: add parame... |
156 157 |
struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count) |
90563ec41 [PATCH] dcdbas: a... |
158 |
{ |
90563ec41 [PATCH] dcdbas: a... |
159 |
ssize_t ret; |
8ed965d61 [PATCH] sem2mutex... |
160 |
mutex_lock(&smi_data_lock); |
abe19b7b8 dcdbas: use memor... |
161 162 |
ret = memory_read_from_buffer(buf, count, &pos, smi_data_buf, smi_data_buf_size); |
8ed965d61 [PATCH] sem2mutex... |
163 |
mutex_unlock(&smi_data_lock); |
90563ec41 [PATCH] dcdbas: a... |
164 165 |
return ret; } |
2c3c8bea6 sysfs: add struct... |
166 |
static ssize_t smi_data_write(struct file *filp, struct kobject *kobj, |
91a690295 sysfs: add parame... |
167 168 |
struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count) |
90563ec41 [PATCH] dcdbas: a... |
169 170 |
{ ssize_t ret; |
b95936cb9 [PATCH] firmware/... |
171 172 |
if ((pos + count) > MAX_SMI_DATA_BUF_SIZE) return -EINVAL; |
8ed965d61 [PATCH] sem2mutex... |
173 |
mutex_lock(&smi_data_lock); |
90563ec41 [PATCH] dcdbas: a... |
174 175 176 177 178 179 180 181 |
ret = smi_data_buf_realloc(pos + count); if (ret) goto out; memcpy(smi_data_buf + pos, buf, count); ret = count; out: |
8ed965d61 [PATCH] sem2mutex... |
182 |
mutex_unlock(&smi_data_lock); |
90563ec41 [PATCH] dcdbas: a... |
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
return ret; } static ssize_t host_control_action_show(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%u ", host_control_action); } static ssize_t host_control_action_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { ssize_t ret; /* make sure buffer is available for host control command */ |
8ed965d61 [PATCH] sem2mutex... |
201 |
mutex_lock(&smi_data_lock); |
90563ec41 [PATCH] dcdbas: a... |
202 |
ret = smi_data_buf_realloc(sizeof(struct apm_cmd)); |
8ed965d61 [PATCH] sem2mutex... |
203 |
mutex_unlock(&smi_data_lock); |
90563ec41 [PATCH] dcdbas: a... |
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
if (ret) return ret; host_control_action = simple_strtoul(buf, NULL, 10); return count; } static ssize_t host_control_smi_type_show(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%u ", host_control_smi_type); } static ssize_t host_control_smi_type_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { host_control_smi_type = simple_strtoul(buf, NULL, 10); return count; } static ssize_t host_control_on_shutdown_show(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%u ", host_control_on_shutdown); } static ssize_t host_control_on_shutdown_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { host_control_on_shutdown = simple_strtoul(buf, NULL, 10); return count; } /** |
3cab7fd96 dcdbas: export fu... |
244 |
* dcdbas_smi_request: generate SMI request |
90563ec41 [PATCH] dcdbas: a... |
245 246 247 |
* * Called with smi_data_lock. */ |
3cab7fd96 dcdbas: export fu... |
248 |
int dcdbas_smi_request(struct smi_cmd *smi_cmd) |
90563ec41 [PATCH] dcdbas: a... |
249 |
{ |
c90e785be cpumask: use cpum... |
250 |
cpumask_var_t old_mask; |
90563ec41 [PATCH] dcdbas: a... |
251 252 253 254 255 |
int ret = 0; if (smi_cmd->magic != SMI_CMD_MAGIC) { dev_info(&dcdbas_pdev->dev, "%s: invalid magic value ", |
eecd58536 firmware: replace... |
256 |
__func__); |
90563ec41 [PATCH] dcdbas: a... |
257 258 259 260 |
return -EBADR; } /* SMI requires CPU 0 */ |
c90e785be cpumask: use cpum... |
261 262 263 264 265 |
if (!alloc_cpumask_var(&old_mask, GFP_KERNEL)) return -ENOMEM; cpumask_copy(old_mask, ¤t->cpus_allowed); set_cpus_allowed_ptr(current, cpumask_of(0)); |
90563ec41 [PATCH] dcdbas: a... |
266 267 268 |
if (smp_processor_id() != 0) { dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0 ", |
eecd58536 firmware: replace... |
269 |
__func__); |
90563ec41 [PATCH] dcdbas: a... |
270 271 272 273 274 |
ret = -EBUSY; goto out; } /* generate SMI */ |
dd65c736d dcdbas: force SMI... |
275 |
/* inb to force posted write through and make SMI happen now */ |
90563ec41 [PATCH] dcdbas: a... |
276 |
asm volatile ( |
dd65c736d dcdbas: force SMI... |
277 278 279 |
"outb %b0,%w1 " "inb %w1" |
90563ec41 [PATCH] dcdbas: a... |
280 281 282 283 284 285 286 287 288 |
: /* no output args */ : "a" (smi_cmd->command_code), "d" (smi_cmd->command_address), "b" (smi_cmd->ebx), "c" (smi_cmd->ecx) : "memory" ); out: |
c90e785be cpumask: use cpum... |
289 290 |
set_cpus_allowed_ptr(current, old_mask); free_cpumask_var(old_mask); |
90563ec41 [PATCH] dcdbas: a... |
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
return ret; } /** * smi_request_store: * * The valid values are: * 0: zero SMI data buffer * 1: generate calling interface SMI * 2: generate raw SMI * * User application writes smi_cmd to smi_data before telling driver * to generate SMI. */ static ssize_t smi_request_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct smi_cmd *smi_cmd; unsigned long val = simple_strtoul(buf, NULL, 10); ssize_t ret; |
8ed965d61 [PATCH] sem2mutex... |
312 |
mutex_lock(&smi_data_lock); |
90563ec41 [PATCH] dcdbas: a... |
313 314 315 316 317 318 319 320 321 322 |
if (smi_data_buf_size < sizeof(struct smi_cmd)) { ret = -ENODEV; goto out; } smi_cmd = (struct smi_cmd *)smi_data_buf; switch (val) { case 2: /* Raw SMI */ |
3cab7fd96 dcdbas: export fu... |
323 |
ret = dcdbas_smi_request(smi_cmd); |
90563ec41 [PATCH] dcdbas: a... |
324 325 326 327 328 329 |
if (!ret) ret = count; break; case 1: /* Calling Interface SMI */ smi_cmd->ebx = (u32) virt_to_phys(smi_cmd->command_buffer); |
3cab7fd96 dcdbas: export fu... |
330 |
ret = dcdbas_smi_request(smi_cmd); |
90563ec41 [PATCH] dcdbas: a... |
331 332 333 334 335 336 337 338 339 340 341 342 343 |
if (!ret) ret = count; break; case 0: memset(smi_data_buf, 0, smi_data_buf_size); ret = count; break; default: ret = -EINVAL; break; } out: |
8ed965d61 [PATCH] sem2mutex... |
344 |
mutex_unlock(&smi_data_lock); |
90563ec41 [PATCH] dcdbas: a... |
345 346 |
return ret; } |
3cab7fd96 dcdbas: export fu... |
347 |
EXPORT_SYMBOL(dcdbas_smi_request); |
90563ec41 [PATCH] dcdbas: a... |
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
/** * host_control_smi: generate host control SMI * * Caller must set up the host control command in smi_data_buf. */ static int host_control_smi(void) { struct apm_cmd *apm_cmd; u8 *data; unsigned long flags; u32 num_ticks; s8 cmd_status; u8 index; apm_cmd = (struct apm_cmd *)smi_data_buf; apm_cmd->status = ESM_STATUS_CMD_UNSUCCESSFUL; switch (host_control_smi_type) { case HC_SMITYPE_TYPE1: spin_lock_irqsave(&rtc_lock, flags); /* write SMI data buffer physical address */ data = (u8 *)&smi_data_buf_phys_addr; for (index = PE1300_CMOS_CMD_STRUCT_PTR; index < (PE1300_CMOS_CMD_STRUCT_PTR + 4); index++, data++) { outb(index, (CMOS_BASE_PORT + CMOS_PAGE2_INDEX_PORT_PIIX4)); outb(*data, (CMOS_BASE_PORT + CMOS_PAGE2_DATA_PORT_PIIX4)); } /* first set status to -1 as called by spec */ cmd_status = ESM_STATUS_CMD_UNSUCCESSFUL; outb((u8) cmd_status, PCAT_APM_STATUS_PORT); /* generate SMM call */ outb(ESM_APM_CMD, PCAT_APM_CONTROL_PORT); spin_unlock_irqrestore(&rtc_lock, flags); /* wait a few to see if it executed */ num_ticks = TIMEOUT_USEC_SHORT_SEMA_BLOCKING; while ((cmd_status = inb(PCAT_APM_STATUS_PORT)) == ESM_STATUS_CMD_UNSUCCESSFUL) { num_ticks--; if (num_ticks == EXPIRED_TIMER) return -ETIME; } break; case HC_SMITYPE_TYPE2: case HC_SMITYPE_TYPE3: spin_lock_irqsave(&rtc_lock, flags); /* write SMI data buffer physical address */ data = (u8 *)&smi_data_buf_phys_addr; for (index = PE1400_CMOS_CMD_STRUCT_PTR; index < (PE1400_CMOS_CMD_STRUCT_PTR + 4); index++, data++) { outb(index, (CMOS_BASE_PORT + CMOS_PAGE1_INDEX_PORT)); outb(*data, (CMOS_BASE_PORT + CMOS_PAGE1_DATA_PORT)); } /* generate SMM call */ if (host_control_smi_type == HC_SMITYPE_TYPE3) outb(ESM_APM_CMD, PCAT_APM_CONTROL_PORT); else outb(ESM_APM_CMD, PE1400_APM_CONTROL_PORT); /* restore RTC index pointer since it was written to above */ CMOS_READ(RTC_REG_C); spin_unlock_irqrestore(&rtc_lock, flags); /* read control port back to serialize write */ cmd_status = inb(PE1400_APM_CONTROL_PORT); /* wait a few to see if it executed */ num_ticks = TIMEOUT_USEC_SHORT_SEMA_BLOCKING; while (apm_cmd->status == ESM_STATUS_CMD_UNSUCCESSFUL) { num_ticks--; if (num_ticks == EXPIRED_TIMER) return -ETIME; } break; default: dev_dbg(&dcdbas_pdev->dev, "%s: invalid SMI type %u ", |
eecd58536 firmware: replace... |
435 |
__func__, host_control_smi_type); |
90563ec41 [PATCH] dcdbas: a... |
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
return -ENOSYS; } return 0; } /** * dcdbas_host_control: initiate host control * * This function is called by the driver after the system has * finished shutting down if the user application specified a * host control action to perform on shutdown. It is safe to * use smi_data_buf at this point because the system has finished * shutting down and no userspace apps are running. */ static void dcdbas_host_control(void) { struct apm_cmd *apm_cmd; u8 action; if (host_control_action == HC_ACTION_NONE) return; action = host_control_action; host_control_action = HC_ACTION_NONE; if (!smi_data_buf) { |
eecd58536 firmware: replace... |
463 464 |
dev_dbg(&dcdbas_pdev->dev, "%s: no SMI buffer ", __func__); |
90563ec41 [PATCH] dcdbas: a... |
465 466 467 468 469 470 |
return; } if (smi_data_buf_size < sizeof(struct apm_cmd)) { dev_dbg(&dcdbas_pdev->dev, "%s: SMI buffer too small ", |
eecd58536 firmware: replace... |
471 |
__func__); |
90563ec41 [PATCH] dcdbas: a... |
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
return; } apm_cmd = (struct apm_cmd *)smi_data_buf; /* power off takes precedence */ if (action & HC_ACTION_HOST_CONTROL_POWEROFF) { apm_cmd->command = ESM_APM_POWER_CYCLE; apm_cmd->reserved = 0; *((s16 *)&apm_cmd->parameters.shortreq.parm[0]) = (s16) 0; host_control_smi(); } else if (action & HC_ACTION_HOST_CONTROL_POWERCYCLE) { apm_cmd->command = ESM_APM_POWER_CYCLE; apm_cmd->reserved = 0; *((s16 *)&apm_cmd->parameters.shortreq.parm[0]) = (s16) 20; host_control_smi(); } } /** * dcdbas_reboot_notify: handle reboot notification for host control */ static int dcdbas_reboot_notify(struct notifier_block *nb, unsigned long code, void *unused) { |
90563ec41 [PATCH] dcdbas: a... |
497 498 499 500 501 502 |
switch (code) { case SYS_DOWN: case SYS_HALT: case SYS_POWER_OFF: if (host_control_on_shutdown) { /* firmware is going to perform host control action */ |
e041c6834 [PATCH] Notifier ... |
503 504 505 506 |
printk(KERN_WARNING "Please wait for shutdown " "action to complete... "); dcdbas_host_control(); |
90563ec41 [PATCH] dcdbas: a... |
507 508 509 510 511 512 513 514 515 516 |
} break; } return NOTIFY_DONE; } static struct notifier_block dcdbas_reboot_nb = { .notifier_call = dcdbas_reboot_notify, .next = NULL, |
e041c6834 [PATCH] Notifier ... |
517 |
.priority = INT_MIN |
90563ec41 [PATCH] dcdbas: a... |
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
}; static DCDBAS_BIN_ATTR_RW(smi_data); static struct bin_attribute *dcdbas_bin_attrs[] = { &bin_attr_smi_data, NULL }; static DCDBAS_DEV_ATTR_RW(smi_data_buf_size); static DCDBAS_DEV_ATTR_RO(smi_data_buf_phys_addr); static DCDBAS_DEV_ATTR_WO(smi_request); static DCDBAS_DEV_ATTR_RW(host_control_action); static DCDBAS_DEV_ATTR_RW(host_control_smi_type); static DCDBAS_DEV_ATTR_RW(host_control_on_shutdown); |
a7f3ea728 [PATCH] dcdbas: c... |
533 534 535 536 537 538 539 |
static struct attribute *dcdbas_dev_attrs[] = { &dev_attr_smi_data_buf_size.attr, &dev_attr_smi_data_buf_phys_addr.attr, &dev_attr_smi_request.attr, &dev_attr_host_control_action.attr, &dev_attr_host_control_smi_type.attr, &dev_attr_host_control_on_shutdown.attr, |
90563ec41 [PATCH] dcdbas: a... |
540 541 |
NULL }; |
a7f3ea728 [PATCH] dcdbas: c... |
542 543 544 545 546 |
static struct attribute_group dcdbas_attr_group = { .attrs = dcdbas_dev_attrs, }; static int __devinit dcdbas_probe(struct platform_device *dev) |
90563ec41 [PATCH] dcdbas: a... |
547 |
{ |
a7f3ea728 [PATCH] dcdbas: c... |
548 |
int i, error; |
90563ec41 [PATCH] dcdbas: a... |
549 550 551 |
host_control_action = HC_ACTION_NONE; host_control_smi_type = HC_SMITYPE_NONE; |
90563ec41 [PATCH] dcdbas: a... |
552 553 554 555 |
/* * BIOS SMI calls require buffer addresses be in 32-bit address space. * This is done by setting the DMA mask below. */ |
284901a90 dma-mapping: repl... |
556 |
dcdbas_pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); |
90563ec41 [PATCH] dcdbas: a... |
557 |
dcdbas_pdev->dev.dma_mask = &dcdbas_pdev->dev.coherent_dma_mask; |
a7f3ea728 [PATCH] dcdbas: c... |
558 559 560 561 562 563 564 565 566 567 568 |
error = sysfs_create_group(&dev->dev.kobj, &dcdbas_attr_group); if (error) return error; for (i = 0; dcdbas_bin_attrs[i]; i++) { error = sysfs_create_bin_file(&dev->dev.kobj, dcdbas_bin_attrs[i]); if (error) { while (--i >= 0) sysfs_remove_bin_file(&dev->dev.kobj, dcdbas_bin_attrs[i]); |
0968cf51b [PATCH] firmware/... |
569 |
sysfs_remove_group(&dev->dev.kobj, &dcdbas_attr_group); |
a7f3ea728 [PATCH] dcdbas: c... |
570 571 572 |
return error; } } |
90563ec41 [PATCH] dcdbas: a... |
573 |
register_reboot_notifier(&dcdbas_reboot_nb); |
a7f3ea728 [PATCH] dcdbas: c... |
574 575 576 577 578 579 580 581 582 583 584 585 |
dev_info(&dev->dev, "%s (version %s) ", DRIVER_DESCRIPTION, DRIVER_VERSION); return 0; } static int __devexit dcdbas_remove(struct platform_device *dev) { int i; unregister_reboot_notifier(&dcdbas_reboot_nb); |
90563ec41 [PATCH] dcdbas: a... |
586 |
for (i = 0; dcdbas_bin_attrs[i]; i++) |
a7f3ea728 [PATCH] dcdbas: c... |
587 588 |
sysfs_remove_bin_file(&dev->dev.kobj, dcdbas_bin_attrs[i]); sysfs_remove_group(&dev->dev.kobj, &dcdbas_attr_group); |
90563ec41 [PATCH] dcdbas: a... |
589 |
|
a7f3ea728 [PATCH] dcdbas: c... |
590 591 |
return 0; } |
90563ec41 [PATCH] dcdbas: a... |
592 |
|
a7f3ea728 [PATCH] dcdbas: c... |
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 |
static struct platform_driver dcdbas_driver = { .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, }, .probe = dcdbas_probe, .remove = __devexit_p(dcdbas_remove), }; /** * dcdbas_init: initialize driver */ static int __init dcdbas_init(void) { int error; error = platform_driver_register(&dcdbas_driver); if (error) return error; dcdbas_pdev = platform_device_alloc(DRIVER_NAME, -1); if (!dcdbas_pdev) { error = -ENOMEM; goto err_unregister_driver; } error = platform_device_add(dcdbas_pdev); if (error) goto err_free_device; |
90563ec41 [PATCH] dcdbas: a... |
622 623 |
return 0; |
a7f3ea728 [PATCH] dcdbas: c... |
624 625 626 627 628 629 |
err_free_device: platform_device_put(dcdbas_pdev); err_unregister_driver: platform_driver_unregister(&dcdbas_driver); return error; |
90563ec41 [PATCH] dcdbas: a... |
630 631 632 633 634 635 636 |
} /** * dcdbas_exit: perform driver cleanup */ static void __exit dcdbas_exit(void) { |
435a80f61 [PATCH] dcdbas: d... |
637 638 639 640 |
/* * make sure functions that use dcdbas_pdev are called * before platform_device_unregister */ |
90563ec41 [PATCH] dcdbas: a... |
641 |
unregister_reboot_notifier(&dcdbas_reboot_nb); |
a7f3ea728 [PATCH] dcdbas: c... |
642 643 644 645 646 647 648 649 |
/* * We have to free the buffer here instead of dcdbas_remove * because only in module exit function we can be sure that * all sysfs attributes belonging to this module have been * released. */ smi_data_buf_free(); |
e3ed249af dcdbas: remove a ... |
650 651 |
platform_device_unregister(dcdbas_pdev); platform_driver_unregister(&dcdbas_driver); |
90563ec41 [PATCH] dcdbas: a... |
652 653 654 655 656 657 658 659 660 |
} module_init(dcdbas_init); module_exit(dcdbas_exit); MODULE_DESCRIPTION(DRIVER_DESCRIPTION " (version " DRIVER_VERSION ")"); MODULE_VERSION(DRIVER_VERSION); MODULE_AUTHOR("Dell Inc."); MODULE_LICENSE("GPL"); |
8f47f0b68 dcdbas: add DMI-b... |
661 662 |
/* Any System or BIOS claiming to be by Dell */ MODULE_ALIAS("dmi:*:[bs]vnD[Ee][Ll][Ll]*:*"); |