[PATCH] PCI Hotplug: Fix echoing 1 to power file of enabled slot problem with SHPC driver

Here is a patch to fix the problem of echoing 1 to "power" file
to enabled slot causing the slot to power down, and echoing 0
to disabled slot causing shpchp_disabled_slot() to be called
twice. This problem was reported by kenji Kaneshige.

Thanks,
Dely

Signed-off-by: Dely Sy <dely.l.sy@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Dely Sy and committed by
Greg KH
ee17fd93 ff0d2f90

+16 -16
+1 -1
drivers/pci/hotplug/shpchp_core.c
··· 95 95 */ 96 96 static void release_slot(struct hotplug_slot *hotplug_slot) 97 97 { 98 - struct slot *slot = (struct slot *)hotplug_slot->private; 98 + struct slot *slot = hotplug_slot->private; 99 99 100 100 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 101 101
+15 -15
drivers/pci/hotplug/shpchp_ctrl.c
··· 1885 1885 func = shpchp_slot_find(p_slot->bus, p_slot->device, 0); 1886 1886 if (!func) { 1887 1887 dbg("%s: Error! slot NULL\n", __FUNCTION__); 1888 - return 1; 1888 + return -ENODEV; 1889 1889 } 1890 1890 1891 1891 /* Check to see if (latch closed, card present, power off) */ ··· 1894 1894 if (rc || !getstatus) { 1895 1895 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1896 1896 up(&p_slot->ctrl->crit_sect); 1897 - return 1; 1897 + return -ENODEV; 1898 1898 } 1899 1899 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1900 1900 if (rc || getstatus) { 1901 1901 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1902 1902 up(&p_slot->ctrl->crit_sect); 1903 - return 1; 1903 + return -ENODEV; 1904 1904 } 1905 1905 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1906 1906 if (rc || getstatus) { 1907 1907 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 1908 1908 up(&p_slot->ctrl->crit_sect); 1909 - return 1; 1909 + return -ENODEV; 1910 1910 } 1911 1911 up(&p_slot->ctrl->crit_sect); 1912 1912 ··· 1914 1914 1915 1915 func = shpchp_slot_create(p_slot->bus); 1916 1916 if (func == NULL) 1917 - return 1; 1917 + return -ENOMEM; 1918 1918 1919 1919 func->bus = p_slot->bus; 1920 1920 func->device = p_slot->device; ··· 1939 1939 /* Setup slot structure with entry for empty slot */ 1940 1940 func = shpchp_slot_create(p_slot->bus); 1941 1941 if (func == NULL) 1942 - return (1); /* Out of memory */ 1942 + return -ENOMEM; /* Out of memory */ 1943 1943 1944 1944 func->bus = p_slot->bus; 1945 1945 func->device = p_slot->device; ··· 1972 1972 struct pci_func *func; 1973 1973 1974 1974 if (!p_slot->ctrl) 1975 - return 1; 1975 + return -ENODEV; 1976 1976 1977 1977 pci_bus = p_slot->ctrl->pci_dev->subordinate; 1978 1978 ··· 1983 1983 if (ret || !getstatus) { 1984 1984 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1985 1985 up(&p_slot->ctrl->crit_sect); 1986 - return 1; 1986 + return -ENODEV; 1987 1987 } 1988 1988 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1989 1989 if (ret || getstatus) { 1990 1990 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1991 1991 up(&p_slot->ctrl->crit_sect); 1992 - return 1; 1992 + return -ENODEV; 1993 1993 } 1994 1994 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1995 1995 if (ret || !getstatus) { 1996 1996 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 1997 1997 up(&p_slot->ctrl->crit_sect); 1998 - return 1; 1998 + return -ENODEV; 1999 1999 } 2000 2000 up(&p_slot->ctrl->crit_sect); 2001 2001 ··· 2011 2011 /* Check the Class Code */ 2012 2012 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); 2013 2013 if (rc) 2014 - return rc; 2014 + return -ENODEV; 2015 2015 2016 2016 if (class_code == PCI_BASE_CLASS_DISPLAY) { 2017 2017 /* Display/Video adapter (not supported) */ ··· 2020 2020 /* See if it's a bridge */ 2021 2021 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 2022 2022 if (rc) 2023 - return rc; 2023 + return -ENODEV; 2024 2024 2025 2025 /* If it's a bridge, check the VGA Enable bit */ 2026 2026 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 2027 2027 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR); 2028 2028 if (rc) 2029 - return rc; 2029 + return -ENODEV; 2030 2030 2031 2031 /* If the VGA Enable bit is set, remove isn't supported */ 2032 2032 if (BCR & PCI_BRIDGE_CTL_VGA) { ··· 2042 2042 if ((func != NULL) && !rc) { 2043 2043 rc = remove_board(func, p_slot->ctrl); 2044 2044 } else if (!rc) 2045 - rc = 1; 2045 + rc = -ENODEV; 2046 2046 2047 2047 if (p_slot) 2048 2048 update_slot_info(p_slot); 2049 2049 2050 - return(rc); 2050 + return rc; 2051 2051 } 2052 2052 2053 2053