pciehp_ctrl.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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/slab.h>
  33. #include <linux/pci.h>
  34. #include "../pci.h"
  35. #include "pciehp.h"
  36. static void interrupt_event_handler(struct work_struct *work);
  37. static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
  38. {
  39. struct event_info *info;
  40. info = kmalloc(sizeof(*info), GFP_ATOMIC);
  41. if (!info)
  42. return -ENOMEM;
  43. info->event_type = event_type;
  44. info->p_slot = p_slot;
  45. INIT_WORK(&info->work, interrupt_event_handler);
  46. queue_work(p_slot->wq, &info->work);
  47. return 0;
  48. }
  49. u8 pciehp_handle_attention_button(struct slot *p_slot)
  50. {
  51. u32 event_type;
  52. struct controller *ctrl = p_slot->ctrl;
  53. /* Attention Button Change */
  54. ctrl_dbg(ctrl, "Attention button interrupt received\n");
  55. /*
  56. * Button pressed - See if need to TAKE ACTION!!!
  57. */
  58. ctrl_info(ctrl, "Button pressed on Slot(%s)\n", slot_name(p_slot));
  59. event_type = INT_BUTTON_PRESS;
  60. queue_interrupt_event(p_slot, event_type);
  61. return 0;
  62. }
  63. u8 pciehp_handle_switch_change(struct slot *p_slot)
  64. {
  65. u8 getstatus;
  66. u32 event_type;
  67. struct controller *ctrl = p_slot->ctrl;
  68. /* Switch Change */
  69. ctrl_dbg(ctrl, "Switch interrupt received\n");
  70. pciehp_get_latch_status(p_slot, &getstatus);
  71. if (getstatus) {
  72. /*
  73. * Switch opened
  74. */
  75. ctrl_info(ctrl, "Latch open on Slot(%s)\n", slot_name(p_slot));
  76. event_type = INT_SWITCH_OPEN;
  77. } else {
  78. /*
  79. * Switch closed
  80. */
  81. ctrl_info(ctrl, "Latch close on Slot(%s)\n", slot_name(p_slot));
  82. event_type = INT_SWITCH_CLOSE;
  83. }
  84. queue_interrupt_event(p_slot, event_type);
  85. return 1;
  86. }
  87. u8 pciehp_handle_presence_change(struct slot *p_slot)
  88. {
  89. u32 event_type;
  90. u8 presence_save;
  91. struct controller *ctrl = p_slot->ctrl;
  92. /* Presence Change */
  93. ctrl_dbg(ctrl, "Presence/Notify input change\n");
  94. /* Switch is open, assume a presence change
  95. * Save the presence state
  96. */
  97. pciehp_get_adapter_status(p_slot, &presence_save);
  98. if (presence_save) {
  99. /*
  100. * Card Present
  101. */
  102. ctrl_info(ctrl, "Card present on Slot(%s)\n", slot_name(p_slot));
  103. event_type = INT_PRESENCE_ON;
  104. } else {
  105. /*
  106. * Not Present
  107. */
  108. ctrl_info(ctrl, "Card not present on Slot(%s)\n",
  109. slot_name(p_slot));
  110. event_type = INT_PRESENCE_OFF;
  111. }
  112. queue_interrupt_event(p_slot, event_type);
  113. return 1;
  114. }
  115. u8 pciehp_handle_power_fault(struct slot *p_slot)
  116. {
  117. u32 event_type;
  118. struct controller *ctrl = p_slot->ctrl;
  119. /* power fault */
  120. ctrl_dbg(ctrl, "Power fault interrupt received\n");
  121. ctrl_err(ctrl, "Power fault on slot %s\n", slot_name(p_slot));
  122. event_type = INT_POWER_FAULT;
  123. ctrl_info(ctrl, "Power fault bit %x set\n", 0);
  124. queue_interrupt_event(p_slot, event_type);
  125. return 1;
  126. }
  127. void pciehp_handle_linkstate_change(struct slot *p_slot)
  128. {
  129. u32 event_type;
  130. struct controller *ctrl = p_slot->ctrl;
  131. /* Link Status Change */
  132. ctrl_dbg(ctrl, "Data Link Layer State change\n");
  133. if (pciehp_check_link_active(ctrl)) {
  134. ctrl_info(ctrl, "slot(%s): Link Up event\n",
  135. slot_name(p_slot));
  136. event_type = INT_LINK_UP;
  137. } else {
  138. ctrl_info(ctrl, "slot(%s): Link Down event\n",
  139. slot_name(p_slot));
  140. event_type = INT_LINK_DOWN;
  141. }
  142. queue_interrupt_event(p_slot, event_type);
  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)) {
  151. pciehp_power_off_slot(pslot);
  152. /*
  153. * After turning power off, we must wait for at least 1 second
  154. * before taking any action that relies on power having been
  155. * removed from the slot/adapter.
  156. */
  157. msleep(1000);
  158. }
  159. pciehp_green_led_off(pslot);
  160. pciehp_set_attention_status(pslot, 1);
  161. }
  162. /**
  163. * board_added - Called after a board has been added to the system.
  164. * @p_slot: &slot where board is added
  165. *
  166. * Turns power on for the board.
  167. * Configures board.
  168. */
  169. static int board_added(struct slot *p_slot)
  170. {
  171. int retval = 0;
  172. struct controller *ctrl = p_slot->ctrl;
  173. struct pci_bus *parent = ctrl->pcie->port->subordinate;
  174. if (POWER_CTRL(ctrl)) {
  175. /* Power on slot */
  176. retval = pciehp_power_on_slot(p_slot);
  177. if (retval)
  178. return retval;
  179. }
  180. pciehp_green_led_blink(p_slot);
  181. /* Check link training status */
  182. retval = pciehp_check_link_status(ctrl);
  183. if (retval) {
  184. ctrl_err(ctrl, "Failed to check link status\n");
  185. goto err_exit;
  186. }
  187. /* Check for a power fault */
  188. if (ctrl->power_fault_detected || pciehp_query_power_fault(p_slot)) {
  189. ctrl_err(ctrl, "Power fault on slot %s\n", slot_name(p_slot));
  190. retval = -EIO;
  191. goto err_exit;
  192. }
  193. retval = pciehp_configure_device(p_slot);
  194. if (retval) {
  195. ctrl_err(ctrl, "Cannot add device at %04x:%02x:00\n",
  196. pci_domain_nr(parent), parent->number);
  197. if (retval != -EEXIST)
  198. goto err_exit;
  199. }
  200. pciehp_green_led_on(p_slot);
  201. return 0;
  202. err_exit:
  203. set_slot_off(ctrl, p_slot);
  204. return retval;
  205. }
  206. /**
  207. * remove_board - Turns off slot and LEDs
  208. * @p_slot: slot where board is being removed
  209. */
  210. static int remove_board(struct slot *p_slot)
  211. {
  212. int retval;
  213. struct controller *ctrl = p_slot->ctrl;
  214. retval = pciehp_unconfigure_device(p_slot);
  215. if (retval)
  216. return retval;
  217. if (POWER_CTRL(ctrl)) {
  218. pciehp_power_off_slot(p_slot);
  219. /*
  220. * After turning power off, we must wait for at least 1 second
  221. * before taking any action that relies on power having been
  222. * removed from the slot/adapter.
  223. */
  224. msleep(1000);
  225. }
  226. /* turn off Green LED */
  227. pciehp_green_led_off(p_slot);
  228. return 0;
  229. }
  230. struct power_work_info {
  231. struct slot *p_slot;
  232. struct work_struct work;
  233. unsigned int req;
  234. #define DISABLE_REQ 0
  235. #define ENABLE_REQ 1
  236. };
  237. /**
  238. * pciehp_power_thread - handle pushbutton events
  239. * @work: &struct work_struct describing work to be done
  240. *
  241. * Scheduled procedure to handle blocking stuff for the pushbuttons.
  242. * Handles all pending events and exits.
  243. */
  244. static void pciehp_power_thread(struct work_struct *work)
  245. {
  246. struct power_work_info *info =
  247. container_of(work, struct power_work_info, work);
  248. struct slot *p_slot = info->p_slot;
  249. int ret;
  250. switch (info->req) {
  251. case DISABLE_REQ:
  252. ctrl_dbg(p_slot->ctrl,
  253. "Disabling domain:bus:device=%04x:%02x:00\n",
  254. pci_domain_nr(p_slot->ctrl->pcie->port->subordinate),
  255. p_slot->ctrl->pcie->port->subordinate->number);
  256. mutex_lock(&p_slot->hotplug_lock);
  257. pciehp_disable_slot(p_slot);
  258. mutex_unlock(&p_slot->hotplug_lock);
  259. mutex_lock(&p_slot->lock);
  260. p_slot->state = STATIC_STATE;
  261. mutex_unlock(&p_slot->lock);
  262. break;
  263. case ENABLE_REQ:
  264. ctrl_dbg(p_slot->ctrl,
  265. "Enabling domain:bus:device=%04x:%02x:00\n",
  266. pci_domain_nr(p_slot->ctrl->pcie->port->subordinate),
  267. p_slot->ctrl->pcie->port->subordinate->number);
  268. mutex_lock(&p_slot->hotplug_lock);
  269. ret = pciehp_enable_slot(p_slot);
  270. mutex_unlock(&p_slot->hotplug_lock);
  271. if (ret)
  272. pciehp_green_led_off(p_slot);
  273. mutex_lock(&p_slot->lock);
  274. p_slot->state = STATIC_STATE;
  275. mutex_unlock(&p_slot->lock);
  276. break;
  277. default:
  278. break;
  279. }
  280. kfree(info);
  281. }
  282. void pciehp_queue_pushbutton_work(struct work_struct *work)
  283. {
  284. struct slot *p_slot = container_of(work, struct slot, work.work);
  285. struct power_work_info *info;
  286. info = kmalloc(sizeof(*info), GFP_KERNEL);
  287. if (!info) {
  288. ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n",
  289. __func__);
  290. return;
  291. }
  292. info->p_slot = p_slot;
  293. INIT_WORK(&info->work, pciehp_power_thread);
  294. mutex_lock(&p_slot->lock);
  295. switch (p_slot->state) {
  296. case BLINKINGOFF_STATE:
  297. p_slot->state = POWEROFF_STATE;
  298. info->req = DISABLE_REQ;
  299. break;
  300. case BLINKINGON_STATE:
  301. p_slot->state = POWERON_STATE;
  302. info->req = ENABLE_REQ;
  303. break;
  304. default:
  305. kfree(info);
  306. goto out;
  307. }
  308. queue_work(p_slot->wq, &info->work);
  309. out:
  310. mutex_unlock(&p_slot->lock);
  311. }
  312. /*
  313. * Note: This function must be called with slot->lock held
  314. */
  315. static void handle_button_press_event(struct slot *p_slot)
  316. {
  317. struct controller *ctrl = p_slot->ctrl;
  318. u8 getstatus;
  319. switch (p_slot->state) {
  320. case STATIC_STATE:
  321. pciehp_get_power_status(p_slot, &getstatus);
  322. if (getstatus) {
  323. p_slot->state = BLINKINGOFF_STATE;
  324. ctrl_info(ctrl,
  325. "PCI slot #%s - powering off due to button "
  326. "press.\n", slot_name(p_slot));
  327. } else {
  328. p_slot->state = BLINKINGON_STATE;
  329. ctrl_info(ctrl,
  330. "PCI slot #%s - powering on due to button "
  331. "press.\n", slot_name(p_slot));
  332. }
  333. /* blink green LED and turn off amber */
  334. pciehp_green_led_blink(p_slot);
  335. pciehp_set_attention_status(p_slot, 0);
  336. queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ);
  337. break;
  338. case BLINKINGOFF_STATE:
  339. case BLINKINGON_STATE:
  340. /*
  341. * Cancel if we are still blinking; this means that we
  342. * press the attention again before the 5 sec. limit
  343. * expires to cancel hot-add or hot-remove
  344. */
  345. ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot));
  346. cancel_delayed_work(&p_slot->work);
  347. if (p_slot->state == BLINKINGOFF_STATE)
  348. pciehp_green_led_on(p_slot);
  349. else
  350. pciehp_green_led_off(p_slot);
  351. pciehp_set_attention_status(p_slot, 0);
  352. ctrl_info(ctrl, "PCI slot #%s - action canceled "
  353. "due to button press\n", slot_name(p_slot));
  354. p_slot->state = STATIC_STATE;
  355. break;
  356. case POWEROFF_STATE:
  357. case POWERON_STATE:
  358. /*
  359. * Ignore if the slot is on power-on or power-off state;
  360. * this means that the previous attention button action
  361. * to hot-add or hot-remove is undergoing
  362. */
  363. ctrl_info(ctrl, "Button ignore on Slot(%s)\n", slot_name(p_slot));
  364. break;
  365. default:
  366. ctrl_warn(ctrl, "Not a valid state\n");
  367. break;
  368. }
  369. }
  370. /*
  371. * Note: This function must be called with slot->lock held
  372. */
  373. static void handle_surprise_event(struct slot *p_slot)
  374. {
  375. u8 getstatus;
  376. struct power_work_info *info;
  377. info = kmalloc(sizeof(*info), GFP_KERNEL);
  378. if (!info) {
  379. ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n",
  380. __func__);
  381. return;
  382. }
  383. info->p_slot = p_slot;
  384. INIT_WORK(&info->work, pciehp_power_thread);
  385. pciehp_get_adapter_status(p_slot, &getstatus);
  386. if (!getstatus) {
  387. p_slot->state = POWEROFF_STATE;
  388. info->req = DISABLE_REQ;
  389. } else {
  390. p_slot->state = POWERON_STATE;
  391. info->req = ENABLE_REQ;
  392. }
  393. queue_work(p_slot->wq, &info->work);
  394. }
  395. /*
  396. * Note: This function must be called with slot->lock held
  397. */
  398. static void handle_link_event(struct slot *p_slot, u32 event)
  399. {
  400. struct controller *ctrl = p_slot->ctrl;
  401. struct power_work_info *info;
  402. info = kmalloc(sizeof(*info), GFP_KERNEL);
  403. if (!info) {
  404. ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n",
  405. __func__);
  406. return;
  407. }
  408. info->p_slot = p_slot;
  409. info->req = event == INT_LINK_UP ? ENABLE_REQ : DISABLE_REQ;
  410. INIT_WORK(&info->work, pciehp_power_thread);
  411. switch (p_slot->state) {
  412. case BLINKINGON_STATE:
  413. case BLINKINGOFF_STATE:
  414. cancel_delayed_work(&p_slot->work);
  415. /* Fall through */
  416. case STATIC_STATE:
  417. p_slot->state = event == INT_LINK_UP ?
  418. POWERON_STATE : POWEROFF_STATE;
  419. queue_work(p_slot->wq, &info->work);
  420. break;
  421. case POWERON_STATE:
  422. if (event == INT_LINK_UP) {
  423. ctrl_info(ctrl,
  424. "Link Up event ignored on slot(%s): already powering on\n",
  425. slot_name(p_slot));
  426. kfree(info);
  427. } else {
  428. ctrl_info(ctrl,
  429. "Link Down event queued on slot(%s): currently getting powered on\n",
  430. slot_name(p_slot));
  431. p_slot->state = POWEROFF_STATE;
  432. queue_work(p_slot->wq, &info->work);
  433. }
  434. break;
  435. case POWEROFF_STATE:
  436. if (event == INT_LINK_UP) {
  437. ctrl_info(ctrl,
  438. "Link Up event queued on slot(%s): currently getting powered off\n",
  439. slot_name(p_slot));
  440. p_slot->state = POWERON_STATE;
  441. queue_work(p_slot->wq, &info->work);
  442. } else {
  443. ctrl_info(ctrl,
  444. "Link Down event ignored on slot(%s): already powering off\n",
  445. slot_name(p_slot));
  446. kfree(info);
  447. }
  448. break;
  449. default:
  450. ctrl_err(ctrl, "Not a valid state on slot(%s)\n",
  451. slot_name(p_slot));
  452. kfree(info);
  453. break;
  454. }
  455. }
  456. static void interrupt_event_handler(struct work_struct *work)
  457. {
  458. struct event_info *info = container_of(work, struct event_info, work);
  459. struct slot *p_slot = info->p_slot;
  460. struct controller *ctrl = p_slot->ctrl;
  461. mutex_lock(&p_slot->lock);
  462. switch (info->event_type) {
  463. case INT_BUTTON_PRESS:
  464. handle_button_press_event(p_slot);
  465. break;
  466. case INT_POWER_FAULT:
  467. if (!POWER_CTRL(ctrl))
  468. break;
  469. pciehp_set_attention_status(p_slot, 1);
  470. pciehp_green_led_off(p_slot);
  471. break;
  472. case INT_PRESENCE_ON:
  473. if (!HP_SUPR_RM(ctrl))
  474. break;
  475. ctrl_dbg(ctrl, "Surprise Insertion\n");
  476. handle_surprise_event(p_slot);
  477. break;
  478. case INT_PRESENCE_OFF:
  479. /*
  480. * Regardless of surprise capability, we need to
  481. * definitely remove a card that has been pulled out!
  482. */
  483. ctrl_dbg(ctrl, "Surprise Removal\n");
  484. handle_surprise_event(p_slot);
  485. break;
  486. case INT_LINK_UP:
  487. case INT_LINK_DOWN:
  488. handle_link_event(p_slot, info->event_type);
  489. break;
  490. default:
  491. break;
  492. }
  493. mutex_unlock(&p_slot->lock);
  494. kfree(info);
  495. }
  496. /*
  497. * Note: This function must be called with slot->hotplug_lock held
  498. */
  499. int pciehp_enable_slot(struct slot *p_slot)
  500. {
  501. u8 getstatus = 0;
  502. int rc;
  503. struct controller *ctrl = p_slot->ctrl;
  504. pciehp_get_adapter_status(p_slot, &getstatus);
  505. if (!getstatus) {
  506. ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot));
  507. return -ENODEV;
  508. }
  509. if (MRL_SENS(p_slot->ctrl)) {
  510. pciehp_get_latch_status(p_slot, &getstatus);
  511. if (getstatus) {
  512. ctrl_info(ctrl, "Latch open on slot(%s)\n",
  513. slot_name(p_slot));
  514. return -ENODEV;
  515. }
  516. }
  517. if (POWER_CTRL(p_slot->ctrl)) {
  518. pciehp_get_power_status(p_slot, &getstatus);
  519. if (getstatus) {
  520. ctrl_info(ctrl, "Already enabled on slot(%s)\n",
  521. slot_name(p_slot));
  522. return -EINVAL;
  523. }
  524. }
  525. pciehp_get_latch_status(p_slot, &getstatus);
  526. rc = board_added(p_slot);
  527. if (rc)
  528. pciehp_get_latch_status(p_slot, &getstatus);
  529. return rc;
  530. }
  531. /*
  532. * Note: This function must be called with slot->hotplug_lock held
  533. */
  534. int pciehp_disable_slot(struct slot *p_slot)
  535. {
  536. u8 getstatus = 0;
  537. struct controller *ctrl = p_slot->ctrl;
  538. if (!p_slot->ctrl)
  539. return 1;
  540. if (POWER_CTRL(p_slot->ctrl)) {
  541. pciehp_get_power_status(p_slot, &getstatus);
  542. if (!getstatus) {
  543. ctrl_info(ctrl, "Already disabled on slot(%s)\n",
  544. slot_name(p_slot));
  545. return -EINVAL;
  546. }
  547. }
  548. return remove_board(p_slot);
  549. }
  550. int pciehp_sysfs_enable_slot(struct slot *p_slot)
  551. {
  552. int retval = -ENODEV;
  553. struct controller *ctrl = p_slot->ctrl;
  554. mutex_lock(&p_slot->lock);
  555. switch (p_slot->state) {
  556. case BLINKINGON_STATE:
  557. cancel_delayed_work(&p_slot->work);
  558. case STATIC_STATE:
  559. p_slot->state = POWERON_STATE;
  560. mutex_unlock(&p_slot->lock);
  561. mutex_lock(&p_slot->hotplug_lock);
  562. retval = pciehp_enable_slot(p_slot);
  563. mutex_unlock(&p_slot->hotplug_lock);
  564. mutex_lock(&p_slot->lock);
  565. p_slot->state = STATIC_STATE;
  566. break;
  567. case POWERON_STATE:
  568. ctrl_info(ctrl, "Slot %s is already in powering on state\n",
  569. slot_name(p_slot));
  570. break;
  571. case BLINKINGOFF_STATE:
  572. case POWEROFF_STATE:
  573. ctrl_info(ctrl, "Already enabled on slot %s\n",
  574. slot_name(p_slot));
  575. break;
  576. default:
  577. ctrl_err(ctrl, "Not a valid state on slot %s\n",
  578. slot_name(p_slot));
  579. break;
  580. }
  581. mutex_unlock(&p_slot->lock);
  582. return retval;
  583. }
  584. int pciehp_sysfs_disable_slot(struct slot *p_slot)
  585. {
  586. int retval = -ENODEV;
  587. struct controller *ctrl = p_slot->ctrl;
  588. mutex_lock(&p_slot->lock);
  589. switch (p_slot->state) {
  590. case BLINKINGOFF_STATE:
  591. cancel_delayed_work(&p_slot->work);
  592. case STATIC_STATE:
  593. p_slot->state = POWEROFF_STATE;
  594. mutex_unlock(&p_slot->lock);
  595. retval = pciehp_disable_slot(p_slot);
  596. mutex_lock(&p_slot->lock);
  597. p_slot->state = STATIC_STATE;
  598. break;
  599. case POWEROFF_STATE:
  600. ctrl_info(ctrl, "Slot %s is already in powering off state\n",
  601. slot_name(p_slot));
  602. break;
  603. case BLINKINGON_STATE:
  604. case POWERON_STATE:
  605. ctrl_info(ctrl, "Already disabled on slot %s\n",
  606. slot_name(p_slot));
  607. break;
  608. default:
  609. ctrl_err(ctrl, "Not a valid state on slot %s\n",
  610. slot_name(p_slot));
  611. break;
  612. }
  613. mutex_unlock(&p_slot->lock);
  614. return retval;
  615. }