mic: vop: Fix use-after-free on remove
[linux/fpc-iii.git] / drivers / scsi / snic / snic_attrs.c
blob32d5d556b6f87ac18be9c1fd61355ff2b808e5c3
1 /*
2 * Copyright 2014 Cisco Systems, Inc. All rights reserved.
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15 * SOFTWARE.
18 #include <linux/string.h>
19 #include <linux/device.h>
21 #include "snic.h"
23 static ssize_t
24 snic_show_sym_name(struct device *dev,
25 struct device_attribute *attr,
26 char *buf)
28 struct snic *snic = shost_priv(class_to_shost(dev));
30 return snprintf(buf, PAGE_SIZE, "%s\n", snic->name);
33 static ssize_t
34 snic_show_state(struct device *dev,
35 struct device_attribute *attr,
36 char *buf)
38 struct snic *snic = shost_priv(class_to_shost(dev));
40 return snprintf(buf, PAGE_SIZE, "%s\n",
41 snic_state_str[snic_get_state(snic)]);
44 static ssize_t
45 snic_show_drv_version(struct device *dev,
46 struct device_attribute *attr,
47 char *buf)
49 return snprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION);
52 static ssize_t
53 snic_show_link_state(struct device *dev,
54 struct device_attribute *attr,
55 char *buf)
57 struct snic *snic = shost_priv(class_to_shost(dev));
59 if (snic->config.xpt_type == SNIC_DAS)
60 snic->link_status = svnic_dev_link_status(snic->vdev);
62 return snprintf(buf, PAGE_SIZE, "%s\n",
63 (snic->link_status) ? "Link Up" : "Link Down");
66 static DEVICE_ATTR(snic_sym_name, S_IRUGO, snic_show_sym_name, NULL);
67 static DEVICE_ATTR(snic_state, S_IRUGO, snic_show_state, NULL);
68 static DEVICE_ATTR(drv_version, S_IRUGO, snic_show_drv_version, NULL);
69 static DEVICE_ATTR(link_state, S_IRUGO, snic_show_link_state, NULL);
71 struct device_attribute *snic_attrs[] = {
72 &dev_attr_snic_sym_name,
73 &dev_attr_snic_state,
74 &dev_attr_drv_version,
75 &dev_attr_link_state,
76 NULL,