Re: [Resend, PATCH v1] ISDN: eicon: switch to use native bitmaps

2017-07-19 Thread David Miller
From: Andy Shevchenko 
Date: Tue, 18 Jul 2017 18:49:26 +0300

> Two arrays are clearly bit maps, so, make that explicit by converting to
> bitmap API and remove custom helpers.
> 
> Note sig_ind() uses out of boundary bit to (looks like) protect against
> potential bitmap_empty() checks for the same bitmap.
> 
> This patch removes that since:
> 1) that didn't guarantee atomicity anyway;
> 2) the first operation inside the for-loop is set bit in the bitmap
>(which effectively makes it non-empty);
> 3) group_optimization() doesn't utilize possible emptiness of the bitmap
>in question.
> 
> Thus, if there is a protection needed it should be implemented properly.
> 
> Signed-off-by: Andy Shevchenko 

Applied, thanks.


[Resend, PATCH v1] ISDN: eicon: switch to use native bitmaps

2017-07-18 Thread Andy Shevchenko
Two arrays are clearly bit maps, so, make that explicit by converting to
bitmap API and remove custom helpers.

Note sig_ind() uses out of boundary bit to (looks like) protect against
potential bitmap_empty() checks for the same bitmap.

This patch removes that since:
1) that didn't guarantee atomicity anyway;
2) the first operation inside the for-loop is set bit in the bitmap
   (which effectively makes it non-empty);
3) group_optimization() doesn't utilize possible emptiness of the bitmap
   in question.

Thus, if there is a protection needed it should be implemented properly.

Signed-off-by: Andy Shevchenko 
---
- resend after v4.13-rc1 is out
 drivers/isdn/hardware/eicon/divacapi.h |  16 +--
 drivers/isdn/hardware/eicon/message.c  | 247 -
 2 files changed, 58 insertions(+), 205 deletions(-)

diff --git a/drivers/isdn/hardware/eicon/divacapi.h 
b/drivers/isdn/hardware/eicon/divacapi.h
index a315a2914d70..c4868a0d82f4 100644
--- a/drivers/isdn/hardware/eicon/divacapi.h
+++ b/drivers/isdn/hardware/eicon/divacapi.h
@@ -26,15 +26,7 @@
 
 /*#define DEBUG */
 
-
-
-
-
-
-
-
-
-
+#include 
 
 #define IMPLEMENT_DTMF 1
 #define IMPLEMENT_LINE_INTERCONNECT2 1
@@ -82,8 +74,6 @@
 #define CODEC_PERMANENT0x02
 #define ADV_VOICE  0x03
 #define MAX_CIP_TYPES  5  /* kind of CIP types for group optimization */
-#define C_IND_MASK_DWORDS  ((MAX_APPL + 32) >> 5)
-
 
 #define FAX_CONNECT_INFO_BUFFER_SIZE  256
 #define NCPI_BUFFER_SIZE  256
@@ -265,8 +255,8 @@ struct _PLCI {
word  ncci_ring_list;
byte  inc_dis_ncci_table[MAX_CHANNELS_PER_PLCI];
t_std_internal_command 
internal_command_queue[MAX_INTERNAL_COMMAND_LEVELS];
-   dword c_ind_mask_table[C_IND_MASK_DWORDS];
-   dword group_optimization_mask_table[C_IND_MASK_DWORDS];
+   DECLARE_BITMAP(c_ind_mask_table, MAX_APPL);
+   DECLARE_BITMAP(group_optimization_mask_table, MAX_APPL);
byte  RBuffer[200];
dword msg_in_queue[MSG_IN_QUEUE_SIZE/sizeof(dword)];
API_SAVE  saved_msg;
diff --git a/drivers/isdn/hardware/eicon/message.c 
b/drivers/isdn/hardware/eicon/message.c
index 3b11422b1cce..eadd1ed1e014 100644
--- a/drivers/isdn/hardware/eicon/message.c
+++ b/drivers/isdn/hardware/eicon/message.c
@@ -23,9 +23,7 @@
  *
  */
 
-
-
-
+#include 
 
 #include "platform.h"
 #include "di_defs.h"
@@ -35,19 +33,9 @@
 #include "mdm_msg.h"
 #include "divasync.h"
 
-
-
 #define FILE_ "MESSAGE.C"
 #define dprintf
 
-
-
-
-
-
-
-
-
 /*--*/
 /* This is options supported for all adapters that are server by*/
 /* XDI driver. Allo it is not necessary to ask it from every adapter*/
@@ -72,9 +60,6 @@ static dword diva_xdi_extended_features = 0;
 /*--*/
 
 static void group_optimization(DIVA_CAPI_ADAPTER *a, PLCI *plci);
-static void set_group_ind_mask(PLCI *plci);
-static void clear_group_ind_mask_bit(PLCI *plci, word b);
-static byte test_group_ind_mask_bit(PLCI *plci, word b);
 void AutomaticLaw(DIVA_CAPI_ADAPTER *);
 word CapiRelease(word);
 word CapiRegister(word);
@@ -1087,106 +1072,6 @@ static void plci_remove(PLCI *plci)
 }
 
 /*--*/
-/* Application Group function helpers   */
-/*--*/
-
-static void set_group_ind_mask(PLCI *plci)
-{
-   word i;
-
-   for (i = 0; i < C_IND_MASK_DWORDS; i++)
-   plci->group_optimization_mask_table[i] = 0xL;
-}
-
-static void clear_group_ind_mask_bit(PLCI *plci, word b)
-{
-   plci->group_optimization_mask_table[b >> 5] &= ~(1L << (b & 0x1f));
-}
-
-static byte test_group_ind_mask_bit(PLCI *plci, word b)
-{
-   return ((plci->group_optimization_mask_table[b >> 5] & (1L << (b & 
0x1f))) != 0);
-}
-
-/*--*/
-/* c_ind_mask operations for arbitrary MAX_APPL */
-/*--*/
-
-static void clear_c_ind_mask(PLCI *plci)
-{
-   word i;
-
-   for (i = 0; i < C_IND_MASK_DWORDS; i++)
-   plci->c_ind_mask_table[i] = 0;
-}
-
-static byte c_ind_mask_empty(PLCI *plci)
-{
-   word i;
-
-   i = 0;
-   while ((i < C_IND_MASK_DWORDS) && (plci->c_ind_mask_table[i] == 0))
-   i++;
-   return (i == C_IND_MASK_DWORDS);
-}
-
-static void set_c_ind_mask_bit(PLCI *plci, word b)
-{
-   plci->c_ind_mask_table[b >> 5] |= (1L << (b & 0x1f));
-}
-
-static void clear_c_ind_mask_bit(PLCI *plci, word b)
-{
-   plci->c_ind_mask_table[b >> 5] &= ~(1L << (b & 0x1f));
-}
-
-static byte test_c_ind_mask_bit(PLCI *plci, word b)
-{
-   return ((plci->c_ind_mask_table[b >> 5] & (1L