Re: [PATCH 1/2] staging: dgnc: remove redundant NULL check for brd

2016-05-26 Thread DaeSeok Youn
2016-05-26 21:29 GMT+09:00 Luis de Bethencourt <lui...@osg.samsung.com>:
> On 26/05/16 05:56, DaeSeok Youn wrote:
>> 2016-05-26 6:48 GMT+09:00 Luis de Bethencourt <lui...@osg.samsung.com>:
>>> On 20/05/16 10:51, Daeseok Youn wrote:
>>>> the "brd" value cannot be NULL in dgnc_finalize_board_init().
>>>> Because "brd" as a parameter of this function was already
>>>> checked for NULL.
>>>>
>>>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>>>> ---
>>>>  drivers/staging/dgnc/dgnc_driver.c | 3 ---
>>>>  1 file changed, 3 deletions(-)
>>>>
>>>> diff --git a/drivers/staging/dgnc/dgnc_driver.c 
>>>> b/drivers/staging/dgnc/dgnc_driver.c
>>>> index af2e835..22257d2 100644
>>>> --- a/drivers/staging/dgnc/dgnc_driver.c
>>>> +++ b/drivers/staging/dgnc/dgnc_driver.c
>>>> @@ -579,9 +579,6 @@ static int dgnc_finalize_board_init(struct dgnc_board 
>>>> *brd)
>>>>  {
>>>>   int rc = 0;
>>>>
>>>> - if (!brd || brd->magic != DGNC_BOARD_MAGIC)
>>>> - return -ENODEV;
>>>> -
>>>>   if (brd->irq) {
>>>>   rc = request_irq(brd->irq, brd->bd_ops->intr,
>>>>IRQF_SHARED, "DGNC", brd);
>>>>
>>>
>>> This is partially correct, the check for brd being NULL is in line 371.
>> Hi Luis,
>>
>> Yes, right. but also brd was assigned the value DGNC_BOARD_MAGIC in line 384.
>> brd->magic = DGNC_BOARD_MAGIC;
>> and also dgnc_finalize_board_init() as a static function is only
>> called in dgnc_found_board(), right?
>>
>>>
>>> But there is a second check for brd->magic != DGNC_BOARD_MAGIC. Do you want
>>> to keep that one?
>> So.. I think it doesn't need to check about DGNC_BOARD_MAGIC.
>
> This is good. I was asking just to make sure it was your intention.
>
> Please add the reason to drop that second check in the commit message as 
> well. So people
> reading the git log can understand both parts. For both patches.
OK. I will update the change log and resend it.

Thanks.

regards,
Daeseok.
>
> Thanks for the fixes :)
>
> Luis
>
>>
>>>
>>> Also, how did you find this patch. It is useful to mention this in the 
>>> commit
>>> message if it was through some static analysis tool. For people using these 
>>> tools
>>> in the future.
>> There are some static analysis tool for checking linux kernel code.
>> But I didn't use
>> those tools for this patch. sometimes, I usually run "smatch" tool for
>> checking linux kernel
>> code.
>>
>> thanks.
>> regards,
>> Daeseok.
>>
>>>
>>> Thanks for the patch :)
>>> Luis
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] staging: dgnc: remove redundant null check in

2016-05-25 Thread DaeSeok Youn
2016-05-26 7:00 GMT+09:00 Luis de Bethencourt <lui...@osg.samsung.com>:
> On 20/05/16 10:51, Daeseok Youn wrote:
>> the "brd" was already checked for NULL before calling dgnc_do_remap().
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>> ---
>>  drivers/staging/dgnc/dgnc_driver.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/drivers/staging/dgnc/dgnc_driver.c 
>> b/drivers/staging/dgnc/dgnc_driver.c
>> index 22257d2..1882ef5 100644
>> --- a/drivers/staging/dgnc/dgnc_driver.c
>> +++ b/drivers/staging/dgnc/dgnc_driver.c
>> @@ -599,9 +599,6 @@ static int dgnc_finalize_board_init(struct dgnc_board 
>> *brd)
>>   */
>>  static void dgnc_do_remap(struct dgnc_board *brd)
>>  {
>> - if (!brd || brd->magic != DGNC_BOARD_MAGIC)
>> - return;
>> -
>>   brd->re_map_membase = ioremap(brd->membase, 0x1000);
>>  }
>>
>>
>
> Same comment as the 1/2 patch.
I sent an e-mail from the 1/2 patch. it has same reason for this patch.

dgnc_do_remap() function is called twice only in dgnc_found_board() function.
and also DNGC_BOARD_MAGIC was assigned into "brd->magic".

So I think it doesn't need to check about DGNC_BOARD_MAGIC.

thanks
regards,
Daeseok.

>
> Do you want to keep the brd->magic != DGNC_BOARD_MAGIC check?
>
> Thanks,
> Luis
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] staging: dgnc: remove redundant NULL check for brd

2016-05-25 Thread DaeSeok Youn
2016-05-26 6:48 GMT+09:00 Luis de Bethencourt <lui...@osg.samsung.com>:
> On 20/05/16 10:51, Daeseok Youn wrote:
>> the "brd" value cannot be NULL in dgnc_finalize_board_init().
>> Because "brd" as a parameter of this function was already
>> checked for NULL.
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>> ---
>>  drivers/staging/dgnc/dgnc_driver.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/drivers/staging/dgnc/dgnc_driver.c 
>> b/drivers/staging/dgnc/dgnc_driver.c
>> index af2e835..22257d2 100644
>> --- a/drivers/staging/dgnc/dgnc_driver.c
>> +++ b/drivers/staging/dgnc/dgnc_driver.c
>> @@ -579,9 +579,6 @@ static int dgnc_finalize_board_init(struct dgnc_board 
>> *brd)
>>  {
>>   int rc = 0;
>>
>> - if (!brd || brd->magic != DGNC_BOARD_MAGIC)
>> - return -ENODEV;
>> -
>>   if (brd->irq) {
>>   rc = request_irq(brd->irq, brd->bd_ops->intr,
>>IRQF_SHARED, "DGNC", brd);
>>
>
> This is partially correct, the check for brd being NULL is in line 371.
Hi Luis,

Yes, right. but also brd was assigned the value DGNC_BOARD_MAGIC in line 384.
brd->magic = DGNC_BOARD_MAGIC;
and also dgnc_finalize_board_init() as a static function is only
called in dgnc_found_board(), right?

>
> But there is a second check for brd->magic != DGNC_BOARD_MAGIC. Do you want
> to keep that one?
So.. I think it doesn't need to check about DGNC_BOARD_MAGIC.

>
> Also, how did you find this patch. It is useful to mention this in the commit
> message if it was through some static analysis tool. For people using these 
> tools
> in the future.
There are some static analysis tool for checking linux kernel code.
But I didn't use
those tools for this patch. sometimes, I usually run "smatch" tool for
checking linux kernel
code.

thanks.
regards,
Daeseok.

>
> Thanks for the patch :)
> Luis
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: dgnc: remove redundant null check in

2016-05-20 Thread Daeseok Youn
the "brd" was already checked for NULL before calling dgnc_do_remap().

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 22257d2..1882ef5 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -599,9 +599,6 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd)
  */
 static void dgnc_do_remap(struct dgnc_board *brd)
 {
-   if (!brd || brd->magic != DGNC_BOARD_MAGIC)
-   return;
-
brd->re_map_membase = ioremap(brd->membase, 0x1000);
 }
 
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: dgnc: remove redundant NULL check for brd

2016-05-20 Thread Daeseok Youn
the "brd" value cannot be NULL in dgnc_finalize_board_init().
Because "brd" as a parameter of this function was already
checked for NULL.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index af2e835..22257d2 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -579,9 +579,6 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd)
 {
int rc = 0;
 
-   if (!brd || brd->magic != DGNC_BOARD_MAGIC)
-   return -ENODEV;
-
if (brd->irq) {
rc = request_irq(brd->irq, brd->bd_ops->intr,
 IRQF_SHARED, "DGNC", brd);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgnc: re-arrange functions for removing forward

2016-05-13 Thread Daeseok Youn
Re-arrange the functions for removing forward declarations in dgnc_cls.c file.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
After applying this patch, the object file size was NOT changed.

 drivers/staging/dgnc/dgnc_cls.c | 949 +++-
 1 file changed, 460 insertions(+), 489 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 46c050c..2347bdc 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -26,56 +26,6 @@
 #include "dgnc_cls.h"
 #include "dgnc_tty.h"
 
-static inline void cls_parse_isr(struct dgnc_board *brd, uint port);
-static inline void cls_clear_break(struct channel_t *ch, int force);
-static inline void cls_set_cts_flow_control(struct channel_t *ch);
-static inline void cls_set_rts_flow_control(struct channel_t *ch);
-static inline void cls_set_ixon_flow_control(struct channel_t *ch);
-static inline void cls_set_ixoff_flow_control(struct channel_t *ch);
-static inline void cls_set_no_output_flow_control(struct channel_t *ch);
-static inline void cls_set_no_input_flow_control(struct channel_t *ch);
-static void cls_parse_modem(struct channel_t *ch, unsigned char signals);
-static void cls_tasklet(unsigned long data);
-static void cls_vpd(struct dgnc_board *brd);
-static void cls_uart_init(struct channel_t *ch);
-static void cls_uart_off(struct channel_t *ch);
-static int cls_drain(struct tty_struct *tty, uint seconds);
-static void cls_param(struct tty_struct *tty);
-static void cls_assert_modem_signals(struct channel_t *ch);
-static void cls_flush_uart_write(struct channel_t *ch);
-static void cls_flush_uart_read(struct channel_t *ch);
-static void cls_disable_receiver(struct channel_t *ch);
-static void cls_enable_receiver(struct channel_t *ch);
-static void cls_send_break(struct channel_t *ch, int msecs);
-static void cls_send_start_character(struct channel_t *ch);
-static void cls_send_stop_character(struct channel_t *ch);
-static void cls_copy_data_from_uart_to_queue(struct channel_t *ch);
-static void cls_copy_data_from_queue_to_uart(struct channel_t *ch);
-static uint cls_get_uart_bytes_left(struct channel_t *ch);
-static void cls_send_immediate_char(struct channel_t *ch, unsigned char);
-static irqreturn_t cls_intr(int irq, void *voidbrd);
-
-struct board_ops dgnc_cls_ops = {
-   .tasklet =  cls_tasklet,
-   .intr = cls_intr,
-   .uart_init =cls_uart_init,
-   .uart_off = cls_uart_off,
-   .drain =cls_drain,
-   .param =cls_param,
-   .vpd =  cls_vpd,
-   .assert_modem_signals = cls_assert_modem_signals,
-   .flush_uart_write = cls_flush_uart_write,
-   .flush_uart_read =  cls_flush_uart_read,
-   .disable_receiver = cls_disable_receiver,
-   .enable_receiver =  cls_enable_receiver,
-   .send_break =   cls_send_break,
-   .send_start_character = cls_send_start_character,
-   .send_stop_character =  cls_send_stop_character,
-   .copy_data_from_queue_to_uart = cls_copy_data_from_queue_to_uart,
-   .get_uart_bytes_left =  cls_get_uart_bytes_left,
-   .send_immediate_char =  cls_send_immediate_char
-};
-
 static inline void cls_set_cts_flow_control(struct channel_t *ch)
 {
unsigned char lcrb = readb(>ch_cls_uart->lcr);
@@ -357,164 +307,444 @@ static inline void cls_clear_break(struct channel_t 
*ch, int force)
spin_unlock_irqrestore(>ch_lock, flags);
 }
 
-/* Parse the ISR register for the specific port */
-static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
+static void cls_copy_data_from_uart_to_queue(struct channel_t *ch)
 {
-   struct channel_t *ch;
-   unsigned char isr = 0;
+   int qleft = 0;
+   unsigned char linestatus = 0;
+   unsigned char error_mask = 0;
+   ushort head;
+   ushort tail;
unsigned long flags;
 
-   /*
-* No need to verify board pointer, it was already
-* verified in the interrupt routine.
-*/
-
-   if (port >= brd->nasync)
+   if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return;
 
-   ch = brd->channels[port];
-   if (ch->magic != DGNC_CHANNEL_MAGIC)
-   return;
+   spin_lock_irqsave(>ch_lock, flags);
+
+   /* cache head and tail of queue */
+   head = ch->ch_r_head;
+   tail = ch->ch_r_tail;
+
+   /* Store how much space we have left in the queue */
+   qleft = tail - head - 1;
+   if (qleft < 0)
+   qleft += RQUEUEMASK + 1;
+
+   /*
+* Create a mask to determine whether we should
+* insert the character (if any) into our queue.
+*/
+   if (ch-&

[PATCH 3/3] staging: dgnc: removes redundant null check and change

2016-05-12 Thread Daeseok Youn
The dgnc_set_modem_info() used only channel_t variable.
Any other variables were used only for checking NULL.

So fist parameter changed from "tty_struct" to "channel_t" and
useless NULL checks and variables are removed.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 24 +++-
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 5119bcb..51c37ee 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -100,7 +100,7 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty);
 static void dgnc_tty_flush_chars(struct tty_struct *tty);
 static void dgnc_tty_flush_buffer(struct tty_struct *tty);
 static void dgnc_tty_hangup(struct tty_struct *tty);
-static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command,
+static int dgnc_set_modem_info(struct channel_t *ch, unsigned int command,
   unsigned int __user *value);
 static int dgnc_get_modem_info(struct channel_t *ch,
   unsigned int __user *value);
@@ -2015,32 +2015,14 @@ static int dgnc_get_modem_info(struct channel_t *ch,
  *
  * Set modem signals, called by ld.
  */
-static int dgnc_set_modem_info(struct tty_struct *tty,
+static int dgnc_set_modem_info(struct channel_t *ch,
   unsigned int command,
   unsigned int __user *value)
 {
-   struct dgnc_board *bd;
-   struct channel_t *ch;
-   struct un_t *un;
int ret = -ENXIO;
unsigned int arg = 0;
unsigned long flags;
 
-   if (!tty || tty->magic != TTY_MAGIC)
-   return ret;
-
-   un = tty->driver_data;
-   if (!un || un->magic != DGNC_UNIT_MAGIC)
-   return ret;
-
-   ch = un->un_ch;
-   if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
-   return ret;
-
-   bd = ch->ch_bd;
-   if (!bd || bd->magic != DGNC_BOARD_MAGIC)
-   return ret;
-
ret = get_user(arg, value);
if (ret)
return ret;
@@ -2607,7 +2589,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
case TIOCMBIC:
case TIOCMSET:
spin_unlock_irqrestore(>ch_lock, flags);
-   return dgnc_set_modem_info(tty, cmd, uarg);
+   return dgnc_set_modem_info(ch, cmd, uarg);
 
/*
 * Here are any additional ioctl's that we want to implement
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging: dgnc: remove redundant variable null check

2016-05-12 Thread Daeseok Youn
The unit struct(un_t) was not used in dgnc_tty_hangup().

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 52a1613..5119bcb 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1294,15 +1294,9 @@ static int dgnc_block_til_ready(struct tty_struct *tty,
  */
 static void dgnc_tty_hangup(struct tty_struct *tty)
 {
-   struct un_t *un;
-
if (!tty || tty->magic != TTY_MAGIC)
return;
 
-   un = tty->driver_data;
-   if (!un || un->magic != DGNC_UNIT_MAGIC)
-   return;
-
/* flush the transmit queues */
dgnc_tty_flush_buffer(tty);
 }
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging: dgnc: remove redundant local variable for

2016-05-12 Thread Daeseok Youn
The local variable "bd" was not used in dgnc_carrier() function.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index a505775..52a1613 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -640,19 +640,12 @@ exit_unlock:
  /
 void dgnc_carrier(struct channel_t *ch)
 {
-   struct dgnc_board *bd;
-
int virt_carrier = 0;
int phys_carrier = 0;
 
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return;
 
-   bd = ch->ch_bd;
-
-   if (!bd || bd->magic != DGNC_BOARD_MAGIC)
-   return;
-
if (ch->ch_mistat & UART_MSR_DCD)
phys_carrier = 1;
 
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2 RESEND] staging: dgnc: remove useless error value assignment

2016-05-10 Thread Daeseok Youn
The "result" variable in dgnc_get_mstat() was initialized with
"-EIO". But if the "ch" is not null, "result" will be set to zero
and if the "ch" is null, dgnc_get_mstat() will return "-ENXIO" as
an error. So "-EIO" error value was useless in dgnc_get_mstat().

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
RESEND: update subject and change log
origin patch : https://lkml.org/lkml/2016/5/4/13

 drivers/staging/dgnc/dgnc_tty.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index cff34d4..30db091 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1979,7 +1979,7 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, 
char c)
 static inline int dgnc_get_mstat(struct channel_t *ch)
 {
unsigned char mstat;
-   int result = -EIO;
+   int result = 0;
unsigned long flags;
 
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
@@ -1991,8 +1991,6 @@ static inline int dgnc_get_mstat(struct channel_t *ch)
 
spin_unlock_irqrestore(>ch_lock, flags);
 
-   result = 0;
-
if (mstat & UART_MCR_DTR)
result |= TIOCM_DTR;
if (mstat & UART_MCR_RTS)
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2 RESEND] staging: dgnc: remove redundant NULL checks in

2016-05-10 Thread Daeseok Youn
The dgnc_block_til_ready() is only used in dgnc_tty_open().
The unit data(struct un_t) was stored into tty->driver_data in dgnc_tty_open().
And also tty and un were tested about NULL so these variables doesn't
need to check for NULL in dgnc_block_til_ready().

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
RESEND: more explanation about this patch.
origin patch : https://lkml.org/lkml/2016/5/4/12

 drivers/staging/dgnc/dgnc_tty.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index a505775..cff34d4 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1172,17 +1172,12 @@ static int dgnc_block_til_ready(struct tty_struct *tty,
struct channel_t *ch)
 {
int retval = 0;
-   struct un_t *un = NULL;
+   struct un_t *un = tty->driver_data;
unsigned long flags;
uintold_flags = 0;
int sleep_on_un_flags = 0;
 
-   if (!tty || tty->magic != TTY_MAGIC || !file || !ch ||
-   ch->magic != DGNC_CHANNEL_MAGIC)
-   return -ENXIO;
-
-   un = tty->driver_data;
-   if (!un || un->magic != DGNC_UNIT_MAGIC)
+   if (!file)
return -ENXIO;
 
spin_lock_irqsave(>ch_lock, flags);
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3] staging: dgnc: remove redundant NULL check in

2016-05-09 Thread DaeSeok Youn
2016-05-09 21:08 GMT+09:00 Greg KH <gre...@linuxfoundation.org>:
> On Wed, May 04, 2016 at 02:13:04PM +0900, Daeseok Youn wrote:
>> tty and ch are already checked for NULL
>> before calling dgnc_block_til_ready().
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>
> Your subject line doesn't make sense, please fix it up and resend.
OK. I will resend this.

thanks

regards,
Daeseok.

>
> thanks,
>
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] staging: dgnc: remove useless assigned error value in

2016-05-09 Thread DaeSeok Youn
2016-05-09 21:09 GMT+09:00 Greg KH <gre...@linuxfoundation.org>:
> On Wed, May 04, 2016 at 02:13:26PM +0900, Daeseok Youn wrote:
>> the result in dgnc_get_mstat() was initialized with -EIO but
>> there are no use of EIO as a result in this function.
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>> ---
>>  drivers/staging/dgnc/dgnc_tty.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> Same Subject: problem here too, it doesn't make sense.
OK. I will resend this.

thanks

regards,
Daeseok.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging: dgnc: Need to check for NULL of ch

2016-05-08 Thread Daeseok Youn
the "ch" from brd structure could be NULL, it need to
check for NULL.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_neo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 9eae1a6..ba57e95 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -380,7 +380,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, 
uint port)
unsigned long flags;
 
ch = brd->channels[port];
-   if (ch->magic != DGNC_CHANNEL_MAGIC)
+   if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return;
 
/* Here we try to figure out what caused the interrupt to happen */
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging: dgnc: remove redundant condition check

2016-05-08 Thread Daeseok Youn
dgnc_board(brd) was already checked for NULL before calling
neo_parse_isr(). And also port doesn't need to check.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_neo.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 3b8ce38..9eae1a6 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -379,12 +379,6 @@ static inline void neo_parse_isr(struct dgnc_board *brd, 
uint port)
unsigned char cause;
unsigned long flags;
 
-   if (!brd || brd->magic != DGNC_BOARD_MAGIC)
-   return;
-
-   if (port >= brd->maxports)
-   return;
-
ch = brd->channels[port];
if (ch->magic != DGNC_CHANNEL_MAGIC)
return;
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging: dgnc: fix 'line over 80 characters'

2016-05-08 Thread Daeseok Youn
fix checkpatch.pl warning about 'line over 80 characters'.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_sysfs.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_sysfs.c 
b/drivers/staging/dgnc/dgnc_sysfs.c
index d825964..b8d41c5 100644
--- a/drivers/staging/dgnc/dgnc_sysfs.c
+++ b/drivers/staging/dgnc/dgnc_sysfs.c
@@ -189,19 +189,21 @@ static ssize_t dgnc_ports_msignals_show(struct device *p,
DGNC_VERIFY_BOARD(p, bd);
 
for (i = 0; i < bd->nasync; i++) {
-   if (bd->channels[i]->ch_open_count) {
+   struct channel_t *ch = bd->channels[i];
+
+   if (ch->ch_open_count) {
count += snprintf(buf + count, PAGE_SIZE - count,
"%d %s %s %s %s %s %s\n",
-   bd->channels[i]->ch_portnum,
-   (bd->channels[i]->ch_mostat & UART_MCR_RTS) ? 
"RTS" : "",
-   (bd->channels[i]->ch_mistat & UART_MSR_CTS) ? 
"CTS" : "",
-   (bd->channels[i]->ch_mostat & UART_MCR_DTR) ? 
"DTR" : "",
-   (bd->channels[i]->ch_mistat & UART_MSR_DSR) ? 
"DSR" : "",
-   (bd->channels[i]->ch_mistat & UART_MSR_DCD) ? 
"DCD" : "",
-   (bd->channels[i]->ch_mistat & UART_MSR_RI)  ? 
"RI"  : "");
+   ch->ch_portnum,
+   (ch->ch_mostat & UART_MCR_RTS) ? "RTS" : "",
+   (ch->ch_mistat & UART_MSR_CTS) ? "CTS" : "",
+   (ch->ch_mostat & UART_MCR_DTR) ? "DTR" : "",
+   (ch->ch_mistat & UART_MSR_DSR) ? "DSR" : "",
+   (ch->ch_mistat & UART_MSR_DCD) ? "DCD" : "",
+   (ch->ch_mistat & UART_MSR_RI)  ? "RI"  : "");
} else {
count += snprintf(buf + count, PAGE_SIZE - count,
-   "%d\n", bd->channels[i]->ch_portnum);
+   "%d\n", ch->ch_portnum);
}
}
return count;
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgnc: Fix a NULL pointer dereference

2016-05-03 Thread Daeseok Youn
The error handling for print_drive after calling tty_alloc_driver()
was needed. But there was error handling but too late for this.
Error handling code moved after tty_alloc_driver() call.

Fixes: 60b3109e5e2d ("staging: dgnc: use tty_alloc_driver instead of kcalloc")
Reported-by: Dan Carpenter <dan.carpen...@oracle.com>
Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 2cecdb0..392d532 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -224,6 +224,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
 TTY_DRIVER_DYNAMIC_DEV |
 TTY_DRIVER_HARDWARE_BREAK);
 
+   if (IS_ERR(brd->print_driver)) {
+   rc = PTR_ERR(brd->print_driver);
+   goto unregister_serial_driver;
+   }
+
snprintf(brd->print_name, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
 
brd->print_driver->name = brd->print_name;
@@ -235,11 +240,6 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->print_driver->init_termios = DgncDefaultTermios;
brd->print_driver->driver_name = DRVSTR;
 
-   if (IS_ERR(brd->print_driver)) {
-   rc = PTR_ERR(brd->print_driver);
-   goto unregister_serial_driver;
-   }
-
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: dgnc: use tty_alloc_driver instead of kcalloc

2016-05-03 Thread DaeSeok Youn
2016-05-03 17:15 GMT+09:00 Dan Carpenter <dan.carpen...@oracle.com>:
> Hello Daeseok Youn,
Hello Dan,
>
> The patch 60b3109e5e2d: "staging: dgnc: use tty_alloc_driver instead
> of kcalloc" from Apr 14, 2016, leads to the following static checker
> warning:
>
> drivers/staging/dgnc/dgnc_tty.c:229 dgnc_tty_register()
> error: 'brd->print_driver' dereferencing possible ERR_PTR()
>
> drivers/staging/dgnc/dgnc_tty.c
>217  /*
>218   * If we're doing transparent print, we have to do all of the 
> above
>219   * again, separately so we don't get the LD confused about 
> what major
>220   * we are when we get into the dgnc_tty_open() routine.
>221   */
>222  brd->print_driver = tty_alloc_driver(brd->maxports,
>223   TTY_DRIVER_REAL_RAW |
>224   TTY_DRIVER_DYNAMIC_DEV |
>225   
> TTY_DRIVER_HARDWARE_BREAK);
>
> This function call needs error handling.
Yes, right. I had a mistake for handling error for print_driver.
Error handling code will be moved after calling tty_alloc_driver().

>
>226
>227  snprintf(brd->print_name, MAXTTYNAMELEN, "pr_dgnc_%d_", 
> brd->boardnum);
>228
>229  brd->print_driver->name = brd->print_name;
>230  brd->print_driver->name_base = 0;
>231  brd->print_driver->major = brd->serial_driver->major;
>232  brd->print_driver->minor_start = 0x80;
>
> regards,
> dan carpenter
Thanks.

regards,
Daeseok Youn.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging: dgnc: remove redundant NULL check in

2016-05-03 Thread Daeseok Youn
tty and ch are already checked for NULL
before calling dgnc_block_til_ready().

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 2cecdb0..d85d005 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1172,17 +1172,12 @@ static int dgnc_block_til_ready(struct tty_struct *tty,
struct channel_t *ch)
 {
int retval = 0;
-   struct un_t *un = NULL;
+   struct un_t *un = tty->driver_data;
unsigned long flags;
uintold_flags = 0;
int sleep_on_un_flags = 0;
 
-   if (!tty || tty->magic != TTY_MAGIC || !file || !ch ||
-   ch->magic != DGNC_CHANNEL_MAGIC)
-   return -ENXIO;
-
-   un = tty->driver_data;
-   if (!un || un->magic != DGNC_UNIT_MAGIC)
+   if (!file)
return -ENXIO;
 
spin_lock_irqsave(>ch_lock, flags);
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging: dgnc: clean up the dgnc_get_modem_info()

2016-05-03 Thread Daeseok Youn
the "ch" in dgnc_get_modem_info() was already checked before calling
this function and also if "ch" is not NULL, dgnc_get_mstat() returns
valid value so it doesn't need to check an error.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 46ca01d..f67d7d4 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -2013,17 +2013,7 @@ static inline int dgnc_get_mstat(struct channel_t *ch)
 static int dgnc_get_modem_info(struct channel_t *ch,
   unsigned int  __user *value)
 {
-   int result;
-
-   if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
-   return -ENXIO;
-
-   result = dgnc_get_mstat(ch);
-
-   if (result < 0)
-   return -ENXIO;
-
-   return put_user(result, value);
+   return put_user(dgnc_get_mstat(ch), value);
 }
 
 /*
-- 
2.8.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgnc: use tty_alloc_driver instead of kcalloc

2016-04-13 Thread Daeseok Youn
The tty_alloc_driver() can allocate memory for ttys and termios.
And also allocated memory will be released easily with
put_tty_driver() call.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.h |   4 +-
 drivers/staging/dgnc/dgnc_tty.c| 144 -
 2 files changed, 62 insertions(+), 86 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 6609ba5..95ec729 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -202,9 +202,9 @@ struct dgnc_board {
 * to our channels.
 */
 
-   struct tty_driver serial_driver;
+   struct tty_driver *serial_driver;
charserial_name[200];
-   struct tty_driver print_driver;
+   struct tty_driver *print_driver;
charprint_name[200];
 
booldgnc_major_serial_registered;
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 074988d..ccba7fc 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -176,55 +176,40 @@ int dgnc_tty_preinit(void)
  */
 int dgnc_tty_register(struct dgnc_board *brd)
 {
-   int rc = 0;
-
-   brd->serial_driver.magic = TTY_DRIVER_MAGIC;
+   int rc;
 
-   snprintf(brd->serial_name, MAXTTYNAMELEN, "tty_dgnc_%d_", 
brd->boardnum);
+   brd->serial_driver = tty_alloc_driver(brd->maxports,
+ TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_DYNAMIC_DEV |
+ TTY_DRIVER_HARDWARE_BREAK);
 
-   brd->serial_driver.name = brd->serial_name;
-   brd->serial_driver.name_base = 0;
-   brd->serial_driver.major = 0;
-   brd->serial_driver.minor_start = 0;
-   brd->serial_driver.num = brd->maxports;
-   brd->serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
-   brd->serial_driver.subtype = SERIAL_TYPE_NORMAL;
-   brd->serial_driver.init_termios = DgncDefaultTermios;
-   brd->serial_driver.driver_name = DRVSTR;
-   brd->serial_driver.flags = (TTY_DRIVER_REAL_RAW |
-  TTY_DRIVER_DYNAMIC_DEV |
-  TTY_DRIVER_HARDWARE_BREAK);
+   if (IS_ERR(brd->serial_driver))
+   return PTR_ERR(brd->serial_driver);
 
-   /*
-* The kernel wants space to store pointers to
-* tty_struct's and termios's.
-*/
-   brd->serial_driver.ttys = kcalloc(brd->maxports,
-sizeof(*brd->serial_driver.ttys),
-GFP_KERNEL);
-   if (!brd->serial_driver.ttys)
-   return -ENOMEM;
+   snprintf(brd->serial_name, MAXTTYNAMELEN, "tty_dgnc_%d_", 
brd->boardnum);
 
-   kref_init(>serial_driver.kref);
-   brd->serial_driver.termios = kcalloc(brd->maxports,
-   sizeof(*brd->serial_driver.termios),
-   GFP_KERNEL);
-   if (!brd->serial_driver.termios)
-   return -ENOMEM;
+   brd->serial_driver->name = brd->serial_name;
+   brd->serial_driver->name_base = 0;
+   brd->serial_driver->major = 0;
+   brd->serial_driver->minor_start = 0;
+   brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
+   brd->serial_driver->subtype = SERIAL_TYPE_NORMAL;
+   brd->serial_driver->init_termios = DgncDefaultTermios;
+   brd->serial_driver->driver_name = DRVSTR;
 
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
 */
-   tty_set_operations(>serial_driver, _tty_ops);
+   tty_set_operations(brd->serial_driver, _tty_ops);
 
if (!brd->dgnc_major_serial_registered) {
/* Register tty devices */
-   rc = tty_register_driver(>serial_driver);
+   rc = tty_register_driver(brd->serial_driver);
if (rc < 0) {
dev_dbg(>pdev->dev,
"Can't register tty device (%d)\n", rc);
-   return rc;
+   goto free_serial_driver;
}
brd->dgnc_major_serial_registered = true;
}
@@ -234,58 +219,55 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgnc_tty_open() routine.
 */
-   brd->print_driver.magic = TTY_DRIVER_MAGI

[PATCH 2/2] staging: dgnc: remove redundant NULL check in

2016-04-05 Thread Daeseok Youn
There were already checking NULL about channel_t / un_t
before calling dgnc_maxcps_room().

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index e97faaa..200d3aa 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1536,19 +1536,8 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct 
*tty)
  */
 static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available)
 {
-   struct channel_t *ch = NULL;
-   struct un_t *un = NULL;
-
-   if (!tty)
-   return bytes_available;
-
-   un = tty->driver_data;
-   if (!un || un->magic != DGNC_UNIT_MAGIC)
-   return bytes_available;
-
-   ch = un->un_ch;
-   if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
-   return bytes_available;
+   struct un_t *un = tty->driver_data;
+   struct channel_t *ch = un->un_ch;
 
/*
 * If its not the Transparent print device, return
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: dgnc: return -ENOMEM when kzalloc failed

2016-04-05 Thread Daeseok Youn
The kzalloc can be failed when memory is not enough
to allocate. When kzalloc failed, it need to return
error code with ENOMEM

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 074988d..e97faaa 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1106,6 +1106,14 @@ static int dgnc_tty_open(struct tty_struct *tty, struct 
file *file)
if (!ch->ch_wqueue)
ch->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL);
 
+   if (!ch->ch_rqueue || !ch->ch_equeue || !ch->ch_wqueue) {
+   kfree(ch->ch_rqueue);
+   kfree(ch->ch_equeue);
+   kfree(ch->ch_wqueue);
+
+   return -ENOMEM;
+   }
+
spin_lock_irqsave(>ch_lock, flags);
 
ch->ch_flags &= ~(CH_OPENING);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: dgnc: remove blank line

2016-04-04 Thread Daeseok Youn
fix checkpatch.pl warning:
Blank lines aren't necessary after an open brace '{'

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_neo.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 2da6a72..3b8ce38 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -1794,7 +1794,6 @@ static void neo_vpd(struct dgnc_board *brd)
if  (((brd->vpd[0x08] != 0x82) &&
  (brd->vpd[0x10] != 0x82)) ||
 (brd->vpd[0x7F] != 0x78)) {
-
memset(brd->vpd, '\0', NEO_VPD_IMAGESIZE);
} else {
/* Search for the serial number */
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: dgnc: remove parenthesis around the CONST |

2016-04-04 Thread Daeseok Youn
remove parenthesis around the CONST | CONST.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_cls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 5e46ac8..46c050c 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -1168,7 +1168,7 @@ static void cls_uart_init(struct channel_t *ch)
/* Clear out UART and FIFO */
readb(>ch_cls_uart->txrx);
 
-   writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | 
UART_FCR_CLEAR_XMIT),
+   writeb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
   >ch_cls_uart->isr_fcr);
udelay(10);
 
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: dgnc: fix CamelCase in dgnc_tty.c

2016-04-01 Thread Daeseok Youn
fix checkpatch.pl warning about 'Avoid CamelCase'

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 2 +-
 drivers/staging/dgnc/digi.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 5d8da41..074988d 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -2931,7 +2931,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
 * Figure out how much data the RealPort Server believes should
 * be in our TX queue.
 */
-   tdist = (buf.tIn - buf.tOut) & 0x;
+   tdist = (buf.tx_in - buf.tx_out) & 0x;
 
/*
 * If we have more data than the RealPort Server believes we
diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h
index 523a2d3..5b983e6 100644
--- a/drivers/staging/dgnc/digi.h
+++ b/drivers/staging/dgnc/digi.h
@@ -109,8 +109,8 @@ struct digi_info {
 
 struct digi_getbuffer /* Struct for holding buffer use counts */
 {
-   unsigned long tIn;
-   unsigned long tOut;
+   unsigned long tx_in;
+   unsigned long tx_out;
unsigned long rxbuf;
unsigned long txbuf;
unsigned long txdone;
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: dgnc: remove too many traverse pointer

2016-04-01 Thread Daeseok Youn
The "ch->ch_bd" is already assined to "bd" but this is only
for checking null or MAGIC number.
in the dgnc_tty_ioctl function, bd can be used for referencing
to board_ops structure.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 37 -
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index d617fca..5d8da41 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -2518,6 +2518,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
  unsigned long arg)
 {
struct dgnc_board *bd;
+   struct board_ops *ch_bd_ops;
struct channel_t *ch;
struct un_t *un;
int rc;
@@ -2539,6 +2540,8 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return -ENODEV;
 
+   ch_bd_ops = bd->bd_ops;
+
spin_lock_irqsave(>ch_lock, flags);
 
if (un->un_open_count <= 0) {
@@ -2563,7 +2566,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
if (rc)
return rc;
 
-   rc = ch->ch_bd->bd_ops->drain(tty, 0);
+   rc = ch_bd_ops->drain(tty, 0);
 
if (rc)
return -EINTR;
@@ -2571,7 +2574,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
spin_lock_irqsave(>ch_lock, flags);
 
if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP))
-   ch->ch_bd->bd_ops->send_break(ch, 250);
+   ch_bd_ops->send_break(ch, 250);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
@@ -2588,13 +2591,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
if (rc)
return rc;
 
-   rc = ch->ch_bd->bd_ops->drain(tty, 0);
+   rc = ch_bd_ops->drain(tty, 0);
if (rc)
return -EINTR;
 
spin_lock_irqsave(>ch_lock, flags);
 
-   ch->ch_bd->bd_ops->send_break(ch, 250);
+   ch_bd_ops->send_break(ch, 250);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
@@ -2606,13 +2609,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
if (rc)
return rc;
 
-   rc = ch->ch_bd->bd_ops->drain(tty, 0);
+   rc = ch_bd_ops->drain(tty, 0);
if (rc)
return -EINTR;
 
spin_lock_irqsave(>ch_lock, flags);
 
-   ch->ch_bd->bd_ops->send_break(ch, 250);
+   ch_bd_ops->send_break(ch, 250);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
@@ -2641,7 +2644,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
spin_lock_irqsave(>ch_lock, flags);
tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) |
   (arg ? CLOCAL : 0));
