From 0767699076e48c51b297297e28a412c9714231ee Mon Sep 17 00:00:00 2001
From: Florian Pose <fp@igh-essen.com>
Date: Thu, 12 Jun 2008 08:31:06 +0000
Subject: [PATCH] Replaced a few GFP_ATOMIC allocations with GFP_KERNEL ones.

---
 TODO                    | 2 --
 master/datagram.c       | 2 +-
 master/fsm_coe.c        | 8 ++++----
 master/fsm_master.c     | 4 ++--
 master/fsm_slave_scan.c | 2 +-
 5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/TODO b/TODO
index 4ff776fe..3d88c4a1 100644
--- a/TODO
+++ b/TODO
@@ -25,8 +25,6 @@ Version 1.4.0:
 * List of commands that require a slave.
 * Remove configs_attached flag.
 * Remove EC_IOCTL_DOMAIN_COUNT.
-* Remove ATOMIC allocations.
-* Clear FMMU configs.
 * Rename master MODE to STATE.
 
 Future issues:
diff --git a/master/datagram.c b/master/datagram.c
index 3fe4891f..3a5c938c 100644
--- a/master/datagram.c
+++ b/master/datagram.c
@@ -146,7 +146,7 @@ int ec_datagram_prealloc(
         datagram->mem_size = 0;
     }
 
-    if (!(datagram->data = kmalloc(size, GFP_ATOMIC))) {
+    if (!(datagram->data = kmalloc(size, GFP_KERNEL))) {
         EC_ERR("Failed to allocate %u bytes of datagram memory!\n", size);
         return -1;
     }
diff --git a/master/fsm_coe.c b/master/fsm_coe.c
index 866fc08b..9e5feaf1 100644
--- a/master/fsm_coe.c
+++ b/master/fsm_coe.c
@@ -466,7 +466,7 @@ void ec_fsm_coe_dict_response(ec_fsm_coe_t *fsm /**< finite state machine */)
             continue;
         }
 
-        if (!(sdo = (ec_sdo_t *) kmalloc(sizeof(ec_sdo_t), GFP_ATOMIC))) {
+        if (!(sdo = (ec_sdo_t *) kmalloc(sizeof(ec_sdo_t), GFP_KERNEL))) {
             EC_ERR("Failed to allocate memory for Sdo!\n");
             fsm->state = ec_fsm_coe_error;
             return;
@@ -689,7 +689,7 @@ void ec_fsm_coe_dict_desc_response(ec_fsm_coe_t *fsm
 
     name_size = rec_size - 12;
     if (name_size) {
-        if (!(sdo->name = kmalloc(name_size + 1, GFP_ATOMIC))) {
+        if (!(sdo->name = kmalloc(name_size + 1, GFP_KERNEL))) {
             EC_ERR("Failed to allocate Sdo name!\n");
             fsm->state = ec_fsm_coe_error;
             return;
@@ -904,7 +904,7 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
     data_size = rec_size - 16;
 
     if (!(entry = (ec_sdo_entry_t *)
-          kmalloc(sizeof(ec_sdo_entry_t), GFP_ATOMIC))) {
+          kmalloc(sizeof(ec_sdo_entry_t), GFP_KERNEL))) {
         EC_ERR("Failed to allocate entry!\n");
         fsm->state = ec_fsm_coe_error;
         return;
@@ -916,7 +916,7 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
 
     if (data_size) {
         uint8_t *desc;
-        if (!(desc = kmalloc(data_size + 1, GFP_ATOMIC))) {
+        if (!(desc = kmalloc(data_size + 1, GFP_KERNEL))) {
             EC_ERR("Failed to allocate Sdo entry name!\n");
             fsm->state = ec_fsm_coe_error;
             return;
diff --git a/master/fsm_master.c b/master/fsm_master.c
index 0bd635b3..b92d3f15 100644
--- a/master/fsm_master.c
+++ b/master/fsm_master.c
@@ -243,8 +243,8 @@ void ec_fsm_master_state_broadcast(
 
             // init slaves
             for (i = 0; i < master->slave_count; i++) {
-                if (!(slave = (ec_slave_t *) kmalloc(sizeof(ec_slave_t),
-                                GFP_ATOMIC))) {
+                if (!(slave = (ec_slave_t *)
+                            kmalloc(sizeof(ec_slave_t), GFP_KERNEL))) {
                     EC_ERR("Failed to allocate slave %u!\n", i);
                     ec_master_clear_slaves(master);
                     master->scan_busy = 0;
diff --git a/master/fsm_slave_scan.c b/master/fsm_slave_scan.c
index 77e6e7d9..9ebb990e 100644
--- a/master/fsm_slave_scan.c
+++ b/master/fsm_slave_scan.c
@@ -404,7 +404,7 @@ alloc_sii:
     }
 
     if (!(slave->sii_words =
-                (uint16_t *) kmalloc(slave->sii_nwords * 2, GFP_ATOMIC))) {
+                (uint16_t *) kmalloc(slave->sii_nwords * 2, GFP_KERNEL))) {
         EC_ERR("Failed to allocate %u words of SII data for slave %u.\n",
                slave->sii_nwords, slave->ring_position);
         slave->sii_nwords = 0;
-- 
GitLab