diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-10-11 04:22:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-11 14:14:25 -0400 |
commit | 5e59393ec242d7b772356c95e2be48384cd0c5d7 (patch) | |
tree | b027efc11d5069707d850783f3effb8dd926a721 /drivers/char/ipmi | |
parent | 41bfcfd9ac0fbb59aaaa18e3ed5774e85b716de4 (diff) |
[PATCH] ipmi: handle sysfs errors
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Acked-by: Corey Minyard <cminyard@acm.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/ipmi')
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 122 |
1 files changed, 93 insertions, 29 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 2455e8d478ac..34a4fd13fa81 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -1928,13 +1928,8 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr, | |||
1928 | (long long) bmc->guid[8]); | 1928 | (long long) bmc->guid[8]); |
1929 | } | 1929 | } |
1930 | 1930 | ||
1931 | static void | 1931 | static void remove_files(struct bmc_device *bmc) |
1932 | cleanup_bmc_device(struct kref *ref) | ||
1933 | { | 1932 | { |
1934 | struct bmc_device *bmc; | ||
1935 | |||
1936 | bmc = container_of(ref, struct bmc_device, refcount); | ||
1937 | |||
1938 | device_remove_file(&bmc->dev->dev, | 1933 | device_remove_file(&bmc->dev->dev, |
1939 | &bmc->device_id_attr); | 1934 | &bmc->device_id_attr); |
1940 | device_remove_file(&bmc->dev->dev, | 1935 | device_remove_file(&bmc->dev->dev, |
@@ -1951,12 +1946,23 @@ cleanup_bmc_device(struct kref *ref) | |||
1951 | &bmc->manufacturer_id_attr); | 1946 | &bmc->manufacturer_id_attr); |
1952 | device_remove_file(&bmc->dev->dev, | 1947 | device_remove_file(&bmc->dev->dev, |
1953 | &bmc->product_id_attr); | 1948 | &bmc->product_id_attr); |
1949 | |||
1954 | if (bmc->id.aux_firmware_revision_set) | 1950 | if (bmc->id.aux_firmware_revision_set) |
1955 | device_remove_file(&bmc->dev->dev, | 1951 | device_remove_file(&bmc->dev->dev, |
1956 | &bmc->aux_firmware_rev_attr); | 1952 | &bmc->aux_firmware_rev_attr); |
1957 | if (bmc->guid_set) | 1953 | if (bmc->guid_set) |
1958 | device_remove_file(&bmc->dev->dev, | 1954 | device_remove_file(&bmc->dev->dev, |
1959 | &bmc->guid_attr); | 1955 | &bmc->guid_attr); |
1956 | } | ||
1957 | |||
1958 | static void | ||
1959 | cleanup_bmc_device(struct kref *ref) | ||
1960 | { | ||
1961 | struct bmc_device *bmc; | ||
1962 | |||
1963 | bmc = container_of(ref, struct bmc_device, refcount); | ||
1964 | |||
1965 | remove_files(bmc); | ||
1960 | platform_device_unregister(bmc->dev); | 1966 | platform_device_unregister(bmc->dev); |
1961 | kfree(bmc); | 1967 | kfree(bmc); |
1962 | } | 1968 | } |
@@ -1977,6 +1983,79 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf) | |||
1977 | mutex_unlock(&ipmidriver_mutex); | 1983 | mutex_unlock(&ipmidriver_mutex); |
1978 | } | 1984 | } |
1979 | 1985 | ||
1986 | static int create_files(struct bmc_device *bmc) | ||
1987 | { | ||
1988 | int err; | ||
1989 | |||
1990 | err = device_create_file(&bmc->dev->dev, | ||
1991 | &bmc->device_id_attr); | ||
1992 | if (err) goto out; | ||
1993 | err = device_create_file(&bmc->dev->dev, | ||
1994 | &bmc->provides_dev_sdrs_attr); | ||
1995 | if (err) goto out_devid; | ||
1996 | err = device_create_file(&bmc->dev->dev, | ||
1997 | &bmc->revision_attr); | ||
1998 | if (err) goto out_sdrs; | ||
1999 | err = device_create_file(&bmc->dev->dev, | ||
2000 | &bmc->firmware_rev_attr); | ||
2001 | if (err) goto out_rev; | ||
2002 | err = device_create_file(&bmc->dev->dev, | ||
2003 | &bmc->version_attr); | ||
2004 | if (err) goto out_firm; | ||
2005 | err = device_create_file(&bmc->dev->dev, | ||
2006 | &bmc->add_dev_support_attr); | ||
2007 | if (err) goto out_version; | ||
2008 | err = device_create_file(&bmc->dev->dev, | ||
2009 | &bmc->manufacturer_id_attr); | ||
2010 | if (err) goto out_add_dev; | ||
2011 | err = device_create_file(&bmc->dev->dev, | ||
2012 | &bmc->product_id_attr); | ||
2013 | if (err) goto out_manu; | ||
2014 | if (bmc->id.aux_firmware_revision_set) { | ||
2015 | err = device_create_file(&bmc->dev->dev, | ||
2016 | &bmc->aux_firmware_rev_attr); | ||
2017 | if (err) goto out_prod_id; | ||
2018 | } | ||
2019 | if (bmc->guid_set) { | ||
2020 | err = device_create_file(&bmc->dev->dev, | ||
2021 | &bmc->guid_attr); | ||
2022 | if (err) goto out_aux_firm; | ||
2023 | } | ||
2024 | |||
2025 | return 0; | ||
2026 | |||
2027 | out_aux_firm: | ||
2028 | if (bmc->id.aux_firmware_revision_set) | ||
2029 | device_remove_file(&bmc->dev->dev, | ||
2030 | &bmc->aux_firmware_rev_attr); | ||
2031 | out_prod_id: | ||
2032 | device_remove_file(&bmc->dev->dev, | ||
2033 | &bmc->product_id_attr); | ||
2034 | out_manu: | ||
2035 | device_remove_file(&bmc->dev->dev, | ||
2036 | &bmc->manufacturer_id_attr); | ||
2037 | out_add_dev: | ||
2038 | device_remove_file(&bmc->dev->dev, | ||
2039 | &bmc->add_dev_support_attr); | ||
2040 | out_version: | ||
2041 | device_remove_file(&bmc->dev->dev, | ||
2042 | &bmc->version_attr); | ||
2043 | out_firm: | ||
2044 | device_remove_file(&bmc->dev->dev, | ||
2045 | &bmc->firmware_rev_attr); | ||
2046 | out_rev: | ||
2047 | device_remove_file(&bmc->dev->dev, | ||
2048 | &bmc->revision_attr); | ||
2049 | out_sdrs: | ||
2050 | device_remove_file(&bmc->dev->dev, | ||
2051 | &bmc->provides_dev_sdrs_attr); | ||
2052 | out_devid: | ||
2053 | device_remove_file(&bmc->dev->dev, | ||
2054 | &bmc->device_id_attr); | ||
2055 | out: | ||
2056 | return err; | ||
2057 | } | ||
2058 | |||
1980 | static int ipmi_bmc_register(ipmi_smi_t intf) | 2059 | static int ipmi_bmc_register(ipmi_smi_t intf) |
1981 | { | 2060 | { |
1982 | int rv; | 2061 | int rv; |
@@ -2051,7 +2130,6 @@ static int ipmi_bmc_register(ipmi_smi_t intf) | |||
2051 | bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO; | 2130 | bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO; |
2052 | bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show; | 2131 | bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show; |
2053 | 2132 | ||
2054 | |||
2055 | bmc->revision_attr.attr.name = "revision"; | 2133 | bmc->revision_attr.attr.name = "revision"; |
2056 | bmc->revision_attr.attr.owner = THIS_MODULE; | 2134 | bmc->revision_attr.attr.owner = THIS_MODULE; |
2057 | bmc->revision_attr.attr.mode = S_IRUGO; | 2135 | bmc->revision_attr.attr.mode = S_IRUGO; |
@@ -2093,28 +2171,14 @@ static int ipmi_bmc_register(ipmi_smi_t intf) | |||
2093 | bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO; | 2171 | bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO; |
2094 | bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show; | 2172 | bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show; |
2095 | 2173 | ||
2096 | device_create_file(&bmc->dev->dev, | 2174 | rv = create_files(bmc); |
2097 | &bmc->device_id_attr); | 2175 | if (rv) { |
2098 | device_create_file(&bmc->dev->dev, | 2176 | mutex_lock(&ipmidriver_mutex); |
2099 | &bmc->provides_dev_sdrs_attr); | 2177 | platform_device_unregister(bmc->dev); |
2100 | device_create_file(&bmc->dev->dev, | 2178 | mutex_unlock(&ipmidriver_mutex); |
2101 | &bmc->revision_attr); | 2179 | |
2102 | device_create_file(&bmc->dev->dev, | 2180 | return rv; |
2103 | &bmc->firmware_rev_attr); | 2181 | } |
2104 | device_create_file(&bmc->dev->dev, | ||
2105 | &bmc->version_attr); | ||
2106 | device_create_file(&bmc->dev->dev, | ||
2107 | &bmc->add_dev_support_attr); | ||
2108 | device_create_file(&bmc->dev->dev, | ||
2109 | &bmc->manufacturer_id_attr); | ||
2110 | device_create_file(&bmc->dev->dev, | ||
2111 | &bmc->product_id_attr); | ||
2112 | if (bmc->id.aux_firmware_revision_set) | ||
2113 | device_create_file(&bmc->dev->dev, | ||
2114 | &bmc->aux_firmware_rev_attr); | ||
2115 | if (bmc->guid_set) | ||
2116 | device_create_file(&bmc->dev->dev, | ||
2117 | &bmc->guid_attr); | ||
2118 | 2182 | ||
2119 | printk(KERN_INFO | 2183 | printk(KERN_INFO |
2120 | "ipmi: Found new BMC (man_id: 0x%6.6x, " | 2184 | "ipmi: Found new BMC (man_id: 0x%6.6x, " |