-   ch->ch_bd->bd_ops->param(tty);
+   ch_bd_ops->param(tty);
spin_unlock_irqrestore(>ch_lock, flags);
 
return 0;
@@ -2678,7 +2681,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
 
if ((arg == TCIFLUSH) || (arg == TCIOFLUSH)) {
ch->ch_r_head = ch->ch_r_tail;
-   ch->ch_bd->bd_ops->flush_uart_read(ch);
+   ch_bd_ops->flush_uart_read(ch);
/* Force queue flow control to be released, if needed */
dgnc_check_queue_flow_control(ch);
}
@@ -2686,7 +2689,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
if ((arg == TCOFLUSH) || (arg == TCIOFLUSH)) {
if (!(un->un_type == DGNC_PRINT)) {
ch->ch_w_head = ch->ch_w_tail;
-   ch->ch_bd->bd_ops->flush_uart_write(ch);
+   ch_bd_ops->flush_uart_write(ch);
 
if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) {
ch->ch_tun.un_flags &=
@@ -2720,14 +2723,14 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
/* flush rx */
ch->ch_flags &= ~CH_STOP;
ch->ch_r_head = ch->ch_r_tail;
-   ch->ch_bd->bd_ops->flush_uart_read(ch);
+   ch

[PATCH 2/2] staging: dgnc: clean up dgnc_input function

2016-03-31 Thread Daeseok Youn
This is for fixing checkpatch.pl warning about
"Alignment should match open parenthesis" but if that is
fixed, code line is over 80 characters.
I think "ch->ch_rqueue + tail + i" could be declared once in
the begining of loop.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 35 ++-
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 5097208..d617fca 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -602,6 +602,8 @@ void dgnc_input(struct channel_t *ch)
 * or the amount of data the card actually has pending...
 */
while (n) {
+   unsigned char *ch_pos = ch->ch_equeue + tail;
+
s = ((head >= tail) ? head : RQUEUESIZE) - tail;
s = min(s, n);
 
@@ -616,29 +618,20 @@ void dgnc_input(struct channel_t *ch)
 */
if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) {
for (i = 0; i < s; i++) {
-   if (*(ch->ch_equeue + tail + i) & UART_LSR_BI)
-   tty_insert_flip_char(tp->port,
-   *(ch->ch_rqueue + tail + i),
-   TTY_BREAK);
-   else if (*(ch->ch_equeue + tail + i) &
-   UART_LSR_PE)
-   tty_insert_flip_char(tp->port,
-   *(ch->ch_rqueue + tail + i),
-   TTY_PARITY);
-   else if (*(ch->ch_equeue + tail + i) &
-   UART_LSR_FE)
-   tty_insert_flip_char(tp->port,
-   *(ch->ch_rqueue + tail + i),
-   TTY_FRAME);
-   else
-   tty_insert_flip_char(tp->port,
-   *(ch->ch_rqueue + tail + i),
-   TTY_NORMAL);
+   unsigned char ch = *(ch_pos + i);
+   char flag = TTY_NORMAL;
+
+   if (ch & UART_LSR_BI)
+   flag = TTY_BREAK;
+   else if (ch & UART_LSR_PE)
+   flag = TTY_PARITY;
+   else if (ch & UART_LSR_FE)
+   flag = TTY_FRAME;
+
+   tty_insert_flip_char(tp->port, ch, flag);
}
} else {
-   tty_insert_flip_string(tp->port,
-  ch->ch_rqueue + tail,
-  s);
+   tty_insert_flip_string(tp->port, ch_pos, s);
}
 
tail += s;
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: dgnc: remove useless variables for saving tty's

2016-03-31 Thread Daeseok Youn
It doesn't need to save major number with variable.
And there are no use of these variables(dgnc_serial_major and
dgnc_transparent_print_major)

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.h | 3 ---
 drivers/staging/dgnc/dgnc_tty.c| 4 
 2 files changed, 7 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 44216ae..6609ba5 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -210,9 +210,6 @@ struct dgnc_board {
booldgnc_major_serial_registered;
booldgnc_major_transparent_print_registered;
 
-   uintdgnc_serial_major;
-   uintdgnc_transparent_print_major;
-
u16 dpatype;/* The board "type",
 * as defined by DPA
 */
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 98b88d1..5097208 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -286,8 +286,6 @@ int dgnc_tty_register(struct dgnc_board *brd)
}
 
dgnc_BoardsByMajor[brd->serial_driver.major] = brd;
-   brd->dgnc_serial_major = brd->serial_driver.major;
-   brd->dgnc_transparent_print_major = brd->print_driver.major;
 
return rc;
 }
@@ -409,7 +407,6 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
 
if (brd->dgnc_major_serial_registered) {
dgnc_BoardsByMajor[brd->serial_driver.major] = NULL;
-   brd->dgnc_serial_major = 0;
for (i = 0; i < brd->nasync; i++) {
if (brd->channels[i])
dgnc_remove_tty_sysfs(brd->channels[i]->
@@ -422,7 +419,6 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
 
if (brd->dgnc_major_transparent_print_registered) {
dgnc_BoardsByMajor[brd->print_driver.major] = NULL;
-   brd->dgnc_transparent_print_major = 0;
for (i = 0; i < brd->nasync; i++) {
if (brd->channels[i])
dgnc_remove_tty_sysfs(brd->channels[i]->
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging: dgnc: fix Logical continuations.

2016-03-28 Thread Daeseok Youn
fix checkpatch.pl warning about
'Logical continuations should be on the previous line'

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_neo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 9412d25..3e490de 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -1811,9 +1811,9 @@ static void neo_vpd(struct dgnc_board *brd)
 * 0x10 : long resource name tage (PCI-66 files)
 * 0x7F : small resource end tag
 */
-   if  (((brd->vpd[0x08] != 0x82)
-   &&  (brd->vpd[0x10] != 0x82))
-   ||  (brd->vpd[0x7F] != 0x78)) {
+   if  (((brd->vpd[0x08] != 0x82) &&
+ (brd->vpd[0x10] != 0x82)) ||
+(brd->vpd[0x7F] != 0x78)) {
 
memset(brd->vpd, '\0', NEO_VPD_IMAGESIZE);
} else {
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging: dgnc: remove parenthesis around the CONST |

2016-03-28 Thread Daeseok Youn
remove parenthesis around the CONST | CONST.
It will be also fixed checkpatch.pl warning about
"Alignment should match open parenthesis" becasue
parenthesis were removed by this patch.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_neo.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index d732e6e..c3bb1b4 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -117,8 +117,8 @@ static inline void neo_set_cts_flow_control(struct 
channel_t *ch)
writeb(efr, >ch_neo_uart->efr);
 
/* Turn on table D, with 8 char hi/low watermarks */
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY),
-   >ch_neo_uart->fctr);
+   writeb(UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY,
+  >ch_neo_uart->fctr);
 
/* Feed the UART our trigger levels */
writeb(8, >ch_neo_uart->tfifo);
@@ -152,8 +152,8 @@ static inline void neo_set_rts_flow_control(struct 
channel_t *ch)
/* Turn on UART enhanced bits */
writeb(efr, >ch_neo_uart->efr);
 
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY),
-   >ch_neo_uart->fctr);
+   writeb(UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY,
+  >ch_neo_uart->fctr);
ch->ch_r_watermark = 4;
 
writeb(32, >ch_neo_uart->rfifo);
@@ -190,7 +190,7 @@ static inline void neo_set_ixon_flow_control(struct 
channel_t *ch)
/* Turn on UART enhanced bits */
writeb(efr, >ch_neo_uart->efr);
 
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY),
+   writeb(UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY,
   >ch_neo_uart->fctr);
ch->ch_r_watermark = 4;
 
@@ -229,8 +229,8 @@ static inline void neo_set_ixoff_flow_control(struct 
channel_t *ch)
writeb(efr, >ch_neo_uart->efr);
 
/* Turn on table D, with 8 char hi/low watermarks */
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY),
-   >ch_neo_uart->fctr);
+   writeb(UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY,
+  >ch_neo_uart->fctr);
 
writeb(8, >ch_neo_uart->tfifo);
ch->ch_t_tlevel = 8;
@@ -270,8 +270,8 @@ static inline void neo_set_no_input_flow_control(struct 
channel_t *ch)
writeb(efr, >ch_neo_uart->efr);
 
/* Turn on table D, with 8 char hi/low watermarks */
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY),
-   >ch_neo_uart->fctr);
+   writeb(UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY,
+  >ch_neo_uart->fctr);
 
ch->ch_r_watermark = 0;
 
@@ -308,8 +308,8 @@ static inline void neo_set_no_output_flow_control(struct 
channel_t *ch)
writeb(efr, >ch_neo_uart->efr);
 
/* Turn on table D, with 8 char hi/low watermarks */
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY),
-   >ch_neo_uart->fctr);
+   writeb(UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY,
+  >ch_neo_uart->fctr);
 
ch->ch_r_watermark = 0;
 
@@ -1373,7 +1373,7 @@ static void neo_flush_uart_read(struct channel_t *ch)
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return;
 
-   writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR),
+   writeb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR,
   >ch_neo_uart->isr_fcr);
neo_pci_posting_flush(ch->ch_bd);
 
@@ -1648,7 +1648,7 @@ static void neo_uart_init(struct channel_t *ch)
 
/* Clear out UART and FIFO */
readb(>ch_neo_uart->txrx);
-   writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | 
UART_FCR_CLEAR_XMIT),
+   writeb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
   >ch_neo_uart->isr_fcr);
readb(>ch_neo_uart->lsr);
readb(>ch_neo_uart->msr);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgnc: replace dgnc_offset_table with bit shift.

2016-03-27 Thread DaeSeok Youn
2016-03-25 22:15 GMT+09:00 walter harms <wha...@bfs.de>:
>
>
> Am 25.03.2016 12:33, schrieb Daeseok Youn:
>> the dgnc_offset_table has a same value with (1 << port).
>> So I tried to replace dgnc_offset_table array with 1 << port.
>> And also there are redundant assignments(tmp and current_port)
>> inside while loop for checking uart port, and remove them.
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>> ---
>> Greg, This patch depends on previous patches.
>> here are links(previous):
>> 1. https://lkml.org/lkml/2016/3/24/661
>> 2. https://lkml.org/lkml/2016/3/24/663
>>
>> if those patches are failed to merge, I will send them again after
>> fixing them.
>>
>> thanks.
>>
>>  drivers/staging/dgnc/dgnc_neo.c | 44 
>> +++--
>>  1 file changed, 20 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/staging/dgnc/dgnc_neo.c 
>> b/drivers/staging/dgnc/dgnc_neo.c
>> index d732e6e..8b6bc73 100644
>> --- a/drivers/staging/dgnc/dgnc_neo.c
>> +++ b/drivers/staging/dgnc/dgnc_neo.c
>> @@ -77,9 +77,6 @@ struct board_ops dgnc_neo_ops = {
>>   .send_immediate_char =  neo_send_immediate_char
>>  };
>>
>> -static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08,
>> -  0x10, 0x20, 0x40, 0x80 };
>> -
>>  /*
>>   * This function allows calls to ensure that all outstanding
>>   * PCI writes have been completed, by doing a PCI read against
>> @@ -923,9 +920,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
>>   struct dgnc_board *brd = voidbrd;
>>   struct channel_t *ch;
>>   int port = 0;
>> - int type = 0;
>> - int current_port;
>> - u32 tmp;
>> + int type;
>>   u32 uart_poll;
>>   unsigned long flags;
>>   unsigned long flags2;
>> @@ -960,28 +955,29 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
>>
>>   /* At this point, we have at least SOMETHING to service, dig 
>> further... */
>>
>> - current_port = 0;
>> -
>>   /* Loop on each port */
>>   while ((uart_poll & 0xff) != 0) {
>> - tmp = uart_poll;
>> -
>> - /* Check current port to see if it has interrupt pending */
>> - if ((tmp & dgnc_offset_table[current_port]) != 0) {
>> - port = current_port;
>> - type = tmp >> (8 + (port * 3));
>> - type &= 0x7;
>> - } else {
>> - current_port++;
>> - continue;
>> - }
>> + int i;
>>
>> - /* Remove this port + type from uart_poll */
>> - uart_poll &= ~(dgnc_offset_table[port]);
>> + type = 0;
>>
>> - if (!type) {
>> - /* If no type, just ignore it, and move onto next port 
>> */
>> - continue;
>> + for (i = port; i < MAXPORTS; i++) {
>> + unsigned int offset_table = 0x1 << i;
>> +
>> + /* Check current port to see
>> +  * if it has interrupt pending
>> +  */
>> + if ((uart_poll & offset_table) != 0) {
>> + port = i;
>> + type = uart_poll >> (8 + (port * 3));
>> + type &= 0x7;
>> +
>> + /* Remove this port + type from uart_poll */
>> + uart_poll &= ~(offset_table);
>
> why not: art_poll &= ~ (0x1 << i);
> then you can easy eliminate offset_table
>
> btw: why do you need i ?
>
> re,
>  wh

Hi, walter.

I'm sorry for reply lately. :-)
Ok. I will try clean up useless variables and send this again.

Thanks.

regards,
Daeseok.
>
>> + }
>> +
>> + if (type)
>> + break;
>>   }
>>
>>   /* Switch on type of interrupt we have */
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgnc: replace dgnc_offset_table with bit shift.

2016-03-25 Thread Daeseok Youn
the dgnc_offset_table has a same value with (1 << port).
So I tried to replace dgnc_offset_table array with 1 << port.
And also there are redundant assignments(tmp and current_port)
inside while loop for checking uart port, and remove them.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
Greg, This patch depends on previous patches.
here are links(previous):
1. https://lkml.org/lkml/2016/3/24/661
2. https://lkml.org/lkml/2016/3/24/663

if those patches are failed to merge, I will send them again after
fixing them.

thanks.

 drivers/staging/dgnc/dgnc_neo.c | 44 +++--
 1 file changed, 20 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index d732e6e..8b6bc73 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -77,9 +77,6 @@ struct board_ops dgnc_neo_ops = {
.send_immediate_char =  neo_send_immediate_char
 };
 
-static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08,
-0x10, 0x20, 0x40, 0x80 };
-
 /*
  * This function allows calls to ensure that all outstanding
  * PCI writes have been completed, by doing a PCI read against
@@ -923,9 +920,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
struct dgnc_board *brd = voidbrd;
struct channel_t *ch;
int port = 0;
-   int type = 0;
-   int current_port;
-   u32 tmp;
+   int type;
u32 uart_poll;
unsigned long flags;
unsigned long flags2;
@@ -960,28 +955,29 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
 
/* At this point, we have at least SOMETHING to service, dig further... 
*/
 
-   current_port = 0;
-
/* Loop on each port */
while ((uart_poll & 0xff) != 0) {
-   tmp = uart_poll;
-
-   /* Check current port to see if it has interrupt pending */
-   if ((tmp & dgnc_offset_table[current_port]) != 0) {
-   port = current_port;
-   type = tmp >> (8 + (port * 3));
-   type &= 0x7;
-   } else {
-   current_port++;
-   continue;
-   }
+   int i;
 
-   /* Remove this port + type from uart_poll */
-   uart_poll &= ~(dgnc_offset_table[port]);
+   type = 0;
 
-   if (!type) {
-   /* If no type, just ignore it, and move onto next port 
*/
-   continue;
+   for (i = port; i < MAXPORTS; i++) {
+   unsigned int offset_table = 0x1 << i;
+
+   /* Check current port to see
+* if it has interrupt pending
+*/
+   if ((uart_poll & offset_table) != 0) {
+   port = i;
+   type = uart_poll >> (8 + (port * 3));
+   type &= 0x7;
+
+   /* Remove this port + type from uart_poll */
+   uart_poll &= ~(offset_table);
+   }
+
+   if (type)
+   break;
}
 
/* Switch on type of interrupt we have */
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] staging: dgnc: fix 'line over 80 characters'

2016-03-24 Thread DaeSeok Youn
2016-03-25 12:19 GMT+09:00 Joe Perches <j...@perches.com>:
> On Fri, 2016-03-25 at 11:44 +0900, Daeseok Youn wrote:
>> fix checkpatch.pl warning about 'line over 80 characters'
>> in dgnc_neo.c
> []
>> diff --git a/drivers/staging/dgnc/dgnc_neo.c 
>> b/drivers/staging/dgnc/dgnc_neo.c
> []
>> @@ -77,7 +77,8 @@ struct board_ops dgnc_neo_ops = {
>>   .send_immediate_char =  neo_send_immediate_char
>>  };
>>
>> -static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 
>> 0x40, 0x80 };
>> +static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08,
>> +  0x10, 0x20, 0x40, 0x80 };
>
Hi, Joe.

