[PATCH 00/11] staging: dgnc: cleanup the function on dgnc driver

2016-09-21 Thread Daeseok Youn
This series of patches will cleanup the functions in dgnc driver.
Rename it and introduce new functions to split big function into
smaller one. Please take a look at my patches to update the dgnc
driver and provide some comments if there are something wrong.

This series of patches maybe have dependency with each other.
If one of these patches cannot be merged, some other patches maybe
cannot be merged properly, I think.

Daeseok Youn (11):
  staging: dgnc: remove redundant initialization for channel_t
  staging: dgnc: remove useless message buffer
  staging: dgnc: missing NULL check for ioremap in dgnc_do_remap()
  staging: dgnc: kfree for board structure in dgnc_found_board()
  staging: dgnc: move functions unrelated with dgnc_found_board()
  staging: dgnc: introduce the dgnc_tty_unregister()
  staging: dgnc: rename dgnc_finalize_board_init() to dgnc_request_irq()
  staging: dgnc: introduce the dgnc_free_irq()
  staging: dgnc: rename dgnc_tty_uninit() to dgnc_cleanup_tty()
  staging: dgnc: remove useless variables
  staging: dgnc: introduce find_board_by_major()

 drivers/staging/dgnc/dgnc_driver.c | 170 ++---
 drivers/staging/dgnc/dgnc_driver.h |   9 --
 drivers/staging/dgnc/dgnc_tty.c|  97 +++--
 drivers/staging/dgnc/dgnc_tty.h|   3 +-
 4 files changed, 138 insertions(+), 141 deletions(-)

-- 
1.9.1



[PATCH 01/11] staging: dgnc: remove redundant initialization for

2016-09-21 Thread Daeseok Youn
The channel array in board_t was initialized in dgnc_found_board()
with NULL. But the channel is going to initialize in dgnc_tty_init().
So the channel array doesn't need to set NULL for initailization.

Signed-off-by: Daeseok Youn 
---
 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 01e948c..b598034 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -400,9 +400,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
brd->state  = BOARD_FOUND;
 
-   for (i = 0; i < MAXPORTS; i++)
-   brd->channels[i] = NULL;
-
/* store which card & revision we have */
pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor);
pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &brd->subdevice);
-- 
1.9.1



[PATCH 02/11] staging: dgnc: remove useless message buffer

2016-09-21 Thread Daeseok Youn
There is a temporary message buffer for the boot message
in dgnc_found_board() but the buffer was not used anywhere in
dgnc driver.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_driver.c | 28 
 drivers/staging/dgnc/dgnc_driver.h |  6 --
 2 files changed, 34 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index b598034..c87b3de 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -324,17 +324,6 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
brd->re_map_membase = NULL;
}
 
-   if (brd->msgbuf_head) {
-   unsigned long flags;
-
-   spin_lock_irqsave(&dgnc_global_lock, flags);
-   brd->msgbuf = NULL;
-   dev_dbg(&brd->pdev->dev, "%s\n", brd->msgbuf_head);
-   kfree(brd->msgbuf_head);
-   brd->msgbuf_head = NULL;
-   spin_unlock_irqrestore(&dgnc_global_lock, flags);
-   }
-
/* Free all allocated channels structs */
for (i = 0; i < MAXPORTS ; i++) {
if (brd->channels[i]) {
@@ -362,7 +351,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
unsigned int pci_irq;
int i = 0;
int rc = 0;
-   unsigned long flags;
 
/* get the board structure and prep it */
dgnc_board[dgnc_num_boards] = kzalloc(sizeof(*brd), GFP_KERNEL);
@@ -371,15 +359,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
if (!brd)
return -ENOMEM;
 
-   /* make a temporary message buffer for the boot messages */
-   brd->msgbuf_head = kcalloc(8192, sizeof(u8), GFP_KERNEL);
-   brd->msgbuf = brd->msgbuf_head;
-
-   if (!brd->msgbuf) {
-   kfree(brd);
-   return -ENOMEM;
-   }
-
/* store the info for the board we've found */
brd->magic = DGNC_BOARD_MAGIC;
brd->boardnum = dgnc_num_boards;
@@ -553,13 +532,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 brd->bd_ops->tasklet,
 (unsigned long)brd);
 
-   spin_lock_irqsave(&dgnc_global_lock, flags);
-   brd->msgbuf = NULL;
-   dev_dbg(&brd->pdev->dev, "%s\n", brd->msgbuf_head);
-   kfree(brd->msgbuf_head);
-   brd->msgbuf_head = NULL;
-   spin_unlock_irqrestore(&dgnc_global_lock, flags);
-
wake_up_interruptible(&brd->state_wait);
 
return 0;
diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 88d2696..747a100 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -213,12 +213,6 @@ struct dgnc_board {
 * as defined by DPA
 */
 
-   /*
-*  Mgmt data.
-*/
-   char*msgbuf_head;
-   char*msgbuf;
-
uintbd_dividend;/* Board/UARTs specific dividend */
 
struct board_ops *bd_ops;
-- 
1.9.1



[PATCH 05/11] staging: dgnc: move functions unrelated with

2016-09-21 Thread Daeseok Youn
The functions related with tty device initialization are needed
to be moved from dgnc_found_board() to dgnc_init_one().

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_driver.c | 81 --
 1 file changed, 43 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 0114e78..a95d13c 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -38,7 +38,7 @@ MODULE_SUPPORTED_DEVICE("dgnc");
  */
 static int dgnc_start(void);
 static int dgnc_finalize_board_init(struct dgnc_board *brd);
-static int dgnc_found_board(struct pci_dev *pdev, int id);
+static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id);
 static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
 static int dgnc_init_one(struct pci_dev *pdev,
@@ -274,6 +274,7 @@ failed_class:
 static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
int rc;
+   struct dgnc_board *brd;
 
/* wake up and enable device */
rc = pci_enable_device(pdev);
@@ -281,9 +282,43 @@ static int dgnc_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (rc)
return -EIO;
 
-   rc = dgnc_found_board(pdev, ent->driver_data);
-   if (rc == 0)
-   dgnc_num_boards++;
+   brd = dgnc_found_board(pdev, ent->driver_data);
+   if (IS_ERR(brd))
+   return PTR_ERR(brd);
+
+   /*
+* Do tty device initialization.
+*/
+
+   rc = dgnc_tty_register(brd);
+   if (rc < 0) {
+   pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc);
+   goto failed;
+   }
+
+   rc = dgnc_finalize_board_init(brd);
+   if (rc < 0) {
+   pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
+   goto failed;
+   }
+
+   rc = dgnc_tty_init(brd);
+   if (rc < 0) {
+   pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
+   goto failed;
+   }
+
+   brd->state = BOARD_READY;
+   brd->dpastatus = BD_RUNNING;
+
+   dgnc_create_ports_sysfiles(brd);
+
+   dgnc_board[dgnc_num_boards++] = brd;
+
+   return 0;
+
+failed:
+   kfree(brd);
 
return rc;
 }
@@ -345,7 +380,7 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
  *
  * A board has been found, init it.
  */
-static int dgnc_found_board(struct pci_dev *pdev, int id)
+static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id)
 {
struct dgnc_board *brd;
unsigned int pci_irq;
@@ -355,7 +390,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
/* get the board structure and prep it */
brd = kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd)
-   return -ENOMEM;
+   return ERR_PTR(-ENOMEM);
 
/* store the info for the board we've found */
brd->magic = DGNC_BOARD_MAGIC;
@@ -505,33 +540,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
goto failed;
}
 
-   /*
-* Do tty device initialization.
-*/
-
-   rc = dgnc_tty_register(brd);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc);
-   goto failed;
-   }
-
-   rc = dgnc_finalize_board_init(brd);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
-   goto failed;
-   }
-
-   rc = dgnc_tty_init(brd);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
-   goto failed;
-   }
-
-   brd->state = BOARD_READY;
-   brd->dpastatus = BD_RUNNING;
-
-   dgnc_create_ports_sysfiles(brd);
-
/* init our poll helper tasklet */
tasklet_init(&brd->helper_tasklet,
 brd->bd_ops->tasklet,
@@ -539,15 +547,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(&brd->state_wait);
 
-   dgnc_board[dgnc_num_boards] = brd;
-
-   return 0;
+   return brd;
 
 failed:
-   dgnc_tty_uninit(brd);
kfree(brd);
 
-   return rc;
+   return ERR_PTR(rc);
 }
 
 static int dgnc_finalize_board_init(struct dgnc_board *brd)
-- 
1.9.1



[PATCH 04/11] staging: dgnc: kfree for board structure in

2016-09-21 Thread Daeseok Youn
The board structure should be freed when any function was failed
in dgnc_found_board(). And the board strucure will be stored
into dgnc_board array when the dgnc_found_board() function has no error.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_driver.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 58cebf4..0114e78 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -353,9 +353,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
int rc = 0;
 
/* get the board structure and prep it */
-   dgnc_board[dgnc_num_boards] = kzalloc(sizeof(*brd), GFP_KERNEL);
-   brd = dgnc_board[dgnc_num_boards];
-
+   brd = kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd)
return -ENOMEM;
 
@@ -411,7 +409,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
if (!brd->membase) {
dev_err(&brd->pdev->dev,
"Card has no PCI IO resources, failing.\n");
-   return -ENODEV;
+   rc = -ENODEV;
+   goto failed;
}
 
brd->membase_end = pci_resource_end(pdev, 4);
@@ -502,7 +501,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
default:
dev_err(&brd->pdev->dev,
"Didn't find any compatible Neo/Classic PCI boards.\n");
-   return -ENXIO;
+   rc = -ENXIO;
+   goto failed;
}
 
/*
@@ -539,14 +539,15 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(&brd->state_wait);
 
+   dgnc_board[dgnc_num_boards] = brd;
+
return 0;
 
 failed:
dgnc_tty_uninit(brd);
-   brd->state = BOARD_FAILED;
-   brd->dpastatus = BD_NOFEP;
+   kfree(brd);
 
-   return -ENXIO;
+   return rc;
 }
 
 static int dgnc_finalize_board_init(struct dgnc_board *brd)
-- 
1.9.1



[PATCH 03/11] staging: dgnc: missing NULL check for ioremap in

2016-09-21 Thread Daeseok Youn
The ioremap() function can be failed, so it need to have error
handling in dgnc_do_remap(). And also the return type of
dgnc_do_remap() should be changed from "void" to "int"

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_driver.c | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index c87b3de..58cebf4 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -43,7 +43,7 @@ static void   dgnc_cleanup_board(struct dgnc_board 
*brd);
 static voiddgnc_poll_handler(ulong dummy);
 static int dgnc_init_one(struct pci_dev *pdev,
  const struct pci_device_id *ent);
-static voiddgnc_do_remap(struct dgnc_board *brd);
+static int dgnc_do_remap(struct dgnc_board *brd);
 
 /*
  * File operations permitted on Control/Management major.
@@ -431,7 +431,10 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
brd->bd_uart_offset = 0x8;
brd->bd_dividend = 921600;
 
-   dgnc_do_remap(brd);
+   rc = dgnc_do_remap(brd);
+
+   if (rc < 0)
+   goto failed;
 
/* Get and store the board VPD, if it exists */
brd->bd_ops->vpd(brd);
@@ -483,15 +486,17 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
brd->bd_uart_offset = 0x200;
brd->bd_dividend = 921600;
 
-   dgnc_do_remap(brd);
+   rc = dgnc_do_remap(brd);
 
-   if (brd->re_map_membase) {
-   /* Read and store the dvid after remapping */
-   brd->dvid = readb(brd->re_map_membase + 0x8D);
+   if (rc < 0)
+   goto failed;
+
+   /* Read and store the dvid after remapping */
+   brd->dvid = readb(brd->re_map_membase + 0x8D);
+
+   /* Get and store the board VPD, if it exists */
+   brd->bd_ops->vpd(brd);
 
-   /* Get and store the board VPD, if it exists */
-   brd->bd_ops->vpd(brd);
-   }
break;
 
default:
@@ -566,9 +571,15 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd)
 /*
  * Remap PCI memory.
  */
-static void dgnc_do_remap(struct dgnc_board *brd)
+static int dgnc_do_remap(struct dgnc_board *brd)
 {
+   int rc = 0;
+
brd->re_map_membase = ioremap(brd->membase, 0x1000);
+   if (!brd->re_map_membase)
+   rc = -ENOMEM;
+
+   return rc;
 }
 
 /*
-- 
1.9.1



[PATCH 10/11] staging: dgnc: remove useless variables

2016-09-21 Thread Daeseok Youn
The dgnc_major_serial_registered and dgnc_major_serial_registered
do not need to use to check whether the tty driver is registered or not.
These variables are used only in dgnc_cleanup_tty() function,
This function will be called normally with initialized board structure.
It means the dgnc_cleanup_tty() cannot be called with unregistered tty.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_driver.h |  3 --
 drivers/staging/dgnc/dgnc_tty.c| 64 +++---
 2 files changed, 25 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 747a100..8792026 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -203,9 +203,6 @@ struct dgnc_board {
struct tty_driver *print_driver;
charprint_name[200];
 
-   booldgnc_major_serial_registered;
-   booldgnc_major_transparent_print_registered;
-
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 5befd28..ba724ab 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -204,15 +204,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
 */
tty_set_operations(brd->serial_driver, &dgnc_tty_ops);
 
-   if (!brd->dgnc_major_serial_registered) {
-   /* Register tty devices */
-   rc = tty_register_driver(brd->serial_driver);
-   if (rc < 0) {
-   dev_dbg(&brd->pdev->dev,
-   "Can't register tty device (%d)\n", rc);
-   goto free_serial_driver;
-   }
-   brd->dgnc_major_serial_registered = true;
+   rc = tty_register_driver(brd->serial_driver);
+   if (rc < 0) {
+   dev_dbg(&brd->pdev->dev,
+   "Can't register tty device (%d)\n", rc);
+   goto free_serial_driver;
}
 
/*
@@ -247,16 +243,12 @@ int dgnc_tty_register(struct dgnc_board *brd)
 */
tty_set_operations(brd->print_driver, &dgnc_tty_ops);
 
-   if (!brd->dgnc_major_transparent_print_registered) {
-   /* Register Transparent Print devices */
-   rc = tty_register_driver(brd->print_driver);
-   if (rc < 0) {
-   dev_dbg(&brd->pdev->dev,
-   "Can't register Transparent Print device(%d)\n",
-   rc);
-   goto free_print_driver;
-   }
-   brd->dgnc_major_transparent_print_registered = true;
+   rc = tty_register_driver(brd->print_driver);
+   if (rc < 0) {
+   dev_dbg(&brd->pdev->dev,
+   "Can't register Transparent Print device(%d)\n",
+   rc);
+   goto free_print_driver;
}
 
dgnc_BoardsByMajor[brd->serial_driver->major] = brd;
@@ -396,29 +388,23 @@ void dgnc_cleanup_tty(struct dgnc_board *brd)
 {
int i = 0;
 
-   if (brd->dgnc_major_serial_registered) {
-   dgnc_BoardsByMajor[brd->serial_driver->major] = NULL;
-   for (i = 0; i < brd->nasync; i++) {
-   if (brd->channels[i])
-   dgnc_remove_tty_sysfs(brd->channels[i]->
- ch_tun.un_sysfs);
-   tty_unregister_device(brd->serial_driver, i);
-   }
-   tty_unregister_driver(brd->serial_driver);
-   brd->dgnc_major_serial_registered = false;
+   dgnc_BoardsByMajor[brd->serial_driver->major] = NULL;
+   for (i = 0; i < brd->nasync; i++) {
+   if (brd->channels[i])
+   dgnc_remove_tty_sysfs(brd->channels[i]->
+ ch_tun.un_sysfs);
+   tty_unregister_device(brd->serial_driver, i);
}
+   tty_unregister_driver(brd->serial_driver);
 
-   if (brd->dgnc_major_transparent_print_registered) {
-   dgnc_BoardsByMajor[brd->print_driver->major] = NULL;
-   for (i = 0; i < brd->nasync; i++) {
-   if (brd->channels[i])
-   dgnc_remove_tty_sysfs(brd->channels[i]->
- ch_pun.un_sysfs);
-   tty_unregister_device(brd->print_driver, i);
-   }
-   tty_unregister_driver(brd->print_driver);
- 

[PATCH 09/11] staging: dgnc: rename dgnc_tty_uninit() to

2016-09-21 Thread Daeseok Youn
The dgnc_tty_uninit() doesn't match with dgnc_tty_init() at all.
And also the dgnc_cleanup_tty() is only called for exiting the module.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_driver.c | 2 +-
 drivers/staging/dgnc/dgnc_tty.c| 4 ++--
 drivers/staging/dgnc/dgnc_tty.h| 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 81ce5c4..fd372d3 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -147,7 +147,7 @@ static void cleanup(bool sysfiles)
 
for (i = 0; i < dgnc_num_boards; ++i) {
dgnc_remove_ports_sysfiles(dgnc_board[i]);
-   dgnc_tty_uninit(dgnc_board[i]);
+   dgnc_cleanup_tty(dgnc_board[i]);
dgnc_cleanup_board(dgnc_board[i]);
}
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 893f473..5befd28 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -387,12 +387,12 @@ void dgnc_tty_post_uninit(void)
 }
 
 /*
- * dgnc_tty_uninit()
+ * dgnc_cleanup_tty()
  *
  * Uninitialize the TTY portion of this driver.  Free all memory and
  * resources.
  */
-void dgnc_tty_uninit(struct dgnc_board *brd)
+void dgnc_cleanup_tty(struct dgnc_board *brd)
 {
int i = 0;
 
diff --git a/drivers/staging/dgnc/dgnc_tty.h b/drivers/staging/dgnc/dgnc_tty.h
index f065c8f..24c9a41 100644
--- a/drivers/staging/dgnc/dgnc_tty.h
+++ b/drivers/staging/dgnc/dgnc_tty.h
@@ -25,7 +25,7 @@ int   dgnc_tty_preinit(void);
 int dgnc_tty_init(struct dgnc_board *);
 
 void   dgnc_tty_post_uninit(void);
-void   dgnc_tty_uninit(struct dgnc_board *);
+void   dgnc_cleanup_tty(struct dgnc_board *);
 
 void   dgnc_input(struct channel_t *ch);
 void   dgnc_carrier(struct channel_t *ch);
-- 
1.9.1



[PATCH 08/11] staging: dgnc: introduce the dgnc_free_irq()

2016-09-21 Thread Daeseok Youn
The dgnc_free_irq() will free the requested IRQ from
the dgnc_request_irq().

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_driver.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 70e68b5..81ce5c4 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -38,6 +38,7 @@ MODULE_SUPPORTED_DEVICE("dgnc");
  */
 static int dgnc_start(void);
 static int dgnc_request_irq(struct dgnc_board *brd);
+static void dgnc_free_irq(struct dgnc_board *brd);
 static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id);
 static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
@@ -305,7 +306,7 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
rc = dgnc_tty_init(brd);
if (rc < 0) {
pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
-   goto unregister_tty;
+   goto free_irq;
}
 
brd->state = BOARD_READY;
@@ -317,6 +318,8 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
return 0;
 
+free_irq:
+   dgnc_free_irq(brd);
 unregister_tty:
dgnc_tty_unregister(brd);
 
@@ -577,6 +580,12 @@ static int dgnc_request_irq(struct dgnc_board *brd)
return rc;
 }
 
+static void dgnc_free_irq(struct dgnc_board *brd)
+{
+   if (brd->irq)
+   free_irq(brd->irq, brd);
+}
+
 /*
  * Remap PCI memory.
  */
-- 
1.9.1



[PATCH 07/11] staging: dgnc: rename dgnc_finalize_board_init() to

2016-09-21 Thread Daeseok Youn
The dgnc_finalize_board_init() function has only job for
requesting the IRQ. It should be renamed to dgnc_request_irq()

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index ffe55a2..70e68b5 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -37,7 +37,7 @@ MODULE_SUPPORTED_DEVICE("dgnc");
  *
  */
 static int dgnc_start(void);
-static int dgnc_finalize_board_init(struct dgnc_board *brd);
+static int dgnc_request_irq(struct dgnc_board *brd);
 static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id);
 static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
@@ -296,7 +296,7 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
goto failed;
}
 
-   rc = dgnc_finalize_board_init(brd);
+   rc = dgnc_request_irq(brd);
if (rc < 0) {
pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
goto unregister_tty;
@@ -558,7 +558,7 @@ failed:
return ERR_PTR(rc);
 }
 
-static int dgnc_finalize_board_init(struct dgnc_board *brd)
+static int dgnc_request_irq(struct dgnc_board *brd)
 {
int rc = 0;
 
-- 
1.9.1



[PATCH 06/11] staging: dgnc: introduce the dgnc_tty_unregister()

2016-09-21 Thread Daeseok Youn
The dgnc_tty_unregister() will be called when
the dgnc_tty_register() is failed.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_driver.c | 7 +--
 drivers/staging/dgnc/dgnc_tty.c| 8 
 drivers/staging/dgnc/dgnc_tty.h| 1 +
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index a95d13c..ffe55a2 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -299,13 +299,13 @@ static int dgnc_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
rc = dgnc_finalize_board_init(brd);
if (rc < 0) {
pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
-   goto failed;
+   goto unregister_tty;
}
 
rc = dgnc_tty_init(brd);
if (rc < 0) {
pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
-   goto failed;
+   goto unregister_tty;
}
 
brd->state = BOARD_READY;
@@ -317,6 +317,9 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
return 0;
 
+unregister_tty:
+   dgnc_tty_unregister(brd);
+
 failed:
kfree(brd);
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index fd46ef0..893f473 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -273,6 +273,14 @@ free_serial_driver:
return rc;
 }
 
+void dgnc_tty_unregister(struct dgnc_board *brd)
+{
+   tty_unregister_driver(brd->print_driver);
+   tty_unregister_driver(brd->serial_driver);
+   put_tty_driver(brd->print_driver);
+   put_tty_driver(brd->serial_driver);
+}
+
 /*
  * dgnc_tty_init()
  *
diff --git a/drivers/staging/dgnc/dgnc_tty.h b/drivers/staging/dgnc/dgnc_tty.h
index 21d3369..f065c8f 100644
--- a/drivers/staging/dgnc/dgnc_tty.h
+++ b/drivers/staging/dgnc/dgnc_tty.h
@@ -19,6 +19,7 @@
 #include "dgnc_driver.h"
 
 intdgnc_tty_register(struct dgnc_board *brd);
+void dgnc_tty_unregister(struct dgnc_board *brd);
 
 intdgnc_tty_preinit(void);
 int dgnc_tty_init(struct dgnc_board *);
-- 
1.9.1



[PATCH 11/11] staging: dgnc: introduce find_board_by_major()

2016-09-21 Thread Daeseok Youn
It was used to get a board structure with dgnc_BoardsByMajor array.
But this driver already has the array for managing initialized board
as dgap_board[]. It can be used for searching the board structure
by major number.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_tty.c | 25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index ba724ab..a486a86 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -45,7 +45,6 @@
 /*
  * internal variables
  */
-static struct dgnc_board   *dgnc_BoardsByMajor[256];
 static unsigned char   *dgnc_TmpWriteBuf;
 
 /*
@@ -251,8 +250,6 @@ int dgnc_tty_register(struct dgnc_board *brd)
goto free_print_driver;
}
 
-   dgnc_BoardsByMajor[brd->serial_driver->major] = brd;
-
return 0;
 
 free_print_driver:
@@ -388,7 +385,6 @@ void dgnc_cleanup_tty(struct dgnc_board *brd)
 {
int i = 0;
 
-   dgnc_BoardsByMajor[brd->serial_driver->major] = NULL;
for (i = 0; i < brd->nasync; i++) {
if (brd->channels[i])
dgnc_remove_tty_sysfs(brd->channels[i]->
@@ -397,7 +393,6 @@ void dgnc_cleanup_tty(struct dgnc_board *brd)
}
tty_unregister_driver(brd->serial_driver);
 
-   dgnc_BoardsByMajor[brd->print_driver->major] = NULL;
for (i = 0; i < brd->nasync; i++) {
if (brd->channels[i])
dgnc_remove_tty_sysfs(brd->channels[i]->
@@ -935,6 +930,24 @@ void dgnc_wakeup_writes(struct channel_t *ch)
spin_unlock_irqrestore(&ch->ch_lock, flags);
 }
 
+struct dgnc_board *find_board_by_major(unsigned int major)
+{
+   int i;
+
+   for (i = 0; i < MAXBOARDS; i++) {
+   struct dgnc_board *brd = dgnc_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
@@ -964,7 +977,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct 
file *file)
return -ENXIO;
 
/* Get board pointer from our array of majors we have allocated */
-   brd = dgnc_BoardsByMajor[major];
+   brd = find_board_by_major(major);
if (!brd)
return -ENXIO;
 
-- 
1.9.1



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

2016-06-20 Thread DaeSeok Youn
2016-06-16 18:23 GMT+09:00 DaeSeok Youn :
> 2016-05-10 15:44 GMT+09:00 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 
>> ---
> Hello Greg,
>
> This patch and patches from this were not merged into your tree for a one 
> month.
> Can you tell me why these are still waiting to merge?

Hello Greg,

Please have a look my comment. My patches have been waiting to merge
your staging tree for a month.
If you don't have pending patches from me, I can send those again.

Thanks.
regards,
Daeseok.
>
> Thanks.
> regards,
> Daeseok.
>
>
>> 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->ch_lock, flags);
>> --
>> 2.8.2
>>


Re: [PATCH 04/11] staging: dgnc: kfree for board structure in

2016-09-22 Thread DaeSeok Youn
2016-09-22 16:21 GMT+09:00 Greg KH :
> On Thu, Sep 22, 2016 at 02:22:03PM +0900, Daeseok Youn wrote:
>> The board structure should be freed when any function was failed
>> in dgnc_found_board(). And the board strucure will be stored
>> into dgnc_board array when the dgnc_found_board() function has no error.
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>>  drivers/staging/dgnc/dgnc_driver.c | 17 +
>>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> Another shortened subject line.
I am not sure why the subject line was cut off.
I will fix them up and resend.

Thanks.
Regards,
Daeseok.
>
> Please look at all of the subjects in this series, fix them up, and
> resend.
>
> thanks,
>
> greg k-h


[PATCH 01/11 V2] staging: dgnc: remove redundant initialization for channel array

2016-09-22 Thread Daeseok Youn
The channel array in board_t was initialized in dgnc_found_board()
with NULL. But the channel is going to initialize in dgnc_tty_init()
again. So the channel array doesn't need to set NULL
for initailization in dgnc_found_board().

Signed-off-by: Daeseok Youn 
---
V2: The subject line was cut off, I put it completely and update
change log.

 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 01e948c..b598034 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -400,9 +400,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
brd->state  = BOARD_FOUND;
 
-   for (i = 0; i < MAXPORTS; i++)
-   brd->channels[i] = NULL;
-
/* store which card & revision we have */
pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor);
pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &brd->subdevice);
-- 
1.9.1



[PATCH 03/11 V2] staging: dgnc: missing NULL check for ioremap in dgnc_do_remap()

2016-09-22 Thread Daeseok Youn
The ioremap() function can be failed, so it need to have error
handling in dgnc_do_remap(). And also the return type of
dgnc_do_remap() should be changed from "void" to "int"

Signed-off-by: Daeseok Youn 
---
V2: the subject line was cut off, I put it completely.

 drivers/staging/dgnc/dgnc_driver.c | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index c87b3de..58cebf4 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -43,7 +43,7 @@ static void   dgnc_cleanup_board(struct dgnc_board 
*brd);
 static voiddgnc_poll_handler(ulong dummy);
 static int dgnc_init_one(struct pci_dev *pdev,
  const struct pci_device_id *ent);
-static voiddgnc_do_remap(struct dgnc_board *brd);
+static int dgnc_do_remap(struct dgnc_board *brd);
 
 /*
  * File operations permitted on Control/Management major.
@@ -431,7 +431,10 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
brd->bd_uart_offset = 0x8;
brd->bd_dividend = 921600;
 
-   dgnc_do_remap(brd);
+   rc = dgnc_do_remap(brd);
+
+   if (rc < 0)
+   goto failed;
 
/* Get and store the board VPD, if it exists */
brd->bd_ops->vpd(brd);
@@ -483,15 +486,17 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
brd->bd_uart_offset = 0x200;
brd->bd_dividend = 921600;
 
-   dgnc_do_remap(brd);
+   rc = dgnc_do_remap(brd);
 
-   if (brd->re_map_membase) {
-   /* Read and store the dvid after remapping */
-   brd->dvid = readb(brd->re_map_membase + 0x8D);
+   if (rc < 0)
+   goto failed;
+
+   /* Read and store the dvid after remapping */
+   brd->dvid = readb(brd->re_map_membase + 0x8D);
+
+   /* Get and store the board VPD, if it exists */
+   brd->bd_ops->vpd(brd);
 
-   /* Get and store the board VPD, if it exists */
-   brd->bd_ops->vpd(brd);
-   }
break;
 
default:
@@ -566,9 +571,15 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd)
 /*
  * Remap PCI memory.
  */
-static void dgnc_do_remap(struct dgnc_board *brd)
+static int dgnc_do_remap(struct dgnc_board *brd)
 {
+   int rc = 0;
+
brd->re_map_membase = ioremap(brd->membase, 0x1000);
+   if (!brd->re_map_membase)
+   rc = -ENOMEM;
+
+   return rc;
 }
 
 /*
-- 
1.9.1



[PATCH 04/11 V2] staging: dgnc: kfree for board structure in dgnc_found_board()

2016-09-22 Thread Daeseok Youn
The board structure should be freed when any function was failed
in dgnc_found_board(). And the board strucure will be stored
into dgnc_board array when the dgnc_found_board() function has no error.

Signed-off-by: Daeseok Youn 
---
V2: the subject line was cut off, I put it completely.

 drivers/staging/dgnc/dgnc_driver.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 58cebf4..0114e78 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -353,9 +353,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
int rc = 0;
 
/* get the board structure and prep it */
-   dgnc_board[dgnc_num_boards] = kzalloc(sizeof(*brd), GFP_KERNEL);
-   brd = dgnc_board[dgnc_num_boards];
-
+   brd = kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd)
return -ENOMEM;
 
