aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/char/raw3270.c39
-rw-r--r--drivers/s390/scsi/zfcp_aux.c60
2 files changed, 38 insertions, 61 deletions
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index bd06607a5dcc..eecb2afad5c2 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -28,6 +28,7 @@
28#include <linux/major.h> 28#include <linux/major.h>
29#include <linux/kdev_t.h> 29#include <linux/kdev_t.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/mutex.h>
31 32
32struct class *class3270; 33struct class *class3270;
33 34
@@ -59,7 +60,7 @@ struct raw3270 {
59#define RAW3270_FLAGS_CONSOLE 8 /* Device is the console. */ 60#define RAW3270_FLAGS_CONSOLE 8 /* Device is the console. */
60 61
61/* Semaphore to protect global data of raw3270 (devices, views, etc). */ 62/* Semaphore to protect global data of raw3270 (devices, views, etc). */
62static DECLARE_MUTEX(raw3270_sem); 63static DEFINE_MUTEX(raw3270_mutex);
63 64
64/* List of 3270 devices. */ 65/* List of 3270 devices. */
65static struct list_head raw3270_devices = LIST_HEAD_INIT(raw3270_devices); 66static struct list_head raw3270_devices = LIST_HEAD_INIT(raw3270_devices);
@@ -815,7 +816,7 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc)
815 * number for it. Note: there is no device with minor 0, 816 * number for it. Note: there is no device with minor 0,
816 * see special case for fs3270.c:fs3270_open(). 817 * see special case for fs3270.c:fs3270_open().
817 */ 818 */
818 down(&raw3270_sem); 819 mutex_lock(&raw3270_mutex);
819 /* Keep the list sorted. */ 820 /* Keep the list sorted. */
820 minor = RAW3270_FIRSTMINOR; 821 minor = RAW3270_FIRSTMINOR;
821 rp->minor = -1; 822 rp->minor = -1;
@@ -832,7 +833,7 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc)
832 rp->minor = minor; 833 rp->minor = minor;
833 list_add_tail(&rp->list, &raw3270_devices); 834 list_add_tail(&rp->list, &raw3270_devices);
834 } 835 }
835 up(&raw3270_sem); 836 mutex_unlock(&raw3270_mutex);
836 /* No free minor number? Then give up. */ 837 /* No free minor number? Then give up. */
837 if (rp->minor == -1) 838 if (rp->minor == -1)
838 return -EUSERS; 839 return -EUSERS;
@@ -1003,7 +1004,7 @@ raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor)
1003 1004
1004 if (minor <= 0) 1005 if (minor <= 0)
1005 return -ENODEV; 1006 return -ENODEV;
1006 down(&raw3270_sem); 1007 mutex_lock(&raw3270_mutex);
1007 rc = -ENODEV; 1008 rc = -ENODEV;
1008 list_for_each_entry(rp, &raw3270_devices, list) { 1009 list_for_each_entry(rp, &raw3270_devices, list) {
1009 if (rp->minor != minor) 1010 if (rp->minor != minor)
@@ -1024,7 +1025,7 @@ raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor)
1024 spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); 1025 spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
1025 break; 1026 break;
1026 } 1027 }
1027 up(&raw3270_sem); 1028 mutex_unlock(&raw3270_mutex);
1028 return rc; 1029 return rc;
1029} 1030}
1030 1031
@@ -1038,7 +1039,7 @@ raw3270_find_view(struct raw3270_fn *fn, int minor)
1038 struct raw3270_view *view, *tmp; 1039 struct raw3270_view *view, *tmp;
1039 unsigned long flags; 1040 unsigned long flags;
1040 1041
1041 down(&raw3270_sem); 1042 mutex_lock(&raw3270_mutex);
1042 view = ERR_PTR(-ENODEV); 1043 view = ERR_PTR(-ENODEV);
1043 list_for_each_entry(rp, &raw3270_devices, list) { 1044 list_for_each_entry(rp, &raw3270_devices, list) {
1044 if (rp->minor != minor) 1045 if (rp->minor != minor)
@@ -1057,7 +1058,7 @@ raw3270_find_view(struct raw3270_fn *fn, int minor)
1057 spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); 1058 spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
1058 break; 1059 break;
1059 } 1060 }
1060 up(&raw3270_sem); 1061 mutex_unlock(&raw3270_mutex);
1061 return view; 1062 return view;
1062} 1063}
1063 1064
@@ -1104,7 +1105,7 @@ raw3270_delete_device(struct raw3270 *rp)
1104 struct ccw_device *cdev; 1105 struct ccw_device *cdev;
1105 1106
1106 /* Remove from device chain. */ 1107 /* Remove from device chain. */
1107 down(&raw3270_sem); 1108 mutex_lock(&raw3270_mutex);
1108 if (rp->clttydev) 1109 if (rp->clttydev)
1109 class_device_destroy(class3270, 1110 class_device_destroy(class3270,
1110 MKDEV(IBM_TTY3270_MAJOR, rp->minor)); 1111 MKDEV(IBM_TTY3270_MAJOR, rp->minor));
@@ -1112,7 +1113,7 @@ raw3270_delete_device(struct raw3270 *rp)
1112 class_device_destroy(class3270, 1113 class_device_destroy(class3270,
1113 MKDEV(IBM_FS3270_MAJOR, rp->minor)); 1114 MKDEV(IBM_FS3270_MAJOR, rp->minor));
1114 list_del_init(&rp->list); 1115 list_del_init(&rp->list);
1115 up(&raw3270_sem); 1116 mutex_unlock(&raw3270_mutex);
1116 1117
1117 /* Disconnect from ccw_device. */ 1118 /* Disconnect from ccw_device. */
1118 cdev = rp->cdev; 1119 cdev = rp->cdev;
@@ -1208,13 +1209,13 @@ int raw3270_register_notifier(void (*notifier)(int, int))
1208 if (!np) 1209 if (!np)
1209 return -ENOMEM; 1210 return -ENOMEM;
1210 np->notifier = notifier; 1211 np->notifier = notifier;
1211 down(&raw3270_sem); 1212 mutex_lock(&raw3270_mutex);
1212 list_add_tail(&np->list, &raw3270_notifier); 1213 list_add_tail(&np->list, &raw3270_notifier);
1213 list_for_each_entry(rp, &raw3270_devices, list) { 1214 list_for_each_entry(rp, &raw3270_devices, list) {
1214 get_device(&rp->cdev->dev); 1215 get_device(&rp->cdev->dev);
1215 notifier(rp->minor, 1); 1216 notifier(rp->minor, 1);
1216 } 1217 }
1217 up(&raw3270_sem); 1218 mutex_unlock(&raw3270_mutex);
1218 return 0; 1219 return 0;
1219} 1220}
1220 1221
@@ -1222,14 +1223,14 @@ void raw3270_unregister_notifier(void (*notifier)(int, int))
1222{ 1223{
1223 struct raw3270_notifier *np; 1224 struct raw3270_notifier *np;
1224 1225
1225 down(&raw3270_sem); 1226 mutex_lock(&raw3270_mutex);
1226 list_for_each_entry(np, &raw3270_notifier, list) 1227 list_for_each_entry(np, &raw3270_notifier, list)
1227 if (np->notifier == notifier) { 1228 if (np->notifier == notifier) {
1228 list_del(&np->list); 1229 list_del(&np->list);
1229 kfree(np); 1230 kfree(np);
1230 break; 1231 break;
1231 } 1232 }
1232 up(&raw3270_sem); 1233 mutex_unlock(&raw3270_mutex);
1233} 1234}
1234 1235
1235/* 1236/*
@@ -1256,10 +1257,10 @@ raw3270_set_online (struct ccw_device *cdev)
1256 goto failure; 1257 goto failure;
1257 raw3270_create_attributes(rp); 1258 raw3270_create_attributes(rp);
1258 set_bit(RAW3270_FLAGS_READY, &rp->flags); 1259 set_bit(RAW3270_FLAGS_READY, &rp->flags);
1259 down(&raw3270_sem); 1260 mutex_lock(&raw3270_mutex);
1260 list_for_each_entry(np, &raw3270_notifier, list) 1261 list_for_each_entry(np, &raw3270_notifier, list)
1261 np->notifier(rp->minor, 1); 1262 np->notifier(rp->minor, 1);
1262 up(&raw3270_sem); 1263 mutex_unlock(&raw3270_mutex);
1263 return 0; 1264 return 0;
1264 1265
1265failure: 1266failure:
@@ -1307,10 +1308,10 @@ raw3270_remove (struct ccw_device *cdev)
1307 } 1308 }
1308 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); 1309 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
1309 1310
1310 down(&raw3270_sem); 1311 mutex_lock(&raw3270_mutex);
1311 list_for_each_entry(np, &raw3270_notifier, list) 1312 list_for_each_entry(np, &raw3270_notifier, list)
1312 np->notifier(rp->minor, 0); 1313 np->notifier(rp->minor, 0);
1313 up(&raw3270_sem); 1314 mutex_unlock(&raw3270_mutex);
1314 1315
1315 /* Reset 3270 device. */ 1316 /* Reset 3270 device. */
1316 raw3270_reset_device(rp); 1317 raw3270_reset_device(rp);
@@ -1370,13 +1371,13 @@ raw3270_init(void)
1370 rc = ccw_driver_register(&raw3270_ccw_driver); 1371 rc = ccw_driver_register(&raw3270_ccw_driver);
1371 if (rc == 0) { 1372 if (rc == 0) {
1372 /* Create attributes for early (= console) device. */ 1373 /* Create attributes for early (= console) device. */
1373 down(&raw3270_sem); 1374 mutex_lock(&raw3270_mutex);
1374 class3270 = class_create(THIS_MODULE, "3270"); 1375 class3270 = class_create(THIS_MODULE, "3270");
1375 list_for_each_entry(rp, &raw3270_devices, list) { 1376 list_for_each_entry(rp, &raw3270_devices, list) {
1376 get_device(&rp->cdev->dev); 1377 get_device(&rp->cdev->dev);
1377 raw3270_create_attributes(rp); 1378 raw3270_create_attributes(rp);
1378 } 1379 }
1379 up(&raw3270_sem); 1380 mutex_unlock(&raw3270_mutex);
1380 } 1381 }
1381 return rc; 1382 return rc;
1382} 1383}
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 95b92f317b6f..395cfc6a344f 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -829,18 +829,6 @@ zfcp_unit_dequeue(struct zfcp_unit *unit)
829 device_unregister(&unit->sysfs_device); 829 device_unregister(&unit->sysfs_device);
830} 830}
831 831
832static void *
833zfcp_mempool_alloc(gfp_t gfp_mask, void *size)
834{
835 return kmalloc((size_t) size, gfp_mask);
836}
837
838static void
839zfcp_mempool_free(void *element, void *size)
840{
841 kfree(element);
842}
843
844/* 832/*
845 * Allocates a combined QTCB/fsf_req buffer for erp actions and fcp/SCSI 833 * Allocates a combined QTCB/fsf_req buffer for erp actions and fcp/SCSI
846 * commands. 834 * commands.
@@ -853,51 +841,39 @@ static int
853zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter) 841zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)
854{ 842{
855 adapter->pool.fsf_req_erp = 843 adapter->pool.fsf_req_erp =
856 mempool_create(ZFCP_POOL_FSF_REQ_ERP_NR, 844 mempool_create_kmalloc_pool(ZFCP_POOL_FSF_REQ_ERP_NR,
857 zfcp_mempool_alloc, zfcp_mempool_free, (void *) 845 sizeof(struct zfcp_fsf_req_pool_element));
858 sizeof(struct zfcp_fsf_req_pool_element)); 846 if (!adapter->pool.fsf_req_erp)
859
860 if (NULL == adapter->pool.fsf_req_erp)
861 return -ENOMEM; 847 return -ENOMEM;
862 848
863 adapter->pool.fsf_req_scsi = 849 adapter->pool.fsf_req_scsi =
864 mempool_create(ZFCP_POOL_FSF_REQ_SCSI_NR, 850 mempool_create_kmalloc_pool(ZFCP_POOL_FSF_REQ_SCSI_NR,
865 zfcp_mempool_alloc, zfcp_mempool_free, (void *) 851 sizeof(struct zfcp_fsf_req_pool_element));
866 sizeof(struct zfcp_fsf_req_pool_element)); 852 if (!adapter->pool.fsf_req_scsi)
867
868 if (NULL == adapter->pool.fsf_req_scsi)
869 return -ENOMEM; 853 return -ENOMEM;
870 854
871 adapter->pool.fsf_req_abort = 855 adapter->pool.fsf_req_abort =
872 mempool_create(ZFCP_POOL_FSF_REQ_ABORT_NR, 856 mempool_create_kmalloc_pool(ZFCP_POOL_FSF_REQ_ABORT_NR,
873 zfcp_mempool_alloc, zfcp_mempool_free, (void *) 857 sizeof(struct zfcp_fsf_req_pool_element));
874 sizeof(struct zfcp_fsf_req_pool_element)); 858 if (!adapter->pool.fsf_req_abort)
875
876 if (NULL == adapter->pool.fsf_req_abort)
877 return -ENOMEM; 859 return -ENOMEM;
878 860
879 adapter->pool.fsf_req_status_read = 861 adapter->pool.fsf_req_status_read =
880 mempool_create(ZFCP_POOL_STATUS_READ_NR, 862 mempool_create_kmalloc_pool(ZFCP_POOL_STATUS_READ_NR,
881 zfcp_mempool_alloc, zfcp_mempool_free, 863 sizeof(struct zfcp_fsf_req));
882 (void *) sizeof(struct zfcp_fsf_req)); 864 if (!adapter->pool.fsf_req_status_read)
883
884 if (NULL == adapter->pool.fsf_req_status_read)
885 return -ENOMEM; 865 return -ENOMEM;
886 866
887 adapter->pool.data_status_read = 867 adapter->pool.data_status_read =
888 mempool_create(ZFCP_POOL_STATUS_READ_NR, 868 mempool_create_kmalloc_pool(ZFCP_POOL_STATUS_READ_NR,
889 zfcp_mempool_alloc, zfcp_mempool_free, 869 sizeof(struct fsf_status_read_buffer));
890 (void *) sizeof(struct fsf_status_read_buffer)); 870 if (!adapter->pool.data_status_read)
891
892 if (NULL == adapter->pool.data_status_read)
893 return -ENOMEM; 871 return -ENOMEM;
894 872
895 adapter->pool.data_gid_pn = 873 adapter->pool.data_gid_pn =
896 mempool_create(ZFCP_POOL_DATA_GID_PN_NR, 874 mempool_create_kmalloc_pool(ZFCP_POOL_DATA_GID_PN_NR,
897 zfcp_mempool_alloc, zfcp_mempool_free, (void *) 875 sizeof(struct zfcp_gid_pn_data));
898 sizeof(struct zfcp_gid_pn_data)); 876 if (!adapter->pool.data_gid_pn)
899
900 if (NULL == adapter->pool.data_gid_pn)
901 return -ENOMEM; 877 return -ENOMEM;
902 878
903 return 0; 879 return 0;