> It may be better to remove this array and use BIT or << where
> dgnc_offset_table is used instead.
Yes, I will remove this array, and use BIT or '<<' instead of using table.
But "a patch" as to have one meaning so I think this patch will be
sent with another one.
>
> If not, this should be const.
>
> static const uint dgnc_offset_table[] = {
> 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
> };
>
>> @@ -116,7 +117,8 @@ static inline void neo_set_cts_flow_control(struct 
>> channel_t *ch)
>>   writeb(efr, >ch_neo_uart->efr);
>>
>>   /* Turn on table D, with 8 char hi/low watermarks */
>> - writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY), 
>> >ch_neo_uart->fctr);
>> + writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY),
>> + >ch_neo_uart->fctr);
>
> You could remove parentheses here around the CONST | CONST
OK. I got it. but it also, I will send a patch after fixing this, not
in this, right?
>
>> @@ -150,7 +152,8 @@ static inline void neo_set_rts_flow_control(struct 
>> channel_t *ch)
>>   /* Turn on UART enhanced bits */
>>   writeb(efr, >ch_neo_uart->efr);
>>
>> - writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY), 
>> >ch_neo_uart->fctr);
>> + writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY),
>> + >ch_neo_uart->fctr);
>
> and here and all the other writeb uses
Thanks.

regards,
Daeseok.
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: dgnc: fix Logical continuations should be on the

2016-03-24 Thread Daeseok Youn
fix checkpatch.pl warning about 'Logical continuations
should be on the previous line' in dgnc_neo.c file.

I think the 'force' need to check first, because if the 'force' is true,
it doesn't need to call another function call.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_neo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 10b596f..d732e6e 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -359,8 +359,8 @@ static inline void neo_clear_break(struct channel_t *ch, 
int force)
 
/* Turn break off, and unset some variables */
if (ch->ch_flags & CH_BREAK_SENDING) {
-   if (time_after_eq(jiffies, ch->ch_stop_sending_break)
-   || force) {
+   if (force ||
+   time_after_eq(jiffies, ch->ch_stop_sending_break)) {
unsigned char temp = readb(>ch_neo_uart->lcr);
 
writeb((temp & ~UART_LCR_SBC), >ch_neo_uart->lcr);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: dgnc: fix 'line over 80 characters'

2016-03-24 Thread Daeseok Youn
fix checkpatch.pl warning about 'line over 80 characters'
in dgnc_neo.c

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_neo.c | 66 +++--
 1 file changed, 44 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 31ac437..10b596f 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -77,7 +77,8 @@ struct board_ops dgnc_neo_ops = {
.send_immediate_char =  neo_send_immediate_char
 };
 
-static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 
0x80 };
+static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08,
+0x10, 0x20, 0x40, 0x80 };
 
 /*
  * This function allows calls to ensure that all outstanding
@@ -116,7 +117,8 @@ static inline void neo_set_cts_flow_control(struct 
channel_t *ch)
writeb(efr, >ch_neo_uart->efr);
 
/* Turn on table D, with 8 char hi/low watermarks */
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY), 
>ch_neo_uart->fctr);
+   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY),
+   >ch_neo_uart->fctr);
 
/* Feed the UART our trigger levels */
writeb(8, >ch_neo_uart->tfifo);
@@ -150,7 +152,8 @@ static inline void neo_set_rts_flow_control(struct 
channel_t *ch)
/* Turn on UART enhanced bits */
writeb(efr, >ch_neo_uart->efr);
 
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY), 
>ch_neo_uart->fctr);
+   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY),
+   >ch_neo_uart->fctr);
ch->ch_r_watermark = 4;
 
writeb(32, >ch_neo_uart->rfifo);
@@ -187,7 +190,8 @@ static inline void neo_set_ixon_flow_control(struct 
channel_t *ch)
/* Turn on UART enhanced bits */
writeb(efr, >ch_neo_uart->efr);
 
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY), 
>ch_neo_uart->fctr);
+   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY),
+  >ch_neo_uart->fctr);
ch->ch_r_watermark = 4;
 
writeb(32, >ch_neo_uart->rfifo);
@@ -225,7 +229,8 @@ static inline void neo_set_ixoff_flow_control(struct 
channel_t *ch)
writeb(efr, >ch_neo_uart->efr);
 
/* Turn on table D, with 8 char hi/low watermarks */
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY), 
>ch_neo_uart->fctr);
+   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY),
+   >ch_neo_uart->fctr);
 
writeb(8, >ch_neo_uart->tfifo);
ch->ch_t_tlevel = 8;
@@ -265,7 +270,8 @@ static inline void neo_set_no_input_flow_control(struct 
channel_t *ch)
writeb(efr, >ch_neo_uart->efr);
 
/* Turn on table D, with 8 char hi/low watermarks */
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY), 
>ch_neo_uart->fctr);
+   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY),
+   >ch_neo_uart->fctr);
 
ch->ch_r_watermark = 0;
 
@@ -302,7 +308,8 @@ static inline void neo_set_no_output_flow_control(struct 
channel_t *ch)
writeb(efr, >ch_neo_uart->efr);
 
/* Turn on table D, with 8 char hi/low watermarks */
-   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY), 
>ch_neo_uart->fctr);
+   writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY),
+   >ch_neo_uart->fctr);
 
ch->ch_r_watermark = 0;
 
@@ -321,7 +328,8 @@ static inline void neo_set_no_output_flow_control(struct 
channel_t *ch)
 static inline void neo_set_new_start_stop_chars(struct channel_t *ch)
 {
/* if hardware flow control is set, then skip this whole thing */
-   if (ch->ch_digi.digi_flags & (CTSPACE | RTSPACE) || ch->ch_c_cflag & 
CRTSCTS)
+   if (ch->ch_digi.digi_flags & (CTSPACE | RTSPACE) ||
+   ch->ch_c_cflag & CRTSCTS)
return;
 
/* Tell UART what start/stop chars it should be looking for */
@@ -393,7 +401,8 @@ static inline void neo_parse_isr(struct dgnc_board *brd, 
uint port)
break;
 
/*
-* Yank off the upper 2 bits, which just show that the FIFO's 
are enabled.
+* Yank off the upper 2 bits,
+* which just show that the FIFO's are enabled.
 */
isr &= ~(UART_17158_IIR_FIFO_ENABLED);
 
@@ -666,7 +675,8 @@ static void neo_param(struct tty_struct *tty)
};
 