@@ -411,7 +409,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
if (!brd->membase) {
dev_err(&brd->pdev->dev,
"Card has no PCI IO resources, failing.\n");
-   return -ENODEV;
+   rc = -ENODEV;
+   goto failed;
}
 
brd->membase_end = pci_resource_end(pdev, 4);
@@ -502,7 +501,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
default:
dev_err(&brd->pdev->dev,
"Didn't find any compatible Neo/Classic PCI boards.\n");
-   return -ENXIO;
+   rc = -ENXIO;
+   goto failed;
}
 
/*
@@ -539,14 +539,15 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(&brd->state_wait);
 
+   dgnc_board[dgnc_num_boards] = brd;
+
return 0;
 
 failed:
dgnc_tty_uninit(brd);
-   brd->state = BOARD_FAILED;
-   brd->dpastatus = BD_NOFEP;
+   kfree(brd);
 
-   return -ENXIO;
+   return rc;
 }
 
 static int dgnc_finalize_board_init(struct dgnc_board *brd)
-- 
1.9.1



[PATCH 05/11 V2] staging: dgnc: move functions unrelated with dgnc_found_board()

2016-09-22 Thread Daeseok Youn
The functions related with tty device initialization are needed
to be moved from dgnc_found_board() to dgnc_init_one().

Signed-off-by: Daeseok Youn 
---
V2: the subject line was cut off, I put it completely.

 drivers/staging/dgnc/dgnc_driver.c | 81 --
 1 file changed, 43 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 0114e78..a95d13c 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -38,7 +38,7 @@ MODULE_SUPPORTED_DEVICE("dgnc");
  */
 static int dgnc_start(void);
 static int dgnc_finalize_board_init(struct dgnc_board *brd);
-static int dgnc_found_board(struct pci_dev *pdev, int id);
+static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id);
 static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
 static int dgnc_init_one(struct pci_dev *pdev,
@@ -274,6 +274,7 @@ failed_class:
 static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
int rc;
+   struct dgnc_board *brd;
 
/* wake up and enable device */
rc = pci_enable_device(pdev);
@@ -281,9 +282,43 @@ static int dgnc_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (rc)
return -EIO;
 
-   rc = dgnc_found_board(pdev, ent->driver_data);
-   if (rc == 0)
-   dgnc_num_boards++;
+   brd = dgnc_found_board(pdev, ent->driver_data);
+   if (IS_ERR(brd))
+   return PTR_ERR(brd);
+
+   /*
+* Do tty device initialization.
+*/
+
+   rc = dgnc_tty_register(brd);
+   if (rc < 0) {
+   pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc);
+   goto failed;
+   }
+
+   rc = dgnc_finalize_board_init(brd);
+   if (rc < 0) {
+   pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
+   goto failed;
+   }
+
+   rc = dgnc_tty_init(brd);
+   if (rc < 0) {
+   pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
+   goto failed;
+   }
+
+   brd->state = BOARD_READY;
+   brd->dpastatus = BD_RUNNING;
+
+   dgnc_create_ports_sysfiles(brd);
+
+   dgnc_board[dgnc_num_boards++] = brd;
+
+   return 0;
+
+failed:
+   kfree(brd);
 
return rc;
 }
@@ -345,7 +380,7 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
  *
  * A board has been found, init it.
  */
-static int dgnc_found_board(struct pci_dev *pdev, int id)
+static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id)
 {
struct dgnc_board *brd;
unsigned int pci_irq;
@@ -355,7 +390,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
/* get the board structure and prep it */
brd = kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd)
-   return -ENOMEM;
+   return ERR_PTR(-ENOMEM);
 
/* store the info for the board we've found */
brd->magic = DGNC_BOARD_MAGIC;
@@ -505,33 +540,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
goto failed;
}
 
-   /*
-* Do tty device initialization.
-*/
-
-   rc = dgnc_tty_register(brd);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc);
-   goto failed;
-   }
-
-   rc = dgnc_finalize_board_init(brd);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
-   goto failed;
-   }
-
-   rc = dgnc_tty_init(brd);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
-   goto failed;
-   }
-
-   brd->state = BOARD_READY;
-   brd->dpastatus = BD_RUNNING;
-
-   dgnc_create_ports_sysfiles(brd);
-
/* init our poll helper tasklet */
tasklet_init(&brd->helper_tasklet,
 brd->bd_ops->tasklet,
@@ -539,15 +547,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(&brd->state_wait);
 
-   dgnc_board[dgnc_num_boards] = brd;
-
-   return 0;
+   return brd;
 
 failed:
-   dgnc_tty_uninit(brd);
kfree(brd);
 
-   return rc;
+   return ERR_PTR(rc);
 }
 
 static int dgnc_finalize_board_init(struct dgnc_board *brd)
-- 
1.9.1



[PATCH 07/11 V2] staging: dgnc: rename dgnc_finalize_board_init() to dgnc_request_irq()

2016-09-22 Thread Daeseok Youn
The dgnc_finalize_board_init() function has only job for
requesting the IRQ. It should be renamed to dgnc_request_irq()

Signed-off-by: Daeseok Youn 
---
V2: the subject line was cut off, I put it completely.

 drivers/staging/dgnc/dgnc_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index ffe55a2..70e68b5 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -37,7 +37,7 @@ MODULE_SUPPORTED_DEVICE("dgnc");
  *
  */
 static int dgnc_start(void);
-static int dgnc_finalize_board_init(struct dgnc_board *brd);
+static int dgnc_request_irq(struct dgnc_board *brd);
 static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id);
 static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
@@ -296,7 +296,7 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
goto failed;
}
 
-   rc = dgnc_finalize_board_init(brd);
+   rc = dgnc_request_irq(brd);
if (rc < 0) {
pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
goto unregister_tty;
@@ -558,7 +558,7 @@ failed:
return ERR_PTR(rc);
 }
 
-static int dgnc_finalize_board_init(struct dgnc_board *brd)
+static int dgnc_request_irq(struct dgnc_board *brd)
 {
int rc = 0;
 
-- 
1.9.1



[PATCH 09/11 V2] staging: dgnc: rename dgnc_tty_uninit() to dgnc_cleanup_tty()

2016-09-22 Thread Daeseok Youn
The dgnc_tty_uninit() doesn't match with dgnc_tty_init() at all.
And also the dgnc_cleanup_tty() is only called for exiting the module.

Signed-off-by: Daeseok Youn 
---
V2: the subject line was cut off, I put it completely.

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

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 81ce5c4..fd372d3 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -147,7 +147,7 @@ static void cleanup(bool sysfiles)
 
for (i = 0; i < dgnc_num_boards; ++i) {
dgnc_remove_ports_sysfiles(dgnc_board[i]);
-   dgnc_tty_uninit(dgnc_board[i]);
+   dgnc_cleanup_tty(dgnc_board[i]);
dgnc_cleanup_board(dgnc_board[i]);
}
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 893f473..5befd28 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -387,12 +387,12 @@ void dgnc_tty_post_uninit(void)
 }
 
 /*
- * dgnc_tty_uninit()
+ * dgnc_cleanup_tty()
  *
  * Uninitialize the TTY portion of this driver.  Free all memory and
  * resources.
  */
-void dgnc_tty_uninit(struct dgnc_board *brd)
+void dgnc_cleanup_tty(struct dgnc_board *brd)
 {
int i = 0;
 
diff --git a/drivers/staging/dgnc/dgnc_tty.h b/drivers/staging/dgnc/dgnc_tty.h
index f065c8f..24c9a41 100644
--- a/drivers/staging/dgnc/dgnc_tty.h
+++ b/drivers/staging/dgnc/dgnc_tty.h
@@ -25,7 +25,7 @@ int   dgnc_tty_preinit(void);
 int dgnc_tty_init(struct dgnc_board *);
 
 void   dgnc_tty_post_uninit(void);
-void   dgnc_tty_uninit(struct dgnc_board *);
+void   dgnc_cleanup_tty(struct dgnc_board *);
 
 void   dgnc_input(struct channel_t *ch);
 void   dgnc_carrier(struct channel_t *ch);
-- 
1.9.1



Re: [PATCH 01/11 V2] staging: dgnc: remove redundant initialization for channel array

2016-09-25 Thread DaeSeok Youn
2016-09-23 21:15 GMT+09:00 Greg KH :
> On Fri, Sep 23, 2016 at 10:25:02AM +0900, Daeseok Youn wrote:
>> The channel array in board_t was initialized in dgnc_found_board()
>> with NULL. But the channel is going to initialize in dgnc_tty_init()
>> again. So the channel array doesn't need to set NULL
>> for initailization in dgnc_found_board().
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>> V2: The subject line was cut off, I put it completely and update
>> change log.
>
> I only got 6 patches of an 11 patch series here, what happened?
I sent only updated 6 patches of series, I will resend 11 patches again.

Thanks.
Regards,
Daeseok Youn.
>
> Please resend the whole series.
>
> thanks,
>
> greg k-h


[PATCH 01/11 V2 RESEND] staging: dgnc: remove redundant initialization for channel array

2016-09-25 Thread Daeseok Youn
The channel array in board_t was initialized in dgnc_found_board()
with NULL. But the channel is going to initialize in dgnc_tty_init().
So the channel array doesn't need to set NULL for initailization.

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

V2: The subject line was cut off, I put it completely and update
change log.

 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 01e948c..b598034 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -400,9 +400,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
brd->state  = BOARD_FOUND;
 
-   for (i = 0; i < MAXPORTS; i++)
-   brd->channels[i] = NULL;
-
/* store which card & revision we have */
pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor);
pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &brd->subdevice);
-- 
1.9.1



[PATCH 02/11 RESEND] staging: dgnc: remove useless message buffer

2016-09-25 Thread Daeseok Youn
There is a temporary message buffer for the boot message
in dgnc_found_board() but the buffer was not used anywhere in
dgnc driver.

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

 drivers/staging/dgnc/dgnc_driver.c | 28 
 drivers/staging/dgnc/dgnc_driver.h |  6 --
 2 files changed, 34 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index b598034..c87b3de 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -324,17 +324,6 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
brd->re_map_membase = NULL;
}
 
-   if (brd->msgbuf_head) {
-   unsigned long flags;
-
-   spin_lock_irqsave(&dgnc_global_lock, flags);
-   brd->msgbuf = NULL;
-   dev_dbg(&brd->pdev->dev, "%s\n", brd->msgbuf_head);
-   kfree(brd->msgbuf_head);
-   brd->msgbuf_head = NULL;
-   spin_unlock_irqrestore(&dgnc_global_lock, flags);
-   }
-
/* Free all allocated channels structs */
for (i = 0; i < MAXPORTS ; i++) {
if (brd->channels[i]) {
@@ -362,7 +351,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
unsigned int pci_irq;
int i = 0;
int rc = 0;
-   unsigned long flags;
 
/* get the board structure and prep it */
dgnc_board[dgnc_num_boards] = kzalloc(sizeof(*brd), GFP_KERNEL);
@@ -371,15 +359,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
if (!brd)
return -ENOMEM;
 
-   /* make a temporary message buffer for the boot messages */
-   brd->msgbuf_head = kcalloc(8192, sizeof(u8), GFP_KERNEL);
-   brd->msgbuf = brd->msgbuf_head;
-
-   if (!brd->msgbuf) {
-   kfree(brd);
-   return -ENOMEM;
-   }
-
/* store the info for the board we've found */
brd->magic = DGNC_BOARD_MAGIC;
brd->boardnum = dgnc_num_boards;
@@ -553,13 +532,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 brd->bd_ops->tasklet,
 (unsigned long)brd);
 
-   spin_lock_irqsave(&dgnc_global_lock, flags);
-   brd->msgbuf = NULL;
-   dev_dbg(&brd->pdev->dev, "%s\n", brd->msgbuf_head);
-   kfree(brd->msgbuf_head);
-   brd->msgbuf_head = NULL;
-   spin_unlock_irqrestore(&dgnc_global_lock, flags);
-
wake_up_interruptible(&brd->state_wait);
 
return 0;
diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 88d2696..747a100 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -213,12 +213,6 @@ struct dgnc_board {
 * as defined by DPA
 */
 
-   /*
-*  Mgmt data.
-*/
-   char*msgbuf_head;
-   char*msgbuf;
-
uintbd_dividend;/* Board/UARTs specific dividend */
 
struct board_ops *bd_ops;
-- 
1.9.1



[PATCH 03/11 V2 RESEND] staging: dgnc: missing NULL check for ioremap in dgnc_do_remap()

2016-09-25 Thread Daeseok Youn
The ioremap() function can be failed, so it need to have error
handling in dgnc_do_remap(). And also the return type of
dgnc_do_remap() should be changed from "void" to "int"

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

V2: The subject line was cut off, I put it completely and update
change log.

 drivers/staging/dgnc/dgnc_driver.c | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index c87b3de..58cebf4 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -43,7 +43,7 @@ static void   dgnc_cleanup_board(struct dgnc_board 
*brd);
 static voiddgnc_poll_handler(ulong dummy);
 static int dgnc_init_one(struct pci_dev *pdev,
  const struct pci_device_id *ent);
-static voiddgnc_do_remap(struct dgnc_board *brd);
+static int dgnc_do_remap(struct dgnc_board *brd);
 
 /*
  * File operations permitted on Control/Management major.
@@ -431,7 +431,10 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
brd->bd_uart_offset = 0x8;
brd->bd_dividend = 921600;
 
-   dgnc_do_remap(brd);
+   rc = dgnc_do_remap(brd);
+
+   if (rc < 0)
+   goto failed;
 
/* Get and store the board VPD, if it exists */
brd->bd_ops->vpd(brd);
@@ -483,15 +486,17 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
brd->bd_uart_offset = 0x200;
brd->bd_dividend = 921600;
 
-   dgnc_do_remap(brd);
+   rc = dgnc_do_remap(brd);
 
-   if (brd->re_map_membase) {
-   /* Read and store the dvid after remapping */
-   brd->dvid = readb(brd->re_map_membase + 0x8D);
+   if (rc < 0)
+   goto failed;
+
+   /* Read and store the dvid after remapping */
+   brd->dvid = readb(brd->re_map_membase + 0x8D);
+
+   /* Get and store the board VPD, if it exists */
+   brd->bd_ops->vpd(brd);
 
-   /* Get and store the board VPD, if it exists */
-   brd->bd_ops->vpd(brd);
-   }
break;
 
default:
@@ -566,9 +571,15 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd)
 /*
  * Remap PCI memory.
  */
-static void dgnc_do_remap(struct dgnc_board *brd)
+static int dgnc_do_remap(struct dgnc_board *brd)
 {
+   int rc = 0;
+
brd->re_map_membase = ioremap(brd->membase, 0x1000);
+   if (!brd->re_map_membase)
+   rc = -ENOMEM;
+
+   return rc;
 }
 
 /*
-- 
1.9.1



[PATCH 04/11] staging: dgnc: kfree for board structure in dgnc_found_board()

2016-09-25 Thread Daeseok Youn
The board structure should be freed when any function was failed
in dgnc_found_board(). And the board strucure will be stored
into dgnc_board array when the dgnc_found_board() function has no error.

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

V2: The subject line was cut off, I put it completely and update
change log.

 drivers/staging/dgnc/dgnc_driver.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 58cebf4..0114e78 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -353,9 +353,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
int rc = 0;
 
/* get the board structure and prep it */
-   dgnc_board[dgnc_num_boards] = kzalloc(sizeof(*brd), GFP_KERNEL);
-   brd = dgnc_board[dgnc_num_boards];
-
+   brd = kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd)
return -ENOMEM;
 
@@ -411,7 +409,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
if (!brd->membase) {
dev_err(&brd->pdev->dev,
"Card has no PCI IO resources, failing.\n");
-   return -ENODEV;
+   rc = -ENODEV;
+   goto failed;
}
 
brd->membase_end = pci_resource_end(pdev, 4);
@@ -502,7 +501,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
default:
dev_err(&brd->pdev->dev,
"Didn't find any compatible Neo/Classic PCI boards.\n");
-   return -ENXIO;
+   rc = -ENXIO;
+   goto failed;
}
 
/*
@@ -539,14 +539,15 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(&brd->state_wait);
 
+   dgnc_board[dgnc_num_boards] = brd;
+
return 0;
 
 failed:
dgnc_tty_uninit(brd);
-   brd->state = BOARD_FAILED;
-   brd->dpastatus = BD_NOFEP;
+   kfree(brd);
 
-   return -ENXIO;
+   return rc;
 }
 
 static int dgnc_finalize_board_init(struct dgnc_board *brd)
-- 
1.9.1



[PATCH 05/11 V2 RESEND] staging: dgnc: move functions unrelated with dgnc_found_board()

2016-09-25 Thread Daeseok Youn
The functions related with tty device initialization are needed
to be moved from dgnc_found_board() to dgnc_init_one().

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

V2: The subject line was cut off, I put it completely and update
change log.

 drivers/staging/dgnc/dgnc_driver.c | 81 --
 1 file changed, 43 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 0114e78..a95d13c 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -38,7 +38,7 @@ MODULE_SUPPORTED_DEVICE("dgnc");
  */
 static int dgnc_start(void);
 static int dgnc_finalize_board_init(struct dgnc_board *brd);
-static int dgnc_found_board(struct pci_dev *pdev, int id);
+static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id);
 static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
 static int dgnc_init_one(struct pci_dev *pdev,
@@ -274,6 +274,7 @@ failed_class:
 static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
int rc;
+   struct dgnc_board *brd;
 
/* wake up and enable device */
rc = pci_enable_device(pdev);
@@ -281,9 +282,43 @@ static int dgnc_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (rc)
return -EIO;
 
-   rc = dgnc_found_board(pdev, ent->driver_data);
-   if (rc == 0)
-   dgnc_num_boards++;
+   brd = dgnc_found_board(pdev, ent->driver_data);
+   if (IS_ERR(brd))
+   return PTR_ERR(brd);
+
+   /*
+* Do tty device initialization.
+*/
+
+   rc = dgnc_tty_register(brd);
+   if (rc < 0) {
+   pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc);
+   goto failed;
+   }
+
+   rc = dgnc_finalize_board_init(brd);
+   if (rc < 0) {
+   pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
+   goto failed;
+   }
+
+   rc = dgnc_tty_init(brd);
+   if (rc < 0) {
+   pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
+   goto failed;
+   }
+
+   brd->state = BOARD_READY;
+   brd->dpastatus = BD_RUNNING;
+
+   dgnc_create_ports_sysfiles(brd);
+
+   dgnc_board[dgnc_num_boards++] = brd;
+
+   return 0;
+
+failed:
+   kfree(brd);
 
return rc;
 }
@@ -345,7 +380,7 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
  *
  * A board has been found, init it.
  */
-static int dgnc_found_board(struct pci_dev *pdev, int id)
+static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id)
 {
struct dgnc_board *brd;
unsigned int pci_irq;
@@ -355,7 +390,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
/* get the board structure and prep it */
brd = kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd)
-   return -ENOMEM;
+   return ERR_PTR(-ENOMEM);
 
/* store the info for the board we've found */
brd->magic = DGNC_BOARD_MAGIC;
@@ -505,33 +540,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
goto failed;
}
 
-   /*
-* Do tty device initialization.
-*/
-
-   rc = dgnc_tty_register(brd);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc);
-   goto failed;
-   }
-
-   rc = dgnc_finalize_board_init(brd);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
-   goto failed;
-   }
-
-   rc = dgnc_tty_init(brd);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
-   goto failed;
-   }
-
-   brd->state = BOARD_READY;
-   brd->dpastatus = BD_RUNNING;
-
-   dgnc_create_ports_sysfiles(brd);
-
/* init our poll helper tasklet */
tasklet_init(&brd->helper_tasklet,
 brd->bd_ops->tasklet,
@@ -539,15 +547,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(&brd->state_wait);
 
-   dgnc_board[dgnc_num_boards] = brd;
-
-   return 0;
+   return brd;
 
 failed:
-   dgnc_tty_uninit(brd);
kfree(brd);
 
-   return rc;
+   return ERR_PTR(rc);
 }
 
 static int dgnc_finalize_board_init(struct dgnc_board *brd)
-- 
1.9.1



[PATCH 06/11 RESEND] staging: dgnc: introduce the dgnc_tty_unregister()

2016-09-25 Thread Daeseok Youn
The dgnc_tty_unregister() will be called when
the dgnc_tty_register() is failed.

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

 drivers/staging/dgnc/dgnc_driver.c | 7 +--
 drivers/staging/dgnc/dgnc_tty.c| 8 
 drivers/staging/dgnc/dgnc_tty.h| 1 +
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index a95d13c..ffe55a2 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -299,13 +299,13 @@ static int dgnc_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
rc = dgnc_finalize_board_init(brd);
if (rc < 0) {
pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
-   goto failed;
+   goto unregister_tty;
}
 
rc = dgnc_tty_init(brd);
if (rc < 0) {
pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
-   goto failed;
+   goto unregister_tty;
}
 
brd->state = BOARD_READY;
@@ -317,6 +317,9 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
return 0;
 
+unregister_tty:
+   dgnc_tty_unregister(brd);
+
 failed:
kfree(brd);
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index fd46ef0..893f473 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -273,6 +273,14 @@ free_serial_driver:
return rc;
 }
 
+void dgnc_tty_unregister(struct dgnc_board *brd)
+{
+   tty_unregister_driver(brd->print_driver);
+   tty_unregister_driver(brd->serial_driver);
+   put_tty_driver(brd->print_driver);
+   put_tty_driver(brd->serial_driver);
+}
+
 /*
  * dgnc_tty_init()
  *
diff --git a/drivers/staging/dgnc/dgnc_tty.h b/drivers/staging/dgnc/dgnc_tty.h
index 21d3369..f065c8f 100644
--- a/drivers/staging/dgnc/dgnc_tty.h
+++ b/drivers/staging/dgnc/dgnc_tty.h
@@ -19,6 +19,7 @@
 #include "dgnc_driver.h"
 
 intdgnc_tty_register(struct dgnc_board *brd);
+void dgnc_tty_unregister(struct dgnc_board *brd);
 
 intdgnc_tty_preinit(void);
 int dgnc_tty_init(struct dgnc_board *);
-- 
1.9.1



[PATCH 07/11 V2 RESEND] staging: dgnc: rename dgnc_finalize_board_init() to dgnc_request_irq()

2016-09-25 Thread Daeseok Youn
The dgnc_finalize_board_init() function has only job for
requesting the IRQ. It should be renamed to dgnc_request_irq()

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

V2: The subject line was cut off, I put it completely and update
change log.

 drivers/staging/dgnc/dgnc_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index ffe55a2..70e68b5 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -37,7 +37,7 @@ MODULE_SUPPORTED_DEVICE("dgnc");
  *
  */
 static int dgnc_start(void);
-static int dgnc_finalize_board_init(struct dgnc_board *brd);
+static int dgnc_request_irq(struct dgnc_board *brd);
 static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id);
 static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
@@ -296,7 +296,7 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
goto failed;
}
 
-   rc = dgnc_finalize_board_init(brd);
+   rc = dgnc_request_irq(brd);
if (rc < 0) {
pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
goto unregister_tty;
@@ -558,7 +558,7 @@ failed:
return ERR_PTR(rc);
 }
 
-static int dgnc_finalize_board_init(struct dgnc_board *brd)
+static int dgnc_request_irq(struct dgnc_board *brd)
 {
int rc = 0;
 
-- 
1.9.1



[PATCH 08/11 RESEND] staging: dgnc: introduce the dgnc_free_irq()

2016-09-25 Thread Daeseok Youn
The dgnc_free_irq() will free the requested IRQ from
the dgnc_request_irq().

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

 drivers/staging/dgnc/dgnc_driver.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 70e68b5..81ce5c4 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -38,6 +38,7 @@ MODULE_SUPPORTED_DEVICE("dgnc");
  */
 static int dgnc_start(void);
 static int dgnc_request_irq(struct dgnc_board *brd);
+static void dgnc_free_irq(struct dgnc_board *brd);
 static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id);
 static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
@@ -305,7 +306,7 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
rc = dgnc_tty_init(brd);
if (rc < 0) {
pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
-   goto unregister_tty;
+   goto free_irq;
}
 
brd->state = BOARD_READY;
@@ -317,6 +318,8 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
return 0;
 
+free_irq:
+   dgnc_free_irq(brd);
 unregister_tty:
dgnc_tty_unregister(brd);
 
@@ -577,6 +580,12 @@ static int dgnc_request_irq(struct dgnc_board *brd)
return rc;
 }
 
+static void dgnc_free_irq(struct dgnc_board *brd)
+{
+   if (brd->irq)
+   free_irq(brd->irq, brd);
+}
+
 /*
  * Remap PCI memory.
  */
-- 
1.9.1



[PATCH 09/11 V2 RESEND] staging: dgnc: rename dgnc_tty_uninit() to dgnc_cleanup_tty()

2016-09-25 Thread Daeseok Youn
The dgnc_tty_uninit() doesn't match with dgnc_tty_init() at all.
And also the dgnc_cleanup_tty() is only called for exiting the module.

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

V2: The subject line was cut off, I put it completely and update
change log.

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

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 81ce5c4..fd372d3 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -147,7 +147,7 @@ static void cleanup(bool sysfiles)
 
for (i = 0; i < dgnc_num_boards; ++i) {
dgnc_remove_ports_sysfiles(dgnc_board[i]);
-   dgnc_tty_uninit(dgnc_board[i]);
+   dgnc_cleanup_tty(dgnc_board[i]);
dgnc_cleanup_board(dgnc_board[i]);
}
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 893f473..5befd28 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -387,12 +387,12 @@ void dgnc_tty_post_uninit(void)
 }
 
 /*
- * dgnc_tty_uninit()
+ * dgnc_cleanup_tty()
  *
  * Uninitialize the TTY portion of this driver.  Free all memory and
  * resources.
  */
