diff options
-rw-r--r-- | drivers/scsi/scsi_debug.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 2a388d06094a..161af1ded888 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
@@ -2014,6 +2014,19 @@ static void scsi_debug_slave_destroy(struct scsi_device * sdp) | |||
2014 | } | 2014 | } |
2015 | } | 2015 | } |
2016 | 2016 | ||
2017 | struct sdebug_dev_info *sdebug_device_create(struct sdebug_host_info *sdbg_host, | ||
2018 | gfp_t flags) | ||
2019 | { | ||
2020 | struct sdebug_dev_info *devip; | ||
2021 | |||
2022 | devip = kzalloc(sizeof(*devip), flags); | ||
2023 | if (devip) { | ||
2024 | devip->sdbg_host = sdbg_host; | ||
2025 | list_add_tail(&devip->dev_list, &sdbg_host->dev_info_list); | ||
2026 | } | ||
2027 | return devip; | ||
2028 | } | ||
2029 | |||
2017 | static struct sdebug_dev_info * devInfoReg(struct scsi_device * sdev) | 2030 | static struct sdebug_dev_info * devInfoReg(struct scsi_device * sdev) |
2018 | { | 2031 | { |
2019 | struct sdebug_host_info * sdbg_host; | 2032 | struct sdebug_host_info * sdbg_host; |
@@ -2038,16 +2051,13 @@ static struct sdebug_dev_info * devInfoReg(struct scsi_device * sdev) | |||
2038 | open_devip = devip; | 2051 | open_devip = devip; |
2039 | } | 2052 | } |
2040 | } | 2053 | } |
2041 | if (NULL == open_devip) { /* try and make a new one */ | 2054 | if (!open_devip) { /* try and make a new one */ |
2042 | open_devip = kzalloc(sizeof(*open_devip),GFP_ATOMIC); | 2055 | open_devip = sdebug_device_create(sdbg_host, GFP_ATOMIC); |
2043 | if (NULL == open_devip) { | 2056 | if (!open_devip) { |
2044 | printk(KERN_ERR "%s: out of memory at line %d\n", | 2057 | printk(KERN_ERR "%s: out of memory at line %d\n", |
2045 | __FUNCTION__, __LINE__); | 2058 | __FUNCTION__, __LINE__); |
2046 | return NULL; | 2059 | return NULL; |
2047 | } | 2060 | } |
2048 | open_devip->sdbg_host = sdbg_host; | ||
2049 | list_add_tail(&open_devip->dev_list, | ||
2050 | &sdbg_host->dev_info_list); | ||
2051 | } | 2061 | } |
2052 | if (open_devip) { | 2062 | if (open_devip) { |
2053 | open_devip->channel = sdev->channel; | 2063 | open_devip->channel = sdev->channel; |
@@ -2935,16 +2945,13 @@ static int sdebug_add_adapter(void) | |||
2935 | 2945 | ||
2936 | devs_per_host = scsi_debug_num_tgts * scsi_debug_max_luns; | 2946 | devs_per_host = scsi_debug_num_tgts * scsi_debug_max_luns; |
2937 | for (k = 0; k < devs_per_host; k++) { | 2947 | for (k = 0; k < devs_per_host; k++) { |
2938 | sdbg_devinfo = kzalloc(sizeof(*sdbg_devinfo),GFP_KERNEL); | 2948 | sdbg_devinfo = sdebug_device_create(sdbg_host, GFP_KERNEL); |
2939 | if (NULL == sdbg_devinfo) { | 2949 | if (!sdbg_devinfo) { |
2940 | printk(KERN_ERR "%s: out of memory at line %d\n", | 2950 | printk(KERN_ERR "%s: out of memory at line %d\n", |
2941 | __FUNCTION__, __LINE__); | 2951 | __FUNCTION__, __LINE__); |
2942 | error = -ENOMEM; | 2952 | error = -ENOMEM; |
2943 | goto clean; | 2953 | goto clean; |
2944 | } | 2954 | } |
2945 | sdbg_devinfo->sdbg_host = sdbg_host; | ||
2946 | list_add_tail(&sdbg_devinfo->dev_list, | ||
2947 | &sdbg_host->dev_info_list); | ||
2948 | } | 2955 | } |
2949 | 2956 | ||
2950 | spin_lock(&sdebug_host_list_lock); | 2957 | spin_lock(&sdebug_host_list_lock); |