/* Only use the TXPrint baud rate if the terminal unit is NOT 
open */
-   if (!(ch->ch_tun.un_flags & UN_ISOPEN) && (un->un_type == 
DGNC_PRINT))
+   if (!(ch->ch_tun.un_flags & UN_ISOPEN) &&

[PATCH 2/2] staging: dgnc: remove unused variable in dgnc_board

2016-03-24 Thread Daeseok Youn
TtyRefCnt was not used anywhere in dgnc.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 3d8e15f..44216ae 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -213,8 +213,6 @@ struct dgnc_board {
uintdgnc_serial_major;
uintdgnc_transparent_print_major;
 
-   uintTtyRefCnt;
-
u16 dpatype;/* The board "type",
 * as defined by DPA
 */
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: dgnc: fix CamelCase in dgnc_drvier.h and

2016-03-24 Thread Daeseok Youn
fix checkpatch.pl warning about CamelCase

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.h | 12 ++--
 drivers/staging/dgnc/dgnc_tty.c| 32 
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index f3d00df..3d8e15f 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -203,15 +203,15 @@ struct dgnc_board {
 */
 
struct tty_driver serial_driver;
-   charSerialName[200];
+   charserial_name[200];
struct tty_driver print_driver;
-   charPrintName[200];
+   charprint_name[200];
 
-   booldgnc_Major_Serial_Registered;
-   booldgnc_Major_TransparentPrint_Registered;
+   booldgnc_major_serial_registered;
+   booldgnc_major_transparent_print_registered;
 
-   uintdgnc_Serial_Major;
-   uintdgnc_TransparentPrint_Major;
+   uintdgnc_serial_major;
+   uintdgnc_transparent_print_major;
 
uintTtyRefCnt;
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 081ac75..98b88d1 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -180,9 +180,9 @@ int dgnc_tty_register(struct dgnc_board *brd)
 
brd->serial_driver.magic = TTY_DRIVER_MAGIC;
 
-   snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
+   snprintf(brd->serial_name, MAXTTYNAMELEN, "tty_dgnc_%d_", 
brd->boardnum);
 
-   brd->serial_driver.name = brd->SerialName;
+   brd->serial_driver.name = brd->serial_name;
brd->serial_driver.name_base = 0;
brd->serial_driver.major = 0;
brd->serial_driver.minor_start = 0;
@@ -218,7 +218,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
 */
tty_set_operations(>serial_driver, _tty_ops);
 
-   if (!brd->dgnc_Major_Serial_Registered) {
+   if (!brd->dgnc_major_serial_registered) {
/* Register tty devices */
rc = tty_register_driver(>serial_driver);
if (rc < 0) {
@@ -226,7 +226,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
"Can't register tty device (%d)\n", rc);
return rc;
}
-   brd->dgnc_Major_Serial_Registered = true;
+   brd->dgnc_major_serial_registered = true;
}
 
/*
@@ -235,9 +235,9 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * we are when we get into the dgnc_tty_open() routine.
 */
brd->print_driver.magic = TTY_DRIVER_MAGIC;
-   snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
+   snprintf(brd->print_name, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
 
-   brd->print_driver.name = brd->PrintName;
+   brd->print_driver.name = brd->print_name;
brd->print_driver.name_base = 0;
brd->print_driver.major = brd->serial_driver.major;
brd->print_driver.minor_start = 0x80;
@@ -273,7 +273,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
 */
tty_set_operations(>print_driver, _tty_ops);
 
-   if (!brd->dgnc_Major_TransparentPrint_Registered) {
+   if (!brd->dgnc_major_transparent_print_registered) {
/* Register Transparent Print devices */
rc = tty_register_driver(>print_driver);
if (rc < 0) {
@@ -282,12 +282,12 @@ int dgnc_tty_register(struct dgnc_board *brd)
rc);
return rc;
}
-   brd->dgnc_Major_TransparentPrint_Registered = true;
+   brd->dgnc_major_transparent_print_registered = true;
}
 
dgnc_BoardsByMajor[brd->serial_driver.major] = brd;
-   brd->dgnc_Serial_Major = brd->serial_driver.major;
-   brd->dgnc_TransparentPrint_Major = brd->print_driver.major;
+   brd->dgnc_serial_major = brd->serial_driver.major;
+   brd->dgnc_transparent_print_major = brd->print_driver.major;
 
return rc;
 }
@@ -407,9 +407,9 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
 {
int i = 0;
 
-   if (brd->dgnc_Major_Serial_Registered) {
+   if (brd->dgnc_major_serial_registered) {
dgnc_BoardsByMajor[brd->serial_driver.major] = NULL;
-   brd->dgnc_Serial_Major = 0;
+   brd->dgnc_serial_major = 0;
for (i = 0; i < brd->nasync; i++) {
if (

[PATCH V2] staging: dgnc: fix CamelCase in dgnc_driver.c

2016-03-23 Thread Daeseok Youn
fix checkpatch.pl warning about CamelCase.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: fix build errors reported by kbuild test robot.
And also save the attached .config file to my linux build tree.
build successfully without any errors.

 drivers/staging/dgnc/dgnc_driver.c | 52 +++---
 drivers/staging/dgnc/dgnc_driver.h |  6 ++---
 drivers/staging/dgnc/dgnc_mgmt.c   | 28 ++--
 drivers/staging/dgnc/dgnc_sysfs.c  |  2 +-
 4 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 4eb410e..af2e835 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -48,7 +48,7 @@ static void   dgnc_do_remap(struct dgnc_board *brd);
 /*
  * File operations permitted on Control/Management major.
  */
-static const struct file_operations dgnc_BoardFops = {
+static const struct file_operations dgnc_board_fops = {
.owner  =   THIS_MODULE,
.unlocked_ioctl =   dgnc_mgmt_ioctl,
.open   =   dgnc_mgmt_open,
@@ -58,11 +58,11 @@ static const struct file_operations dgnc_BoardFops = {
 /*
  * Globals
  */
-uint   dgnc_NumBoards;
-struct dgnc_board  *dgnc_Board[MAXBOARDS];
+uint   dgnc_num_boards;
+struct dgnc_board  *dgnc_board[MAXBOARDS];
 DEFINE_SPINLOCK(dgnc_global_lock);
 DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */
-uint   dgnc_Major;
+uint   dgnc_major;
 intdgnc_poll_tick = 20;/* Poll interval - 20 ms */
 
 /*
@@ -92,7 +92,7 @@ struct board_id {
unsigned int is_pci_express;
 };
 
-static struct board_id dgnc_Ids[] = {
+static struct board_id dgnc_ids[] = {
{   PCI_DEVICE_CLASSIC_4_PCI_NAME,  4,  0   },
{   PCI_DEVICE_CLASSIC_4_422_PCI_NAME,  4,  0   },
{   PCI_DEVICE_CLASSIC_8_PCI_NAME,  8,  0   },
@@ -140,14 +140,14 @@ static void cleanup(bool sysfiles)
if (sysfiles)
dgnc_remove_driver_sysfiles(_driver);
 
-   device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
+   device_destroy(dgnc_class, MKDEV(dgnc_major, 0));
class_destroy(dgnc_class);
-   unregister_chrdev(dgnc_Major, "dgnc");
+   unregister_chrdev(dgnc_major, "dgnc");
 
-   for (i = 0; i < dgnc_NumBoards; ++i) {
-   dgnc_remove_ports_sysfiles(dgnc_Board[i]);
-   dgnc_tty_uninit(dgnc_Board[i]);
-   dgnc_cleanup_board(dgnc_Board[i]);
+   for (i = 0; i < dgnc_num_boards; ++i) {
+   dgnc_remove_ports_sysfiles(dgnc_board[i]);
+   dgnc_tty_uninit(dgnc_board[i]);
+   dgnc_cleanup_board(dgnc_board[i]);
}
 
dgnc_tty_post_uninit();
@@ -217,12 +217,12 @@ static int dgnc_start(void)
 *
 * Register management/dpa devices
 */
-   rc = register_chrdev(0, "dgnc", _BoardFops);
+   rc = register_chrdev(0, "dgnc", _board_fops);
if (rc < 0) {
pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc);
return rc;
}
-   dgnc_Major = rc;
+   dgnc_major = rc;
 
dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
if (IS_ERR(dgnc_class)) {
@@ -232,7 +232,7 @@ static int dgnc_start(void)
}
 
dev = device_create(dgnc_class, NULL,
-   MKDEV(dgnc_Major, 0),
+   MKDEV(dgnc_major, 0),
NULL, "dgnc_mgmt");
if (IS_ERR(dev)) {
rc = PTR_ERR(dev);
@@ -262,11 +262,11 @@ static int dgnc_start(void)
return 0;
 
 failed_tty:
-   device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
+   device_destroy(dgnc_class, MKDEV(dgnc_major, 0));
 failed_device:
class_destroy(dgnc_class);
 failed_class:
-   unregister_chrdev(dgnc_Major, "dgnc");
+   unregister_chrdev(dgnc_major, "dgnc");
return rc;
 }
 
@@ -283,7 +283,7 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
rc = dgnc_found_board(pdev, ent->driver_data);
if (rc == 0)
-   dgnc_NumBoards++;
+   dgnc_num_boards++;
 
return rc;
 }
@@ -346,7 +346,7 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
}
}
 
-   dgnc_Board[brd->boardnum] = NULL;
+   dgnc_board[brd->boardnum] = NULL;
 
kfree(brd);
 }
@@ -365,8 +365,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
unsigned long flags;
 
/* get the board structure and prep it */
-   dgnc_Board[dgnc_NumBoards] = kzalloc(sizeof(*brd), GFP_KERNEL);
-   brd = dgnc_Board[dgnc_NumBoards];

[PATCH] staging: dgnc: fix CamelCase in dgnc_driver.c

2016-03-22 Thread Daeseok Youn
fix checkpatch.pl warning about CamelCase.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.c | 52 +++---
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 4eb410e..af2e835 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -48,7 +48,7 @@ static void   dgnc_do_remap(struct dgnc_board *brd);
 /*
  * File operations permitted on Control/Management major.
  */
-static const struct file_operations dgnc_BoardFops = {
+static const struct file_operations dgnc_board_fops = {
.owner  =   THIS_MODULE,
.unlocked_ioctl =   dgnc_mgmt_ioctl,
.open   =   dgnc_mgmt_open,
@@ -58,11 +58,11 @@ static const struct file_operations dgnc_BoardFops = {
 /*
  * Globals
  */
-uint   dgnc_NumBoards;
-struct dgnc_board  *dgnc_Board[MAXBOARDS];
+uint   dgnc_num_boards;
+struct dgnc_board  *dgnc_board[MAXBOARDS];
 DEFINE_SPINLOCK(dgnc_global_lock);
 DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */
-uint   dgnc_Major;
+uint   dgnc_major;
 intdgnc_poll_tick = 20;/* Poll interval - 20 ms */
 
 /*
@@ -92,7 +92,7 @@ struct board_id {
unsigned int is_pci_express;
 };
 
-static struct board_id dgnc_Ids[] = {
+static struct board_id dgnc_ids[] = {
{   PCI_DEVICE_CLASSIC_4_PCI_NAME,  4,  0   },
{   PCI_DEVICE_CLASSIC_4_422_PCI_NAME,  4,  0   },
{   PCI_DEVICE_CLASSIC_8_PCI_NAME,  8,  0   },
@@ -140,14 +140,14 @@ static void cleanup(bool sysfiles)
if (sysfiles)
dgnc_remove_driver_sysfiles(_driver);
 
-   device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
+   device_destroy(dgnc_class, MKDEV(dgnc_major, 0));
class_destroy(dgnc_class);
-   unregister_chrdev(dgnc_Major, "dgnc");
+   unregister_chrdev(dgnc_major, "dgnc");
 
-   for (i = 0; i < dgnc_NumBoards; ++i) {
-   dgnc_remove_ports_sysfiles(dgnc_Board[i]);
-   dgnc_tty_uninit(dgnc_Board[i]);
-   dgnc_cleanup_board(dgnc_Board[i]);
+   for (i = 0; i < dgnc_num_boards; ++i) {
+   dgnc_remove_ports_sysfiles(dgnc_board[i]);
+   dgnc_tty_uninit(dgnc_board[i]);
+   dgnc_cleanup_board(dgnc_board[i]);
}
 
dgnc_tty_post_uninit();
@@ -217,12 +217,12 @@ static int dgnc_start(void)
 *
 * Register management/dpa devices
 */
-   rc = register_chrdev(0, "dgnc", _BoardFops);
+   rc = register_chrdev(0, "dgnc", _board_fops);
if (rc < 0) {
pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc);
return rc;
}
-   dgnc_Major = rc;
+   dgnc_major = rc;
 
dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
if (IS_ERR(dgnc_class)) {
@@ -232,7 +232,7 @@ static int dgnc_start(void)
}
 
dev = device_create(dgnc_class, NULL,
-   MKDEV(dgnc_Major, 0),
+   MKDEV(dgnc_major, 0),
NULL, "dgnc_mgmt");
if (IS_ERR(dev)) {
rc = PTR_ERR(dev);
@@ -262,11 +262,11 @@ static int dgnc_start(void)
return 0;
 
 failed_tty:
-   device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
+   device_destroy(dgnc_class, MKDEV(dgnc_major, 0));
 failed_device:
class_destroy(dgnc_class);
 failed_class:
-   unregister_chrdev(dgnc_Major, "dgnc");
+   unregister_chrdev(dgnc_major, "dgnc");
return rc;
 }
 
@@ -283,7 +283,7 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
rc = dgnc_found_board(pdev, ent->driver_data);
if (rc == 0)
-   dgnc_NumBoards++;
+   dgnc_num_boards++;
 
return rc;
 }
@@ -346,7 +346,7 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
}
}
 
-   dgnc_Board[brd->boardnum] = NULL;
+   dgnc_board[brd->boardnum] = NULL;
 
kfree(brd);
 }
@@ -365,8 +365,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
unsigned long flags;
 
/* get the board structure and prep it */
-   dgnc_Board[dgnc_NumBoards] = kzalloc(sizeof(*brd), GFP_KERNEL);
-   brd = dgnc_Board[dgnc_NumBoards];
+   dgnc_board[dgnc_num_boards] = kzalloc(sizeof(*brd), GFP_KERNEL);
+   brd = dgnc_board[dgnc_num_boards];
 
if (!brd)
return -ENOMEM;
@@ -382,15 +382,15 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* store the info for the board we've found */
brd->m

Re: [PATCH 3/3] staging: dgnc: use tty_alloc_driver instead of kcalloc

2016-03-22 Thread DaeSeok Youn
2016-03-22 22:02 GMT+09:00 Greg KH <gre...@linuxfoundation.org>:
> On Tue, Mar 22, 2016 at 04:40:24PM +0900, DaeSeok Youn wrote:
>> 2016-03-22 6:05 GMT+09:00 Greg KH <gre...@linuxfoundation.org>:
>> > On Mon, Mar 14, 2016 at 01:29:00PM +0900, Daeseok Youn wrote:
>> >> the tty_alloc_driver() can allocate memory for ttys and termios.
>> >> And also it can release allocated memory easly with using
>> >> put_tty_driver().
>> >>
>> >> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>> >
>> > But you broke the driver in the previous patch, you can't do that, each
>> > patch has to be 'stand-alone'.
>> I am not sure about 'stand-alone'. this patch has to have dependency on
>> previous patch..
>
> Yes, that is ok, but your first patch said it was just function
> renaming, and then the second patch broke functionality, and the third
> fixed it up.  You should have a working kernel at each step in your
> patch series, which you did not.
I got it. So I start over from fixing coding style of dgnc module like
I was doing
dgap module.

>
>> And I have a question not related this thread,
>> I had been waiting my patches merged and also have other patches on
>> same file(in case of dgnc).
>> I couldn't send next patches until previous patches are taken.
>> How can I manage my patches for this case?
>
> Just send your new patches and say they depend on the previous ones.  My
> staging patch queue is almost empty at the moment so odds are I have
> already applied, or rejected them.
thanks for your explanation. :-)

I will try to make patches more carefully.

regards,
Daeseok.
>
> thanks,
>
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgnc: fix camelcase of SerialDriver and PrintDriver

2016-03-22 Thread DaeSeok Youn
2016-03-22 21:21 GMT+09:00 walter harms <wha...@bfs.de>:
>
> You have send this patch before, right ?
> then it is a good custom to have something like: [Patch V2] in the
> subject line. In the comment you should write somethink like
>
> v2:  fix withspace damage
> v1:  fix issue
>
> Otherwise none of the reviewer maintainer will see what was changes.
> Sometimes patch run a few rounds before applied.
Yes, you're right.

I should leave a message.. sorry.

I had been making many patches, I think, until last year.
But I didn't contribute to linux kernel for long time(maybe one year.. :-( )
And I made mistakes while sending patches.. I was breaking the working
code because of this.

So I want to start over from making minor patches like fixing coding style.

Now, this patch was taken by Greg.
And also I will try to fix other coding style first of this module.
(I had been fixing issues dgap module that was removed in linux-next
branch. dgnc has same issues what dgap has.
I can also fix issues in dgnc module.)

Thanks for comment.

regards,
Daeseok.
>
> just my two cents
>
> re,
>  wh
>
> Am 22.03.2016 10:20, schrieb Daeseok Youn:
>> fix the checkpatch.pl warning about CamelCase.
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>> ---
>>  drivers/staging/dgnc/dgnc_driver.h |   4 +-
>>  drivers/staging/dgnc/dgnc_tty.c| 118 
>> ++---
>>  2 files changed, 61 insertions(+), 61 deletions(-)
>>
>> diff --git a/drivers/staging/dgnc/dgnc_driver.h 
>> b/drivers/staging/dgnc/dgnc_driver.h
>> index e4be81b..953c891 100644
>> --- a/drivers/staging/dgnc/dgnc_driver.h
>> +++ b/drivers/staging/dgnc/dgnc_driver.h
>> @@ -202,9 +202,9 @@ struct dgnc_board {
>>* to our channels.
>>*/
>>
>> - struct tty_driver   SerialDriver;
>> + struct tty_driver serial_driver;
>>   charSerialName[200];
>> - struct tty_driver   PrintDriver;
>> + struct tty_driver print_driver;
>>   charPrintName[200];
>>
>>   booldgnc_Major_Serial_Registered;
>> diff --git a/drivers/staging/dgnc/dgnc_tty.c 
>> b/drivers/staging/dgnc/dgnc_tty.c
>> index bcd2bdf..081ac75 100644
>> --- a/drivers/staging/dgnc/dgnc_tty.c
>> +++ b/drivers/staging/dgnc/dgnc_tty.c
>> @@ -178,20 +178,20 @@ int dgnc_tty_register(struct dgnc_board *brd)
>>  {
>>   int rc = 0;
>>
>> - brd->SerialDriver.magic = TTY_DRIVER_MAGIC;
>> + brd->serial_driver.magic = TTY_DRIVER_MAGIC;
>>
>>   snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", 
>> brd->boardnum);
>>
>> - brd->SerialDriver.name = brd->SerialName;
>> - brd->SerialDriver.name_base = 0;
>> - brd->SerialDriver.major = 0;
>> - brd->SerialDriver.minor_start = 0;
>> - brd->SerialDriver.num = brd->maxports;
>> - brd->SerialDriver.type = TTY_DRIVER_TYPE_SERIAL;
>> - brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL;
>> - brd->SerialDriver.init_termios = DgncDefaultTermios;
>> - brd->SerialDriver.driver_name = DRVSTR;
>> - brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW |
>> + brd->serial_driver.name = brd->SerialName;
>> + brd->serial_driver.name_base = 0;
>> + brd->serial_driver.major = 0;
>> + brd->serial_driver.minor_start = 0;
>> + brd->serial_driver.num = brd->maxports;
>> + brd->serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
>> + brd->serial_driver.subtype = SERIAL_TYPE_NORMAL;
>> + brd->serial_driver.init_termios = DgncDefaultTermios;
>> + brd->serial_driver.driver_name = DRVSTR;
>> + brd->serial_driver.flags = (TTY_DRIVER_REAL_RAW |
>>  TTY_DRIVER_DYNAMIC_DEV |
>>  TTY_DRIVER_HARDWARE_BREAK);
>>
>> @@ -199,28 +199,28 @@ int dgnc_tty_register(struct dgnc_board *brd)
>>* The kernel wants space to store pointers to
>>* tty_struct's and termios's.
>>*/
>> - brd->SerialDriver.ttys = kcalloc(brd->maxports,
>> -  sizeof(*brd->SerialDriver.ttys),
>> + brd->serial_driver.ttys = kcalloc(brd->maxports,
>> +  sizeof(*brd->serial_driver.ttys),
>>GFP_KERNEL);
>> - if (!brd->SerialDriver.ttys)
>> + if (!brd->

[PATCH] staging: dgnc: fix camelcase of SerialDriver and PrintDriver

2016-03-22 Thread Daeseok Youn
fix the checkpatch.pl warning about CamelCase.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.h |   4 +-
 drivers/staging/dgnc/dgnc_tty.c| 118 ++---
 2 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index e4be81b..953c891 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -202,9 +202,9 @@ struct dgnc_board {
 * to our channels.
 */
 
-   struct tty_driver   SerialDriver;
+   struct tty_driver serial_driver;
charSerialName[200];
-   struct tty_driver   PrintDriver;
+   struct tty_driver print_driver;
charPrintName[200];
 
booldgnc_Major_Serial_Registered;
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index bcd2bdf..081ac75 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -178,20 +178,20 @@ int dgnc_tty_register(struct dgnc_board *brd)
 {
int rc = 0;
 
-   brd->SerialDriver.magic = TTY_DRIVER_MAGIC;
+   brd->serial_driver.magic = TTY_DRIVER_MAGIC;
 
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
 
-   brd->SerialDriver.name = brd->SerialName;
-   brd->SerialDriver.name_base = 0;
-   brd->SerialDriver.major = 0;
-   brd->SerialDriver.minor_start = 0;
-   brd->SerialDriver.num = brd->maxports;
-   brd->SerialDriver.type = TTY_DRIVER_TYPE_SERIAL;
-   brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL;
-   brd->SerialDriver.init_termios = DgncDefaultTermios;
-   brd->SerialDriver.driver_name = DRVSTR;
-   brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW |
+   brd->serial_driver.name = brd->SerialName;
+   brd->serial_driver.name_base = 0;
+   brd->serial_driver.major = 0;
+   brd->serial_driver.minor_start = 0;
+   brd->serial_driver.num = brd->maxports;
+   brd->serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
+   brd->serial_driver.subtype = SERIAL_TYPE_NORMAL;
+   brd->serial_driver.init_termios = DgncDefaultTermios;
+   brd->serial_driver.driver_name = DRVSTR;
+   brd->serial_driver.flags = (TTY_DRIVER_REAL_RAW |
   TTY_DRIVER_DYNAMIC_DEV |
   TTY_DRIVER_HARDWARE_BREAK);
 
@@ -199,28 +199,28 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd->SerialDriver.ttys = kcalloc(brd->maxports,
-sizeof(*brd->SerialDriver.ttys),
+   brd->serial_driver.ttys = kcalloc(brd->maxports,
+sizeof(*brd->serial_driver.ttys),
 GFP_KERNEL);
-   if (!brd->SerialDriver.ttys)
+   if (!brd->serial_driver.ttys)
return -ENOMEM;
 
-   kref_init(>SerialDriver.kref);
-   brd->SerialDriver.termios = kcalloc(brd->maxports,
-   sizeof(*brd->SerialDriver.termios),
+   kref_init(>serial_driver.kref);
+   brd->serial_driver.termios = kcalloc(brd->maxports,
+   sizeof(*brd->serial_driver.termios),
GFP_KERNEL);
-   if (!brd->SerialDriver.termios)
+   if (!brd->serial_driver.termios)
return -ENOMEM;
 
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
 */
-   tty_set_operations(>SerialDriver, _tty_ops);
+   tty_set_operations(>serial_driver, _tty_ops);
 
if (!brd->dgnc_Major_Serial_Registered) {
/* Register tty devices */
-   rc = tty_register_driver(>SerialDriver);
+   rc = tty_register_driver(>serial_driver);
if (rc < 0) {
dev_dbg(>pdev->dev,
"Can't register tty device (%d)\n", rc);
@@ -234,19 +234,19 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgnc_tty_open() routine.
 */
-   brd->PrintDriver.magic = TTY_DRIVER_MAGIC;
+   brd->print_driver.magic = TTY_DRIVER_MAGIC;
snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
 
-   brd->PrintDriver.name = brd->PrintName;
-   brd->PrintDriver.name_base = 0;
-   brd->Pr

Re: [PATCH 3/3] staging: dgnc: use tty_alloc_driver instead of kcalloc

2016-03-22 Thread DaeSeok Youn
2016-03-22 6:05 GMT+09:00 Greg KH <gre...@linuxfoundation.org>:
> On Mon, Mar 14, 2016 at 01:29:00PM +0900, Daeseok Youn wrote:
>> the tty_alloc_driver() can allocate memory for ttys and termios.
>> And also it can release allocated memory easly with using
>> put_tty_driver().
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>
> But you broke the driver in the previous patch, you can't do that, each
> patch has to be 'stand-alone'.
I am not sure about 'stand-alone'. this patch has to have dependency on
previous patch..

I am not sure how to make a series of patches that are related with others.

In this series of patches, 1/3 was failed to merge because changelog entry was
missing. So other patches(2/3, 3/3) was breaking working codes.
I will resend this patch with previous and check more before sending
these patches.
Sorry for the noise..

And I have a question not related this thread,
I had been waiting my patches merged and also have other patches on
same file(in case of dgnc).
I couldn't send next patches until previous patches are taken.
How can I manage my patches for this case?

thanks.

regards,
Daeseok.

>
> thanks,
>
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] staging: dgnc: use pointer type of tty_struct

2016-03-22 Thread DaeSeok Youn
2016-03-22 6:05 GMT+09:00 Greg KH <gre...@linuxfoundation.org>:
> On Mon, Mar 14, 2016 at 01:28:31PM +0900, Daeseok Youn wrote:
>> For using tty_alloc_driver, SerialDriver has to be pointer type.
>
> Yes, but you aren't calling tty_alloc_driver, so this patch totally
> breaks the working code :(
yes.. my changelog was NOT good enough to explain.
I was tried to make this patch based on "staging-testing branch" of
staging git tree.

Actually, I sent 3 patches
[1/3] staging: dgnc: fix camelcase of SerialDriver and PrintDriver
[2/3] staging: dgnc: use pointer type of tty_struct
[3/3] staging: dgnc: use tty_alloc_driver instead of kcalloc

without 1/3 patch set, it can break the working code..
(you left a comment on 1/3 and also it couldn't be taken.)
>
> Please be more careful...
Yes, I will be..
Sorry. :-(

I will resend a series of patches for this

thanks.
regards,
Daeseok.
>
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3] staging: dgnc: fix camelcase of SerialDriver and

2016-03-22 Thread DaeSeok Youn
2016-03-22 6:02 GMT+09:00 Greg KH <gre...@linuxfoundation.org>:
> On Mon, Mar 14, 2016 at 01:28:01PM +0900, Daeseok Youn wrote:
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>
> Your subject: does not make sense, and I can't take a patch without any
> changelog entry :(
ok. I will add comment to changelog entry and resend this.

Thanks.

regards,
Daeseok.
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging: dgnc: use pointer type of tty_struct

2016-03-13 Thread Daeseok Youn
For using tty_alloc_driver, SerialDriver has to be pointer type.
It also has checkpatch.pl warning about Camelcase, so
SerialDriver is changed to serial_driver.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.h |   4 +-
 drivers/staging/dgnc/dgnc_tty.c| 118 ++---
 2 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 953c891..15abe15 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -202,9 +202,9 @@ struct dgnc_board {
 * to our channels.
 */
 
-   struct tty_driver serial_driver;
+   struct tty_driver *serial_driver;
charSerialName[200];
-   struct tty_driver print_driver;
+   struct tty_driver *print_driver;
charPrintName[200];
 
booldgnc_Major_Serial_Registered;
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 51251ef..4e4efa2 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -178,20 +178,20 @@ int dgnc_tty_register(struct dgnc_board *brd)
 {
int rc = 0;
 
-   brd->serial_driver.magic = TTY_DRIVER_MAGIC;
+   brd->serial_driver->magic = TTY_DRIVER_MAGIC;
 
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
 
-   brd->serial_driver.name = brd->SerialName;
-   brd->serial_driver.name_base = 0;
-   brd->serial_driver.major = 0;
-   brd->serial_driver.minor_start = 0;
-   brd->serial_driver.num = brd->maxports;
-   brd->serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
-   brd->serial_driver.subtype = SERIAL_TYPE_NORMAL;
-   brd->serial_driver.init_termios = DgncDefaultTermios;
-   brd->serial_driver.driver_name = DRVSTR;
-   brd->serial_driver.flags = (TTY_DRIVER_REAL_RAW |
+   brd->serial_driver->name = brd->SerialName;
+   brd->serial_driver->name_base = 0;
+   brd->serial_driver->major = 0;
+   brd->serial_driver->minor_start = 0;
+   brd->serial_driver->num = brd->maxports;
+   brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
+   brd->serial_driver->subtype = SERIAL_TYPE_NORMAL;
+   brd->serial_driver->init_termios = DgncDefaultTermios;
+   brd->serial_driver->driver_name = DRVSTR;
+   brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW |
   TTY_DRIVER_DYNAMIC_DEV |
   TTY_DRIVER_HARDWARE_BREAK);
 
@@ -199,28 +199,28 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd->serial_driver.ttys = kcalloc(brd->maxports,
-sizeof(*brd->serial_driver.ttys),
+   brd->serial_driver->ttys = kcalloc(brd->maxports,
+sizeof(*brd->serial_driver->ttys),
 GFP_KERNEL);
-   if (!brd->serial_driver.ttys)
+   if (!brd->serial_driver->ttys)
return -ENOMEM;
 
-   kref_init(>serial_driver.kref);
-   brd->serial_driver.termios = kcalloc(brd->maxports,
-   sizeof(*brd->serial_driver.termios),
+   kref_init(>serial_driver->kref);
+   brd->serial_driver->termios = kcalloc(brd->maxports,
+   
sizeof(*brd->serial_driver->termios),
GFP_KERNEL);
-   if (!brd->serial_driver.termios)
+   if (!brd->serial_driver->termios)
return -ENOMEM;
 
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
 */
-   tty_set_operations(>serial_driver, _tty_ops);
+   tty_set_operations(brd->serial_driver, _tty_ops);
 
if (!brd->dgnc_Major_Serial_Registered) {
/* Register tty devices */
-   rc = tty_register_driver(>serial_driver);
+   rc = tty_register_driver(brd->serial_driver);
if (rc < 0) {
dev_dbg(>pdev->dev,
"Can't register tty device (%d)\n", rc);
@@ -234,19 +234,19 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgnc_tty_open() routine.
 */
-   brd->print_driver.magic = TTY_DRIVER_MAGIC;
+   brd->print_driver->magic = TTY_DRIVE

[PATCH 3/3] staging: dgnc: use tty_alloc_driver instead of kcalloc

2016-03-13 Thread Daeseok Youn
the tty_alloc_driver() can allocate memory for ttys and termios.
And also it can release allocated memory easly with using
put_tty_driver().

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 86 +++--
 1 file changed, 31 insertions(+), 55 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 4e4efa2..118936b 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -176,9 +176,15 @@ int dgnc_tty_preinit(void)
  */
 int dgnc_tty_register(struct dgnc_board *brd)
 {
-   int rc = 0;
+   int rc;
+
+   brd->serial_driver = tty_alloc_driver(brd->maxports,
+ TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_DYNAMIC_DEV |
+ TTY_DRIVER_HARDWARE_BREAK);
 
-   brd->serial_driver->magic = TTY_DRIVER_MAGIC;
+   if (IS_ERR(brd->serial_driver))
+   return PTR_ERR(brd->serial_driver);
 
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
 
@@ -186,31 +192,10 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->serial_driver->name_base = 0;
brd->serial_driver->major = 0;
brd->serial_driver->minor_start = 0;
-   brd->serial_driver->num = brd->maxports;
brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->serial_driver->subtype = SERIAL_TYPE_NORMAL;
brd->serial_driver->init_termios = DgncDefaultTermios;
brd->serial_driver->driver_name = DRVSTR;
-   brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW |
-  TTY_DRIVER_DYNAMIC_DEV |
-  TTY_DRIVER_HARDWARE_BREAK);
-
-   /*
-* The kernel wants space to store pointers to
-* tty_struct's and termios's.
-*/
-   brd->serial_driver->ttys = kcalloc(brd->maxports,
-sizeof(*brd->serial_driver->ttys),
-GFP_KERNEL);
-   if (!brd->serial_driver->ttys)
-   return -ENOMEM;
-
-   kref_init(>serial_driver->kref);
-   brd->serial_driver->termios = kcalloc(brd->maxports,
-   
sizeof(*brd->serial_driver->termios),
-   GFP_KERNEL);
-   if (!brd->serial_driver->termios)
-   return -ENOMEM;
 
/*
 * Entry points for driver.  Called by the kernel from
@@ -224,7 +209,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
if (rc < 0) {
dev_dbg(>pdev->dev,
"Can't register tty device (%d)\n", rc);
-   return rc;
+   goto free_serial_driver;
}
brd->dgnc_Major_Serial_Registered = true;
}
@@ -234,38 +219,26 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgnc_tty_open() routine.
 */
-   brd->print_driver->magic = TTY_DRIVER_MAGIC;
+   brd->print_driver = tty_alloc_driver(brd->maxports,
+TTY_DRIVER_REAL_RAW |
+TTY_DRIVER_DYNAMIC_DEV |
+TTY_DRIVER_HARDWARE_BREAK);
+
+   if (IS_ERR(brd->print_driver)) {
+   rc = PTR_ERR(brd->print_driver);
+   goto unregister_serial_driver;
+   }
+
snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
 
brd->print_driver->name = brd->PrintName;
brd->print_driver->name_base = 0;
brd->print_driver->major = brd->serial_driver->major;
brd->print_driver->minor_start = 0x80;
-   brd->print_driver->num = brd->maxports;
brd->print_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->print_driver->subtype = SERIAL_TYPE_NORMAL;
brd->print_driver->init_termios = DgncDefaultTermios;
brd->print_driver->driver_name = DRVSTR;
-   brd->print_driver->flags = (TTY_DRIVER_REAL_RAW |
- TTY_DRIVER_DYNAMIC_DEV |
- TTY_DRIVER_HARDWARE_BREAK);
-
-   /*
-* The kernel wants space to store pointers to
-* tty_struct's and termios's.  Must be separated from
-* the Serial Driver so we don't get confused
-*/
-   brd->print_driver->ttys = kcalloc(brd->maxports,
-

[PATCH 1/3] staging: dgnc: fix camelcase of SerialDriver and

2016-03-13 Thread Daeseok Youn
Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.h |   4 +-
 drivers/staging/dgnc/dgnc_tty.c| 118 ++---
 2 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index e4be81b..953c891 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -202,9 +202,9 @@ struct dgnc_board {
 * to our channels.
 */
 
-   struct tty_driver   SerialDriver;
+   struct tty_driver serial_driver;
charSerialName[200];
-   struct tty_driver   PrintDriver;
+   struct tty_driver print_driver;
charPrintName[200];
 
booldgnc_Major_Serial_Registered;
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index f33c3b5..51251ef 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -178,20 +178,20 @@ int dgnc_tty_register(struct dgnc_board *brd)
 {
int rc = 0;
 
-   brd->SerialDriver.magic = TTY_DRIVER_MAGIC;
+   brd->serial_driver.magic = TTY_DRIVER_MAGIC;
 
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
 
-   brd->SerialDriver.name = brd->SerialName;
-   brd->SerialDriver.name_base = 0;
-   brd->SerialDriver.major = 0;
-   brd->SerialDriver.minor_start = 0;
-   brd->SerialDriver.num = brd->maxports;
-   brd->SerialDriver.type = TTY_DRIVER_TYPE_SERIAL;
-   brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL;
-   brd->SerialDriver.init_termios = DgncDefaultTermios;
-   brd->SerialDriver.driver_name = DRVSTR;
-   brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW |
+   brd->serial_driver.name = brd->SerialName;
+   brd->serial_driver.name_base = 0;
+   brd->serial_driver.major = 0;
+   brd->serial_driver.minor_start = 0;
+   brd->serial_driver.num = brd->maxports;
+   brd->serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
+   brd->serial_driver.subtype = SERIAL_TYPE_NORMAL;
+   brd->serial_driver.init_termios = DgncDefaultTermios;
+   brd->serial_driver.driver_name = DRVSTR;
+   brd->serial_driver.flags = (TTY_DRIVER_REAL_RAW |
   TTY_DRIVER_DYNAMIC_DEV |
   TTY_DRIVER_HARDWARE_BREAK);
 
@@ -199,28 +199,28 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd->SerialDriver.ttys = kcalloc(brd->maxports,
-sizeof(*brd->SerialDriver.ttys),
+   brd->serial_driver.ttys = kcalloc(brd->maxports,
+sizeof(*brd->serial_driver.ttys),
 GFP_KERNEL);
-   if (!brd->SerialDriver.ttys)
+   if (!brd->serial_driver.ttys)
return -ENOMEM;
 
-   kref_init(>SerialDriver.kref);
-   brd->SerialDriver.termios = kcalloc(brd->maxports,
-   sizeof(*brd->SerialDriver.termios),
+   kref_init(>serial_driver.kref);
+   brd->serial_driver.termios = kcalloc(brd->maxports,
+   sizeof(*brd->serial_driver.termios),
GFP_KERNEL);
-   if (!brd->SerialDriver.termios)
+   if (!brd->serial_driver.termios)
return -ENOMEM;
 
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
 */
-   tty_set_operations(>SerialDriver, _tty_ops);
+   tty_set_operations(>serial_driver, _tty_ops);
 
if (!brd->dgnc_Major_Serial_Registered) {
/* Register tty devices */
-   rc = tty_register_driver(>SerialDriver);
+   rc = tty_register_driver(>serial_driver);
if (rc < 0) {
dev_dbg(>pdev->dev,
"Can't register tty device (%d)\n", rc);
@@ -234,19 +234,19 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgnc_tty_open() routine.
 */
-   brd->PrintDriver.magic = TTY_DRIVER_MAGIC;
+   brd->print_driver.magic = TTY_DRIVER_MAGIC;
snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
 
-   brd->PrintDriver.name = brd->PrintName;
-   brd->PrintDriver.name_base = 0;
-   brd->PrintDriver.major = brd->SerialDr

Re: [PATCH 2/2] Staging: dgap: modified the block comments

2016-03-10 Thread DaeSeok Youn
2016-03-10 17:21 GMT+09:00 Tanvi Surana :
> I have modified the file dgap.c ,making changes to the multiline 
> comments,thus making them appear presentable
>
> Signed-Off-By: Tanvi Surana 
> ---
>  drivers/staging/dgap/dgap.c | 59 
> +
>  1 file changed, 33 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
> index bad3551..deff2c4 100644
> --- a/drivers/staging/dgap/dgap.c
> +++ b/drivers/staging/dgap/dgap.c
> @@ -91,22 +91,22 @@ static uint dgap_poll_stop; /* Used to tell 
> poller to stop */
>  static struct timer_list dgap_poll_timer;
>
>  /*
> - SUPPORTED PRODUCTS
> -
> - Card Model   Number of Ports  Interface
> - 
> - Acceleport Xem   4 - 64  (EIA232 & EIA422)
> - Acceleport Xr4 & 8   (EIA232)
> - Acceleport Xr 9204 & 8   (EIA232)
> - Acceleport C/X   8 - 128 (EIA232)
> - Acceleport EPC/X 8 - 224 (EIA232)
> - Acceleport Xr/4224 & 8   (EIA422)
> - Acceleport 2r/9202   (EIA232)
> - Acceleport 4r/9204   (EIA232)
> - Acceleport 8r/9208   (EIA232)
> -
> - IBM 8-Port Asynchronous PCI Adapter  (EIA232)
> - IBM 128-Port Asynchronous PCI Adapter(EIA232 & EIA422)
> +   SUPPORTED PRODUCTS
> +
> +   Card Model   Number of Ports  Interface
> +   
> +   Acceleport Xem   4 - 64  (EIA232 & EIA422)
> +   Acceleport Xr4 & 8   (EIA232)
> +   Acceleport Xr 9204 & 8   (EIA232)
> +   Acceleport C/X   8 - 128 (EIA232)
> +   Acceleport EPC/X 8 - 224 (EIA232)
> +   Acceleport Xr/4224 & 8   (EIA422)
> +   Acceleport 2r/9202   (EIA232)
> +   Acceleport 4r/9204   (EIA232)
> +   Acceleport 8r/9208   (EIA232)
> +
> +   IBM 8-Port Asynchronous PCI Adapter  (EIA232)
> +   IBM 128-Port Asynchronous PCI Adapter(EIA232 & EIA422)
>  */
>
>  static struct pci_device_id dgap_pci_tbl[] = {
> @@ -1465,7 +1465,8 @@ static void dgap_parity_scan(struct channel_t *ch, 
> unsigned char *cbuf,
>   *
>   *  ch  - Pointer to channel structure.
>   *
> - *===*/
> + *===
> + */
>
>  static void dgap_input(struct channel_t *ch)
>  {
> @@ -1694,7 +1695,8 @@ static void dgap_write_wakeup(struct board_t *bd, 
> struct channel_t *ch,
>  /
>   * Determines when CARRIER changes state and takes appropriate
>   * action.
> - /
> + ***
> + */
>  static void dgap_carrier(struct channel_t *ch)
>  {
> struct board_t *bd;
> @@ -2339,7 +2341,8 @@ schedule_poller:
>   *  ncmds   - Wait until ncmds or fewer cmds are left
>   *in the cmd buffer before returning.
>   *
> - *===*/
> + *===
> + */
>  static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1,
>   u8 byte2, uint ncmds)
>  {
> @@ -2424,7 +2427,8 @@ static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 
> byte1,
>   *  ncmds   - Wait until ncmds or fewer cmds are left
>   *in the cmd buffer before returning.
>   *
> - *===*/
> + *===
> + */
>  static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds)
>  {
> char __iomem *vaddr;
> @@ -2506,7 +2510,8 @@ static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 
> word, uint ncmds)
>   *  ncmds   - Wait until ncmds or fewer cmds are left
>   *in the cmd buffer before returning.
>   *
> - *===*/
> + *===
> + */
>  static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint 
> ncmds)
>  {
> char __iomem *vaddr;
> @@ -2598,7 +2603,8 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 
> cmd, u16 word, uint ncmds)
>   *  buf 

[PATCH 2/2 V2] staging: dgnc: use tty_alloc_driver instead of kcalloc

2016-03-06 Thread Daeseok Youn
the tty_alloc_driver() can allocate memory for ttys and termios.
And also it can release allocated memory easly with using
put_tty_driver().

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: removes appended email header on top of commit log

 drivers/staging/dgnc/dgnc_tty.c | 86 +++--
 1 file changed, 31 insertions(+), 55 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index e91cf70..6437a81 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -176,9 +176,15 @@ int dgnc_tty_preinit(void)
  */
 int dgnc_tty_register(struct dgnc_board *brd)
 {
-   int rc = 0;
+   int rc;
+
+   brd->serial_driver = tty_alloc_driver(brd->maxports,
+ TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_DYNAMIC_DEV |
+ TTY_DRIVER_HARDWARE_BREAK);
 
-   brd->serial_driver->magic = TTY_DRIVER_MAGIC;
+   if (IS_ERR(brd->serial_driver))
+   return PTR_ERR(brd->serial_driver);
 
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
 
@@ -186,31 +192,10 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->serial_driver->name_base = 0;
brd->serial_driver->major = 0;
brd->serial_driver->minor_start = 0;
-   brd->serial_driver->num = brd->maxports;
brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->serial_driver->subtype = SERIAL_TYPE_NORMAL;
brd->serial_driver->init_termios = DgncDefaultTermios;
brd->serial_driver->driver_name = DRVSTR;
-   brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW |
-  TTY_DRIVER_DYNAMIC_DEV |
-  TTY_DRIVER_HARDWARE_BREAK);
-
-   /*
-* The kernel wants space to store pointers to
-* tty_struct's and termios's.
-*/
-   brd->serial_driver->ttys = kcalloc(brd->maxports,
-sizeof(*brd->serial_driver->ttys),
-GFP_KERNEL);
-   if (!brd->serial_driver->ttys)
-   return -ENOMEM;
-
-   kref_init(>serial_driver->kref);
-   brd->serial_driver->termios = kcalloc(brd->maxports,
-   
sizeof(*brd->serial_driver->termios),
-   GFP_KERNEL);
-   if (!brd->serial_driver->termios)
-   return -ENOMEM;
 
/*
 * Entry points for driver.  Called by the kernel from
@@ -224,7 +209,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
if (rc < 0) {
dev_dbg(>pdev->dev,
"Can't register tty device (%d)\n", rc);
-   return rc;
+   goto free_serial_driver;
}
brd->dgnc_Major_Serial_Registered = true;
}
@@ -234,38 +219,26 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgnc_tty_open() routine.
 */
-   brd->print_driver->magic = TTY_DRIVER_MAGIC;
+   brd->print_driver = tty_alloc_driver(brd->maxports,
+TTY_DRIVER_REAL_RAW |
+TTY_DRIVER_DYNAMIC_DEV |
+TTY_DRIVER_HARDWARE_BREAK);
+
+   if (IS_ERR(brd->print_driver)) {
+   rc = PTR_ERR(brd->print_driver);
+   goto unregister_serial_driver;
+   }
+
snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
 
brd->print_driver->name = brd->PrintName;
brd->print_driver->name_base = 0;
brd->print_driver->major = brd->serial_driver->major;
brd->print_driver->minor_start = 0x80;
-   brd->print_driver->num = brd->maxports;
brd->print_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->print_driver->subtype = SERIAL_TYPE_NORMAL;
brd->print_driver->init_termios = DgncDefaultTermios;
brd->print_driver->driver_name = DRVSTR;
-   brd->print_driver->flags = (TTY_DRIVER_REAL_RAW |
- TTY_DRIVER_DYNAMIC_DEV |
- TTY_DRIVER_HARDWARE_BREAK);
-
-   /*
-* The kernel wants space to store pointers to
-* tty_struct's and termios's.  Must be separated from
-* the Serial Driver so we don't get confused
-*/
-   brd->print_driver->ttys = kcalloc(brd->maxports,

[PATCH 1/2 V2] staging: dgnc: use pointer type of tty_struct

2016-03-06 Thread Daeseok Youn
For using tty_alloc_driver, SerialDriver has to be pointer type.
It also has checkpatch.pl warning about Camelcase, so
SerialDriver is changed to serial_driver.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: removes appended email header on top of commit log

 drivers/staging/dgnc/dgnc_driver.h |   4 +-
 drivers/staging/dgnc/dgnc_tty.c| 118 ++---
 2 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index ce7cd9b..1c7a8fa 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -205,9 +205,9 @@ struct dgnc_board {
 * to our channels.
 */
 
-   struct tty_driver   SerialDriver;
+   struct tty_driver *serial_driver;
charSerialName[200];
-   struct tty_driver   PrintDriver;
+   struct tty_driver *print_driver;
charPrintName[200];
 
booldgnc_Major_Serial_Registered;
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index b79eab0..e91cf70 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -178,20 +178,20 @@ int dgnc_tty_register(struct dgnc_board *brd)
 {
int rc = 0;
 
-   brd->SerialDriver.magic = TTY_DRIVER_MAGIC;
+   brd->serial_driver->magic = TTY_DRIVER_MAGIC;
 
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
 
-   brd->SerialDriver.name = brd->SerialName;
-   brd->SerialDriver.name_base = 0;
-   brd->SerialDriver.major = 0;
-   brd->SerialDriver.minor_start = 0;
-   brd->SerialDriver.num = brd->maxports;
-   brd->SerialDriver.type = TTY_DRIVER_TYPE_SERIAL;
-   brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL;
-   brd->SerialDriver.init_termios = DgncDefaultTermios;
-   brd->SerialDriver.driver_name = DRVSTR;
-   brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW |
+   brd->serial_driver->name = brd->SerialName;
+   brd->serial_driver->name_base = 0;
+   brd->serial_driver->major = 0;
+   brd->serial_driver->minor_start = 0;
+   brd->serial_driver->num = brd->maxports;
+   brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
+   brd->serial_driver->subtype = SERIAL_TYPE_NORMAL;
+   brd->serial_driver->init_termios = DgncDefaultTermios;
+   brd->serial_driver->driver_name = DRVSTR;
+   brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW |
   TTY_DRIVER_DYNAMIC_DEV |
   TTY_DRIVER_HARDWARE_BREAK);
 
@@ -199,28 +199,28 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd->SerialDriver.ttys = kcalloc(brd->maxports,
-sizeof(*brd->SerialDriver.ttys),
+   brd->serial_driver->ttys = kcalloc(brd->maxports,
+sizeof(*brd->serial_driver->ttys),
 GFP_KERNEL);
-   if (!brd->SerialDriver.ttys)
+   if (!brd->serial_driver->ttys)
return -ENOMEM;
 
-   kref_init(>SerialDriver.kref);
-   brd->SerialDriver.termios = kcalloc(brd->maxports,
-   sizeof(*brd->SerialDriver.termios),
+   kref_init(>serial_driver->kref);
+   brd->serial_driver->termios = kcalloc(brd->maxports,
+   
sizeof(*brd->serial_driver->termios),
GFP_KERNEL);
-   if (!brd->SerialDriver.termios)
+   if (!brd->serial_driver->termios)
return -ENOMEM;
 
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
 */
-   tty_set_operations(>SerialDriver, _tty_ops);
+   tty_set_operations(brd->serial_driver, _tty_ops);
 
if (!brd->dgnc_Major_Serial_Registered) {
/* Register tty devices */
-   rc = tty_register_driver(>SerialDriver);
+   rc = tty_register_driver(brd->serial_driver);
if (rc < 0) {
dev_dbg(>pdev->dev,
"Can't register tty device (%d)\n", rc);
@@ -234,19 +234,19 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgnc_tty_open() routine.
 */
-   brd->PrintDriver.magic = TTY_DRIVER_MAGIC;
+   brd-&

Re: [PATCH 1/2] staging: dgnc: use pointer type of tty_struct

2016-03-06 Thread DaeSeok Youn
2016-03-07 16:10 GMT+09:00 Sudip Mukherjee <sudipm.mukher...@gmail.com>:
>
> On Mon, Feb 29, 2016 at 11:15:51AM +0900, Daeseok Youn wrote:
> > From 70f8703b3bd73fa56f4ea91e98967b8925550aa6 Mon Sep 17 00:00:00 2001
> > From: Daeseok Youn <daeseok.y...@gmail.com>
> > Date: Thu, 25 Feb 2016 14:53:37 +0900
> > Subject: [PATCH 1/2] staging: dgnc: use pointer type of tty_struct
>
> These lines above are not required in the commit log. Please send v2 of
> both your patches without these lines.

ok. I will send my patches again.

Thanks.

regards,
Daeseok.
>
> regards
> sudip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2 v2] staging: dgnc: use tty_alloc_driver instead of kcalloc

2016-03-01 Thread Daeseok Youn
the tty_alloc_driver() can allocate memory for ttys and termios.
And also it can release allocated memory easly with using
put_tty_driver().

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
v2 : typo in subject, changed from dgap to dgnc

 drivers/staging/dgnc/dgnc_tty.c | 86 +++--
 1 file changed, 31 insertions(+), 55 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index e91cf70..6437a81 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -176,9 +176,15 @@ int dgnc_tty_preinit(void)
  */
 int dgnc_tty_register(struct dgnc_board *brd)
 {
-   int rc = 0;
+   int rc;
+
+   brd->serial_driver = tty_alloc_driver(brd->maxports,
+ TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_DYNAMIC_DEV |
+ TTY_DRIVER_HARDWARE_BREAK);
 
-   brd->serial_driver->magic = TTY_DRIVER_MAGIC;
+   if (IS_ERR(brd->serial_driver))
+   return PTR_ERR(brd->serial_driver);
 
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
 
@@ -186,31 +192,10 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->serial_driver->name_base = 0;
brd->serial_driver->major = 0;
brd->serial_driver->minor_start = 0;
-   brd->serial_driver->num = brd->maxports;
brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->serial_driver->subtype = SERIAL_TYPE_NORMAL;
brd->serial_driver->init_termios = DgncDefaultTermios;
brd->serial_driver->driver_name = DRVSTR;
-   brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW |
-  TTY_DRIVER_DYNAMIC_DEV |
-  TTY_DRIVER_HARDWARE_BREAK);
-
-   /*
-* The kernel wants space to store pointers to
-* tty_struct's and termios's.
-*/
-   brd->serial_driver->ttys = kcalloc(brd->maxports,
-sizeof(*brd->serial_driver->ttys),
-GFP_KERNEL);
-   if (!brd->serial_driver->ttys)
-   return -ENOMEM;
-
-   kref_init(>serial_driver->kref);
-   brd->serial_driver->termios = kcalloc(brd->maxports,
-   
sizeof(*brd->serial_driver->termios),
-   GFP_KERNEL);
-   if (!brd->serial_driver->termios)
-   return -ENOMEM;
 
/*
 * Entry points for driver.  Called by the kernel from
@@ -224,7 +209,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
if (rc < 0) {
dev_dbg(>pdev->dev,
"Can't register tty device (%d)\n", rc);
-   return rc;
+   goto free_serial_driver;
}
brd->dgnc_Major_Serial_Registered = true;
}
@@ -234,38 +219,26 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgnc_tty_open() routine.
 */
-   brd->print_driver->magic = TTY_DRIVER_MAGIC;
+   brd->print_driver = tty_alloc_driver(brd->maxports,
+TTY_DRIVER_REAL_RAW |
+TTY_DRIVER_DYNAMIC_DEV |
+TTY_DRIVER_HARDWARE_BREAK);
+
+   if (IS_ERR(brd->print_driver)) {
+   rc = PTR_ERR(brd->print_driver);
+   goto unregister_serial_driver;
+   }
+
snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
 
brd->print_driver->name = brd->PrintName;
brd->print_driver->name_base = 0;
brd->print_driver->major = brd->serial_driver->major;
brd->print_driver->minor_start = 0x80;
-   brd->print_driver->num = brd->maxports;
brd->print_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->print_driver->subtype = SERIAL_TYPE_NORMAL;
brd->print_driver->init_termios = DgncDefaultTermios;
brd->print_driver->driver_name = DRVSTR;
-   brd->print_driver->flags = (TTY_DRIVER_REAL_RAW |
- TTY_DRIVER_DYNAMIC_DEV |
- TTY_DRIVER_HARDWARE_BREAK);
-
-   /*
-* The kernel wants space to store pointers to
-* tty_struct's and termios's.  Must be separated from
-* the Serial Driver so we don't get confused
-*/
-   brd->print_driver->ttys = kcalloc(brd->maxports,
-  

[PATCH 2/2] staging: dgap: use tty_alloc_driver instead of kcalloc

2016-02-28 Thread Daeseok Youn
>From 60b1e6e5d9401f10f584928d4feeb8a3b72b46a9 Mon Sep 17 00:00:00 2001
From: Daeseok Youn <daeseok.y...@gmail.com>
Date: Mon, 29 Feb 2016 11:04:02 +0900
Subject: [PATCH 2/2] staging: dgap: use tty_alloc_driver instead of kcalloc

the tty_alloc_driver() can allocate memory for ttys and termios.
And also it can release allocated memory easly with using
put_tty_driver().

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 86 +++--
 1 file changed, 31 insertions(+), 55 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 01a0018..da5cba7 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -176,9 +176,15 @@ int dgnc_tty_preinit(void)
  */
 int dgnc_tty_register(struct dgnc_board *brd)
 {
-   int rc = 0;
+   int rc;
+
+   brd->serial_driver = tty_alloc_driver(brd->maxports,
+ TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_DYNAMIC_DEV |
+ TTY_DRIVER_HARDWARE_BREAK);
 
-   brd->serial_driver->magic = TTY_DRIVER_MAGIC;
+   if (IS_ERR(brd->serial_driver))
+   return PTR_ERR(brd->serial_driver);
 
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
 
@@ -186,31 +192,10 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->serial_driver->name_base = 0;
brd->serial_driver->major = 0;
brd->serial_driver->minor_start = 0;
-   brd->serial_driver->num = brd->maxports;
brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->serial_driver->subtype = SERIAL_TYPE_NORMAL;
brd->serial_driver->init_termios = DgncDefaultTermios;
brd->serial_driver->driver_name = DRVSTR;
-   brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW |
-  TTY_DRIVER_DYNAMIC_DEV |
-  TTY_DRIVER_HARDWARE_BREAK);
-
-   /*
-* The kernel wants space to store pointers to
-* tty_struct's and termios's.
-*/
-   brd->serial_driver->ttys = kcalloc(brd->maxports,
-sizeof(*brd->serial_driver->ttys),
-GFP_KERNEL);
-   if (!brd->serial_driver->ttys)
-   return -ENOMEM;
-
-   kref_init(>serial_driver->kref);
-   brd->serial_driver->termios = kcalloc(brd->maxports,
-   
sizeof(*brd->serial_driver->termios),
-   GFP_KERNEL);
-   if (!brd->serial_driver->termios)
-   return -ENOMEM;
 
/*
 * Entry points for driver.  Called by the kernel from
@@ -224,7 +209,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
if (rc < 0) {
dev_dbg(>pdev->dev,
"Can't register tty device (%d)\n", rc);
-   return rc;
+   goto free_serial_driver;
}
brd->dgnc_Major_Serial_Registered = true;
}
@@ -234,38 +219,26 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgnc_tty_open() routine.
 */
-   brd->print_driver->magic = TTY_DRIVER_MAGIC;
+   brd->print_driver = tty_alloc_driver(brd->maxports,
+TTY_DRIVER_REAL_RAW |
+TTY_DRIVER_DYNAMIC_DEV |
+TTY_DRIVER_HARDWARE_BREAK);
+
+   if (IS_ERR(brd->print_driver)) {
+   rc = PTR_ERR(brd->print_driver);
+   goto unregister_serial_driver;
+   }
+
snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
 
brd->print_driver->name = brd->PrintName;
brd->print_driver->name_base = 0;
brd->print_driver->major = brd->serial_driver->major;
brd->print_driver->minor_start = 0x80;
-   brd->print_driver->num = brd->maxports;
brd->print_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->print_driver->subtype = SERIAL_TYPE_NORMAL;
brd->print_driver->init_termios = DgncDefaultTermios;
brd->print_driver->driver_name = DRVSTR;
-   brd->print_driver->flags = (TTY_DRIVER_REAL_RAW |
- TTY_DRIVER_DYNAMIC_DEV |
- TTY_DRIVER_HARDWARE_BREAK);
-
-   /*
-* The kernel wants sp

[PATCH 1/2] staging: dgnc: use pointer type of tty_struct

2016-02-28 Thread Daeseok Youn
>From 70f8703b3bd73fa56f4ea91e98967b8925550aa6 Mon Sep 17 00:00:00 2001
From: Daeseok Youn <daeseok.y...@gmail.com>
Date: Thu, 25 Feb 2016 14:53:37 +0900
Subject: [PATCH 1/2] staging: dgnc: use pointer type of tty_struct

For using tty_alloc_driver, SerialDriver has to be pointer type.
It also has checkpatch.pl warning about Camelcase, so
SerialDriver is changed to serial_driver.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.h |   4 +-
 drivers/staging/dgnc/dgnc_tty.c| 118 ++---
 2 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index ce7cd9b..1c7a8fa 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -205,9 +205,9 @@ struct dgnc_board {
 * to our channels.
 */
 
-   struct tty_driver   SerialDriver;
+   struct tty_driver *serial_driver;
charSerialName[200];
-   struct tty_driver   PrintDriver;
+   struct tty_driver *print_driver;
charPrintName[200];
 
booldgnc_Major_Serial_Registered;
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 8b1ba65..01a0018 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -178,20 +178,20 @@ int dgnc_tty_register(struct dgnc_board *brd)
 {
int rc = 0;
 
-   brd->SerialDriver.magic = TTY_DRIVER_MAGIC;
+   brd->serial_driver->magic = TTY_DRIVER_MAGIC;
 
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
 
-   brd->SerialDriver.name = brd->SerialName;
-   brd->SerialDriver.name_base = 0;
-   brd->SerialDriver.major = 0;
-   brd->SerialDriver.minor_start = 0;
-   brd->SerialDriver.num = brd->maxports;
-   brd->SerialDriver.type = TTY_DRIVER_TYPE_SERIAL;
-   brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL;
-   brd->SerialDriver.init_termios = DgncDefaultTermios;
-   brd->SerialDriver.driver_name = DRVSTR;
-   brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW |
+   brd->serial_driver->name = brd->SerialName;
+   brd->serial_driver->name_base = 0;
+   brd->serial_driver->major = 0;
+   brd->serial_driver->minor_start = 0;
+   brd->serial_driver->num = brd->maxports;
+   brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
+   brd->serial_driver->subtype = SERIAL_TYPE_NORMAL;
+   brd->serial_driver->init_termios = DgncDefaultTermios;
+   brd->serial_driver->driver_name = DRVSTR;
+   brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW |
   TTY_DRIVER_DYNAMIC_DEV |
   TTY_DRIVER_HARDWARE_BREAK);
 
@@ -199,28 +199,28 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd->SerialDriver.ttys = kcalloc(brd->maxports,
-sizeof(*brd->SerialDriver.ttys),
+   brd->serial_driver->ttys = kcalloc(brd->maxports,
+sizeof(*brd->serial_driver->ttys),
 GFP_KERNEL);
-   if (!brd->SerialDriver.ttys)
+   if (!brd->serial_driver->ttys)
return -ENOMEM;
 
-   kref_init(>SerialDriver.kref);
-   brd->SerialDriver.termios = kcalloc(brd->maxports,
-   sizeof(*brd->SerialDriver.termios),
+   kref_init(>serial_driver->kref);
+   brd->serial_driver->termios = kcalloc(brd->maxports,
+   
sizeof(*brd->serial_driver->termios),
GFP_KERNEL);
-   if (!brd->SerialDriver.termios)
+   if (!brd->serial_driver->termios)
return -ENOMEM;
 
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
 */
-   tty_set_operations(>SerialDriver, _tty_ops);
+   tty_set_operations(brd->serial_driver, _tty_ops);
 
if (!brd->dgnc_Major_Serial_Registered) {
/* Register tty devices */
-   rc = tty_register_driver(>SerialDriver);
+   rc = tty_register_driver(brd->serial_driver);
if (rc < 0) {
dev_dbg(>pdev->dev,
"Can't register tty device (%d)\n", rc);
@@ -234,19 +234,19 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * again, separately so we don

[PATCH] staging: dgap: fix if statement that always evaluates to true

2015-01-23 Thread Daeseok Youn
cppcheck warning:
(warnning) Logical disjunction always evaluates to true

Reported-by: David Binderman dcb...@hotmail.com
Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 518ab56..7184747 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -978,8 +978,8 @@ static int dgap_parsefile(char **in)
brd-u.board.conc1++;
 
conc_type = dgap_gettok(in);
-   if (conc_type == 0 || conc_type != CX ||
-   conc_type != EPC) {
+   if (conc_type == 0 || (conc_type != CX 
+   conc_type != EPC)) {
pr_err(failed to set a type of concentratros);
return -1;
}
@@ -1019,8 +1019,8 @@ static int dgap_parsefile(char **in)
brd-u.board.module1++;
 
module_type = dgap_gettok(in);
-   if (module_type == 0 || module_type != PORTS ||
-   module_type != MODEM) {
+   if (module_type == 0 || (module_type != PORTS 
+   module_type != MODEM)) {
pr_err(failed to set a type of module);
return -1;
}
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging/dgap/dgap.c:981: bad if test ?

2015-01-22 Thread DaeSeok Youn
Hi,

2015-01-22 19:14 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:

 On Thu, Jan 22, 2015 at 10:05:53AM +, David Binderman wrote:
 Hello there,

 [linux-3.19-rc5/drivers/staging/dgap/dgap.c:981]: (warning) Logical 
 disjunction always evaluates to true: conc_type != 65 || conc_type != 66.

 Source code is

 if (conc_type == 0 || conc_type != CX ||
 conc_type != EPC) {

 Suggest code rework.

 Thanks.  This bug was introduced in:
Yes, right. I will fix this bug.

The configuration file has a type of concentrator and that type has
two different modules that are ccon and epc.
If configuration file has another type for concentrator, returns
-1 but it always return an error.

Thanks for reporting.

regards,
Daeseok Youn.


 commit f6aa0164cd3b1c5192e87f5651ec382c3bc3abac
 Author: Daeseok Youn daeseok.y...@gmail.com
 Date:   Sat Aug 9 14:38:41 2014 +0900

 staging: dgap: Simplify to set a concentrator type

 It is same manner with setting a board type.
 For example of config file for concentrator,
 conc ccon or
 conc epcon

 After allocating a type of CNODE then set a type of concentrator.
 So remove cases in swith statement, just get a token from string
 and set to conc.type. And also it doesn't need to conc.v_type.

 Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
 Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

 Let's CC Daeseok.

 regards,
 dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgap: use gotos for handling error in dgap_remap()

2014-12-25 Thread Daeseok Youn
Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   30 +++---
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index bdb5317..518ab56 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -1400,27 +1400,27 @@ static int dgap_remap(struct board_t *brd)
return -ENOMEM;
 
if (!request_mem_region(brd-membase + PCI_IO_OFFSET, 0x20,
-   dgap)) {
-   release_mem_region(brd-membase, 0x20);
-   return -ENOMEM;
-   }
+   dgap))
+   goto err_req_mem;
 
brd-re_map_membase = ioremap(brd-membase, 0x20);
-   if (!brd-re_map_membase) {
-   release_mem_region(brd-membase, 0x20);
-   release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
-   return -ENOMEM;
-   }
+   if (!brd-re_map_membase)
+   goto err_remap_mem;
 
brd-re_map_port = ioremap((brd-membase + PCI_IO_OFFSET), 0x20);
-   if (!brd-re_map_port) {
-   release_mem_region(brd-membase, 0x20);
-   release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
-   iounmap(brd-re_map_membase);
-   return -ENOMEM;
-   }
+   if (!brd-re_map_port)
+   goto err_remap_port;
 
return 0;
+
+err_remap_port:
+   iounmap(brd-re_map_membase);
+err_remap_mem:
+   release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
+err_req_mem:
+   release_mem_region(brd-membase, 0x20);
+
+   return -ENOMEM;
 }
 
 static void dgap_unmap(struct board_t *brd)
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/4] staging: dgap: set tty's flags by tty_alloc_driver()

2014-11-06 Thread Daeseok Youn
tty's flags can be set by calling tty_alloc_driver().

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index aa393d2..6418cc5 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -5236,7 +5236,10 @@ static int dgap_tty_register(struct board_t *brd)
 {
int rc;
 
-   brd-serial_driver = tty_alloc_driver(MAXPORTS, 0);
+   brd-serial_driver = tty_alloc_driver(MAXPORTS,
+ TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_DYNAMIC_DEV |
+ TTY_DRIVER_HARDWARE_BREAK);
if (IS_ERR(brd-serial_driver))
return PTR_ERR(brd-serial_driver);
 
@@ -5250,9 +5253,6 @@ static int dgap_tty_register(struct board_t *brd)
brd-serial_driver-subtype = SERIAL_TYPE_NORMAL;
brd-serial_driver-init_termios = dgap_default_termios;
brd-serial_driver-driver_name = DRVSTR;
-   brd-serial_driver-flags = (TTY_DRIVER_REAL_RAW |
-   TTY_DRIVER_DYNAMIC_DEV |
-   TTY_DRIVER_HARDWARE_BREAK);
 
/* The kernel wants space to store pointers to tty_structs */
brd-serial_driver-ttys =
@@ -5273,7 +5273,10 @@ static int dgap_tty_register(struct board_t *brd)
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgap_tty_open() routine.
 */
-   brd-print_driver = tty_alloc_driver(MAXPORTS, 0);
+   brd-print_driver = tty_alloc_driver(MAXPORTS,
+TTY_DRIVER_REAL_RAW |
+TTY_DRIVER_DYNAMIC_DEV |
+TTY_DRIVER_HARDWARE_BREAK);
if (IS_ERR(brd-print_driver)) {
rc = PTR_ERR(brd-print_driver);
goto free_serial_drv;
@@ -5289,9 +5292,6 @@ static int dgap_tty_register(struct board_t *brd)
brd-print_driver-subtype = SERIAL_TYPE_NORMAL;
brd-print_driver-init_termios = dgap_default_termios;
brd-print_driver-driver_name = DRVSTR;
-   brd-print_driver-flags = (TTY_DRIVER_REAL_RAW |
-  TTY_DRIVER_DYNAMIC_DEV |
-  TTY_DRIVER_HARDWARE_BREAK);
 
/* The kernel wants space to store pointers to tty_structs */
brd-print_driver-ttys =
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/4] staging: dgap: fix memory leak caused by double allocation of tty_structs

2014-11-06 Thread Daeseok Youn
The tty_struct of serial_driver and print_driver were getting
allocated twice. One is allocated in tty_alloc_driver(), the other
is in dgap_tty_register(). So remove these in dgap_tty_register().

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   16 
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 6418cc5..688aaa4 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -5254,14 +5254,6 @@ static int dgap_tty_register(struct board_t *brd)
brd-serial_driver-init_termios = dgap_default_termios;
brd-serial_driver-driver_name = DRVSTR;
 
-   /* The kernel wants space to store pointers to tty_structs */
-   brd-serial_driver-ttys =
-   kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL);
-   if (!brd-serial_driver-ttys) {
-   rc = -ENOMEM;
-   goto free_serial_drv;
-   }
-
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
@@ -5293,14 +5285,6 @@ static int dgap_tty_register(struct board_t *brd)
brd-print_driver-init_termios = dgap_default_termios;
brd-print_driver-driver_name = DRVSTR;
 
-   /* The kernel wants space to store pointers to tty_structs */
-   brd-print_driver-ttys =
-   kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL);
-   if (!brd-print_driver-ttys) {
-   rc = -ENOMEM;
-   goto free_print_drv;
-   }
-
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] staging: dgap: remove useless variables for saving tty's major

2014-11-06 Thread Daeseok Youn
The board_t has a tty_struct(serial_driver and print_driver)
that has a major number. When major number is compared in
dgap_tty_open(), just use brd-serial_driver{print_driver}-major.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |9 ++---
 drivers/staging/dgap/dgap.h |3 ---
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 688aaa4..3f23e5b 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -4477,10 +4477,10 @@ static int dgap_tty_open(struct tty_struct *tty, struct 
file *file)
spin_lock_irqsave(ch-ch_lock, lock_flags2);
 
/* Figure out our type */
-   if (major == brd-dgap_serial_major) {
+   if (major == brd-serial_driver-major) {
un = brd-channels[minor]-ch_tun;
un-un_type = DGAP_SERIAL;
-   } else if (major == brd-dgap_transparent_print_major) {
+   } else if (major == brd-print_driver-major) {
un = brd-channels[minor]-ch_pun;
un-un_type = DGAP_PRINT;
} else {
@@ -5302,10 +5302,7 @@ static int dgap_tty_register(struct board_t *brd)
goto unregister_serial_drv;
 
dgap_boards_by_major[brd-serial_driver-major] = brd;
-   brd-dgap_serial_major = brd-serial_driver-major;
-
dgap_boards_by_major[brd-print_driver-major] = brd;
-   brd-dgap_transparent_print_major = brd-print_driver-major;
 
return 0;
 
@@ -6563,7 +6560,6 @@ static void dgap_cleanup_tty(struct board_t *brd)
unsigned int i;
 
dgap_boards_by_major[brd-serial_driver-major] = NULL;
-   brd-dgap_serial_major = 0;
for (i = 0; i  brd-nasync; i++) {
tty_port_destroy(brd-serial_ports[i]);
dev = brd-channels[i]-ch_tun.un_sysfs;
@@ -6575,7 +6571,6 @@ static void dgap_cleanup_tty(struct board_t *brd)
kfree(brd-serial_ports);
 
dgap_boards_by_major[brd-print_driver-major] = NULL;
-   brd-dgap_transparent_print_major = 0;
for (i = 0; i  brd-nasync; i++) {
tty_port_destroy(brd-printer_ports[i]);
dev = brd-channels[i]-ch_pun.un_sysfs;
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index 14e2ed0..6840331 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -584,9 +584,6 @@ struct board_t {
struct tty_port *printer_ports;
charprint_name[200];
 
-   u32 dgap_serial_major;
-   u32 dgap_transparent_print_major;
-
struct bs_t __iomem *bd_bs; /* Base structure pointer */
 
char*flipbuf;   /* Our flip buffer, alloced if*/
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] staging: dgap: introducing find_board_by_major()

2014-11-06 Thread Daeseok Youn
use find_board_by_major function instead of getting a brd from static
arrary. Becasue tty's major number doesn't start zero and we can
find a brd from dgap_board[].

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   28 +---
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 3f23e5b..f38354f 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -80,7 +80,6 @@ static int dgap_poll_tick = 20;   /* Poll interval - 20 
ms */
 
 static struct class *dgap_class;
 
-static struct board_t *dgap_boards_by_major[256];
 static uint dgap_count = 500;
 
 /*
@@ -4409,6 +4408,22 @@ static void dgap_tty_unthrottle(struct tty_struct *tty)
spin_unlock_irqrestore(bd-bd_lock, lock_flags);
 }
 
+static struct board_t *find_board_by_major(unsigned int major)
+{
+   unsigned int i;
+
+   for (i = 0; i  MAXBOARDS; i++) {
+   struct board_t *brd = dgap_board[i];
+   if (!brd)
+   return NULL;
+   if (major == brd-serial_driver-major ||
+   major == brd-print_driver-major)
+   return brd;
+   }
+
+   return NULL;
+}
+
 /
  *
  * TTY Entry points and helper functions
@@ -4435,11 +4450,7 @@ static int dgap_tty_open(struct tty_struct *tty, struct 
file *file)
major = MAJOR(tty_devnum(tty));
minor = MINOR(tty_devnum(tty));
 
-   if (major  255)
-   return -EIO;
-
-   /* Get board pointer from our array of majors we have allocated */
-   brd = dgap_boards_by_major[major];
+   brd = find_board_by_major(major);
if (!brd)
return -EIO;
 
@@ -5301,9 +5312,6 @@ static int dgap_tty_register(struct board_t *brd)
if (rc  0)
goto unregister_serial_drv;
 
-   dgap_boards_by_major[brd-serial_driver-major] = brd;
-   dgap_boards_by_major[brd-print_driver-major] = brd;
-
return 0;
 
 unregister_serial_drv:
@@ -6559,7 +6567,6 @@ static void dgap_cleanup_tty(struct board_t *brd)
struct device *dev;
unsigned int i;
 
-   dgap_boards_by_major[brd-serial_driver-major] = NULL;
for (i = 0; i  brd-nasync; i++) {
tty_port_destroy(brd-serial_ports[i]);
dev = brd-channels[i]-ch_tun.un_sysfs;
@@ -6570,7 +6577,6 @@ static void dgap_cleanup_tty(struct board_t *brd)
put_tty_driver(brd-serial_driver);
kfree(brd-serial_ports);
 
-   dgap_boards_by_major[brd-print_driver-major] = NULL;
for (i = 0; i  brd-nasync; i++) {
tty_port_destroy(brd-printer_ports[i]);
dev = brd-channels[i]-ch_pun.un_sysfs;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgap: remove unnecessary function

2014-11-05 Thread Daeseok Youn
The dgap_init_global() initialize the dgap_board
that is a global variable as static and dgap_poll_timer.
But init_timer() is called twice in dgap_start() and dgap_board
doesn't need to be initialized to NULL.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   23 ---
 1 files changed, 0 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 293dc33..aa393d2 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -7019,23 +7019,6 @@ static struct pci_driver dgap_driver = {
 };
 
 /*
- * dgap_init_globals()
- *
- * This is where we initialize the globals from the static insmod
- * configuration variables.  These are declared near the head of
- * this file.
- */
-static void dgap_init_globals(void)
-{
-   unsigned int i;
-
-   for (i = 0; i  MAXBOARDS; i++)
-   dgap_board[i] = NULL;
-
-   init_timer(dgap_poll_timer);
-}
-
-/*
  * Start of driver.
  */
 static int dgap_start(void)
@@ -7044,12 +7027,6 @@ static int dgap_start(void)
unsigned long flags;
struct device *device;
 
-   /*
-* make sure that the globals are
-* init'd before we do anything else
-*/
-   dgap_init_globals();
-
dgap_numboards = 0;
 
pr_info(For the tools package please visit http://www.digi.com\n;);
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH V2] staging: dgap: re-arrange functions for removing forward declarations

2014-10-30 Thread DaeSeok Youn
Hi,

2014-10-31 5:33 GMT+09:00 Greg KH gre...@linuxfoundation.org:
 On Thu, Oct 30, 2014 at 12:14:00PM +0900, Daeseok Youn wrote:
 Re-arrange the functions for removing forward declarations.

 Tested-by: Mark Hounschell ma...@compro.net
 Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
 Tested-by: Mark Hounschell ma...@compro.net
 ---
 V2: this patch is rebased on staging-next branch.

 Still doesn't apply :(

You maybe merge this patch to staging-testing branch, right?
I tried to rebase this patch on staging-next but staging-testing had
two patches more from Tapasweni.

I will rebase on staging-testing and send this again.

Thanks.

regards,
Daeseok Youn.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND] staging: dgap: re-arrange functions for removing forward declarations

2014-10-29 Thread DaeSeok Youn
Hi,



2014-10-29 18:22 GMT+09:00 Greg KH gre...@linuxfoundation.org:
 On Sun, Oct 26, 2014 at 11:08:54AM +0900, Daeseok Youn wrote:
 Re-arrange the functions for removing forward declarations.

 Tested-by: Mark Hounschell ma...@compro.net
 Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
 ---
 RESEND: This patch is tested all by Mark.
 It is good to merge. Greg, check please.

 It doesn't apply to my tree :(
Yes, it need to rebase as Mark's comment.

I will send this again after rebase.

Thanks.
Daeseok Youn.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgap: re-arrange functions for removing forward declarations.

2014-10-14 Thread DaeSeok Youn
Hi,

2014-10-14 11:19 GMT+09:00 Joe Perches j...@perches.com:
 On Tue, 2014-10-14 at 04:04 +0200, Greg KH wrote:
 On Mon, Oct 13, 2014 at 07:56:38AM -0700, Joe Perches wrote:
  On Mon, 2014-10-13 at 17:01 +0900, DaeSeok Youn wrote:
   2014-10-13 12:25 GMT+09:00 Greg KH gre...@linuxfoundation.org:
On Mon, Oct 13, 2014 at 11:34:25AM +0900, Daeseok Youn wrote:
Re-arrange the functions for removing forward declarations.
 []
This patch has too many changes for re-arranging the functions.
So I wonder that I should break this up into smaller patches.
Are the .o files identical before and after this patch?  If so, it's
fine.
   Ok. I will check for that.
  The .o files shouldn't be identical after function reordering.

 Hm, they might be the same size, but I can see how on some
 architectures (like ppc) how that would not be the case, you are right.

 Isn't there an objdiff program or something like that which might help
 in validating that nothing changed in the source for type of patch
 that just moves functions around in a file.

 There is a scripts/objdiff, but that is basically for whitespace
 only changes.

 I don't know of a way to compare objects when functions are
 rearranged in the source file.

 Anyone else?

I was just trying to sort objdump -d output by function name with
someone's python script.
The script was on github. url : https://gist.github.com/fritschy/1183292

And I got two results, one is before applying this patch, another is
after doing that.
These are possible to compare but it has difference of base address...

I'm not sure what should I do for applying this patch. :-(
If anyone knows how to compare, let me know.

Thanks.

Regards,
Daeseok Youn.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgap: re-arrange functions for removing forward declarations.

2014-10-13 Thread DaeSeok Youn
Hi,

2014-10-13 12:25 GMT+09:00 Greg KH gre...@linuxfoundation.org:
 On Mon, Oct 13, 2014 at 11:34:25AM +0900, Daeseok Youn wrote:
 Re-arrange the functions for removing forward declarations.

 Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
 ---
 This patch has too many changes for re-arranging the functions.
 So I wonder that I should break this up into smaller patches.

 Are the .o files identical before and after this patch?  If so, it's
 fine.
Ok. I will check for that.

Thanks.

regards,
Daeseok Youn.


 thanks,

 greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgap: re-arrange functions for removing forward declarations.

2014-10-13 Thread DaeSeok Youn
Hi,

2014-10-13 23:56 GMT+09:00 Joe Perches j...@perches.com:
 On Mon, 2014-10-13 at 17:01 +0900, DaeSeok Youn wrote:
 Hi,

 2014-10-13 12:25 GMT+09:00 Greg KH gre...@linuxfoundation.org:
  On Mon, Oct 13, 2014 at 11:34:25AM +0900, Daeseok Youn wrote:
  Re-arrange the functions for removing forward declarations.
 
  Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
  ---
  This patch has too many changes for re-arranging the functions.
  So I wonder that I should break this up into smaller patches.
 
  Are the .o files identical before and after this patch?  If so, it's
  fine.
 Ok. I will check for that.

 The .o files shouldn't be identical after function reordering.

Is it possible to sort objdump -d output by function name?
I'm not sure but it can be checked after sorting.

I think greg want to know missing functions in this patch because this
has many changes.

thanks.

regards,
Daeseok Youn.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH V2] staging: dgap: introduce dgap_stop()

2014-10-09 Thread DaeSeok Youn
Hi,

2014-10-09 19:23 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
 On Thu, Oct 09, 2014 at 03:19:03PM +0530, Sudip Mukherjee wrote:
 On Thu, Oct 09, 2014 at 01:40:11PM +0900, Daeseok Youn wrote:
  The dgap_init_module() need to unwind for cleanup variables properly.
  Because dgap_init_module() calls dgap_cleanup_module() for freeing
  variables but this function is possible to free variables
  which are not allocated.
 
  Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
  ---
  V2: change ulong which is non-standard to unsigned long.
 I think , Dan, in his review of your v1 , asked you to rearrange the 
 functions and get rid of the forward declarations.


 I was fine with v1 actually...  It's a bug fix, and this is staging and
 there are tons of forward declarations already.  Eventually we need to
 get rid of them but it can be done later.
Yes, I will cleanup as your review.

thanks.

regards,
Daeseok Youn.


 regards,
 dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging: dgap: remove unnecessary if statement for checking NULL

2014-10-08 Thread Daeseok Youn
dgap_release_remap() function is only called after the memory
has been remapped so if statement for checking NULL doesn't
need.

And also release_mem_region() calls are moved after iounmap() calls.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   13 -
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index d0be1ce..a48740f 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -1013,15 +1013,10 @@ static int dgap_do_remap(struct board_t *brd)
 
 static void dgap_release_remap(struct board_t *brd)
 {
-   if (brd-re_map_membase) {
-   release_mem_region(brd-membase, 0x20);
-   iounmap(brd-re_map_membase);
-   }
-
-   if (brd-re_map_port) {
-   release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
-   iounmap(brd-re_map_port);
-   }
+   iounmap(brd-re_map_port);
+   iounmap(brd-re_map_membase);
+   release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
+   release_mem_region(brd-membase, 0x20);
 }
 /*
 *
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging: dgap: change function names properly

2014-10-08 Thread Daeseok Youn
dgap_do_remap() and dgap_release_remap() names could be
changed to dgap_remap() and dgap_unmap().

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   14 +++---
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index a48740f..7c79fe6 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -78,8 +78,8 @@ static void dgap_cleanup_board(struct board_t *brd);
 static void dgap_poll_handler(ulong dummy);
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id 
*ent);
 static void dgap_remove_one(struct pci_dev *dev);
-static int dgap_do_remap(struct board_t *brd);
-static void dgap_release_remap(struct board_t *brd);
+static int dgap_remap(struct board_t *brd);
+static void dgap_unmap(struct board_t *brd);
 static irqreturn_t dgap_intr(int irq, void *voidbrd);
 
 static int dgap_tty_open(struct tty_struct *tty, struct file *file);
@@ -621,7 +621,7 @@ free_flipbuf:
dgap_free_flipbuf(brd);
 cleanup_brd:
dgap_cleanup_nodes();
-   dgap_release_remap(brd);
+   dgap_unmap(brd);
kfree(brd);
 
return rc;
@@ -683,7 +683,7 @@ static void dgap_cleanup_board(struct board_t *brd)
 
tasklet_kill(brd-helper_tasklet);
 
-   dgap_release_remap(brd);
+   dgap_unmap(brd);
 
/* Free all allocated channels structs */
for (i = 0; i  MAXPORTS ; i++)
@@ -804,7 +804,7 @@ static struct board_t *dgap_found_board(struct pci_dev 
*pdev, int id,
tasklet_init(brd-helper_tasklet, dgap_poll_tasklet,
(unsigned long) brd);
 
-   ret = dgap_do_remap(brd);
+   ret = dgap_remap(brd);
if (ret)
goto free_brd;
 
@@ -979,7 +979,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type,
 /*
  * Remap PCI memory.
  */
-static int dgap_do_remap(struct board_t *brd)
+static int dgap_remap(struct board_t *brd)
 {
if (!brd || brd-magic != DGAP_BOARD_MAGIC)
return -EIO;
@@ -1011,7 +1011,7 @@ static int dgap_do_remap(struct board_t *brd)
return 0;
 }
 
-static void dgap_release_remap(struct board_t *brd)
+static void dgap_unmap(struct board_t *brd)
 {
iounmap(brd-re_map_port);
iounmap(brd-re_map_membase);
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging: dgap: introduce dgap_stop()

2014-10-08 Thread Daeseok Youn
The dgap_init_module() need to unwind for cleanup variables properly.
Because dgap_init_module() calls dgap_cleanup_module() for freeing
variables but this function is possible to free variables
which are not allocated.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   27 ++-
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 7c79fe6..00f34b5 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -71,6 +71,7 @@ MODULE_DESCRIPTION(Driver for the Digi International EPCA 
PCI based product lin
 MODULE_SUPPORTED_DEVICE(dgap);
 
 static int dgap_start(void);
+static void dgap_stop(void);
 static void dgap_init_globals(void);
 static struct board_t *dgap_found_board(struct pci_dev *pdev, int id,
int boardnum);
@@ -479,19 +480,20 @@ static int dgap_init_module(void)
 
rc = pci_register_driver(dgap_driver);
if (rc)
-   goto err_cleanup;
+   goto err_stop;
 
rc = dgap_create_driver_sysfiles(dgap_driver);
if (rc)
-   goto err_cleanup;
+   goto err_unregister;
 
dgap_driver_state = DRIVER_READY;
 
return 0;
 
-err_cleanup:
-
-   dgap_cleanup_module();
+err_unregister:
+   pci_unregister_driver(dgap_driver);
+err_stop:
+   dgap_stop();
 
return rc;
 }
@@ -561,6 +563,21 @@ failed_class:
return rc;
 }
 
+static void dgap_stop(void)
+{
+   ulong lock_flags;
+
+   spin_lock_irqsave(dgap_poll_lock, lock_flags);
+   dgap_poll_stop = 1;
+   spin_unlock_irqrestore(dgap_poll_lock, lock_flags);
+
+   del_timer_sync(dgap_poll_timer);
+
+   device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
+   class_destroy(dgap_class);
+   unregister_chrdev(DIGI_DGAP_MAJOR, dgap);
+}
+
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
int rc;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] staging: dgap: introduce dgap_stop()

2014-10-08 Thread DaeSeok Youn
Hi, Dan

2014-10-08 20:37 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
 All three of these patches are good and a nice improvement.  This one is
 a good bugfix.  I have some notes for later, though below.

 On Wed, Oct 08, 2014 at 08:13:56PM +0900, Daeseok Youn wrote:
 diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
 index 7c79fe6..00f34b5 100644
 --- a/drivers/staging/dgap/dgap.c
 +++ b/drivers/staging/dgap/dgap.c
 @@ -71,6 +71,7 @@ MODULE_DESCRIPTION(Driver for the Digi International EPCA 
 PCI based product lin
  MODULE_SUPPORTED_DEVICE(dgap);

  static int dgap_start(void);
 +static void dgap_stop(void);

 These kinds of forward declarations are annoying.  The whole file needs
 to be re-arranged so that we don't have to deal with them.
OK. I will try to re-arrange and remove forward declarations.


 @@ -561,6 +563,21 @@ failed_class:
   return rc;
  }

 +static void dgap_stop(void)
 +{
 + ulong lock_flags;
OK. I will send this patch again after changing ulong to unsigned long.

 This is non-standard.  Traditionally it would be:

 unsigned long flags;

 regards,
 dan carpenter

Thanks

regards,
Daeseok Youn

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2] staging: dgap: introduce dgap_stop()

2014-10-08 Thread Daeseok Youn
The dgap_init_module() need to unwind for cleanup variables properly.
Because dgap_init_module() calls dgap_cleanup_module() for freeing
variables but this function is possible to free variables
which are not allocated.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
V2: change ulong which is non-standard to unsigned long.

 drivers/staging/dgap/dgap.c |   27 ++-
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 7c79fe6..290ca3b 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -71,6 +71,7 @@ MODULE_DESCRIPTION(Driver for the Digi International EPCA 
PCI based product lin
 MODULE_SUPPORTED_DEVICE(dgap);
 
 static int dgap_start(void);
+static void dgap_stop(void);
 static void dgap_init_globals(void);
 static struct board_t *dgap_found_board(struct pci_dev *pdev, int id,
int boardnum);
@@ -479,19 +480,20 @@ static int dgap_init_module(void)
 
rc = pci_register_driver(dgap_driver);
if (rc)
-   goto err_cleanup;
+   goto err_stop;
 
rc = dgap_create_driver_sysfiles(dgap_driver);
if (rc)
-   goto err_cleanup;
+   goto err_unregister;
 
dgap_driver_state = DRIVER_READY;
 
return 0;
 
-err_cleanup:
-
-   dgap_cleanup_module();
+err_unregister:
+   pci_unregister_driver(dgap_driver);
+err_stop:
+   dgap_stop();
 
return rc;
 }
@@ -561,6 +563,21 @@ failed_class:
return rc;
 }
 
+static void dgap_stop(void)
+{
+   unsigned long lock_flags;
+
+   spin_lock_irqsave(dgap_poll_lock, lock_flags);
+   dgap_poll_stop = 1;
+   spin_unlock_irqrestore(dgap_poll_lock, lock_flags);
+
+   del_timer_sync(dgap_poll_timer);
+
+   device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
+   class_destroy(dgap_class);
+   unregister_chrdev(DIGI_DGAP_MAJOR, dgap);
+}
+
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
int rc;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] staging: dgap: use dgap_release_remap() in dgap_cleanup_board()

2014-09-25 Thread DaeSeok Youn
2014-09-25 16:50 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
 On Thu, Sep 25, 2014 at 09:26:47AM +0900, DaeSeok Youn wrote:
 Hi,

 2014-09-24 18:45 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
  On Tue, Sep 23, 2014 at 09:22:36AM +0900, Daeseok Youn wrote:
   static void dgap_release_remap(struct board_t *brd)
   {
  - release_mem_region(brd-membase, 0x20);
  - release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
  - iounmap(brd-re_map_membase);
  - iounmap(brd-re_map_port);
  + if (brd-re_map_membase) {
 
  I hate this if conditions.  Let's not complicate dgap_release_remap(),
  let's fix the callers instead.  Especially dgap_init_module() is a
  totally sucky function with bad unwinding.
 ok. then,
if (brd-re_map_membase  brd-re_map_port)
 dgap_release_remap(brd);

 right?

 What I'm saying is there should be no if statement because we should
 only call this function after the memory has been remapped so there
 should be no if conditions in this function at all.
OK. I got this. remove if statement in dgap_release_remap().


 The problem is that dgap_init_module() doesn't unwind, it just tries to
 free every variable without considering whether or not it was allocated.
 It's the One Err approach to error handling where you just have one
 error label that calls free on every single thing in the world.  It
 *should* look more like this:

 static int dgap_init_module(void)
 {
 int rc;

 pr_info(%s, Digi International Part Number %s\n, DG_NAME, DG_PART);

 rc = dgap_start();
 if (rc)
 return rc;

 rc = pci_register_driver(dgap_driver);
 if (rc)
 goto err_stop;

 rc = dgap_create_driver_sysfiles(dgap_driver);
 if (rc)
 goto err_unregister;

 dgap_driver_state = DRIVER_READY;

 return 0;

 err_unregister:   // - note that the label names reflect where the label
   //is not where the goto is.  dgap_start() uses
   //wrong/confusing label names.
 pci_unregister_driver(dgap_driver);
 err_stop:
 dgap_stop();  // - mirror image of dgap_start();

 return rc;
 }

 dgap_stop() is easy to write because it's based on the error handling
 in dgap_start().

 static void dgap_start(void)
 {
 spin_lock_irqsave(dgap_poll_lock, lock_flags);
 dgap_poll_stop = 1;
 spin_unlock_irqrestore(dgap_poll_lock, lock_flags);

 del_timer_sync(dgap_poll_timer);

 device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
 class_destroy(dgap_class);
 unregister_chrdev(DIGI_DGAP_MAJOR, dgap);
 }

 The existing dgap_init_module() free every single thing in the entire
 universe approach is buggy because it tries to delete the sysfs files
 before they have been allocated.  This is called a One Err Bug because
 having just one error label makes the code too complicated for anyone to
 understand.  You have to add all kinds of if conditions everywhere and
 it's a mess.
thanks for kind explanation.

I will send patches as your comments.

regards,
Daeseok Youn.

 regards,
 dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] staging: dgap: adds missing iounmap for re_map_port in dgap_release_remap()

2014-09-24 Thread DaeSeok Youn
Hi,

2014-09-24 18:42 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
 On Wed, Sep 24, 2014 at 12:36:48PM +0300, Dan Carpenter wrote:
 On Tue, Sep 23, 2014 at 09:22:08AM +0900, Daeseok Youn wrote:
  Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
  ---
   drivers/staging/dgap/dgap.c |1 +
   1 files changed, 1 insertions(+), 0 deletions(-)
 
  diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
  index 779d144..637ea8a 100644
  --- a/drivers/staging/dgap/dgap.c
  +++ b/drivers/staging/dgap/dgap.c
  @@ -1026,6 +1026,7 @@ static void dgap_release_remap(struct board_t *brd)
  release_mem_region(brd-membase, 0x20);
  release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
  iounmap(brd-re_map_membase);
  +   iounmap(brd-re_map_port);


 I don't think it matters, but at least aesthetically it would be better
 to unmap first and then release the regions.  (You can do this in a
 different patch).
Ok. I will make another patch as your comment.


 Also dgap_do_remap() unwinds in the wrong order and is sucky.  It should
 use gotos.

 Also the name dgap_do_remap() isn't great.  Remap is a verb not a noun
 so the _do isn't needed.  Just dgap_remap() and dgap_release_remap()
 could be changed to dgap_unmap().
OK. rename those functions.

Thanks.

regards,
Daeseok Youn.

 regards,
 dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] staging: dgap: use dgap_release_remap() in dgap_cleanup_board()

2014-09-24 Thread DaeSeok Youn
Hi,

2014-09-24 18:45 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
 On Tue, Sep 23, 2014 at 09:22:36AM +0900, Daeseok Youn wrote:
  static void dgap_release_remap(struct board_t *brd)
  {
 - release_mem_region(brd-membase, 0x20);
 - release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
 - iounmap(brd-re_map_membase);
 - iounmap(brd-re_map_port);
 + if (brd-re_map_membase) {

 I hate this if conditions.  Let's not complicate dgap_release_remap(),
 let's fix the callers instead.  Especially dgap_init_module() is a
 totally sucky function with bad unwinding.
ok. then,
   if (brd-re_map_membase  brd-re_map_port)
dgap_release_remap(brd);

right?

 Let's not apply this patch.
oh.. this patch was already applied to staging tree.
I will make different patch for this.

thanks.

regards,
Daeseok Youn.

 regards,
 dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging: dgap: remove unused 'runwait' variable

2014-09-22 Thread Daeseok Youn
Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |1 -
 drivers/staging/dgap/dgap.h |1 -
 2 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index db8ccd1..779d144 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -742,7 +742,6 @@ static struct board_t *dgap_found_board(struct pci_dev 
*pdev, int id,
 
spin_lock_init(brd-bd_lock);
 
-   brd-runwait= 0;
brd-inhibit_poller = FALSE;
brd-wait_for_bios  = 0;
brd-wait_for_fep   = 0;
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index ba05c65..14e2ed0 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -572,7 +572,6 @@ struct board_t {
u8 __iomem  *re_map_port;   /* Remapped io port of the card */
u8 __iomem  *re_map_membase;/* Remapped memory of the card */
 
-   u8  runwait;/* # Processes waiting for FEP  */
u8  inhibit_poller; /* Tells the poller to leave us alone */
 
struct channel_t *channels[MAXPORTS]; /* array of pointers to our */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging: dgap: use dgap_release_remap() in dgap_cleanup_board()

2014-09-22 Thread Daeseok Youn
Just simply use dgap_release_remap() in dgap_cleanup_board() for
releasing map memory.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   25 ++---
 1 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 637ea8a..d0be1ce 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -683,17 +683,7 @@ static void dgap_cleanup_board(struct board_t *brd)
 
tasklet_kill(brd-helper_tasklet);
 
-   if (brd-re_map_port) {
-   release_mem_region(brd-membase + 0x20, 0x20);
-   iounmap(brd-re_map_port);
-   brd-re_map_port = NULL;
-   }
-
-   if (brd-re_map_membase) {
-   release_mem_region(brd-membase, 0x20);
-   iounmap(brd-re_map_membase);
-   brd-re_map_membase = NULL;
-   }
+   dgap_release_remap(brd);
 
/* Free all allocated channels structs */
for (i = 0; i  MAXPORTS ; i++)
@@ -1023,10 +1013,15 @@ static int dgap_do_remap(struct board_t *brd)
 
 static void dgap_release_remap(struct board_t *brd)
 {
-   release_mem_region(brd-membase, 0x20);
-   release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
-   iounmap(brd-re_map_membase);
-   iounmap(brd-re_map_port);
+   if (brd-re_map_membase) {
+   release_mem_region(brd-membase, 0x20);
+   iounmap(brd-re_map_membase);
+   }
+
+   if (brd-re_map_port) {
+   release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
+   iounmap(brd-re_map_port);
+   }
 }
 /*
 *
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging: dgap: adds missing iounmap for re_map_port in dgap_release_remap()

2014-09-22 Thread Daeseok Youn
Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 779d144..637ea8a 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -1026,6 +1026,7 @@ static void dgap_release_remap(struct board_t *brd)
release_mem_region(brd-membase, 0x20);
release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
iounmap(brd-re_map_membase);
+   iounmap(brd-re_map_port);
 }
 /*
 *
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgap: use schedule_timeout_interruptible() instead of dgap_ms_sleep()

2014-09-16 Thread DaeSeok Youn
Hi,

2014-09-16 15:31 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:

 On Tue, Sep 16, 2014 at 12:33:33PM +0900, Daeseok Youn wrote:
  @@ -2297,12 +2273,12 @@ static void dgap_tty_close(struct tty_struct *tty, 
  struct file *file)
 * Go to sleep to ensure RTS/DTR
 * have been dropped for modems to see it.
 */
  - if (ch-ch_close_delay) {
  - spin_unlock_irqrestore(ch-ch_lock,
  -lock_flags);
  - dgap_ms_sleep(ch-ch_close_delay);
  - spin_lock_irqsave(ch-ch_lock, lock_flags);
  - }
  + spin_unlock_irqrestore(ch-ch_lock,
  + lock_flags);
  + /* .25 second delay for dropping RTS/DTR */
  + schedule_timeout_interruptible(msecs_to_jiffies(250));
  + signal_pending(current);

 There is no point in calling signal_pending() if you don't care about
 the return value.
Yes, you're right.
Originally it didn't have any handling of the return value from
signal_pending().
So, I will re-send this patch after removing signal_pending().

Thanks.

regards,
Daeseok Youn

  + spin_lock_irqsave(ch-ch_lock, lock_flags);
}
 

 regards,
 dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2] staging: dgap: use schedule_timeout_interruptible() instead of dgap_ms_sleep()

2014-09-16 Thread Daeseok Youn
Using schedule_timeout_interruptible() is exactly same as
setting a status of current process and calling  schedule_timeout().

Removes dgap_ms_sleep(), because this function is used
only when closing tty channel on dgap_tty_close().
And also removes ch_close_delay that is always set to 250
on dgap_tty_init().

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
V2: remove singal_pending().

 drivers/staging/dgap/dgap.c |   37 +++--
 drivers/staging/dgap/dgap.h |3 ---
 2 files changed, 7 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 67da1d5..db8ccd1 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -180,7 +180,6 @@ static char *dgap_create_config_string(struct board_t *bd, 
char *string);
 static uint dgap_config_get_useintr(struct board_t *bd);
 static uint dgap_config_get_altpin(struct board_t *bd);
 
-static int dgap_ms_sleep(ulong ms);
 static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len);
 static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len);
 #ifdef DIGI_CONCENTRATORS_SUPPORTED
@@ -1200,26 +1199,6 @@ static void dgap_init_globals(void)
 
 /
  *
- * Utility functions
- *
- /
-
-/*
- * dgap_ms_sleep()
- *
- * Put the driver to sleep for x ms's
- *
- * Returns 0 if timed out, !0 (showing signal) if interrupted by a signal.
- */
-static int dgap_ms_sleep(ulong ms)
-{
-   current-state = TASK_INTERRUPTIBLE;
-   schedule_timeout((ms * HZ) / 1000);
-   return signal_pending(current);
-}
-
-/
- *
  * TTY Initialization/Cleanup Functions
  *
  /
@@ -1462,9 +1441,6 @@ static int dgap_tty_init(struct board_t *brd)
ch-ch_tstart = 0;
ch-ch_rstart = 0;
 
-   /* .25 second delay */
-   ch-ch_close_delay = 250;
-
/*
 * Set queue water marks, interrupt mask,
 * and general tty parameters.
@@ -2297,12 +2273,13 @@ static void dgap_tty_close(struct tty_struct *tty, 
struct file *file)
 * Go to sleep to ensure RTS/DTR
 * have been dropped for modems to see it.
 */
-   if (ch-ch_close_delay) {
-   spin_unlock_irqrestore(ch-ch_lock,
-  lock_flags);
-   dgap_ms_sleep(ch-ch_close_delay);
-   spin_lock_irqsave(ch-ch_lock, lock_flags);
-   }
+   spin_unlock_irqrestore(ch-ch_lock,
+   lock_flags);
+
+   /* .25 second delay for dropping RTS/DTR */
+   schedule_timeout_interruptible(msecs_to_jiffies(250));
+
+   spin_lock_irqsave(ch-ch_lock, lock_flags);
}
 
ch-pscan_state = 0;
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index a0307b9..ba05c65 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -982,9 +982,6 @@ struct channel_t {
u32 ch_open_count;  /* open count   */
u32 ch_flags;   /* Channel flags*/
 
-   u32 ch_close_delay; /* How long we should drop  */
-   /* RTS/DTR for  */
-
u32 ch_cpstime; /* Time for CPS calculations*/
 
tcflag_t ch_c_iflag;/* channel iflags   */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgap: use schedule_timeout_interruptible() instead of dgap_ms_sleep()

2014-09-15 Thread Daeseok Youn
Using schedule_timeout_interruptible() is exactly same as
setting a status of current process and calling  schedule_timeout().

Removes dgap_ms_sleep(), because this function is used
only when closing tty channel on dgap_tty_close().
And also removes ch_close_delay that is always set to 250
on dgap_tty_init().

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   36 ++--
 drivers/staging/dgap/dgap.h |3 ---
 2 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 67da1d5..8aff0de 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -180,7 +180,6 @@ static char *dgap_create_config_string(struct board_t *bd, 
char *string);
 static uint dgap_config_get_useintr(struct board_t *bd);
 static uint dgap_config_get_altpin(struct board_t *bd);
 
-static int dgap_ms_sleep(ulong ms);
 static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len);
 static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len);
 #ifdef DIGI_CONCENTRATORS_SUPPORTED
@@ -1200,26 +1199,6 @@ static void dgap_init_globals(void)
 
 /
  *
- * Utility functions
- *
- /
-
-/*
- * dgap_ms_sleep()
- *
- * Put the driver to sleep for x ms's
- *
- * Returns 0 if timed out, !0 (showing signal) if interrupted by a signal.
- */
-static int dgap_ms_sleep(ulong ms)
-{
-   current-state = TASK_INTERRUPTIBLE;
-   schedule_timeout((ms * HZ) / 1000);
-   return signal_pending(current);
-}
-
-/
- *
  * TTY Initialization/Cleanup Functions
  *
  /
@@ -1462,9 +1441,6 @@ static int dgap_tty_init(struct board_t *brd)
ch-ch_tstart = 0;
ch-ch_rstart = 0;
 
-   /* .25 second delay */
-   ch-ch_close_delay = 250;
-
/*
 * Set queue water marks, interrupt mask,
 * and general tty parameters.
@@ -2297,12 +2273,12 @@ static void dgap_tty_close(struct tty_struct *tty, 
struct file *file)
 * Go to sleep to ensure RTS/DTR
 * have been dropped for modems to see it.
 */
-   if (ch-ch_close_delay) {
-   spin_unlock_irqrestore(ch-ch_lock,
-  lock_flags);
-   dgap_ms_sleep(ch-ch_close_delay);
-   spin_lock_irqsave(ch-ch_lock, lock_flags);
-   }
+   spin_unlock_irqrestore(ch-ch_lock,
+   lock_flags);
+   /* .25 second delay for dropping RTS/DTR */
+   schedule_timeout_interruptible(msecs_to_jiffies(250));
+   signal_pending(current);
+   spin_lock_irqsave(ch-ch_lock, lock_flags);
}
 
ch-pscan_state = 0;
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index a0307b9..ba05c65 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -982,9 +982,6 @@ struct channel_t {
u32 ch_open_count;  /* open count   */
u32 ch_flags;   /* Channel flags*/
 
-   u32 ch_close_delay; /* How long we should drop  */
-   /* RTS/DTR for  */
-
u32 ch_cpstime; /* Time for CPS calculations*/
 
tcflag_t ch_c_iflag;/* channel iflags   */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: dgap: remove redundant setting a variable

2014-08-18 Thread Daeseok Youn
The brd(board_t) is initialized with zero, so intr_used
is not needed to set zero when request_irq() is failed.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |7 +--
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 45f20b4..ff95376 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -846,14 +846,9 @@ static int dgap_request_irq(struct board_t *brd)
 
rc = request_irq(brd-irq, dgap_intr, IRQF_SHARED, DGAP, brd);
 
-   if (rc)
-   brd-intr_used = 0;
-   else
+   if (!rc)
brd-intr_used = 1;
-   } else {
-   brd-intr_used = 0;
}
-
return 0;
 }
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: dgap: remove useless a variable within board_t

2014-08-18 Thread Daeseok Youn
The use_interrupts is used only in dagp_request_irq() for checking
a value from user config file. It doesn't need in board_t struct.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |4 +---
 drivers/staging/dgap/dgap.h |1 -
 2 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index ff95376..8929dbf 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -837,12 +837,10 @@ static int dgap_request_irq(struct board_t *brd)
if (!brd || brd-magic != DGAP_BOARD_MAGIC)
return -ENODEV;
 
-   brd-use_interrupts = dgap_config_get_useintr(brd);
-
/*
 * Set up our interrupt handler if we are set to do interrupts.
 */
-   if (brd-use_interrupts  brd-irq) {
+   if (dgap_config_get_useintr(brd)  brd-irq) {
 
rc = request_irq(brd-irq, dgap_intr, IRQF_SHARED, DGAP, brd);
 
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index 52e1d64..a0307b9 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -558,7 +558,6 @@ struct board_t {
 
u16 nasync; /* Number of ports on card */
 
-   u32 use_interrupts; /* Should we be interrupt driven? */
ulong   irq;/* Interrupt request number */
ulong   intr_count; /* Count of interrupts */
u32 intr_used;  /* Non-zero if using interrupts */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/7 V2] staging: dgap: remove useless variable

2014-08-12 Thread Daeseok Youn
dgap_major_serial_registered and dgap_major_transparent_print_registered
could be checked whether a board is initialized.
But it doesn't need to check that variables becasue dgap_board
as global is managed for boards which are initialized completely.
So when it called dgap_cleanup_tty() function, various allocated
variables in a board will free properly.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
V2: update change log.

 drivers/staging/dgap/dgap.c |   48 +-
 drivers/staging/dgap/dgap.h |3 --
 2 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index ac12e99..55c06c9 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -1320,11 +1320,9 @@ static int dgap_tty_register(struct board_t *brd)
if (rc  0)
goto unregister_serial_drv;
 
-   brd-dgap_major_serial_registered = TRUE;
dgap_boards_by_major[brd-serial_driver-major] = brd;
brd-dgap_serial_major = brd-serial_driver-major;
 
-   brd-dgap_major_transparent_print_registered = TRUE;
dgap_boards_by_major[brd-print_driver-major] = brd;
brd-dgap_transparent_print_major = brd-print_driver-major;
 
@@ -1544,35 +1542,29 @@ static void dgap_cleanup_tty(struct board_t *brd)
struct device *dev;
int i;
 
-   if (brd-dgap_major_serial_registered) {
-   dgap_boards_by_major[brd-serial_driver-major] = NULL;
-   brd-dgap_serial_major = 0;
-   for (i = 0; i  brd-nasync; i++) {
-   tty_port_destroy(brd-serial_ports[i]);
-   dev = brd-channels[i]-ch_tun.un_sysfs;
-   dgap_remove_tty_sysfs(dev);
-   tty_unregister_device(brd-serial_driver, i);
-   }
-   tty_unregister_driver(brd-serial_driver);
-   put_tty_driver(brd-serial_driver);
-   kfree(brd-serial_ports);
-   brd-dgap_major_serial_registered = FALSE;
-   }
-
-   if (brd-dgap_major_transparent_print_registered) {
-   dgap_boards_by_major[brd-print_driver-major] = NULL;
-   brd-dgap_transparent_print_major = 0;
-   for (i = 0; i  brd-nasync; i++) {
-   tty_port_destroy(brd-printer_ports[i]);
-   dev = brd-channels[i]-ch_pun.un_sysfs;
-   dgap_remove_tty_sysfs(dev);
-   tty_unregister_device(brd-print_driver, i);
-   }
-   tty_unregister_driver(brd-print_driver);
-   put_tty_driver(brd-print_driver);
-   kfree(brd-printer_ports);
-   brd-dgap_major_transparent_print_registered = FALSE;
+   dgap_boards_by_major[brd-serial_driver-major] = NULL;
+   brd-dgap_serial_major = 0;
+   for (i = 0; i  brd-nasync; i++) {
+   tty_port_destroy(brd-serial_ports[i]);
+   dev = brd-channels[i]-ch_tun.un_sysfs;
+   dgap_remove_tty_sysfs(dev);
+   tty_unregister_device(brd-serial_driver, i);
+   }
+   tty_unregister_driver(brd-serial_driver);
+   put_tty_driver(brd-serial_driver);
+   kfree(brd-serial_ports);
+
+   dgap_boards_by_major[brd-print_driver-major] = NULL;
+   brd-dgap_transparent_print_major = 0;
+   for (i = 0; i  brd-nasync; i++) {
+   tty_port_destroy(brd-printer_ports[i]);
+   dev = brd-channels[i]-ch_pun.un_sysfs;
+   dgap_remove_tty_sysfs(dev);
+   tty_unregister_device(brd-print_driver, i);
}
+   tty_unregister_driver(brd-print_driver);
+   put_tty_driver(brd-print_driver);
+   kfree(brd-printer_ports);
 }
 
 /*===
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index 9728d59..0482a4c 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -586,9 +586,6 @@ struct board_t {
struct tty_port *printer_ports;
charprint_name[200];
 
-   u32 dgap_major_serial_registered;
-   u32 dgap_major_transparent_print_registered;
-
u32 dgap_serial_major;
u32 dgap_transparent_print_major;
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/7] staging: dgap: remove useless variable

2014-08-11 Thread DaeSeok Youn
Hi, Dan

2014-08-11 19:56 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
 On Sat, Aug 09, 2014 at 02:36:44PM +0900, Daeseok Youn wrote:
 dgap_major_serial_registered and dgap_major_transparent_print_registered
 could be checked whether a board is initialized.
 But it doesn't need to check that variables becasue dgap module
 isn't calling the dgap_cleanup_tty() without initializing
 for a board completely.

 I don't understand.  What about the call to dgap_cleanup_module() in
 dgap_init_module()?
I think the call of dgap_cleanup_tty()
in dgap_cleanup_module() from dgap_init_module() is not reached.
Because dgap_init_module() is called when driver is loaded, at this
point of time,
there are no boards that are initialized.(dgap_numboards is zero)

And the change log of this is needed to modify for clearing message.

Thanks.

regards,
Daeseok Youn.

 regards,
 dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/7] staging: dgap: remove redundant declarations.

2014-08-08 Thread Daeseok Youn
These are already defined in dgap.h.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 55c06c9..b1253c0 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -158,12 +158,6 @@ static void dgap_err(char *s);
 /*
  * Function prototypes from dgap_sysfs.h
  */
-struct board_t;
-struct channel_t;
-struct un_t;
-struct pci_driver;
-struct class_device;
-
 static void dgap_create_ports_sysfiles(struct board_t *bd);
 static void dgap_remove_ports_sysfiles(struct board_t *bd);
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/7] staging: dgap: remove useless variable

2014-08-08 Thread Daeseok Youn
dgap_major_serial_registered and dgap_major_transparent_print_registered
could be checked whether a board is initialized.
But it doesn't need to check that variables becasue dgap module
isn't calling the dgap_cleanup_tty() without initializing
for a board completely.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   48 +-
 drivers/staging/dgap/dgap.h |3 --
 2 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index ac12e99..55c06c9 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -1320,11 +1320,9 @@ static int dgap_tty_register(struct board_t *brd)
if (rc  0)
goto unregister_serial_drv;
 
-   brd-dgap_major_serial_registered = TRUE;
dgap_boards_by_major[brd-serial_driver-major] = brd;
brd-dgap_serial_major = brd-serial_driver-major;
 
-   brd-dgap_major_transparent_print_registered = TRUE;
dgap_boards_by_major[brd-print_driver-major] = brd;
brd-dgap_transparent_print_major = brd-print_driver-major;
 
@@ -1544,35 +1542,29 @@ static void dgap_cleanup_tty(struct board_t *brd)
struct device *dev;
int i;
 
-   if (brd-dgap_major_serial_registered) {
-   dgap_boards_by_major[brd-serial_driver-major] = NULL;
-   brd-dgap_serial_major = 0;
-   for (i = 0; i  brd-nasync; i++) {
-   tty_port_destroy(brd-serial_ports[i]);
-   dev = brd-channels[i]-ch_tun.un_sysfs;
-   dgap_remove_tty_sysfs(dev);
-   tty_unregister_device(brd-serial_driver, i);
-   }
-   tty_unregister_driver(brd-serial_driver);
-   put_tty_driver(brd-serial_driver);
-   kfree(brd-serial_ports);
-   brd-dgap_major_serial_registered = FALSE;
-   }
-
-   if (brd-dgap_major_transparent_print_registered) {
-   dgap_boards_by_major[brd-print_driver-major] = NULL;
-   brd-dgap_transparent_print_major = 0;
-   for (i = 0; i  brd-nasync; i++) {
-   tty_port_destroy(brd-printer_ports[i]);
-   dev = brd-channels[i]-ch_pun.un_sysfs;
-   dgap_remove_tty_sysfs(dev);
-   tty_unregister_device(brd-print_driver, i);
-   }
-   tty_unregister_driver(brd-print_driver);
-   put_tty_driver(brd-print_driver);
-   kfree(brd-printer_ports);
-   brd-dgap_major_transparent_print_registered = FALSE;
+   dgap_boards_by_major[brd-serial_driver-major] = NULL;
+   brd-dgap_serial_major = 0;
+   for (i = 0; i  brd-nasync; i++) {
+   tty_port_destroy(brd-serial_ports[i]);
+   dev = brd-channels[i]-ch_tun.un_sysfs;
+   dgap_remove_tty_sysfs(dev);
+   tty_unregister_device(brd-serial_driver, i);
+   }
+   tty_unregister_driver(brd-serial_driver);
+   put_tty_driver(brd-serial_driver);
+   kfree(brd-serial_ports);
+
+   dgap_boards_by_major[brd-print_driver-major] = NULL;
+   brd-dgap_transparent_print_major = 0;
+   for (i = 0; i  brd-nasync; i++) {
+   tty_port_destroy(brd-printer_ports[i]);
+   dev = brd-channels[i]-ch_pun.un_sysfs;
+   dgap_remove_tty_sysfs(dev);
+   tty_unregister_device(brd-print_driver, i);
}
+   tty_unregister_driver(brd-print_driver);
+   put_tty_driver(brd-print_driver);
+   kfree(brd-printer_ports);
 }
 
 /*===
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index 9728d59..0482a4c 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -586,9 +586,6 @@ struct board_t {
struct tty_port *printer_ports;
charprint_name[200];
 
-   u32 dgap_major_serial_registered;
-   u32 dgap_major_transparent_print_registered;
-
u32 dgap_serial_major;
u32 dgap_transparent_print_major;
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/7] staging: dgap: cleanup duplicated warning message on dgap_tty_init()

2014-08-08 Thread Daeseok Youn
If true_count is not same with brd-nasync, warning messages are
printed. But it has duplicated messages within if statement.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   17 ++---
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index b1253c0..51f9ebc 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -1374,19 +1374,14 @@ static int dgap_tty_init(struct board_t *brd)
brd-nasync = brd-maxports;
 
if (true_count != brd-nasync) {
-   if ((brd-type == PPCM)  (true_count == 64)) {
-   pr_warn(dgap: %s configured for %d ports, has %d 
ports.\n,
-   brd-name, brd-nasync, true_count);
-   pr_warn(dgap: Please make SURE the EBI cable running 
from the card\n);
-   pr_warn(dgap: to each EM module is plugged into EBI 
IN!\n);
-   } else if ((brd-type == PPCM)  (true_count == 0)) {
-   pr_warn(dgap: %s configured for %d ports, has %d 
ports.\n,
-   brd-name, brd-nasync, true_count);
+   pr_warn(dgap: %s configured for %d ports, has %d ports.\n,
+   brd-name, brd-nasync, true_count);
+
+   if ((brd-type == PPCM) 
+   (true_count == 64 || true_count == 0)) {
pr_warn(dgap: Please make SURE the EBI cable running 
from the card\n);
pr_warn(dgap: to each EM module is plugged into EBI 
IN!\n);
-   } else
-   pr_warn(dgap: %s configured for %d ports, has %d 
ports.\n,
-   brd-name, brd-nasync, true_count);
+   }
 
brd-nasync = true_count;
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/7] staging: dgap: Simplify set a board type from configration file

2014-08-08 Thread Daeseok Youn
Board types need to separate normal command like IO, MEM and so on.
And the board type will come after board string in config file normally.
(If it is not, dgap_gettok returns an error with zero)
After that, set a variable of a number which is matched with specific
a board number to board.type. The dgap_gettok() returns that number so
just set to board.type and also v_type can be removed.

In case of boards of PCI type are set variables to zero. These can
be removed because p as cnode get memory from kzalloc so already
set to zero.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |  109 ++
 drivers/staging/dgap/dgap.h |1 -
 2 files changed, 16 insertions(+), 94 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 51f9ebc..7fb54d1 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -399,10 +399,7 @@ struct toklist {
char *string;
 };
 
-static struct toklist dgap_tlist[] = {
-   { BEGIN,config_begin },
-   { END,  config_end },
-   { BOARD,board },
+static struct toklist dgap_brdtype[] = {
{ PCX,  Digi_AccelePort_C/X_PCI },
{ PEPC, Digi_AccelePort_EPC/X_PCI },
{ PPCM, Digi_AccelePort_Xem_PCI },
@@ -411,6 +408,13 @@ static struct toklist dgap_tlist[] = {
{ APORT8_920P,  Digi_AccelePort_8r_920_PCI },
{ PAPORT4,  Digi_AccelePort_4r_PCI(EIA-232/RS-422) },
{ PAPORT8,  Digi_AccelePort_8r_PCI(EIA-232/RS-422) },
+   { 0, NULL }
+};
+
+static struct toklist dgap_tlist[] = {
+   { BEGIN,config_begin },
+   { END,  config_end },
+   { BOARD,board },
{ IO,   io },
{ PCIINFO,  pciinfo },
{ LINE, line },
@@ -6382,6 +6386,8 @@ static int dgap_parsefile(char **in)
}
 
for (; ;) {
+   int board_type = 0;
+
rc = dgap_gettok(in);
if (rc == 0) {
dgap_err(unexpected EOF);
@@ -6412,88 +6418,13 @@ static int dgap_parsefile(char **in)
line = conc = NULL;
brd = p;
linecnt = -1;
-   break;
-
-   case APORT2_920P:   /* AccelePort_4 */
-   if (p-type != BNODE) {
-   dgap_err(unexpected Digi_2r_920 string);
-   return -1;
-   }
-   p-u.board.type = APORT2_920P;
-   p-u.board.v_type = 1;
-   break;
 
-   case APORT4_920P:   /* AccelePort_4 */
-   if (p-type != BNODE) {
-   dgap_err(unexpected Digi_4r_920 string);
+   board_type = dgap_gettok(in);
+   if (board_type == 0)
return -1;
-   }
-   p-u.board.type = APORT4_920P;
-   p-u.board.v_type = 1;
-   break;
 
-   case APORT8_920P:   /* AccelePort_8 */
-   if (p-type != BNODE) {
-   dgap_err(unexpected Digi_8r_920 string);
-   return -1;
-   }
-   p-u.board.type = APORT8_920P;
-   p-u.board.v_type = 1;
-   break;
+   p-u.board.type = board_type;
 
-   case PAPORT4:   /* AccelePort_4 PCI */
-   if (p-type != BNODE) {
-   dgap_err(unexpected Digi_4r(PCI) string);
-   return -1;
-   }
-   p-u.board.type = PAPORT4;
-   p-u.board.v_type = 1;
-   break;
-
-   case PAPORT8:   /* AccelePort_8 PCI */
-   if (p-type != BNODE) {
-   dgap_err(unexpected Digi_8r string);
-   return -1;
-   }
-   p-u.board.type = PAPORT8;
-   p-u.board.v_type = 1;
-   break;
-
-   case PCX:   /* PCI C/X */
-   if (p-type != BNODE) {
-   dgap_err(unexpected Digi_C/X_(PCI) string);
-   return -1;
-   }
-   p-u.board.type = PCX;
-   p-u.board.v_type = 1;
-   p-u.board.conc1 = 0;
-   p-u.board.conc2 = 0;
-   p-u.board.module1 = 0;
-   p-u.board.module2 = 0;
-   break;
-
-   case PEPC:  /* PCI EPC/X */
-   if (p-type

[PATCH 5/7] staging: dgap: Simplify to set a concentrator type

2014-08-08 Thread Daeseok Youn
It is same manner with setting a board type.
For example of config file for concentrator,
conc ccon or
conc epcon

After allocating a type of CNODE then set a type of concentrator.
So remove cases in swith statement, just get a token from string
and set to conc.type. And also it doesn't need to conc.v_type.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   26 +++---
 drivers/staging/dgap/dgap.h |1 -
 2 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 7fb54d1..1d27976 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -6387,6 +6387,7 @@ static int dgap_parsefile(char **in)
 
for (; ;) {
int board_type = 0;
+   int conc_type = 0;
 
rc = dgap_gettok(in);
if (rc == 0) {
@@ -6719,24 +6720,15 @@ static int dgap_parsefile(char **in)
else
brd-u.board.conc1++;
 
-   break;
-
-   case CX:/* c/x type concentrator */
-   if (p-type != CNODE) {
-   dgap_err(cx only valid for concentrators);
+   conc_type = dgap_gettok(in);
+   if (conc_type == 0 || conc_type != CX ||
+   conc_type != EPC) {
+   dgap_err(failed to set a type of 
concentratros);
return -1;
}
-   p-u.conc.type = CX;
-   p-u.conc.v_type = 1;
-   break;
 
-   case EPC:   /* epc type concentrator */
-   if (p-type != CNODE) {
-   dgap_err(cx only valid for concentrators);
-   return -1;
-   }
-   p-u.conc.type = EPC;
-   p-u.conc.v_type = 1;
+   p-u.conc.type = conc_type;
+
break;
 
case MOD:   /* EBI module */
@@ -7200,10 +7192,6 @@ static int dgap_checknode(struct cnode *p)
return 0;
 
case CNODE:
-   if (p-u.conc.v_type == 0) {
-   dgap_err(concentrator type not specified);
-   return 1;
-   }
if (p-u.conc.v_speed == 0) {
dgap_err(concentrator line speed not specified);
return 1;
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index c01aa28..800f407 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -1206,7 +1206,6 @@ struct cnode {
char  *id;
char  *idstr;
long  start;
-   char  v_type;
char  v_connect;
char  v_speed;
char  v_nport;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/7] staging: dgap: Simplify to set a module type

2014-08-08 Thread Daeseok Youn
It is same manner with setting a board type.
After allocating a type of MNODE, get a token value
set to module.type.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |   26 +++---
 drivers/staging/dgap/dgap.h |1 -
 2 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 1d27976..a54b8d4 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -6388,6 +6388,7 @@ static int dgap_parsefile(char **in)
for (; ;) {
int board_type = 0;
int conc_type = 0;
+   int module_type = 0;
 
rc = dgap_gettok(in);
if (rc == 0) {
@@ -6762,24 +6763,15 @@ static int dgap_parsefile(char **in)
else
brd-u.board.module1++;
 
-   break;
-
-   case PORTS: /* ports type EBI module */
-   if (p-type != MNODE) {
-   dgap_err(ports only valid for EBI modules);
+   module_type = dgap_gettok(in);
+   if (module_type == 0 || module_type != PORTS ||
+   module_type != MODEM) {
+   dgap_err(failed to set a type of module);
return -1;
}
-   p-u.module.type = PORTS;
-   p-u.module.v_type = 1;
-   break;
 
-   case MODEM: /* ports type EBI module */
-   if (p-type != MNODE) {
-   dgap_err(modem only valid for modem modules);
-   return -1;
-   }
-   p-u.module.type = MODEM;
-   p-u.module.v_type = 1;
+   p-u.module.type = module_type;
+
break;
 
case CABLE:
@@ -7207,10 +7199,6 @@ static int dgap_checknode(struct cnode *p)
return 0;
 
case MNODE:
-   if (p-u.module.v_type == 0) {
-   dgap_err(EBI module type not specified);
-   return 1;
-   }
if (p-u.module.v_nport == 0) {
dgap_err(number of ports on EBI module not specified);
return 1;
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index 800f407..52e1d64 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -1219,7 +1219,6 @@ struct cnode {
char *id;
char *idstr;
long start;
-   char v_type;
char v_nport;
char v_id;
char v_start;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH V2] staging: dgap: introduce dgap_cleanup_nodes()

2014-08-04 Thread DaeSeok Youn
Hi, Mark and Greg.

Thanks for testing. :-)

Greg, is this patch possible to merge to your staging tree?
Please check for me.
patch : https://lkml.org/lkml/2014/7/31/2

Thanks.

regards,
Daeseok Youn.

2014-08-04 21:40 GMT+09:00 Mark Hounschell ma...@compro.net:
 On 07/31/2014 07:14 PM, DaeSeok Youn wrote:

 Hi, Mark

 2014-07-31 21:44 GMT+09:00 Mark Hounschell ma...@compro.net:

 On 07/31/2014 12:02 AM, Daeseok Youn wrote:


 When a configration file is parsed with dgap_parsefile(),
 makes nodes for saving configrations for board.

 Making a node will allocate node memory and strings for saving
 configrations with kstrdup().

 So these are freed when dgap is unloaded or failed to initialize.

 Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
 ---
 V2: Do not need to free for NULLNODE.

 I have been too busy to solve this issue, sorry for late.

 Mark, Can you test this patch? I try to make simple module which is
 testing dgap_parsefile() and dgap_cleanup_nodes().


 I'll be happy to, but I can't do it until Monday. I'm not where the
 hardware
 is until then.

 That's OK. :-)


 After applying this patch I am still able to load and unload the driver at
 will, and it still works for me.

 Regards
 Mark

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH V2] staging: dgap: introduce dgap_cleanup_nodes()

2014-08-04 Thread DaeSeok Youn
2014-08-05 8:38 GMT+09:00 Greg KH gre...@linuxfoundation.org:
 On Tue, Aug 05, 2014 at 08:33:16AM +0900, DaeSeok Youn wrote:
 Hi, Mark and Greg.

 Thanks for testing. :-)

 Greg, is this patch possible to merge to your staging tree?
 Please check for me.
 patch : https://lkml.org/lkml/2014/7/31/2

 It's the middle of the merge window, I can't do anything until after
 3.17-rc1 is out.  So wait until then, I'll pick up the patch at that
 point in time, it's still in my to-apply queue.

OK. I will wait until then.
Thanks.

regards,
Daeseok Youn

 thanks,

 greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH V2] staging: dgap: introduce dgap_cleanup_nodes()

2014-07-31 Thread DaeSeok Youn
Hi, Mark

2014-07-31 21:44 GMT+09:00 Mark Hounschell ma...@compro.net:
 On 07/31/2014 12:02 AM, Daeseok Youn wrote:

 When a configration file is parsed with dgap_parsefile(),
 makes nodes for saving configrations for board.

 Making a node will allocate node memory and strings for saving
 configrations with kstrdup().

 So these are freed when dgap is unloaded or failed to initialize.

 Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
 ---
 V2: Do not need to free for NULLNODE.

 I have been too busy to solve this issue, sorry for late.

 Mark, Can you test this patch? I try to make simple module which is
 testing dgap_parsefile() and dgap_cleanup_nodes().


 I'll be happy to, but I can't do it until Monday. I'm not where the hardware
 is until then.
That's OK. :-)

Thanks.
Daeseok Youn.

 Regards
 Mark

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2] staging: dgap: introduce dgap_cleanup_nodes()

2014-07-30 Thread Daeseok Youn
When a configration file is parsed with dgap_parsefile(),
makes nodes for saving configrations for board.

Making a node will allocate node memory and strings for saving
configrations with kstrdup().

So these are freed when dgap is unloaded or failed to initialize.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
V2: Do not need to free for NULLNODE.

I have been too busy to solve this issue, sorry for late.

Mark, Can you test this patch? I try to make simple module which is
testing dgap_parsefile() and dgap_cleanup_nodes().

There was a problem in freeing NULLNODE so if node is NULLNODE,
just bypass and get next one.

 drivers/staging/dgap/dgap.c |   52 +++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 06c55cb..ac12e99 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -201,6 +201,7 @@ static int dgap_test_fep(struct board_t *brd);
 static int dgap_tty_register_ports(struct board_t *brd);
 static int dgap_firmware_load(struct pci_dev *pdev, int card_type,
  struct board_t *brd);
+static void dgap_cleanup_nodes(void);
 
 static void dgap_cleanup_module(void);
 
@@ -619,6 +620,7 @@ unregister_tty:
 free_flipbuf:
dgap_free_flipbuf(brd);
 cleanup_brd:
+   dgap_cleanup_nodes();
dgap_release_remap(brd);
kfree(brd);
 
@@ -659,6 +661,8 @@ static void dgap_cleanup_module(void)
dgap_cleanup_board(dgap_board[i]);
}
 
+   dgap_cleanup_nodes();
+
if (dgap_numboards)
pci_unregister_driver(dgap_driver);
 }
@@ -6323,6 +6327,54 @@ static void dgap_remove_tty_sysfs(struct device *c)
sysfs_remove_group(c-kobj, dgap_tty_attribute_group);
 }
 
+static void dgap_cleanup_nodes(void)
+{
+   struct cnode *p;
+
+   p = dgap_head;
+
+   while (p) {
+   struct cnode *tmp = p-next;
+
+   if (p-type == NULLNODE) {
+   p = tmp;
+   continue;
+   }
+
+   switch (p-type) {
+   case BNODE:
+   kfree(p-u.board.portstr);
+   kfree(p-u.board.addrstr);
+   kfree(p-u.board.pcibusstr);
+   kfree(p-u.board.pcislotstr);
+   kfree(p-u.board.method);
+   break;
+   case CNODE:
+   kfree(p-u.conc.id);
+   kfree(p-u.conc.connect);
+   break;
+   case MNODE:
+   kfree(p-u.module.id);
+   break;
+   case TNODE:
+   kfree(p-u.ttyname);
+   break;
+   case CUNODE:
+   kfree(p-u.cuname);
+   break;
+   case LNODE:
+   kfree(p-u.line.cable);
+   break;
+   case PNODE:
+   kfree(p-u.printname);
+   break;
+   }
+
+   kfree(p-u.board.status);
+   kfree(p);
+   p = tmp;
+   }
+}
 /*
  * Parse a configuration file read into memory as a string.
  */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgap: introduce dgap_cleanup_nodes()

2014-07-17 Thread DaeSeok Youn
Hi, Mark.

Thanks for testing.

I am trying to solve this problem with config sample which is sent by you.

regards,
Daeseok Youn.

2014-07-17 22:27 GMT+09:00 Mark Hounschell ma...@compro.net:
 On 07/16/2014 09:35 PM, Daeseok Youn wrote:
 When a configration file is parsed with dgap_parsefile(),
 makes nodes for saving configrations for board.

 Making a node will allocate node memory and strings for saving
 configrations with kstrdup().

 So these are freed when dgap is unloaded or failed to initialize.

 Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
 ---
 Mark, please review this patch.
 Thanks.

   drivers/staging/dgap/dgap.c |   47 
 +++
   1 files changed, 47 insertions(+), 0 deletions(-)

 diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
 index 06c55cb..e9df2ea 100644
 --- a/drivers/staging/dgap/dgap.c
 +++ b/drivers/staging/dgap/dgap.c
 @@ -201,6 +201,7 @@ static int dgap_test_fep(struct board_t *brd);
   static int dgap_tty_register_ports(struct board_t *brd);
   static int dgap_firmware_load(struct pci_dev *pdev, int card_type,
 struct board_t *brd);
 +static void dgap_cleanup_nodes(void);

   static void dgap_cleanup_module(void);

 @@ -619,6 +620,7 @@ unregister_tty:
   free_flipbuf:
   dgap_free_flipbuf(brd);
   cleanup_brd:
 + dgap_cleanup_nodes();
   dgap_release_remap(brd);
   kfree(brd);

 @@ -659,6 +661,8 @@ static void dgap_cleanup_module(void)
   dgap_cleanup_board(dgap_board[i]);
   }

 + dgap_cleanup_nodes();
 +
   if (dgap_numboards)
   pci_unregister_driver(dgap_driver);
   }
 @@ -6323,6 +6327,49 @@ static void dgap_remove_tty_sysfs(struct device *c)
   sysfs_remove_group(c-kobj, dgap_tty_attribute_group);
   }

 +static void dgap_cleanup_nodes(void)
 +{
 + struct cnode *p;
 +
 + p = dgap_head;
 +
 + while (p) {
 + struct cnode *tmp = p-next;
 +
 + switch (p-type) {
 + case BNODE:
 + kfree(p-u.board.portstr);
 + kfree(p-u.board.addrstr);
 + kfree(p-u.board.pcibusstr);
 + kfree(p-u.board.pcislotstr);
 + kfree(p-u.board.method);
 + break;
 + case CNODE:
 + kfree(p-u.conc.id);
 + kfree(p-u.conc.connect);
 + break;
 + case MNODE:
 + kfree(p-u.module.id);
 + break;
 + case TNODE:
 + kfree(p-u.ttyname);
 + break;
 + case CUNODE:
 + kfree(p-u.cuname);
 + break;
 + case LNODE:
 + kfree(p-u.line.cable);
 + break;
 + case PNODE:
 + kfree(p-u.printname);
 + break;
 + }
 +
 + kfree(p-u.board.status);
 + kfree(p);
 + p = tmp;
 + }
 +}
   /*
* Parse a configuration file read into memory as a string.
*/


 I get a kernel oops when unloading the driver with this patch.

 2014-07-17T09:22:12.666987-04:00 harley kernel: [60216.979134] task: 
 8801037846b0 ti: 880149256000 task.ti: 880149256000
 2014-07-17T09:22:12.666988-04:00 harley kernel: [60216.979136] RIP: 
 0010:[8034d5ff]  [8034d5ff] kfree+0x17f/0x190
 2014-07-17T09:22:12.666989-04:00 harley kernel: [60216.979143] RSP: 
 0018:880149257e78  EFLAGS: 00010246
 2014-07-17T09:22:12.666991-04:00 harley kernel: [60216.979144] RAX: 
 40080068 RBX: a0428d20 RCX: 038eb895
 2014-07-17T09:22:12.666992-04:00 harley kernel: [60216.979146] RDX: 
 40080068 RSI: ea0004131e00 RDI: a0428d20
 2014-07-17T09:22:12.666993-04:00 harley kernel: [60216.979147] RBP: 
 880149257e90 R08: 00015b60 R09: 88014fd55b60
 2014-07-17T09:22:12.666994-04:00 harley kernel: [60216.979149] R10: 
 ea810a00 R11: a0424ffd R12: 88005a3d2a80
 2014-07-17T09:22:12.666995-04:00 harley kernel: [60216.979150] R13: 
 a041c155 R14: 0002 R15: 0bc0
 2014-07-17T09:22:12.666996-04:00 harley kernel: [60216.979152] FS:  
 7fb7d51d2700() GS:88014fd4() knlGS:
 2014-07-17T09:22:12.666997-04:00 harley kernel: [60216.979154] CS:  0010 DS: 
  ES:  CR0: 8005003b
 2014-07-17T09:22:12.666998-04:00 harley kernel: [60216.979155] CR2: 
 7fe66ee4e000 CR3: 0001497af000 CR4: 000407e0
 2014-07-17T09:22:12.666999-04:00 harley kernel: [60216.979156] Stack:
 2014-07-17T09:22:12.667000-04:00 harley kernel: [60216.979157]  
 a0428d20 88005a3d2a80 8801259dd330 880149257eb0
 2014-07-17T09:22:12.667001-04:00 harley kernel: [60216.979161]  
 a041c155 0700 8801259dd000

Re: [PATCH 6/8 V2] staging: dgap: remove unneeded dgap_err()

2014-07-16 Thread DaeSeok Youn
2014-07-16 8:50 GMT+09:00 Greg KH gre...@linuxfoundation.org:
 On Wed, Jul 16, 2014 at 08:21:30AM +0900, DaeSeok Youn wrote:
 Hi,

 2014-07-16 0:29 GMT+09:00 Greg KH gre...@linuxfoundation.org:
  On Tue, Jul 15, 2014 at 06:11:44PM +0900, Daeseok Youn wrote:
  The dgap_err() is printing a message with pr_err(),
  so all those are replaced.
 
  Use definition pr_fmt and then all of dgap: in
  the beginning of print messages are removed.
 
  And also removed out of memory message because
  the kernel has own message for that.
 
  Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
  ---
  V2: use pr_fmt dgap: prefix on print message on dgap.
  remove out of memory message.
 
  Adds Mark to TO list and CC list for checking send
  this email properly to him.
 
   drivers/staging/dgap/dgap.c |  306 
  +++
   1 files changed, 133 insertions(+), 173 deletions(-)
 
  diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
  index 06c55cb..9e750fb 100644
  --- a/drivers/staging/dgap/dgap.c
  +++ b/drivers/staging/dgap/dgap.c
  @@ -41,6 +41,8 @@
*/
   #undef DIGI_CONCENTRATORS_SUPPORTED
 
  +#define pr_fmt(fmt) dgap:  fmt
  +
   #include linux/kernel.h
   #include linux/module.h
   #include linux/pci.h
  @@ -153,7 +155,6 @@ static void dgap_firmware_reset_port(struct channel_t 
  *ch);
   static int dgap_gettok(char **in);
   static char *dgap_getword(char **in);
   static int dgap_checknode(struct cnode *p);
  -static void dgap_err(char *s);
 
   /*
* Function prototypes from dgap_sysfs.h
  @@ -815,7 +816,7 @@ static struct board_t *dgap_found_board(struct 
  pci_dev *pdev, int id,
if (ret)
goto free_brd;
 
  - pr_info(dgap: board %d: %s (rev %d), irq %ld\n,
  + pr_info(board %d: %s (rev %d), irq %ld\n,
boardnum, brd-name, brd-rev, brd-irq);
 
  Almost all of the pr_*() calls in this driver should be converted over
  to use dev_*() calls instead.  And some of them, like this one, should
  be removed entirely (no need for a driver to be noisy when a device
  for it is found, it should be quiet if at all possible, unless something
  went wrong.)
 
  So can you do that here instead?  I've applied the earlier patches in
  this series, and stopped here.
 OK. I can. pr_*() calls are replaced with dev_*() calls.
 And also removes some of print message which are useless like out
 of memory

 Yes, please do that, that would be great.
I have been working to change pr_*() to dev_*(), but dgap_parse() has no
struct device for using dev_*(). If dgap_parse still need for this driver,
it need to take a parameter for using dev_*(), it may be pdev but
configuration
file doesn't need to parse in kernel at all, dgap_parse() will be removed.

So I will wait to verify by Mark about parsing configuration file.

Thanks.

regards,
Daeseok Youn.


 thanks,

 greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


<    1   2   3   4   5   >