-void dgnc_tty_uninit(struct dgnc_board *brd)
+void dgnc_cleanup_tty(struct dgnc_board *brd)
 {
int i = 0;
 
diff --git a/drivers/staging/dgnc/dgnc_tty.h b/drivers/staging/dgnc/dgnc_tty.h
index f065c8f..24c9a41 100644
--- a/drivers/staging/dgnc/dgnc_tty.h
+++ b/drivers/staging/dgnc/dgnc_tty.h
@@ -25,7 +25,7 @@ int   dgnc_tty_preinit(void);
 int dgnc_tty_init(struct dgnc_board *);
 
 void   dgnc_tty_post_uninit(void);
-void   dgnc_tty_uninit(struct dgnc_board *);
+void   dgnc_cleanup_tty(struct dgnc_board *);
 
 void   dgnc_input(struct channel_t *ch);
 void   dgnc_carrier(struct channel_t *ch);
-- 
1.9.1



[PATCH 10/11 RESEND] staging: dgnc: remove useless variables

2016-09-25 Thread Daeseok Youn
The dgnc_major_serial_registered and dgnc_major_serial_registered
do not need to use to check whether the tty driver is registered or not.
These variables are used only in dgnc_cleanup_tty() function,
This function will be called normally with initialized board structure.
It means the dgnc_cleanup_tty() cannot be called with unregistered tty.

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

 drivers/staging/dgnc/dgnc_driver.h |  3 --
 drivers/staging/dgnc/dgnc_tty.c| 64 +++---
 2 files changed, 25 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 747a100..8792026 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -203,9 +203,6 @@ struct dgnc_board {
struct tty_driver *print_driver;
charprint_name[200];
 
-   booldgnc_major_serial_registered;
-   booldgnc_major_transparent_print_registered;
-
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 5befd28..ba724ab 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -204,15 +204,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
 */
tty_set_operations(brd->serial_driver, &dgnc_tty_ops);
 
-   if (!brd->dgnc_major_serial_registered) {
-   /* Register tty devices */
-   rc = tty_register_driver(brd->serial_driver);
-   if (rc < 0) {
-   dev_dbg(&brd->pdev->dev,
-   "Can't register tty device (%d)\n", rc);
-   goto free_serial_driver;
-   }
-   brd->dgnc_major_serial_registered = true;
+   rc = tty_register_driver(brd->serial_driver);
+   if (rc < 0) {
+   dev_dbg(&brd->pdev->dev,
+   "Can't register tty device (%d)\n", rc);
+   goto free_serial_driver;
}
 
/*
@@ -247,16 +243,12 @@ int dgnc_tty_register(struct dgnc_board *brd)
 */
tty_set_operations(brd->print_driver, &dgnc_tty_ops);
 
-   if (!brd->dgnc_major_transparent_print_registered) {
-   /* Register Transparent Print devices */
-   rc = tty_register_driver(brd->print_driver);
-   if (rc < 0) {
-   dev_dbg(&brd->pdev->dev,
-   "Can't register Transparent Print device(%d)\n",
-   rc);
-   goto free_print_driver;
-   }
-   brd->dgnc_major_transparent_print_registered = true;
+   rc = tty_register_driver(brd->print_driver);
+   if (rc < 0) {
+   dev_dbg(&brd->pdev->dev,
+   "Can't register Transparent Print device(%d)\n",
+   rc);
+   goto free_print_driver;
}
 
dgnc_BoardsByMajor[brd->serial_driver->major] = brd;
@@ -396,29 +388,23 @@ void dgnc_cleanup_tty(struct dgnc_board *brd)
 {
int i = 0;
 
-   if (brd->dgnc_major_serial_registered) {
-   dgnc_BoardsByMajor[brd->serial_driver->major] = NULL;
-   for (i = 0; i < brd->nasync; i++) {
-   if (brd->channels[i])
-   dgnc_remove_tty_sysfs(brd->channels[i]->
- ch_tun.un_sysfs);
-   tty_unregister_device(brd->serial_driver, i);
-   }
-   tty_unregister_driver(brd->serial_driver);
-   brd->dgnc_major_serial_registered = false;
+   dgnc_BoardsByMajor[brd->serial_driver->major] = NULL;
+   for (i = 0; i < brd->nasync; i++) {
+   if (brd->channels[i])
+   dgnc_remove_tty_sysfs(brd->channels[i]->
+ ch_tun.un_sysfs);
+   tty_unregister_device(brd->serial_driver, i);
}
+   tty_unregister_driver(brd->serial_driver);
 
-   if (brd->dgnc_major_transparent_print_registered) {
-   dgnc_BoardsByMajor[brd->print_driver->major] = NULL;
-   for (i = 0; i < brd->nasync; i++) {
-   if (brd->channels[i])
-   dgnc_remove_tty_sysfs(brd->channels[i]->
- ch_pun.un_sysfs);
-   tty_unregister_device(brd->print_driv

[PATCH 11/11 RESEND] staging: dgnc: introduce find_board_by_major()

2016-09-25 Thread Daeseok Youn
It was used to get a board structure with dgnc_BoardsByMajor array.
But this driver already has the array for managing initialized board
as dgap_board[]. It can be used for searching the board structure
by major number.

Signed-off-by: Daeseok Youn 
---
RESEND: send the whole series again. Because I missed some patches
when the V2 patches sent.

 drivers/staging/dgnc/dgnc_tty.c | 25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index ba724ab..a486a86 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -45,7 +45,6 @@
 /*
  * internal variables
  */
-static struct dgnc_board   *dgnc_BoardsByMajor[256];
 static unsigned char   *dgnc_TmpWriteBuf;
 
 /*
@@ -251,8 +250,6 @@ int dgnc_tty_register(struct dgnc_board *brd)
goto free_print_driver;
}
 
-   dgnc_BoardsByMajor[brd->serial_driver->major] = brd;
-
return 0;
 
 free_print_driver:
@@ -388,7 +385,6 @@ void dgnc_cleanup_tty(struct dgnc_board *brd)
 {
int i = 0;
 
-   dgnc_BoardsByMajor[brd->serial_driver->major] = NULL;
for (i = 0; i < brd->nasync; i++) {
if (brd->channels[i])
dgnc_remove_tty_sysfs(brd->channels[i]->
@@ -397,7 +393,6 @@ void dgnc_cleanup_tty(struct dgnc_board *brd)
}
tty_unregister_driver(brd->serial_driver);
 
-   dgnc_BoardsByMajor[brd->print_driver->major] = NULL;
for (i = 0; i < brd->nasync; i++) {
if (brd->channels[i])
dgnc_remove_tty_sysfs(brd->channels[i]->
@@ -935,6 +930,24 @@ void dgnc_wakeup_writes(struct channel_t *ch)
spin_unlock_irqrestore(&ch->ch_lock, flags);
 }
 
+struct dgnc_board *find_board_by_major(unsigned int major)
+{
+   int i;
+
+   for (i = 0; i < MAXBOARDS; i++) {
+   struct dgnc_board *brd = dgnc_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
@@ -964,7 +977,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct 
file *file)
return -ENXIO;
 
/* Get board pointer from our array of majors we have allocated */
-   brd = dgnc_BoardsByMajor[major];
+   brd = find_board_by_major(major);
if (!brd)
return -ENXIO;
 
-- 
1.9.1



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

2014-12-25 Thread Daeseok Youn
Signed-off-by: Daeseok Youn 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[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 
Signed-off-by: Daeseok Youn 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] scsi: aic7xxx: Use kzalloc instead of kmalloc/memset

2015-01-28 Thread Daeseok Youn
Signed-off-by: Daeseok Youn 
---
 drivers/scsi/aic7xxx/aic7xxx_core.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c 
b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 10172a3..7f34d25 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -4464,10 +4464,9 @@ ahc_softc_init(struct ahc_softc *ahc)
ahc->pause = ahc->unpause | PAUSE; 
/* XXX The shared scb data stuff should be deprecated */
if (ahc->scb_data == NULL) {
-   ahc->scb_data = kmalloc(sizeof(*ahc->scb_data), GFP_ATOMIC);
+   ahc->scb_data = kzalloc(sizeof(*ahc->scb_data), GFP_ATOMIC);
if (ahc->scb_data == NULL)
return (ENOMEM);
-   memset(ahc->scb_data, 0, sizeof(*ahc->scb_data));
}
 
return (0);
@@ -4780,10 +4779,9 @@ ahc_init_scbdata(struct ahc_softc *ahc)
SLIST_INIT(&scb_data->sg_maps);
 
/* Allocate SCB resources */
-   scb_data->scbarray = kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, 
GFP_ATOMIC);
+   scb_data->scbarray = kzalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, 
GFP_ATOMIC);
if (scb_data->scbarray == NULL)
return (ENOMEM);
-   memset(scb_data->scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX_ALLOC);
 
/* Determine the number of hardware SCBs and initialize them */
 
@@ -7558,14 +7556,13 @@ ahc_handle_en_lun(struct ahc_softc *ahc, struct cam_sim 
*sim, union ccb *ccb)
return;
}
}
-   lstate = kmalloc(sizeof(*lstate), GFP_ATOMIC);
+   lstate = kzalloc(sizeof(*lstate), GFP_ATOMIC);
if (lstate == NULL) {
xpt_print_path(ccb->ccb_h.path);
printk("Couldn't allocate lstate\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
-   memset(lstate, 0, sizeof(*lstate));
status = xpt_create_path(&lstate->path, /*periph*/NULL,
 xpt_path_path_id(ccb->ccb_h.path),
 xpt_path_target_id(ccb->ccb_h.path),
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] scsi: aic79xx: Use kzalloc instead of kmalloc/memset

2015-01-28 Thread Daeseok Youn
Signed-off-by: Daeseok Youn 
---
 drivers/scsi/aic7xxx/aic79xx_core.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c 
b/drivers/scsi/aic7xxx/aic79xx_core.c
index 97f2acc..109e2c9 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -10437,14 +10437,13 @@ ahd_handle_en_lun(struct ahd_softc *ahd, struct 
cam_sim *sim, union ccb *ccb)
return;
}
}
-   lstate = kmalloc(sizeof(*lstate), GFP_ATOMIC);
+   lstate = kzalloc(sizeof(*lstate), GFP_ATOMIC);
if (lstate == NULL) {
xpt_print_path(ccb->ccb_h.path);
printk("Couldn't allocate lstate\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
-   memset(lstate, 0, sizeof(*lstate));
status = xpt_create_path(&lstate->path, /*periph*/NULL,
 xpt_path_path_id(ccb->ccb_h.path),
 xpt_path_target_id(ccb->ccb_h.path),
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] scsi: aic7xxx: use kzalloc instead of kmalloc/memset

2015-01-28 Thread Daeseok Youn
Signed-off-by: Daeseok Youn 
---
 drivers/scsi/aic7xxx/aic7xxx_osm.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c 
b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 8836011..a2f2c77 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -1214,10 +1214,9 @@ ahc_platform_alloc(struct ahc_softc *ahc, void 
*platform_arg)
 {
 
ahc->platform_data =
-   kmalloc(sizeof(struct ahc_platform_data), GFP_ATOMIC);
+   kzalloc(sizeof(struct ahc_platform_data), GFP_ATOMIC);
if (ahc->platform_data == NULL)
return (ENOMEM);
-   memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data));
ahc->platform_data->irq = AHC_LINUX_NOIRQ;
ahc_lockinit(ahc);
ahc->seltime = (aic7xxx_seltime & 0x3) << 4;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] scsi: missing iounmap for mvi->regs_ex

2015-01-28 Thread Daeseok Youn
It also need to call iounmap() when it fails to get res_start and
res_len from pci_resource_start{len}(pdev, bar).

Signed-off-by: Daeseok Youn 
---
 drivers/scsi/mvsas/mv_init.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 53030b0..2508db2 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -348,15 +348,15 @@ int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex)
else
mvi->regs = ioremap_nocache(res_start, res_len);
 
-   if (!mvi->regs) {
-   if (mvi->regs_ex && (res_flag_ex & IORESOURCE_MEM))
-   iounmap(mvi->regs_ex);
-   mvi->regs_ex = NULL;
+   if (!mvi->regs)
goto err_out;
-   }
 
return 0;
 err_out:
+   if (mvi->regs_ex && (res_flag_ex & IORESOURCE_MEM))
+   iounmap(mvi->regs_ex);
+   mvi->regs_ex = NULL;
+
return -1;
 }
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Ocfs2-devel] [PATCH 1/4 V2] ocfs2: use retval instead of status for checking error

2015-03-19 Thread DaeSeok Youn
2015-03-19 15:24 GMT+09:00 Joseph Qi :
> Looks good to me.
>
> On 2015/2/28 7:48, Daeseok Youn wrote:
>> The use of 'status' in __ocfs2_add_entry() can return wrong
>> status when some functions are failed.
>>
>> If ocfs2_journal_access_db() in __ocfs2_add_entry() is failed,
>> that status is saved to 'status' but return variable is 'retval'
>> which is saved 'success' status. In case of this,  __ocfs2_add_entry()
>> is failed but can be returned as 'success'.
>>
>> So replace 'status' with 'retval'.
>>
>> Signed-off-by: Daeseok Youn 
>
> Reviewed-by: Joseph Qi 
Hi, Joseph.

Thanks for review this patch. I have actually tried to set this file
system on my machine with qemu but I didn't success, yet.

Regards,
Daeseok Youn.

>> ---
>> V2 : update changelog
>>
>>  fs/ocfs2/dir.c |   12 ++--
>>  1 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
>> index b08050b..1478a50 100644
>> --- a/fs/ocfs2/dir.c
>> +++ b/fs/ocfs2/dir.c
>> @@ -1617,7 +1617,7 @@ int __ocfs2_add_entry(handle_t *handle,
>>   struct ocfs2_dir_entry *de, *de1;
>>   struct ocfs2_dinode *di = (struct ocfs2_dinode *)parent_fe_bh->b_data;
>>   struct super_block *sb = dir->i_sb;
>> - int retval, status;
>> + int retval;
>>   unsigned int size = sb->s_blocksize;
>>   struct buffer_head *insert_bh = lookup->dl_leaf_bh;
>>   char *data_start = insert_bh->b_data;
>> @@ -1695,22 +1695,22 @@ int __ocfs2_add_entry(handle_t *handle,
>>   }
>>
>>   if (insert_bh == parent_fe_bh)
>> - status = ocfs2_journal_access_di(handle,
>> + retval = ocfs2_journal_access_di(handle,
>>
>> INODE_CACHE(dir),
>>insert_bh,
>>
>> OCFS2_JOURNAL_ACCESS_WRITE);
>>   else {
>> - status = ocfs2_journal_access_db(handle,
>> + retval = ocfs2_journal_access_db(handle,
>>
>> INODE_CACHE(dir),
>>insert_bh,
>> OCFS2_JOURNAL_ACCESS_WRITE);
>>
>>   if (ocfs2_dir_indexed(dir)) {
>> - status = ocfs2_dx_dir_insert(dir,
>> + retval = ocfs2_dx_dir_insert(dir,
>>   handle,
>>   lookup);
>> - if (status) {
>> - mlog_errno(status);
>> + if (retval) {
>> + mlog_errno(retval);
>>   goto bail;
>>   }
>>   }
>>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Ocfs2-devel] [PATCH 2/4 RESEND] ocfs2: remove extra mlog_errno() call in __ocfs2_add_entry()

2015-03-19 Thread DaeSeok Youn
OK.

If i want to clean up mlog() call twice, mlog() in " bail" can be
removed, right?

Thanks.
Regards,
Daeseok Youn

2015-03-19 19:45 GMT+09:00 Joseph Qi :
> On 2015/2/28 7:49, Daeseok Youn wrote:
>> Signed-off-by: Daeseok Youn 
>> ---
>> RESEND: this patch is rebased by 1/4
>>
>>  fs/ocfs2/dir.c |8 ++--
>>  1 files changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
>> index 1478a50..c1ab24f 100644
>> --- a/fs/ocfs2/dir.c
>> +++ b/fs/ocfs2/dir.c
>> @@ -1689,10 +1689,8 @@ int __ocfs2_add_entry(handle_t *handle,
>>   if (ocfs2_dirent_would_fit(de, rec_len)) {
>>   dir->i_mtime = dir->i_ctime = CURRENT_TIME;
>>   retval = ocfs2_mark_inode_dirty(handle, dir, 
>> parent_fe_bh);
>> - if (retval < 0) {
>> - mlog_errno(retval);
>> + if (retval < 0)
>>   goto bail;
>> - }
>>
>>   if (insert_bh == parent_fe_bh)
>>   retval = ocfs2_journal_access_di(handle,
>> @@ -1709,10 +1707,8 @@ int __ocfs2_add_entry(handle_t *handle,
>>   retval = ocfs2_dx_dir_insert(dir,
>>   handle,
>>   lookup);
>> - if (retval) {
>> - mlog_errno(retval);
>> + if (retval)
>>   goto bail;
>> - }
>>   }
>>   }
>>
>>
> IMO, these two mlogs are not "extra" because we can directly know the
> cause if error occurs.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Ocfs2-devel] [PATCH 3/4 RESEND] ocfs2: need to handle error for ocfs2_journal_access_di() call

2015-03-19 Thread DaeSeok Youn
OK.

I will send this patch again.
This patch will be based on https://lkml.org/lkml/2015/2/27/655

thanks

regards,
Daeseok Youn

2015-03-19 20:00 GMT+09:00 Joseph Qi :
> On 2015/2/28 7:51, Daeseok Youn wrote:
>> There is no error handle when ocfs2_journal_access_di() is failed.
>> And also it doesn't need to call ocfs2_dx_dir_insert() when
>> ocfs2_journal_access_db() is failed.
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>> RESEND: this patch rebased by 1/4
>>
>>  fs/ocfs2/dir.c |8 
>>  1 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
>> index c1ab24f..c63f2b6 100644
>> --- a/fs/ocfs2/dir.c
>> +++ b/fs/ocfs2/dir.c
>> @@ -1703,15 +1703,15 @@ int __ocfs2_add_entry(handle_t *handle,
>>insert_bh,
>> OCFS2_JOURNAL_ACCESS_WRITE);
>>
>> - if (ocfs2_dir_indexed(dir)) {
>> + if (!retval && ocfs2_dir_indexed(dir))
>>   retval = ocfs2_dx_dir_insert(dir,
>>   handle,
>>   lookup);
>> - if (retval)
>> - goto bail;
>> - }
>>   }
>>
>> + if (retval)
>> + goto bail;
>> +
>>   /* By now the buffer is marked for journaling */
>>   offset += le16_to_cpu(de->rec_len);
>>   if (le64_to_cpu(de->inode)) {
>>
> I agree with you that we should do the corresponding check.
> But I don't think we need remove the mlog as described in my previous
> mail.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ocfs2: use retval instead of status for checking error

2015-04-22 Thread DaeSeok Youn
Hi, Joseph.

2015-04-23 9:49 GMT+09:00 Joseph Qi :
> On 2015/4/19 13:43, Daeseok Youn wrote:
>> The use of 'status' in __ocfs2_add_entry() can return wrong
>> value. Some functions' return value in __ocfs2_add_entry(),
>> i.e ocfs2_journal_access_di() is saved to 'status'.
>> But 'status' is not used in 'bail' label for returning result
>> of __ocfs2_add_entry().
>>
>> So use retval instead of status.
>>
>> Signed-off-by: Daeseok Youn 
>
> Reviewed-by: Joseph Qi 
Thanks for review.

regards,
Daeseok Youn.
>> ---
>> This patch was came from 'https://lkml.org/lkml/2015/2/27/655'
>> This patch was needed to test but I didn't have any environment
>> for testing ocfs2 filesystem. But I have one, now.
>> (I'm too busy to make this enviroment. And qemu for this fs is difficult
>>  for me. :-(, sorry for that)
>>
>> Briefly how to set my environment for testing this fs with qemu.
>> 1. Getting and building linux kernel with linux-next branch for x86_64 qemu.
>>And also options of ocfs2 related are enabled(built-in)
>> 2. Makes own root file system with 'buildroot' project.
>> 3. Getting and building ocfs2-tools.
>>   Then binaries after building this tool are moved my rootfs.
>> 4. Makes dummy disk image(5G) which will be formatted in qemu.
>> 5. Booting qemu with rootfs image and dummy disk image.
>> 6. mkfs.ocfs2 --fs-feature=local 
>>   this maybe possilbe to mount standalone mode.
>> 7. tunefs.ocfs2  --fs-features=indexed-dirs,noinline-data 
>> 8. make a cluster and one node
>>   use o2cb_ctl tool.
>> 9. o2cb service load and initialize
>>   # /etc/init.d/o2cb load && /etc/init.d/o2cb configure
>>   # /etc/init.d/o2cb online
>> 10. mount ocfs2
>>   # mount.ocfs2  
>>
>> And use GDB for debugging my patch path.
>> Connect gdb with qemu and add breakpoint in __ocfs2_add_entry() of 
>> fs/ocfs2/dir.c
>>
>> And test my patch.
>> # cd 
>> # mkdir 
>>
>> This how-to is not written all my work, just briefly I said.
>>
>>  fs/ocfs2/dir.c |   20 ++--
>>  1 files changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
>> index 990e8f7..a9513ff 100644
>> --- a/fs/ocfs2/dir.c
>> +++ b/fs/ocfs2/dir.c
>> @@ -1607,7 +1607,7 @@ int __ocfs2_add_entry(handle_t *handle,
>>   struct ocfs2_dir_entry *de, *de1;
>>   struct ocfs2_dinode *di = (struct ocfs2_dinode *)parent_fe_bh->b_data;
>>   struct super_block *sb = dir->i_sb;
>> - int retval, status;
>> + int retval;
>>   unsigned int size = sb->s_blocksize;
>>   struct buffer_head *insert_bh = lookup->dl_leaf_bh;
>>   char *data_start = insert_bh->b_data;
>> @@ -1685,25 +1685,25 @@ int __ocfs2_add_entry(handle_t *handle,
>>   }
>>
>>   if (insert_bh == parent_fe_bh)
>> - status = ocfs2_journal_access_di(handle,
>> + retval = ocfs2_journal_access_di(handle,
>>
>> INODE_CACHE(dir),
>>insert_bh,
>>
>> OCFS2_JOURNAL_ACCESS_WRITE);
>>   else {
>> - status = ocfs2_journal_access_db(handle,
>> + retval = ocfs2_journal_access_db(handle,
>>
>> INODE_CACHE(dir),
>>insert_bh,
>> OCFS2_JOURNAL_ACCESS_WRITE);
>>
>> - if (ocfs2_dir_indexed(dir)) {
>> - status = ocfs2_dx_dir_insert(dir,
>> + if (!retval && ocfs2_dir_indexed(dir))
>> + retval = ocfs2_dx_dir_insert(dir,
>>   handle,
>>   lookup);
>> - if (status) {
>> - mlog_errno(status);
>> - goto bail;
>> - }
>> - }
>> + }
>> +
>> + if (retval) {
>> + mlog_errno(retval);
>> + goto bail;
>>   }
>>
>>   /* By now the buffer is marked for journaling */
>>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ocfs2: use retval instead of status for checking error

2015-04-23 Thread DaeSeok Youn
Hi, Andrew.

Is there problem this patch to merge?
If you care about mlog_errno() cleanup, I will send another patch for that.

And also if you have any reasons this patch has not been taken,
please let me know. I will fix and test again.

Thanks.

regards,
Daeseok Youn/

2015-04-23 9:49 GMT+09:00 Joseph Qi :
> On 2015/4/19 13:43, Daeseok Youn wrote:
>> The use of 'status' in __ocfs2_add_entry() can return wrong
>> value. Some functions' return value in __ocfs2_add_entry(),
>> i.e ocfs2_journal_access_di() is saved to 'status'.
>> But 'status' is not used in 'bail' label for returning result
>> of __ocfs2_add_entry().
>>
>> So use retval instead of status.
>>
>> Signed-off-by: Daeseok Youn 
>
> Reviewed-by: Joseph Qi 
>> ---
>> This patch was came from 'https://lkml.org/lkml/2015/2/27/655'
>> This patch was needed to test but I didn't have any environment
>> for testing ocfs2 filesystem. But I have one, now.
>> (I'm too busy to make this enviroment. And qemu for this fs is difficult
>>  for me. :-(, sorry for that)
>>
>> Briefly how to set my environment for testing this fs with qemu.
>> 1. Getting and building linux kernel with linux-next branch for x86_64 qemu.
>>And also options of ocfs2 related are enabled(built-in)
>> 2. Makes own root file system with 'buildroot' project.
>> 3. Getting and building ocfs2-tools.
>>   Then binaries after building this tool are moved my rootfs.
>> 4. Makes dummy disk image(5G) which will be formatted in qemu.
>> 5. Booting qemu with rootfs image and dummy disk image.
>> 6. mkfs.ocfs2 --fs-feature=local 
>>   this maybe possilbe to mount standalone mode.
>> 7. tunefs.ocfs2  --fs-features=indexed-dirs,noinline-data 
>> 8. make a cluster and one node
>>   use o2cb_ctl tool.
>> 9. o2cb service load and initialize
>>   # /etc/init.d/o2cb load && /etc/init.d/o2cb configure
>>   # /etc/init.d/o2cb online
>> 10. mount ocfs2
>>   # mount.ocfs2  
>>
>> And use GDB for debugging my patch path.
>> Connect gdb with qemu and add breakpoint in __ocfs2_add_entry() of 
>> fs/ocfs2/dir.c
>>
>> And test my patch.
>> # cd 
>> # mkdir 
>>
>> This how-to is not written all my work, just briefly I said.
>>
>>  fs/ocfs2/dir.c |   20 ++--
>>  1 files changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
>> index 990e8f7..a9513ff 100644
>> --- a/fs/ocfs2/dir.c
>> +++ b/fs/ocfs2/dir.c
>> @@ -1607,7 +1607,7 @@ int __ocfs2_add_entry(handle_t *handle,
>>   struct ocfs2_dir_entry *de, *de1;
>>   struct ocfs2_dinode *di = (struct ocfs2_dinode *)parent_fe_bh->b_data;
>>   struct super_block *sb = dir->i_sb;
>> - int retval, status;
>> + int retval;
>>   unsigned int size = sb->s_blocksize;
>>   struct buffer_head *insert_bh = lookup->dl_leaf_bh;
>>   char *data_start = insert_bh->b_data;
>> @@ -1685,25 +1685,25 @@ int __ocfs2_add_entry(handle_t *handle,
>>   }
>>
>>   if (insert_bh == parent_fe_bh)
>> - status = ocfs2_journal_access_di(handle,
>> + retval = ocfs2_journal_access_di(handle,
>>
>> INODE_CACHE(dir),
>>insert_bh,
>>
>> OCFS2_JOURNAL_ACCESS_WRITE);
>>   else {
>> - status = ocfs2_journal_access_db(handle,
>> + retval = ocfs2_journal_access_db(handle,
>>
>> INODE_CACHE(dir),
>>insert_bh,
>> OCFS2_JOURNAL_ACCESS_WRITE);
>>
>> - if (ocfs2_dir_indexed(dir)) {
>> - status = ocfs2_dx_dir_insert(dir,
>> + if (!retval && ocfs2_dir_indexed(dir))
>> + retval = ocfs2_dx_dir_insert(dir,
>>   handle,
>>   lookup);
>> - if (status) {
>> - 

[PATCH RESEND] ocfs2: use retval instead of status for checking error

2015-04-23 Thread Daeseok Youn
The use of 'status' in __ocfs2_add_entry() can return wrong
value. Some functions' return value in __ocfs2_add_entry(),
i.e ocfs2_journal_access_di() is saved to 'status'.
But 'status' is not used in 'bail' label for returning result
of __ocfs2_add_entry().

So use retval instead of status.

Reviewed-by: Joseph Qi 
Signed-off-by: Daeseok Youn 
---
RESEND: missed my patch in ocfs2-devel mailing list so send it again
And also add 'Reviewed-by' line.

Previous sent message of my patch
This patch was came from 'https://lkml.org/lkml/2015/2/27/655'
This patch was needed to test but I didn't have any environment
for testing ocfs2 filesystem. But I have one, now.
(I'm too busy to make this enviroment. And qemu for this fs is difficult
  for me. :-(, sorry for that)

Briefly how to set my environment for testing this fs with qemu.
1. Getting and building linux kernel with linux-next branch for x86_64
qemu.
And also options of ocfs2 related are enabled(built-in)
2. Makes own root file system with 'buildroot' project.
3. Getting and building ocfs2-tools.
   Then binaries after building this tool are moved my rootfs.
4. Makes dummy disk image(5G) which will be formatted in qemu.
5. Booting qemu with rootfs image and dummy disk image.
6. mkfs.ocfs2 --fs-feature=local 
   this maybe possilbe to mount standalone mode.
7. tunefs.ocfs2  --fs-features=indexed-dirs,noinline-data 
8. make a cluster and one node
   use o2cb_ctl tool.
9. o2cb service load and initialize
  # /etc/init.d/o2cb load && /etc/init.d/o2cb configure
  # /etc/init.d/o2cb online
10. mount ocfs2
  # mount.ocfs2  

And use GDB for debugging my patch path.
Connect gdb with qemu and add breakpoint in __ocfs2_add_entry() of
fs/ocfs2/dir.c

And test my patch.
# cd 
# mkdir 

This how-to is not written all my work, just briefly I said.

 fs/ocfs2/dir.c |   20 ++--
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 990e8f7..a9513ff 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -1607,7 +1607,7 @@ int __ocfs2_add_entry(handle_t *handle,
struct ocfs2_dir_entry *de, *de1;
struct ocfs2_dinode *di = (struct ocfs2_dinode *)parent_fe_bh->b_data;
struct super_block *sb = dir->i_sb;
-   int retval, status;
+   int retval;
unsigned int size = sb->s_blocksize;
struct buffer_head *insert_bh = lookup->dl_leaf_bh;
char *data_start = insert_bh->b_data;
@@ -1685,25 +1685,25 @@ int __ocfs2_add_entry(handle_t *handle,
}
 
if (insert_bh == parent_fe_bh)
-   status = ocfs2_journal_access_di(handle,
+   retval = ocfs2_journal_access_di(handle,
 
INODE_CACHE(dir),
 insert_bh,
 
OCFS2_JOURNAL_ACCESS_WRITE);
else {
-   status = ocfs2_journal_access_db(handle,
+   retval = ocfs2_journal_access_db(handle,
 
INODE_CACHE(dir),
 insert_bh,
  OCFS2_JOURNAL_ACCESS_WRITE);
 
-   if (ocfs2_dir_indexed(dir)) {
-   status = ocfs2_dx_dir_insert(dir,
+   if (!retval && ocfs2_dir_indexed(dir))
+   retval = ocfs2_dx_dir_insert(dir,
handle,
lookup);
-   if (status) {
-   mlog_errno(status);
-   goto bail;
-   }
-   }
+   }
+
+   if (retval) {
+   mlog_errno(retval);
+   goto bail;
}
 
/* By now the buffer is marked for journaling */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RESEND] ocfs2: use retval instead of status for checking error

2015-04-28 Thread DaeSeok Youn
Hi, Andrew.

2015-04-24 10:45 GMT+09:00 Daeseok Youn :
> The use of 'status' in __ocfs2_add_entry() can return wrong
> value. Some functions' return value in __ocfs2_add_entry(),
> i.e ocfs2_journal_access_di() is saved to 'status'.
> But 'status' is not used in 'bail' label for returning result
> of __ocfs2_add_entry().
>
> So use retval instead of status.
>
> Reviewed-by: Joseph Qi 
> Signed-off-by: Daeseok Youn 

This patch was shown up to ocfs2 mailing list.
https://oss.oracle.com/pipermail/ocfs2-devel/2015-April/010757.html

please check for me.

If this patch has any problem, let me know.
Thanks.

regards,
Daeseok Youn.
> ---
> RESEND: missed my patch in ocfs2-devel mailing list so send it again
> And also add 'Reviewed-by' line.
>
> Previous sent message of my patch
> This patch was came from 'https://lkml.org/lkml/2015/2/27/655'
> This patch was needed to test but I didn't have any environment
> for testing ocfs2 filesystem. But I have one, now.
> (I'm too busy to make this enviroment. And qemu for this fs is difficult
>   for me. :-(, sorry for that)
>
> Briefly how to set my environment for testing this fs with qemu.
> 1. Getting and building linux kernel with linux-next branch for x86_64
> qemu.
> And also options of ocfs2 related are enabled(built-in)
> 2. Makes own root file system with 'buildroot' project.
> 3. Getting and building ocfs2-tools.
>Then binaries after building this tool are moved my rootfs.
> 4. Makes dummy disk image(5G) which will be formatted in qemu.
> 5. Booting qemu with rootfs image and dummy disk image.
> 6. mkfs.ocfs2 --fs-feature=local 
>this maybe possilbe to mount standalone mode.
> 7. tunefs.ocfs2  --fs-features=indexed-dirs,noinline-data 
> 8. make a cluster and one node
>use o2cb_ctl tool.
> 9. o2cb service load and initialize
>   # /etc/init.d/o2cb load && /etc/init.d/o2cb configure
>   # /etc/init.d/o2cb online
> 10. mount ocfs2
>   # mount.ocfs2  
>
> And use GDB for debugging my patch path.
> Connect gdb with qemu and add breakpoint in __ocfs2_add_entry() of
> fs/ocfs2/dir.c
>
> And test my patch.
> # cd 
> # mkdir 
>
> This how-to is not written all my work, just briefly I said.
>
>  fs/ocfs2/dir.c |   20 ++--
>  1 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
> index 990e8f7..a9513ff 100644
> --- a/fs/ocfs2/dir.c
> +++ b/fs/ocfs2/dir.c
> @@ -1607,7 +1607,7 @@ int __ocfs2_add_entry(handle_t *handle,
> struct ocfs2_dir_entry *de, *de1;
> struct ocfs2_dinode *di = (struct ocfs2_dinode *)parent_fe_bh->b_data;
> struct super_block *sb = dir->i_sb;
> -   int retval, status;
> +   int retval;
> unsigned int size = sb->s_blocksize;
> struct buffer_head *insert_bh = lookup->dl_leaf_bh;
> char *data_start = insert_bh->b_data;
> @@ -1685,25 +1685,25 @@ int __ocfs2_add_entry(handle_t *handle,
> }
>
> if (insert_bh == parent_fe_bh)
> -   status = ocfs2_journal_access_di(handle,
> +   retval = ocfs2_journal_access_di(handle,
>  
> INODE_CACHE(dir),
>  insert_bh,
>  
> OCFS2_JOURNAL_ACCESS_WRITE);
> else {
> -   status = ocfs2_journal_access_db(handle,
> +   retval = ocfs2_journal_access_db(handle,
>  
> INODE_CACHE(dir),
>  insert_bh,
>   OCFS2_JOURNAL_ACCESS_WRITE);
>
> -   if (ocfs2_dir_indexed(dir)) {
> -   status = ocfs2_dx_dir_insert(dir,
> +   if (!retval && ocfs2_dir_indexed(dir))
> +   retval = ocfs2_dx_dir_insert(dir,
> handle,
> lookup);
> -   if (status) {
> -   mlog_errno(status);
> -   goto bail;
> -   }
> -   }
> +   }
> +
>

[PATCH] ocfs2: use retval instead of status for checking error

2015-04-18 Thread Daeseok Youn
The use of 'status' in __ocfs2_add_entry() can return wrong
value. Some functions' return value in __ocfs2_add_entry(),
i.e ocfs2_journal_access_di() is saved to 'status'.
But 'status' is not used in 'bail' label for returning result
of __ocfs2_add_entry().

So use retval instead of status.

Signed-off-by: Daeseok Youn 
---
This patch was came from 'https://lkml.org/lkml/2015/2/27/655'
This patch was needed to test but I didn't have any environment
for testing ocfs2 filesystem. But I have one, now.
(I'm too busy to make this enviroment. And qemu for this fs is difficult
 for me. :-(, sorry for that)

Briefly how to set my environment for testing this fs with qemu.
1. Getting and building linux kernel with linux-next branch for x86_64 qemu.
   And also options of ocfs2 related are enabled(built-in)
2. Makes own root file system with 'buildroot' project.
3. Getting and building ocfs2-tools.
  Then binaries after building this tool are moved my rootfs.
4. Makes dummy disk image(5G) which will be formatted in qemu.
5. Booting qemu with rootfs image and dummy disk image.
6. mkfs.ocfs2 --fs-feature=local 
  this maybe possilbe to mount standalone mode.
7. tunefs.ocfs2  --fs-features=indexed-dirs,noinline-data 
8. make a cluster and one node
  use o2cb_ctl tool.
9. o2cb service load and initialize
  # /etc/init.d/o2cb load && /etc/init.d/o2cb configure
  # /etc/init.d/o2cb online
10. mount ocfs2
  # mount.ocfs2  

And use GDB for debugging my patch path.
Connect gdb with qemu and add breakpoint in __ocfs2_add_entry() of 
fs/ocfs2/dir.c

And test my patch.
# cd 
# mkdir 

This how-to is not written all my work, just briefly I said.

 fs/ocfs2/dir.c |   20 ++--
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 990e8f7..a9513ff 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -1607,7 +1607,7 @@ int __ocfs2_add_entry(handle_t *handle,
struct ocfs2_dir_entry *de, *de1;
struct ocfs2_dinode *di = (struct ocfs2_dinode *)parent_fe_bh->b_data;
struct super_block *sb = dir->i_sb;
-   int retval, status;
+   int retval;
unsigned int size = sb->s_blocksize;
struct buffer_head *insert_bh = lookup->dl_leaf_bh;
char *data_start = insert_bh->b_data;
@@ -1685,25 +1685,25 @@ int __ocfs2_add_entry(handle_t *handle,
}
 
if (insert_bh == parent_fe_bh)
-   status = ocfs2_journal_access_di(handle,
+   retval = ocfs2_journal_access_di(handle,
 
INODE_CACHE(dir),
 insert_bh,
 
OCFS2_JOURNAL_ACCESS_WRITE);
else {
-   status = ocfs2_journal_access_db(handle,
+   retval = ocfs2_journal_access_db(handle,
 
INODE_CACHE(dir),
 insert_bh,
  OCFS2_JOURNAL_ACCESS_WRITE);
 
-   if (ocfs2_dir_indexed(dir)) {
-   status = ocfs2_dx_dir_insert(dir,
+   if (!retval && ocfs2_dir_indexed(dir))
+   retval = ocfs2_dx_dir_insert(dir,
handle,
lookup);
-   if (status) {
-   mlog_errno(status);
-   goto bail;
-   }
-   }
+   }
+
+   if (retval) {
+   mlog_errno(retval);
+   goto bail;
}
 
/* By now the buffer is marked for journaling */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mm: memblock: remove return value of memblock_free_all()

2021-01-13 Thread Daeseok Youn
No one checks the return value of memblock_free_all().
Make the return value void.

memblock_free_all() is used on mem_init() for each
architecture, and the total count of freed pages will be added
to _totalram_pages variable by calling totalram_pages_add().

so do not need to return total count of freed pages.

Signed-off-by: Daeseok Youn 
---
 include/linux/memblock.h | 2 +-
 mm/memblock.c| 6 +-
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 9c5cc95c7cee..076fda398dff 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -117,7 +117,7 @@ int memblock_mark_mirror(phys_addr_t base, phys_addr_t 
size);
 int memblock_mark_nomap(phys_addr_t base, phys_addr_t size);
 int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
 
-unsigned long memblock_free_all(void);
+void memblock_free_all(void);
 void reset_node_managed_pages(pg_data_t *pgdat);
 void reset_all_zones_managed_pages(void);
 void memblock_enforce_memory_reserved_overlap(void);
diff --git a/mm/memblock.c b/mm/memblock.c
index 40ca30bfa387..2a2b1fe4b659 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2074,10 +2074,8 @@ void __init reset_all_zones_managed_pages(void)
 
 /**
  * memblock_free_all - release free pages to the buddy allocator
- *
- * Return: the number of pages actually released.
  */
-unsigned long __init memblock_free_all(void)
+void __init memblock_free_all(void)
 {
unsigned long pages;
 
@@ -2086,8 +2084,6 @@ unsigned long __init memblock_free_all(void)
 
pages = free_low_memory_core_early();
totalram_pages_add(pages);
-
-   return pages;
 }
 
 #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK)
-- 
2.25.1



[PATCH] staging: ced401: remove redundant spin_unlock

2014-02-23 Thread Daeseok Youn
>From 5e737e8211cd1f83488e484c088befc5feb755a9 Mon Sep 17 00:00:00 2001
From: Daeseok Youn 
Date: Mon, 24 Feb 2014 09:17:41 +0900
Subject: [PATCH] staging: ced401: remove redundant spin_unlock

sparse says:
drivers/staging/ced1401/usb1401.c:1080:28: warning:
 context imbalance in 'Handle1401Esc' - unexpected unlock

Signed-off-by: Daeseok Youn 
---
 drivers/staging/ced1401/usb1401.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ced1401/usb1401.c 
b/drivers/staging/ced1401/usb1401.c
index efc310c..8195eb9 100644
--- a/drivers/staging/ced1401/usb1401.c
+++ b/drivers/staging/ced1401/usb1401.c
@@ -1053,7 +1053,6 @@ static int Handle1401Esc(DEVICE_EXTENSION *pdx, char *pCh,
/*  This can never happen, really */
dev_err(&pdx->interface->dev,
"ERROR: DMA setup while transfer still 
waiting");
-   spin_unlock(&pdx->stagedLock);
} else {
if ((wTransType == TM_EXTTOHOST)
|| (wTransType == TM_EXTTO1401)) {
-- 
1.7.9.5

---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging: ced401: remove redundant spin_unlock

2014-02-24 Thread DaeSeok Youn
2014-02-24 17:06 GMT+09:00 Dan Carpenter :
> On Mon, Feb 24, 2014 at 09:51:35AM +0900, Daeseok Youn wrote:
>> >From 5e737e8211cd1f83488e484c088befc5feb755a9 Mon Sep 17 00:00:00 2001
>> From: Daeseok Youn 
>> Date: Mon, 24 Feb 2014 09:17:41 +0900
>> Subject: [PATCH] staging: ced401: remove redundant spin_unlock
>
> Don't send this header.  We get everything from the email header.
Actually, I did attach a file which is output of "git format-patch"
with text mode. So this header was included in my e-mail.
I will remove this header and send patch again. And I don't send this
header again.

>
>>
>> sparse says:
>> drivers/staging/ced1401/usb1401.c:1080:28: warning:
>>  context imbalance in 'Handle1401Esc' - unexpected unlock
>>
>
> Your fix is correct, but the changelog is not good.  These messages in
> Sparse are wrong over 80% of the time.  So when I see one in a commit
> message I assume it is wrong.  Add some more explanation to say why you
> removed the spin_unlock.
You're right. I will add more explanation about this patch.

>
> Also "redundant" means "unnecessary" but sort of implies that it is
> harmless.  Say something like: "staging: ced401: fix double unlock bug".
Ok. fix my subject as your comment.

>
> regards,
> dan carpenter
>
Thanks for your comment.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] staging: ced401: fix double unlock bug

2014-02-24 Thread Daeseok Youn

After spin_lock() is called, all of if-else conditions in this brace
should reach the end of else and spin_unlock() must be called.
So It doesn't need to call spin_unlock() without a return statement
for handling an error.

Also sparse says:
drivers/staging/ced1401/usb1401.c:1080:28: warning:
 context imbalance in 'Handle1401Esc' - unexpected unlock

Signed-off-by: Daeseok Youn 
---
 drivers/staging/ced1401/usb1401.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ced1401/usb1401.c 
b/drivers/staging/ced1401/usb1401.c
index efc310c..8195eb9 100644
--- a/drivers/staging/ced1401/usb1401.c
+++ b/drivers/staging/ced1401/usb1401.c
@@ -1053,7 +1053,6 @@ static int Handle1401Esc(DEVICE_EXTENSION *pdx, char *pCh,
/*  This can never happen, really */
dev_err(&pdx->interface->dev,
"ERROR: DMA setup while transfer still 
waiting");
-   spin_unlock(&pdx->stagedLock);
} else {
if ((wTransType == TM_EXTTOHOST)
|| (wTransType == TM_EXTTO1401)) {
-- 
1.7.9.5

---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] dcache: replace obsolete simple_strtoul() with kstrtoul()

2014-02-24 Thread Daeseok Youn

Signed-off-by: Daeseok Youn 
---
 fs/dcache.c |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 265e0ce..f360620 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3345,10 +3345,9 @@ EXPORT_SYMBOL(d_tmpfile);
 static __initdata unsigned long dhash_entries;
 static int __init set_dhash_entries(char *str)
 {
-   if (!str)
-   return 0;
-   dhash_entries = simple_strtoul(str, &str, 0);
-   return 1;
+   if (str && !kstrtoul(str, 0, &dhash_entries))
+   return 1;
+   return 0;
 }
 __setup("dhash_entries=", set_dhash_entries);
 
-- 
1.7.9.5

---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] staging: ced401: fix double unlock bug

2014-02-24 Thread DaeSeok Youn
Ok.

I will make a patch based on linux-next branch and send it again.
Thanks.

Daeseok Youn

2014-02-25 9:43 GMT+09:00 Greg KH :
> On Mon, Feb 24, 2014 at 07:23:15PM +0900, Daeseok Youn wrote:
>>
>> After spin_lock() is called, all of if-else conditions in this brace
>> should reach the end of else and spin_unlock() must be called.
>> So It doesn't need to call spin_unlock() without a return statement
>> for handling an error.
>>
>> Also sparse says:
>> drivers/staging/ced1401/usb1401.c:1080:28: warning:
>>  context imbalance in 'Handle1401Esc' - unexpected unlock
>>
>> Signed-off-by: Daeseok Youn 
>
> This patch doesn't apply to my tree, can you please redo it against
> linux-next and resend it so that I can apply it?
>
> thanks,
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3] staging: ced401: fix double unlock bug

2014-02-24 Thread Daeseok Youn

After spin_lock() is called, all of if-else conditions in this brace
should reach the end of else and spin_unlock() must be called.
So It doesn't need to call spin_unlock() without a return statement
for handling an error.

Also sparse says:
drivers/staging/ced1401/usb1401.c:1080:28: warning:
 context imbalance in 'Handle1401Esc' - unexpected unlock

Reviewed-by: Dan Carpenter 
Signed-off-by: Daeseok Youn 
---
 drivers/staging/ced1401/usb1401.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ced1401/usb1401.c 
b/drivers/staging/ced1401/usb1401.c
index f441e33..c281fda 100644
--- a/drivers/staging/ced1401/usb1401.c
+++ b/drivers/staging/ced1401/usb1401.c
@@ -1054,7 +1054,6 @@ static int Handle1401Esc(DEVICE_EXTENSION *pdx, char *pCh,
/*  This can never happen, really */
dev_err(&pdx->interface->dev,
"ERROR: DMA setup while transfer still 
waiting\n");
-   spin_unlock(&pdx->stagedLock);
} else {
if ((wTransType == TM_EXTTOHOST)
|| (wTransType == TM_EXTTO1401)) {
-- 
1.7.9.5

---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: lustre: make functions as static

2014-02-26 Thread Daeseok Youn

These functions are only referenced in this file scope
so it can be marked static.
And remove space between function name and open parenthesis.

Signed-off-by: Daeseok Youn 
---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|   94 ++--
 1 file changed, 47 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 644a000..0c333cb 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -41,7 +41,7 @@
 #include "o2iblnd.h"
 #include 
 
-lnd_t the_o2iblnd = {
+static lnd_t the_o2iblnd = {
.lnd_type   = O2IBLND,
.lnd_startup= kiblnd_startup,
.lnd_shutdown   = kiblnd_shutdown,
@@ -53,8 +53,8 @@ lnd_t the_o2iblnd = {
 
 kib_data_t   kiblnd_data;
 
-__u32
-kiblnd_cksum (void *ptr, int nob)
+static __u32
+kiblnd_cksum(void *ptr, int nob)
 {
char  *c  = ptr;
__u32  sum = 0;
@@ -368,7 +368,7 @@ kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, 
lnet_nid_t nid)
 }
 
 void
-kiblnd_destroy_peer (kib_peer_t *peer)
+kiblnd_destroy_peer(kib_peer_t *peer)
 {
kib_net_t *net = peer->ibp_ni->ni_data;
 
@@ -390,7 +390,7 @@ kiblnd_destroy_peer (kib_peer_t *peer)
 }
 
 kib_peer_t *
-kiblnd_find_peer_locked (lnet_nid_t nid)
+kiblnd_find_peer_locked(lnet_nid_t nid)
 {
/* the caller is responsible for accounting the additional reference
 * that this creates */
@@ -419,7 +419,7 @@ kiblnd_find_peer_locked (lnet_nid_t nid)
 }
 
 void
-kiblnd_unlink_peer_locked (kib_peer_t *peer)
+kiblnd_unlink_peer_locked(kib_peer_t *peer)
 {
LASSERT (list_empty(&peer->ibp_conns));
 
@@ -429,8 +429,8 @@ kiblnd_unlink_peer_locked (kib_peer_t *peer)
kiblnd_peer_decref(peer);
 }
 
-int
-kiblnd_get_peer_info (lnet_ni_t *ni, int index,
+static int
+kiblnd_get_peer_info(lnet_ni_t *ni, int index,
  lnet_nid_t *nidp, int *count)
 {
kib_peer_t  *peer;
@@ -468,8 +468,8 @@ kiblnd_get_peer_info (lnet_ni_t *ni, int index,
return -ENOENT;
 }
 
-void
-kiblnd_del_peer_locked (kib_peer_t *peer)
+static void
+kiblnd_del_peer_locked(kib_peer_t *peer)
 {
struct list_head   *ctmp;
struct list_head   *cnxt;
@@ -489,8 +489,8 @@ kiblnd_del_peer_locked (kib_peer_t *peer)
 * last ref on it. */
 }
 
-int
-kiblnd_del_peer (lnet_ni_t *ni, lnet_nid_t nid)
+static int
+kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
 {
LIST_HEAD(zombies);
struct list_head*ptmp;
@@ -543,8 +543,8 @@ kiblnd_del_peer (lnet_ni_t *ni, lnet_nid_t nid)
return rc;
 }
 
-kib_conn_t *
-kiblnd_get_conn_by_idx (lnet_ni_t *ni, int index)
+static kib_conn_t *
+kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index)
 {
kib_peer_t  *peer;
struct list_head*ptmp;
@@ -584,16 +584,16 @@ kiblnd_get_conn_by_idx (lnet_ni_t *ni, int index)
return NULL;
 }
 
-void
-kiblnd_debug_rx (kib_rx_t *rx)
+static void
+kiblnd_debug_rx(kib_rx_t *rx)
 {
CDEBUG(D_CONSOLE, "  %p status %d msg_type %x cred %d\n",
   rx, rx->rx_status, rx->rx_msg->ibm_type,
   rx->rx_msg->ibm_credits);
 }
 
-void
-kiblnd_debug_tx (kib_tx_t *tx)
+static void
+kiblnd_debug_tx(kib_tx_t *tx)
 {
CDEBUG(D_CONSOLE, "  %p snd %d q %d w %d rc %d dl %lx "
   "cookie "LPX64" msg %s%s type %x cred %d\n",
@@ -604,8 +604,8 @@ kiblnd_debug_tx (kib_tx_t *tx)
   tx->tx_msg->ibm_type, tx->tx_msg->ibm_credits);
 }
 
-void
-kiblnd_debug_conn (kib_conn_t *conn)
+static void
+kiblnd_debug_conn(kib_conn_t *conn)
 {
struct list_head*tmp;
int i;
@@ -920,7 +920,7 @@ kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id 
*cmid,
 }
 
 void
-kiblnd_destroy_conn (kib_conn_t *conn)
+kiblnd_destroy_conn(kib_conn_t *conn)
 {
struct rdma_cm_id *cmid = conn->ibc_cmid;
kib_peer_t  *peer = conn->ibc_peer;
@@ -988,7 +988,7 @@ kiblnd_destroy_conn (kib_conn_t *conn)
 }
 
 int
-kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why)
+kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why)
 {
kib_conn_t   *conn;
struct list_head *ctmp;
@@ -1011,7 +1011,7 @@ kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why)
 }
 
 int
-kiblnd_close_stale_conns_locked (kib_peer_t *peer,
+kiblnd_close_stale_conns_locked(kib_peer_t *peer,
 int version, __u64 incarnation)
 {
kib_conn_t   *conn;
@@ -1039,8 +1039,8 @@ kiblnd_close_stale_conns_locked (kib_peer_t *peer,
return count;
 }
 
-int
-kiblnd_close_matching_conns (lnet_ni_t *ni, lnet_nid_t nid)
+static int
+kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
 {
kib_peer

Re: [PATCH] staging: lustre: make functions as static

2014-02-26 Thread DaeSeok Youn
Actually , I saw some code like this file which is seperate line
between return value and function name.
So I didn't make one line of them.

Ok, I will make another patch after merge this one.
Thanks.
Daeseok Youn.

2014-02-26 18:20 GMT+09:00, Dan Carpenter :
> On Wed, Feb 26, 2014 at 06:17:59PM +0900, Daeseok Youn wrote:
>>
>> These functions are only referenced in this file scope
>> so it can be marked static.
>> And remove space between function name and open parenthesis.
>
> If it's on the same line as a "static" change then it's fine, otherwise
> it should go in a separate patch.
>
> regards,
> dan carpenter
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging: lustre: make functions as static

2014-02-26 Thread DaeSeok Youn
Oh.. sorry.
Ok, I will seperate this patch as you said.

Thanks.
Daeseok Youn.

2014-02-26 20:31 GMT+09:00, Dan Carpenter :
> On Wed, Feb 26, 2014 at 08:11:40PM +0900, DaeSeok Youn wrote:
>> Actually , I saw some code like this file which is seperate line
>> between return value and function name.
>> So I didn't make one line of them.
>>
>> Ok, I will make another patch after merge this one.
>
> No, you are misunderstanding what I am saying.  Those type of function
> declarations are allowed in the kernel so the original code is fine.
> What I am saying is this patch is doing two thing but it should be doing
> only one thing.
>
>>  @@ -53,8 +53,8 @@ lnd_t the_o2iblnd = {
>>
>>  kib_data_tkiblnd_data;
>>
>> -__u32
>> -kiblnd_cksum (void *ptr, int nob)
>> +static __u32
>> +kiblnd_cksum(void *ptr, int nob)
>>  {
>>  char  *c  = ptr;
>>  __u32  sum = 0;
>
> Changing the white space here is OK because it is a minor related
> white space change.
>
>> @@ -368,7 +368,7 @@ kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp,
>> lnet_nid_t nid)
>>  }
>>
>>  void
>> -kiblnd_destroy_peer (kib_peer_t *peer)
>> +kiblnd_destroy_peer(kib_peer_t *peer)
>> {
>
> This is a random unrelated white space change, so do it in a separate
> patch.
>
> regards,
> dan carpenter
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: unisys: use kzalloc instead of kmalloc/memset 0

2014-03-12 Thread Daeseok Youn

Signed-off-by: Daeseok Youn 
---
 drivers/staging/unisys/uislib/uislib.c   |5 +
 drivers/staging/unisys/uislib/uisutils.c |2 +-
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uislib.c 
b/drivers/staging/unisys/uislib/uislib.c
index d77df9a..9748fcb 100644
--- a/drivers/staging/unisys/uislib/uislib.c
+++ b/drivers/staging/unisys/uislib/uislib.c
@@ -339,8 +339,6 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf)
return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
}
 
-   memset(bus, 0, size);
-
/* Currently by default, the bus Number is the GuestHandle.
 * Configure Bus message can override this.
 */
@@ -530,7 +528,6 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
}
 
-   memset(dev, 0, sizeof(struct device_info));
dev->channelTypeGuid = msg->cmd.createDevice.dataTypeGuid;
dev->intr = msg->cmd.createDevice.intr;
dev->channelAddr = msg->cmd.createDevice.channelAddr;
@@ -1437,7 +1434,7 @@ uislib_malloc(size_t siz, gfp_t gfp, U8 contiguous, char 
*fn, int ln)
* get memory for you (like, invoke oom killer), which
* will probably cripple the system.
*/
-   p = kmalloc(siz, gfp | __GFP_NORETRY);
+   p = kzalloc(siz, gfp | __GFP_NORETRY);
}
if (p == NULL) {
LOGERR("uislib_malloc failed to alloc %d bytes @%s:%d",
diff --git a/drivers/staging/unisys/uislib/uisutils.c 
b/drivers/staging/unisys/uislib/uisutils.c
index 208b7ea..2f05be1 100644
--- a/drivers/staging/unisys/uislib/uisutils.c
+++ b/drivers/staging/unisys/uislib/uisutils.c
@@ -294,7 +294,7 @@ ReqHandlerAdd(GUID switchTypeGuid,
rc = UISMALLOC(sizeof(*rc), GFP_ATOMIC);
if (!rc)
return NULL;
-   memset(rc, 0, sizeof(*rc));
+
rc->switchTypeGuid = switchTypeGuid;
rc->controlfunc = controlfunc;
rc->min_channel_bytes = min_channel_bytes;
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: cxt1e1: remove redundant memset() call

2014-03-14 Thread Daeseok Youn

The banner array doens't need to set to 0.
sprintf() adds a terminating '\0'.

And the sn array can be declared and initialized to zero.
So remove redundant memset() with zero.

Remove unnecessary cast for memcpy().

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/hwprobe.c |   12 +++-
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c
index d87a011..d41fb79 100644
--- a/drivers/staging/cxt1e1/hwprobe.c
+++ b/drivers/staging/cxt1e1/hwprobe.c
@@ -51,22 +51,16 @@ show_two(hdw_info_t *hi, int brdno)
struct pci_dev *pdev;
char   *bid;
char   banner[80];
-   charsn[6];
-
-   /* clear print buffer */
-   memset(banner, 0, 80);
+   charsn[6] = {0,};
 
ci = (ci_t *)(netdev_priv(hi->ndev));
bid = sbeid_get_bdname(ci);
switch (hi->promfmt) {
case PROM_FORMAT_TYPE1:
-   memcpy(sn, (FLD_TYPE1 *)(hi->mfg_info.pft1.Serial), 6);
+   memcpy(sn, hi->mfg_info.pft1.Serial, 6);
break;
case PROM_FORMAT_TYPE2:
-   memcpy(sn, (FLD_TYPE2 *)(hi->mfg_info.pft2.Serial), 6);
-   break;
-   default:
-   memset(sn, 0, 6);
+   memcpy(sn, hi->mfg_info.pft2.Serial, 6);
break;
}
 
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/7] staging: cxt1e1: remove space between function name and parenthesis

2014-03-03 Thread Daeseok Youn

clean up checkpatch.pl warnings in linux.c:
 WARNING: space prohibited between function name
 and open parenthesis '('

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |  524 
 1 files changed, 262 insertions(+), 262 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 4a08e16..7129265 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -56,30 +56,30 @@
 
 /***/
 /* forward references */
-status_tc4_chan_work_init (mpi_t *, mch_t *);
-voidmusycc_wq_chan_restart (void *);
-status_t __init c4_init (ci_t *, u_char *, u_char *);
-status_t __init c4_init2 (ci_t *);
-ci_t   *__init c4_new (void *);
-int __init  c4hw_attach_all (void);
-void __init hdw_sn_get (hdw_info_t *, int);
+status_tc4_chan_work_init(mpi_t *, mch_t *);
+voidmusycc_wq_chan_restart(void *);
+status_t __init c4_init(ci_t *, u_char *, u_char *);
+status_t __init c4_init2(ci_t *);
+ci_t   *__init c4_new(void *);
+int __init  c4hw_attach_all(void);
+void __init hdw_sn_get(hdw_info_t *, int);
 
 #ifdef CONFIG_SBE_PMCC4_NCOMM
-irqreturn_t c4_ebus_intr_th_handler (void *);
+irqreturn_t c4_ebus_intr_th_handler(void *);
 
 #endif
-int c4_frame_rw (ci_t *, struct sbecom_port_param *);
-status_tc4_get_port (ci_t *, int);
-int c4_loop_port (ci_t *, int, u_int8_t);
-int c4_musycc_rw (ci_t *, struct c4_musycc_param *);
-int c4_new_chan (ci_t *, int, int, void *);
-status_tc4_set_port (ci_t *, int);
-int c4_pld_rw (ci_t *, struct sbecom_port_param *);
-voidcleanup_devs (void);
-voidcleanup_ioremap (void);
-status_tmusycc_chan_down (ci_t *, int);
-irqreturn_t musycc_intr_th_handler (void *);
-int musycc_start_xmit (ci_t *, int, void *);
+int c4_frame_rw(ci_t *, struct sbecom_port_param *);
+status_tc4_get_port(ci_t *, int);
+int c4_loop_port(ci_t *, int, u_int8_t);
+int c4_musycc_rw(ci_t *, struct c4_musycc_param *);
+int c4_new_chan(ci_t *, int, int, void *);
+status_tc4_set_port(ci_t *, int);
+int c4_pld_rw(ci_t *, struct sbecom_port_param *);
+voidcleanup_devs(void);
+voidcleanup_ioremap(void);
+status_tmusycc_chan_down(ci_t *, int);
+irqreturn_t musycc_intr_th_handler(void *);
+int musycc_start_xmit(ci_t *, int, void *);
 
 extern char pmcc4_OSSI_release[];
 extern ci_t *CI;
@@ -94,9 +94,9 @@ extern struct s_hdw_info hdw_info[];
 
 #if _v7_hdlc_
 #define V7(x) (x ## _v7)
-extern int  hdlc_netif_rx_v7 (hdlc_device *, struct sk_buff *);
-extern int  register_hdlc_device_v7 (hdlc_device *);
-extern int  unregister_hdlc_device_v7 (hdlc_device *);
+extern int  hdlc_netif_rx_v7(hdlc_device *, struct sk_buff *);
+extern int  register_hdlc_device_v7(hdlc_device *);
+extern int  unregister_hdlc_device_v7(hdlc_device *);
 
 #else
 #define V7(x) x
@@ -127,28 +127,28 @@ module_param(max_rxdesc_used, int, 0444);
 //
 //
 
-void   *
-getuserbychan (int channum)
+void *
+getuserbychan(int channum)
 {
 mch_t  *ch;
 
-ch = c4_find_chan (channum);
+ch = c4_find_chan(channum);
 return ch ? ch->user : NULL;
 }
 
 
-char   *
-get_hdlc_name (hdlc_device *hdlc)
+char *
+get_hdlc_name(hdlc_device *hdlc)
 {
 struct c4_priv *priv = hdlc->priv;
-struct net_device *dev = getuserbychan (priv->channum);
+struct net_device *dev = getuserbychan(priv->channum);
 
 return dev->name;
 }
 
 
-static  status_t
-mkret (int bsd)
+static status_t
+mkret(int bsd)
 {
 if (bsd > 0)
 return -bsd;
@@ -179,7 +179,7 @@ mkret (int bsd)
  * within a port's group.
  */
 void
-c4_wk_chan_restart (mch_t *ch)
+c4_wk_chan_restart(mch_t *ch)
 {
 mpi_t  *pi = ch->up;
 
@@ -190,29 +190,29 @@ c4_wk_chan_restart (mch_t *ch)
 
 /* create new entry w/in workqueue for this channel and let'er rip */
 
-/** queue_work (struct workqueue_struct *queue,
- ** struct work_struct *work);
+/** queue_work(struct workqueue_struct *queue,
+ **struct work_struct *work);
  **/
-queue_work (pi->wq_port, &ch->ch_work);
+queue_work(pi->wq_port, &ch->ch_work);
 }
 
 status_t
-c4_wk_chan_init (mpi_t *pi, mch_t *ch)
+c4_wk_chan_init(mpi_t *pi, mch_t *ch)
 {
 /*
  * this will be used to restart a stopped channel
  */
 
-/** INIT_WORK (struct work_struct *work,
- **void (*function)(void *),
- **void *data);
+/** INIT_WORK(struct work_struct *work,
+ **   void (*function)(void *),
+ **   void *data);
  **/
 INIT_WORK

[PATCH 2/7] staging: cxt1e1: Fix no spaces at the start of a line in linux.c

2014-03-03 Thread Daeseok Youn

clean up checkpatch.pl warnings:
 WARNING: please no spaces at the start of a line in

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c | 1478 
 1 files changed, 743 insertions(+), 735 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 7129265..17d73f4 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -86,7 +86,7 @@ extern ci_t *CI;
 extern struct s_hdw_info hdw_info[];
 
 #if defined(CONFIG_SBE_HDLC_V7) || defined(CONFIG_SBE_WAN256T3_HDLC_V7) || \
-defined(CONFIG_SBE_HDLC_V7_MODULE) || 
defined(CONFIG_SBE_WAN256T3_HDLC_V7_MODULE)
+   defined(CONFIG_SBE_HDLC_V7_MODULE) || 
defined(CONFIG_SBE_WAN256T3_HDLC_V7_MODULE)
 #define _v7_hdlc_  1
 #else
 #define _v7_hdlc_  0
@@ -130,30 +130,30 @@ module_param(max_rxdesc_used, int, 0444);
 void *
 getuserbychan(int channum)
 {
-mch_t  *ch;
+   mch_t  *ch;
 
-ch = c4_find_chan(channum);
-return ch ? ch->user : NULL;
+   ch = c4_find_chan(channum);
+   return ch ? ch->user : NULL;
 }
 
 
 char *
 get_hdlc_name(hdlc_device *hdlc)
 {
-struct c4_priv *priv = hdlc->priv;
-struct net_device *dev = getuserbychan(priv->channum);
+   struct c4_priv *priv = hdlc->priv;
+   struct net_device *dev = getuserbychan(priv->channum);
 
-return dev->name;
+   return dev->name;
 }
 
 
 static status_t
 mkret(int bsd)
 {
-if (bsd > 0)
-return -bsd;
-else
-return bsd;
+   if (bsd > 0)
+   return -bsd;
+   else
+   return bsd;
 }
 
 /***/
@@ -181,72 +181,72 @@ mkret(int bsd)
 void
 c4_wk_chan_restart(mch_t *ch)
 {
-mpi_t  *pi = ch->up;
+   mpi_t  *pi = ch->up;
 
 #ifdef RLD_RESTART_DEBUG
-pr_info(">> %s: queueing Port %d Chan %d, mch_t @ %p\n",
-__func__, pi->portnum, ch->channum, ch);
+   pr_info(">> %s: queueing Port %d Chan %d, mch_t @ %p\n",
+   __func__, pi->portnum, ch->channum, ch);
 #endif
 
-/* create new entry w/in workqueue for this channel and let'er rip */
+   /* create new entry w/in workqueue for this channel and let'er rip */
 
-/** queue_work(struct workqueue_struct *queue,
- **struct work_struct *work);
- **/
-queue_work(pi->wq_port, &ch->ch_work);
+   /** queue_work(struct workqueue_struct *queue,
+**struct work_struct *work);
+**/
+   queue_work(pi->wq_port, &ch->ch_work);
 }
 
 status_t
 c4_wk_chan_init(mpi_t *pi, mch_t *ch)
 {
-/*
- * this will be used to restart a stopped channel
- */
-
-/** INIT_WORK(struct work_struct *work,
- **   void (*function)(void *),
- **   void *data);
- **/
-INIT_WORK(&ch->ch_work, (void *)musycc_wq_chan_restart);
-return 0;   /* success */
+   /*
+* this will be used to restart a stopped channel
+*/
+
+   /** INIT_WORK(struct work_struct *work,
+**   void (*function)(void *),
+**   void *data);
+**/
+   INIT_WORK(&ch->ch_work, (void *)musycc_wq_chan_restart);
+   return 0;   /* success */
 }
 
 status_t
 c4_wq_port_init(mpi_t *pi)
 {
 
-charname[16], *np;  /* NOTE: name of the queue limited by system
- * to 10 characters */
+   charname[16], *np;  /* NOTE: name of the queue limited by system
+* to 10 characters */
 
-if (pi->wq_port)
-return 0;   /* already initialized */
+   if (pi->wq_port)
+   return 0;   /* already initialized */
 
-np = name;
-memset(name, 0, 16);
-sprintf(np, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */
+   np = name;
+   memset(name, 0, 16);
+   sprintf(np, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */
 
 #ifdef RLD_RESTART_DEBUG
-pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
-__func__, name, pi->portnum); /* RLD DEBUG */
+   pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
+   __func__, name, pi->portnum); /* RLD DEBUG */
 #endif
-if (!(pi->wq_port = create_singlethread_workqueue(name)))
-return -ENOMEM;
-return 0;   /* success */
+   if (!(pi->wq_port = create_singlethread_workqueue(name)))
+   return -ENOMEM;
+   return 0;   /* success */
 }
 
 void
 c4_wq_port_cleanup(mpi_t *pi)
 {
-/*
- * PORT POINT: cannot call this if WQ is statically allocat

[PATCH 3/7] staging: cxt1e1: Fix line length over 80 characters in linux.c

2014-03-03 Thread Daeseok Youn

clean up checkpatch.pl warnings:
 WARNING: Line length over 80 characters

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   48 +--
 1 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 17d73f4..579e68e 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -31,7 +31,7 @@
 #include "pmcc4_private.h"
 #include "sbeproc.h"
 
-/*
+/***
  * Error out early if we have compiler trouble.
  *
  *   (This section is included from the kernel's init/main.c as a friendly
@@ -50,7 +50,7 @@
 #warning gcc-4.1.0 is known to miscompile the kernel.  A different compiler 
version is recommended.
 #endif
 
-/*/
+/***/
 
 #define CHANNAME "hdlc"
 
@@ -321,7 +321,8 @@ chan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, 
int cmd)
 
 
 static int
-chan_attach_noop(struct net_device *ndev, unsigned short foo_1, unsigned short 
foo_2)
+chan_attach_noop(struct net_device *ndev, unsigned short foo_1,
+unsigned short foo_2)
 {
/* our driver has nothing to do here, show's
 * over, go home
@@ -431,13 +432,15 @@ create_chan(struct net_device *ndev, ci_t *ci,
priv = OS_kmalloc(sizeof(struct c4_priv));
if (!priv)
{
-   pr_warning("%s: no memory for net_device !\n", 
ci->devname);
+   pr_warning("%s: no memory for net_device !\n",
+  ci->devname);
return NULL;
}
dev = alloc_hdlcdev(priv);
if (!dev)
{
-   pr_warning("%s: no memory for hdlc_device !\n", 
ci->devname);
+   pr_warning("%s: no memory for hdlc_device !\n",
+  ci->devname);
OS_kfree(priv);
return NULL;
}
@@ -458,10 +461,12 @@ create_chan(struct net_device *ndev, ci_t *ci,
switch (hi->promfmt)
{
case PROM_FORMAT_TYPE1:
-   memcpy(dev->dev_addr, (FLD_TYPE1 *) 
(hi->mfg_info.pft1.Serial), 6);
+   memcpy(dev->dev_addr,
+  (FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6);
break;
case PROM_FORMAT_TYPE2:
-   memcpy(dev->dev_addr, (FLD_TYPE2 *) 
(hi->mfg_info.pft2.Serial), 6);
+   memcpy(dev->dev_addr,
+  (FLD_TYPE2 *) (hi->mfg_info.pft2.Serial), 6);
break;
default:
memset(dev->dev_addr, 0, 6);
@@ -691,9 +696,11 @@ do_create_chan(struct net_device *ndev, void *data)
ret = mkret(c4_new_chan(ci, cp.port, cp.channum, dev));
if (ret)
{
-   rtnl_unlock(); /* needed due to Ioctl calling 
sequence */
+   /* needed due to Ioctl calling sequence */
+   rtnl_unlock();
unregister_hdlc_device(dev);
-   rtnl_lock();   /* needed due to Ioctl calling 
sequence */
+   /* needed due to Ioctl calling sequence */
+   rtnl_lock();
free_netdev(dev);
}
return ret;
@@ -753,11 +760,13 @@ do_deluser(struct net_device *ndev, int lockit)
ch->user = NULL;/* will be freed, below */
}
 
+   /* needed if Ioctl calling sequence */
if (lockit)
-   rtnl_unlock(); /* needed if Ioctl calling sequence 
*/
+   rtnl_unlock();
unregister_hdlc_device(ndev);
+   /* needed if Ioctl calling sequence */
if (lockit)
-   rtnl_lock();   /* needed if Ioctl calling sequence 
*/
+   rtnl_lock();
free_netdev(ndev);
return 0;
 }
@@ -927,7 +936,8 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
ret = do_pld_rw(ndev, data);
break;
case SBE_IOC_IID_GET:
-   ret = (iolen == sizeof(struct sbe_iid_info)) ? 
c4_get_iidinfo(ci, &arg.u.iip) : -EFAULT;
+   ret = (iolen == sizeof(struct sbe_iid_info)) ?
+  c4_get_iidinfo(ci, &arg.u.iip) : -EFAULT;
if (ret == 0)   /* no error, copy data */
if (copy_to_user(data, &am

[PATCH 4/7] staging: cxt1e1: fix checkpatch error 'assignment in if condition'

2014-03-03 Thread Daeseok Youn

checkpatch.pl error in linux.c:
 ERROR: do not use assignment in if condition

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   28 +---
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 579e68e..cade004 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -229,7 +229,8 @@ c4_wq_port_init(mpi_t *pi)
pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
__func__, name, pi->portnum); /* RLD DEBUG */
 #endif
-   if (!(pi->wq_port = create_singlethread_workqueue(name)))
+   pi->wq_port = create_singlethread_workqueue(name);
+   if (!pi->wq_port)
return -ENOMEM;
return 0;   /* success */
 }
@@ -286,12 +287,14 @@ chan_open(struct net_device *ndev)
const struct c4_priv *priv = hdlc->priv;
int ret;
 
-   if ((ret = hdlc_open(ndev)))
-   {
+   ret = hdlc_open(ndev);
+   if (ret) {
pr_info("hdlc_open failure, err %d.\n", ret);
return ret;
}
-   if ((ret = c4_chan_up(priv->ci, priv->channum)))
+
+   ret = c4_chan_up(priv->ci, priv->channum);
+   if (ret)
return -ret;
try_module_get(THIS_MODULE);
netif_start_queue(ndev);
@@ -648,7 +651,8 @@ do_get_chan(struct net_device *ndev, void *data)
sizeof(struct sbecom_chan_param)))
return -EFAULT;
 
-   if ((ret = mkret(c4_get_chan(cp.channum, &cp
+   ret = mkret(c4_get_chan(cp.channum, &cp));
+   if (ret)
return ret;
 
if (copy_to_user(data, &cp, sizeof(struct sbecom_chan_param)))
@@ -864,7 +868,8 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
return -EPERM;
if (cmd != SIOCDEVPRIVATE + 15)
return -EINVAL;
-   if (!(ci = get_ci_by_dev(ndev)))
+   ci =  get_ci_by_dev(ndev);
+   if (!ci)
return -EINVAL;
if (ci->state != C_RUNNING)
return -ENODEV;
@@ -1100,9 +1105,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
tasklet_enable(&ci->ci_musycc_isr_tasklet);
 #endif
 
-
-   if ((error_flag = c4_init2(ci)) != SBE_DRVR_SUCCESS)
-   {
+   error_flag = c4_init2(ci);
+   if (error_flag != SBE_DRVR_SUCCESS) {
 #ifdef CONFIG_PROC_FS
sbecom_proc_brd_cleanup(ci);
 #endif
@@ -1123,7 +1127,8 @@ c4_mod_init(void)
int rtn;
 
pr_warning("%s\n", pmcc4_OSSI_release);
-   if ((rtn = c4hw_attach_all()))
+   rtn = c4hw_attach_all();
+   if (rtn)
return -rtn; /* installation failure - see system log */
 
/* housekeeping notifications */
@@ -1174,7 +1179,8 @@ cleanup_hdlc(void)
ci = (ci_t *)(netdev_priv(hi->ndev));
for (j = 0; j < ci->max_port; j++)
for (k = 0; k < MUSYCC_NCHANS; k++)
-   if ((ndev = ci->port[j].chan[k]->user))
+   ndev = ci->port[j].chan[k]->user;
+   if (ndev)
{
do_deluser(ndev, 0);
}
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/7] staging: cxt1e1: fix checkpatch errors with open brace '{'

2014-03-03 Thread Daeseok Youn

clean up checkpatch.pl error in linux.c:
 ERROR: that open brace { should be on the previous line

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   67 ---
 1 files changed, 21 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index cade004..7eb6625 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -242,8 +242,7 @@ c4_wq_port_cleanup(mpi_t *pi)
 * PORT POINT: cannot call this if WQ is statically allocated w/in
 * structure since it calls kfree(wq);
 */
-   if (pi->wq_port)
-   {
+   if (pi->wq_port) {
destroy_workqueue(pi->wq_port);/* this also calls
* flush_workqueue() */
pi->wq_port = NULL;
@@ -433,15 +432,13 @@ create_chan(struct net_device *ndev, ci_t *ci,
 
/* allocate then fill in private data structure */
priv = OS_kmalloc(sizeof(struct c4_priv));
-   if (!priv)
-   {
+   if (!priv) {
pr_warning("%s: no memory for net_device !\n",
   ci->devname);
return NULL;
}
dev = alloc_hdlcdev(priv);
-   if (!dev)
-   {
+   if (!dev) {
pr_warning("%s: no memory for hdlc_device !\n",
   ci->devname);
OS_kfree(priv);
@@ -459,10 +456,8 @@ create_chan(struct net_device *ndev, ci_t *ci,
*dev->name = 0; /* default ifconfig name = "hdlc" */
 
hi = (hdw_info_t *)ci->hdw_info;
-   if (hi->mfg_info_sts == EEPROM_OK)
-   {
-   switch (hi->promfmt)
-   {
+   if (hi->mfg_info_sts == EEPROM_OK) {
+   switch (hi->promfmt) {
case PROM_FORMAT_TYPE1:
memcpy(dev->dev_addr,
   (FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6);
@@ -476,9 +471,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
break;
}
} else
-   {
memset(dev->dev_addr, 0, 6);
-   }
 
hdlc->xmit = c4_linux_xmit;
 
@@ -502,8 +495,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
 
/* needed due to Ioctl calling sequence */
rtnl_lock();
-   if (ret)
-   {
+   if (ret) {
if (cxt1e1_log_level >= LOG_WARN)
pr_info("%s: create_chan[%d] registration error = 
%d.\n",
ci->devname, cp->channum, ret);
@@ -698,8 +690,7 @@ do_create_chan(struct net_device *ndev, void *data)
if (!dev)
return -EBUSY;
ret = mkret(c4_new_chan(ci, cp.port, cp.channum, dev));
-   if (ret)
-   {
+   if (ret) {
/* needed due to Ioctl calling sequence */
rtnl_unlock();
unregister_hdlc_device(dev);
@@ -805,8 +796,7 @@ do_reset(struct net_device *musycc_dev, void *data)
const struct c4_priv *priv;
int i;
 
-   for (i = 0; i < 128; i++)
-   {
+   for (i = 0; i < 128; i++) {
struct net_device *ndev;
charbuf[sizeof(CHANNAME) + 3];
 
@@ -817,8 +807,7 @@ do_reset(struct net_device *musycc_dev, void *data)
priv = dev_to_hdlc(ndev)->priv;
 
if ((unsigned long) (priv->ci) ==
-   (unsigned long) (netdev_priv(musycc_dev)))
-   {
+   (unsigned long) (netdev_priv(musycc_dev))) {
ndev->flags &= ~IFF_UP;
netif_stop_queue(ndev);
do_deluser(ndev, 1);
@@ -845,10 +834,8 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
void   *data;
int iocmd, iolen;
status_tret;
-   static struct data
-   {
-   union
-   {
+   static struct data {
+   union {
u_int8_t c;
u_int32_t i;
struct sbe_brd_info bip;
@@ -891,8 +878,7 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
return -EFAULT;
 
ret = 0;
-   switch (iocmd)
-   {
+   switch (iocmd) {
case SBE_IOC_PORT_GET:
//pr_info(">> SBE_IOC_PORT_GET Ioctl...\n");
ret = do_get_port(ndev, data);
@@ -975,8 +961,7 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
ci_t   *ci;
 
ndev = alloc_netdev(sizeof(ci_t), SBE_IFACETM

[PATCH 6/7] staging: cxtie1: remove unneeded mkret() calls

2014-03-03 Thread Daeseok Youn

The mkret() change a value of error from positive to
negative. This patch is modified to return negative value
when it failed. It doesn't need to call with function
for changing from positive to negative.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   72 +--
 drivers/staging/cxt1e1/musycc.c|2 +-
 drivers/staging/cxt1e1/pmcc4_drv.c |   40 ++--
 3 files changed, 48 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 7eb6625..599a5ef 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -146,16 +146,6 @@ get_hdlc_name(hdlc_device *hdlc)
return dev->name;
 }
 
-
-static status_t
-mkret(int bsd)
-{
-   if (bsd > 0)
-   return -bsd;
-   else
-   return bsd;
-}
-
 /***/
 #include 
 
@@ -293,8 +283,8 @@ chan_open(struct net_device *ndev)
}
 
ret = c4_chan_up(priv->ci, priv->channum);
-   if (ret)
-   return -ret;
+   if (ret < 0)
+   return ret;
try_module_get(THIS_MODULE);
netif_start_queue(ndev);
return 0;   /* no error = success */
@@ -524,8 +514,8 @@ do_get_port(struct net_device *ndev, void *data)
if (!ci)
return -EINVAL; /* get card info */
 
-   ret = mkret(c4_get_port(ci, pp.portnum));
-   if (ret)
+   ret = c4_get_port(ci, pp.portnum);
+   if (ret < 0)
return ret;
if (copy_to_user(data, &ci->port[pp.portnum].p,
 sizeof(struct sbecom_port_param)))
@@ -552,7 +542,7 @@ do_set_port(struct net_device *ndev, void *data)
return -ENXIO;
 
memcpy(&ci->port[pp.portnum].p, &pp, sizeof(struct sbecom_port_param));
-   return mkret(c4_set_port(ci, pp.portnum));
+   return c4_set_port(ci, pp.portnum);
 }
 
 /* work the port loopback mode as per directed */
@@ -567,7 +557,7 @@ do_port_loop(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   return mkret(c4_loop_port(ci, pp.portnum, pp.port_mode));
+   return c4_loop_port(ci, pp.portnum, pp.port_mode);
 }
 
 /* set the specified register with the given value / or just read it */
@@ -583,8 +573,8 @@ do_framer_rw(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   ret = mkret(c4_frame_rw(ci, &pp));
-   if (ret)
+   ret = c4_frame_rw(ci, &pp);
+   if (ret < 0)
return ret;
if (copy_to_user(data, &pp, sizeof(struct sbecom_port_param)))
return -EFAULT;
@@ -604,7 +594,8 @@ do_pld_rw(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   ret = mkret(c4_pld_rw(ci, &pp));
+
+   ret = c4_pld_rw(ci, &pp);
if (ret)
return ret;
if (copy_to_user(data, &pp, sizeof(struct sbecom_port_param)))
@@ -625,8 +616,8 @@ do_musycc_rw(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   ret = mkret(c4_musycc_rw(ci, &mp));
-   if (ret)
+   ret = c4_musycc_rw(ci, &mp);
+   if (ret < 0)
return ret;
if (copy_to_user(data, &mp, sizeof(struct c4_musycc_param)))
return -EFAULT;
@@ -643,8 +634,8 @@ do_get_chan(struct net_device *ndev, void *data)
sizeof(struct sbecom_chan_param)))
return -EFAULT;
 
-   ret = mkret(c4_get_chan(cp.channum, &cp));
-   if (ret)
+   ret = c4_get_chan(cp.channum, &cp);
+   if (ret < 0)
return ret;
 
if (copy_to_user(data, &cp, sizeof(struct sbecom_chan_param)))
@@ -656,7 +647,6 @@ static status_t
 do_set_chan(struct net_device *ndev, void *data)
 {
struct sbecom_chan_param cp;
-   int ret;
ci_t   *ci;
 
if (copy_from_user(&cp, data, sizeof(struct sbecom_chan_param)))
@@ -664,13 +654,7 @@ do_set_chan(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   switch (ret = mkret(c4_set_chan(cp.channum, &cp)))
-   {
-   case 0:
-   return 0;
-   default:
-   return ret;
-   }
+   return c4_set_chan(cp.channum, &cp);
 }
 
 static status_t
@@ -689,8 +673,8 @@ do_create_chan(struct net_device *ndev, void *data)
dev = create_chan(ndev, ci, &cp);
if (!dev)
return -EBUSY;
-   ret = mkret(c4_new_chan(ci, cp.port, cp.channum, dev));
-   if (ret) {
+   ret 

[PATCH 7/7] staging: cxt1e1: remove unneeded a value

2014-03-03 Thread Daeseok Youn

It doesn't need to assign name array address to np pointer.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 599a5ef..390b1f5 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -205,15 +205,14 @@ status_t
 c4_wq_port_init(mpi_t *pi)
 {
 
-   charname[16], *np;  /* NOTE: name of the queue limited by system
+   charname[16];  /* NOTE: name of the queue limited by system
 * to 10 characters */
 
if (pi->wq_port)
return 0;   /* already initialized */
 
-   np = name;
memset(name, 0, 16);
-   sprintf(np, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */
+   sprintf(name, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */
 
 #ifdef RLD_RESTART_DEBUG
pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/7] staging: cxt1e1: Fix line length over 80 characters in linux.c

2014-03-03 Thread DaeSeok Youn
Thanks for review.

How about fix it as your comment within another patch?

I sent many smaller patches for fixing coding style and other things.
And I think this patch has just fixed about long line length, so I
want to let it leave this change and
I will send a patch after fixing as your comment.

just my opinion.

Regards.
Daeseok Youn.

2014-03-04 12:24 GMT+09:00 Joe Perches :
> On Tue, 2014-03-04 at 11:08 +0900, Daeseok Youn wrote:
>> clean up checkpatch.pl warnings:
>>  WARNING: Line length over 80 characters
>
> Please run your patches through checkpatch.
>
>> diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
>
>> @@ -431,13 +432,15 @@ create_chan(struct net_device *ndev, ci_t *ci,
>>   priv = OS_kmalloc(sizeof(struct c4_priv));
>>   if (!priv)
>>   {
>> - pr_warning("%s: no memory for net_device !\n", 
>> ci->devname);
>> + pr_warning("%s: no memory for net_device !\n",
>> +ci->devname);
>
> pr_warn would be nice
>
>> @@ -458,10 +461,12 @@ create_chan(struct net_device *ndev, ci_t *ci,
>>   switch (hi->promfmt)
>>   {
>>   case PROM_FORMAT_TYPE1:
>> - memcpy(dev->dev_addr, (FLD_TYPE1 *) 
>> (hi->mfg_info.pft1.Serial), 6);
>> + memcpy(dev->dev_addr,
>> +(FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6);
>
> Likely better to remove the (FLD_TYPE1 *) altogether.
>
>>   break;
>>   case PROM_FORMAT_TYPE2:
>> - memcpy(dev->dev_addr, (FLD_TYPE2 *) 
>> (hi->mfg_info.pft2.Serial), 6);
>> + memcpy(dev->dev_addr,
>> +(FLD_TYPE2 *) (hi->mfg_info.pft2.Serial), 6);
>
> Likely better to remove the (FLD_TYPE2 *) too.
> Maybe consolidate the blocks too.
>
>
>> @@ -1053,13 +1065,15 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long 
>> f0, unsigned long f1,
>>   switch (hi->promfmt)
>>   {
>>   case PROM_FORMAT_TYPE1:
>> - memcpy(ndev->dev_addr, (FLD_TYPE1 *) 
>> (hi->mfg_info.pft1.Serial), 6);
>> + memcpy(ndev->dev_addr,
>> +(FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6);
>
> unnecessary casts?
>
>>   /* unaligned data acquisition */
>>   memcpy(&tmp, (FLD_TYPE1 *) (hi->mfg_info.pft1.Id), 4);
>
> here too.
>
>>   ci->brd_id = cpu_to_be32(tmp);
>>   break;
>>   case PROM_FORMAT_TYPE2:
>> - memcpy(ndev->dev_addr, (FLD_TYPE2 *) 
>> (hi->mfg_info.pft2.Serial), 6);
>> + memcpy(ndev->dev_addr,
>> +(FLD_TYPE2 *) (hi->mfg_info.pft2.Serial), 6);
>>   /* unaligned data acquisition */
>>   memcpy(&tmp, (FLD_TYPE2 *) (hi->mfg_info.pft2.Id), 4);
>
> etc.
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5 v4] Staging: cxt1e1: Fix line length over 80 characters in hwprobe.c

2014-03-04 Thread Daeseok Youn

clean up checkpatch.pl warnings:
 WARNING: Line length over 80 characters

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/hwprobe.c |   45 --
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c
index 85040bb..da991a3 100644
--- a/drivers/staging/cxt1e1/hwprobe.c
+++ b/drivers/staging/cxt1e1/hwprobe.c
@@ -37,7 +37,8 @@ extern int  drvr_state;
 
 /* forward references */
 voidc4_stopwd(ci_t *);
-struct net_device * __init c4_add_dev(hdw_info_t *, int, unsigned long, 
unsigned long, int, int);
+struct net_device * __init c4_add_dev(hdw_info_t *, int, unsigned long,
+ unsigned long, int, int);
 
 
 struct s_hdw_info hdw_info[MAX_BOARDS];
@@ -104,24 +105,31 @@ hdw_sn_get(hdw_info_t *hi, int brdno)
addr = (long) hi->addr_mapped[1] + EEPROM_OFFSET;
 
/* read EEPROM with largest known format size... */
-   pmc_eeprom_read_buffer(addr, 0, (char *)hi->mfg_info.data, 
sizeof(FLD_TYPE2));
+   pmc_eeprom_read_buffer(addr, 0, (char *)hi->mfg_info.data,
+  sizeof(FLD_TYPE2));
 
 #if 0
{
unsigned char *ucp = (unsigned char *) &hi->mfg_info.data;
 
pr_info("eeprom[00]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 0), *(ucp + 1), *(ucp + 2), *(ucp + 3), 
*(ucp + 4), *(ucp + 5), *(ucp + 6), *(ucp + 7));
+   *(ucp + 0), *(ucp + 1), *(ucp + 2), *(ucp + 3),
+   *(ucp + 4), *(ucp + 5), *(ucp + 6), *(ucp + 7));
pr_info("eeprom[08]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 8), *(ucp + 9), *(ucp + 10), *(ucp + 
11), *(ucp + 12), *(ucp + 13), *(ucp + 14), *(ucp + 15));
+   *(ucp + 8), *(ucp + 9), *(ucp + 10), *(ucp + 11),
+   *(ucp + 12), *(ucp + 13), *(ucp + 14), *(ucp + 15));
pr_info("eeprom[16]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 16), *(ucp + 17), *(ucp + 18), *(ucp + 
19), *(ucp + 20), *(ucp + 21), *(ucp + 22), *(ucp + 23));
+   *(ucp + 16), *(ucp + 17), *(ucp + 18), *(ucp + 19),
+   *(ucp + 20), *(ucp + 21), *(ucp + 22), *(ucp + 23));
pr_info("eeprom[24]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 24), *(ucp + 25), *(ucp + 26), *(ucp + 
27), *(ucp + 28), *(ucp + 29), *(ucp + 30), *(ucp + 31));
+   *(ucp + 24), *(ucp + 25), *(ucp + 26), *(ucp + 27),
+   *(ucp + 28), *(ucp + 29), *(ucp + 30), *(ucp + 31));
pr_info("eeprom[32]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 32), *(ucp + 33), *(ucp + 34), *(ucp + 
35), *(ucp + 36), *(ucp + 37), *(ucp + 38), *(ucp + 39));
+   *(ucp + 32), *(ucp + 33), *(ucp + 34), *(ucp + 35),
+   *(ucp + 36), *(ucp + 37), *(ucp + 38), *(ucp + 39));
pr_info("eeprom[40]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 40), *(ucp + 41), *(ucp + 42), *(ucp + 
43), *(ucp + 44), *(ucp + 45), *(ucp + 46), *(ucp + 47));
+   *(ucp + 40), *(ucp + 41), *(ucp + 42), *(ucp + 43),
+   *(ucp + 44), *(ucp + 45), *(ucp + 46), *(ucp + 47));
}
 #endif
 #if 0
@@ -230,10 +238,11 @@ c4_hdw_init(struct pci_dev *pdev, int found)
return 0;
}
 
-   if (pdev->bus)  /* obtain bus number */
+   /* obtain bus number */
+   if (pdev->bus)
busno = pdev->bus->number;
else
-   busno = 0;  /* default for system PCI 
inconsistency */
+   busno = 0; /* default for system PCI inconsistency */
slot = pdev->devfn & ~0x07;
 
/*
@@ -246,8 +255,8 @@ c4_hdw_init(struct pci_dev *pdev, int found)
for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++)
{
/*
-* match with board's first found interface, otherwise this is 
first
-* found
+* match with board's first found interface, otherwise this is
+* first found
 */
if ((hi->pci_slot == 0xff) ||   /* new board */
((hi->pci_slot == slot) && (hi->bus == pdev->bus)))
@@ -256,13 +265,14 @@ c4_hdw_init(struct pci_dev *pdev, int found)
if (i == MAX_BOARDS)/* no match in above loop means MAX
 * exceeded */
{
-   pr_warning("exceeded number of allowed devices (&g

Re: [PATCH 3/7] staging: cxt1e1: Fix line length over 80 characters in linux.c

2014-03-04 Thread DaeSeok Youn
Thanks for review.
Ok. I Will fix later.

Daeseok Youn
2014-03-04 17:45 GMT+09:00, Dan Carpenter :
> On Tue, Mar 04, 2014 at 11:08:46AM +0900, Daeseok Youn wrote:
>>
>> clean up checkpatch.pl warnings:
>>  WARNING: Line length over 80 characters
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>>  drivers/staging/cxt1e1/linux.c |   48
>> +--
>>  1 files changed, 31 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/staging/cxt1e1/linux.c
>> b/drivers/staging/cxt1e1/linux.c
>> index 17d73f4..579e68e 100644
>> --- a/drivers/staging/cxt1e1/linux.c
>> +++ b/drivers/staging/cxt1e1/linux.c
>> @@ -31,7 +31,7 @@
>>  #include "pmcc4_private.h"
>>  #include "sbeproc.h"
>>
>> -/*
>> +/***
>
> This should just be:
>
> /*
>  *
>  *
>
> Not ** etc.
>
> Fix in a later patch if you want.
>
> regards,
> dan carpenter
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/7] staging: cxt1e1: fix checkpatch error 'assignment in if condition'

2014-03-04 Thread DaeSeok Youn
Yes, it need to add brace in inner loop.
I will send again.

Thanks for review.
Daeseok Youn

2014-03-04 18:04 GMT+09:00, Dan Carpenter :
> On Tue, Mar 04, 2014 at 11:09:39AM +0900, Daeseok Youn wrote:
>> @@ -1174,7 +1179,8 @@ cleanup_hdlc(void)
>>  ci = (ci_t *)(netdev_priv(hi->ndev));
>>  for (j = 0; j < ci->max_port; j++)
>>  for (k = 0; k < MUSYCC_NCHANS; k++)
>> -if ((ndev = ci->port[j].chan[k]->user))
>> +ndev = ci->port[j].chan[k]->user;
>> +if (ndev)
>>  {
>>  do_deluser(ndev, 0);
>>  }
>
>
> This patch introduces a bug here because the inner for loop now has two
> statement but no curly braces.
>
> regards,
> dan carpenter
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/7 v2] staging: cxt1e1: fix checkpatch error 'assignment in if condition'

2014-03-04 Thread Daeseok Youn

checkpatch.pl error in linux.c:
 ERROR: do not use assignment in if condition

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   31 +++
 1 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 579e68e..e4541af 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -229,7 +229,8 @@ c4_wq_port_init(mpi_t *pi)
pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
__func__, name, pi->portnum); /* RLD DEBUG */
 #endif
-   if (!(pi->wq_port = create_singlethread_workqueue(name)))
+   pi->wq_port = create_singlethread_workqueue(name);
+   if (!pi->wq_port)
return -ENOMEM;
return 0;   /* success */
 }
@@ -286,12 +287,14 @@ chan_open(struct net_device *ndev)
const struct c4_priv *priv = hdlc->priv;
int ret;
 
-   if ((ret = hdlc_open(ndev)))
-   {
+   ret = hdlc_open(ndev);
+   if (ret) {
pr_info("hdlc_open failure, err %d.\n", ret);
return ret;
}
-   if ((ret = c4_chan_up(priv->ci, priv->channum)))
+
+   ret = c4_chan_up(priv->ci, priv->channum);
+   if (ret)
return -ret;
try_module_get(THIS_MODULE);
netif_start_queue(ndev);
@@ -648,7 +651,8 @@ do_get_chan(struct net_device *ndev, void *data)
sizeof(struct sbecom_chan_param)))
return -EFAULT;
 
-   if ((ret = mkret(c4_get_chan(cp.channum, &cp
+   ret = mkret(c4_get_chan(cp.channum, &cp));
+   if (ret)
return ret;
 
if (copy_to_user(data, &cp, sizeof(struct sbecom_chan_param)))
@@ -864,7 +868,8 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
return -EPERM;
if (cmd != SIOCDEVPRIVATE + 15)
return -EINVAL;
-   if (!(ci = get_ci_by_dev(ndev)))
+   ci =  get_ci_by_dev(ndev);
+   if (!ci)
return -EINVAL;
if (ci->state != C_RUNNING)
return -ENODEV;
@@ -1100,9 +1105,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
tasklet_enable(&ci->ci_musycc_isr_tasklet);
 #endif
 
-
-   if ((error_flag = c4_init2(ci)) != SBE_DRVR_SUCCESS)
-   {
+   error_flag = c4_init2(ci);
+   if (error_flag != SBE_DRVR_SUCCESS) {
 #ifdef CONFIG_PROC_FS
sbecom_proc_brd_cleanup(ci);
 #endif
@@ -1123,7 +1127,8 @@ c4_mod_init(void)
int rtn;
 
pr_warning("%s\n", pmcc4_OSSI_release);
-   if ((rtn = c4hw_attach_all()))
+   rtn = c4hw_attach_all();
+   if (rtn)
return -rtn; /* installation failure - see system log */
 
/* housekeeping notifications */
@@ -1173,11 +1178,13 @@ cleanup_hdlc(void)
{
ci = (ci_t *)(netdev_priv(hi->ndev));
for (j = 0; j < ci->max_port; j++)
-   for (k = 0; k < MUSYCC_NCHANS; k++)
-   if ((ndev = ci->port[j].chan[k]->user))
+   for (k = 0; k < MUSYCC_NCHANS; k++) {
+   ndev = ci->port[j].chan[k]->user;
+   if (ndev)
{
do_deluser(ndev, 0);
}
+   }
}
}
 }
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/7 v2] staging: cxt1e1: fix checkpatch errors with open brace '{'

2014-03-04 Thread Daeseok Youn

clean up checkpatch.pl error in linux.c:
 ERROR: that open brace { should be on the previous line

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   67 ---
 1 files changed, 21 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index e4541af..478516f 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -242,8 +242,7 @@ c4_wq_port_cleanup(mpi_t *pi)
 * PORT POINT: cannot call this if WQ is statically allocated w/in
 * structure since it calls kfree(wq);
 */
-   if (pi->wq_port)
-   {
+   if (pi->wq_port) {
destroy_workqueue(pi->wq_port);/* this also calls
* flush_workqueue() */
pi->wq_port = NULL;
@@ -433,15 +432,13 @@ create_chan(struct net_device *ndev, ci_t *ci,
 
/* allocate then fill in private data structure */
priv = OS_kmalloc(sizeof(struct c4_priv));
-   if (!priv)
-   {
+   if (!priv) {
pr_warning("%s: no memory for net_device !\n",
   ci->devname);
return NULL;
}
dev = alloc_hdlcdev(priv);
-   if (!dev)
-   {
+   if (!dev) {
pr_warning("%s: no memory for hdlc_device !\n",
   ci->devname);
OS_kfree(priv);
@@ -459,10 +456,8 @@ create_chan(struct net_device *ndev, ci_t *ci,
*dev->name = 0; /* default ifconfig name = "hdlc" */
 
hi = (hdw_info_t *)ci->hdw_info;
-   if (hi->mfg_info_sts == EEPROM_OK)
-   {
-   switch (hi->promfmt)
-   {
+   if (hi->mfg_info_sts == EEPROM_OK) {
+   switch (hi->promfmt) {
case PROM_FORMAT_TYPE1:
memcpy(dev->dev_addr,
   (FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6);
@@ -476,9 +471,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
break;
}
} else
-   {
memset(dev->dev_addr, 0, 6);
-   }
 
hdlc->xmit = c4_linux_xmit;
 
@@ -502,8 +495,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
 
/* needed due to Ioctl calling sequence */
rtnl_lock();
-   if (ret)
-   {
+   if (ret) {
if (cxt1e1_log_level >= LOG_WARN)
pr_info("%s: create_chan[%d] registration error = 
%d.\n",
ci->devname, cp->channum, ret);
@@ -698,8 +690,7 @@ do_create_chan(struct net_device *ndev, void *data)
if (!dev)
return -EBUSY;
ret = mkret(c4_new_chan(ci, cp.port, cp.channum, dev));
-   if (ret)
-   {
+   if (ret) {
/* needed due to Ioctl calling sequence */
rtnl_unlock();
unregister_hdlc_device(dev);
@@ -805,8 +796,7 @@ do_reset(struct net_device *musycc_dev, void *data)
const struct c4_priv *priv;
int i;
 
-   for (i = 0; i < 128; i++)
-   {
+   for (i = 0; i < 128; i++) {
struct net_device *ndev;
charbuf[sizeof(CHANNAME) + 3];
 
@@ -817,8 +807,7 @@ do_reset(struct net_device *musycc_dev, void *data)
priv = dev_to_hdlc(ndev)->priv;
 
if ((unsigned long) (priv->ci) ==
-   (unsigned long) (netdev_priv(musycc_dev)))
-   {
+   (unsigned long) (netdev_priv(musycc_dev))) {
ndev->flags &= ~IFF_UP;
netif_stop_queue(ndev);
do_deluser(ndev, 1);
@@ -845,10 +834,8 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
void   *data;
int iocmd, iolen;
status_tret;
-   static struct data
-   {
-   union
-   {
+   static struct data {
+   union {
u_int8_t c;
u_int32_t i;
struct sbe_brd_info bip;
@@ -891,8 +878,7 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
return -EFAULT;
 
ret = 0;
-   switch (iocmd)
-   {
+   switch (iocmd) {
case SBE_IOC_PORT_GET:
//pr_info(">> SBE_IOC_PORT_GET Ioctl...\n");
ret = do_get_port(ndev, data);
@@ -975,8 +961,7 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
ci_t   *ci;
 
ndev = alloc_netdev(sizeof(ci_t), SBE_IFACETM

Re: [PATCH 5/7] staging: cxt1e1: fix checkpatch errors with open brace '{'

2014-03-04 Thread DaeSeok Youn
Hi, greg

I already resend patch 4 and 5. :-)

It had a bug which is noticed by Dan.

I tried to fix assignment in if condition and missed curly brace in inner loop.
So I fixed that bug and resend patch 4. And patch 5 is rebased after
fixing patch 4.

And I tested to apply these patch to staging-next branch from mailing list.
Please check.

Thanks.
Daeseok Youn.

2014-03-05 9:35 GMT+09:00 Greg KH :
> On Tue, Mar 04, 2014 at 11:10:44AM +0900, Daeseok Youn wrote:
>>
>> clean up checkpatch.pl error in linux.c:
>>  ERROR: that open brace { should be on the previous line
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>>  drivers/staging/cxt1e1/linux.c |   67 
>> ---
>>  1 files changed, 21 insertions(+), 46 deletions(-)
>
> As patch 4 can't be applied, I can't apply these either, please resend
> the rest of the series when you fix them up.
>
> thanks,
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/7] staging: cxt1e1: fix checkpatch errors with open brace '{'

2014-03-04 Thread DaeSeok Youn
OK.
I send patches again.

Thanks.
Daeseok Youn.

2014-03-05 10:06 GMT+09:00 Greg KH :
> On Wed, Mar 05, 2014 at 09:55:14AM +0900, DaeSeok Youn wrote:
>> Hi, greg
>>
>> I already resend patch 4 and 5. :-)
>>
>> It had a bug which is noticed by Dan.
>>
>> I tried to fix assignment in if condition and missed curly brace in inner 
>> loop.
>> So I fixed that bug and resend patch 4. And patch 5 is rebased after
>> fixing patch 4.
>>
>> And I tested to apply these patch to staging-next branch from mailing list.
>> Please check.
>
> I've flushed all of your patches from my queue now, please resend
> anything I haven't applied.
>
> thanks,
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/7 v3] staging: cxt1e1: fix checkpatch error 'assignment in if condition'

2014-03-04 Thread Daeseok Youn

checkpatch.pl error in linux.c:
 ERROR: do not use assignment in if condition

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   31 +++
 1 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 579e68e..e4541af 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -229,7 +229,8 @@ c4_wq_port_init(mpi_t *pi)
pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
__func__, name, pi->portnum); /* RLD DEBUG */
 #endif
-   if (!(pi->wq_port = create_singlethread_workqueue(name)))
+   pi->wq_port = create_singlethread_workqueue(name);
+   if (!pi->wq_port)
return -ENOMEM;
return 0;   /* success */
 }
@@ -286,12 +287,14 @@ chan_open(struct net_device *ndev)
const struct c4_priv *priv = hdlc->priv;
int ret;
 
-   if ((ret = hdlc_open(ndev)))
-   {
+   ret = hdlc_open(ndev);
+   if (ret) {
pr_info("hdlc_open failure, err %d.\n", ret);
return ret;
}
-   if ((ret = c4_chan_up(priv->ci, priv->channum)))
+
+   ret = c4_chan_up(priv->ci, priv->channum);
+   if (ret)
return -ret;
try_module_get(THIS_MODULE);
netif_start_queue(ndev);
@@ -648,7 +651,8 @@ do_get_chan(struct net_device *ndev, void *data)
sizeof(struct sbecom_chan_param)))
return -EFAULT;
 
-   if ((ret = mkret(c4_get_chan(cp.channum, &cp
+   ret = mkret(c4_get_chan(cp.channum, &cp));
+   if (ret)
return ret;
 
if (copy_to_user(data, &cp, sizeof(struct sbecom_chan_param)))
@@ -864,7 +868,8 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
return -EPERM;
if (cmd != SIOCDEVPRIVATE + 15)
return -EINVAL;
-   if (!(ci = get_ci_by_dev(ndev)))
+   ci =  get_ci_by_dev(ndev);
+   if (!ci)
return -EINVAL;
if (ci->state != C_RUNNING)
return -ENODEV;
@@ -1100,9 +1105,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
tasklet_enable(&ci->ci_musycc_isr_tasklet);
 #endif
 
-
-   if ((error_flag = c4_init2(ci)) != SBE_DRVR_SUCCESS)
-   {
+   error_flag = c4_init2(ci);
+   if (error_flag != SBE_DRVR_SUCCESS) {
 #ifdef CONFIG_PROC_FS
sbecom_proc_brd_cleanup(ci);
 #endif
@@ -1123,7 +1127,8 @@ c4_mod_init(void)
int rtn;
 
pr_warning("%s\n", pmcc4_OSSI_release);
-   if ((rtn = c4hw_attach_all()))
+   rtn = c4hw_attach_all();
+   if (rtn)
return -rtn; /* installation failure - see system log */
 
/* housekeeping notifications */
@@ -1173,11 +1178,13 @@ cleanup_hdlc(void)
{
ci = (ci_t *)(netdev_priv(hi->ndev));
for (j = 0; j < ci->max_port; j++)
-   for (k = 0; k < MUSYCC_NCHANS; k++)
-   if ((ndev = ci->port[j].chan[k]->user))
+   for (k = 0; k < MUSYCC_NCHANS; k++) {
+   ndev = ci->port[j].chan[k]->user;
+   if (ndev)
{
do_deluser(ndev, 0);
}
+   }
}
}
 }
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/7 v3] staging: cxt1e1: fix checkpatch errors with open brace '{'

2014-03-04 Thread Daeseok Youn

clean up checkpatch.pl error in linux.c:
 ERROR: that open brace { should be on the previous line

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   67 ---
 1 files changed, 21 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index e4541af..478516f 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -242,8 +242,7 @@ c4_wq_port_cleanup(mpi_t *pi)
 * PORT POINT: cannot call this if WQ is statically allocated w/in
 * structure since it calls kfree(wq);
 */
-   if (pi->wq_port)
-   {
+   if (pi->wq_port) {
destroy_workqueue(pi->wq_port);/* this also calls
* flush_workqueue() */
pi->wq_port = NULL;
@@ -433,15 +432,13 @@ create_chan(struct net_device *ndev, ci_t *ci,
 
/* allocate then fill in private data structure */
priv = OS_kmalloc(sizeof(struct c4_priv));
-   if (!priv)
-   {
+   if (!priv) {
pr_warning("%s: no memory for net_device !\n",
   ci->devname);
return NULL;
}
dev = alloc_hdlcdev(priv);
-   if (!dev)
-   {
+   if (!dev) {
pr_warning("%s: no memory for hdlc_device !\n",
   ci->devname);
OS_kfree(priv);
@@ -459,10 +456,8 @@ create_chan(struct net_device *ndev, ci_t *ci,
*dev->name = 0; /* default ifconfig name = "hdlc" */
 
hi = (hdw_info_t *)ci->hdw_info;
-   if (hi->mfg_info_sts == EEPROM_OK)
-   {
-   switch (hi->promfmt)
-   {
+   if (hi->mfg_info_sts == EEPROM_OK) {
+   switch (hi->promfmt) {
case PROM_FORMAT_TYPE1:
memcpy(dev->dev_addr,
   (FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6);
@@ -476,9 +471,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
break;
}
} else
-   {
memset(dev->dev_addr, 0, 6);
-   }
 
hdlc->xmit = c4_linux_xmit;
 
@@ -502,8 +495,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
 
/* needed due to Ioctl calling sequence */
rtnl_lock();
-   if (ret)
-   {
+   if (ret) {
if (cxt1e1_log_level >= LOG_WARN)
pr_info("%s: create_chan[%d] registration error = 
%d.\n",
ci->devname, cp->channum, ret);
@@ -698,8 +690,7 @@ do_create_chan(struct net_device *ndev, void *data)
if (!dev)
return -EBUSY;
ret = mkret(c4_new_chan(ci, cp.port, cp.channum, dev));
-   if (ret)
-   {
+   if (ret) {
/* needed due to Ioctl calling sequence */
rtnl_unlock();
unregister_hdlc_device(dev);
@@ -805,8 +796,7 @@ do_reset(struct net_device *musycc_dev, void *data)
const struct c4_priv *priv;
int i;
 
-   for (i = 0; i < 128; i++)
-   {
+   for (i = 0; i < 128; i++) {
struct net_device *ndev;
charbuf[sizeof(CHANNAME) + 3];
 
@@ -817,8 +807,7 @@ do_reset(struct net_device *musycc_dev, void *data)
priv = dev_to_hdlc(ndev)->priv;
 
if ((unsigned long) (priv->ci) ==
-   (unsigned long) (netdev_priv(musycc_dev)))
-   {
+   (unsigned long) (netdev_priv(musycc_dev))) {
ndev->flags &= ~IFF_UP;
netif_stop_queue(ndev);
do_deluser(ndev, 1);
@@ -845,10 +834,8 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
void   *data;
int iocmd, iolen;
status_tret;
-   static struct data
-   {
-   union
-   {
+   static struct data {
+   union {
u_int8_t c;
u_int32_t i;
struct sbe_brd_info bip;
@@ -891,8 +878,7 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
return -EFAULT;
 
ret = 0;
-   switch (iocmd)
-   {
+   switch (iocmd) {
case SBE_IOC_PORT_GET:
//pr_info(">> SBE_IOC_PORT_GET Ioctl...\n");
ret = do_get_port(ndev, data);
@@ -975,8 +961,7 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
ci_t   *ci;
 
ndev = alloc_netdev(sizeof(ci_t), SBE_IFACETM

[PATCH 6/7] staging: cxtie1: remove unneeded mkret() calls

2014-03-04 Thread Daeseok Youn

The mkret() change a value of error from positive to
negative. This patch is modified to return negative value
when it failed. It doesn't need to call with function
for changing from positive to negative.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   72 +--
 drivers/staging/cxt1e1/musycc.c|2 +-
 drivers/staging/cxt1e1/pmcc4_drv.c |   40 ++--
 3 files changed, 48 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 478516f..5bb42ae 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -146,16 +146,6 @@ get_hdlc_name(hdlc_device *hdlc)
return dev->name;
 }
 
-
-static status_t
-mkret(int bsd)
-{
-   if (bsd > 0)
-   return -bsd;
-   else
-   return bsd;
-}
-
 /***/
 #include 
 
@@ -293,8 +283,8 @@ chan_open(struct net_device *ndev)
}
 
ret = c4_chan_up(priv->ci, priv->channum);
-   if (ret)
-   return -ret;
+   if (ret < 0)
+   return ret;
try_module_get(THIS_MODULE);
netif_start_queue(ndev);
return 0;   /* no error = success */
@@ -524,8 +514,8 @@ do_get_port(struct net_device *ndev, void *data)
if (!ci)
return -EINVAL; /* get card info */
 
-   ret = mkret(c4_get_port(ci, pp.portnum));
-   if (ret)
+   ret = c4_get_port(ci, pp.portnum);
+   if (ret < 0)
return ret;
if (copy_to_user(data, &ci->port[pp.portnum].p,
 sizeof(struct sbecom_port_param)))
@@ -552,7 +542,7 @@ do_set_port(struct net_device *ndev, void *data)
return -ENXIO;
 
memcpy(&ci->port[pp.portnum].p, &pp, sizeof(struct sbecom_port_param));
-   return mkret(c4_set_port(ci, pp.portnum));
+   return c4_set_port(ci, pp.portnum);
 }
 
 /* work the port loopback mode as per directed */
@@ -567,7 +557,7 @@ do_port_loop(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   return mkret(c4_loop_port(ci, pp.portnum, pp.port_mode));
+   return c4_loop_port(ci, pp.portnum, pp.port_mode);
 }
 
 /* set the specified register with the given value / or just read it */
@@ -583,8 +573,8 @@ do_framer_rw(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   ret = mkret(c4_frame_rw(ci, &pp));
-   if (ret)
+   ret = c4_frame_rw(ci, &pp);
+   if (ret < 0)
return ret;
if (copy_to_user(data, &pp, sizeof(struct sbecom_port_param)))
return -EFAULT;
@@ -604,7 +594,8 @@ do_pld_rw(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   ret = mkret(c4_pld_rw(ci, &pp));
+
+   ret = c4_pld_rw(ci, &pp);
if (ret)
return ret;
if (copy_to_user(data, &pp, sizeof(struct sbecom_port_param)))
@@ -625,8 +616,8 @@ do_musycc_rw(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   ret = mkret(c4_musycc_rw(ci, &mp));
-   if (ret)
+   ret = c4_musycc_rw(ci, &mp);
+   if (ret < 0)
return ret;
if (copy_to_user(data, &mp, sizeof(struct c4_musycc_param)))
return -EFAULT;
@@ -643,8 +634,8 @@ do_get_chan(struct net_device *ndev, void *data)
sizeof(struct sbecom_chan_param)))
return -EFAULT;
 
-   ret = mkret(c4_get_chan(cp.channum, &cp));
-   if (ret)
+   ret = c4_get_chan(cp.channum, &cp);
+   if (ret < 0)
return ret;
 
if (copy_to_user(data, &cp, sizeof(struct sbecom_chan_param)))
@@ -656,7 +647,6 @@ static status_t
 do_set_chan(struct net_device *ndev, void *data)
 {
struct sbecom_chan_param cp;
-   int ret;
ci_t   *ci;
 
if (copy_from_user(&cp, data, sizeof(struct sbecom_chan_param)))
@@ -664,13 +654,7 @@ do_set_chan(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   switch (ret = mkret(c4_set_chan(cp.channum, &cp)))
-   {
-   case 0:
-   return 0;
-   default:
-   return ret;
-   }
+   return c4_set_chan(cp.channum, &cp);
 }
 
 static status_t
@@ -689,8 +673,8 @@ do_create_chan(struct net_device *ndev, void *data)
dev = create_chan(ndev, ci, &cp);
if (!dev)
return -EBUSY;
-   ret = mkret(c4_new_chan(ci, cp.port, cp.channum, dev));
-   if (ret) {
+   ret 

[PATCH 7/7] staging: cxt1e1: remove unneeded a value

2014-03-04 Thread Daeseok Youn

It doesn't need to assign name array address to np pointer.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 5bb42ae..cae8c66 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -205,15 +205,14 @@ status_t
 c4_wq_port_init(mpi_t *pi)
 {
 
-   charname[16], *np;  /* NOTE: name of the queue limited by system
+   charname[16];  /* NOTE: name of the queue limited by system
 * to 10 characters */
 
if (pi->wq_port)
return 0;   /* already initialized */
 
-   np = name;
memset(name, 0, 16);
-   sprintf(np, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */
+   sprintf(name, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */
 
 #ifdef RLD_RESTART_DEBUG
pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: cxt1e1: use kzalloc instead of kmalloc/memset 0

2014-03-04 Thread Daeseok Youn

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/sbecom_inline_linux.h |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/cxt1e1/sbecom_inline_linux.h 
b/drivers/staging/cxt1e1/sbecom_inline_linux.h
index ba3ff3e..6dd1b55 100644
--- a/drivers/staging/cxt1e1/sbecom_inline_linux.h
+++ b/drivers/staging/cxt1e1/sbecom_inline_linux.h
@@ -46,11 +46,9 @@ voidpci_write_32 (u_int32_t *p, u_int32_t v);
 static inline void *
 OS_kmalloc (size_t size)
 {
-char   *ptr = kmalloc (size, GFP_KERNEL | GFP_DMA);
+   char *ptr = kzalloc(size, GFP_KERNEL | GFP_DMA);
 
-if (ptr)
-memset (ptr, 0, size);
-return ptr;
+   return ptr;
 }
 
 static inline void
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: dgap: remove useless cast on kzalloc()

2014-03-05 Thread Daeseok Youn

coccinelle warning:
drivers/staging/dgap/dgap.c:782:3-7: WARNING:
 casting value returned by k[cmz]alloc to (char *) is useless.
drivers/staging/dgap/dgap.c:776:2-16: WARNING:
 casting value returned by k[cmz]alloc to (struct board_t *) is useless.

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index cbce457..1adcd13 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -773,13 +773,13 @@ static int dgap_found_board(struct pci_dev *pdev, int id)
 
/* get the board structure and prep it */
brd = dgap_Board[dgap_NumBoards] =
-   (struct board_t *) kzalloc(sizeof(struct board_t), GFP_KERNEL);
+   kzalloc(sizeof(struct board_t), GFP_KERNEL);
if (!brd)
return -ENOMEM;
 
/* make a temporary message buffer for the boot messages */
brd->msgbuf = brd->msgbuf_head =
-   (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL);
+   kzalloc(sizeof(char) * 8192, GFP_KERNEL);
if (!brd->msgbuf) {
kfree(brd);
return -ENOMEM;
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging: cxt1e1: use kzalloc instead of kmalloc/memset 0

2014-03-05 Thread DaeSeok Youn
Thanks for review.

OK. I will try to change all of OS_kmalloc to kmalloc/kzalloc.
And I also check GFP_DMA flag in kmalloc/kzalloc.

Regards,
Daeseok Youn

2014-03-05 19:04 GMT+09:00 Tobias Klauser :
> On 2014-03-05 at 03:37:15 +0100, Daeseok Youn  wrote:
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>>  drivers/staging/cxt1e1/sbecom_inline_linux.h |6 ++
>>  1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/staging/cxt1e1/sbecom_inline_linux.h 
>> b/drivers/staging/cxt1e1/sbecom_inline_linux.h
>> index ba3ff3e..6dd1b55 100644
>> --- a/drivers/staging/cxt1e1/sbecom_inline_linux.h
>> +++ b/drivers/staging/cxt1e1/sbecom_inline_linux.h
>> @@ -46,11 +46,9 @@ voidpci_write_32 (u_int32_t *p, u_int32_t v);
>>  static inline void *
>>  OS_kmalloc (size_t size)
>>  {
>> -char   *ptr = kmalloc (size, GFP_KERNEL | GFP_DMA);
>> + char *ptr = kzalloc(size, GFP_KERNEL | GFP_DMA);
>>
>> -if (ptr)
>> -memset (ptr, 0, size);
>> -return ptr;
>> + return ptr;
>>  }
>
> It would probably be even better to get rid of this function altogether
> and replace all calls to it by kmalloc/kzalloc.
>
> From a quick look at the users of OS_kmalloc, it also looks like GFP_DMA
> isn't needed for all of them.
>
> Cheers
> Tobias
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 7/7] staging: cxt1e1: remove unneeded a value

2014-03-05 Thread DaeSeok Youn
2014-03-05 19:13 GMT+09:00 Tobias Klauser :
> On 2014-03-05 at 02:24:22 +0100, Daeseok Youn  wrote:
>>
>> It doesn't need to assign name array address to np pointer.
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>>  drivers/staging/cxt1e1/linux.c |5 ++---
>>  1 files changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
>> index 5bb42ae..cae8c66 100644
>> --- a/drivers/staging/cxt1e1/linux.c
>> +++ b/drivers/staging/cxt1e1/linux.c
>> @@ -205,15 +205,14 @@ status_t
>>  c4_wq_port_init(mpi_t *pi)
>>  {
>>
>> - charname[16], *np;  /* NOTE: name of the queue limited by 
>> system
>> + charname[16];  /* NOTE: name of the queue limited by system
>>* to 10 characters */
>>
>>   if (pi->wq_port)
>>   return 0;   /* already initialized */
>>
>> - np = name;
>>   memset(name, 0, 16);
>
> This isn't necessary since s{,n}printf() adds a terminating '\0'.
Yes, I have looked at lib/vsprintf.c. I found it adds null to a string
in the end of vsnprintf() function.
I will remove memset() line.

>
>> - sprintf(np, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */
>> + sprintf(name, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */
>
> Better use snprintf() here, even if the comment above claims the name
> never to be no longer than 10 characters.
OK. I will replace sprintf with snprintf() and set a string length to "10".

Thanks for review.
Daeseok Youn.
>
> Cheers
> Tobias
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 7/7] staging: cxt1e1: remove unneeded a value

2014-03-05 Thread DaeSeok Youn
Ok.
I will use sizeof(name) for snprintf() call.

Thanks.
Daeseok Youn.

2014-03-06 16:33 GMT+09:00 Tobias Klauser :
> On 2014-03-06 at 08:19:19 +0100, DaeSeok Youn  wrote:
>> 2014-03-05 19:13 GMT+09:00 Tobias Klauser :
>> > On 2014-03-05 at 02:24:22 +0100, Daeseok Youn  
>> > wrote:
>> >>
>> >> It doesn't need to assign name array address to np pointer.
>> >>
>> >> Signed-off-by: Daeseok Youn 
>> >> ---
>> >>  drivers/staging/cxt1e1/linux.c |5 ++---
>> >>  1 files changed, 2 insertions(+), 3 deletions(-)
>> >>
>> >> diff --git a/drivers/staging/cxt1e1/linux.c 
>> >> b/drivers/staging/cxt1e1/linux.c
>> >> index 5bb42ae..cae8c66 100644
>> >> --- a/drivers/staging/cxt1e1/linux.c
>> >> +++ b/drivers/staging/cxt1e1/linux.c
>> >> @@ -205,15 +205,14 @@ status_t
>> >>  c4_wq_port_init(mpi_t *pi)
>> >>  {
>> >>
>> >> - charname[16], *np;  /* NOTE: name of the queue limited by 
>> >> system
>> >> + charname[16];  /* NOTE: name of the queue limited by system
>> >>* to 10 characters */
>> >>
>> >>   if (pi->wq_port)
>> >>   return 0;   /* already initialized */
>> >>
>> >> - np = name;
>> >>   memset(name, 0, 16);
>> >
>> > This isn't necessary since s{,n}printf() adds a terminating '\0'.
>> Yes, I have looked at lib/vsprintf.c. I found it adds null to a string
>> in the end of vsnprintf() function.
>> I will remove memset() line.
>>
>> >
>> >> - sprintf(np, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) 
>> >> */
>> >> + sprintf(name, "%s%d", pi->up->devname, pi->portnum); /* IE 
>> >> pmcc4-01) */
>> >
>> > Better use snprintf() here, even if the comment above claims the name
>> > never to be no longer than 10 characters.
>> OK. I will replace sprintf with snprintf() and set a string length to "10".
>
> It's probably fine to leave the string at length 16 (since there's also
> a number appended to it) and the use sizeof(name) for the snprintf call.
>
> Cheers
> Tobias
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 7/7] staging: cxt1e1: remove unneeded a value

2014-03-06 Thread Daeseok Youn

It doesn't need to assign name array address to np pointer.

Signed-off-by: Daeseok Youn 
---
v2: replace sprintf() with snprintf() and remove memset() call
because snprintf() adds a terminating '\0'

 drivers/staging/cxt1e1/linux.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 5bb42ae..9ac48ee 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -205,15 +205,13 @@ status_t
 c4_wq_port_init(mpi_t *pi)
 {
 
-   charname[16], *np;  /* NOTE: name of the queue limited by system
+   charname[16];  /* NOTE: name of the queue limited by system
 * to 10 characters */
-
if (pi->wq_port)
return 0;   /* already initialized */
 
-   np = name;
-   memset(name, 0, 16);
-   sprintf(np, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */
+   /* IE pmcc4-01 */
+   snprintf(name, sizeof(name), "%s%d", pi->up->devname, pi->portnum);
 
 #ifdef RLD_RESTART_DEBUG
pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/7 v3] staging: cxt1e1: fix checkpatch error 'assignment in if condition'

2014-03-06 Thread DaeSeok Youn
Sorry for confusing you.
Actually 1-3 patches already merged to staging-next branch.

And then I had a request resending the rest of the series.
So I just sent 4-7 again. Sorry, I should rebase these patches and
make a series newly.

I will send patches again properly.
I think this patches need to rebase current staging-next branch.

Thanks.
Daeseok Youn.

2014-03-07 4:57 GMT+09:00 Greg KH :
> On Wed, Mar 05, 2014 at 10:21:01AM +0900, Daeseok Youn wrote:
>>
>> checkpatch.pl error in linux.c:
>>  ERROR: do not use assignment in if condition
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>>  drivers/staging/cxt1e1/linux.c |   31 +++
>>  1 files changed, 19 insertions(+), 12 deletions(-)
>
> I don't see patches 1-3 here, so I'm dropping this whole series.
>
> I do not have any short-term, or long-term, memory about patches I've
> rejected / approved / discussed, as I deal with thousands of them every
> week.  You need to be explicit as to what is going on, and don't try to
> confused me.
>
> Please resend properly.
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 7/7] staging: cxt1e1: remove unneeded a value

2014-03-06 Thread DaeSeok Youn
Ok.
I will fix it and send again.

Thanks.
Daeseok Youn

2014-03-07 4:58 GMT+09:00 Greg KH :
> On Thu, Mar 06, 2014 at 05:12:48PM +0900, Daeseok Youn wrote:
>>
>> It doesn't need to assign name array address to np pointer.
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>> v2: replace sprintf() with snprintf() and remove memset() call
>> because snprintf() adds a terminating '\0'
>
> Your Subject: does not make sense, please fix it up and resend.
>
> thanks,
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] staging: cxt1e1: fix checkpatch error 'assignment in if condition'

2014-03-06 Thread Daeseok Youn

checkpatch.pl error in linux.c:
 ERROR: do not use assignment in if condition

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   31 +++
 1 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 2924c39..4eadd29 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -228,7 +228,8 @@ c4_wq_port_init(mpi_t *pi)
pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
__func__, name, pi->portnum); /* RLD DEBUG */
 #endif
-   if (!(pi->wq_port = create_singlethread_workqueue(name)))
+   pi->wq_port = create_singlethread_workqueue(name);
+   if (!pi->wq_port)
return -ENOMEM;
return 0;   /* success */
 }
@@ -285,12 +286,14 @@ chan_open(struct net_device *ndev)
const struct c4_priv *priv = hdlc->priv;
int ret;
 
-   if ((ret = hdlc_open(ndev)))
-   {
+   ret = hdlc_open(ndev);
+   if (ret) {
pr_info("hdlc_open failure, err %d.\n", ret);
return ret;
}
-   if ((ret = c4_chan_up(priv->ci, priv->channum)))
+
+   ret = c4_chan_up(priv->ci, priv->channum);
+   if (ret)
return -ret;
try_module_get(THIS_MODULE);
netif_start_queue(ndev);
@@ -647,7 +650,8 @@ do_get_chan(struct net_device *ndev, void *data)
sizeof(struct sbecom_chan_param)))
return -EFAULT;
 
-   if ((ret = mkret(c4_get_chan(cp.channum, &cp
+   ret = mkret(c4_get_chan(cp.channum, &cp));
+   if (ret)
return ret;
 
if (copy_to_user(data, &cp, sizeof(struct sbecom_chan_param)))
@@ -863,7 +867,8 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
return -EPERM;
if (cmd != SIOCDEVPRIVATE + 15)
return -EINVAL;
-   if (!(ci = get_ci_by_dev(ndev)))
+   ci = get_ci_by_dev(ndev);
+   if (!ci)
return -EINVAL;
if (ci->state != C_RUNNING)
return -ENODEV;
@@ -1098,9 +1103,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
tasklet_enable(&ci->ci_musycc_isr_tasklet);
 #endif
 
-
-   if ((error_flag = c4_init2(ci)) != SBE_DRVR_SUCCESS)
-   {
+   error_flag = c4_init2(ci);
+   if (error_flag != SBE_DRVR_SUCCESS) {
 #ifdef CONFIG_PROC_FS
sbecom_proc_brd_cleanup(ci);
 #endif
@@ -1120,7 +1124,8 @@ c4_mod_init(void)
 {
int rtn;
 
-   if ((rtn = c4hw_attach_all()))
+   rtn = c4hw_attach_all();
+   if (rtn)
return -rtn; /* installation failure - see system log */
 
/* housekeeping notifications */
@@ -1170,11 +1175,13 @@ cleanup_hdlc(void)
{
ci = (ci_t *)(netdev_priv(hi->ndev));
for (j = 0; j < ci->max_port; j++)
-   for (k = 0; k < MUSYCC_NCHANS; k++)
-   if ((ndev = ci->port[j].chan[k]->user))
+   for (k = 0; k < MUSYCC_NCHANS; k++) {
+   ndev = ci->port[j].chan[k]->user;
+   if (ndev)
{
do_deluser(ndev, 0);
}
+   }
}
}
 }
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] staging: cxt1e1: fix checkpatch errors with open brace '{'

2014-03-06 Thread Daeseok Youn

clean up checkpatch.pl error in linux.c:
 ERROR: that open brace { should be on the previous line

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   67 ---
 1 files changed, 21 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 4eadd29..549efd1 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -241,8 +241,7 @@ c4_wq_port_cleanup(mpi_t *pi)
 * PORT POINT: cannot call this if WQ is statically allocated w/in
 * structure since it calls kfree(wq);
 */
-   if (pi->wq_port)
-   {
+   if (pi->wq_port) {
destroy_workqueue(pi->wq_port);/* this also calls
* flush_workqueue() */
pi->wq_port = NULL;
@@ -432,15 +431,13 @@ create_chan(struct net_device *ndev, ci_t *ci,
 
/* allocate then fill in private data structure */
priv = OS_kmalloc(sizeof(struct c4_priv));
-   if (!priv)
-   {
+   if (!priv) {
pr_warning("%s: no memory for net_device !\n",
   ci->devname);
return NULL;
}
dev = alloc_hdlcdev(priv);
-   if (!dev)
-   {
+   if (!dev) {
pr_warning("%s: no memory for hdlc_device !\n",
   ci->devname);
OS_kfree(priv);
@@ -458,10 +455,8 @@ create_chan(struct net_device *ndev, ci_t *ci,
*dev->name = 0; /* default ifconfig name = "hdlc" */
 
hi = (hdw_info_t *)ci->hdw_info;
-   if (hi->mfg_info_sts == EEPROM_OK)
-   {
-   switch (hi->promfmt)
-   {
+   if (hi->mfg_info_sts == EEPROM_OK) {
+   switch (hi->promfmt) {
case PROM_FORMAT_TYPE1:
memcpy(dev->dev_addr,
   (FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6);
@@ -475,9 +470,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
break;
}
} else
-   {
memset(dev->dev_addr, 0, 6);
-   }
 
hdlc->xmit = c4_linux_xmit;
 
@@ -501,8 +494,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
 
/* needed due to Ioctl calling sequence */
rtnl_lock();
-   if (ret)
-   {
+   if (ret) {
if (cxt1e1_log_level >= LOG_WARN)
pr_info("%s: create_chan[%d] registration error = 
%d.\n",
ci->devname, cp->channum, ret);
@@ -697,8 +689,7 @@ do_create_chan(struct net_device *ndev, void *data)
if (!dev)
return -EBUSY;
ret = mkret(c4_new_chan(ci, cp.port, cp.channum, dev));
-   if (ret)
-   {
+   if (ret) {
/* needed due to Ioctl calling sequence */
rtnl_unlock();
unregister_hdlc_device(dev);
@@ -804,8 +795,7 @@ do_reset(struct net_device *musycc_dev, void *data)
const struct c4_priv *priv;
int i;
 
-   for (i = 0; i < 128; i++)
-   {
+   for (i = 0; i < 128; i++) {
struct net_device *ndev;
charbuf[sizeof(CHANNAME) + 3];
 
@@ -816,8 +806,7 @@ do_reset(struct net_device *musycc_dev, void *data)
priv = dev_to_hdlc(ndev)->priv;
 
if ((unsigned long) (priv->ci) ==
-   (unsigned long) (netdev_priv(musycc_dev)))
-   {
+   (unsigned long) (netdev_priv(musycc_dev))) {
ndev->flags &= ~IFF_UP;
netif_stop_queue(ndev);
do_deluser(ndev, 1);
@@ -844,10 +833,8 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
void   *data;
int iocmd, iolen;
status_tret;
-   static struct data
-   {
-   union
-   {
+   static struct data {
+   union {
u_int8_t c;
u_int32_t i;
struct sbe_brd_info bip;
@@ -890,8 +877,7 @@ c4_ioctl(struct net_device *ndev, struct ifreq *ifr, int 
cmd)
return -EFAULT;
 
ret = 0;
-   switch (iocmd)
-   {
+   switch (iocmd) {
case SBE_IOC_PORT_GET:
//pr_info(">> SBE_IOC_PORT_GET Ioctl...\n");
ret = do_get_port(ndev, data);
@@ -974,8 +960,7 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
ci_t   *ci;
 
ndev = alloc_netdev(sizeof(ci_t), SBE_IFACETM

[PATCH 3/4] staging: cxtie1: remove unneeded mkret() calls

2014-03-06 Thread Daeseok Youn

The mkret() change a value of error from positive to
negative. This patch is modified to return negative value
when it failed. It doesn't need to call with function
for changing from positive to negative.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |   72 +--
 drivers/staging/cxt1e1/musycc.c|2 +-
 drivers/staging/cxt1e1/pmcc4_drv.c |   40 ++--
 3 files changed, 48 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 549efd1..5d7ddd4 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -145,16 +145,6 @@ get_hdlc_name(hdlc_device *hdlc)
return dev->name;
 }
 
-
-static status_t
-mkret(int bsd)
-{
-   if (bsd > 0)
-   return -bsd;
-   else
-   return bsd;
-}
-
 /***/
 #include 
 
@@ -292,8 +282,8 @@ chan_open(struct net_device *ndev)
}
 
ret = c4_chan_up(priv->ci, priv->channum);
-   if (ret)
-   return -ret;
+   if (ret < 0)
+   return ret;
try_module_get(THIS_MODULE);
netif_start_queue(ndev);
return 0;   /* no error = success */
@@ -523,8 +513,8 @@ do_get_port(struct net_device *ndev, void *data)
if (!ci)
return -EINVAL; /* get card info */
 
-   ret = mkret(c4_get_port(ci, pp.portnum));
-   if (ret)
+   ret = c4_get_port(ci, pp.portnum);
+   if (ret < 0)
return ret;
if (copy_to_user(data, &ci->port[pp.portnum].p,
 sizeof(struct sbecom_port_param)))
@@ -551,7 +541,7 @@ do_set_port(struct net_device *ndev, void *data)
return -ENXIO;
 
memcpy(&ci->port[pp.portnum].p, &pp, sizeof(struct sbecom_port_param));
-   return mkret(c4_set_port(ci, pp.portnum));
+   return c4_set_port(ci, pp.portnum);
 }
 
 /* work the port loopback mode as per directed */
@@ -566,7 +556,7 @@ do_port_loop(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   return mkret(c4_loop_port(ci, pp.portnum, pp.port_mode));
+   return c4_loop_port(ci, pp.portnum, pp.port_mode);
 }
 
 /* set the specified register with the given value / or just read it */
@@ -582,8 +572,8 @@ do_framer_rw(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   ret = mkret(c4_frame_rw(ci, &pp));
-   if (ret)
+   ret = c4_frame_rw(ci, &pp);
+   if (ret < 0)
return ret;
if (copy_to_user(data, &pp, sizeof(struct sbecom_port_param)))
return -EFAULT;
@@ -603,7 +593,8 @@ do_pld_rw(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   ret = mkret(c4_pld_rw(ci, &pp));
+
+   ret = c4_pld_rw(ci, &pp);
if (ret)
return ret;
if (copy_to_user(data, &pp, sizeof(struct sbecom_port_param)))
@@ -624,8 +615,8 @@ do_musycc_rw(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   ret = mkret(c4_musycc_rw(ci, &mp));
-   if (ret)
+   ret = c4_musycc_rw(ci, &mp);
+   if (ret < 0)
return ret;
if (copy_to_user(data, &mp, sizeof(struct c4_musycc_param)))
return -EFAULT;
@@ -642,8 +633,8 @@ do_get_chan(struct net_device *ndev, void *data)
sizeof(struct sbecom_chan_param)))
return -EFAULT;
 
-   ret = mkret(c4_get_chan(cp.channum, &cp));
-   if (ret)
+   ret = c4_get_chan(cp.channum, &cp);
+   if (ret < 0)
return ret;
 
if (copy_to_user(data, &cp, sizeof(struct sbecom_chan_param)))
@@ -655,7 +646,6 @@ static status_t
 do_set_chan(struct net_device *ndev, void *data)
 {
struct sbecom_chan_param cp;
-   int ret;
ci_t   *ci;
 
if (copy_from_user(&cp, data, sizeof(struct sbecom_chan_param)))
@@ -663,13 +653,7 @@ do_set_chan(struct net_device *ndev, void *data)
ci = get_ci_by_dev(ndev);
if (!ci)
return -EINVAL;
-   switch (ret = mkret(c4_set_chan(cp.channum, &cp)))
-   {
-   case 0:
-   return 0;
-   default:
-   return ret;
-   }
+   return c4_set_chan(cp.channum, &cp);
 }
 
 static status_t
@@ -688,8 +672,8 @@ do_create_chan(struct net_device *ndev, void *data)
dev = create_chan(ndev, ci, &cp);
if (!dev)
return -EBUSY;
-   ret = mkret(c4_new_chan(ci, cp.port, cp.channum, dev));
-   if (ret) {
+   ret 

[PATCH 4/4] staging: cxt1e1: remove redundant memset() call

2014-03-06 Thread Daeseok Youn

The name array doens't need to set to 0. Because
sprintf/snprintf adds a terminating '\0'.

And also it doesn't need to assign name array
address to np pointer.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/linux.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 5d7ddd4..efd3eb8 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -204,15 +204,13 @@ status_t
 c4_wq_port_init(mpi_t *pi)
 {
 
-   charname[16], *np;  /* NOTE: name of the queue limited by system
+   charname[16];  /* NOTE: name of the queue limited by system
 * to 10 characters */
-
if (pi->wq_port)
return 0;   /* already initialized */
 
-   np = name;
-   memset(name, 0, 16);
-   sprintf(np, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */
+   /* IE pmcc4-01 */
+   snprintf(name, sizeof(name), "%s%d", pi->up->devname, pi->portnum);
 
 #ifdef RLD_RESTART_DEBUG
pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
-- 
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] staging: lustre: make functions as static

2014-02-26 Thread Daeseok Youn

These functions are only referenced in this file scope
so it can be marked static.
And remove space between function name and open parenthesis.

Signed-off-by: Daeseok Youn 
---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|   70 ++--
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 644a000..0727998 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -41,7 +41,7 @@
 #include "o2iblnd.h"
 #include 
 
-lnd_t the_o2iblnd = {
+static lnd_t the_o2iblnd = {
.lnd_type   = O2IBLND,
.lnd_startup= kiblnd_startup,
.lnd_shutdown   = kiblnd_shutdown,
@@ -53,8 +53,8 @@ lnd_t the_o2iblnd = {
 
 kib_data_t   kiblnd_data;
 
-__u32
-kiblnd_cksum (void *ptr, int nob)
+static __u32
+kiblnd_cksum(void *ptr, int nob)
 {
char  *c  = ptr;
__u32  sum = 0;
@@ -429,8 +429,8 @@ kiblnd_unlink_peer_locked (kib_peer_t *peer)
kiblnd_peer_decref(peer);
 }
 
-int
-kiblnd_get_peer_info (lnet_ni_t *ni, int index,
+static int
+kiblnd_get_peer_info(lnet_ni_t *ni, int index,
  lnet_nid_t *nidp, int *count)
 {
kib_peer_t  *peer;
@@ -468,8 +468,8 @@ kiblnd_get_peer_info (lnet_ni_t *ni, int index,
return -ENOENT;
 }
 
-void
-kiblnd_del_peer_locked (kib_peer_t *peer)
+static void
+kiblnd_del_peer_locked(kib_peer_t *peer)
 {
struct list_head   *ctmp;
struct list_head   *cnxt;
@@ -489,8 +489,8 @@ kiblnd_del_peer_locked (kib_peer_t *peer)
 * last ref on it. */
 }
 
-int
-kiblnd_del_peer (lnet_ni_t *ni, lnet_nid_t nid)
+static int
+kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
 {
LIST_HEAD(zombies);
struct list_head*ptmp;
@@ -543,8 +543,8 @@ kiblnd_del_peer (lnet_ni_t *ni, lnet_nid_t nid)
return rc;
 }
 
-kib_conn_t *
-kiblnd_get_conn_by_idx (lnet_ni_t *ni, int index)
+static kib_conn_t *
+kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index)
 {
kib_peer_t  *peer;
struct list_head*ptmp;
@@ -584,16 +584,16 @@ kiblnd_get_conn_by_idx (lnet_ni_t *ni, int index)
return NULL;
 }
 
-void
-kiblnd_debug_rx (kib_rx_t *rx)
+static void
+kiblnd_debug_rx(kib_rx_t *rx)
 {
CDEBUG(D_CONSOLE, "  %p status %d msg_type %x cred %d\n",
   rx, rx->rx_status, rx->rx_msg->ibm_type,
   rx->rx_msg->ibm_credits);
 }
 
-void
-kiblnd_debug_tx (kib_tx_t *tx)
+static void
+kiblnd_debug_tx(kib_tx_t *tx)
 {
CDEBUG(D_CONSOLE, "  %p snd %d q %d w %d rc %d dl %lx "
   "cookie "LPX64" msg %s%s type %x cred %d\n",
@@ -604,8 +604,8 @@ kiblnd_debug_tx (kib_tx_t *tx)
   tx->tx_msg->ibm_type, tx->tx_msg->ibm_credits);
 }
 
-void
-kiblnd_debug_conn (kib_conn_t *conn)
+static void
+kiblnd_debug_conn(kib_conn_t *conn)
 {
struct list_head*tmp;
int i;
@@ -1039,8 +1039,8 @@ kiblnd_close_stale_conns_locked (kib_peer_t *peer,
return count;
 }
 
-int
-kiblnd_close_matching_conns (lnet_ni_t *ni, lnet_nid_t nid)
+static int
+kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
 {
kib_peer_t   *peer;
struct list_head *ptmp;
@@ -1440,7 +1440,7 @@ kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev, 
kib_rdma_desc_t *rd)
return mr;
 }
 
-void
+static void
 kiblnd_destroy_fmr_pool(kib_fmr_pool_t *pool)
 {
LASSERT (pool->fpo_map_count == 0);
@@ -1454,7 +1454,7 @@ kiblnd_destroy_fmr_pool(kib_fmr_pool_t *pool)
LIBCFS_FREE(pool, sizeof(kib_fmr_pool_t));
 }
 
-void
+static void
 kiblnd_destroy_fmr_pool_list(struct list_head *head)
 {
kib_fmr_pool_t *pool;
@@ -1480,7 +1480,7 @@ static int kiblnd_fmr_flush_trigger(int ncpts)
return max(IBLND_FMR_POOL_FLUSH, size);
 }
 
-int
+static int
 kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t **pp_fpo)
 {
/* FMR pool for RDMA */
@@ -1719,7 +1719,7 @@ kiblnd_init_pool(kib_poolset_t *ps, kib_pool_t *pool, int 
size)
pool->po_size = size;
 }
 
-void
+static void
 kiblnd_destroy_pool_list(struct list_head *head)
 {
kib_pool_t *pool;
@@ -2192,7 +2192,7 @@ kiblnd_tx_init(kib_pool_t *pool, struct list_head *node)
tx->tx_cookie = tps->tps_next_tx_cookie ++;
 }
 
-void
+static void
 kiblnd_net_fini_pools(kib_net_t *net)
 {
int i;
@@ -2234,7 +2234,7 @@ kiblnd_net_fini_pools(kib_net_t *net)
}
 }
 
-int
+static int
 kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
 {
unsigned long   flags;
@@ -2408,7 +2408,7 @@ kiblnd_hdev_get_attr(kib_hca_dev_t *hdev)
return -EINVAL;
 }
 
-void
+static void
 kiblnd_hdev_cleanup_mrs(kib_hca_dev_t *hdev)
 {
int i;
@@ -24

[PATCH 1/2] staging: bcm: Remove unneeded set a variable

2014-02-27 Thread Daeseok Youn

bClassificationSucceed is initialized with "false",
do not need to set "false" again.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/bcm/Qos.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c
index 0727599..ead57b4 100644
--- a/drivers/staging/bcm/Qos.c
+++ b/drivers/staging/bcm/Qos.c
@@ -222,10 +222,7 @@ static USHORT  IpVersion4(struct bcm_mini_adapter 
*Adapter,
 
//Checking classifier validity
if (!pstClassifierRule->bUsed || pstClassifierRule->ucDirection 
== DOWNLINK_DIR)
-   {
-   bClassificationSucceed = false;
break;
-   }
 
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, 
"is IPv6 check!");
if (pstClassifierRule->bIpv6Protocol)
-- 
1.7.9.5

---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] staging: bcm: fix checkpatch error 'assignment in if condition'

2014-02-27 Thread Daeseok Youn

clean up checkpatch errors and bClassificationSucceed is set to "TRUE"
proper location.

If protocal is not TCP or UDP, when it checks protocal, bClassificationSucceed
must be set to TRUE.
Also the end of do-while(0) loop, bClassificationSucceed is set to TRUE.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/bcm/Qos.c |   32 ++--
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c
index ead57b4..4f31583 100644
--- a/drivers/staging/bcm/Qos.c
+++ b/drivers/staging/bcm/Qos.c
@@ -230,51 +230,47 @@ static USHORT IpVersion4(struct bcm_mini_adapter 
*Adapter,
 
//**Checking IP header 
parameter**//
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, 
"Trying to match Source IP Address");
-   if (false == (bClassificationSucceed =
-   MatchSrcIpAddress(pstClassifierRule, iphd->saddr)))
+   if (!MatchSrcIpAddress(pstClassifierRule, iphd->saddr))
break;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, 
"Source IP Address Matched");
 
-   if (false == (bClassificationSucceed =
-   MatchDestIpAddress(pstClassifierRule, iphd->daddr)))
+   if (!MatchDestIpAddress(pstClassifierRule, iphd->daddr))
break;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, 
"Destination IP Address Matched");
 
-   if (false == (bClassificationSucceed =
-   MatchTos(pstClassifierRule, iphd->tos)))
-   {
+   if (!MatchTos(pstClassifierRule, iphd->tos)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, 
DBG_LVL_ALL, "TOS Match failed\n");
break;
}
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, 
"TOS Matched");
 
-   if (false == (bClassificationSucceed =
-   MatchProtocol(pstClassifierRule, iphd->protocol)))
+   if (!MatchProtocol(pstClassifierRule, iphd->protocol))
break;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, 
"Protocol Matched");
 
//if protocol is not TCP or UDP then no need of comparing 
source port and destination port
-   if (iphd->protocol != TCP && iphd->protocol != UDP)
+   if (iphd->protocol != TCP && iphd->protocol != UDP) {
+   bClassificationSucceed = TRUE;
break;
+   }
//**Checking Transport Layer Header field if 
present *//
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, 
"Source Port %04x",
(iphd->protocol == UDP) ? xprt_hdr->uhdr.source : 
xprt_hdr->thdr.source);
 
-   if (false == (bClassificationSucceed =
-   MatchSrcPort(pstClassifierRule,
-   ntohs((iphd->protocol == UDP) ?
-   xprt_hdr->uhdr.source : 
xprt_hdr->thdr.source
+   if (!MatchSrcPort(pstClassifierRule,
+ ntohs((iphd->protocol == UDP) ?
+ xprt_hdr->uhdr.source : 
xprt_hdr->thdr.source)))
break;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, 
"Src Port Matched");
 
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, 
"Destination Port %04x",
(iphd->protocol == UDP) ? xprt_hdr->uhdr.dest :
xprt_hdr->thdr.dest);
-   if (false == (bClassificationSucceed =
-   MatchDestPort(pstClassifierRule,
-   ntohs((iphd->protocol == UDP) ?
-   xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest
+   if (!MatchDestPort(pstClassifierRule,
+  ntohs((iphd->protocol == UDP) ?
+  xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest)))
break;
+   bClassificationSucceed = TRUE;
} while (0);
 
if (TRUE == bClassificationSucceed)
-- 
1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: cxt1e1: remove unused variable

2014-02-27 Thread Daeseok Youn

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/hwprobe.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c
index 02b4f8f..07de83f 100644
--- a/drivers/staging/cxt1e1/hwprobe.c
+++ b/drivers/staging/cxt1e1/hwprobe.c
@@ -49,10 +49,9 @@ show_two (hdw_info_t *hi, int brdno)
 ci_t   *ci;
 struct pci_dev *pdev;
 char   *bid;
-char   *bp, banner[80];
+char   banner[80];
 charsn[6];
 
-bp = banner;
 memset (banner, 0, 80); /* clear print buffer */
 
 ci = (ci_t *)(netdev_priv(hi->ndev));
-- 
1.7.9.5

---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/5] staging: cxt1e1: remove space between function name and parenthesis

2014-02-27 Thread Daeseok Youn

clean up checkpatch.pl warnings:
 WARNING: space prohibited between function name
 and open parenthesis '('

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/hwprobe.c |  120 +++---
 1 file changed, 60 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c
index 07de83f..5e93580 100644
--- a/drivers/staging/cxt1e1/hwprobe.c
+++ b/drivers/staging/cxt1e1/hwprobe.c
@@ -36,15 +36,15 @@ extern int  error_flag;
 extern int  drvr_state;
 
 /* forward references */
-voidc4_stopwd (ci_t *);
-struct net_device * __init c4_add_dev (hdw_info_t *, int, unsigned long, 
unsigned long, int, int);
+voidc4_stopwd(ci_t *);
+struct net_device * __init c4_add_dev(hdw_info_t *, int, unsigned long, 
unsigned long, int, int);
 
 
 struct s_hdw_info hdw_info[MAX_BOARDS];
 
 
 void__init
-show_two (hdw_info_t *hi, int brdno)
+show_two(hdw_info_t *hi, int brdno)
 {
 ci_t   *ci;
 struct pci_dev *pdev;
@@ -52,26 +52,26 @@ show_two (hdw_info_t *hi, int brdno)
 char   banner[80];
 charsn[6];
 
-memset (banner, 0, 80); /* clear print buffer */
+memset(banner, 0, 80); /* clear print buffer */
 
 ci = (ci_t *)(netdev_priv(hi->ndev));
-bid = sbeid_get_bdname (ci);
+bid = sbeid_get_bdname(ci);
 switch (hi->promfmt)
 {
 case PROM_FORMAT_TYPE1:
-memcpy (sn, (FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6);
+memcpy(sn, (FLD_TYPE1 *)(hi->mfg_info.pft1.Serial), 6);
 break;
 case PROM_FORMAT_TYPE2:
-memcpy (sn, (FLD_TYPE2 *) (hi->mfg_info.pft2.Serial), 6);
+memcpy(sn, (FLD_TYPE2 *)(hi->mfg_info.pft2.Serial), 6);
 break;
 default:
-memset (sn, 0, 6);
+memset(sn, 0, 6);
 break;
 }
 
-sprintf (banner, "%s: %s  S/N %06X, MUSYCC Rev %02X",
- hi->devname, bid,
- ((sn[3] << 16) & 0xff) |
+sprintf(banner, "%s: %s  S/N %06X, MUSYCC Rev %02X",
+hi->devname, bid,
+((sn[3] << 16) & 0xff) |
   ((sn[4] << 8) & 0x00ff00) |
   (sn[5] & 0xff),
  (u_int8_t) hi->revid[0]);
@@ -82,20 +82,20 @@ show_two (hdw_info_t *hi, int brdno)
 pr_info("%s: %s at v/p=%lx/%lx (%02x:%02x.%x) irq %d\n",
 hi->devname, "MUSYCC",
 (unsigned long) hi->addr_mapped[0], hi->addr[0],
-hi->pci_busno, (u_int8_t) PCI_SLOT (pdev->devfn),
-(u_int8_t) PCI_FUNC (pdev->devfn), pdev->irq);
+hi->pci_busno, (u_int8_t)PCI_SLOT(pdev->devfn),
+(u_int8_t)PCI_FUNC(pdev->devfn), pdev->irq);
 
 pdev = hi->pdev[1];
 pr_info("%s: %s at v/p=%lx/%lx (%02x:%02x.%x) irq %d\n",
 hi->devname, "EBUS  ",
 (unsigned long) hi->addr_mapped[1], hi->addr[1],
-hi->pci_busno, (u_int8_t) PCI_SLOT (pdev->devfn),
-(u_int8_t) PCI_FUNC (pdev->devfn), pdev->irq);
+hi->pci_busno, (u_int8_t)PCI_SLOT(pdev->devfn),
+(u_int8_t)PCI_FUNC(pdev->devfn), pdev->irq);
 }
 
 
 void__init
-hdw_sn_get (hdw_info_t *hi, int brdno)
+hdw_sn_get(hdw_info_t *hi, int brdno)
 {
 /* obtain hardware EEPROM information */
 longaddr;
@@ -103,7 +103,7 @@ hdw_sn_get (hdw_info_t *hi, int brdno)
 addr = (long) hi->addr_mapped[1] + EEPROM_OFFSET;
 
 /* read EEPROM with largest known format size... */
-pmc_eeprom_read_buffer (addr, 0, (char *) hi->mfg_info.data, sizeof 
(FLD_TYPE2));
+pmc_eeprom_read_buffer(addr, 0, (char *)hi->mfg_info.data, 
sizeof(FLD_TYPE2));
 
 #if 0
 {
@@ -133,7 +133,7 @@ hdw_sn_get (hdw_info_t *hi, int brdno)
 hi->mfg_info.Serial[5]);
 #endif
 
-if ((hi->promfmt = pmc_verify_cksum (&hi->mfg_info.data)) == 
PROM_FORMAT_Unk)
+if ((hi->promfmt = pmc_verify_cksum(&hi->mfg_info.data)) == 
PROM_FORMAT_Unk)
 {
 /* bad crc, data is suspect */
 if (cxt1e1_log_level >= LOG_WARN)
@@ -145,7 +145,7 @@ hdw_sn_get (hdw_info_t *hi, int brdno)
 
 
 void__init
-prep_hdw_info (void)
+prep_hdw_info(void)
 {
 hdw_info_t *hi;
 int i;
@@ -165,7 +165,7 @@ prep_hdw_info (void)
 }
 
 void
-cleanup_ioremap (void)
+cleanup_ioremap(void)
 {
 hdw_info_t *hi;
 int i;
@@ -176,14 +176,14 @@ cleanup_ioremap (void)
 break;
 if (hi->addr_mapped[0])
 {
-iounmap ((void *) (hi->addr_mapped[0]));
-release_mem_region ((long) hi->addr[0], hi->len[0]);
+iounmap((void *)(hi->addr_mapped[0]));
+release_mem_region((long) hi->addr[0], hi->len[0]);
 hi->addr_mapped[0] = 0;
 }
  

[PATCH 2/5] staging: cxt1e1: Fix no spaces at the start of a line in hwprobe.c

2014-02-27 Thread Daeseok Youn

clean up checkpatch.pl warnings:
WARNING: please no spaces at the start of a line in

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/hwprobe.c |  585 +++---
 1 file changed, 293 insertions(+), 292 deletions(-)

diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c
index 5e93580..85040bb 100644
--- a/drivers/staging/cxt1e1/hwprobe.c
+++ b/drivers/staging/cxt1e1/hwprobe.c
@@ -43,347 +43,348 @@ struct net_device * __init c4_add_dev(hdw_info_t *, int, 
unsigned long, unsigned
 struct s_hdw_info hdw_info[MAX_BOARDS];
 
 
-void__init
+void __init
 show_two(hdw_info_t *hi, int brdno)
 {
-ci_t   *ci;
-struct pci_dev *pdev;
-char   *bid;
-char   banner[80];
-charsn[6];
-
-memset(banner, 0, 80); /* clear print buffer */
-
-ci = (ci_t *)(netdev_priv(hi->ndev));
-bid = sbeid_get_bdname(ci);
-switch (hi->promfmt)
-{
-case PROM_FORMAT_TYPE1:
-memcpy(sn, (FLD_TYPE1 *)(hi->mfg_info.pft1.Serial), 6);
-break;
-case PROM_FORMAT_TYPE2:
-memcpy(sn, (FLD_TYPE2 *)(hi->mfg_info.pft2.Serial), 6);
-break;
-default:
-memset(sn, 0, 6);
-break;
-}
-
-sprintf(banner, "%s: %s  S/N %06X, MUSYCC Rev %02X",
-hi->devname, bid,
-((sn[3] << 16) & 0xff) |
-  ((sn[4] << 8) & 0x00ff00) |
-  (sn[5] & 0xff),
- (u_int8_t) hi->revid[0]);
-
-pr_info("%s\n", banner);
-
-pdev = hi->pdev[0];
-pr_info("%s: %s at v/p=%lx/%lx (%02x:%02x.%x) irq %d\n",
-hi->devname, "MUSYCC",
-(unsigned long) hi->addr_mapped[0], hi->addr[0],
-hi->pci_busno, (u_int8_t)PCI_SLOT(pdev->devfn),
-(u_int8_t)PCI_FUNC(pdev->devfn), pdev->irq);
-
-pdev = hi->pdev[1];
-pr_info("%s: %s at v/p=%lx/%lx (%02x:%02x.%x) irq %d\n",
-hi->devname, "EBUS  ",
-(unsigned long) hi->addr_mapped[1], hi->addr[1],
-hi->pci_busno, (u_int8_t)PCI_SLOT(pdev->devfn),
-(u_int8_t)PCI_FUNC(pdev->devfn), pdev->irq);
+   ci_t   *ci;
+   struct pci_dev *pdev;
+   char   *bid;
+   char   banner[80];
+   charsn[6];
+
+   /* clear print buffer */
+   memset(banner, 0, 80);
+
+   ci = (ci_t *)(netdev_priv(hi->ndev));
+   bid = sbeid_get_bdname(ci);
+   switch (hi->promfmt)
+   {
+   case PROM_FORMAT_TYPE1:
+   memcpy(sn, (FLD_TYPE1 *)(hi->mfg_info.pft1.Serial), 6);
+   break;
+   case PROM_FORMAT_TYPE2:
+   memcpy(sn, (FLD_TYPE2 *)(hi->mfg_info.pft2.Serial), 6);
+   break;
+   default:
+   memset(sn, 0, 6);
+   break;
+   }
+
+   sprintf(banner, "%s: %s  S/N %06X, MUSYCC Rev %02X",
+   hi->devname, bid,
+   ((sn[3] << 16) & 0xff) |
+   ((sn[4] << 8) & 0x00ff00) |
+   (sn[5] & 0xff),
+   (u_int8_t) hi->revid[0]);
+
+   pr_info("%s\n", banner);
+
+   pdev = hi->pdev[0];
+   pr_info("%s: %s at v/p=%lx/%lx (%02x:%02x.%x) irq %d\n",
+   hi->devname, "MUSYCC",
+   (unsigned long) hi->addr_mapped[0], hi->addr[0],
+   hi->pci_busno, (u_int8_t) PCI_SLOT(pdev->devfn),
+   (u_int8_t) PCI_FUNC(pdev->devfn), pdev->irq);
+
+   pdev = hi->pdev[1];
+   pr_info("%s: %s at v/p=%lx/%lx (%02x:%02x.%x) irq %d\n",
+   hi->devname, "EBUS  ",
+   (unsigned long) hi->addr_mapped[1], hi->addr[1],
+   hi->pci_busno, (u_int8_t) PCI_SLOT(pdev->devfn),
+   (u_int8_t) PCI_FUNC(pdev->devfn), pdev->irq);
 }
 
 
-void__init
+void __init
 hdw_sn_get(hdw_info_t *hi, int brdno)
 {
-/* obtain hardware EEPROM information */
-longaddr;
+   /* obtain hardware EEPROM information */
+   longaddr;
 
-addr = (long) hi->addr_mapped[1] + EEPROM_OFFSET;
+   addr = (long) hi->addr_mapped[1] + EEPROM_OFFSET;
 
-/* read EEPROM with largest known format size... */
-pmc_eeprom_read_buffer(addr, 0, (char *)hi->mfg_info.data, 
sizeof(FLD_TYPE2));
+   /* read EEPROM with largest known format size... */
+   pmc_eeprom_read_buffer(addr, 0, (char *)hi->mfg_info.data, 
sizeof(FLD_TYPE2));
 
 #if 0
-{
-unsigned char *ucp = (unsigned char *) &hi->mfg_info.data;
-
-pr_info("eeprom[00]:  %02x %02x %02x %02x  %02x %02x %02x %02x\n",
-*(ucp + 0), *(ucp + 1), *(ucp + 2), *(ucp + 3), *(ucp + 4), 
*(ucp + 5), *(ucp + 6), *(ucp + 7));
-

[PATCH 3/5] Staging: cxt1e1: Fix line length over 80 characters in hwprobe.c

2014-02-27 Thread Daeseok Youn

clean up checkpatch.pl warnings:
 WARNING: Line length over 80 characters

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/hwprobe.c |   45 
--
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/cxt1e1/hwprobe.c 
b/drivers/staging/cxt1e1/hwprobe.c
index 85040bb..d6ccbd9 100644
--- a/drivers/staging/cxt1e1/hwprobe.c
+++ b/drivers/staging/cxt1e1/hwprobe.c
@@ -37,7 +37,8 @@ extern int  drvr_state;
 
 /* forward references */
 voidc4_stopwd(ci_t *);
-struct net_device * __init c4_add_dev(hdw_info_t *, int, unsigned long, 
unsigned long, int, int);
+struct net_device * __init c4_add_dev(hdw_info_t *, int, unsigned long,
+ unsigned long, int, int);
 
 
 struct s_hdw_info hdw_info[MAX_BOARDS];
@@ -104,24 +105,31 @@ hdw_sn_get(hdw_info_t *hi, int brdno)
addr = (long) hi->addr_mapped[1] + EEPROM_OFFSET;
 
/* read EEPROM with largest known format size... */
-   pmc_eeprom_read_buffer(addr, 0, (char *)hi->mfg_info.data, 
sizeof(FLD_TYPE2));
+   pmc_eeprom_read_buffer(addr, 0, (char *)hi->mfg_info.data,
+  sizeof(FLD_TYPE2));
 
 #if 0
{
unsigned char *ucp = (unsigned char *) &hi->mfg_info.data;
 
pr_info("eeprom[00]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 0), *(ucp + 1), *(ucp + 2), *(ucp + 3), 
*(ucp + 4), 
*(ucp + 5), *(ucp + 6), *(ucp + 7));
+   *(ucp + 0), *(ucp + 1), *(ucp + 2), *(ucp + 3),
+   *(ucp + 4), *(ucp + 5), *(ucp + 6), *(ucp + 7));
pr_info("eeprom[08]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 8), *(ucp + 9), *(ucp + 10), *(ucp + 
11), *(ucp + 12), 
*(ucp + 13), *(ucp + 14), *(ucp + 15));
+   *(ucp + 8), *(ucp + 9), *(ucp + 10), *(ucp + 11),
+   *(ucp + 12), *(ucp + 13), *(ucp + 14), *(ucp + 15));
pr_info("eeprom[16]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 16), *(ucp + 17), *(ucp + 18), *(ucp + 
19), *(ucp + 
20), *(ucp + 21), *(ucp + 22), *(ucp + 23));
+   *(ucp + 16), *(ucp + 17), *(ucp + 18), *(ucp + 19),
+   *(ucp + 20), *(ucp + 21), *(ucp + 22), *(ucp + 23));
pr_info("eeprom[24]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 24), *(ucp + 25), *(ucp + 26), *(ucp + 
27), *(ucp + 
28), *(ucp + 29), *(ucp + 30), *(ucp + 31));
+   *(ucp + 24), *(ucp + 25), *(ucp + 26), *(ucp + 27),
+   *(ucp + 28), *(ucp + 29), *(ucp + 30), *(ucp + 31));
pr_info("eeprom[32]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 32), *(ucp + 33), *(ucp + 34), *(ucp + 
35), *(ucp + 
36), *(ucp + 37), *(ucp + 38), *(ucp + 39));
+   *(ucp + 32), *(ucp + 33), *(ucp + 34), *(ucp + 35),
+   *(ucp + 36), *(ucp + 37), *(ucp + 38), *(ucp + 39));
pr_info("eeprom[40]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 40), *(ucp + 41), *(ucp + 42), *(ucp + 
43), *(ucp + 
44), *(ucp + 45), *(ucp + 46), *(ucp + 47));
+   *(ucp + 40), *(ucp + 41), *(ucp + 42), *(ucp + 43),
+   *(ucp + 44), *(ucp + 45), *(ucp + 46), *(ucp + 47));
}
 #endif
 #if 0
@@ -230,10 +238,11 @@ c4_hdw_init(struct pci_dev *pdev, int found)
return 0;
}
 
-   if (pdev->bus)  /* obtain bus number */
+   /* obtain bus number */
+   if (pdev->bus)
busno = pdev->bus->number;
else
-   busno = 0;  /* default for system PCI 
inconsistency */
+   busno = 0; /* default for system PCI inconsistency */
slot = pdev->devfn & ~0x07;
 
/*
@@ -246,8 +255,8 @@ c4_hdw_init(struct pci_dev *pdev, int found)
for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++)
{
/*
-* match with board's first found interface, otherwise this is 
first
-* found
+* match with board's first found interface, otherwise this is
+* fisrt found
 */
if ((hi->pci_slot == 0xff) ||   /* new board */
((hi->pci_slot == slot) && (hi->bus == pdev->bus)))
@@ -256,13 +265,14 @@ c4_hdw_init(struct pci_dev *pdev, int found)
if (i == MAX_BOARDS)/* no match in above loop means MAX
 * exceeded */
{
-   pr_warning("exceeded number of allowed devices (&g

[PATCH 4/5] staging: cxt1e1: fix checkpatch error 'assignment in if condition'

2014-02-27 Thread Daeseok Youn

checkpatch.pl error:
 ERROR: do not use assignment in if condition

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/hwprobe.c |   18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c
index d6ccbd9..5f0e05d 100644
--- a/drivers/staging/cxt1e1/hwprobe.c
+++ b/drivers/staging/cxt1e1/hwprobe.c
@@ -142,8 +142,8 @@ hdw_sn_get(hdw_info_t *hi, int brdno)
hi->mfg_info.Serial[5]);
 #endif
 
-   if ((hi->promfmt = pmc_verify_cksum(&hi->mfg_info.data)) == 
PROM_FORMAT_Unk)
-   {
+   hi->promfmt = pmc_verify_cksum(&hi->mfg_info.data);
+   if (hi->promfmt == PROM_FORMAT_Unk) {
/* bad crc, data is suspect */
if (cxt1e1_log_level >= LOG_WARN)
pr_info("%s: EEPROM cksum error\n", hi->devname);
@@ -232,8 +232,8 @@ c4_hdw_init(struct pci_dev *pdev, int found)
unsigned char busno = 0xff;
 
/* our MUSYCC chip supports two functions, 0 & 1 */
-   if ((fun = PCI_FUNC(pdev->devfn)) > 1)
-   {
+   fun = PCI_FUNC(pdev->devfn);
+   if (fun > 1) {
pr_warning("unexpected devfun: 0x%x\n", pdev->devfn);
return 0;
}
@@ -380,11 +380,11 @@ c4hw_attach_all(void)
}
pci_set_master(hi->pdev[0]);
pci_set_master(hi->pdev[1]);
-   if (!(hi->ndev = c4_add_dev(hi, i, (long) hi->addr_mapped[0],
-   (long) hi->addr_mapped[1],
-   hi->pdev[0]->irq,
-   hi->pdev[1]->irq)))
-   {
+   hi->ndev = c4_add_dev(hi, i, (long) hi->addr_mapped[0],
+ (long) hi->addr_mapped[1],
+ hi->pdev[0]->irq,
+ hi->pdev[1]->irq);
+   if (!hi->ndev) {
drvr_state = SBE_DRVR_DOWN;
cleanup_ioremap();
/* NOTE: c4_add_dev() does its own device cleanup */
-- 
1.7.9.5

---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5] staging: cxt1e1: fix checkpatch errors with open brace '{'

2014-02-27 Thread Daeseok Youn

clean up checkpatch.pl error:
 ERROR: that open brace { should be on the previous line

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/hwprobe.c |   62 +++---
 1 file changed, 25 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c
index 5f0e05d..d87a011 100644
--- a/drivers/staging/cxt1e1/hwprobe.c
+++ b/drivers/staging/cxt1e1/hwprobe.c
@@ -58,8 +58,7 @@ show_two(hdw_info_t *hi, int brdno)
 
ci = (ci_t *)(netdev_priv(hi->ndev));
bid = sbeid_get_bdname(ci);
-   switch (hi->promfmt)
-   {
+   switch (hi->promfmt) {
case PROM_FORMAT_TYPE1:
memcpy(sn, (FLD_TYPE1 *)(hi->mfg_info.pft1.Serial), 6);
break;
@@ -159,8 +158,7 @@ prep_hdw_info(void)
hdw_info_t *hi;
int i;
 
-   for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++)
-   {
+   for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) {
hi->pci_busno = 0xff;
hi->pci_slot = 0xff;
hi->pci_pin[0] = 0;
@@ -179,18 +177,15 @@ cleanup_ioremap(void)
hdw_info_t *hi;
int i;
 
-   for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++)
-   {
+   for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) {
if (hi->pci_slot == 0xff)
break;
-   if (hi->addr_mapped[0])
-   {
+   if (hi->addr_mapped[0]) {
iounmap((void *)(hi->addr_mapped[0]));
release_mem_region((long) hi->addr[0], hi->len[0]);
hi->addr_mapped[0] = 0;
}
-   if (hi->addr_mapped[1])
-   {
+   if (hi->addr_mapped[1]) {
iounmap((void *)(hi->addr_mapped[1]));
release_mem_region((long) hi->addr[1], hi->len[1]);
hi->addr_mapped[1] = 0;
@@ -205,8 +200,7 @@ cleanup_devs(void)
hdw_info_t *hi;
int i;
 
-   for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++)
-   {
+   for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) {
if (hi->pci_slot == 0xff || !hi->ndev)
break;
c4_stopwd(netdev_priv(hi->ndev));
@@ -252,8 +246,7 @@ c4_hdw_init(struct pci_dev *pdev, int found)
 * element, identified by "slot==(0xff)".  The second part of a board's
 * functionality will match the previously loaded slot/busno.
 */
-   for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++)
-   {
+   for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) {
/*
 * match with board's first found interface, otherwise this is
 * fisrt found
@@ -262,17 +255,19 @@ c4_hdw_init(struct pci_dev *pdev, int found)
((hi->pci_slot == slot) && (hi->bus == pdev->bus)))
break;  /* found for-loop exit */
}
-   if (i == MAX_BOARDS)/* no match in above loop means MAX
-* exceeded */
-   {
+
+   /* no match in above loop means MAX exceeded */
+   if (i == MAX_BOARDS) {
pr_warning("exceeded number of allowed devices (>%d)?\n",
   MAX_BOARDS);
return 0;
}
+
if (pdev->bus)
hi->pci_busno = pdev->bus->number;
else
hi->pci_busno = 0; /* default for system PCI inconsistency */
+
hi->pci_slot = slot;
pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &hi->pci_pin[fun]);
pci_read_config_byte(pdev, PCI_REVISION_ID, &hi->revid[fun]);
@@ -311,43 +306,38 @@ c4hw_attach_all(void)
/*** scan PCI bus for all possible boards */
while ((pdev = pci_get_device(PCI_VENDOR_ID_CONEXANT,
  PCI_DEVICE_ID_CN8474,
- pdev)))
-   {
+ pdev))) {
if (c4_hdw_init(pdev, found))
found++;
}
-   if (!found)
-   {
+
+   if (!found) {
pr_warning("No boards found\n");
return -ENODEV;
}
+
/* sanity check for consistent hardware found */
-   for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++)
-   {
-   if (hi->pci_slot != 0xff && (!hi->addr[0] || !hi->addr[1]))
-   {
+   for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) {
+   if (hi->pci_slot != 0xff && (!hi->addr[0] || !hi->addr[1])) {
pr_warning("%s:

Re: [PATCH 3/5] Staging: cxt1e1: Fix line length over 80 characters in hwprobe.c

2014-02-27 Thread DaeSeok Youn
OK. sorry.
I will send again.

Thanks.
Daeseok Youn

2014-02-28 16:28 GMT+09:00 Dan Carpenter :
> On Fri, Feb 28, 2014 at 04:12:22PM +0900, Daeseok Youn wrote:
>>
>> clean up checkpatch.pl warnings:
>>  WARNING: Line length over 80 characters
>>
>
> Patch is white space dammaged and doesn't apply.
>
> regards,
> dan carpenter
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5 v2] Staging: cxt1e1: Fix line length over 80 characters in hwprobe.c

2014-02-27 Thread Daeseok Youn

clean up checkpatch.pl warnings:
 WARNING: Line length over 80 characters

Signed-off-by: Daeseok Youn 
---
 drivers/staging/cxt1e1/hwprobe.c |   45 --
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c
index 85040bb..d6ccbd9 100644
--- a/drivers/staging/cxt1e1/hwprobe.c
+++ b/drivers/staging/cxt1e1/hwprobe.c
@@ -37,7 +37,8 @@ extern int  drvr_state;
 
 /* forward references */
 voidc4_stopwd(ci_t *);
-struct net_device * __init c4_add_dev(hdw_info_t *, int, unsigned long, 
unsigned long, int, int);
+struct net_device * __init c4_add_dev(hdw_info_t *, int, unsigned long,
+ unsigned long, int, int);
 
 
 struct s_hdw_info hdw_info[MAX_BOARDS];
@@ -104,24 +105,31 @@ hdw_sn_get(hdw_info_t *hi, int brdno)
addr = (long) hi->addr_mapped[1] + EEPROM_OFFSET;
 
/* read EEPROM with largest known format size... */
-   pmc_eeprom_read_buffer(addr, 0, (char *)hi->mfg_info.data, 
sizeof(FLD_TYPE2));
+   pmc_eeprom_read_buffer(addr, 0, (char *)hi->mfg_info.data,
+  sizeof(FLD_TYPE2));
 
 #if 0
{
unsigned char *ucp = (unsigned char *) &hi->mfg_info.data;
 
pr_info("eeprom[00]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 0), *(ucp + 1), *(ucp + 2), *(ucp + 3), 
*(ucp + 4), *(ucp + 5), *(ucp + 6), *(ucp + 7));
+   *(ucp + 0), *(ucp + 1), *(ucp + 2), *(ucp + 3),
+   *(ucp + 4), *(ucp + 5), *(ucp + 6), *(ucp + 7));
pr_info("eeprom[08]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 8), *(ucp + 9), *(ucp + 10), *(ucp + 
11), *(ucp + 12), *(ucp + 13), *(ucp + 14), *(ucp + 15));
+   *(ucp + 8), *(ucp + 9), *(ucp + 10), *(ucp + 11),
+   *(ucp + 12), *(ucp + 13), *(ucp + 14), *(ucp + 15));
pr_info("eeprom[16]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 16), *(ucp + 17), *(ucp + 18), *(ucp + 
19), *(ucp + 20), *(ucp + 21), *(ucp + 22), *(ucp + 23));
+   *(ucp + 16), *(ucp + 17), *(ucp + 18), *(ucp + 19),
+   *(ucp + 20), *(ucp + 21), *(ucp + 22), *(ucp + 23));
pr_info("eeprom[24]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 24), *(ucp + 25), *(ucp + 26), *(ucp + 
27), *(ucp + 28), *(ucp + 29), *(ucp + 30), *(ucp + 31));
+   *(ucp + 24), *(ucp + 25), *(ucp + 26), *(ucp + 27),
+   *(ucp + 28), *(ucp + 29), *(ucp + 30), *(ucp + 31));
pr_info("eeprom[32]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 32), *(ucp + 33), *(ucp + 34), *(ucp + 
35), *(ucp + 36), *(ucp + 37), *(ucp + 38), *(ucp + 39));
+   *(ucp + 32), *(ucp + 33), *(ucp + 34), *(ucp + 35),
+   *(ucp + 36), *(ucp + 37), *(ucp + 38), *(ucp + 39));
pr_info("eeprom[40]:  %02x %02x %02x %02x  %02x %02x %02x 
%02x\n",
-   *(ucp + 40), *(ucp + 41), *(ucp + 42), *(ucp + 
43), *(ucp + 44), *(ucp + 45), *(ucp + 46), *(ucp + 47));
+   *(ucp + 40), *(ucp + 41), *(ucp + 42), *(ucp + 43),
+   *(ucp + 44), *(ucp + 45), *(ucp + 46), *(ucp + 47));
}
 #endif
 #if 0
@@ -230,10 +238,11 @@ c4_hdw_init(struct pci_dev *pdev, int found)
return 0;
}
 
-   if (pdev->bus)  /* obtain bus number */
+   /* obtain bus number */
+   if (pdev->bus)
busno = pdev->bus->number;
else
-   busno = 0;  /* default for system PCI 
inconsistency */
+   busno = 0; /* default for system PCI inconsistency */
slot = pdev->devfn & ~0x07;
 
/*
@@ -246,8 +255,8 @@ c4_hdw_init(struct pci_dev *pdev, int found)
for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++)
{
/*
-* match with board's first found interface, otherwise this is 
first
-* found
+* match with board's first found interface, otherwise this is
+* fisrt found
 */
if ((hi->pci_slot == 0xff) ||   /* new board */
((hi->pci_slot == slot) && (hi->bus == pdev->bus)))
@@ -256,13 +265,14 @@ c4_hdw_init(struct pci_dev *pdev, int found)
if (i == MAX_BOARDS)/* no match in above loop means MAX
 * exceeded */
{
-   pr_warning("exceeded number of allowed devices (&g

  1   2   3   4   5   6   >