pciehp_ctrl.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. /*
  2. * PCI Express Hot Plug Controller Driver
  3. *
  4. * Copyright (C) 1995,2001 Compaq Computer Corporation
  5. * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
  6. * Copyright (C) 2001 IBM Corp.
  7. * Copyright (C) 2003-2004 Intel Corporation
  8. *
  9. * All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or (at
  14. * your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  19. * NON INFRINGEMENT. See the GNU General Public License for more
  20. * details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25. *
  26. * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
  27. *
  28. */
  29. #include <linux/module.h>
  30. #include <linux/kernel.h>
  31. #include <linux/types.h>
  32. #include <linux/smp_lock.h>
  33. #include <linux/pci.h>
  34. #include <linux/workqueue.h>
  35. #include "../pci.h"
  36. #include "pciehp.h"
  37. static void interrupt_event_handler(struct work_struct *work);
  38. static int pciehp_enable_slot(struct slot *p_slot);
  39. static int pciehp_disable_slot(struct slot *p_slot);
  40. static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
  41. {
  42. struct event_info *info;
  43. info = kmalloc(sizeof(*info), GFP_ATOMIC);
  44. if (!info)
  45. return -ENOMEM;
  46. info->event_type = event_type;
  47. info->p_slot = p_slot;
  48. INIT_WORK(&info->work, interrupt_event_handler);
  49. schedule_work(&info->work);
  50. return 0;
  51. }
  52. u8 pciehp_handle_attention_button(u8 hp_slot, struct controller *ctrl)
  53. {
  54. struct slot *p_slot;
  55. u32 event_type;
  56. /* Attention Button Change */
  57. dbg("pciehp: Attention button interrupt received.\n");
  58. p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
  59. /*
  60. * Button pressed - See if need to TAKE ACTION!!!
  61. */
  62. info("Button pressed on Slot(%s)\n", p_slot->name);
  63. event_type = INT_BUTTON_PRESS;
  64. queue_interrupt_event(p_slot, event_type);
  65. return 0;
  66. }
  67. u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
  68. {
  69. struct slot *p_slot;
  70. u8 getstatus;
  71. u32 event_type;
  72. /* Switch Change */
  73. dbg("pciehp: Switch interrupt received.\n");
  74. p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
  75. p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
  76. if (getstatus) {
  77. /*
  78. * Switch opened
  79. */
  80. info("Latch open on Slot(%s)\n", p_slot->name);
  81. event_type = INT_SWITCH_OPEN;
  82. } else {
  83. /*
  84. * Switch closed
  85. */
  86. info("Latch close on Slot(%s)\n", p_slot->name);
  87. event_type = INT_SWITCH_CLOSE;
  88. }
  89. queue_interrupt_event(p_slot, event_type);
  90. return 1;
  91. }
  92. u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl)
  93. {
  94. struct slot *p_slot;
  95. u32 event_type;
  96. u8 presence_save;
  97. /* Presence Change */
  98. dbg("pciehp: Presence/Notify input change.\n");
  99. p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
  100. /* Switch is open, assume a presence change
  101. * Save the presence state
  102. */
  103. p_slot->hpc_ops->get_adapter_status(p_slot, &presence_save);
  104. if (presence_save) {
  105. /*
  106. * Card Present
  107. */
  108. info("Card present on Slot(%s)\n", p_slot->name);
  109. event_type = INT_PRESENCE_ON;
  110. } else {
  111. /*
  112. * Not Present
  113. */
  114. info("Card not present on Slot(%s)\n", p_slot->name);
  115. event_type = INT_PRESENCE_OFF;
  116. }
  117. queue_interrupt_event(p_slot, event_type);
  118. return 1;
  119. }
  120. u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl)
  121. {
  122. struct slot *p_slot;
  123. u32 event_type;
  124. /* power fault */
  125. dbg("pciehp: Power fault interrupt received.\n");
  126. p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
  127. if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) {
  128. /*
  129. * power fault Cleared
  130. */
  131. info("Power fault cleared on Slot(%s)\n", p_slot->name);
  132. event_type = INT_POWER_FAULT_CLEAR;
  133. } else {
  134. /*
  135. * power fault
  136. */
  137. info("Power fault on Slot(%s)\n", p_slot->name);
  138. event_type = INT_POWER_FAULT;
  139. info("power fault bit %x set\n", hp_slot);
  140. }
  141. queue_interrupt_event(p_slot, event_type);
  142. return 1;
  143. }
  144. /* The following routines constitute the bulk of the
  145. hotplug controller logic
  146. */
  147. static void set_slot_off(struct controller *ctrl, struct slot * pslot)
  148. {
  149. /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
  150. if (POWER_CTRL(ctrl->ctrlcap)) {
  151. if (pslot->hpc_ops->power_off_slot(pslot)) {
  152. err("%s: Issue of Slot Power Off command failed\n",
  153. __FUNCTION__);
  154. return;
  155. }
  156. }
  157. if (PWR_LED(ctrl->ctrlcap))
  158. pslot->hpc_ops->green_led_off(pslot);
  159. if (ATTN_LED(ctrl->ctrlcap)) {
  160. if (pslot->hpc_ops->set_attention_status(pslot, 1)) {
  161. err("%s: Issue of Set Attention Led command failed\n",
  162. __FUNCTION__);
  163. return;
  164. }
  165. }
  166. }
  167. /**
  168. * board_added - Called after a board has been added to the system.
  169. *
  170. * Turns power on for the board
  171. * Configures board
  172. *
  173. */
  174. static int board_added(struct slot *p_slot)
  175. {
  176. u8 hp_slot;
  177. int retval = 0;
  178. struct controller *ctrl = p_slot->ctrl;
  179. hp_slot = p_slot->device - ctrl->slot_device_offset;
  180. dbg("%s: slot device, slot offset, hp slot = %d, %d ,%d\n",
  181. __FUNCTION__, p_slot->device,
  182. ctrl->slot_device_offset, hp_slot);
  183. if (POWER_CTRL(ctrl->ctrlcap)) {
  184. /* Power on slot */
  185. retval = p_slot->hpc_ops->power_on_slot(p_slot);
  186. if (retval)
  187. return retval;
  188. }
  189. if (PWR_LED(ctrl->ctrlcap))
  190. p_slot->hpc_ops->green_led_blink(p_slot);
  191. /* Wait for ~1 second */
  192. msleep(1000);
  193. /* Check link training status */
  194. retval = p_slot->hpc_ops->check_lnk_status(ctrl);
  195. if (retval) {
  196. err("%s: Failed to check link status\n", __FUNCTION__);
  197. set_slot_off(ctrl, p_slot);
  198. return retval;
  199. }
  200. /* Check for a power fault */
  201. if (p_slot->hpc_ops->query_power_fault(p_slot)) {
  202. dbg("%s: power fault detected\n", __FUNCTION__);
  203. retval = POWER_FAILURE;
  204. goto err_exit;
  205. }
  206. retval = pciehp_configure_device(p_slot);
  207. if (retval) {
  208. err("Cannot add device 0x%x:%x\n", p_slot->bus,
  209. p_slot->device);
  210. goto err_exit;
  211. }
  212. /*
  213. * Some PCI Express root ports require fixup after hot-plug operation.
  214. */
  215. if (pcie_mch_quirk)
  216. pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
  217. if (PWR_LED(ctrl->ctrlcap))
  218. p_slot->hpc_ops->green_led_on(p_slot);
  219. return 0;
  220. err_exit:
  221. set_slot_off(ctrl, p_slot);
  222. return retval;
  223. }
  224. /**
  225. * remove_board - Turns off slot and LED's
  226. *
  227. */
  228. static int remove_board(struct slot *p_slot)
  229. {
  230. u8 device;
  231. u8 hp_slot;
  232. int retval = 0;
  233. struct controller *ctrl = p_slot->ctrl;
  234. retval = pciehp_unconfigure_device(p_slot);
  235. if (retval)
  236. return retval;
  237. device = p_slot->device;
  238. hp_slot = p_slot->device - ctrl->slot_device_offset;
  239. p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
  240. dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
  241. if (POWER_CTRL(ctrl->ctrlcap)) {
  242. /* power off slot */
  243. retval = p_slot->hpc_ops->power_off_slot(p_slot);
  244. if (retval) {
  245. err("%s: Issue of Slot Disable command failed\n",
  246. __FUNCTION__);
  247. return retval;
  248. }
  249. }
  250. if (PWR_LED(ctrl->ctrlcap))
  251. /* turn off Green LED */
  252. p_slot->hpc_ops->green_led_off(p_slot);
  253. return 0;
  254. }
  255. struct power_work_info {
  256. struct slot *p_slot;
  257. struct work_struct work;
  258. };
  259. /**
  260. * pciehp_pushbutton_thread
  261. *
  262. * Scheduled procedure to handle blocking stuff for the pushbuttons
  263. * Handles all pending events and exits.
  264. *
  265. */
  266. static void pciehp_power_thread(struct work_struct *work)
  267. {
  268. struct power_work_info *info =
  269. container_of(work, struct power_work_info, work);
  270. struct slot *p_slot = info->p_slot;
  271. mutex_lock(&p_slot->lock);
  272. switch (p_slot->state) {
  273. case POWEROFF_STATE:
  274. mutex_unlock(&p_slot->lock);
  275. dbg("%s: disabling bus:device(%x:%x)\n",
  276. __FUNCTION__, p_slot->bus, p_slot->device);
  277. pciehp_disable_slot(p_slot);
  278. mutex_lock(&p_slot->lock);
  279. p_slot->state = STATIC_STATE;
  280. break;
  281. case POWERON_STATE:
  282. mutex_unlock(&p_slot->lock);
  283. if (pciehp_enable_slot(p_slot) &&
  284. PWR_LED(p_slot->ctrl->ctrlcap))
  285. p_slot->hpc_ops->green_led_off(p_slot);
  286. mutex_lock(&p_slot->lock);
  287. p_slot->state = STATIC_STATE;
  288. break;
  289. default:
  290. break;
  291. }
  292. mutex_unlock(&p_slot->lock);
  293. kfree(info);
  294. }
  295. void pciehp_queue_pushbutton_work(struct work_struct *work)
  296. {
  297. struct slot *p_slot = container_of(work, struct slot, work.work);
  298. struct power_work_info *info;
  299. info = kmalloc(sizeof(*info), GFP_KERNEL);
  300. if (!info) {
  301. err("%s: Cannot allocate memory\n", __FUNCTION__);
  302. return;
  303. }
  304. info->p_slot = p_slot;
  305. INIT_WORK(&info->work, pciehp_power_thread);
  306. mutex_lock(&p_slot->lock);
  307. switch (p_slot->state) {
  308. case BLINKINGOFF_STATE:
  309. p_slot->state = POWEROFF_STATE;
  310. break;
  311. case BLINKINGON_STATE:
  312. p_slot->state = POWERON_STATE;
  313. break;
  314. default:
  315. goto out;
  316. }
  317. queue_work(pciehp_wq, &info->work);
  318. out:
  319. mutex_unlock(&p_slot->lock);
  320. }
  321. static int update_slot_info(struct slot *slot)
  322. {
  323. struct hotplug_slot_info *info;
  324. int result;
  325. info = kmalloc(sizeof(*info), GFP_KERNEL);
  326. if (!info)
  327. return -ENOMEM;
  328. slot->hpc_ops->get_power_status(slot, &(info->power_status));
  329. slot->hpc_ops->get_attention_status(slot, &(info->attention_status));
  330. slot->hpc_ops->get_latch_status(slot, &(info->latch_status));
  331. slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status));
  332. result = pci_hp_change_slot_info(slot->hotplug_slot, info);
  333. kfree (info);
  334. return result;
  335. }
  336. /*
  337. * Note: This function must be called with slot->lock held
  338. */
  339. static void handle_button_press_event(struct slot *p_slot)
  340. {
  341. struct controller *ctrl = p_slot->ctrl;
  342. u8 getstatus;
  343. switch (p_slot->state) {
  344. case STATIC_STATE:
  345. p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
  346. if (getstatus) {
  347. p_slot->state = BLINKINGOFF_STATE;
  348. info("PCI slot #%s - powering off due to button "
  349. "press.\n", p_slot->name);
  350. } else {
  351. p_slot->state = BLINKINGON_STATE;
  352. info("PCI slot #%s - powering on due to button "
  353. "press.\n", p_slot->name);
  354. }
  355. /* blink green LED and turn off amber */
  356. if (PWR_LED(ctrl->ctrlcap))
  357. p_slot->hpc_ops->green_led_blink(p_slot);
  358. if (ATTN_LED(ctrl->ctrlcap))
  359. p_slot->hpc_ops->set_attention_status(p_slot, 0);
  360. schedule_delayed_work(&p_slot->work, 5*HZ);
  361. break;
  362. case BLINKINGOFF_STATE:
  363. case BLINKINGON_STATE:
  364. /*
  365. * Cancel if we are still blinking; this means that we
  366. * press the attention again before the 5 sec. limit
  367. * expires to cancel hot-add or hot-remove
  368. */
  369. info("Button cancel on Slot(%s)\n", p_slot->name);
  370. dbg("%s: button cancel\n", __FUNCTION__);
  371. cancel_delayed_work(&p_slot->work);
  372. if (p_slot->state == BLINKINGOFF_STATE) {
  373. if (PWR_LED(ctrl->ctrlcap))
  374. p_slot->hpc_ops->green_led_on(p_slot);
  375. } else {
  376. if (PWR_LED(ctrl->ctrlcap))
  377. p_slot->hpc_ops->green_led_off(p_slot);
  378. }
  379. if (ATTN_LED(ctrl->ctrlcap))
  380. p_slot->hpc_ops->set_attention_status(p_slot, 0);
  381. info("PCI slot #%s - action canceled due to button press\n",
  382. p_slot->name);
  383. p_slot->state = STATIC_STATE;
  384. break;
  385. case POWEROFF_STATE:
  386. case POWERON_STATE:
  387. /*
  388. * Ignore if the slot is on power-on or power-off state;
  389. * this means that the previous attention button action
  390. * to hot-add or hot-remove is undergoing
  391. */
  392. info("Button ignore on Slot(%s)\n", p_slot->name);
  393. update_slot_info(p_slot);
  394. break;
  395. default:
  396. warn("Not a valid state\n");
  397. break;
  398. }
  399. }
  400. /*
  401. * Note: This function must be called with slot->lock held
  402. */
  403. static void handle_surprise_event(struct slot *p_slot)
  404. {
  405. u8 getstatus;
  406. struct power_work_info *info;
  407. info = kmalloc(sizeof(*info), GFP_KERNEL);
  408. if (!info) {
  409. err("%s: Cannot allocate memory\n", __FUNCTION__);
  410. return;
  411. }
  412. info->p_slot = p_slot;
  413. INIT_WORK(&info->work, pciehp_power_thread);
  414. p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
  415. if (!getstatus)
  416. p_slot->state = POWEROFF_STATE;
  417. else
  418. p_slot->state = POWERON_STATE;
  419. queue_work(pciehp_wq, &info->work);
  420. }
  421. static void interrupt_event_handler(struct work_struct *work)
  422. {
  423. struct event_info *info = container_of(work, struct event_info, work);
  424. struct slot *p_slot = info->p_slot;
  425. struct controller *ctrl = p_slot->ctrl;
  426. mutex_lock(&p_slot->lock);
  427. switch (info->event_type) {
  428. case INT_BUTTON_PRESS:
  429. handle_button_press_event(p_slot);
  430. break;
  431. case INT_POWER_FAULT:
  432. if (!POWER_CTRL(ctrl->ctrlcap))
  433. break;
  434. if (ATTN_LED(ctrl->ctrlcap))
  435. p_slot->hpc_ops->set_attention_status(p_slot, 1);
  436. if (PWR_LED(ctrl->ctrlcap))
  437. p_slot->hpc_ops->green_led_off(p_slot);
  438. break;
  439. case INT_PRESENCE_ON:
  440. case INT_PRESENCE_OFF:
  441. if (!HP_SUPR_RM(ctrl->ctrlcap))
  442. break;
  443. dbg("Surprise Removal\n");
  444. update_slot_info(p_slot);
  445. handle_surprise_event(p_slot);
  446. break;
  447. default:
  448. update_slot_info(p_slot);
  449. break;
  450. }
  451. mutex_unlock(&p_slot->lock);
  452. kfree(info);
  453. }
  454. int pciehp_enable_slot(struct slot *p_slot)
  455. {
  456. u8 getstatus = 0;
  457. int rc;
  458. /* Check to see if (latch closed, card present, power off) */
  459. mutex_lock(&p_slot->ctrl->crit_sect);
  460. rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
  461. if (rc || !getstatus) {
  462. info("%s: no adapter on slot(%s)\n", __FUNCTION__,
  463. p_slot->name);
  464. mutex_unlock(&p_slot->ctrl->crit_sect);
  465. return -ENODEV;
  466. }
  467. if (MRL_SENS(p_slot->ctrl->ctrlcap)) {
  468. rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
  469. if (rc || getstatus) {
  470. info("%s: latch open on slot(%s)\n", __FUNCTION__,
  471. p_slot->name);
  472. mutex_unlock(&p_slot->ctrl->crit_sect);
  473. return -ENODEV;
  474. }
  475. }
  476. if (POWER_CTRL(p_slot->ctrl->ctrlcap)) {
  477. rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
  478. if (rc || getstatus) {
  479. info("%s: already enabled on slot(%s)\n", __FUNCTION__,
  480. p_slot->name);
  481. mutex_unlock(&p_slot->ctrl->crit_sect);
  482. return -EINVAL;
  483. }
  484. }
  485. p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
  486. rc = board_added(p_slot);
  487. if (rc) {
  488. p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
  489. }
  490. update_slot_info(p_slot);
  491. mutex_unlock(&p_slot->ctrl->crit_sect);
  492. return rc;
  493. }
  494. int pciehp_disable_slot(struct slot *p_slot)
  495. {
  496. u8 getstatus = 0;
  497. int ret = 0;
  498. if (!p_slot->ctrl)
  499. return 1;
  500. /* Check to see if (latch closed, card present, power on) */
  501. mutex_lock(&p_slot->ctrl->crit_sect);
  502. if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) {
  503. ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
  504. if (ret || !getstatus) {
  505. info("%s: no adapter on slot(%s)\n", __FUNCTION__,
  506. p_slot->name);
  507. mutex_unlock(&p_slot->ctrl->crit_sect);
  508. return -ENODEV;
  509. }
  510. }
  511. if (MRL_SENS(p_slot->ctrl->ctrlcap)) {
  512. ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
  513. if (ret || getstatus) {
  514. info("%s: latch open on slot(%s)\n", __FUNCTION__,
  515. p_slot->name);
  516. mutex_unlock(&p_slot->ctrl->crit_sect);
  517. return -ENODEV;
  518. }
  519. }
  520. if (POWER_CTRL(p_slot->ctrl->ctrlcap)) {
  521. ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
  522. if (ret || !getstatus) {
  523. info("%s: already disabled slot(%s)\n", __FUNCTION__,
  524. p_slot->name);
  525. mutex_unlock(&p_slot->ctrl->crit_sect);
  526. return -EINVAL;
  527. }
  528. }
  529. ret = remove_board(p_slot);
  530. update_slot_info(p_slot);
  531. mutex_unlock(&p_slot->ctrl->crit_sect);
  532. return ret;
  533. }
  534. int pciehp_sysfs_enable_slot(struct slot *p_slot)
  535. {
  536. int retval = -ENODEV;
  537. mutex_lock(&p_slot->lock);
  538. switch (p_slot->state) {
  539. case BLINKINGON_STATE:
  540. cancel_delayed_work(&p_slot->work);
  541. case STATIC_STATE:
  542. p_slot->state = POWERON_STATE;
  543. mutex_unlock(&p_slot->lock);
  544. retval = pciehp_enable_slot(p_slot);
  545. mutex_lock(&p_slot->lock);
  546. p_slot->state = STATIC_STATE;
  547. break;
  548. case POWERON_STATE:
  549. info("Slot %s is already in powering on state\n",
  550. p_slot->name);
  551. break;
  552. case BLINKINGOFF_STATE:
  553. case POWEROFF_STATE:
  554. info("Already enabled on slot %s\n", p_slot->name);
  555. break;
  556. default:
  557. err("Not a valid state on slot %s\n", p_slot->name);
  558. break;
  559. }
  560. mutex_unlock(&p_slot->lock);
  561. return retval;
  562. }
  563. int pciehp_sysfs_disable_slot(struct slot *p_slot)
  564. {
  565. int retval = -ENODEV;
  566. mutex_lock(&p_slot->lock);
  567. switch (p_slot->state) {
  568. case BLINKINGOFF_STATE:
  569. cancel_delayed_work(&p_slot->work);
  570. case STATIC_STATE:
  571. p_slot->state = POWEROFF_STATE;
  572. mutex_unlock(&p_slot->lock);
  573. retval = pciehp_disable_slot(p_slot);
  574. mutex_lock(&p_slot->lock);
  575. p_slot->state = STATIC_STATE;
  576. break;
  577. case POWEROFF_STATE:
  578. info("Slot %s is already in powering off state\n",
  579. p_slot->name);
  580. break;
  581. case BLINKINGON_STATE:
  582. case POWERON_STATE:
  583. info("Already disabled on slot %s\n", p_slot->name);
  584. break;
  585. default:
  586. err("Not a valid state on slot %s\n", p_slot->name);
  587. break;
  588. }
  589. mutex_unlock(&p_slot->lock);
  590. return retval;
  591. }